diff --git a/mod/item.php b/mod/item.php index 7d36d7f70a..712174b0ae 100644 --- a/mod/item.php +++ b/mod/item.php @@ -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']; diff --git a/mod/photos.php b/mod/photos.php index 9d99edf050..9a3a402a4b 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -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']; diff --git a/mod/profiles.php b/mod/profiles.php index 74844ff42e..013e8e8200 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -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'];