Debug some of the subscriptions+tags problems
This commit is contained in:
parent
04d498784f
commit
d6879bfe0c
@ -75,7 +75,11 @@ class SubscribersAction extends GalleryAction
|
||||
$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);
|
||||
|
@ -84,7 +84,11 @@ class SubscriptionsAction extends GalleryAction
|
||||
$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);
|
||||
|
@ -575,4 +575,58 @@ class User extends Memcached_DataObject
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ class GalleryAction extends Action
|
||||
var $profile = null;
|
||||
var $user = null;
|
||||
var $page = null;
|
||||
var $tag = null;
|
||||
|
||||
function prepare($args)
|
||||
{
|
||||
@ -69,6 +70,8 @@ class GalleryAction extends Action
|
||||
|
||||
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
|
||||
|
||||
$this->tag = $this->trimmed('tag');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -84,7 +87,7 @@ class GalleryAction extends Action
|
||||
# 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;
|
||||
}
|
||||
|
||||
@ -124,7 +127,7 @@ class GalleryAction extends Action
|
||||
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'));
|
||||
|
@ -169,9 +169,9 @@ class ProfileList extends Widget
|
||||
$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);
|
||||
|
Loading…
Reference in New Issue
Block a user