Files
actions
accessadminpanel.php
addpeopletag.php
all.php
allrss.php
apiaccountratelimitstatus.php
apiaccountregister.php
apiaccountupdatebackgroundcolor.php
apiaccountupdatedeliverydevice.php
apiaccountupdatelinkcolor.php
apiaccountupdateprofile.php
apiaccountupdateprofileimage.php
apiaccountverifycredentials.php
apiatomservice.php
apiattachment.php
apiblockcreate.php
apiblockdestroy.php
apicheckhub.php
apichecknickname.php
apiconversation.php
apiexternalprofileshow.php
apifriendshipscreate.php
apifriendshipsdestroy.php
apifriendshipsexists.php
apifriendshipsshow.php
apignusocialconfig.php
apignusocialversion.php
apigroupadmins.php
apigroupcreate.php
apigroupismember.php
apigroupjoin.php
apigroupleave.php
apigrouplist.php
apigrouplistall.php
apigroupmembership.php
apigroupprofileupdate.php
apigroupshow.php
apihelptest.php
apilist.php
apilistmember.php
apilistmembers.php
apilistmemberships.php
apilists.php
apilistsubscriber.php
apilistsubscribers.php
apilistsubscriptions.php
apimediaupload.php
apioauthaccesstoken.php
apioauthauthorize.php
apioauthpin.php
apioauthrequesttoken.php
apisearchatom.php
apisearchjson.php
apistatusesdestroy.php
apistatusesshow.php
apistatusesupdate.php
apisubscriptions.php
apitimelinefriends.php
apitimelinegroup.php
apitimelinehome.php
apitimelinelist.php
apitimelinementions.php
apitimelinenetworkpublic.php
apitimelinepublic.php
apitimelinetag.php
apitimelineuser.php
apitrends.php
apiuserfollowers.php
apiuserfriends.php
apiuserprofileimage.php
apiusershow.php
approvegroup.php
approvesub.php
atompubmembershipfeed.php
atompubshowmembership.php
atompubshowsubscription.php
atompubsubscriptionfeed.php
attachment.php
attachment_thumbnail.php
avatarbynickname.php
avatarsettings.php
backupaccount.php
block.php
blockedfromgroup.php
cancelgroup.php
cancelsubscription.php
confirmaddress.php
conversation.php
deleteaccount.php
deleteapplication.php
deletegroup.php
deletenotice.php
deleteuser.php
doc.php
editapplication.php
editgroup.php
editpeopletag.php
emailsettings.php
featured.php
foaf.php
foafgroup.php
geocode.php
getfile.php
grantrole.php
groupblock.php
groupbyid.php
grouplogo.php
groupmembers.php
groupqueue.php
grouprss.php
groups.php
groupsearch.php
groupunblock.php
imsettings.php
invite.php
joingroup.php
leavegroup.php
licenseadminpanel.php
login.php
logout.php
makeadmin.php
microsummary.php
networkpublic.php
newapplication.php
newgroup.php
newnotice.php
noticesearch.php
noticesearchrss.php
nudge.php
oauthappssettings.php
oauthconnectionssettings.php
oldschoolsettings.php
opensearch.php
otp.php
passwordsettings.php
pathsadminpanel.php
peoplesearch.php
peopletag.php
peopletagautocomplete.php
peopletagged.php
peopletagsbyuser.php
peopletagsforuser.php
peopletagsubscribers.php
peopletagsubscriptions.php
plugindisable.php
pluginenable.php
pluginsadminpanel.php
profilecompletion.php
profilesettings.php
profiletagbyid.php
public.php
publicrss.php
publictagcloud.php
recoverpassword.php
redirect.php
redirecturl.php
register.php
removepeopletag.php
replies.php
repliesrss.php
restoreaccount.php
revokerole.php
robotstxt.php
rsd.php
sandbox.php
selftag.php
sessionsadminpanel.php
showapplication.php
showgroup.php
shownotice.php
showprofiletag.php
showstream.php
silence.php
siteadminpanel.php
sitenoticeadminpanel.php
smssettings.php
startpage.php
subedit.php
subqueue.php
subscribe.php
subscribepeopletag.php
subscribers.php
subscriptions.php
sup.php
tag.php
tagprofile.php
tagrss.php
top.php
unblock.php
unsandbox.php
unsilence.php
unsubscribe.php
unsubscribepeopletag.php
urlsettings.php
useradminpanel.php
userbyid.php
usergroups.php
userrss.php
version.php
avatar
background
classes
db
doc-src
extlib
file
js
lib
local
locale
mail-src
plugins
scripts
socialfy-your-domain
tests
theme
.gitignore
CONFIGURE
COPYING
EVENTS.txt
INSTALL
Makefile
PLUGINS.txt
README.md
TODO.SOCIAL
UPGRADE
apple-touch-icon.png
favicon.ico
htaccess.sample
index.php
install.php
lighttpd.conf.example
gnu-social/actions/peopletagautocomplete.php
Mikael Nordfeldth c00491cd7a Cosmetic changes to common_redirect, clientError, serverError
Since these functions exit (or throw exception) after running, there
is no need to have a 'return' statement or similar afterwards.
2014-03-10 00:25:57 +01:00

125 lines
3.2 KiB
PHP

<?php
/**
* StatusNet - the distributed open-source microblogging tool
* Copyright (C) 2008-2010, StatusNet, Inc.
*
* Peopletag autocomple action.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* PHP version 5
*
* @category Action
* @package StatusNet
* @author Shashi Gowda <connect2shashi@gmail.com>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
* @link http://status.net/
*/
if (!defined('STATUSNET')) {
exit(1);
}
class PeopletagautocompleteAction extends Action
{
var $user;
var $tags;
var $last_mod;
/**
* Check pre-requisites and instantiate attributes
*
* @param Array $args array of arguments (URL, GET, POST)
*
* @return boolean success flag
*/
function prepare($args)
{
parent::prepare($args);
// Only for logged-in users
$this->user = common_current_user();
if (empty($this->user)) {
// TRANS: Error message displayed when trying to perform an action that requires a logged in user.
$this->clientError(_('Not logged in.'));
}
// CSRF protection
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
// TRANS: Client error displayed when the session token does not match or is not given.
$this->clientError(_('There was a problem with your session token.'.
' Try again, please.'));
}
$profile = $this->user->getProfile();
$tags = $profile->getLists(common_current_user());
$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['url'] = $tags->homeUrl();
$arr['freq'] = $tags->taggedCount();
$this->tags[] = $arr;
}
$tags = NULL;
return true;
}
/**
* Last modified time
*
* Helps in browser-caching
*
* @return String time
*/
function lastModified()
{
return strtotime($this->last_mod);
}
/**
* Handle request
*
* Print the JSON autocomplete data
*
* @param Array $args unused.
*
* @return void
*/
function handle($args)
{
//common_log(LOG_DEBUG, 'Autocomplete data: ' . json_encode($this->tags));
if ($this->tags) {
print(json_encode($this->tags));
exit(0);
}
return false;
}
}