break;
}
-
logger('like: verb ' . $verb . ' item ' . $item_id);
-
$r = q("SELECT * FROM `item` WHERE `id` = '%s' OR `uri` = '%s' LIMIT 1",
dbesc($item_id),
dbesc($item_id)
$owner_uid = $item['uid'];
- if(! can_write_wall($a,$owner_uid)) {
+ if (! can_write_wall($a,$owner_uid)) {
return false;
}
if (! dbm::is_result($r)) {
return false;
}
- if(! $r[0]['self'])
+ if (! $r[0]['self']) {
$remote_owner = $r[0];
+ }
}
// this represents the post owner on this system.
WHERE `contact`.`self` = 1 AND `contact`.`uid` = %d LIMIT 1",
intval($owner_uid)
);
- if (dbm::is_result($r))
+ if (dbm::is_result($r)) {
$owner = $r[0];
+ }
- if(! $owner) {
+ if (! $owner) {
logger('like: no owner');
return false;
}
- if(! $remote_owner)
+ if (! $remote_owner) {
$remote_owner = $owner;
-
+ }
// This represents the person posting
- if((local_user()) && (local_user() == $owner_uid)) {
+ if ((local_user()) && (local_user() == $owner_uid)) {
$contact = $owner;
- }
- else {
+ } else {
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($_SESSION['visitor_id']),
intval($owner_uid)
);
- if (dbm::is_result($r))
+ if (dbm::is_result($r)) {
$contact = $r[0];
+ }
}
- if(! $contact) {
+ if (! $contact) {
return false;
}
// event participation are essentially radio toggles. If you make a subsequent choice,
// we need to eradicate your first choice.
- if($activity === ACTIVITY_ATTEND || $activity === ACTIVITY_ATTENDNO || $activity === ACTIVITY_ATTENDMAYBE) {
+ if ($activity === ACTIVITY_ATTEND || $activity === ACTIVITY_ATTENDNO || $activity === ACTIVITY_ATTENDMAYBE) {
$verbs = " '" . dbesc(ACTIVITY_ATTEND) . "','" . dbesc(ACTIVITY_ATTENDNO) . "','" . dbesc(ACTIVITY_ATTENDMAYBE) . "' ";
}
$uri = item_new_uri($a->get_hostname(),$owner_uid);
$post_type = (($item['resource-id']) ? t('photo') : t('status'));
- if($item['object-type'] === ACTIVITY_OBJ_EVENT)
+ if ($item['object-type'] === ACTIVITY_OBJ_EVENT) {
$post_type = t('event');
+ }
$objtype = (($item['resource-id']) ? ACTIVITY_OBJ_IMAGE : ACTIVITY_OBJ_NOTE );
$link = xmlify('<link rel="alternate" type="text/html" href="' . App::get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . '" />' . "\n") ;
$body = $item['body'];
<content>$body</content>
</object>
EOT;
- if($verb === 'like')
+ if ($verb === 'like') {
$bodyverb = t('%1$s likes %2$s\'s %3$s');
- if($verb === 'dislike')
+ }
+ if ($verb === 'dislike') {
$bodyverb = t('%1$s doesn\'t like %2$s\'s %3$s');
- if($verb === 'attendyes')
+ }
+ if ($verb === 'attendyes') {
$bodyverb = t('%1$s is attending %2$s\'s %3$s');
- if($verb === 'attendno')
+ }
+ if ($verb === 'attendno') {
$bodyverb = t('%1$s is not attending %2$s\'s %3$s');
- if($verb === 'attendmaybe')
+ }
+ if ($verb === 'attendmaybe') {
$bodyverb = t('%1$s may attend %2$s\'s %3$s');
+ }
- if(! isset($bodyverb))
- return false;
+ if (! isset($bodyverb)) {
+ return false;
+ }
+ $ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]';
+ $alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]';
+ $plink = '[url=' . App::get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . ']' . $post_type . '[/url]';
+
+ /// @TODO Or rewrite this to multi-line initialization of the array?
$arr = array();
$arr['guid'] = get_guid(32);
$arr['author-name'] = $contact['name'];
$arr['author-link'] = $contact['url'];
$arr['author-avatar'] = $contact['thumb'];
-
- $ulink = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]';
- $alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]';
- $plink = '[url=' . App::get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['id'] . ']' . $post_type . '[/url]';
$arr['body'] = sprintf( $bodyverb, $ulink, $alink, $plink );
-
$arr['verb'] = $activity;
$arr['object-type'] = $objtype;
$arr['object'] = $obj;
$post_id = item_store($arr);
- if(! $item['visible']) {
+ if (! $item['visible']) {
$r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d AND `uid` = %d",
intval($item['id']),
intval($owner_uid)
// Save the author information for the like in case we need to relay to Diaspora
- diaspora::store_like_signature($contact, $post_id);
+ Diaspora::store_like_signature($contact, $post_id);
$arr['id'] = $post_id;