]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Post.php
Merge pull request #10350 from annando/api-notifications
[friendica.git] / src / Model / Post.php
index 864e2a5742e0e08f2d3ce02aff55e36811f207e5..2dc73446be188955ff7d38d48bc6da3f0f7eabbf 100644 (file)
@@ -127,12 +127,13 @@ class Post
         * Check if post data exists
         *
         * @param array $condition array of fields for condition
+        * @param bool  $user_mode true = post-user-view, false = post-view
         *
         * @return boolean Are there rows for that condition?
         * @throws \Exception
         */
-       public static function exists($condition) {
-               return DBA::exists('post-user-view', $condition);
+       public static function exists($condition, bool $user_mode = true) {
+               return DBA::exists($user_mode ? 'post-user-view' : 'post-view', $condition);
        }
 
        /**
@@ -140,6 +141,7 @@ class Post
         *
         * @param array        $condition array of fields for condition
         * @param array        $params    Array of several parameters
+        * @param bool         $user_mode true = post-user-view, false = post-view
         *
         * @return int
         *
@@ -151,9 +153,9 @@ class Post
         * $count = Post::count($condition);
         * @throws \Exception
         */
-       public static function count(array $condition = [], array $params = [])
+       public static function count(array $condition = [], array $params = [], bool $user_mode = true)
        {
-               return DBA::count('post-user-view', $condition, $params);
+               return DBA::count($user_mode ? 'post-user-view' : 'post-view', $condition, $params);
        }
 
        /**
@@ -162,15 +164,16 @@ class Post
         * @param array $fields
         * @param array $condition
         * @param array $params
+        * @param bool  $user_mode true = post-user-view, false = post-view
         * @return bool|array
         * @throws \Exception
         * @see   DBA::select
         */
-       public static function selectFirst(array $fields = [], array $condition = [], $params = [])
+       public static function selectFirst(array $fields = [], array $condition = [], $params = [], bool $user_mode = true)
        {
                $params['limit'] = 1;
 
-               $result = self::select($fields, $condition, $params);
+               $result = self::select($fields, $condition, $params, $user_mode);
 
                if (is_bool($result)) {
                        return $result;
@@ -265,13 +268,14 @@ class Post
         * @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
+        * @param bool  $user_mode true = post-user-view, false = post-view
         *
         * @return boolean|object
         * @throws \Exception
         */
-       public static function select(array $selected = [], array $condition = [], $params = [])
+       public static function select(array $selected = [], array $condition = [], $params = [], bool $user_mode = true)
        {
-               return self::selectView('post-user-view', $selected, $condition, $params);
+               return self::selectView($user_mode ? 'post-user-view' : 'post-view', $selected, $condition, $params);
        }
 
        /**