]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Item.php
Avoid multiple lines in post-view, added thread view
[friendica.git] / src / Model / Item.php
index fe7e85dae17cb4c141644570993730b03a86f023..888a81831ad00a3c519705d1c7a8dd14ba054523 100644 (file)
@@ -148,15 +148,6 @@ class Item
                return $postfields;
        }
 
-       public static function isLegacyMode()
-       {
-               if (is_null(self::$legacy_mode)) {
-                       self::$legacy_mode = (DI::config()->get("system", "post_update_version") < 1279);
-               }
-
-               return self::$legacy_mode;
-       }
-
        /**
         * Set the pinned state of an item
         *
@@ -267,17 +258,6 @@ class Item
 
                // ---------------------- Transform item content data ----------------------
 
-               // Fetch data from the item-content table whenever there is content there
-               if (self::isLegacyMode()) {
-                       $legacy_fields = array_merge(Post\DeliveryData::LEGACY_FIELD_LIST, self::MIXED_CONTENT_FIELDLIST);
-                       foreach ($legacy_fields as $field) {
-                               if (empty($row[$field]) && !empty($row['internal-item-' . $field])) {
-                                       $row[$field] = $row['internal-item-' . $field];
-                               }
-                               unset($row['internal-item-' . $field]);
-                       }
-               }
-
                if (array_key_exists('verb', $row)) {
                        if (!is_null($row['internal-verb'])) {
                                $row['verb'] = $row['internal-verb'];
@@ -353,7 +333,7 @@ class Item
         * @param bool   $do_close
         * @return array Data array
         */
-       public static function inArray($stmt, $do_close = true) {
+       public static function toArray($stmt, $do_close = true) {
                if (is_bool($stmt)) {
                        return $stmt;
                }
@@ -390,75 +370,6 @@ class Item
                return $retval;
        }
 
-       /**
-        * Retrieve a single record from the item table for a given user and returns it in an associative array
-        *
-        * @param integer $uid User ID
-        * @param array   $selected
-        * @param array   $condition
-        * @param array   $params
-        * @return bool|array
-        * @throws \Exception
-        * @see   DBA::select
-        */
-       public static function selectFirstForUser($uid, array $selected = [], array $condition = [], $params = [])
-       {
-               $params['uid'] = $uid;
-
-               if (empty($selected)) {
-                       $selected = self::DISPLAY_FIELDLIST;
-               }
-
-               return self::selectFirst($selected, $condition, $params);
-       }
-
-       /**
-        * Select rows from the item table for a given user
-        *
-        * @param integer $uid       User ID
-        * @param array   $selected  Array of selected fields, empty for all
-        * @param array   $condition Array of fields for condition
-        * @param array   $params    Array of several parameters
-        *
-        * @return boolean|object
-        * @throws \Exception
-        */
-       public static function selectForUser($uid, array $selected = [], array $condition = [], $params = [])
-       {
-               $params['uid'] = $uid;
-
-               if (empty($selected)) {
-                       $selected = self::DISPLAY_FIELDLIST;
-               }
-
-               return self::select($selected, $condition, $params);
-       }
-
-       /**
-        * Retrieve a single record from the item table and returns it in an associative array
-        *
-        * @param array $fields
-        * @param array $condition
-        * @param array $params
-        * @return bool|array
-        * @throws \Exception
-        * @see   DBA::select
-        */
-       public static function selectFirst(array $fields = [], array $condition = [], $params = [])
-       {
-               $params['limit'] = 1;
-
-               $result = self::select($fields, $condition, $params);
-
-               if (is_bool($result)) {
-                       return $result;
-               } else {
-                       $row = self::fetch($result);
-                       DBA::close($result);
-                       return $row;
-               }
-       }
-
        /**
         * Select rows from the item table and returns them as an array
         *
@@ -852,9 +763,6 @@ class Item
                foreach ($fields as $table => $table_fields) {
                        foreach ($table_fields as $field => $select) {
                                if (empty($selected) || in_array($select, $selected)) {
-                                       if (self::isLegacyMode() && in_array($select, $legacy_fields)) {
-                                               $selection[] = "`item`.`".$select."` AS `internal-item-" . $select . "`";
-                                       }
                                        if (is_int($field)) {
                                                $selection[] = "`" . $table . "`.`" . $select . "`";
                                        } else {
@@ -926,7 +834,7 @@ class Item
                foreach (array_merge(self::CONTENT_FIELDLIST, self::MIXED_CONTENT_FIELDLIST) as $field) {
                        if (isset($fields[$field])) {
                                $content_fields[$field] = $fields[$field];
-                               if (in_array($field, self::CONTENT_FIELDLIST) || !self::isLegacyMode()) {
+                               if (in_array($field, self::CONTENT_FIELDLIST)) {
                                        unset($fields[$field]);
                                } else {
                                        $fields[$field] = null;
@@ -987,14 +895,6 @@ class Item
                                        $item_content = DBA::selectFirst('item-content', [], ['uri-id' => $item['uri-id']]);
                                        if (DBA::isResult($item_content)) {
                                                $item_fields = ['icid' => $item_content['id']];
-                                               // Clear all fields in the item table that have a content in the item-content table
-                                               if (self::isLegacyMode()) {
-                                                       foreach ($item_content as $field => $content) {
-                                                               if (in_array($field, self::MIXED_CONTENT_FIELDLIST) && !empty($content)) {
-                                                                       $item_fields[$field] = null;
-                                                               }
-                                                       }
-                                               }
                                                DBA::update('item', $item_fields, ['id' => $item['id']]);
                                        }
                                }
@@ -1518,7 +1418,7 @@ class Item
                        'wall', 'private', 'forum_mode', 'origin', 'author-id'];
                $condition = ['uri' => $item['thr-parent'], 'uid' => $item['uid']];
                $params = ['order' => ['id' => false]];
-               $parent = self::selectFirst($fields, $condition, $params);
+               $parent = Post::selectFirst($fields, $condition, $params);
 
                if (!DBA::isResult($parent)) {
                        Logger::notice('item parent was not found - ignoring item', ['thr-parent' => $item['thr-parent'], 'uid' => $item['uid']]);
@@ -1533,7 +1433,7 @@ class Item
                        'parent-uri' => $parent['parent-uri'],
                        'uid' => $parent['uid']];
                $params = ['order' => ['id' => false]];
-               $toplevel_parent = self::selectFirst($fields, $condition, $params);
+               $toplevel_parent = Post::selectFirst($fields, $condition, $params);
                if (!DBA::isResult($toplevel_parent)) {
                        Logger::notice('item top level parent was not found - ignoring item', ['parent-uri' => $parent['parent-uri'], 'uid' => $parent['uid']]);
                        return [];
@@ -2019,7 +1919,7 @@ class Item
                $transmit = $notify || ($item['visible'] && ($parent_origin || $item['origin']));
 
                if ($transmit) {
-                       $transmit_item = self::selectFirst(['verb', 'origin'], ['id' => $item['id']]);
+                       $transmit_item = Post::selectFirst(['verb', 'origin'], ['id' => $item['id']]);
                        // Don't relay participation messages
                        if (($transmit_item['verb'] == Activity::FOLLOW) && 
                                (!$transmit_item['origin'] || ($item['author-id'] != Contact::getPublicIdByUserId($uid)))) {
@@ -3492,7 +3392,7 @@ class Item
                 *
                 * default permissions - anonymous user
                 */
-               $sql = sprintf(" AND `item`.`private` != %d", self::PRIVATE);
+               $sql = sprintf(" AND `private` != %d", self::PRIVATE);
 
                // Profile owner - everything is visible
                if ($local_user && ($local_user == $owner_id)) {
@@ -3508,12 +3408,12 @@ class Item
                        $set = PermissionSet::get($owner_id, $remote_user);
 
                        if (!empty($set)) {
-                               $sql_set = sprintf(" OR (`item`.`private` = %d AND `item`.`wall` AND `item`.`psid` IN (", self::PRIVATE) . implode(',', $set) . "))";
+                               $sql_set = sprintf(" OR (`private` = %d AND `wall` AND `psid` IN (", self::PRIVATE) . implode(',', $set) . "))";
                        } else {
                                $sql_set = '';
                        }
 
-                       $sql = sprintf(" AND (`item`.`private` != %d", self::PRIVATE) . $sql_set . ")";
+                       $sql = sprintf(" AND (`private` != %d", self::PRIVATE) . $sql_set . ")";
                }
 
                return $sql;