1
1
Fork 0

Merge pull request #3849 from annando/forum-exclamation

Use the exclamation mark to address forums as well
This commit is contained in:
Tobias Diekershoff 2017-10-31 22:22:46 +01:00 committed by GitHub
commit db04a78d84
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 62 additions and 18 deletions

View file

@ -58,6 +58,11 @@ Also, if the forum is a public forum, your posting will be public for the all in
If your post is private you must also explicitly include the group in the post permissions (to allow the forum "contact" to see the post) **and** mention it in a tag (which redistributes the post to the forum members). If your post is private you must also explicitly include the group in the post permissions (to allow the forum "contact" to see the post) **and** mention it in a tag (which redistributes the post to the forum members).
Posting privately to a public forum, will result in your posting being displayed on the forum wall, but not on yours. Posting privately to a public forum, will result in your posting being displayed on the forum wall, but not on yours.
Additionally it is possible to address a forum with the exclamation mark.
In the example above this means that you can address the bicycle forum via !bicycle.
The difference to the @ is that the post will only be sent to the addressed forum.
This also means that you shouldn't address multiple forums in a single post in that way since it will only be distributed by one the forums.
You may also post to a community forum by posting a "wall-to-wall" post using secure cross-site authentication. You may also post to a community forum by posting a "wall-to-wall" post using secure cross-site authentication.
Comments which are relayed to community forums will be relayed back to the original post creator. Comments which are relayed to community forums will be relayed back to the original post creator.

View file

@ -52,6 +52,11 @@ Wenn Du Mitglied eines Community-Forums bist, kannst Du das Forum in einem Beitr
Zum Beispiel würde @Fahrrad Deinen Beitrag neben den sonst ausgewählten Nutzern an alle Nutzer schicken, die in der Gruppe "Fahrrad" sind. Zum Beispiel würde @Fahrrad Deinen Beitrag neben den sonst ausgewählten Nutzern an alle Nutzer schicken, die in der Gruppe "Fahrrad" sind.
Wenn Dein Beitrag privat ist, musst Du diese Gruppe explizit in den Zugriffsrechten des Beitrags auswählen **und** sie mit dem @-Tag erwähnen (was den Beitrag auf die Gruppenmitglieder erweitert). Wenn Dein Beitrag privat ist, musst Du diese Gruppe explizit in den Zugriffsrechten des Beitrags auswählen **und** sie mit dem @-Tag erwähnen (was den Beitrag auf die Gruppenmitglieder erweitert).
Zusätzlich ist es möglich, Foren mit dem Ausrufezeichen zu adressieren.
Im obigen Beispiel bedeutet dies, dass Du das Fahrrad-Forum per !Fahrrad erreichen würdest.
Der Unterschied zum @ besteht darin, dass der Beitrag auschließlich über das Forum verbreitet wird und nicht an weitere Nutzer.
Dies bedeutet auch, dass es nicht sinnvoll ist, mehrere Foren per ! in einem Beitrag zu adressieren, da nur eines der Foren den Beitrag verbreiten wird.
Du kannst außerdem via "Wall zu Wall" einen Beitrag auf der Community-Seite bzw. in dem Community-Forum erstellen. Du kannst außerdem via "Wall zu Wall" einen Beitrag auf der Community-Seite bzw. in dem Community-Forum erstellen.
Kommentare, die Du an ein Community-Forum schickst, werden dem Originalbeitrag hinzugefügt. Kommentare, die Du an ein Community-Forum schickst, werden dem Originalbeitrag hinzugefügt.

View file

@ -478,9 +478,18 @@ function acl_lookup(App $a, $out_type = 'json') {
intval(local_user()) intval(local_user())
); );
$contact_count = (int)$r[0]['c']; $contact_count = (int)$r[0]['c'];
} } elseif ($type == 'f') {
elseif ($type == 'm') { // autocomplete for editor mentions of forums
$r = q("SELECT COUNT(*) AS c FROM `contact`
WHERE `uid` = %d AND NOT `self`
AND NOT `blocked` AND NOT `pending` AND NOT `archive`
AND (`forum` OR `prv`)
AND `success_update` >= `failure_update`
AND `notify` != '' $sql_extra2" ,
intval(local_user())
);
$contact_count = (int)$r[0]['c'];
} elseif ($type == 'm') {
// autocomplete for Private Messages // autocomplete for Private Messages
$r = q("SELECT COUNT(*) AS c FROM `contact` $r = q("SELECT COUNT(*) AS c FROM `contact`
@ -495,8 +504,7 @@ function acl_lookup(App $a, $out_type = 'json') {
); );
$contact_count = (int)$r[0]['c']; $contact_count = (int)$r[0]['c'];
} } elseif ($type == 'a') {
elseif ($type == 'a') {
// autocomplete for Contacts // autocomplete for Contacts
@ -570,8 +578,17 @@ function acl_lookup(App $a, $out_type = 'json') {
intval(local_user()), intval(local_user()),
dbesc(NETWORK_STATUSNET) dbesc(NETWORK_STATUSNET)
); );
} } elseif ($type == 'f') {
elseif ($type == 'm') { $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `addr`, `forum`, `prv` FROM `contact`
WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` AND `notify` != ''
AND `success_update` >= `failure_update` AND NOT (`network` IN ('%s'))
AND (`forum` OR `prv`)
$sql_extra2
ORDER BY `name` ASC ",
intval(local_user()),
dbesc(NETWORK_STATUSNET)
);
} elseif ($type == 'm') {
$r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `addr` FROM `contact` $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag`, `addr` FROM `contact`
WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive` WHERE `uid` = %d AND NOT `self` AND NOT `blocked` AND NOT `pending` AND NOT `archive`
AND `success_update` >= `failure_update` AND `network` IN ('%s','%s','%s') AND `success_update` >= `failure_update` AND `network` IN ('%s','%s','%s')

View file

@ -853,7 +853,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
* The original author commented, but as this is a comment, the permissions * The original author commented, but as this is a comment, the permissions
* weren't fixed up so it will still show the comment as private unless we fix it here. * weren't fixed up so it will still show the comment as private unless we fix it here.
*/ */
if ((intval($r[0]['forum_mode']) == 1) && (! $r[0]['private'])) { if ((intval($r[0]['forum_mode']) == 1) && $r[0]['private']) {
$arr['private'] = 0; $arr['private'] = 0;
} }

View file

@ -203,6 +203,15 @@ function string2bb(element) {
template: contact_format, template: contact_format,
}; };
// Autocomplete forums
forums = {
match: /(^|\s)(!\!*)([^ \n]+)$/,
index: 3,
search: function(term, callback) { contact_search(term, callback, backend_url, 'f'); },
replace: editor_replace,
template: contact_format,
};
// Autocomplete smilies e.g. ":like" // Autocomplete smilies e.g. ":like"
smilies = { smilies = {
match: /(^|\s)(:[a-z]{2,})$/, match: /(^|\s)(:[a-z]{2,})$/,
@ -213,7 +222,7 @@ function string2bb(element) {
}; };
this.attr('autocomplete','off'); this.attr('autocomplete','off');
this.textcomplete([contacts,smilies], {className:'acpopup', zIndex:10000}); this.textcomplete([contacts, forums, smilies], {className:'acpopup', zIndex:10000});
}; };
})( jQuery ); })( jQuery );

View file

@ -557,7 +557,11 @@ function item_post(App $a) {
INNER JOIN `item` ON `item`.`contact-id` = `contact`.`id` AND `contact`.`url` = `item`.`author-link` INNER JOIN `item` ON `item`.`contact-id` = `contact`.`id` AND `contact`.`url` = `item`.`author-link`
WHERE `item`.`id` = `item`.`parent` AND `item`.`parent` = %d", intval($parent)); WHERE `item`.`id` = `item`.`parent` AND `item`.`parent` = %d", intval($parent));
if (dbm::is_result($toplevel_parent)) { if (dbm::is_result($toplevel_parent)) {
$toplevel_contact = '@' . $toplevel_parent[0]['nick'] . '+' . $toplevel_parent[0]['id']; if (!empty($toplevel_parent[0]['addr'])) {
$toplevel_contact = '@' . $toplevel_parent[0]['addr'];
} else {
$toplevel_contact = '@' . $toplevel_parent[0]['nick'] . '+' . $toplevel_parent[0]['id'];
}
} else { } else {
$toplevel_parent = q("SELECT `author-link`, `author-name` FROM `item` WHERE `id` = `parent` AND `parent` = %d", intval($parent)); $toplevel_parent = q("SELECT `author-link`, `author-name` FROM `item` WHERE `id` = `parent` AND `parent` = %d", intval($parent));
$toplevel_contact = '@[url=' . $toplevel_parent[0]['author-link'] . ']' . $toplevel_parent[0]['author-name'] . '[/url]'; $toplevel_contact = '@[url=' . $toplevel_parent[0]['author-link'] . ']' . $toplevel_parent[0]['author-name'] . '[/url]';
@ -575,7 +579,9 @@ function item_post(App $a) {
if (count($tags)) { if (count($tags)) {
foreach ($tags as $tag) { foreach ($tags as $tag) {
if (strpos($tag, '#') === 0) { $tag_type = substr($tag, 0, 1);
if ($tag_type == '#') {
continue; continue;
} }
@ -599,14 +605,15 @@ function item_post(App $a) {
if ($success['replaced']) { if ($success['replaced']) {
$tagged[] = $tag; $tagged[] = $tag;
} }
if (is_array($success['contact']) && intval($success['contact']['prv'])) { // When the forum is private or the forum is addressed with a "!" make the post private
if (is_array($success['contact']) && ($success['contact']['prv'] || ($tag_type == '!'))) {
$private_forum = true; $private_forum = true;
$private_id = $success['contact']['id']; $private_id = $success['contact']['id'];
} }
} }
} }
if (($private_forum) && (! $parent) && (! $private)) { if ($private_forum && !$parent && !$private) {
// we tagged a private forum in a top level post and the message was public. // we tagged a private forum in a top level post and the message was public.
// Restrict it. // Restrict it.
$private = 1; $private = 1;
@ -1107,9 +1114,11 @@ function handle_tag(App $a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $n
$replaced = false; $replaced = false;
$r = null; $r = null;
$tag_type = '@';
//is it a person tag? //is it a person tag?
if (strpos($tag, '@') === 0) { if ((strpos($tag, '@') === 0) || (strpos($tag, '!') === 0)) {
$tag_type = substr($tag, 0, 1);
//is it already replaced? //is it already replaced?
if (strpos($tag, '[url=')) { if (strpos($tag, '[url=')) {
//append tag to str_tags //append tag to str_tags
@ -1121,7 +1130,7 @@ function handle_tag(App $a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $n
} }
// Checking for the alias that is used for OStatus // Checking for the alias that is used for OStatus
$pattern = "/@\[url\=(.*?)\](.*?)\[\/url\]/ism"; $pattern = "/[@!]\[url\=(.*?)\](.*?)\[\/url\]/ism";
if (preg_match($pattern, $tag, $matches)) { if (preg_match($pattern, $tag, $matches)) {
$r = q("SELECT `alias`, `name` FROM `contact` WHERE `nurl` = '%s' AND `alias` != '' AND `uid` = 0", $r = q("SELECT `alias`, `name` FROM `contact` WHERE `nurl` = '%s' AND `alias` != '' AND `uid` = 0",
@ -1282,12 +1291,11 @@ function handle_tag(App $a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $n
//if there is an url for this persons profile //if there is an url for this persons profile
if (isset($profile) && ($newname != "")) { if (isset($profile) && ($newname != "")) {
$replaced = true; $replaced = true;
// create profile link // create profile link
$profile = str_replace(',', '%2c', $profile); $profile = str_replace(',', '%2c', $profile);
$newtag = '@[url=' . $profile . ']' . $newname . '[/url]'; $newtag = $tag_type.'[url=' . $profile . ']' . $newname . '[/url]';
$body = str_replace('@' . $name, $newtag, $body); $body = str_replace($tag_type . $name, $newtag, $body);
// append tag to str_tags // append tag to str_tags
if (! stristr($str_tags, $newtag)) { if (! stristr($str_tags, $newtag)) {
if (strlen($str_tags)) { if (strlen($str_tags)) {