Skip to content

Commit

Permalink
Excluded deleted Questions from All views
Browse files Browse the repository at this point in the history
  • Loading branch information
snytkine committed May 17, 2011
1 parent 801f923 commit 90b4468
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 26 deletions.
26 changes: 10 additions & 16 deletions lib/Lampcms/Controllers/Tagged.php
Expand Up @@ -56,8 +56,8 @@
/**
* Controller for rendering page
* with list of questions for specific tag or tags
*
*
*
*
* @author Dmitri Snytkine
*
*/
Expand All @@ -78,18 +78,18 @@ class Tagged extends Unanswered
* Conditions can be == 'unanswered', 'hot', 'recent' (default)
*/
protected function getCursor(){

/**
* Must call getTags() before
* using this->rawTags because
* it is set inside the getTags() method
*
*
*
*
*/
$this->aTags = $this->getTags();
$this->pagerPath = '/tagged/'.$this->rawTags;


d('aTags: '.print_r($this->aTags, 1));

$aFields = array();
Expand All @@ -105,14 +105,8 @@ protected function getCursor(){
$sort = array('i_ts' => -1);

$where = array('a_tags' => array('$all' => $this->aTags) );
$where['i_del_ts'] = null;

/**
* Exclude deleted items unless viewer
* is a moderator
*/
if(!$this->oRegistry->Viewer->isModerator()){
$where['i_del_ts'] = null;
}

/**
* @todo
Expand All @@ -131,8 +125,8 @@ protected function getCursor(){
return $this;
}



protected function makeRecentTags(){

/**
Expand Down Expand Up @@ -174,7 +168,7 @@ protected function makeRecentTags(){
}

$this->makeFollowTagButton();

return $this;
}

Expand Down
18 changes: 8 additions & 10 deletions lib/Lampcms/Controllers/Unanswered.php
Expand Up @@ -90,7 +90,7 @@ class Unanswered extends Viewquestions
* @var string
*/
protected $tags = '';

/**
* Tags
*/
Expand Down Expand Up @@ -141,7 +141,7 @@ protected function getCursor(){
case 'tagged':
$where = array('i_sel_ans' => null, 'a_tags' => array('$all' => $this->getTags()) );
$this->pagerPath = '/unanswered/tagged/'.$this->rawTags;
//'i_sel_ans' => null,
//'i_sel_ans' => null,
$this->typeDiv = Urhere::factory($this->oRegistry)->get('tplQuntypes', 'newest');
/**
* @todo
Expand All @@ -165,12 +165,10 @@ protected function getCursor(){
}

/**
* Exclude deleted items unless viewer
* is a moderator
* Exclude deleted items
*/
if(!$this->oRegistry->Viewer->isModerator()){
$where['i_del_ts'] = null;
}
$where['i_del_ts'] = null;

$this->oCursor = $this->oRegistry->Mongo->QUESTIONS->find($where);
$this->count = $this->oCursor->count(true);
d('$this->oCursor: '.gettype($this->oCursor).' $this->count: '.$this->count);
Expand Down Expand Up @@ -202,7 +200,7 @@ protected function addTagFollowers(){
*/
protected function getTags(){
if(empty($this->aTags)){

/**
* And now a workaround
* for the genocidal RewriteRule bug
Expand Down Expand Up @@ -252,12 +250,12 @@ protected function getTags(){
$this->rawTags = $tags;
$this->title = $this->tags;
d('this->title: '.$this->title);

if(empty($this->tags)){
return array();
}


$this->aTags = explode(' ', $this->tags);
$this->aTags = \array_filter($this->aTags);
d('aTags: '.print_r($this->aTags, 1));
Expand Down

0 comments on commit 90b4468

Please sign in to comment.