mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-06-25 20:31:31 +02:00
* Addressbook/PostgreSQL: fix SQL error when last/next date column is enabled
This commit is contained in:
parent
da2d6aad50
commit
8f03a02308
@ -1694,35 +1694,37 @@ class Contacts extends Contacts\Storage
|
|||||||
$calendars = array();
|
$calendars = array();
|
||||||
$bocal = new calendar_bo();
|
$bocal = new calendar_bo();
|
||||||
$type_field = $type=='u' ? 'account_id' : 'contact_id';
|
$type_field = $type=='u' ? 'account_id' : 'contact_id';
|
||||||
$sql = 'SELECT n_fn,org_name,'.$type_field.' AS user_id,
|
$concat_start_id_recurrance = $this->db->concat('cal_start',"':'",'egw_cal_user.cal_id',"':'",'cal_recur_date');
|
||||||
|
$now = $this->db->unix_timestamp('NOW()');
|
||||||
|
$sql = "SELECT n_fn,org_name,$type_field AS user_id,
|
||||||
(
|
(
|
||||||
select concat(cal_start,":",egw_cal_user.cal_id,":",cal_recur_date)
|
SELECT $concat_start_id_recurrance
|
||||||
from egw_cal_user
|
|
||||||
JOIN egw_cal_dates on egw_cal_dates.cal_id=egw_cal_user.cal_id and (cal_recur_date=0 or cal_recur_date=cal_start)
|
|
||||||
JOIN egw_cal ON egw_cal.cal_id=egw_cal_user.cal_id AND egw_cal.cal_deleted IS NULL
|
|
||||||
WHERE cal_user_type="'.$type.'" and cal_user_id='.$type_field.' and cal_start < unix_timestamp(now())';
|
|
||||||
if ( !$GLOBALS['egw_info']['user']['preferences']['calendar']['show_rejected'])
|
|
||||||
{
|
|
||||||
$sql .= ' AND egw_cal_user.cal_status != "R"';
|
|
||||||
}
|
|
||||||
$sql .= '
|
|
||||||
order by cal_start DESC Limit 1
|
|
||||||
) as last_event,
|
|
||||||
(
|
|
||||||
select concat(cal_start,":",egw_cal_user.cal_id,":",cal_recur_date)
|
|
||||||
FROM egw_cal_user
|
FROM egw_cal_user
|
||||||
JOIN egw_cal_dates on egw_cal_dates.cal_id=egw_cal_user.cal_id and (cal_recur_date=0 or cal_recur_date=cal_start)
|
JOIN egw_cal_dates on egw_cal_dates.cal_id=egw_cal_user.cal_id and (cal_recur_date=0 or cal_recur_date=cal_start)
|
||||||
JOIN egw_cal ON egw_cal.cal_id=egw_cal_user.cal_id AND egw_cal.cal_deleted IS NULL
|
JOIN egw_cal ON egw_cal.cal_id=egw_cal_user.cal_id AND egw_cal.cal_deleted IS NULL
|
||||||
WHERE cal_user_type="'.$type.'" and cal_user_id='.$type_field.' and cal_start > unix_timestamp(now())';
|
WHERE cal_user_type='$type' and cal_user_id=$type_field and cal_start < $now";
|
||||||
if ( !$GLOBALS['egw_info']['user']['preferences']['calendar']['show_rejected'])
|
if ( !$GLOBALS['egw_info']['user']['preferences']['calendar']['show_rejected'])
|
||||||
{
|
{
|
||||||
$sql .= ' AND egw_cal_user.cal_status != "R"';
|
$sql .= " AND egw_cal_user.cal_status != 'R'";
|
||||||
|
}
|
||||||
|
$sql .= "
|
||||||
|
order by cal_start DESC Limit 1
|
||||||
|
) as last_event,
|
||||||
|
(
|
||||||
|
SELECT $concat_start_id_recurrance
|
||||||
|
FROM egw_cal_user
|
||||||
|
JOIN egw_cal_dates on egw_cal_dates.cal_id=egw_cal_user.cal_id and (cal_recur_date=0 or cal_recur_date=cal_start)
|
||||||
|
JOIN egw_cal ON egw_cal.cal_id=egw_cal_user.cal_id AND egw_cal.cal_deleted IS NULL
|
||||||
|
WHERE cal_user_type='$type' and cal_user_id=$type_field and cal_start > $now";
|
||||||
|
if ( !$GLOBALS['egw_info']['user']['preferences']['calendar']['show_rejected'])
|
||||||
|
{
|
||||||
|
$sql .= " AND egw_cal_user.cal_status != 'R'";
|
||||||
}
|
}
|
||||||
$sql .= 'order by cal_recur_date ASC, cal_start ASC Limit 1
|
$sql .= 'order by cal_recur_date ASC, cal_start ASC Limit 1
|
||||||
|
|
||||||
) as next_event
|
) as next_event
|
||||||
FROM egw_addressbook
|
FROM egw_addressbook
|
||||||
WHERE '.$type_field.' IN ('.implode(',', array_map(array($this->db, 'quote'), $uids)).')';
|
WHERE '.$this->db->expression('egw_addressbook', array($type_field => $uids));
|
||||||
|
|
||||||
|
|
||||||
$contacts =& $this->db->query($sql, __LINE__, __FILE__);
|
$contacts =& $this->db->query($sql, __LINE__, __FILE__);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user