]> git.mxchange.org Git - friendica.git/blobdiff - include/like.php
Add Contact Object
[friendica.git] / include / like.php
index 4f26002719dcb1fabd5f143dddfce320d7ee3d3b..e8d69689b5453391b727a817a8a5df532c0b82d3 100644 (file)
@@ -1,8 +1,11 @@
 <?php
 
 use Friendica\App;
-
-require_once("include/diaspora.php");
+use Friendica\Core\System;
+use Friendica\Core\Worker;
+use Friendica\Database\DBM;
+use Friendica\Object\Contact;
+use Friendica\Protocol\Diaspora;
 
 /**
  * @brief add/remove activity to an item
@@ -70,7 +73,7 @@ function do_like($item_id, $verb) {
                dbesc($item_id)
        );
 
-       if (! $item_id || ! dbm::is_result($items)) {
+       if (! $item_id || ! DBM::is_result($items)) {
                logger('like: unknown item ' . $item_id);
                return false;
        }
@@ -88,7 +91,7 @@ function do_like($item_id, $verb) {
                AND `contact`.`uid` = %d",
                intval($item['uid'])
        );
-       if (dbm::is_result($owners)) {
+       if (DBM::is_result($owners)) {
                $owner_self_contact = $owners[0];
        } else {
                logger('like: unknown owner ' . $item['uid']);
@@ -101,7 +104,7 @@ function do_like($item_id, $verb) {
        $contacts = q("SELECT * FROM `contact` WHERE `id` = %d",
                intval($author_id)
        );
-       if (dbm::is_result($contacts)) {
+       if (DBM::is_result($contacts)) {
                $author_contact = $contacts[0];
        } else {
                logger('like: unknown author ' . $author_id);
@@ -118,7 +121,7 @@ function do_like($item_id, $verb) {
                $contacts = q("SELECT * FROM `contact` WHERE `id` = %d",
                        intval($item_contact_id)
                );
-               if (dbm::is_result($contacts)) {
+               if (DBM::is_result($contacts)) {
                        $item_contact = $contacts[0];
                } else {
                        logger('like: unknown item contact ' . $item_contact_id);
@@ -148,7 +151,7 @@ function do_like($item_id, $verb) {
        );
 
        // If it exists, mark it as deleted
-       if (dbm::is_result($existing_like)) {
+       if (DBM::is_result($existing_like)) {
                $like_item = $existing_like[0];
 
                // Already voted, undo it
@@ -165,7 +168,7 @@ function do_like($item_id, $verb) {
                );
 
                $like_item_id = $like_item['id'];
-               proc_run(PRIORITY_HIGH, "include/notifier.php", "like", $like_item_id);
+               Worker::add(PRIORITY_HIGH, "Notifier", "like", $like_item_id);
 
                if (!$event_verb_flag || $like_item['verb'] == $activity) {
                        return true;
@@ -183,7 +186,7 @@ function do_like($item_id, $verb) {
                $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_self_contact['nick'] . '/' . $item['id'] . '" />' . "\n") ;
+       $link = xmlify('<link rel="alternate" type="text/html" href="' . System::baseUrl() . '/display/' . $owner_self_contact['nick'] . '/' . $item['id'] . '" />' . "\n") ;
        $body = $item['body'];
 
        $obj = <<< EOT
@@ -200,7 +203,7 @@ EOT;
 
        $ulink = '[url=' . $author_contact['url'] . ']' . $author_contact['name'] . '[/url]';
        $alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]';
-       $plink = '[url=' . App::get_baseurl() . '/display/' . $owner_self_contact['nick'] . '/' . $item['id'] . ']' . $post_type . '[/url]';
+       $plink = '[url=' . System::baseUrl() . '/display/' . $owner_self_contact['nick'] . '/' . $item['id'] . ']' . $post_type . '[/url]';
 
        $new_item = array(
                'guid'          => get_guid(32),
@@ -252,7 +255,7 @@ EOT;
 
        call_hooks('post_local_end', $new_item);
 
-       proc_run(PRIORITY_HIGH, "include/notifier.php", "like", $new_item_id);
+       Worker::add(PRIORITY_HIGH, "Notifier", "like", $new_item_id);
 
        return true;
 }