return $postfields;
}
- public static function isLegacyMode()
- {
- if (is_null(self::$legacy_mode)) {
- self::$legacy_mode = (DI::config()->get("system", "post_update_version") < 1279);
- }
-
- return self::$legacy_mode;
- }
-
/**
* Set the pinned state of an item
*
* @return array|false current row or false
* @throws \Exception
*/
- public static function fetch($stmt)
+ private static function fetch($stmt)
{
$row = DBA::fetch($stmt);
// ---------------------- Transform item content data ----------------------
- // Fetch data from the item-content table whenever there is content there
- if (self::isLegacyMode()) {
- $legacy_fields = array_merge(Post\DeliveryData::LEGACY_FIELD_LIST, self::MIXED_CONTENT_FIELDLIST);
- foreach ($legacy_fields as $field) {
- if (empty($row[$field]) && !empty($row['internal-item-' . $field])) {
- $row[$field] = $row['internal-item-' . $field];
- }
- unset($row['internal-item-' . $field]);
- }
- }
-
if (array_key_exists('verb', $row)) {
if (!is_null($row['internal-verb'])) {
$row['verb'] = $row['internal-verb'];
* @param bool $do_close
* @return array Data array
*/
- public static function inArray($stmt, $do_close = true) {
+ public static function toArray($stmt, $do_close = true) {
if (is_bool($stmt)) {
return $stmt;
}
return $retval;
}
- /**
- * Retrieve a single record from the item table for a given user and returns it in an associative array
- *
- * @param integer $uid User ID
- * @param array $selected
- * @param array $condition
- * @param array $params
- * @return bool|array
- * @throws \Exception
- * @see DBA::select
- */
- public static function selectFirstForUser($uid, array $selected = [], array $condition = [], $params = [])
- {
- $params['uid'] = $uid;
-
- if (empty($selected)) {
- $selected = self::DISPLAY_FIELDLIST;
- }
-
- return self::selectFirst($selected, $condition, $params);
- }
-
- /**
- * 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
- * @throws \Exception
- */
- public static function selectForUser($uid, array $selected = [], array $condition = [], $params = [])
- {
- $params['uid'] = $uid;
-
- if (empty($selected)) {
- $selected = self::DISPLAY_FIELDLIST;
- }
-
- return self::select($selected, $condition, $params);
- }
-
/**
* Retrieve a single record from the item table and returns it in an associative array
*
foreach ($fields as $table => $table_fields) {
foreach ($table_fields as $field => $select) {
if (empty($selected) || in_array($select, $selected)) {
- if (self::isLegacyMode() && in_array($select, $legacy_fields)) {
- $selection[] = "`item`.`".$select."` AS `internal-item-" . $select . "`";
- }
if (is_int($field)) {
$selection[] = "`" . $table . "`.`" . $select . "`";
} else {
foreach (array_merge(self::CONTENT_FIELDLIST, self::MIXED_CONTENT_FIELDLIST) as $field) {
if (isset($fields[$field])) {
$content_fields[$field] = $fields[$field];
- if (in_array($field, self::CONTENT_FIELDLIST) || !self::isLegacyMode()) {
+ if (in_array($field, self::CONTENT_FIELDLIST)) {
unset($fields[$field]);
} else {
$fields[$field] = null;
$item_content = DBA::selectFirst('item-content', [], ['uri-id' => $item['uri-id']]);
if (DBA::isResult($item_content)) {
$item_fields = ['icid' => $item_content['id']];
- // Clear all fields in the item table that have a content in the item-content table
- if (self::isLegacyMode()) {
- foreach ($item_content as $field => $content) {
- if (in_array($field, self::MIXED_CONTENT_FIELDLIST) && !empty($content)) {
- $item_fields[$field] = null;
- }
- }
- }
DBA::update('item', $item_fields, ['id' => $item['id']]);
}
}
'wall', 'private', 'forum_mode', 'origin', 'author-id'];
$condition = ['uri' => $item['thr-parent'], 'uid' => $item['uid']];
$params = ['order' => ['id' => false]];
- $parent = self::selectFirst($fields, $condition, $params);
+ $parent = Post::selectFirst($fields, $condition, $params);
if (!DBA::isResult($parent)) {
Logger::notice('item parent was not found - ignoring item', ['thr-parent' => $item['thr-parent'], 'uid' => $item['uid']]);
'parent-uri' => $parent['parent-uri'],
'uid' => $parent['uid']];
$params = ['order' => ['id' => false]];
- $toplevel_parent = self::selectFirst($fields, $condition, $params);
+ $toplevel_parent = Post::selectFirst($fields, $condition, $params);
if (!DBA::isResult($toplevel_parent)) {
Logger::notice('item top level parent was not found - ignoring item', ['parent-uri' => $parent['parent-uri'], 'uid' => $parent['uid']]);
return [];
$transmit = $notify || ($item['visible'] && ($parent_origin || $item['origin']));
if ($transmit) {
- $transmit_item = self::selectFirst(['verb', 'origin'], ['id' => $item['id']]);
+ $transmit_item = Post::selectFirst(['verb', 'origin'], ['id' => $item['id']]);
// Don't relay participation messages
if (($transmit_item['verb'] == Activity::FOLLOW) &&
(!$transmit_item['origin'] || ($item['author-id'] != Contact::getPublicIdByUserId($uid)))) {
*
* default permissions - anonymous user
*/
- $sql = sprintf(" AND `item`.`private` != %d", self::PRIVATE);
+ $sql = sprintf(" AND `private` != %d", self::PRIVATE);
// Profile owner - everything is visible
if ($local_user && ($local_user == $owner_id)) {
$set = PermissionSet::get($owner_id, $remote_user);
if (!empty($set)) {
- $sql_set = sprintf(" OR (`item`.`private` = %d AND `item`.`wall` AND `item`.`psid` IN (", self::PRIVATE) . implode(',', $set) . "))";
+ $sql_set = sprintf(" OR (`private` = %d AND `wall` AND `psid` IN (", self::PRIVATE) . implode(',', $set) . "))";
} else {
$sql_set = '';
}
- $sql = sprintf(" AND (`item`.`private` != %d", self::PRIVATE) . $sql_set . ")";
+ $sql = sprintf(" AND (`private` != %d", self::PRIVATE) . $sql_set . ")";
}
return $sql;