123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- <?php
- if (!defined('STATUSNET')) {
- exit(1);
- }
- class PeopletagautocompleteAction extends Action
- {
- var $user;
- var $tags;
- var $last_mod;
-
- function prepare($args)
- {
- parent::prepare($args);
-
- $this->user = common_current_user();
- if (empty($this->user)) {
-
- $this->clientError(_('Not logged in.'));
- }
-
- $token = $this->trimmed('token');
- if (!$token || $token != common_session_token()) {
-
- $this->clientError(_('There was a problem with your session token.'.
- ' Try again, please.'));
- }
- $profile = $this->user->getProfile();
- $tags = $profile->getLists($this->scoped);
- $this->tags = array();
- while ($tags->fetch()) {
- if (empty($this->last_mod)) {
- $this->last_mod = $tags->modified;
- }
- $arr = array();
- $arr['tag'] = $tags->tag;
- $arr['mode'] = $tags->private ? 'private' : 'public';
-
- $arr['freq'] = $tags->taggedCount();
- $this->tags[] = $arr;
- }
- $tags = NULL;
- return true;
- }
-
- function lastModified()
- {
- return strtotime($this->last_mod);
- }
-
- function handle($args)
- {
-
- if ($this->tags) {
- print(json_encode($this->tags));
- exit(0);
- }
- return false;
- }
- }
|