]> git.mxchange.org Git - friendica.git/commitdiff
allow tagging of people by name or nickname
authorZach Prezkuta <fermion@gmx.com>
Sat, 29 Sep 2012 23:55:40 +0000 (17:55 -0600)
committerZach Prezkuta <fermion@gmx.com>
Sat, 29 Sep 2012 23:55:40 +0000 (17:55 -0600)
mod/item.php
mod/photos.php
mod/profiles.php

index 7d36d7f70aca152a91646dcd4dda5065d51e63a5..712174b0ae79ee15bc014144912b315e3bd71f31 100644 (file)
@@ -994,7 +994,25 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag) {
                                                intval($tagcid),
                                                intval($profile_uid)
                                );
-                       } elseif(strstr($name,'_') || strstr($name,' ')) { //no id
+                       else {
+                               $newname = str_replace('_',' ',$name);
+
+                               //select someone from this user's contacts by name
+                               $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
+                                               dbesc($newname),
+                                               intval($profile_uid)
+                               );
+
+                               if(! $r) {
+                                       //select someone by attag or nick and the name passed in
+                                       $r = q("SELECT * FROM `contact` WHERE `attag` = '%s' OR `nick` = '%s' AND `uid` = %d ORDER BY `attag` DESC LIMIT 1",
+                                                       dbesc($name),
+                                                       dbesc($name),
+                                                       intval($profile_uid)
+                                       );
+                               }
+                       }
+/*                     } elseif(strstr($name,'_') || strstr($name,' ')) { //no id
                                //get the real name
                                $newname = str_replace('_',' ',$name);
                                //select someone from this user's contacts by name
@@ -1009,7 +1027,7 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag) {
                                                dbesc($name),
                                                intval($profile_uid)
                                );
-                       }
+                       }*/
                        //$r is set, if someone could be selected
                        if(count($r)) {
                                $profile = $r[0]['url'];
index 9d99edf0504da21d003fe2a58c17220273e0a40b..9a3a402a4b1a169aff24c0bd89934e338a4ffdb9 100644 (file)
@@ -481,7 +481,25 @@ function photos_post(&$a) {
                                                                        intval($profile_uid)
                                                                );
                                                        }
-                                                       elseif(strstr($name,'_') || strstr($name,' ')) {
+                                                       else {
+                                                               $newname = str_replace('_',' ',$name);
+
+                                                               //select someone from this user's contacts by name
+                                                               $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
+                                                                               dbesc($newname),
+                                                                               intval($page_owner_uid)
+                                                               );
+
+                                                               if(! $r) {
+                                                                       //select someone by attag or nick and the name passed in
+                                                                       $r = q("SELECT * FROM `contact` WHERE `attag` = '%s' OR `nick` = '%s' AND `uid` = %d ORDER BY `attag` DESC LIMIT 1",
+                                                                                       dbesc($name),
+                                                                                       dbesc($name),
+                                                                                       intval($page_owner_uid)
+                                                                       );
+                                                               }
+                                                       }
+/*                                                     elseif(strstr($name,'_') || strstr($name,' ')) {
                                                                $newname = str_replace('_',' ',$name);
                                                                $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
                                                                        dbesc($newname),
@@ -494,7 +512,7 @@ function photos_post(&$a) {
                                                                        dbesc($name),
                                                                        intval($page_owner_uid)
                                                                );
-                                                       }
+                                                       }*/
                                                        if(count($r)) {
                                                                $newname = $r[0]['name'];
                                                                $profile = $r[0]['url'];
index 74844ff42efad0d6fb5965316facf567a5461d7b..013e8e82002617ac88b23940909567c29d6bf106 100644 (file)
@@ -101,7 +101,7 @@ function profiles_post(&$a) {
                                }
                                else {
                                        $newname = $lookup;
-                                       if(strstr($lookup,' ')) {
+/*                                     if(strstr($lookup,' ')) {
                                                $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
                                                        dbesc($newname),
                                                        intval(local_user())
@@ -112,6 +112,17 @@ function profiles_post(&$a) {
                                                        dbesc($lookup),
                                                        intval(local_user())
                                                );
+                                       }*/
+                                       
+                                       $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
+                                               dbesc($newname),
+                                               intval(local_user())
+                                       );
+                                       if(! $r) {
+                                               $r = q("SELECT * FROM `contact` WHERE `nick` = '%s' AND `uid` = %d LIMIT 1",
+                                                       dbesc($lookup),
+                                                       intval(local_user())
+                                               );
                                        }
                                        if(count($r)) {
                                                $prf = $r[0]['url'];