mirror of
https://github.com/friendica/friendica
synced 2025-04-26 13:50:11 +00:00
New item field "Post-type" and new table "permissionset" (#5408)
* "post-type" replaces "bookmark" and "type" * Removed some more type * Added index to permission set * The permission set is now stored * The permission set is now removed upon expiry * Post update now stores the permission set * New file * Permissions are now sorted * Changed documentation
This commit is contained in:
parent
0b38f1c58b
commit
5af9596dde
29 changed files with 222 additions and 145 deletions
|
@ -8,6 +8,7 @@ use Friendica\Core\Config;
|
|||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\PermissionSet;
|
||||
use dba;
|
||||
|
||||
require_once 'include/dba.php';
|
||||
|
@ -31,7 +32,7 @@ class PostUpdate
|
|||
if (!self::update1206()) {
|
||||
return;
|
||||
}
|
||||
if (!self::update1276()) {
|
||||
if (!self::update1278()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -227,19 +228,20 @@ class PostUpdate
|
|||
*
|
||||
* @return bool "true" when the job is done
|
||||
*/
|
||||
private static function update1276()
|
||||
private static function update1278()
|
||||
{
|
||||
// Was the script completed?
|
||||
if (Config::get("system", "post_update_version") >= 1276) {
|
||||
if (Config::get("system", "post_update_version") >= 1278) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$id = Config::get("system", "post_update_version_1276_id", 0);
|
||||
$id = Config::get("system", "post_update_version_1278_id", 0);
|
||||
|
||||
logger("Start from item " . $id, LOGGER_DEBUG);
|
||||
|
||||
$fields = array_merge(Item::MIXED_CONTENT_FIELDLIST, ['network', 'author-id', 'owner-id', 'tag', 'file',
|
||||
'author-name', 'author-avatar', 'author-link', 'owner-name', 'owner-avatar', 'owner-link', 'id']);
|
||||
'author-name', 'author-avatar', 'author-link', 'owner-name', 'owner-avatar', 'owner-link', 'id',
|
||||
'uid', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'psid', 'post-type', 'bookmark', 'type']);
|
||||
|
||||
$start_id = $id;
|
||||
$rows = 0;
|
||||
|
@ -263,18 +265,32 @@ class PostUpdate
|
|||
$item['owner-id'] = Contact::getIdForURL($item["owner-link"], 0, false, $default);
|
||||
}
|
||||
|
||||
if (empty($item['psid'])) {
|
||||
$item['psid'] = PermissionSet::fetchIDForPost($item);
|
||||
}
|
||||
|
||||
if ($item['post-type'] == 0) {
|
||||
if (!empty($item['type']) && ($item['type'] == 'note')) {
|
||||
$item['post-type'] = Item::PT_PERSONAL_NOTE;
|
||||
} elseif (!empty($item['type']) && ($item['type'] == 'photo')) {
|
||||
$item['post-type'] = Item::PT_IMAGE;
|
||||
} elseif (!empty($item['bookmark']) && $item['bookmark']) {
|
||||
$item['post-type'] = Item::PT_PAGE;
|
||||
}
|
||||
}
|
||||
|
||||
Item::update($item, ['id' => $id]);
|
||||
|
||||
++$rows;
|
||||
}
|
||||
dba::close($items);
|
||||
|
||||
Config::set("system", "post_update_version_1276_id", $id);
|
||||
Config::set("system", "post_update_version_1278_id", $id);
|
||||
|
||||
logger("Processed rows: " . $rows . " - last processed item: " . $id, LOGGER_DEBUG);
|
||||
|
||||
if ($start_id == $id) {
|
||||
Config::set("system", "post_update_version", 1276);
|
||||
Config::set("system", "post_update_version", 1278);
|
||||
logger("Done", LOGGER_DEBUG);
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue