]> git.mxchange.org Git - friendica.git/blobdiff - mod/poke.php
friendica-5847 Console Cache List command doesn't work
[friendica.git] / mod / poke.php
index 2fd7068f78b8721e0b95660583eb02a92a35940d..6ebb8632c18b3a24bc229b2c300fc1a8e346e97f 100644 (file)
@@ -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']          = System::createGUID(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'] = '<object><type>' . ACTIVITY_OBJ_PERSON . '</type><title>' . $target['name'] . '</title><id>' . System::baseUrl() . '/contact/' . $target['id'] . '</id>';
+       $arr['object'] = '<object><type>' . ACTIVITY_OBJ_PERSON . '</type><title>' . $target['name'] . '</title><id>' . $target['url'] . '</id>';
        $arr['object'] .= '<link>' . xmlify('<link rel="alternate" type="text/html" href="' . $target['url'] . '" />' . "\n");
 
        $arr['object'] .= xmlify('<link rel="photo" type="image/jpeg" href="' . $target['photo'] . '" />' . "\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();