]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Post.php
Posts per author/server on the community pages (#13764)
[friendica.git] / src / Model / Post.php
index 6f855867f6ea18bd59c1b0101dda71ad5474ce5a..2e8bbe22e3650fdc7ffd265f5c3428d37b2b608d 100644 (file)
@@ -23,7 +23,6 @@ namespace Friendica\Model;
 
 use BadMethodCallException;
 use Friendica\Core\Logger;
-use Friendica\Core\System;
 use Friendica\Database\Database;
 use Friendica\Database\DBA;
 use Friendica\DI;
@@ -36,10 +35,10 @@ class Post
         *
         * @param integer $uri_id
         * @param array   $fields
-        * @return int    ID of inserted post
+        * @return bool   Success of the insert process
         * @throws \Exception
         */
-       public static function insert(int $uri_id, array $data = []): int
+       public static function insert(int $uri_id, array $data = []): bool
        {
                if (empty($uri_id)) {
                        throw new BadMethodCallException('Empty URI_id');
@@ -50,11 +49,7 @@ class Post
                // Additionally assign the key fields
                $fields['uri-id'] = $uri_id;
 
-               if (!DBA::insert('post', $fields, Database::INSERT_IGNORE)) {
-                       return 0;
-               }
-
-               return DBA::lastInsertId();
+               return DBA::insert('post', $fields, Database::INSERT_IGNORE);
        }
 
        /**
@@ -501,6 +496,23 @@ class Post
                return self::selectViewForUser('post-view', $uid, $selected, $condition, $params);
        }
 
+       /**
+        * Select rows from the post-timeline-view view for a given user
+        * This function is used for API calls.
+        *
+        * @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 selectTimelineForUser(int $uid, array $selected = [], array $condition = [], array $params = [])
+       {
+               return self::selectViewForUser('post-timeline-view', $uid, $selected, $condition, $params);
+       }
+
        /**
         * Select rows from the post-thread-user-view view for a given user
         *
@@ -598,7 +610,7 @@ class Post
        {
                $affected = 0;
 
-               Logger::info('Start Update', ['fields' => $fields, 'condition' => $condition, 'uid' => DI::userSession()->getLocalUserId(),'callstack' => System::callstack(10)]);
+               Logger::info('Start Update', ['fields' => $fields, 'condition' => $condition, 'uid' => DI::userSession()->getLocalUserId()]);
 
                // Don't allow changes to fields that are responsible for the relation between the records
                unset($fields['id']);