diff --git a/calendar/inc/class.bocalupdate.inc.php b/calendar/inc/class.bocalupdate.inc.php index b81a4ec9be..cf8d5e1739 100644 --- a/calendar/inc/class.bocalupdate.inc.php +++ b/calendar/inc/class.bocalupdate.inc.php @@ -101,6 +101,7 @@ class bocalupdate extends bocal { return false; } + if (!$event['id']) // some defaults for new entries { // if no owner given, set user to owner @@ -138,6 +139,7 @@ class bocalupdate extends bocal } return false; } + // check for conflicts only happens !$ignore_conflicts AND if start + end date are given if (!$ignore_conflicts && !$event['non_blocking'] && isset($event['start']) && isset($event['end'])) { @@ -258,6 +260,7 @@ class bocalupdate extends bocal return $conflicts; } } + // save the event to the database if ($touch_modified) { @@ -278,6 +281,7 @@ class bocalupdate extends bocal { return $cal_id; } + $event = $this->read($cal_id); // we re-read the event, in case only partial information was update and we need the full info for the notifies //echo "new $cal_id="; _debug_array($event); @@ -293,6 +297,7 @@ class bocalupdate extends bocal else // update existing event { $this->check4update($event,$old_event); + } // notify the link-class about the update, as other apps may be subscribt to it $this->link->notify_update('calendar',$cal_id,$event); @@ -693,6 +698,7 @@ class bocalupdate extends bocal { return false; } + // invalidate the read-cache if it contains the event we store now if ($event['id'] && $event['id'] == $this->cached_event['id']) $this->cached_event = array(); @@ -704,10 +710,8 @@ class bocalupdate extends bocal if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0; } // Lock realized with a counter, that is checked and incremented as we save the entry - $check_etag = $event['etag']; - if (!$check_etag){ - $check_etag=$check_etag+1; - } + $check_etag = ($event['etag'] ? $event['etag']:1); + // same with the recur exceptions if (isset($event['recur_exception']) && is_array($event['recur_exception'])) { @@ -1118,7 +1122,7 @@ class bocalupdate extends bocal */ function update_edit_user(&$event2update) { - $event2update['cal_edit_time']=$this->now_su; + $event2update['edit_time']=$this->now_su; return $this->so->save_edit_user($event2update); } } diff --git a/calendar/inc/class.socal.inc.php b/calendar/inc/class.socal.inc.php index fef71d5dbe..969c34bde0 100644 --- a/calendar/inc/class.socal.inc.php +++ b/calendar/inc/class.socal.inc.php @@ -499,7 +499,6 @@ ORDER BY cal_user_type, cal_usre_id $cal_id = (int) $event['id']; unset($event['id']); - $set_recurrences = !$cal_id && $event['recur_type'] != MCAL_RECUR_NONE; // add colum prefix 'cal_' if there's not already a 'recur_' prefix @@ -514,15 +513,16 @@ ORDER BY cal_user_type, cal_usre_id if (is_array($event['cal_category'])) $event['cal_category'] = implode(',',$event['cal_category']); // while saving handle the etag as condition for the update, to check if an entry was saved before this action occured - $check_etag = $event['cal_etag']; + $check_etag = ($check_modified ? $check_modified : $event['cal_etag']); if ($cal_id) { $event['cal_etag']=$check_etag+1; $event['cal_edit_user']=NULL; $event['cal_edit_time']=NULL; - $where = array('cal_id' => $cal_id); - if ($check_etag) $where['cal_etag'] = $check_etag; + // cal_etag will be set on first save (if not set) + $where = array('cal_id' => $cal_id,'cal_etag'=>$check_etag); + #if ($check_etag) $where['cal_etag'] = $check_etag; if (!$this->db->update($this->cal_table,$event,$where,__LINE__,__FILE__)) { //error_log("### socal::write(".print_r($event,true).") where=".print_r($where,true)." returning false"); @@ -535,6 +535,8 @@ ORDER BY cal_user_type, cal_usre_id return 0; // someone else updated the modtime or deleted the entry } + } else { + $event['cal_etag']=$check_modified; } if ($cal_id) @@ -1152,6 +1154,15 @@ ORDER BY cal_user_type, cal_usre_id $cal_id = (int) $event2update['id']; //unset($event2update['id']); + // add colum prefix 'cal_' if there's not already a 'recur_' prefix + foreach($event2update as $col => $val) + { + if ($col{0} != '#' && substr($col,0,6) != 'recur_' && $col != 'alarm') + { + $event2update['cal_'.$col] = $val; + unset($event2update[$col]); + } + } if ($cal_id && $event2update['cal_edit_user'] && $event2update['cal_edit_time']) { diff --git a/calendar/inc/class.uiforms.inc.php b/calendar/inc/class.uiforms.inc.php index cb1a8635b5..dfea4904e5 100644 --- a/calendar/inc/class.uiforms.inc.php +++ b/calendar/inc/class.uiforms.inc.php @@ -416,7 +416,7 @@ class uiforms extends uical $event['button_was'] = $button; // remember for ignore return $this->conflicts($event,$conflicts,$preserv); } - elseif ($conflicts ==0) + elseif ($conflicts ===0) { $msg .= ($msg ? ', ' : '') .lang('Error: the entry has been updated since you opened it for editing!').'
'. lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','DB"; - $event2update['id']=$event['id']; - $event2update['cal_edit_user']=$this->user; - $event2update['cal_edit_time']=''; // this is set in bo->update_edit_user - $this->bo->update_edit_user($event2update); - } - else - { - if ($event['edit_user'] && $event['edit_user']!=$this->user) $content['msg'].=" ".lang('This entry is opened by user: ').$GLOBALS['egw']->accounts->id2name($event['edit_user']); + if ($locktime) { + // the warning and the saving of edit_user and time will only be performed, if there is a lock time set + if (($this->bo->now_su>($event['edit_time']+$locktime)) || ($event['edit_time']=='')) + { + //echo "write Lock!!->DB"; + $event2update['id']=$event['id']; + $event2update['edit_user']=$this->user; + $event2update['edit_time']=''; // this is set in bo->update_edit_user + $this->bo->update_edit_user($event2update); + } + else + { + if ($event['edit_user'] && $event['edit_user']!=$this->user) $content['msg'].=" ".lang('This entry is opened by user: ').$GLOBALS['egw']->accounts->id2name($event['edit_user']); + } + } else { + } // non_interactive==true from $_GET calls immediate save action without displaying the edit form if(isset($_GET['non_interactive']) && (bool)$_GET['non_interactive'] === true)