3 * StatusNet, the distributed open-source microblogging tool
5 * Action for showing profiles self-tagged with a given tag
9 * LICENCE: This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Affero General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Affero General Public License for more details.
19 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 * @author Evan Prodromou <evan@status.net>
25 * @author Zach Copley <zach@status.net>
26 * @copyright 2009 StatusNet, Inc.
27 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
28 * @link http://status.net/
31 if (!defined('STATUSNET') && !defined('LACONICA')) {
35 require_once INSTALLDIR.'/lib/profilelist.php';
38 * This class outputs a paginated list of profiles self-tagged with a given tag
42 * @author Evan Prodromou <evan@status.net>
43 * @author Zach Copley <zach@status.net>
44 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
45 * @link http://status.net/
50 class PeopletagAction extends Action
57 * For initializing members of the class.
59 * @param array $argarray misc. arguments
61 * @return boolean true
63 function prepare($argarray)
65 parent::prepare($argarray);
67 $this->tag = $this->trimmed('tag');
69 if (!common_valid_profile_tag($this->tag)) {
70 $this->clientError(sprintf(_('Not a valid people tag: %s'),
75 $this->page = ($this->arg('page')) ? $this->arg('page') : 1;
77 common_set_returnto($this->selfUrl());
85 * @param array $argarray is ignored since it's now passed in in prepare()
87 * @return boolean is read only action?
89 function handle($argarray)
91 parent::handle($argarray);
96 * Whips up a query to get a list of profiles based on the provided
97 * people tag and page, initalizes a ProfileList widget, and displays
102 function showContent()
105 $profile = new Profile();
107 $offset = ($this->page - 1) * PROFILES_PER_PAGE;
108 $limit = PROFILES_PER_PAGE + 1;
110 if (common_config('db', 'type') == 'pgsql') {
111 $lim = ' LIMIT ' . $limit . ' OFFSET ' . $offset;
113 $lim = ' LIMIT ' . $offset . ', ' . $limit;
116 // XXX: memcached this
118 $qry = 'SELECT profile.* ' .
119 'FROM profile JOIN profile_tag ' .
120 'ON profile.id = profile_tag.tagger ' .
121 'WHERE profile_tag.tagger = profile_tag.tagged ' .
123 'ORDER BY profile_tag.modified DESC%s';
125 $profile->query(sprintf($qry, $this->tag, $lim));
127 $pl = new ProfileList($profile, $this);
130 $this->pagination($this->page > 1,
131 $cnt > PROFILES_PER_PAGE,
134 array('tag' => $this->tag));
138 * Returns the page title
140 * @return string page title
144 return sprintf(_('Users self-tagged with %1$s - page %2$d'),
145 $this->tag, $this->page);