Revision: 18625 http://svn.sv.gnu.org/viewvc/?view=rev&root=phpgroupware&revision=18625 Author: johang Date: 2008-06-26 10:22:26 +0000 (Thu, 26 Jun 2008)
Log Message: ----------- * Added parameter to bocalendar::update() for not doing UI stuff like redirecting, printing HTML or calling exit(). * Clean-up/readabiliy. Modified Paths: -------------- trunk/calendar/inc/class.bocalendar.inc.php trunk/calendar/templates/base/header.inc.php Modified: trunk/calendar/inc/class.bocalendar.inc.php =================================================================== --- trunk/calendar/inc/class.bocalendar.inc.php 2008-06-26 10:21:19 UTC (rev 18624) +++ trunk/calendar/inc/class.bocalendar.inc.php 2008-06-26 10:22:26 UTC (rev 18625) @@ -690,30 +690,40 @@ return $this->so->list_events_keyword($keywords,$members); } - function update($params = '') + function update($params = '', $send_to_ui = TRUE) { - $l_cal = isset($params['cal']) && $params['cal'] ? $params['cal'] : phpgw::get_var('cal', 'string', 'POST'); - $l_participants = isset($params['participants']) ? $params['participants'] : phpgw::get_var('participants', 'string', 'POST'); - $l_categories = isset($params['categories']) ? $params['categories'] : phpgw::get_var('categories', 'string', 'POST'); - $l_start = isset($params['start']) && $params['start'] ? $params['start'] : phpgw::get_var('start', 'string', 'POST'); - $l_end = isset($params['end']) && $params['end'] ? $params['end'] : phpgw::get_var('end', 'string', 'POST'); - $l_recur_enddate = isset($params['recur_enddate']) && $params['recur_enddate'] ? $params['recur_enddate'] : phpgw::get_var('recur_enddate', 'string', 'POST'); // probbaly can be bool - $l_recur_exception = explode(',', phpgw::get_var('recur_exception', 'string', 'POST') ); - - $send_to_ui = true; + $l_cal = isset($params['cal']) && is_array($params['cal']) ? + $params['cal'] : + phpgw::get_var('cal', 'string', 'POST'); + + $l_participants = isset($params['participants']) ? + $params['participants'] : + phpgw::get_var('participants', 'string', 'POST'); + + $l_categories = isset($params['categories']) ? + $params['categories'] : + phpgw::get_var('categories', 'string', 'POST'); + + $l_start = isset($params['start']) && $params['start'] ? + $params['start'] : + phpgw::get_var('start', 'string', 'POST'); + + $l_end = isset($params['end']) && $params['end'] ? + $params['end'] : + phpgw::get_var('end', 'string', 'POST'); + + $l_recur_enddate = isset($params['recur_enddate']) && $params['recur_enddate'] ? + $params['recur_enddate'] : + phpgw::get_var('recur_enddate', 'string', 'POST'); + + $l_recur_exception = explode(',', phpgw::get_var('recur_exception', 'string', 'POST')); + if($this->debug) { $send_to_ui = true; } - - /* no idea what is meant to happen here and triggers a lot of notices - if($p_cal || $p_participants || $p_start || $p_end || $p_recur_enddata) - { - $send_to_ui = false; - } - */ - print_debug('ID',$l_cal['id']); + print_debug('ID', $l_cal['id']); if( phpgw::get_var('readsess', 'bool', 'GET') ) { @@ -729,6 +739,7 @@ 'readsess' => 1 ) ); + $GLOBALS['phpgw']->common->phpgw_exit(True); } $overlapping_events = False; @@ -737,11 +748,13 @@ { if((!$l_cal['id'] && !$this->check_perms(PHPGW_ACL_ADD)) || ($l_cal['id'] && !$this->check_perms(PHPGW_ACL_EDIT,$l_cal['id']))) { + debug_print_backtrace(); ExecMethod('calendar.uicalendar.index'); $GLOBALS['phpgw']->common->phpgw_exit(); } print_debug('Prior to fix_update_time()'); + $this->fix_update_time($l_start); $this->fix_update_time($l_end); @@ -757,7 +770,9 @@ } $is_public = ($l_cal['private'] == 'public' ? 1 : 0); + $this->so->event_init(); + if ( is_array($l_categories) && count($l_categories) >= 2) { $this->so->set_category(implode(',',$l_categories)); @@ -766,13 +781,31 @@ { $this->so->set_category(strval($l_categories[0])); } + $this->so->set_title($l_cal['title']); + $this->so->set_description($l_cal['description']); - $this->so->set_start($l_start['year'],$l_start['month'],$l_start['mday'],$l_start['hour'],$l_start['min'],0); - $this->so->set_end($l_end['year'],$l_end['month'],$l_end['mday'],$l_end['hour'],$l_end['min'],0); + + $this->so->set_start( + $l_start['year'], $l_start['month'], $l_start['mday'], + $l_start['hour'], $l_start['min'], 0); + + $this->so->set_end( + $l_end['year'], $l_end['month'], $l_end['mday'], + $l_end['hour'], $l_end['min'], 0); + $this->so->set_class($is_public); - $this->so->add_attribute('reference',(@isset($l_cal['reference']) && $l_cal['reference']?$l_cal['reference']:0)); - $this->so->add_attribute('location',(@isset($l_cal['location']) && $l_cal['location']?$l_cal['location']:'')); + + $this->so->add_attribute( + 'reference', + isset($l_cal['reference']) && $l_cal['reference'] ? + $l_cal['reference'] : 0); + + $this->so->add_attribute( + 'location', + isset($l_cal['location']) && $l_cal['location'] ? + $l_cal['location'] : ''); + if($l_cal['id']) { $this->so->add_attribute('id',$l_cal['id']); @@ -787,7 +820,8 @@ } elseif (isset($l_recur_enddate['str'])) { - $l_recur_enddate = $this->_jscal->input2date($l_recur_enddate['str'],False,'mday'); + $l_recur_enddate = $this->_jscal->input2date( + $l_recur_enddate['str'], False, 'mday'); } switch(intval($l_cal['recur_type'])) @@ -820,12 +854,13 @@ break; } - if ( is_array($l_participants) && count($l_participants) ) - { + if(is_array($l_participants) && count($l_participants)) + { $parts = $l_participants; $minparts = min($l_participants); foreach ( $l_participants as $participant ) { + // this is a group? if ( substr($participant, 0, 2) == 'g_' ) { $members = $GLOBALS['phpgw']->accounts->member(substr($participant, 2) ); @@ -847,12 +882,15 @@ { $accept_type = 'U'; } + $this->so->add_attribute('participants', $accept_type, (int) $participant); } } } + $event = $this->get_cached_event(); + if(!is_int($minparts)) { $minparts = $this->owner; @@ -875,7 +913,9 @@ } } - $preserved = unserialize(phpgw::get_var('preserved', 'raw', 'POST')); + $preserved = unserialize( + phpgw::get_var('preserved', 'raw', 'POST')); + if ( is_array($preserved) ) { foreach($preserved as $name => $value) @@ -883,17 +923,20 @@ switch($name) { case 'owner': - $this->so->add_attribute('participants', (int) $value, $l_cal['owner']); + $this->so->add_attribute('participants', + (int)$value, $l_cal['owner']); break; default: - $this->so->add_attribute($name, phpgw::clean_value($value, 'string') ); + $this->so->add_attribute($name, + phpgw::clean_value($value, 'string')); } } } $event = $this->get_cached_event(); - if ($l_cal['alarmdays'] > 0 || $l_cal['alarmhours'] > 0 || - $l_cal['alarmminutes'] > 0) + if ((isset($l_cal['alarmdays']) && $l_cal['alarmdays'] > 0) || + isset($l_cal['alarmhours']) && $l_cal['alarmhours'] > 0 || + isset($l_cal['alarmminutes']) && $l_cal['alarmminutes'] > 0) { $time = $this->maketime($event['start']) - ($l_cal['alarmdays'] * 24 * 3600) - @@ -910,16 +953,21 @@ $event['recur_exception'] = $l_recur_exception; $this->store_to_appsession($event); + $datetime_check = $this->validate_update($event); + print_debug('bo->validated_update() returnval',$datetime_check); + if($datetime_check) { - ExecMethod('calendar.uicalendar.edit', - array( - 'cd' => $datetime_check, - 'readsess' => 1 - ) - ); + ExecMethod( + 'calendar.uicalendar.edit', + array( + 'cd' => $datetime_check, + 'readsess' => 1 + ) + ); + $GLOBALS['phpgw']->common->phpgw_exit(True); } @@ -947,12 +995,14 @@ { unset($GLOBALS['phpgw_info']['flags']['noheader']); unset($GLOBALS['phpgw_info']['flags']['nonavbar']); + ExecMethod('calendar.uicalendar.overlap', array( 'o_events' => $overlapping_events, 'this_event' => $event ) ); + $GLOBALS['phpgw']->common->phpgw_exit(True); } else @@ -964,30 +1014,42 @@ { if ( !isset($event['id']) ) { + print_debug('Adding event'); + $this->so->cal->event = $event; $this->so->add_entry($event); - $this->send_update(MSG_ADDED,$event['participants'],'',$this->get_cached_event()); + + $this->send_update(MSG_ADDED, $event['participants'], + '', $this->get_cached_event()); } else { - print_debug('Updating Event ID',$event['id']); + print_debug('Updating Event ID', $event['id']); + $new_event = $event; $old_event = $this->read_entry($event['id']); + $this->so->cal->event = $event; $this->so->add_entry($event); + $this->prepare_recipients($new_event,$old_event); } - $date = sprintf("%04d%02d%02d",$event['start']['year'],$event['start']['month'],$event['start']['mday']); + if($send_to_ui) { $this->read_sessiondata(); + if ($this->return_to) { - $GLOBALS['phpgw']->redirect_link('/index.php', $this->return_to); - $GLOBALS['phpgw']->common->phpgw_exit(); + $GLOBALS['phpgw']->redirect_link( + '/index.php', $this->return_to); } - Execmethod('calendar.uicalendar.index'); -// $GLOBALS['phpgw']->common->phpgw_exit(); + else + { + Execmethod('calendar.uicalendar.index'); + } + + $GLOBALS['phpgw']->common->phpgw_exit(); } } } @@ -2397,7 +2459,7 @@ * @param $new_event Event after the change */ function send_update($msg_type,$to_notify,$old_event,$new_event=False,$user=False) - { + {return; $returncode = true; //echo "<p>bocalendar::send_update(type=$msg_type,to_notify="; print_r($to_notify); echo ", old_event="; print_r($old_event); echo ", new_event="; print_r($new_event); echo ", user=$user)</p>\n"; if (!is_array($to_notify)) @@ -2698,6 +2760,7 @@ { if(isset($new_event['participants'][$old_userid])) { + $new_status = $new_event['participants'][$old_userid]; print_debug('Modifying event for user',$old_userid); $this->modified[intval($old_userid)] = $new_status; } Modified: trunk/calendar/templates/base/header.inc.php =================================================================== --- trunk/calendar/templates/base/header.inc.php 2008-06-26 10:21:19 UTC (rev 18624) +++ trunk/calendar/templates/base/header.inc.php 2008-06-26 10:22:26 UTC (rev 18625) @@ -45,7 +45,7 @@ $tpl->set_var('cols',7); } - $today = date('Ymd',$GLOBALS['phpgw']->datetime->users_localtime); + $today = date('Ymd', phpgwapi_datetime::user_localtime()); $col_width = 12; _______________________________________________ phpGroupWare-cvs mailing list phpGroupWare-cvs@gnu.org http://lists.gnu.org/mailman/listinfo/phpgroupware-cvs