aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
authorMike Macgirvin <mike@macgirvin.com>2010-10-28 18:18:20 -0700
committerMike Macgirvin <mike@macgirvin.com>2010-10-28 18:18:20 -0700
commit051fb7107ef5c449d9d9627298b85abe882e8186 (patch)
tree51929f42dc2fa1d8925c5bc20e757af248d2237e /mod
parentf7e1e907bccbdba93122412f7bc5952b09a7815c (diff)
downloadvolse-hubzilla-051fb7107ef5c449d9d9627298b85abe882e8186.tar.gz
volse-hubzilla-051fb7107ef5c449d9d9627298b85abe882e8186.tar.bz2
volse-hubzilla-051fb7107ef5c449d9d9627298b85abe882e8186.zip
linkify @person and @person@domain.com tags
Diffstat (limited to 'mod')
-rw-r--r--mod/item.php45
1 files changed, 44 insertions, 1 deletions
diff --git a/mod/item.php b/mod/item.php
index 4ebb1e978..64a23e7fb 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -114,6 +114,49 @@ function item_post(&$a) {
}
}
+ $str_tags = '';
+ $tagged = array();
+
+ $tags = get_tags($body);
+
+
+ if($tags) {
+ foreach($tags as $tag) {
+ if(strpos($tag,'@') === 0) {
+ $name = substr($tag,1);
+ if(strpos($name,'@')) {
+
+ $links = @webfinger($name);
+ if(count($links)) {
+ foreach($links as $link) {
+ if($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page')
+ $profile = $link['@attributes']['href'];
+ if($link['@attributes']['rel'] === 'salmon')
+ $salmon = $link['@attributes']['href'];
+ }
+ }
+ }
+ else {
+ $r = q("SELECT * FROM `contact` WHERE `nick` = '%s' AND `uid` = %d LIMIT 1",
+ dbesc($name),
+ intval($profile_uid)
+ );
+ if(count($r)) {
+ $profile = $r[0]['url'];
+ $salmon = $r[0]['notify'];
+ }
+ }
+ if($profile) {
+ $profile = str_replace(',','%2c',$profile);
+ $body = str_replace($name,'[url=' . $profile . ']' . $name . '[/url]', $body);
+ if(strlen($str_tags))
+ $str_tags .= ',';
+ $str_tags .= '[url=' . $profile . ']' . $name . '[/url]';
+ }
+ }
+ }
+ }
+
$wall = 0;
if($post_type === 'wall' || $post_type === 'wall-comment')
$wall = 1;
@@ -345,7 +388,7 @@ function item_content(&$a) {
else {
notice( t('Permission denied.') . EOL);
goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
- return; //NOTREACHED
+ //NOTREACHED
}
}
} \ No newline at end of file