mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-27 00:09:13 +01:00
fixed some problems with r34529: move all filtering into SQL query
- group-calendar empty - owner-too filter fixed - events with multiple users with differnt status and group invitation fixed
This commit is contained in:
parent
52be51f4bf
commit
da95032505
@ -448,7 +448,10 @@ class calendar_bo
|
||||
$offset = isset($params['offset']) && $params['offset'] !== false ? (int) $params['offset'] : false;
|
||||
// socal::search() returns rejected group-invitations, as only the user not also the group is rejected
|
||||
// as we cant remove them efficiantly in SQL, we kick them out here, but only if just one user is displayed
|
||||
$remove_rejected_by_user = !in_array($filter,array('all','rejected','owner')) && count($params['users']) == 1 ? $params['users'][0] : null;
|
||||
$users_in = (array)$params_in['users'];
|
||||
$remove_rejected_by_user = !in_array($filter,array('all','rejected')) &&
|
||||
count($users_in) == 1 && $users_in[0] > 0 ? $users_in[0] : null;
|
||||
//error_log(__METHOD__.'('.array2string($params_in).", $sql_filter) params[users]=".array2string($params['users']).' --> remove_rejected_by_user='.array2string($remove_rejected_by_user));
|
||||
|
||||
if ($this->debug && ($this->debug > 1 || $this->debug == 'search'))
|
||||
{
|
||||
|
@ -520,14 +520,19 @@ class calendar_so
|
||||
|
||||
if ($remove_rejected_by_user)
|
||||
{
|
||||
$rejected_by_user_join = "JOIN $this->user_table rejected_by_user".
|
||||
$rejected_by_user_join = "LEFT JOIN $this->user_table rejected_by_user".
|
||||
" ON $this->cal_table.cal_id=rejected_by_user.cal_id".
|
||||
" AND rejected_by_user.cal_user_type='u'".
|
||||
" AND rejected_by_user.cal_user_id=".$this->db->quote($remove_rejected_by_user).
|
||||
" AND rejected_by_user.cal_status!='R'";
|
||||
$where[] = "(recur_type IS NULL AND rejected_by_user.cal_recur_date=0 OR cal_start=rejected_by_user.cal_recur_date)";
|
||||
" AND (recur_type IS NULL AND rejected_by_user.cal_recur_date=0 OR cal_start=rejected_by_user.cal_recur_date)";
|
||||
$or_required = array(
|
||||
'rejected_by_user.cal_status IS NULL',
|
||||
"rejected_by_user.cal_status!='R'",
|
||||
);
|
||||
if ($filter == 'owner') $or_required[] = 'cal_owner='.(int)$remove_rejected_by_user;
|
||||
$where[] = '('.implode(' OR ',$or_required).')';
|
||||
}
|
||||
//$starttime = microtime(true);
|
||||
//$starttime = microtime(true);
|
||||
if ($useUnionQuery)
|
||||
{
|
||||
// allow apps to supply participants and/or icons
|
||||
@ -536,7 +541,7 @@ class calendar_so
|
||||
// changed the original OR in the query into a union, to speed up the query execution under MySQL 5
|
||||
$select = array(
|
||||
'table' => $this->cal_table,
|
||||
'join' => "JOIN $this->dates_table ON $this->cal_table.cal_id=$this->dates_table.cal_id JOIN $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id $rejected_by_user_join LEFT JOIN $this->repeats_table ON $this->cal_table.cal_id=$this->repeats_table.cal_id",
|
||||
'join' => "JOIN $this->dates_table ON $this->cal_table.cal_id=$this->dates_table.cal_id JOIN $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id LEFT JOIN $this->repeats_table ON $this->cal_table.cal_id=$this->repeats_table.cal_id $rejected_by_user_join",
|
||||
'cols' => $cols,
|
||||
'where' => $where,
|
||||
'app' => 'calendar',
|
||||
@ -623,7 +628,7 @@ class calendar_so
|
||||
$where,__LINE__,__FILE__,$offset,$params['append'].' ORDER BY '.$params['order'],'calendar',$num_rows,
|
||||
"JOIN $this->dates_table ON $this->cal_table.cal_id=$this->dates_table.cal_id JOIN $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id $rejected_by_user_join LEFT JOIN $this->repeats_table ON $this->cal_table.cal_id=$this->repeats_table.cal_id");
|
||||
}
|
||||
//error_log(__METHOD__."() useUnionQuery=$useUnionQuery --> query took ".(microtime(true)-$starttime));
|
||||
//error_log(__METHOD__."() useUnionQuery=$useUnionQuery --> query took ".(microtime(true)-$starttime));
|
||||
if (isset($params['cols']))
|
||||
{
|
||||
return $rs; // if colums are specified we return the recordset / iterator
|
||||
|
Loading…
Reference in New Issue
Block a user