<?php
/**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2022, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
return DBA::count('post-user-view', $condition, $params);
}
+ /**
+ * Counts the post-thread-user-view records satisfying the provided condition
+ *
+ * @param array $condition array of fields for condition
+ * @param array $params Array of several parameters
+ *
+ * @return int
+ *
+ * Example:
+ * $condition = ["uid" => 1, "network" => 'dspr'];
+ * or:
+ * $condition = ["`uid` = ? AND `network` IN (?, ?)", 1, 'dfrn', 'dspr'];
+ *
+ * $count = Post::count($condition);
+ * @throws \Exception
+ */
+ public static function countThread(array $condition = [], array $params = [])
+ {
+ return DBA::count('post-thread-user-view', $condition, $params);
+ }
+
/**
* Counts the post-view records satisfying the provided condition
*
}
}
- /**
- * Select pinned rows from the post-thread-user 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 selectPinned(int $uid, array $selected = [], array $condition = [], $params = [])
- {
- $postthreaduser = DBA::select('post-thread-user', ['uri-id'], ['uid' => $uid, 'pinned' => true]);
- if (!DBA::isResult($postthreaduser)) {
- return $postthreaduser;
- }
-
- $pinned = [];
- while ($useritem = DBA::fetch($postthreaduser)) {
- $pinned[] = $useritem['uri-id'];
- }
- DBA::close($postthreaduser);
-
- if (empty($pinned)) {
- return [];
- }
-
- $condition = DBA::mergeConditions(['uri-id' => $pinned, 'uid' => $uid, 'gravity' => GRAVITY_PARENT], $condition);
-
- return self::selectForUser($uid, $selected, $condition, $params);
- }
-
/**
* Update existing post entries
*