Skip to content

Commit

Permalink
upgrader
Browse files Browse the repository at this point in the history
  • Loading branch information
KellyLSB committed Apr 19, 2012
1 parent 8592090 commit 15edbe6
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions extend/sql/library/extensions/taxonomy.php
Expand Up @@ -269,11 +269,15 @@ public function modelPrioritizeTag(Model $model, $map = false, $priority = 0, $u
else return true;
}

public function listExcludeTag(ListObj $list, $map, $or = false) {
return $this->listHasTag($list, $map, $or, true);
}

/**
* Filtering function for lists
* @author Kelly Becker
*/
public function listHasTag(ListObj $list, $map = false, $or = false) {
public function listHasTag(ListObj $list, $map = false, $or = false, $opposite = false) {
if(!isset($list->__taxonomy_cache)) $list->__taxonomy_cache = array();

/**
Expand Down Expand Up @@ -316,6 +320,9 @@ public function listHasTag(ListObj $list, $map = false, $or = false) {
$list->__taxonomy_cache[($or ? 'O' : 'A').':'.$model][] = $id;
}

if($opposite)
$list->__taxonomy_cache['opposite'] = true;

/**
* Return the list object
* @author Kelly Becker
Expand All @@ -332,6 +339,10 @@ public function list_on_run_query(ListObj $list) {

$tax_cache = $list->__taxonomy_cache;

if(isset($tax_cache['opposite']))
$opposite = $tax_cache['opposite'];
unset($tax_cache['opposite']);

foreach($tax_cache as $tag => $ids) {
$flag = substr($tag, 0, 1);
$tag = substr($tag, 2);
Expand Down Expand Up @@ -379,7 +390,11 @@ public function list_on_run_query(ListObj $list) {

if(empty($query)) continue;

$query = "`id` IN (SELECT `owner` FROM `\$tags $list->_table` WHERE $query)";
if($opposite)
$opposite = "NOT ";
else $opposite = '';

$query = "`id` $opposite IN (SELECT `owner` FROM `\$tags $list->_table` WHERE $query)";
$list->manual_condition($query);
}

Expand Down

0 comments on commit 15edbe6

Please sign in to comment.