* @link http://status.net/
*/
-if (!defined('GNUSOCIAL') && !defined('STATUSNET')) {
- exit(1);
-}
+if (!defined('GNUSOCIAL')) { exit(1); }
/**
* List users for autocompletion
{
$max=0;
foreach($this->profiles as $profile){
- $max = max($max,strtotime($user->modified),strtotime($profile->modified));
+ $max = max($max, strtotime($profile->modified));
}
foreach($this->groups as $group){
$max = max($max,strtotime($group->modified));
protected function prepare(array $args=array())
{
// If we die, show short error messages.
- StatusNet::setApi(true);
+ GNUsocial::setApi(true);
parent::prepare($args);
- $cur = common_current_user();
- if (!$cur) {
- // TRANS: Client exception in autocomplete plugin.
- throw new ClientException(_m('Access forbidden.'), true);
- }
-
$this->groups=array();
$this->profiles=array();
$term = $this->arg('term');
$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));
+ . ' where subscriber = %d)', $this->scoped->id));
if ($profile->find()) {
while($profile->fetch()) {
$this->profiles[]=clone($profile);
$group = new User_group();
$group->limit($limit);
$group->whereAdd('nickname like \'' . trim($group->escape($term), '\'') . '%\'');
+ //Can't post to groups we're not subscribed to...:
+ $group->whereAdd(sprintf('id in (SELECT group_id FROM group_member'
+ . ' WHERE profile_id = %d)', $this->scoped->id));
if($group->find()){
while($group->fetch()) {
$this->groups[]=clone($group);
$results = array();
foreach($this->profiles as $profile){
$avatarUrl = $profile->avatarUrl(AVATAR_MINI_SIZE);
+ $acct = $profile->getAcctUri();
+ $identifier = explode(':', $profile->getAcctUri(), 2)[1];
$results[] = array(
- 'value' => '@'.$profile->nickname,
- 'nickname' => $profile->nickname,
- 'label'=> $profile->getFancyName(),
+ 'value' => '@'.$identifier,
+ 'nickname' => $profile->getNickname(),
+ 'acct_uri' => $acct,
+ 'label'=> "${identifier} (".$profile->getFullname().")",
'avatar' => $avatarUrl,
'type' => 'user'
);
}
foreach($this->groups as $group){
+ $profile = $group->getProfile();
// sigh.... encapsulate this upstream!
if ($group->mini_logo) {
$avatarUrl = $group->mini_logo;
} else {
$avatarUrl = User_group::defaultLogo(AVATAR_MINI_SIZE);
}
+ $acct = $profile->getAcctUri();
+ $identifier = explode(':', $profile->getAcctUri(), 2)[1];
$results[] = array(
- 'value' => '!'.$group->nickname,
- 'nickname' => $group->nickname,
- 'label'=> $group->getFancyName(),
+ 'value' => '!'.$group->getNickname(),
+ 'nickname' => $group->getNickname(),
+ 'acct_uri' => $acct,
+ 'label'=> "${identifier} (".$group->getFullname().")",
'avatar' => $avatarUrl,
'type' => 'group');
}