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'];
return $retval;
}
- /**
- * 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']]);
}
}