X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fpoke.php;h=6ebb8632c18b3a24bc229b2c300fc1a8e346e97f;hb=8841519c0dfae069aff6bee6325fa868e4b9b641;hp=55bb799d1fab3c3ff87a43913b54456d2678ee0c;hpb=e84c48b979ab265cd29ff3624e975e288c6755fc;p=friendica.git diff --git a/mod/poke.php b/mod/poke.php index 55bb799d1f..6ebb8632c1 100644 --- a/mod/poke.php +++ b/mod/poke.php @@ -18,25 +18,26 @@ use Friendica\Core\Addon; use Friendica\Core\L10n; use Friendica\Core\System; use Friendica\Core\Worker; -use Friendica\Database\DBM; +use Friendica\Database\DBA; use Friendica\Model\Item; require_once 'include/security.php'; require_once 'include/items.php'; -function poke_init(App $a) { - +function poke_init(App $a) +{ if (!local_user()) { return; } $uid = local_user(); - $verb = notags(trim($_GET['verb'])); - if (!$verb) { + if (empty($_GET['verb'])) { return; } + $verb = notags(trim($_GET['verb'])); + $verbs = get_poke_verbs(); if (!array_key_exists($verb, $verbs)) { @@ -61,7 +62,7 @@ function poke_init(App $a) { intval($uid) ); - if (!DBM::is_result($r)) { + if (!DBA::isResult($r)) { logger('poke: no contact ' . $contact_id); return; } @@ -73,7 +74,7 @@ function poke_init(App $a) { $condition = ['id' => $parent, 'parent' => $parent, 'uid' => $uid]; $item = Item::selectFirst($fields, $condition); - if (DBM::is_result($item)) { + if (DBA::isResult($item)) { $parent_uri = $item['uri']; $private = $item['private']; $allow_cid = $item['allow_cid']; @@ -96,11 +97,10 @@ function poke_init(App $a) { $arr = []; - $arr['guid'] = get_guid(32); + $arr['guid'] = System::createUUID(); $arr['uid'] = $uid; $arr['uri'] = $uri; - $arr['parent-uri'] = ($parent_uri ? $parent_uri : $uri); - $arr['type'] = 'activity'; + $arr['parent-uri'] = (!empty($parent_uri) ? $parent_uri : $uri); $arr['wall'] = 1; $arr['contact-id'] = $poster['id']; $arr['owner-name'] = $poster['name']; @@ -122,7 +122,7 @@ function poke_init(App $a) { $arr['origin'] = 1; $arr['body'] = '[url=' . $poster['url'] . ']' . $poster['name'] . '[/url]' . ' ' . L10n::t($verbs[$verb][0]) . ' ' . '[url=' . $target['url'] . ']' . $target['name'] . '[/url]'; - $arr['object'] = '' . ACTIVITY_OBJ_PERSON . '' . $target['name'] . '' . System::baseUrl() . '/contact/' . $target['id'] . ''; + $arr['object'] = '' . ACTIVITY_OBJ_PERSON . '' . $target['name'] . '' . $target['url'] . ''; $arr['object'] .= '' . xmlify('' . "\n"); $arr['object'] .= xmlify('' . "\n"); @@ -138,10 +138,8 @@ function poke_init(App $a) { return; } - - -function poke_content(App $a) { - +function poke_content(App $a) +{ if (!local_user()) { notice(L10n::t('Permission denied.') . EOL); return; @@ -150,17 +148,17 @@ function poke_content(App $a) { $name = ''; $id = ''; - if (intval($_GET['c'])) { - $r = q("SELECT `id`,`name` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", - intval($_GET['c']), - intval(local_user()) - ); - if (DBM::is_result($r)) { - $name = $item['name']; - $id = $item['id']; - } + if (empty($_GET['c'])) { + return; + } + + $contact = DBA::selectFirst('contact', ['id', 'name'], ['id' => $_GET['c'], 'uid' => local_user()]); + if (!DBA::isResult($contact)) { + return; } + $name = $contact['name']; + $id = $contact['id']; $base = System::baseUrl();