'signed_text', 'signature', 'signer'];
/**
- * Retrieve a single record from the item table and returns it in an associative array
+ * Retrieve a single record from the item table for a given user and returns it in an associative array
*
* @brief Retrieve a single record from a table
* @param integer $uid User ID
* @return bool|array
* @see dba::select
*/
- public static function selectFirst($uid, array $fields = [], array $condition = [], $params = [])
+ public static function selectFirstForUser($uid, array $selected = [], array $condition = [], $params = [])
+ {
+ $params['uid'] = $uid;
+
+ if (empty($selected)) {
+ $selected = Item::DISPLAY_FIELDLIST;
+ }
+
+ return self::selectFirst($selected, $condition, $params);
+ }
+
+ /**
+ * @brief 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
+ */
+ public static function selectForUser($uid, array $selected = [], array $condition = [], $params = [])
+ {
+ $params['uid'] = $uid;
+
+ if (empty($selected)) {
+ $selected = Item::DISPLAY_FIELDLIST;
+ }
+
+ return self::select($selected, $condition, $params);
+ }
+
+ /**
+ * Retrieve a single record from the item table and returns it in an associative array
+ *
+ * @brief Retrieve a single record from a table
+ * @param array $fields
+ * @param array $condition
+ * @param array $params
+ * @return bool|array
+ * @see dba::select
+ */
+ public static function selectFirst(array $fields = [], array $condition = [], $params = [])
{
$params['limit'] = 1;
- $result = self::select($uid, $fields, $condition, $params);
+
+ $result = self::select($fields, $condition, $params);
if (is_bool($result)) {
return $result;
/**
* @brief Select rows from the item table
*
- * @param integer $uid User ID
- * @param array $fields Array of selected fields, empty for all
+ * @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
*/
- public static function select($uid, array $selected = [], array $condition = [], $params = [])
+ public static function select(array $selected = [], array $condition = [], $params = [])
{
+ $uid = 0;
+ $usermode = false;
+
+ if (isset($params['uid'])) {
+ $uid = $params['uid'];
+ $usermode = true;
+ }
+
$fields = self::fieldlist($selected);
$select_fields = self::constructSelectFields($fields, $selected);
$condition_string = self::addTablesToFields($condition_string, $fields);
- $condition_string = $condition_string . ' AND ' . self::condition(false);
+ if ($usermode) {
+ $condition_string = $condition_string . ' AND ' . self::condition(false);
+ }
$param_string = self::addTablesToFields(dba::buildParameter($params), $fields);
* @return bool|array
* @see dba::select
*/
- public static function selectFirstThread($uid, array $fields = [], array $condition = [], $params = [])
+ public static function selectFirstThreadForUser($uid, array $fields = [], array $condition = [], $params = [])
{
$params['limit'] = 1;
- $result = self::selectThread($uid, $fields, $condition, $params);
+ $result = self::selectThreadForUser($uid, $fields, $condition, $params);
if (is_bool($result)) {
return $result;
*
* @return boolean|object
*/
- public static function selectThread($uid, array $selected = [], array $condition = [], $params = [])
+ public static function selectThreadForUser($uid, array $selected = [], array $condition = [], $params = [])
{
+ if (empty($selected)) {
+ $selected = Item::DISPLAY_FIELDLIST;
+ }
+
$fields = self::fieldlist($selected);
$threadfields = ['thread' => ['iid', 'uid', 'contact-id', 'owner-id', 'author-id',
*/
private static function fieldlist($selected)
{
- /*
- These Fields are not added below. They are here to for bug search.
- */
-
$item_fields = ['author-id', 'owner-id', 'contact-id', 'uid', 'id', 'parent',
'uri', 'thr-parent', 'parent-uri', 'content-warning',
'commented', 'created', 'edited', 'received', 'verb', 'object-type', 'postopts', 'plink',