2008-11-20 22:42:07 +00:00
|
|
|
<?php
|
2009-02-08 21:25:48 +00:00
|
|
|
/**
|
2009-08-25 23:12:20 +01:00
|
|
|
* StatusNet, the distributed open-source microblogging tool
|
2008-11-20 22:42:07 +00:00
|
|
|
*
|
2009-02-08 21:25:48 +00:00
|
|
|
* Action for showing profiles self-tagged with a given tag
|
|
|
|
*
|
|
|
|
* PHP version 5
|
|
|
|
*
|
|
|
|
* LICENCE: This program is free software: you can redistribute it and/or modify
|
2008-11-20 22:42:07 +00:00
|
|
|
* 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/>.
|
2009-02-08 21:25:48 +00:00
|
|
|
*
|
|
|
|
* @category Action
|
2009-08-25 23:12:20 +01:00
|
|
|
* @package StatusNet
|
2009-08-25 23:19:04 +01:00
|
|
|
* @author Evan Prodromou <evan@status.net>
|
|
|
|
* @author Zach Copley <zach@status.net>
|
2009-08-25 23:12:20 +01:00
|
|
|
* @copyright 2009 StatusNet, Inc.
|
2009-02-08 21:25:48 +00:00
|
|
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
2009-08-25 23:16:46 +01:00
|
|
|
* @link http://status.net/
|
2008-11-20 22:42:07 +00:00
|
|
|
*/
|
|
|
|
|
2009-08-26 15:41:36 +01:00
|
|
|
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
2009-02-08 21:25:48 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
2008-11-20 22:42:07 +00:00
|
|
|
|
2009-01-24 10:44:32 +00:00
|
|
|
require_once INSTALLDIR.'/lib/profilelist.php';
|
2008-11-20 22:42:07 +00:00
|
|
|
|
2009-02-08 21:25:48 +00:00
|
|
|
/**
|
|
|
|
* This class outputs a paginated list of profiles self-tagged with a given tag
|
|
|
|
*
|
|
|
|
* @category Output
|
2009-08-25 23:12:20 +01:00
|
|
|
* @package StatusNet
|
2009-08-25 23:19:04 +01:00
|
|
|
* @author Evan Prodromou <evan@status.net>
|
|
|
|
* @author Zach Copley <zach@status.net>
|
2009-02-08 21:25:48 +00:00
|
|
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
2009-08-25 23:16:46 +01:00
|
|
|
* @link http://status.net/
|
2009-02-08 21:25:48 +00:00
|
|
|
*
|
|
|
|
* @see Action
|
|
|
|
*/
|
|
|
|
|
2008-12-23 19:49:23 +00:00
|
|
|
class PeopletagAction extends Action
|
|
|
|
{
|
2009-02-08 21:25:48 +00:00
|
|
|
|
|
|
|
var $tag = null;
|
2009-01-24 11:06:46 +00:00
|
|
|
var $page = null;
|
2009-02-08 21:25:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* For initializing members of the class.
|
|
|
|
*
|
|
|
|
* @param array $argarray misc. arguments
|
|
|
|
*
|
|
|
|
* @return boolean true
|
|
|
|
*/
|
|
|
|
function prepare($argarray)
|
2008-12-23 19:33:23 +00:00
|
|
|
{
|
2009-02-08 21:25:48 +00:00
|
|
|
parent::prepare($argarray);
|
2008-11-20 22:42:07 +00:00
|
|
|
|
2009-01-24 11:06:46 +00:00
|
|
|
$this->tag = $this->trimmed('tag');
|
2008-11-20 22:42:07 +00:00
|
|
|
|
2009-01-24 11:06:46 +00:00
|
|
|
if (!common_valid_profile_tag($this->tag)) {
|
2009-11-08 21:26:13 +00:00
|
|
|
$this->clientError(sprintf(_('Not a valid user tag: %s'),
|
2009-02-08 21:25:48 +00:00
|
|
|
$this->tag));
|
2008-12-23 19:19:07 +00:00
|
|
|
return;
|
|
|
|
}
|
2008-11-20 22:42:07 +00:00
|
|
|
|
2009-02-08 21:25:48 +00:00
|
|
|
$this->page = ($this->arg('page')) ? $this->arg('page') : 1;
|
2008-11-20 22:42:07 +00:00
|
|
|
|
2009-02-08 21:25:48 +00:00
|
|
|
common_set_returnto($this->selfUrl());
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handler method
|
|
|
|
*
|
|
|
|
* @param array $argarray is ignored since it's now passed in in prepare()
|
|
|
|
*
|
|
|
|
* @return boolean is read only action?
|
|
|
|
*/
|
|
|
|
function handle($argarray)
|
|
|
|
{
|
|
|
|
parent::handle($argarray);
|
2009-01-24 11:06:46 +00:00
|
|
|
$this->showPage();
|
2009-01-24 10:44:32 +00:00
|
|
|
}
|
2009-02-08 21:25:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Whips up a query to get a list of profiles based on the provided
|
|
|
|
* people tag and page, initalizes a ProfileList widget, and displays
|
|
|
|
* it to the user.
|
|
|
|
*
|
|
|
|
* @return nothing
|
|
|
|
*/
|
2009-01-24 11:06:46 +00:00
|
|
|
function showContent()
|
2008-12-23 19:33:23 +00:00
|
|
|
{
|
2009-02-08 21:25:48 +00:00
|
|
|
|
2008-12-23 19:19:07 +00:00
|
|
|
$profile = new Profile();
|
2008-11-20 22:42:07 +00:00
|
|
|
|
2009-02-08 21:25:48 +00:00
|
|
|
$offset = ($this->page - 1) * PROFILES_PER_PAGE;
|
|
|
|
$limit = PROFILES_PER_PAGE + 1;
|
|
|
|
|
|
|
|
if (common_config('db', 'type') == 'pgsql') {
|
2008-12-23 19:19:07 +00:00
|
|
|
$lim = ' LIMIT ' . $limit . ' OFFSET ' . $offset;
|
|
|
|
} else {
|
|
|
|
$lim = ' LIMIT ' . $offset . ', ' . $limit;
|
|
|
|
}
|
2008-11-20 22:42:07 +00:00
|
|
|
|
2009-02-08 21:25:48 +00:00
|
|
|
// XXX: memcached this
|
|
|
|
|
2009-01-25 10:03:49 +00:00
|
|
|
$qry = 'SELECT profile.* ' .
|
|
|
|
'FROM profile JOIN profile_tag ' .
|
|
|
|
'ON profile.id = profile_tag.tagger ' .
|
|
|
|
'WHERE profile_tag.tagger = profile_tag.tagged ' .
|
2009-03-11 23:41:30 +00:00
|
|
|
"AND tag = '%s' " .
|
2009-02-08 21:25:48 +00:00
|
|
|
'ORDER BY profile_tag.modified DESC%s';
|
|
|
|
|
2009-01-25 10:03:49 +00:00
|
|
|
$profile->query(sprintf($qry, $this->tag, $lim));
|
2008-11-20 22:42:07 +00:00
|
|
|
|
2009-06-17 16:21:53 +01:00
|
|
|
$pl = new ProfileList($profile, $this);
|
2009-01-24 10:44:32 +00:00
|
|
|
$cnt = $pl->show();
|
2009-02-08 21:25:48 +00:00
|
|
|
|
2009-01-24 11:06:46 +00:00
|
|
|
$this->pagination($this->page > 1,
|
2008-12-23 19:19:07 +00:00
|
|
|
$cnt > PROFILES_PER_PAGE,
|
2009-01-24 11:06:46 +00:00
|
|
|
$this->page,
|
2009-02-08 21:25:48 +00:00
|
|
|
'peopletag',
|
2009-01-24 11:06:46 +00:00
|
|
|
array('tag' => $this->tag));
|
|
|
|
}
|
2009-02-08 21:25:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the page title
|
|
|
|
*
|
|
|
|
* @return string page title
|
|
|
|
*/
|
|
|
|
function title()
|
2009-01-24 11:06:46 +00:00
|
|
|
{
|
2009-02-08 21:25:48 +00:00
|
|
|
return sprintf(_('Users self-tagged with %s - page %d'),
|
|
|
|
$this->tag, $this->page);
|
2008-12-23 19:19:07 +00:00
|
|
|
}
|
2009-02-08 21:25:48 +00:00
|
|
|
|
2008-11-20 22:42:07 +00:00
|
|
|
}
|