Fix Usergroup filter #382

Merged
tonypartridge merged 1 commits from staging into staging 2019-03-09 22:33:50 +00:00
Showing only changes of commit c9d9f8b7a8 - Show all commits

View File

@ -10624,6 +10624,20 @@ class Interpretation extends Fields
$function[] = $this->_t(2) . "\$db = JFactory::getDbo();"; $function[] = $this->_t(2) . "\$db = JFactory::getDbo();";
$function[] = PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) . " Create a new query object."; $function[] = PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) . " Create a new query object.";
$function[] = $this->_t(2) . "\$query = \$db->getQuery(true);"; $function[] = $this->_t(2) . "\$query = \$db->getQuery(true);";
// check if usergroup as we change to an object query
if ($filter['type'] === 'usergroup') {
$function[] = PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) . " Select the text.";
$function[] = $this->_t(2) . "\$query->select(\$db->quoteName('g." . $filter['code'] . "', 'id'));";
$function[] = $this->_t(2) . "\$query->select(\$db->quoteName('ug.title', 'title'));";
$function[] = $this->_t(2) . "\$query->from(\$db->quoteName('#__" . $component . "_" . $filter['database'] . "', 'g'));";
$function[] = $this->_t(2) . "\$query->join('LEFT', \$db->quoteName('#__usergroups', 'ug') . ' ON (' . (\$db->quoteName('g." . $filter['code'] . "') . ' = ' . \$db->quoteName('ug.id') . ')'));";
$function[] = $this->_t(2) . "\$query->order(\$db->quoteName('title') . ' ASC');";
$function[] = $this->_t(2) . "\$query->group(\$db->quoteName('ug.id'));";
$function[] = PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) . " Reset the query using our newly populated query object.";
$function[] = $this->_t(2) . "\$db->setQuery(\$query);";
$function[] = PHP_EOL . $this->_t(2) . "\$results = \$db->loadObjectList();";
} else {
$function[] = PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) . " Select the text."; $function[] = PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) . " Select the text.";
$function[] = $this->_t(2) . "\$query->select(\$db->quoteName('" . $filter['code'] . "'));"; $function[] = $this->_t(2) . "\$query->select(\$db->quoteName('" . $filter['code'] . "'));";
$function[] = $this->_t(2) . "\$query->from(\$db->quoteName('#__" . $component . "_" . $filter['database'] . "'));"; $function[] = $this->_t(2) . "\$query->from(\$db->quoteName('#__" . $component . "_" . $filter['database'] . "'));";
@ -10631,9 +10645,13 @@ class Interpretation extends Fields
$function[] = PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) . " Reset the query using our newly populated query object."; $function[] = PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) . " Reset the query using our newly populated query object.";
$function[] = $this->_t(2) . "\$db->setQuery(\$query);"; $function[] = $this->_t(2) . "\$db->setQuery(\$query);";
$function[] = PHP_EOL . $this->_t(2) . "\$results = \$db->loadColumn();"; $function[] = PHP_EOL . $this->_t(2) . "\$results = \$db->loadColumn();";
}
$function[] = PHP_EOL . $this->_t(2) . "if (\$results)"; $function[] = PHP_EOL . $this->_t(2) . "if (\$results)";
$function[] = $this->_t(2) . "{"; $function[] = $this->_t(2) . "{";
// check if translated vlaue is used
// check if translated value is used
if ($translation) if ($translation)
{ {
$function[] = $this->_t(3) . "//" . $this->setLine(__LINE__) . " get model"; $function[] = $this->_t(3) . "//" . $this->setLine(__LINE__) . " get model";
@ -10644,7 +10662,8 @@ class Interpretation extends Fields
$function[] = $this->_t(3) . "foreach (\$results as \$" . $filter['code'] . ")"; $function[] = $this->_t(3) . "foreach (\$results as \$" . $filter['code'] . ")";
$function[] = $this->_t(3) . "{"; $function[] = $this->_t(3) . "{";
// check if translated vlaue is used
// check if translated value is used
if ($translation) if ($translation)
{ {
$function[] = $this->_t(4) . "//" . $this->setLine(__LINE__) . " Translate the " . $filter['code'] . " selection"; $function[] = $this->_t(4) . "//" . $this->setLine(__LINE__) . " Translate the " . $filter['code'] . " selection";
@ -10657,6 +10676,11 @@ class Interpretation extends Fields
$function[] = $this->_t(4) . "//" . $this->setLine(__LINE__) . " Now add the " . $filter['code'] . " and its text to the options array"; $function[] = $this->_t(4) . "//" . $this->setLine(__LINE__) . " Now add the " . $filter['code'] . " and its text to the options array";
$function[] = $this->_t(4) . "\$_filter[] = JHtml::_('select.option', \$" . $filter['code'] . ", JFactory::getUser(\$" . $filter['code'] . ")->name);"; $function[] = $this->_t(4) . "\$_filter[] = JHtml::_('select.option', \$" . $filter['code'] . ", JFactory::getUser(\$" . $filter['code'] . ")->name);";
} }
else if ($filter['type'] === 'usergroup')
{
$function[] = $this->_t(4) . "//" . $this->setLine(__LINE__) . " Now add the " . $filter['code'] . " and its text to the options array";
$function[] = $this->_t(4) . "\$_filter[] = JHtml::_('select.option', \$" . $filter['code'] . "->id, \$" . $filter['code'] . "->title);";
}
else else
{ {
$function[] = $this->_t(4) . "//" . $this->setLine(__LINE__) . " Now add the " . $filter['code'] . " and its text to the options array"; $function[] = $this->_t(4) . "//" . $this->setLine(__LINE__) . " Now add the " . $filter['code'] . " and its text to the options array";