minor cleanup on ratings - no real functional changes at this time

This commit is contained in:
redmatrix 2016-08-04 18:56:05 -07:00
parent 92862f93f3
commit eeabf514ea
2 changed files with 20 additions and 12 deletions

View File

@ -152,29 +152,37 @@ class Connedit extends \Zotlabs\Web\Controller {
$new_friend = false; $new_friend = false;
// only store a record and notify the directory if the rating changed
if(! $is_self) { if(! $is_self) {
$signed = $orig_record[0]['abook_xchan'] . '.' . $rating . '.' . $rating_text; $signed = $orig_record[0]['abook_xchan'] . '.' . $rating . '.' . $rating_text;
$sig = base64url_encode(rsa_sign($signed,$channel['channel_prvkey'])); $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", $z = q("select * from xlink where xlink_xchan = '%s' and xlink_link = '%s' and xlink_static = 1 limit 1",
dbesc($channel['channel_hash']), dbesc($channel['channel_hash']),
dbesc($orig_record[0]['abook_xchan']) dbesc($orig_record[0]['abook_xchan'])
); );
if($z) { if($z) {
$record = $z[0]['xlink_id']; if(($z[0]['xlink_rating'] != $rating) || ($z[0]['xlink_rating_text'] != $rating_text)) {
$w = q("update xlink set xlink_rating = '%d', xlink_rating_text = '%s', xlink_sig = '%s', xlink_updated = '%s' $record = $z[0]['xlink_id'];
where xlink_id = %d", $w = q("update xlink set xlink_rating = '%d', xlink_rating_text = '%s', xlink_sig = '%s', xlink_updated = '%s'
intval($rating), where xlink_id = %d",
dbesc($rating_text), intval($rating),
dbesc($sig), dbesc($rating_text),
dbesc(datetime_convert()), dbesc($sig),
intval($record) 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 ) ", $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($channel['channel_hash']),
dbesc($orig_record[0]['abook_xchan']), dbesc($orig_record[0]['abook_xchan']),

View File

@ -43,7 +43,7 @@ class Rate extends \Zotlabs\Web\Controller {
} }
function post() { function post() {
if(! local_channel()) if(! local_channel())
return; return;