diff options
author | redmatrix <git@macgirvin.com> | 2016-08-04 18:56:05 -0700 |
---|---|---|
committer | redmatrix <git@macgirvin.com> | 2016-08-04 18:56:05 -0700 |
commit | eeabf514eab20523b847c38cf5befb7f040b7d72 (patch) | |
tree | f94ac0ec7262d6d86c93c2ea74b8708fbfacb099 | |
parent | 92862f93f31beb009247144bae5d8b0a58b562b5 (diff) | |
download | volse-hubzilla-eeabf514eab20523b847c38cf5befb7f040b7d72.tar.gz volse-hubzilla-eeabf514eab20523b847c38cf5befb7f040b7d72.tar.bz2 volse-hubzilla-eeabf514eab20523b847c38cf5befb7f040b7d72.zip |
minor cleanup on ratings - no real functional changes at this time
-rw-r--r-- | Zotlabs/Module/Connedit.php | 30 | ||||
-rw-r--r-- | Zotlabs/Module/Rate.php | 2 |
2 files changed, 20 insertions, 12 deletions
diff --git a/Zotlabs/Module/Connedit.php b/Zotlabs/Module/Connedit.php index 93ee30999..8fa6f0e96 100644 --- a/Zotlabs/Module/Connedit.php +++ b/Zotlabs/Module/Connedit.php @@ -152,11 +152,16 @@ class Connedit extends \Zotlabs\Web\Controller { $new_friend = false; + // only store a record and notify the directory if the rating changed + if(! $is_self) { $signed = $orig_record[0]['abook_xchan'] . '.' . $rating . '.' . $rating_text; - $sig = base64url_encode(rsa_sign($signed,$channel['channel_prvkey'])); + + $rated = ((intval($rating) || strlen($rating_text)) ? true : false); + + $record = 0; $z = q("select * from xlink where xlink_xchan = '%s' and xlink_link = '%s' and xlink_static = 1 limit 1", dbesc($channel['channel_hash']), @@ -164,17 +169,20 @@ class Connedit extends \Zotlabs\Web\Controller { ); if($z) { - $record = $z[0]['xlink_id']; - $w = q("update xlink set xlink_rating = '%d', xlink_rating_text = '%s', xlink_sig = '%s', xlink_updated = '%s' - where xlink_id = %d", - intval($rating), - dbesc($rating_text), - dbesc($sig), - dbesc(datetime_convert()), - intval($record) - ); + if(($z[0]['xlink_rating'] != $rating) || ($z[0]['xlink_rating_text'] != $rating_text)) { + $record = $z[0]['xlink_id']; + $w = q("update xlink set xlink_rating = '%d', xlink_rating_text = '%s', xlink_sig = '%s', xlink_updated = '%s' + where xlink_id = %d", + intval($rating), + dbesc($rating_text), + dbesc($sig), + dbesc(datetime_convert()), + intval($record) + ); + } } - else { + elseif($rated) { + // only create a record if there's something to save $w = q("insert into xlink ( xlink_xchan, xlink_link, xlink_rating, xlink_rating_text, xlink_sig, xlink_updated, xlink_static ) values ( '%s', '%s', %d, '%s', '%s', '%s', 1 ) ", dbesc($channel['channel_hash']), dbesc($orig_record[0]['abook_xchan']), diff --git a/Zotlabs/Module/Rate.php b/Zotlabs/Module/Rate.php index da23b840e..2f769b36b 100644 --- a/Zotlabs/Module/Rate.php +++ b/Zotlabs/Module/Rate.php @@ -43,7 +43,7 @@ class Rate extends \Zotlabs\Web\Controller { } - function post() { + function post() { if(! local_channel()) return; |