diff options
-rw-r--r-- | boot.php | 25 | ||||
-rw-r--r-- | include/dir_fns.php | 3 | ||||
-rw-r--r-- | include/zot.php | 42 | ||||
-rw-r--r-- | install/database.sql | 5 | ||||
-rw-r--r-- | install/update.php | 13 | ||||
-rw-r--r-- | mod/zfinger.php | 20 | ||||
-rw-r--r-- | version.inc | 2 |
7 files changed, 94 insertions, 16 deletions
@@ -16,7 +16,7 @@ require_once('include/features.php'); define ( 'FRIENDICA_PLATFORM', 'Friendica Red'); define ( 'FRIENDICA_VERSION', trim(file_get_contents('version.inc')) . 'R'); define ( 'ZOT_REVISION', 1 ); -define ( 'DB_UPDATE_VERSION', 1010 ); +define ( 'DB_UPDATE_VERSION', 1011 ); define ( 'EOL', '<br />' . "\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); @@ -1722,6 +1722,27 @@ if(! function_exists('current_theme_url')) { } } +function z_birthday($dob,$tz,$format="Y-m-d H:i:s") { + + if(! strlen($tz)) + $tz = 'UTC'; + + $tmp_dob = substr($dob,5); + if(intval($tmp_dob)) { + $y = datetime_convert($tz,$tz,'now','Y'); + $bd = $y . '-' . $tmp_dob . ' 00:00'; + $t_dob = strtotime($bd); + $now = strtotime(datetime_convert($tz,$tz,'now')); + if($t_dob < $now) + $bd = $y + 1 . '-' . $tmp_dob . ' 00:00'; + $birthday = datetime_convert($tz,'UTC',$bd,$format); + } + + return $birthday; + +} + + if(! function_exists('feed_birthday')) { function feed_birthday($uid,$tz) { @@ -1763,7 +1784,7 @@ if(! function_exists('feed_birthday')) { $now = strtotime(datetime_convert($tz,$tz,'now')); if($t_dob < $now) $bd = $y + 1 . '-' . $tmp_dob . ' 00:00'; - $birthday = datetime_convert($tz,'UTC',$bd,ATOM_TIME); + $birthday = datetime_convert($tz,'UTC',$bd,$format); } } diff --git a/include/dir_fns.php b/include/dir_fns.php index 2c2694782..904d27189 100644 --- a/include/dir_fns.php +++ b/include/dir_fns.php @@ -46,6 +46,9 @@ function syncdirs($uid) { $r = q("delete from xprof where xprof_hash = '%s' limit 1", dbesc($hash) ); + $r = q("delete from xtag where xtag_hash = '%s' limit 1", + dbesc($hash) + ); } } diff --git a/include/zot.php b/include/zot.php index 0bd575b94..001088f6a 100644 --- a/include/zot.php +++ b/include/zot.php @@ -313,13 +313,15 @@ function zot_refresh($them,$channel = null) { $r = q("delete from xprof where xprof_hash = '%s' limit 1", dbesc($x['hash']) ); + $r = q("delete from xtag where xtag_hash = '%s' limit 1", + dbesc($x['hash']) + ); } } } return true; } return false; - } @@ -926,7 +928,9 @@ function process_mail_delivery($sender,$arr,$deliveries) { } function process_profile_delivery($sender,$arr,$deliveries) { - // deliveries is irrelevant + + // deliveries is irrelevant, what to do about birthday notification....? + import_directory_profile($sender['hash'],$arr); } @@ -950,6 +954,7 @@ function import_directory_profile($hash,$profile) { $clean = array(); if(array_key_exists('keywords',$profile) and is_array($profile['keywords'])) { + import_directory_keywords($hash,$profile['keywords']); foreach($profile['keywords'] as $kw) { $kw = trim(htmlentities($kw,ENT_COMPAT,'UTF-8')); } @@ -1007,3 +1012,36 @@ function import_directory_profile($hash,$profile) { return; } +function import_directory_keywords($hash,$keywords) { + + $existing = array(); + $r = q("select * from xtag where xtag_hash = '%s'", + dbesc($hash) + ); + + if($r) { + foreach($r as $rr) + $existing[] = $rr['xtag_term']; + } + + $clean = array(); + foreach($keywords as $kw) { + $kw = trim(htmlentities($kw,ENT_COMPAT,'UTF-8')); + $clean[] = $kw; + } + + foreach($existing as $x) { + if(! in_array($x,$clean)) + $r = q("delete from xtag where xtag_hash = '%s' and xtag_term = '%s' limit 1", + dbesc($hash), + dbesc($x) + ); + } + foreach($clean as $x) { + if(! in_array($x,$existing)) + $r = q("insert int xtag ( xtag_hash, xtag_term) values ( '%s' ,'%s' )", + dbesc($hash), + dbesc($x) + ); + } +}
\ No newline at end of file diff --git a/install/database.sql b/install/database.sql index 817091df5..02bbb5f0f 100644 --- a/install/database.sql +++ b/install/database.sql @@ -17,6 +17,7 @@ CREATE TABLE IF NOT EXISTS `abook` ( `abook_created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `abook_updated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `abook_connnected` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `abook_dob` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `abook_flags` int(11) NOT NULL DEFAULT '0', `abook_profile` char(64) NOT NULL DEFAULT '', PRIMARY KEY (`abook_id`), @@ -30,7 +31,8 @@ CREATE TABLE IF NOT EXISTS `abook` ( KEY `abook_updated` (`abook_updated`), KEY `abook_connnected` (`abook_connnected`), KEY `abook_flags` (`abook_flags`), - KEY `abook_profile` (`abook_profile`) + KEY `abook_profile` (`abook_profile`), + KEY `abook_dob` (`abook_dob`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `account` ( @@ -641,6 +643,7 @@ CREATE TABLE IF NOT EXISTS `profile` ( `name` char(255) NOT NULL, `pdesc` char(255) NOT NULL, `dob` char(32) NOT NULL DEFAULT '0000-00-00', + `dob_tz` char(255) NOT NULL DEFAULT 'UTC', `address` char(255) NOT NULL, `locality` char(255) NOT NULL, `region` char(255) NOT NULL, diff --git a/install/update.php b/install/update.php index 4c5e4d3a6..e8f52273e 100644 --- a/install/update.php +++ b/install/update.php @@ -1,6 +1,6 @@ <?php -define( 'UPDATE_VERSION' , 1010 ); +define( 'UPDATE_VERSION' , 1011 ); /** * @@ -169,3 +169,14 @@ function update_r1009() { } +function update_r1010() { + $r = q("ALTER TABLE `abook` ADD `abook_dob` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `abook_connnected` , +ADD INDEX ( `abook_dob` )"); + + $r2 = q("ALTER TABLE `profile` ADD `dob_tz` CHAR( 255 ) NOT NULL DEFAULT 'UTC' AFTER `dob`"); + + if($r && $r2) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} + diff --git a/mod/zfinger.php b/mod/zfinger.php index 72f680c1c..d9fe91765 100644 --- a/mod/zfinger.php +++ b/mod/zfinger.php @@ -81,15 +81,17 @@ function zfinger_init(&$a) { $profile = array(); if($p) { - $profile['description'] = $p[0]['pdesc']; - $profile['birthday'] = $p[0]['dob']; - $profile['gender'] = $p[0]['gender']; - $profile['marital'] = $p[0]['marital']; - $profile['sexual'] = $p[0]['sexual']; - $profile['locale'] = $p[0]['locality']; - $profile['region'] = $p[0]['region']; - $profile['postcode'] = $p[0]['postal_code']; - $profile['country'] = $p[0]['country_name']; + $profile['description'] = $p[0]['pdesc']; + $profile['birthday'] = $p[0]['dob']; + if($profile['birthday'] != '0000-00-00') + $profile['next_birthday'] = z_birthday($p[0]['dob'],$e['channel_timezone']); + $profile['gender'] = $p[0]['gender']; + $profile['marital'] = $p[0]['marital']; + $profile['sexual'] = $p[0]['sexual']; + $profile['locale'] = $p[0]['locality']; + $profile['region'] = $p[0]['region']; + $profile['postcode'] = $p[0]['postal_code']; + $profile['country'] = $p[0]['country_name']; if($p[0]['keywords']) { $tags = array(); $k = explode(' ',$p[0]['keywords']); diff --git a/version.inc b/version.inc index a5ce5d4da..2851cd0e4 100644 --- a/version.inc +++ b/version.inc @@ -1 +1 @@ -2012-12-26.181 +2012-12-27.182 |