1
0
Fork 0

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:
Michael Vogel 2018-07-19 15:52:05 +02:00 committed by Hypolite Petovan
commit 5af9596dde
29 changed files with 222 additions and 145 deletions

View file

@ -110,7 +110,8 @@ function editpost_content(App $a) {
'$shortnoloc' => L10n::t('clear location'),
'$wait' => L10n::t('Please wait'),
'$permset' => L10n::t('Permission settings'),
'$ptyp' => $item['type'],
'$wall' => $item['wall'],
'$posttype' => $item['post-type'],
'$content' => undo_post_tagging($item['body']),
'$post_id' => $post_id,
'$baseurl' => System::baseUrl(),

View file

@ -90,6 +90,7 @@ function item_post(App $a) {
$objecttype = null;
$profile_uid = defaults($_REQUEST, 'profile_uid', local_user());
$posttype = defaults($_REQUEST, 'post_type', Item::PT_ARTICLE);
if ($thr_parent || $thr_parent_uri) {
if ($thr_parent) {
@ -124,10 +125,6 @@ function item_post(App $a) {
$parent_contact = Contact::getDetailsByURL($parent_item["author-link"]);
$objecttype = ACTIVITY_OBJ_COMMENT;
if (!x($_REQUEST, 'type')) {
$_REQUEST['type'] = 'net-comment';
}
}
if ($parent) {
@ -138,6 +135,7 @@ function item_post(App $a) {
$app = strip_tags(defaults($_REQUEST, 'source', ''));
$extid = strip_tags(defaults($_REQUEST, 'extid', ''));
$object = defaults($_REQUEST, 'object', '');
$wall = intval(defaults($_REQUEST, 'wall', 1));
// Ensure that the user id in a thread always stay the same
if (!is_null($parent_user) && in_array($parent_user, [local_user(), 0])) {
@ -259,6 +257,8 @@ function item_post(App $a) {
$str_contact_deny = $parent_item['deny_cid'];
$str_group_deny = $parent_item['deny_gid'];
$private = $parent_item['private'];
$wall = $parent_item['wall'];
}
$pubmail_enabled = defaults($_REQUEST, 'pubmail_enable', false) && !$private;
@ -329,16 +329,6 @@ function item_post(App $a) {
$contact_record = dba::selectFirst('contact', [], ['uid' => $profile_uid, 'self' => true]);
}
$post_type = notags(trim($_REQUEST['type']));
if ($post_type === 'net-comment' && $parent_item !== null) {
if ($parent_item['wall'] == 1) {
$post_type = 'wall-comment';
} else {
$post_type = 'remote-comment';
}
}
// Look for any tags and linkify them
$str_tags = '';
$inform = '';
@ -429,6 +419,7 @@ function item_post(App $a) {
$contact_id = $private_id;
$contact_record = $forum_contact;
$_REQUEST['origin'] = false;
$wall = 0;
}
/*
@ -507,11 +498,11 @@ function item_post(App $a) {
// embedded bookmark or attachment in post? set bookmark flag
$bookmark = 0;
$data = BBCode::getAttachmentData($body);
if (preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism", $body, $match, PREG_SET_ORDER) || isset($data["type"])) {
if ((preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism", $body, $match, PREG_SET_ORDER) || isset($data["type"]))
&& ($posttype != Item::PT_PERSONAL_NOTE)) {
$posttype = Item::PT_PAGE;
$objecttype = ACTIVITY_OBJ_BOOKMARK;
$bookmark = 1;
}
$body = bb_translate_video($body);
@ -556,12 +547,6 @@ function item_post(App $a) {
}
}
$wall = 0;
if (($post_type === 'wall' || $post_type === 'wall-comment') && !count($forum_contact)) {
$wall = 1;
}
if (!strlen($verb)) {
$verb = ACTIVITY_POST;
}
@ -588,7 +573,6 @@ function item_post(App $a) {
$datarray = [];
$datarray['uid'] = $profile_uid;
$datarray['type'] = $post_type;
$datarray['wall'] = $wall;
$datarray['gravity'] = $gravity;
$datarray['network'] = $network;
@ -618,6 +602,7 @@ function item_post(App $a) {
$datarray['file'] = $categories;
$datarray['inform'] = $inform;
$datarray['verb'] = $verb;
$datarray['post-type'] = $posttype;
$datarray['object-type'] = $objecttype;
$datarray['allow_cid'] = $str_contact_allow;
$datarray['allow_gid'] = $str_group_allow;
@ -626,7 +611,6 @@ function item_post(App $a) {
$datarray['private'] = $private;
$datarray['pubmail'] = $pubmail_enabled;
$datarray['attach'] = $attachments;
$datarray['bookmark'] = intval($bookmark);
// This is not a bug. The item store function changes 'parent-uri' to 'thr-parent' and fetches 'parent-uri' new. (We should change this)
$datarray['parent-uri'] = $thr_parent_uri;

View file

@ -589,8 +589,8 @@ function networkThreadedView(App $a, $update, $parent)
// desired.
$sql_post_table = '';
$sql_options = (($star) ? " AND `thread`.`starred` " : '');
$sql_options .= (($bmark) ? " AND `thread`.`bookmark` " : '');
$sql_options = ($star ? " AND `thread`.`starred` " : '');
$sql_options .= ($bmark ? sprintf(" AND `thread`.`post-type` = %d ", Item::PT_PAGE) : '');
$sql_extra = $sql_options;
$sql_extra2 = '';
$sql_extra3 = '';

View file

@ -57,13 +57,9 @@ function notes_content(App $a, $update = false)
$o .= status_editor($a, $x, $a->contact['id']);
}
$condition = ["`uid` = ? AND `type` = 'note' AND `gravity` = ? AND NOT `wall`
AND `allow_cid` = ? AND `contact-id` = ?",
local_user(), GRAVITY_PARENT, '<' . $a->contact['id'] . '>', $a->contact['id']];
$condition = ['uid' => local_user(), 'post-type' => Item::PT_PERSONAL_NOTE, 'gravity' => GRAVITY_PARENT,
'wall' => false, 'allow_cid' => '<' . $a->contact['id'] . '>', 'contact-id'=> $a->contact['id']];
$notes = dba::count('item', $condition);
$a->set_pager_total($notes);
$a->set_pager_itemspage(40);
$params = ['order' => ['created' => true],
@ -86,6 +82,6 @@ function notes_content(App $a, $update = false)
}
}
$o .= paginate($a);
$o .= alt_pager($a, count($r));
return $o;
}

View file

@ -21,7 +21,7 @@ function oexchange_init(App $a) {
function oexchange_content(App $a) {
if (! local_user()) {
if (!local_user()) {
$o = Login::form();
return $o;
}
@ -31,27 +31,26 @@ function oexchange_content(App $a) {
return;
}
$url = (((x($_REQUEST,'url')) && strlen($_REQUEST['url']))
$url = ((x($_REQUEST,'url') && strlen($_REQUEST['url']))
? urlencode(notags(trim($_REQUEST['url']))) : '');
$title = (((x($_REQUEST,'title')) && strlen($_REQUEST['title']))
$title = ((x($_REQUEST,'title') && strlen($_REQUEST['title']))
? '&title=' . urlencode(notags(trim($_REQUEST['title']))) : '');
$description = (((x($_REQUEST,'description')) && strlen($_REQUEST['description']))
$description = ((x($_REQUEST,'description') && strlen($_REQUEST['description']))
? '&description=' . urlencode(notags(trim($_REQUEST['description']))) : '');
$tags = (((x($_REQUEST,'tags')) && strlen($_REQUEST['tags']))
$tags = ((x($_REQUEST,'tags') && strlen($_REQUEST['tags']))
? '&tags=' . urlencode(notags(trim($_REQUEST['tags']))) : '');
$s = Network::fetchUrl(System::baseUrl() . '/parse_url?f=&url=' . $url . $title . $description . $tags);
if (! strlen($s)) {
if (!strlen($s)) {
return;
}
$post = [];
$post['profile_uid'] = local_user();
$post['return'] = '/oexchange/done' ;
$post['return'] = '/oexchange/done';
$post['body'] = Friendica\Content\Text\HTML::toBBCode($s);
$post['type'] = 'wall';
$_REQUEST = $post;
require_once('mod/item.php');

View file

@ -459,7 +459,7 @@ function photos_post(App $a)
$arr['uid'] = $page_owner_uid;
$arr['uri'] = $uri;
$arr['parent-uri'] = $uri;
$arr['type'] = 'photo';
$arr['post-type'] = Item::PT_IMAGE;
$arr['wall'] = 1;
$arr['resource-id'] = $p[0]['resource-id'];
$arr['contact-id'] = $owner_record['id'];
@ -626,7 +626,6 @@ function photos_post(App $a)
$arr['uid'] = $page_owner_uid;
$arr['uri'] = $uri;
$arr['parent-uri'] = $uri;
$arr['type'] = 'activity';
$arr['wall'] = 1;
$arr['contact-id'] = $owner_record['id'];
$arr['owner-name'] = $owner_record['name'];
@ -1446,7 +1445,6 @@ function photos_content(App $a)
$comments .= replace_macros($cmnt_tpl, [
'$return_path' => '',
'$jsreload' => $return_url,
'$type' => 'wall-comment',
'$id' => $link_item['id'],
'$parent' => $link_item['id'],
'$profile_uid' => $owner_uid,
@ -1485,7 +1483,6 @@ function photos_content(App $a)
$comments .= replace_macros($cmnt_tpl,[
'$return_path' => '',
'$jsreload' => $return_url,
'$type' => 'wall-comment',
'$id' => $link_item['id'],
'$parent' => $link_item['id'],
'$profile_uid' => $owner_uid,
@ -1546,7 +1543,6 @@ function photos_content(App $a)
$comments .= replace_macros($cmnt_tpl, [
'$return_path' => '',
'$jsreload' => $return_url,
'$type' => 'wall-comment',
'$id' => $item['item_id'],
'$parent' => $item['parent'],
'$profile_uid' => $owner_uid,

View file

@ -100,7 +100,6 @@ function poke_init(App $a) {
$arr['uid'] = $uid;
$arr['uri'] = $uri;
$arr['parent-uri'] = ($parent_uri ? $parent_uri : $uri);
$arr['type'] = 'activity';
$arr['wall'] = 1;
$arr['contact-id'] = $poster['id'];
$arr['owner-name'] = $poster['name'];

View file

@ -122,7 +122,6 @@ EOT;
$arr['uri'] = $uri;
$arr['uid'] = $owner_uid;
$arr['contact-id'] = $contact['id'];
$arr['type'] = 'activity';
$arr['wall'] = $item['wall'];
$arr['origin'] = 1;
$arr['gravity'] = GRAVITY_ACTIVITY;

View file

@ -119,7 +119,6 @@ EOT;
$arr['uri'] = $uri;
$arr['uid'] = $owner_uid;
$arr['contact-id'] = $contact['id'];
$arr['type'] = 'activity';
$arr['wall'] = $item['wall'];
$arr['gravity'] = GRAVITY_COMMENT;
$arr['parent'] = $item['id'];