Skip to content

Commit

Permalink
altered list model buildQuerySelect() now accepts a jQueryBuilder obj…
Browse files Browse the repository at this point in the history
…ect as second parameter. Changed calendar viz to use buildQuerySelect() to get all of the lists data, needed for canEditRow/canDeleteRow plugins which are run on the data (this fixes issue where those plugins were not correctly applied to the calendar event edit/delete buttons)
  • Loading branch information
pollen8 committed Dec 4, 2013
1 parent 141d97f commit f1eb3a5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
35 changes: 29 additions & 6 deletions components/com_fabrik/models/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -2540,11 +2540,12 @@ private function selectSlug(&$fields)
* Get the select part of the query
*
* @param string $mode list/form - effects which elements are selected
* @param JQueryBuilder $query Querybuilder (false to return string)
*
* @return string
* @return mixed string if $query = false, otherwise $query
*/

public function buildQuerySelect($mode = 'list')
public function buildQuerySelect($mode = 'list', $query = false)
{
$profiler = JProfiler::getInstance('Application');
JDEBUG ? $profiler->mark('queryselect: start') : null;
Expand All @@ -2571,16 +2572,38 @@ public function buildQuerySelect($mode = 'list')
{
$sfields .= ', ';
$strPKey = $pk . ' AS ' . $db->quoteName('__pk_val') . "\n";
$query = 'SELECT ' . $calc_found_rows . ' DISTINCT ' . $sfields . $strPKey;

if ($query)
{
$query->select($calc_found_rows . ' DISTINCT ' . $sfields . $strPKey);
}
else
{
$sql = 'SELECT ' . $calc_found_rows . ' DISTINCT ' . $sfields . $strPKey;
}
}
else
{
$query = 'SELECT ' . $calc_found_rows . ' DISTINCT ' . trim($sfields, ", \n") . "\n";
if ($query)
{
$query->select($calc_found_rows . ' DISTINCT ' . $sfields);
}
else
{
$sql = 'SELECT ' . $calc_found_rows . ' DISTINCT ' . trim($sfields, ", \n") . "\n";
}
}

$query .= ' FROM ' . $db->quoteName($table->db_table_name) . " \n";
if ($query)
{
$query->from($db->quoteName($table->db_table_name));
}
else
{
$sql .= ' FROM ' . $db->quoteName($table->db_table_name) . " \n";
}

return $query;
return $query ? $query : $sql;
}

/**
Expand Down
4 changes: 1 addition & 3 deletions plugins/fabrik_visualization/calendar/models/calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,6 @@ public function getEvents()
// If db join selected for the label we need to get the label element and not the value
$label = FabrikString::safeColName($els[$qlabel]->getOrderByName());

// $$$ hugh @TODO doesn't seem to work for join elements, so adding hack till I can talk
// to rob about this one.
if (method_exists($els[$qlabel], 'getJoinLabelColumn'))
{
$label = $els[$qlabel]->getJoinLabelColumn();
Expand All @@ -465,11 +463,11 @@ public function getEvents()
$pk = $listModel->getTable()->db_primary_key;
$status = empty($data['status']) ? '""' : $data['status'];
$query = $db->getQuery(true);
$query = $listModel->buildQuerySelect('list', $query);
$status = trim($data['status']) !== '' ? FabrikString::safeColName($data['status']) : "''";
$query->select($pk . ' AS id, ' . $pk . ' AS rowid, ' . $startdate . ' AS startdate, ' . $enddate . ' AS enddate')
->select('"" AS link, ' . $label . ' AS label, ' . $db->quote($data['colour']) . ' AS colour, 0 AS formid')
->select($status . ' AS status')
->from($table->db_table_name)
->order($startdate . ' ASC');
$query = $listModel->buildQueryJoin($query);
$query = $listModel->buildQueryWhere(true, $query);
Expand Down

0 comments on commit f1eb3a5

Please sign in to comment.