diff options
-rw-r--r-- | boot.php | 2 | ||||
-rw-r--r-- | include/socgraph.php | 15 | ||||
-rw-r--r-- | install/database.sql | 4 | ||||
-rw-r--r-- | install/update.php | 9 | ||||
-rw-r--r-- | mod/poco.php | 12 |
5 files changed, 29 insertions, 13 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', 1028 ); +define ( 'DB_UPDATE_VERSION', 1029 ); define ( 'EOL', '<br />' . "\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); diff --git a/include/socgraph.php b/include/socgraph.php index f6be92657..0d9ae3e6c 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -37,13 +37,12 @@ function poco_load($xchan = null,$url = null) { } - $url = $url . '?f=&fields=displayName,hash,urls,photos' ; + $url = $url . '?f=&fields=displayName,hash,urls,photos,rating' ; logger('poco_load: ' . $url, LOGGER_DEBUG); $s = z_fetch_url($url); - if(! $s['success']) { logger('poco_load: returns ' . print_r($s,true)); return; @@ -67,9 +66,11 @@ function poco_load($xchan = null,$url = null) { $address = ''; $name = ''; $hash = ''; + $rating = 0; - $name = $entry['displayName']; - $hash = $entry['hash']; + $name = $entry['displayName']; + $hash = $entry['hash']; + $rating = ((array_key_exists('rating',$entry)) ? intval($entry['rating']) : 0); if(x($entry,'urls') && is_array($entry['urls'])) { foreach($entry['urls'] as $url) { @@ -121,15 +122,17 @@ function poco_load($xchan = null,$url = null) { dbesc($hash) ); if(! $r) { - q("insert into xlink ( xlink_xchan, xlink_link, xlink_updated ) values ( '%s', '%s', '%s' ) ", + q("insert into xlink ( xlink_xchan, xlink_link, xlink_rating, xlink_updated ) values ( '%s', '%s', %d, '%s' ) ", dbesc($xchan), dbesc($hash), + intval($rating), dbesc(datetime_convert()) ); } else { - q("update xlink set xlink_updated = '%s' where xlink_id = %d limit 1", + q("update xlink set xlink_updated = '%s', rating = %d where xlink_id = %d limit 1", dbesc(datetime_convert()), + intval($rating), intval($r[0]['xlink_id']) ); } diff --git a/install/database.sql b/install/database.sql index 03279d6aa..3deb96c21 100644 --- a/install/database.sql +++ b/install/database.sql @@ -892,11 +892,13 @@ CREATE TABLE IF NOT EXISTS `xlink` ( `xlink_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `xlink_xchan` char(255) NOT NULL DEFAULT '', `xlink_link` char(255) NOT NULL DEFAULT '', + `xlink_rating` int(11) NOT NULL DEFAULT '0', `xlink_updated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (`xlink_id`), KEY `xlink_xchan` (`xlink_xchan`), KEY `xlink_link` (`xlink_link`), - KEY `xlink_updated` (`xlink_updated`) + KEY `xlink_updated` (`xlink_updated`), + KEY `xlink_rating` (`xlink_rating`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `xprof` ( diff --git a/install/update.php b/install/update.php index 301d6e06f..7cdeb0e89 100644 --- a/install/update.php +++ b/install/update.php @@ -1,6 +1,6 @@ <?php -define( 'UPDATE_VERSION' , 1028 ); +define( 'UPDATE_VERSION' , 1029 ); /** * @@ -350,3 +350,10 @@ ADD INDEX ( `abook_rating` )"); return UPDATE_FAILED; } +function update_r1028() { + $r = q"ALTER TABLE `xlink` ADD `xlink_rating` INT NOT NULL DEFAULT '0' AFTER `xlink_link` , +ADD INDEX ( `xlink_rating` ) "); + if($r) + return UPDATE_SUCCESS; + return UPDATE_FAILED; +} diff --git a/mod/poco.php b/mod/poco.php index 3ebc5ece4..a5808b7db 100644 --- a/mod/poco.php +++ b/mod/poco.php @@ -126,10 +126,8 @@ function poco_init(&$a) { 'displayName' => false, 'urls' => false, 'preferredUsername' => false, - 'photos' => false - - - + 'photos' => false, + 'rating' => false ); if((! x($_GET,'fields')) || ($_GET['fields'] === '@all')) @@ -165,6 +163,12 @@ function poco_init(&$a) { $entry['preferredUsername'] = substr($rr['xchan_addr'],0,strpos($rr['xchan_addr'],'@')); if($fields_ret['photos']) $entry['photos'] = array(array('value' => $rr['xchan_photo_l'], 'mimetype' => $rr['xchan_photo_mimetype'], 'type' => 'profile')); + if($fields_ret['rating']) { + $entry['rating'] = ((array_key_exists('abook_rating',$rr)) ? array(intval($rr['abook_rating'])) : 0); + // maybe this should be a composite calculated rating in $system_mode + if($system_mode) + $entry['rating'] = 0; + } $ret['entry'][] = $entry; } } |