aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2023-03-02 21:15:19 +0000
committerMario <mario@mariovavti.com>2023-03-02 21:15:19 +0000
commitda034045cc1bba74287b7c3e83f4a94ff5359150 (patch)
tree10e2ae77b7ab81811cf8e63cf5a38cf04761ebf4 /include
parent65f001b4b7dcf23ee80e137cfca64993a3da5318 (diff)
downloadvolse-hubzilla-da034045cc1bba74287b7c3e83f4a94ff5359150.tar.gz
volse-hubzilla-da034045cc1bba74287b7c3e83f4a94ff5359150.tar.bz2
volse-hubzilla-da034045cc1bba74287b7c3e83f4a94ff5359150.zip
some work on bringing bang tags back for forums
Diffstat (limited to 'include')
-rw-r--r--include/items.php13
-rw-r--r--include/text.php21
2 files changed, 16 insertions, 18 deletions
diff --git a/include/items.php b/include/items.php
index b795df90d..d8f817fc2 100644
--- a/include/items.php
+++ b/include/items.php
@@ -2686,12 +2686,7 @@ function tag_deliver($uid, $item_id) {
* Now we've got those out of the way. Let's see if this is a post that's tagged for re-delivery
*/
- $terms = [];
- if (array_key_exists('term', $item)) {
- $terms = array_merge(get_terms_oftype($item['term'],TERM_MENTION),get_terms_oftype($item['term'],TERM_FORUM));
- logger('Post mentions: ' . print_r($terms,true), LOGGER_DATA);
- }
-
+ $terms = isset($item['term']) ? get_terms_oftype($item['term'], [TERM_MENTION, TERM_FORUM]) : [];
$max_forums = get_config('system','max_tagged_forums',2);
$matched_forums = 0;
@@ -2732,7 +2727,7 @@ function tag_deliver($uid, $item_id) {
// standard forum tagging sequence !forumname
-/*
+
$forumpattern = '/\!\!?\[[uz]rl\=([^\]]*?)\]((?:.(?!\[[uz]rl\=))*?)\[\/[uz]rl\]/';
$forumpattern2 = '/\[[uz]rl\=([^\]]*?)\]\!((?:.(?!\[[uz]rl\=))*?)\[\/[uz]rl\]/';
@@ -2766,8 +2761,6 @@ function tag_deliver($uid, $item_id) {
}
}
-*/
-
if(! ($tagged || $plustagged)) {
logger('Mention was in a reshare or exceeded max_tagged_forums - ignoring');
continue;
@@ -2993,7 +2986,6 @@ function tgroup_check($uid, $item) {
$body = preg_replace('/\[share(.*?)\[\/share\]/','',$item['body']);
-/*
$forumpattern = '/\!\!?\[zrl\=([^\]]*?)\]((?:.(?!\[zrl\=))*?)\[\/zrl\]/';
$forumpattern2 = '/\[zrl\=([^\]]*?)\]\!((?:.(?!\[zrl\=))*?)\[\/zrl\]/';
@@ -3033,7 +3025,6 @@ function tgroup_check($uid, $item) {
logger('tgroup_check: mention was in a reshare or exceeded max_tagged_forums - ignoring');
continue;
}
-*/
return true;
}
diff --git a/include/text.php b/include/text.php
index d7ffa5550..415a51790 100644
--- a/include/text.php
+++ b/include/text.php
@@ -1652,7 +1652,7 @@ function format_hashtags(&$item) {
function format_mentions(&$item) {
$s = '';
- $terms = isset($item['term']) ? get_terms_oftype($item['term'], TERM_MENTION) : [];
+ $terms = isset($item['term']) ? get_terms_oftype($item['term'], [TERM_MENTION, TERM_FORUM]) : [];
if($terms) {
foreach($terms as $t) {
if(! isset($t['term']))
@@ -2876,7 +2876,7 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true)
$termtype = ((strpos($tag,'#') === 0) ? TERM_HASHTAG : TERM_UNKNOWN);
$termtype = ((strpos($tag,'@') === 0) ? TERM_MENTION : $termtype);
-// $termtype = ((strpos($tag,'!') === 0) ? TERM_FORUM : $termtype);
+ $termtype = ((strpos($tag,'!') === 0) ? TERM_FORUM : $termtype);
$termtype = ((strpos($tag,'#^[') === 0) ? TERM_BOOKMARK : $termtype);
// Is it a hashtag of some kind?
@@ -2943,7 +2943,7 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true)
// BEGIN mentions
- if ($termtype === TERM_MENTION) {
+ if (in_array($termtype, [TERM_MENTION, TERM_FORUM])) {
// The @! tag will alter permissions
@@ -3051,8 +3051,15 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true)
$profile = str_replace(',','%2c',$profile);
$url = $profile;
- $newtag = '@' . (($exclusive) ? '!' : '') . '[zrl=' . $profile . ']' . $newname . '[/zrl]';
- $body = str_replace('@' . (($exclusive) ? '!' : '') . $name, $newtag, $body);
+ if($termtype === TERM_FORUM) {
+ $newtag = '!' . (($exclusive) ? '!' : '') . '[zrl=' . $profile . ']' . $newname . '[/zrl]';
+ $body = str_replace('!' . (($exclusive) ? '!' : '') . $name, $newtag, $body);
+ }
+
+ if ($termtype === TERM_MENTION) {
+ $newtag = '@' . (($exclusive) ? '!' : '') . '[zrl=' . $profile . ']' . $newname . '[/zrl]';
+ $body = str_replace('@' . (($exclusive) ? '!' : '') . $name, $newtag, $body);
+ }
// append tag to str_tags
if(! stristr($str_tags,$newtag)) {
@@ -3110,12 +3117,12 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true)
//create profile link
$profile = str_replace(',','%2c',$profile);
$url = $profile;
-/*
+
if($termtype === TERM_FORUM) {
$newtag = '!' . (($exclusive) ? '!' : '') . '[zrl=' . $profile . ']' . $newname . '[/zrl]';
$body = str_replace('!' . (($exclusive) ? '!' : '') . $name, $newtag, $body);
}
-*/
+
if ($termtype === TERM_MENTION) {
$newtag = '@' . (($exclusive) ? '!' : '') . '[zrl=' . $profile . ']' . $newname . '[/zrl]';
$body = str_replace('@' . (($exclusive) ? '!' : '') . $name, $newtag, $body);