$offset = ($this->page-1) * PROFILES_PER_PAGE;
$limit = PROFILES_PER_PAGE + 1;
- $subscribers = $this->user->getSubscribers($offset, $limit);
+ if ($this->tag) {
+ $subscribers = $this->user->getTaggedSubscribers($this->tag, $offset, $limit);
+ } else {
+ $subscribers = $this->user->getSubscribers($offset, $limit);
+ }
if ($subscribers) {
$subscribers_list = new SubscribersList($subscribers, $this->user, $this);
$offset = ($this->page-1) * PROFILES_PER_PAGE;
$limit = PROFILES_PER_PAGE + 1;
- $subscriptions = $this->user->getSubscriptions($offset, $limit);
+ if ($this->tag) {
+ $subscriptions = $this->user->getTaggedSubscriptions($this->tag, $offset, $limit);
+ } else {
+ $subscriptions = $this->user->getSubscriptions($offset, $limit);
+ }
if ($subscriptions) {
$subscriptions_list = new SubscriptionsList($subscriptions, $this->user, $this);
return $profile;
}
+
+ function getTaggedSubscribers($tag, $offset=0, $limit=null)
+ {
+ $qry =
+ 'SELECT profile.* ' .
+ 'FROM profile JOIN subscription ' .
+ 'ON profile.id = subscription.subscriber ' .
+ 'JOIN profile_tag ON (profile_tag.tagged = subscription.subscriber ' .
+ 'AND profile_tag.tagger = subscription.subscribed) ' .
+ 'WHERE subscription.subscribed = %d ' .
+ 'AND profile_tag.tag = "%s" ' .
+ 'AND subscription.subscribed != subscription.subscriber ' .
+ 'ORDER BY subscription.created DESC ';
+
+ if ($offset) {
+ if (common_config('db','type') == 'pgsql') {
+ $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
+ } else {
+ $qry .= ' LIMIT ' . $offset . ', ' . $limit;
+ }
+ }
+
+ $profile = new Profile();
+
+ $cnt = $profile->query(sprintf($qry, $this->id, $tag));
+
+ return $profile;
+ }
+
+ function getTaggedSubscriptions($tag, $offset=0, $limit=null)
+ {
+ $qry =
+ 'SELECT profile.* ' .
+ 'FROM profile JOIN subscription ' .
+ 'ON profile.id = subscription.subscribed ' .
+ 'JOIN profile_tag on (profile_tag.tagged = subscription.subscribed ' .
+ 'AND profile_tag.tagger = subscription.subscriber) ' .
+ 'WHERE subscription.subscriber = %d ' .
+ 'AND profile_tag.tag = "%s" ' .
+ 'AND subscription.subscribed != subscription.subscriber ' .
+ 'ORDER BY subscription.created DESC ';
+
+ if (common_config('db','type') == 'pgsql') {
+ $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
+ } else {
+ $qry .= ' LIMIT ' . $offset . ', ' . $limit;
+ }
+
+ $profile = new Profile();
+
+ $profile->query(sprintf($qry, $this->id, $tag));
+
+ return $profile;
+ }
}
var $profile = null;
var $user = null;
var $page = null;
+ var $tag = null;
function prepare($args)
{
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
+ $this->tag = $this->trimmed('tag');
+
return true;
}
# Post from the tag dropdown; redirect to a GET
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
- common_redirect($this->self_url(), 307);
+ common_redirect($this->selfUrl(), 307);
return;
}
array('href' =>
common_local_url($this->trimmed('action'),
array('nickname' =>
- $profile->nickname))),
+ $this->user->nickname))),
_('All'));
$this->elementEnd('li');
$this->elementStart('li', array('id'=>'filter_tags_item'));
$this->out->elementStart('ul', 'tags xoxo');
foreach ($tags as $tag) {
$this->out->elementStart('li');
- $this->element('span', 'mark_hash', '#');
+ $this->out->element('span', 'mark_hash', '#');
$this->out->element('a', array('rel' => 'tag',
- 'href' => common_local_url($this->action,
+ 'href' => common_local_url($this->action->trimmed('action'),
array('nickname' => $this->owner->nickname,
'tag' => $tag))),
$tag);