X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FAutocomplete%2Factions%2Fautocomplete.php;fp=plugins%2FAutocomplete%2Factions%2Fautocomplete.php;h=fce00145732c7065a571384d3460d3f2d5ca91a1;hb=834ecd0f80209a44935f730d81466810cdc3c779;hp=787ef15326e195c167af3b54424ff1bc049f8351;hpb=862a2dab3f2b54b09cf672ecca8b74098d3a9717;p=quix0rs-gnu-social.git diff --git a/plugins/Autocomplete/actions/autocomplete.php b/plugins/Autocomplete/actions/autocomplete.php index 787ef15326..fce0014573 100644 --- a/plugins/Autocomplete/actions/autocomplete.php +++ b/plugins/Autocomplete/actions/autocomplete.php @@ -2,7 +2,7 @@ /** * StatusNet, the distributed open-source microblogging tool * - * List users for autocompletion + * List profiles and groups for autocompletion * * PHP version 5 * @@ -29,7 +29,7 @@ * @link http://status.net/ */ -if (!defined('STATUSNET') && !defined('LACONICA')) { +if (!defined('GNUSOCIAL') && !defined('STATUSNET')) { exit(1); } @@ -62,8 +62,8 @@ class AutocompleteAction extends Action function lastModified() { $max=0; - foreach($this->users as $user){ - $max = max($max,strtotime($user->modified),strtotime($user->getProfile()->modified)); + foreach($this->profiles as $profile){ + $max = max($max,strtotime($user->modified),strtotime($profile->modified)); } foreach($this->groups as $group){ $max = max($max,strtotime($group->modified)); @@ -103,19 +103,22 @@ class AutocompleteAction extends Action } $this->groups=array(); - $this->users=array(); + $this->profiles=array(); $term = $this->arg('term'); $limit = $this->arg('limit'); if($limit > 200) $limit=200; //prevent DOS attacks if(substr($term,0,1)=='@'){ - //user search + //profile search $term=substr($term,1); - $user = new User(); - $user->limit($limit); - $user->whereAdd('nickname like \'' . trim($user->escape($term), '\'') . '%\''); - if($user->find()){ - while($user->fetch()) { - $this->users[]=clone($user); + $profile = new Profile(); + $profile->limit($limit); + $profile->whereAdd('nickname like \'' . trim($profile->escape($term), '\'') . '%\''); + $profile->whereAdd(sprintf('id in (SELECT id FROM user) OR ' + . 'id in (SELECT subscribed from subscription' + . ' where subscriber = %d)', $cur->id)); + if ($profile->find()) { + while($profile->fetch()) { + $this->profiles[]=clone($profile); } } } @@ -139,8 +142,7 @@ class AutocompleteAction extends Action parent::handle(); $results = array(); - foreach($this->users as $user){ - $profile = $user->getProfile(); + foreach($this->profiles as $profile){ $avatarUrl = $profile->avatarUrl(AVATAR_MINI_SIZE); $results[] = array( 'value' => '@'.$profile->nickname,