<?php
-
+/**
+ * @file include/like.php
+ */
use Friendica\App;
+use Friendica\Core\Addon;
+use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
switch ($verb) {
case 'like':
- $bodyverb = t('%1$s likes %2$s\'s %3$s');
+ $bodyverb = L10n::t('%1$s likes %2$s\'s %3$s');
$activity = ACTIVITY_LIKE;
break;
case 'unlike':
- $bodyverb = t('%1$s doesn\'t like %2$s\'s %3$s');
+ $bodyverb = L10n::t('%1$s doesn\'t like %2$s\'s %3$s');
$activity = ACTIVITY_LIKE;
break;
case 'dislike':
case 'undislike':
- $bodyverb = t('%1$s doesn\'t like %2$s\'s %3$s');
+ $bodyverb = L10n::t('%1$s doesn\'t like %2$s\'s %3$s');
$activity = ACTIVITY_DISLIKE;
break;
case 'attendyes':
case 'unattendyes':
- $bodyverb = t('%1$s is attending %2$s\'s %3$s');
+ $bodyverb = L10n::t('%1$s is attending %2$s\'s %3$s');
$activity = ACTIVITY_ATTEND;
break;
case 'attendno':
case 'unattendno':
- $bodyverb = t('%1$s is not attending %2$s\'s %3$s');
+ $bodyverb = L10n::t('%1$s is not attending %2$s\'s %3$s');
$activity = ACTIVITY_ATTENDNO;
break;
case 'attendmaybe':
case 'unattendmaybe':
- $bodyverb = t('%1$s may attend %2$s\'s %3$s');
+ $bodyverb = L10n::t('%1$s may attend %2$s\'s %3$s');
$activity = ACTIVITY_ATTENDMAYBE;
break;
default:
$item = $items[0];
$uid = $item['uid'];
- if (!can_write_wall($a, $uid) && (($uid != 0) || !local_user())) {
+ if (($uid == 0) && local_user()) {
+ $uid = local_user();
+ }
+
+ if (!can_write_wall($uid)) {
logger('like: unable to write on wall ' . $uid);
return false;
}
// Retrieves the local post owner
- if ($uid != 0) {
- $owners = q("SELECT `contact`.* FROM `contact`
- WHERE `contact`.`self`
- AND `contact`.`uid` = %d",
- intval($uid)
- );
- if (DBM::is_result($owners)) {
- $owner_self_contact = $owners[0];
- } else {
- logger('like: unknown owner ' . $uid);
- return false;
- }
+ $owners = q("SELECT `contact`.* FROM `contact`
+ WHERE `contact`.`self`
+ AND `contact`.`uid` = %d",
+ intval($uid)
+ );
+ if (DBM::is_result($owners)) {
+ $owner_self_contact = $owners[0];
} else {
- $uid = local_user();
- $owner_self_contact = ['uid' => 0, 'nick' => 'feed-item'];
+ logger('like: unknown owner ' . $uid);
+ return false;
}
// Retrieve the current logged in user's public contact
AND (`parent` = '%s' OR `parent-uri` = '%s' OR `thr-parent` = '%s')
LIMIT 1",
intval($author_contact['id']),
- intval($uid),
+ intval($item['uid']),
dbesc($item_id), dbesc($item_id), dbesc($item['uri'])
);
// Clean up the Diaspora signatures for this like
// Go ahead and do it even if Diaspora support is disabled. We still want to clean up
// if it had been enabled in the past
- dba::delete('sign', array('iid' => $like_item['id']));
+ dba::delete('sign', ['iid' => $like_item['id']]);
$like_item_id = $like_item['id'];
Worker::add(PRIORITY_HIGH, "Notifier", "like", $like_item_id);
}
// Else or if event verb different from existing row, create a new item row
- $post_type = (($item['resource-id']) ? t('photo') : t('status'));
+ $post_type = (($item['resource-id']) ? L10n::t('photo') : L10n::t('status'));
if ($item['object-type'] === ACTIVITY_OBJ_EVENT) {
- $post_type = t('event');
+ $post_type = L10n::t('event');
}
$objtype = $item['resource-id'] ? ACTIVITY_OBJ_IMAGE : ACTIVITY_OBJ_NOTE ;
$link = xmlify('<link rel="alternate" type="text/html" href="' . System::baseUrl() . '/display/' . $owner_self_contact['nick'] . '/' . $item['id'] . '" />' . "\n") ;
$alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]';
$plink = '[url=' . System::baseUrl() . '/display/' . $owner_self_contact['nick'] . '/' . $item['id'] . ']' . $post_type . '[/url]';
- $new_item = array(
+ $new_item = [
'guid' => get_guid(32),
- 'uri' => item_new_uri($a->get_hostname(), $uid),
- 'uid' => $uid,
+ 'uri' => item_new_uri($a->get_hostname(), $item['uid']),
+ 'uid' => $item['uid'],
'contact-id' => $item_contact_id,
'type' => 'activity',
'wall' => $item['wall'],
'deny_gid' => $item['deny_gid'],
'visible' => 1,
'unseen' => 1,
- 'last-child' => 0
- );
+ ];
$new_item_id = item_store($new_item);
$new_item['id'] = $new_item_id;
- call_hooks('post_local_end', $new_item);
+ Addon::callHooks('post_local_end', $new_item);
Worker::add(PRIORITY_HIGH, "Notifier", "like", $new_item_id);