mirror of
https://github.com/friendica/friendica
synced 2024-11-10 10:22:53 +00:00
Merge pull request #498 from fermionic/more-robust-tag-conversion
allow tagging of people by name or nickname
This commit is contained in:
commit
c9536ac056
3 changed files with 52 additions and 5 deletions
22
mod/item.php
22
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'];
|
||||
|
|
|
@ -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'];
|
||||
|
|
|
@ -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'];
|
||||
|
|
Loading…
Reference in a new issue