From 8c9f70444495e9a9e75577bc868ddc2e8b74c0cf Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 3 Nov 2015 13:41:16 +0000 Subject: [PATCH] * Calendar/CalDAV: recurring events with non-EGroupware participants (specified by email) were showing additional participants with cryptic mailto addresses (DB update required!) because egw_cal_user.cal_user_attendee in recurrences was lost due a typo, includes update script to fix existing entries --- calendar/inc/class.calendar_so.inc.php | 2 +- calendar/setup/setup.inc.php | 2 +- calendar/setup/tables_update.inc.php | 46 ++++++++++++++++++++++++-- 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/calendar/inc/class.calendar_so.inc.php b/calendar/inc/class.calendar_so.inc.php index f72a6ec003..231001b367 100644 --- a/calendar/inc/class.calendar_so.inc.php +++ b/calendar/inc/class.calendar_so.inc.php @@ -2149,7 +2149,7 @@ ORDER BY cal_user_type, cal_usre_id 'cal_status' => $status, 'cal_quantity' => $quantity, 'cal_role' => $role, - 'cal_attendee' => $type == 'e' ? substr($uid, 1) : null, + 'cal_user_attendee' => $type == 'e' ? substr($uid, 1) : null, ),array( 'cal_id' => $cal_id, 'cal_recur_date' => $start, diff --git a/calendar/setup/setup.inc.php b/calendar/setup/setup.inc.php index 515d5252d0..e6d720e063 100755 --- a/calendar/setup/setup.inc.php +++ b/calendar/setup/setup.inc.php @@ -10,7 +10,7 @@ */ $setup_info['calendar']['name'] = 'calendar'; -$setup_info['calendar']['version'] = '14.3.900'; +$setup_info['calendar']['version'] = '14.3.901'; $setup_info['calendar']['app_order'] = 3; $setup_info['calendar']['enable'] = 1; $setup_info['calendar']['index'] = 'calendar.calendar_uiviews.index&ajax=true'; diff --git a/calendar/setup/tables_update.inc.php b/calendar/setup/tables_update.inc.php index 148d616c7b..c7e2c044be 100644 --- a/calendar/setup/tables_update.inc.php +++ b/calendar/setup/tables_update.inc.php @@ -2573,7 +2573,7 @@ function calendar_upgrade14_3() // by ordering by status we prever accepted over tentative over unknow over deleted foreach($GLOBALS['egw_setup']->db->select('egw_cal_user', "cal_id,cal_recur_date,$email AS email", array( 'cal_user_type' => 'e', - ), __LINE__, __FILE__, false, "GROUP BY cal_id,cal_recur_date,$email HAVING COUNT(*)>1") as $row) + ), __LINE__, __FILE__, false, "GROUP BY cal_id,cal_recur_date,$email HAVING COUNT(*)>1", 'calendar') as $row) { $n = 0; foreach($GLOBALS['egw_setup']->db->select('egw_cal_user', "*,$email AS email", array( @@ -2581,7 +2581,7 @@ function calendar_upgrade14_3() 'cal_recur_date' => $row['cal_recur_date'], 'cal_user_type' => 'e', $email.'='.$GLOBALS['egw_setup']->db->quote($row['email']), - ), __LINE__, __FILE__, 'ORDER BY cal_status') as $user) // order A, T, U, X + ), __LINE__, __FILE__, false, 'ORDER BY cal_status', 'calendar') as $user) // order A, T, U, X { if (strpos($user['email'], '@') !== false && !$n++) continue; $GLOBALS['egw_setup']->db->delete('egw_cal_user', array_intersect_key($user, array_flip(array('cal_id','cal_recur_date','cal_user_type','cal_user_id','cal_status')))); @@ -2606,13 +2606,53 @@ function calendar_upgrade14_3() return $GLOBALS['setup_info']['calendar']['currentver'] = '14.3.001'; } +/** + * Fix NULL in egw_cal_user.cal_user_attendee for recurrences by using value from master (cal_recur_date=0) + * + * @return string + */ +function calendar_upgrade14_3_001() +{ + $GLOBALS['calendar_upgrade14_3_001-run'] = true; + + foreach($GLOBALS['egw_setup']->db->query("SELECT egw_cal_user.cal_id AS cal_id,egw_cal_user.cal_user_id AS cal_user_id,egw_cal_user.cal_user_attendee AS cal_user_attendee +FROM egw_cal_user +JOIN egw_cal_user user ON user.cal_id=egw_cal_user.cal_id AND user.cal_user_type='e' AND user.cal_user_id=egw_cal_user.cal_user_id AND user.cal_user_attendee IS NULL +WHERE egw_cal_user.cal_user_type='e' AND egw_cal_user.cal_user_attendee IS NOT NULL +GROUP BY egw_cal_user.cal_id,egw_cal_user.cal_user_id,egw_cal_user.cal_user_attendee", __LINE__, __FILE__) as $row) + { + $GLOBALS['egw_setup']->db->update('egw_cal_user', array( + 'cal_user_attendee' => $row['cal_user_attendee'], + ), array( + 'cal_id' => $row['cal_id'], + 'cal_user_type' => 'e', + 'cal_user_id' => $row['cal_user_id'], + 'cal_user_attendee IS NULL' + ), __LINE__, __FILE__, 'calendar'); + } + return $GLOBALS['setup_info']['calendar']['currentver'] = '14.3.002'; +} /** * Setting new index url from setup.inc.php * * @return string */ -function calendar_upgrade14_3_001() +function calendar_upgrade14_3_002() { return $GLOBALS['setup_info']['calendar']['currentver'] = '14.3.900'; } + +/** + * Setting new index url from setup.inc.php + * + * @return string + */ +function calendar_upgrade14_3_900() +{ + if (empty($GLOBALS['calendar_upgrade14_3_001-run'])) + { + calendar_upgrade14_3_001(); + } + return $GLOBALS['setup_info']['calendar']['currentver'] = '14.3.901'; +}