missing year on profile birthday input, some optimisations to stats

This commit is contained in:
zotlabs 2018-04-02 13:32:10 -07:00
parent bcffb6cf55
commit 9a1f051068
3 changed files with 17 additions and 39 deletions

View File

@ -125,10 +125,16 @@ function datetime_convert($from = 'UTC', $to = 'UTC', $s = 'now', $fmt = "Y-m-d
*/ */
function dob($dob) { function dob($dob) {
$y = substr($dob,0,4);
if((! ctype_digit($y)) || ($y < 1900))
$ignore_year = true;
else
$ignore_year = false;
if ($dob === '0000-00-00' || $dob === '') if ($dob === '0000-00-00' || $dob === '')
$value = ''; $value = '';
else else
$value = (($year) ? datetime_convert('UTC','UTC',$dob,'Y-m-d') : datetime_convert('UTC','UTC',$dob,'m-d')); $value = (($ignore_year) ? datetime_convert('UTC','UTC',$dob,'m-d') : datetime_convert('UTC','UTC',$dob,'Y-m-d'));
$o = replace_macros(get_markup_template("field_input.tpl"), [ $o = replace_macros(get_markup_template("field_input.tpl"), [
'$field' => [ 'dob', t('Birthday'), $value, ((intval($value)) ? t('Age: ') . age($value,App::$user['timezone'],App::$user['timezone']) : ''), '', 'placeholder="' . t('YYYY-MM-DD or MM-DD') .'"' ] '$field' => [ 'dob', t('Birthday'), $value, ((intval($value)) ? t('Age: ') . age($value,App::$user['timezone'],App::$user['timezone']) : ''), '', 'placeholder="' . t('YYYY-MM-DD or MM-DD') .'"' ]

View File

@ -2551,9 +2551,7 @@ function tag_deliver($uid, $item_id) {
$j_obj = json_decode($item['obj'],true); $j_obj = json_decode($item['obj'],true);
logger('tag_deliver: tag object: ' . print_r($j_obj,true), LOGGER_DATA); logger('tag_deliver: tag object: ' . print_r($j_obj,true), LOGGER_DATA);
if($j_obj && $j_obj['id'] && $j_obj['title']) { if($j_obj && $j_obj['id'] && $j_obj['title']) {
if(is_array($j_obj['link'])) //COMMUNITYTAG
$taglink = get_rel_link($j_obj['link'],'alternate');
store_item_tag($u[0]['channel_id'],$p[0]['id'],TERM_OBJ_POST,TERM_COMMUNITYTAG,$j_obj['title'],$j_obj['id']); store_item_tag($u[0]['channel_id'],$p[0]['id'],TERM_OBJ_POST,TERM_COMMUNITYTAG,$j_obj['title'],$j_obj['id']);
$x = q("update item set edited = '%s', received = '%s', changed = '%s' where mid = '%s' and uid = %d", $x = q("update item set edited = '%s', received = '%s', changed = '%s' where mid = '%s' and uid = %d",
dbesc(datetime_convert()), dbesc(datetime_convert()),

View File

@ -17,23 +17,10 @@ function update_channels_active_halfyear_stat() {
db_utcnow(), db_quoteinterval('6 MONTH') db_utcnow(), db_quoteinterval('6 MONTH')
); );
if($r) { if($r) {
$s = ''; set_config('system','channels_active_halfyear_stat',count($r));
foreach($r as $rr) {
if($s)
$s .= ',';
$s .= intval($rr['channel_id']);
} }
$x = q("select uid from item where uid in ( $s ) and item_wall = 1 and created > %s - INTERVAL %s group by uid", else {
db_utcnow(), db_quoteinterval('6 MONTH') set_config('system','channels_active_halfyear_stat','0');
);
if($x) {
$channels_active_halfyear_stat = count($x);
set_config('system','channels_active_halfyear_stat',$channels_active_halfyear_stat);
} else {
set_config('system','channels_active_halfyear_stat',0);
}
} else {
set_config('system','channels_active_halfyear_stat',0);
} }
} }
@ -43,28 +30,15 @@ function update_channels_active_monthly_stat() {
db_utcnow(), db_quoteinterval('1 MONTH') db_utcnow(), db_quoteinterval('1 MONTH')
); );
if($r) { if($r) {
$s = ''; set_config('system','channels_active_monthly_stat',count($r));
foreach($r as $rr) {
if($s)
$s .= ',';
$s .= intval($rr['channel_id']);
} }
$x = q("select uid from item where uid in ( $s ) and item_wall = 1 and created > %s - INTERVAL %s group by uid", else {
db_utcnow(), db_quoteinterval('1 MONTH') set_config('system','channels_active_monthly_stat','0');
);
if($x) {
$channels_active_monthly_stat = count($x);
set_config('system','channels_active_monthly_stat',$channels_active_monthly_stat);
} else {
set_config('system','channels_active_monthly_stat',0);
}
} else {
set_config('system','channels_active_monthly_stat',0);
} }
} }
function update_local_posts_stat() { function update_local_posts_stat() {
$posts = q("SELECT COUNT(*) AS local_posts FROM item WHERE item_wall = 1 "); $posts = q("SELECT COUNT(*) AS local_posts FROM item WHERE item_wall = 1 and id = parent");
if (is_array($posts)) { if (is_array($posts)) {
$local_posts_stat = intval($posts[0]["local_posts"]); $local_posts_stat = intval($posts[0]["local_posts"]);
set_config('system','local_posts_stat',$local_posts_stat); set_config('system','local_posts_stat',$local_posts_stat);