]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Item.php
Merge pull request #6515 from annando/connector-posts
[friendica.git] / src / Model / Item.php
index 6c071bfc7fb7e1adec24c92a2f893dda94e0bea0..67071db31817d315b25b7a10b00d8f9b23cf3387 100644 (file)
@@ -20,15 +20,6 @@ use Friendica\Core\Renderer;
 use Friendica\Core\System;
 use Friendica\Core\Worker;
 use Friendica\Database\DBA;
-use Friendica\Model\Contact;
-use Friendica\Model\Event;
-use Friendica\Model\FileTag;
-use Friendica\Model\PermissionSet;
-use Friendica\Model\Term;
-use Friendica\Model\ItemURI;
-use Friendica\Model\Photo;
-use Friendica\Model\Attach;
-use Friendica\Object\Image;
 use Friendica\Protocol\Diaspora;
 use Friendica\Protocol\OStatus;
 use Friendica\Util\DateTimeFormat;
@@ -1245,18 +1236,24 @@ class Item extends BaseObject
        // This function will finally cover most of the preparation functionality in mod/item.php
        public static function prepare(&$item)
        {
+               /*
+                * @TODO: Unused code triggering inspection errors
+                *
                $data = BBCode::getAttachmentData($item['body']);
                if ((preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism", $item['body'], $match, PREG_SET_ORDER) || isset($data["type"]))
                        && ($posttype != Item::PT_PERSONAL_NOTE)) {
                        $posttype = Item::PT_PAGE;
                        $objecttype = ACTIVITY_OBJ_BOOKMARK;
                }
+                */
        }
 
        public static function insert($item, $force_parent = false, $notify = false, $dontcache = false)
        {
                $orig_item = $item;
 
+               $priority = PRIORITY_HIGH;
+
                // If it is a posting where users should get notifications, then define it as wall posting
                if ($notify) {
                        $item['wall'] = 1;
@@ -1266,8 +1263,6 @@ class Item extends BaseObject
 
                        if (is_int($notify)) {
                                $priority = $notify;
-                       } else {
-                               $priority = PRIORITY_HIGH;
                        }
                } else {
                        $item['network'] = trim(defaults($item, 'network', Protocol::PHANTOM));
@@ -1795,13 +1790,13 @@ class Item extends BaseObject
                        DBA::insert('diaspora-interaction', ['uri-id' => $item['uri-id'], 'interaction' => $diaspora_signed_text], true);
                }
 
-               $deleted = self::tagDeliver($item['uid'], $current_post);
+               self::tagDeliver($item['uid'], $current_post);
 
                /*
                 * current post can be deleted if is for a community page and no mention are
                 * in it.
                 */
-               if (!$deleted && !$dontcache) {
+               if (!$dontcache) {
                        $posted_item = self::selectFirst(self::ITEM_FIELDLIST, ['id' => $current_post]);
                        if (DBA::isResult($posted_item)) {
                                if ($notify) {
@@ -1855,7 +1850,7 @@ class Item extends BaseObject
                                $cmd = 'wall-new';
                        }
 
-                       Worker::add(['priority' => PRIORITY_HIGH, 'dont_fork' => true], 'Notifier', $cmd, $current_post);
+                       Worker::add(['priority' => $priority, 'dont_fork' => true], 'Notifier', $cmd, $current_post);
                }
 
                return $current_post;
@@ -2024,7 +2019,7 @@ class Item extends BaseObject
                $condition = ['id' => $itemid, 'uid' => 0,
                        'network' => [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, ""],
                        'visible' => true, 'deleted' => false, 'moderated' => false, 'private' => false];
-               $item = self::selectFirst(self::ITEM_FIELDLIST, ['id' => $itemid]);
+               $item = self::selectFirst(self::ITEM_FIELDLIST, $condition);
                if (!DBA::isResult($item)) {
                        return;
                }
@@ -2481,7 +2476,7 @@ class Item extends BaseObject
                $id = 0;
 
                if ($uid == 0) {
-                       $uid == local_user();
+                       $uid = local_user();
                }
 
                // Does the given user have this item?
@@ -2531,8 +2526,8 @@ class Item extends BaseObject
                        return;
                }
 
-               $community_page = (($user['page-flags'] == Contact::PAGE_COMMUNITY) ? true : false);
-               $prvgroup = (($user['page-flags'] == Contact::PAGE_PRVGROUP) ? true : false);
+               $community_page = (($user['page-flags'] == User::PAGE_FLAGS_COMMUNITY) ? true : false);
+               $prvgroup = (($user['page-flags'] == User::PAGE_FLAGS_PRVGROUP) ? true : false);
 
                $item = self::selectFirst(self::ITEM_FIELDLIST, ['id' => $item_id]);
                if (!DBA::isResult($item)) {
@@ -3049,7 +3044,6 @@ class Item extends BaseObject
                // Contact-id is the uid-dependant author contact
                if (local_user() == $uid) {
                        $item_contact_id = $owner_self_contact['id'];
-                       $item_contact = $owner_self_contact;
                } else {
                        $item_contact_id = Contact::getIdForURL($author_contact['url'], $uid, true);
                        $item_contact = DBA::selectFirst('contact', [], ['id' => $item_contact_id]);
@@ -3176,8 +3170,6 @@ class Item extends BaseObject
                        $item["mention"] = 1;
                }
 
-               $sql = "";
-
                $fields = [];
 
                foreach ($item as $field => $data) {