]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Item.php
Update src/Model/Photo.php
[friendica.git] / src / Model / Item.php
index 8c7515e1121d6bd27f7a1e0ba2858e925f92cb9b..6488e479e5bdae9a87a54d813d8def8c072bec41 100644 (file)
@@ -76,7 +76,7 @@ class Item
                'commented', 'created', 'edited', 'received', 'verb', 'object-type', 'postopts', 'plink',
                'wall', 'private', 'starred', 'origin', 'parent-origin', 'title', 'body', 'language',
                'content-warning', 'location', 'coord', 'app', 'rendered-hash', 'rendered-html', 'object',
-               'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid',
+               'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'mention',
                'author-id', 'author-link', 'author-name', 'author-avatar', 'author-network',
                'owner-id', 'owner-link', 'owner-name', 'owner-avatar', 'owner-network', 'owner-contact-type',
                'causer-id', 'causer-link', 'causer-name', 'causer-avatar', 'causer-contact-type', 'causer-network',
@@ -94,9 +94,9 @@ class Item
                        'private', 'title', 'body', 'raw-body', 'location', 'coord', 'app',
                        'inform', 'deleted', 'extid', 'post-type', 'gravity',
                        'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid',
-                       'author-id', 'author-link', 'owner-id', 'owner-link', 'contact-uid',
+                       'author-id', 'author-link', 'author-name', 'author-avatar', 'owner-id', 'owner-link', 'contact-uid',
                        'signed_text', 'network', 'wall', 'contact-id', 'plink', 'forum_mode', 'origin',
-                       'thr-parent-id', 'parent-uri-id', 'postopts', 'pubmail', 
+                       'thr-parent-id', 'parent-uri-id', 'postopts', 'pubmail',
                        'event-created', 'event-edited', 'event-start', 'event-finish',
                        'event-summary', 'event-desc', 'event-location', 'event-type',
                        'event-nofinish', 'event-adjust', 'event-ignore', 'event-id'];
@@ -241,7 +241,7 @@ class Item
                        if ($item['uid'] == $uid) {
                                self::markForDeletionById($item['id'], PRIORITY_HIGH);
                        } elseif ($item['uid'] != 0) {
-                               Logger::log('Wrong ownership. Not deleting item ' . $item['id']);
+                               Logger::notice('Wrong ownership. Not deleting item', ['id' => $item['id']]);
                        }
                }
                DBA::close($items);
@@ -970,6 +970,10 @@ class Item
                        unset($item['event-id']);
                }
 
+               if (empty($item['causer-id'])) {
+                       unset($item['causer-id']);
+               }
+
                Post::insert($item['uri-id'], $item);
 
                if ($item['gravity'] == GRAVITY_PARENT) {
@@ -1499,6 +1503,10 @@ class Item
         */
        private static function getLanguage(array $item)
        {
+               if (!empty($item['language'])) {
+                       return $item['language'];
+               }
+
                if (!in_array($item['gravity'], [GRAVITY_PARENT, GRAVITY_COMMENT]) || empty($item['body'])) {
                        return '';
                }
@@ -2169,9 +2177,15 @@ class Item
 
        public static function firstPostDate($uid, $wall = false)
        {
-               $condition = ['gravity' => GRAVITY_PARENT, 'uid' => $uid, 'wall' => $wall, 'deleted' => false, 'visible' => true];
+               $user = User::getById($uid, ['register_date']);
+               if (empty($user)) {
+                       return false;
+               }
+
+               $condition = ["`uid` = ? AND `wall` = ? AND NOT `deleted` AND `visible` AND `received` >= ?",
+                       $uid, $wall, $user['register_date']];
                $params = ['order' => ['received' => false]];
-               $thread = Post::selectFirst(['received'], $condition, $params);
+               $thread = Post::selectFirstThread(['received'], $condition, $params);
                if (DBA::isResult($thread)) {
                        $postdate = substr(DateTimeFormat::local($thread['received']), 0, 10);
                        return $postdate;
@@ -2467,22 +2481,23 @@ class Item
        /**
         * get translated item type
         *
-        * @param $item
+        * @param array                $item
+        * @param \Friendica\Core\L10n $l10n
         * @return string
         */
-       public static function postType($item)
+       public static function postType(array $item, \Friendica\Core\L10n $l10n)
        {
                if (!empty($item['event-id'])) {
-                       return DI::l10n()->t('event');
+                       return $l10n->t('event');
                } elseif (!empty($item['resource-id'])) {
-                       return DI::l10n()->t('photo');
+                       return $l10n->t('photo');
                } elseif ($item['gravity'] == GRAVITY_ACTIVITY) {
-                       return DI::l10n()->t('activity');
+                       return $l10n->t('activity');
                } elseif ($item['gravity'] == GRAVITY_COMMENT) {
-                       return DI::l10n()->t('comment');
+                       return $l10n->t('comment');
                }
 
-               return DI::l10n()->t('post');
+               return $l10n->t('post');
        }
 
        /**