check if $query[append] already contains a GROUP BY clause, fixes SQL error when browsing /apps/infolog in EPL

This commit is contained in:
Ralf Becker 2016-10-07 14:32:26 +02:00
parent c3fb98f3c1
commit 4e2db6c789

View File

@ -902,6 +902,15 @@ class infolog_so
// do not return deleted attendees
$join .= " LEFT JOIN $this->users_table attendees ON main.info_id=attendees.info_id AND attendees.info_res_deleted IS NULL";
$group_by = ' GROUP BY main.info_id ';
// check if $query['append'] already contains a GROUP BY clause
if (stripos($query['append'], 'group by') !== false)
{
$query['append'] .= ',main.info_id ';
}
else
{
$query['append'] = $group_by;
}
$pid = 'AND ' . $this->db->expression($this->info_table,array('info_id_parent' => ($action == 'sp' ?$query['action_id'] : 0)));
if ($GLOBALS['egw_info']['user']['preferences']['infolog']['listNoSubs'] != '1' && $action != 'sp' ||
@ -952,7 +961,7 @@ class infolog_so
if (is_array($cols)) $cols = implode(',',$cols);
$cols .= ','.$this->db->group_concat('attendees.account_id').' AS info_responsible';
$rs = $this->db->query($sql='SELECT '.$mysql_calc_rows.' '.$distinct.' '.$cols.' '.$info_customfield.' '.$sql_query.
$query['append'].$group_by.' '.$ordermethod,__LINE__,__FILE__,
$query['append'].$ordermethod,__LINE__,__FILE__,
(int) $query['start'],isset($query['start']) ? (int) $query['num_rows'] : -1,false,Api\Db::FETCH_ASSOC);
//echo "<p>db::query('$sql',,,".(int)$query['start'].','.(isset($query['start']) ? (int) $query['num_rows'] : -1).")</p>\n";