aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rwxr-xr-xinclude/items.php2
-rw-r--r--include/message.php2
-rw-r--r--include/photos.php2
-rw-r--r--include/text.php162
4 files changed, 108 insertions, 60 deletions
diff --git a/include/items.php b/include/items.php
index 1fe98c119..76ae79e6f 100755
--- a/include/items.php
+++ b/include/items.php
@@ -4561,7 +4561,7 @@ function set_linkified_perms($linkified, &$str_contact_allow, &$str_group_allow,
$first_access_tag = true;
foreach($linkified as $x) {
- $access_tag = $x['access_tag'];
+ $access_tag = $x['success']['access_tag'];
if(($access_tag) && (! $parent_item)) {
logger('access_tag: ' . $tag . ' ' . print_r($access_tag,true), LOGGER_DATA);
if ($first_access_tag && (! get_pconfig($profile_uid,'system','no_private_mention_acl_override'))) {
diff --git a/include/message.php b/include/message.php
index 936c01631..037c59c60 100644
--- a/include/message.php
+++ b/include/message.php
@@ -44,7 +44,7 @@ function send_message($uid = 0, $recipient = '', $body = '', $subject = '', $rep
$body = cleanup_bbcode($body);
- $results = linkify_tags($a, $body, $uid);
+ $results = linkify_tags($body, $uid);
if(! $raw) {
if(preg_match_all("/\[attachment\](.*?)\[\/attachment\]/",((strpos($body,'[/crypt]')) ? $_POST['media_str'] : $body),$match)) {
diff --git a/include/photos.php b/include/photos.php
index ae51703e0..44406e0b0 100644
--- a/include/photos.php
+++ b/include/photos.php
@@ -356,7 +356,7 @@ function photo_upload($channel, $observer, $args) {
$large_photos = feature_enabled($channel['channel_id'], 'large_photos');
- linkify_tags($a, $args['body'], $channel_id);
+ linkify_tags($args['body'], $channel_id);
if($large_photos) {
$scale = 1;
diff --git a/include/text.php b/include/text.php
index ad7678483..b017b038a 100644
--- a/include/text.php
+++ b/include/text.php
@@ -2631,8 +2631,9 @@ function extra_query_args() {
* @param boolean $in_network default true
* @return boolean true if replaced, false if not replaced
*/
-function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag, $in_network = true) {
+function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true) {
+ $channel = App::get_channel();
$replaced = false;
$r = null;
$match = array();
@@ -2688,21 +2689,20 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag, $i
$str_tags .= $newtag;
}
- return [
- 'replaced' => $replaced,
- 'termtype' => $termtype,
- 'term' => $basetag,
- 'url' => $url,
- 'contact' => []
- ];
-
+ return [ [
+ 'replaced' => $replaced,
+ 'termtype' => $termtype,
+ 'term' => $basetag,
+ 'url' => $url,
+ 'contact' => [],
+ 'access_tag' => '',
+ ]];
}
// END hashtags
// BEGIN mentions
-
if ( in_array($termtype, [ TERM_MENTION, TERM_FORUM ] )) {
// The @! tag and !! tag will alter permissions
@@ -2713,7 +2713,7 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag, $i
$exclusive = (((strpos(substr($tag,1), '!') === 0) && $in_network) ? true : false);
//is it already replaced?
- if(strpos($tag,'[zrl=') || strpos($tag,'[url='))
+ if(strpos($tag,"[zrl=") || strpos($tag,"[url="))
return $replaced;
// get the channel name
@@ -2731,7 +2731,7 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag, $i
$newname = substr($name,1);
$newname = substr($newname,0,-1);
- $r = q("select * from xchan where xchan_addr = '%s' or xchan_url = '%s' limit 1",
+ $r = q("select * from xchan where xchan_addr = '%s' or xchan_url = '%s'",
dbesc($newname),
dbesc($newname)
);
@@ -2754,7 +2754,7 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag, $i
// select someone from this user's contacts by name
$r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash
- WHERE xchan_name = '%s' AND abook_channel = %d LIMIT 1",
+ WHERE xchan_name = '%s' AND abook_channel = %d ",
dbesc($newname),
intval($profile_uid)
);
@@ -2763,7 +2763,7 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag, $i
if((! $r) && strpos($newname,'@')) {
$r = q("SELECT * FROM xchan left join hubloc on xchan_hash = hubloc_hash
- WHERE hubloc_addr = '%s' LIMIT 1",
+ WHERE hubloc_addr = '%s' ",
dbesc($newname)
);
}
@@ -2772,7 +2772,7 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag, $i
if(! $r) {
$r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash
- WHERE xchan_addr like ('%s') AND abook_channel = %d LIMIT 1",
+ WHERE xchan_addr like ('%s') AND abook_channel = %d ",
dbesc(((strpos($newname,'@')) ? $newname : $newname . '@%')),
intval($profile_uid)
);
@@ -2780,17 +2780,62 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag, $i
}
- // $r is set if we found something
- $channel = App::get_channel();
+
+
+
+ $fn_results = [];
+ $access_tag = EMPTY_STR;
+
+
+ // $r is set if we found something
if($r) {
- $profile = $r[0]['xchan_url'];
- $newname = $r[0]['xchan_name'];
- // add the channel's xchan_hash to $access_tag if exclusive
- if($exclusive) {
- $access_tag .= 'cid:' . $r[0]['xchan_hash'];
+ foreach($r as $xc) {
+ $profile = $xc['xchan_url'];
+ $newname = $xc['xchan_name'];
+ // add the channel's xchan_hash to $access_tag if exclusive
+ if($exclusive) {
+ $access_tag = 'cid:' . $xc['xchan_hash'];
+ }
+
+ // if there is a url for this channel
+
+ if(isset($profile)) {
+ $replaced = 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);
+ }
+ else {
+ // ( $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)) {
+ if(strlen($str_tags))
+ $str_tags .= ',';
+ $str_tags .= $newtag;
+ }
+ }
+
+
+ $fn_results[] = [
+ 'replaced' => $replaced,
+ 'termtype' => $termtype,
+ 'term' => $newname,
+ 'url' => $url,
+ 'access_tag' => $access_tag,
+ 'contact' => (($r) ? $xc : []),
+ ];
+
}
+
}
else {
@@ -2802,7 +2847,6 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag, $i
// weird - as all the other tags are linked to something.
if(local_channel() && local_channel() == $profile_uid) {
- require_once('include/group.php');
$grp = group_byname($profile_uid,$name);
if($grp) {
@@ -2819,58 +2863,62 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag, $i
}
}
}
- }
- // if there is a url for this channel
- if(isset($profile)) {
- $replaced = 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);
- }
- else {
- // ( $termtype === TERM_MENTION )
- $newtag = '@' . (($exclusive) ? '!' : '') . '[zrl=' . $profile . ']' . $newname . '[/zrl]';
- $body = str_replace('@' . (($exclusive) ? '!' : '') . $name, $newtag, $body);
- }
+ // if there is a url for this channel
- // append tag to str_tags
- if(! stristr($str_tags,$newtag)) {
- if(strlen($str_tags))
- $str_tags .= ',';
- $str_tags .= $newtag;
+ if(isset($profile)) {
+ $replaced = 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);
+ }
+ else {
+ // ( $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)) {
+ if(strlen($str_tags))
+ $str_tags .= ',';
+ $str_tags .= $newtag;
+ }
}
+
+ $fn_results[] = [
+ 'replaced' => $replaced,
+ 'termtype' => $termtype,
+ 'term' => $newname,
+ 'url' => $url,
+ 'access_tag' => $access_tag,
+ 'contact' => [],
+ ];
}
}
+
+ return $fn_results;
- return [
- 'replaced' => $replaced,
- 'termtype' => $termtype,
- 'term' => $newname,
- 'url' => $url,
- 'contact' => (($r) ? $r[0] : [])
- ];
}
-function linkify_tags($a, &$body, $uid, $in_network = true) {
+function linkify_tags(&$body, $uid, $in_network = true) {
$str_tags = EMPTY_STR;
- $tagged = [];
$results = [];
$tags = get_tags($body);
if(count($tags)) {
foreach($tags as $tag) {
- $access_tag = '';
- $success = handle_tag($a, $body, $access_tag, $str_tags, ($uid) ? $uid : App::$profile_uid , $tag, $in_network);
+ $success = handle_tag($body, $str_tags, ($uid) ? $uid : App::$profile_uid , $tag, $in_network);
- $results[] = array('success' => $success, 'access_tag' => $access_tag);
- if($success['replaced']) $tagged[] = $tag;
+ foreach($success as $handled_tag) {
+ $results[] = [ 'success' => $handled_tag ];
+ }
}
}