Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* &tagField string optional Field that will be used to compare with given tags. Default: alias
* &matchAll int optional If set to 1, resource must have all specified tags. Default: 0
* &field string optional modResource field that will be used to compare with assigned resource ID
* &class string optional
*
* USAGE:
*
Expand All @@ -32,6 +33,7 @@
$matchAll = (int) $modx->getOption('matchAll', $scriptProperties, 0);
$field = $modx->getOption('field', $scriptProperties, 'id');
$where = $modx->fromJSON($where);
$class = $modx->getOption('class', $scriptProperties, 'modResource');
if ($where == false) {
$where = array();
}
Expand Down Expand Up @@ -133,9 +135,9 @@
}

if ($matchAll == 0) {
$where[] = "EXISTS (SELECT 1 FROM {$modx->getTableName('TaggerTagResource')} r WHERE r.tag IN (" . implode(',', $tagIDs) . ") AND r.resource = modResource." . $field . ")";
$where[] = "EXISTS (SELECT 1 FROM {$modx->getTableName('TaggerTagResource')} r WHERE r.tag IN (" . implode(',', $tagIDs) . ") AND r.resource = ".$class."." . $field . ")";
} else {
$where[] = "EXISTS (SELECT 1 as found FROM {$modx->getTableName('TaggerTagResource')} r WHERE r.tag IN (" . implode(',', $tagIDs) . ") AND r.resource = modResource." . $field . " GROUP BY found HAVING count(found) = " . $tagsCount . ")";
$where[] = "EXISTS (SELECT 1 as found FROM {$modx->getTableName('TaggerTagResource')} r WHERE r.tag IN (" . implode(',', $tagIDs) . ") AND r.resource = ".$class."." . $field . " GROUP BY found HAVING count(found) = " . $tagsCount . ")";
}

return $modx->toJSON($where);
return $modx->toJSON($where);