From f3397a4e27e39d8c0a8f3ca50cd7ea0332b67575 Mon Sep 17 00:00:00 2001 From: skeeter Date: Sun, 29 Jul 2001 22:09:24 +0000 Subject: [PATCH] Change to use associated arrays for internal storage of the calendar events. ** This is geared at SOAP support! ** ** This is now SOAP compatible! ** --- calendar/inc/class.bocalendar.inc.php | 223 +++++++++++-------- calendar/inc/class.socalendar.inc.php | 18 -- calendar/inc/class.socalendar__.inc.php | 110 +++++----- calendar/inc/class.socalendar_sql.inc.php | 123 +++++------ calendar/inc/class.uicalendar.inc.php | 250 ++++++++++------------ calendar/soap_client.php | 82 +++++++ calendar/soap_server.php | 50 +++++ 7 files changed, 495 insertions(+), 361 deletions(-) create mode 100755 calendar/soap_client.php create mode 100755 calendar/soap_server.php diff --git a/calendar/inc/class.bocalendar.inc.php b/calendar/inc/class.bocalendar.inc.php index 6f8df19545..a4262e7444 100755 --- a/calendar/inc/class.bocalendar.inc.php +++ b/calendar/inc/class.bocalendar.inc.php @@ -17,11 +17,56 @@ class bocalendar { var $public_functions = Array( - 'read_entries' => True, 'read_entry' => True, 'delete_entry' => True, 'update' => True, - 'preferences' => True + 'preferences' => True, + 'assoc_array' => True, + 'store_to_cache' => True + ); + + var $soap_functions = Array( + 'read_entry' => Array( + 'in' => Array( + 'int' + ), + 'out' => Array( + 'SOAPStruct' + ) + ), + 'delete_entry' => Array( + 'in' => Array( + 'int' + ), + 'out' => Array( + 'int' + ) + ), + 'update' => Array( + 'in' => Array( + 'array', + 'array', + 'array', + 'array', + 'array' + ), + 'out' => Array( + 'array' + ) + ), + 'store_to_cache' => Array( + 'in' => Array( + 'int', + 'int', + 'int', + 'int', + 'int', + 'int' + ), + 'out' => Array( + 'SOAPStruct' + ) + ) ); var $debug = False; @@ -48,6 +93,8 @@ var $modified; var $deleted; var $added; + + var $soap = False; var $use_session = False; @@ -180,7 +227,8 @@ { if($this->check_perms(PHPGW_ACL_READ)) { - return $this->so->read_entry($id); + $event = $this->so->read_entry($id); + return $event; } } @@ -210,7 +258,7 @@ { $event_id = $this->so->cal->deleted_events[$i]; $event = $this->so->read_entry($event_id); - $this->send_update(MSG_DELETED,$event->participants,$event); + $this->send_update(MSG_DELETED,$event['participants'],$event); } $this->so->expunge(); } @@ -219,35 +267,6 @@ function search_keywords($keywords) { return $this->so->list_events_keyword($keywords); -/* - $event_ids = $this->so->list_events_keyword($keywords); - $event_ids_repeating = $this->so->list_repeated_events_keyword($keywords); - - $c_event_ids = count($cached_event_ids); - $c_event_ids_repeating = count($cached_event_ids_repeating); - - if($this->debug) - { - echo "events cached : $c_event_ids : for : ".sprintf("%04d%02d%02d",$syear,$smonth,$sday)."
\n"; - echo "repeating events cached : $c_event_ids_repeating : for : ".sprintf("%04d%02d%02d",$syear,$smonth,$sday)."
\n"; - } - - if($c_cached_ids) - { - for($i=0;$i<$c_cached_ids;$i++) - { - $cached_events[] = $this->so->read_entry($event_ids[$i]); - } - } - - if($c_event_ids_repeating) - { - for($i=0;$i<$c_event_ids_repeating;$i++) - { - $cached_events[] = $this->so->read_entry($event_ids_repeating[$i]); - } - } -*/ } function update($p_cal=0,$p_participants=0,$p_start=0,$p_end=0,$p_recur_enddata=0) @@ -260,6 +279,12 @@ $end = ($p_end?$p_end:$end); $recur_enddate = ($p_recur_enddate?$p_recur_enddate:$recur_enddate); + $send_to_ui = True; + if($p_cal && $p_participants && $p_start && $p_end && $p_recur_enddata) + { + $send_to_ui = False; + } + $overlapping_events = False; $ui = CreateObject('calendar.uicalendar'); @@ -312,7 +337,6 @@ $recur_enddate['month'] = 0; $recur_enddate['mday'] = 0; } - $cal['recur_data'] = $cal['rpt_sun'] + $cal['rpt_mon'] + $cal['rpt_tue'] + $cal['rpt_wed'] + $cal['rpt_thu'] + $cal['rpt_fri'] + $cal['rpt_sat']; switch($cal['recur_type']) { @@ -323,6 +347,7 @@ $this->so->set_recur_daily($recur_enddate['year'],$recur_enddate['month'],$recur_enddate['mday'],$cal['recur_interval']); break; case MCAL_RECUR_WEEKLY: + $cal['recur_data'] = $cal['rpt_sun'] + $cal['rpt_mon'] + $cal['rpt_tue'] + $cal['rpt_wed'] + $cal['rpt_thu'] + $cal['rpt_fri'] + $cal['rpt_sat']; $this->so->set_recur_weekly($recur_enddate['year'],$recur_enddate['month'],$recur_enddate['mday'],$cal['recur_interval'],$cal['recur_data']); break; case MCAL_RECUR_MONTHLY_MDAY: @@ -367,12 +392,12 @@ @reset($part); while(list($key,$value) = each($part)) { - $this->so->add_attribute('participants['.$key.']','U'); + $this->so->add_attribute('participants','U',$key); } reset($participants); $event = $this->get_cached_event(); - if(!@$event->participants[$cal['owner']]) + if(!@$event['participants'][$cal['owner']]) { $this->so->add_attribute('owner',$minparts); } @@ -389,32 +414,42 @@ settype($start,'integer'); settype($end,'integer'); - $start = mktime($event->start->hour,$event->start->min,$event->start->sec,$event->start->month,$event->start->mday,$event->start->year) - $this->datetime->tz_offset; - $end = mktime($event->end->hour,$event->end->min,$event->end->sec,$event->end->month,$event->end->mday,$event->end->year) - $this->datetime->tz_offset; + $start = $this->maketime($event['start']) - $this->datetime->tz_offset; + $end = $this->maketime($event['end']) - $this->datetime->tz_offset; - $overlapping_events = $this->overlap($start,$end,$event->participants,$event->owner,$event->id); + $overlapping_events = $this->overlap($start,$end,$event['participants'],$event->owner,$event->id); } if($overlapping_events) { - $ui->overlap($overlapping_events,$event); + if($send_to_ui) + { + $ui->overlap($overlapping_events,$event); + } + else + { + return $overlapping_events; + } } else { - if(!$event->id) + if(!$event['id']) { $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 { $new_event = $event; - $old_event = $this->read_entry($new_event->id); + $old_event = $this->read_entry($new_event['id']); $this->prepare_recipients($new_event,$old_event); $this->so->add_entry($event); } - $date = sprintf("%04d%02d%02d",$event->start->year,$event->start->month,$event->start->mday); - $ui->index(); + $date = sprintf("%04d%02d%02d",$event['start']['year'],$event['start']['month'],$event['start']['mday']); + if($send_to_ui) + { + $ui->index(); + } } } @@ -499,6 +534,11 @@ unset($holiday); } + function maketime($time) + { + return mktime($time['hour'],$time['min'],$time['sec'],$time['month'],$time['mday'],$time['year']); + } + function can_user_edit($event) { $can_edit = False; @@ -554,17 +594,17 @@ { $error = 40; } - elseif (($this->datetime->time_valid($event->start->hour,$event->start->min,0) == False) || ($this->datetime->time_valid($event->end->hour,$event->end->min,0) == False)) + elseif (($this->datetime->time_valid($event['start']['hour'],$event['start']['min'],0) == False) || ($this->datetime->time_valid($event['end']['hour'],$event['end']['min'],0) == False)) { $error = 41; } - elseif (($this->datetime->date_valid($event->start->year,$event->start->month,$event->start->mday) == False) || ($this->datetime->date_valid($event->end->year,$event->end->month,$event->end->mday) == False) || ($this->datetime->date_compare($event->start->year,$event->start->month,$event->start->mday,$event->end->year,$event->end->month,$event->end->mday) == 1)) + elseif (($this->datetime->date_valid($event['start']['year'],$event['start']['month'],$event['start']['mday']) == False) || ($this->datetime->date_valid($event['end']['year'],$event['end']['month'],$event['end']['mday']) == False) || ($this->datetime->date_compare($event['start']['year'],$event['start']['month'],$event['start']['mday'],$event['end']['year'],$event['end']['month'],$event['end']['mday']) == 1)) { $error = 42; } - elseif ($this->datetime->date_compare($event->start->year,$event->start->month,$event->start->mday,$event->end->year,$event->end->month,$event->end->mday) == 0) + elseif ($this->datetime->date_compare($event['start']['year'],$event['start']['month'],$event['start']['mday'],$event['end']['year'],$event['end']['month'],$event['end']['mday']) == 0) { - if ($this->datetime->time_compare($event->start->hour,$event->start->min,0,$event->end->hour,$event->end->min,0) == 1) + if ($this->datetime->time_compare($event['start']['hour'],$event['start']['min'],0,$event['end']['hour'],$event['end']['min'],0) == 1) { $error = 42; } @@ -734,21 +774,21 @@ { $owner = $this->owner; } - if ($owner == $phpgw_info['user']['account_id'] || ($event->public==1) || ($this->check_perms(PHPGW_ACL_PRIVATE,$owner) && $event->public==0)) + if ($owner == $phpgw_info['user']['account_id'] || ($event['public']==1) || ($this->check_perms(PHPGW_ACL_PRIVATE,$owner) && $event['public']==0)) { return False; } - elseif($event->public == 0) + elseif($event['public'] == 0) { return True; } - elseif($event->public == 2) + elseif($event['public'] == 2) { $is_private = True; $groups = $phpgw->accounts->memberships($owner); while (list($key,$group) = each($groups)) { - if (strpos(' '.implode($event->groups,',').' ',$group['account_id'])) + if (strpos(' '.implode($event['groups'],',').' ',$group['account_id'])) { return False; } @@ -768,13 +808,13 @@ { return 'private'; } - elseif (strlen($event->$field) > 19) + elseif (strlen($event[$field]) > 19) { - return substr($event->$field, 0 , 19) . '...'; + return substr($event[$field], 0 , 19) . '...'; } else { - return $event->$field; + return $event[$field]; } } @@ -872,9 +912,9 @@ for($i=0;$icached_events[$date]);$i++) { $events = $this->cached_events[$date][$i]; - $events_id = $events->id; - $event_id = $event->id; - if($events->id == $event->id) + $events_id = $events['id']; + $event_id = $event['id']; + if($events['id'] == $event['id']) { $inserted = True; break; @@ -882,7 +922,7 @@ $year = substr($date,0,4); $month = substr($date,4,2); $day = substr($date,6,2); - if(date('Hi',mktime($event->start->hour,$event->start->min,$event->start->sec,$month,$day,$year)) < date('Hi',mktime($events->start->hour,$events->start->min,$events->start->sec,$month,$day,$year))) + if(date('Hi',mktime($event['start']['hour'],$event['start']['min'],$event['start']['sec'],$month,$day,$year)) < date('Hi',mktime($events['start']['hour'],$events['start']['min'],$events['start']['sec'],$month,$day,$year))) { for($j=count($this->cached_events[$date]);$j>=$i;$j--) { @@ -917,10 +957,10 @@ { $rep_events = $this->repeating_events[$i]; $id = $rep_events->id; - $event_beg_day = mktime(0,0,0,$rep_events->start->month,$rep_events->start->mday,$rep_events->start->year); - if($rep_events->recur_enddate->month != 0 && $rep_events->recur_enddate->mday != 0 && $rep_events->recur_enddate->year != 0) + $event_beg_day = mktime(0,0,0,$rep_events['start']['month'],$rep_events['start']['mday'],$rep_events['start']['year']); + if($rep_events['recur_enddate']['month'] != 0 && $rep_events['recur_enddate']['mday'] != 0 && $rep_events['recur_enddate']['year'] != 0) { - $event_recur_time = mktime($rep_events->recur_enddate->hour,$rep_events->recur_enddate->min,$rep_events->recur_enddate->sec,$rep_events->recur_enddate->month,$rep_events->recur_enddate->mday,$rep_events->recur_enddate->year); + $event_recur_time = $this->maketime($rep_events['recur_enddate']); } else { @@ -942,8 +982,8 @@ } else { - $freq = $rep_events->recur_interval; - $type = $rep_events->recur_type; + $freq = $rep_events['recur_interval']; + $type = $rep_events['recur_type']; switch($type) { case MCAL_RECUR_DAILY: @@ -986,35 +1026,35 @@ $check = MCAL_M_SATURDAY; break; } - if ($rep_events->recur_data & $check) + if ($rep_events['recur_data'] & $check) { $this->sort_event($rep_events,$search_date_full); } break; case MCAL_RECUR_MONTHLY_WDAY: - if ((($search_date_year - $rep_events->start->year) * 12 + $search_date_month - $rep_events->start->month) % $freq) + if ((($search_date_year - $rep_events['start']['year']) * 12 + $search_date_month - $rep_events['start']['month']) % $freq) { continue; } - if (($this->datetime->day_of_week($rep_events->start->year,$rep_events->start->month,$rep_events->start->mday) == $this->datetime->day_of_week($search_date_year,$search_date_month,$search_date_day)) && - (ceil($rep_events->start->mday/7) == ceil($search_date_day/7))) + if (($this->datetime->day_of_week($rep_events['start']['year'],$rep_events['start']['month'],$rep_events['start']['mday']) == $this->datetime->day_of_week($search_date_year,$search_date_month,$search_date_day)) && + (ceil($rep_events['start']['mday']/7) == ceil($search_date_day/7))) { $this->sort_event($rep_events,$search_date_full); } break; case MCAL_RECUR_MONTHLY_MDAY: - if ((($search_date_year - $rep_events->start->year) * 12 + $search_date_month - $rep_events->start->month) % $freq) + if ((($search_date_year - $rep_events['start']['year']) * 12 + $search_date_month - $rep_events['start']['month']) % $freq) { continue; } - if ($search_date_day == $rep_events->start->mday) + if ($search_date_day == $rep_events['start']['mday']) { $this->sort_event($rep_events,$search_date_full); } break; case MCAL_RECUR_YEARLY: - if (($search_date_year - $rep_events->start->year) % $freq) + if (($search_date_year - $rep_events['start']['year']) % $freq) { continue; } @@ -1086,8 +1126,8 @@ for($i=0;$i<$c_cached_ids;$i++) { $event = $this->so->read_entry($cached_event_ids[$i]); - $starttime = mktime($event->start->hour,$event->start->min,$event->start->sec,$event->start->month,$event->start->mday,$event->start->year); - $endtime = mktime($event->end->hour,$event->end->min,$event->end->sec,$event->end->month,$event->end->mday,$event->end->year); + $starttime = $this->maketime($event['start']); + $endtime = $this->maketime($event['end']); $this->cached_events[date('Ymd',$starttime)][] = $event; if($this->cached_events[date('Ymd',$endtime)][count($this->cached_events[date('Ymd',$starttime)]) - 1] != $event) { @@ -1109,6 +1149,7 @@ $this->check_repeating_events($date); } } + return $this->cached_events; } /* Begin Appsession Data */ @@ -1359,7 +1400,7 @@ } $private = $this->is_private($event,$part); $time_display = $phpgw->common->show_date($eventstart['raw'],$this->users_timeformat).'-'.$phpgw->common->show_date($eventend['raw'],$this->users_timeformat); - $time_description = '('.$time_display.') '.$this->get_short_field($event,$private,'title').$this->display_status($event->participants[$part]); + $time_description = '('.$time_display.') '.$this->get_short_field($event,$private,'title').$this->display_status($event['participants'][$part]); for($m=$startminute;$m<=$endminute;$m++) { $index = ($hour + (($m * $increment) * 100)); @@ -1378,15 +1419,15 @@ switch($status) { case REJECTED: - $this->send_update(MSG_REJECTED,$old_event->participants,$old_event); + $this->send_update(MSG_REJECTED,$old_event['participants'],$old_event); $this->so->set_status($cal_id,$status); break; case TENTATIVE: - $this->send_update(MSG_TENTATIVE,$old_event->participants,$old_event); + $this->send_update(MSG_TENTATIVE,$old_event['participants'],$old_event); $this->so->set_status($cal_id,$status); break; case ACCEPTED: - $this->send_update(MSG_ACCEPTED,$old_event->participants,$old_event); + $this->send_update(MSG_ACCEPTED,$old_event['participants'],$old_event); $this->so->set_status($cal_id,$status); break; } @@ -1415,7 +1456,7 @@ if($old_event != False) { - $t_old_start_time = mktime($old_event->start->hour,$old_event->start->min,$old_event->start->sec,$old_event->start->month,$old_event->start->mday,$old_event->start->year); + $t_old_start_time = $this->maketime($old_event['start']); if($t_old_start_time < (time() - 86400)) { return False; @@ -1447,32 +1488,32 @@ { case MSG_DELETED: $action = 'Deleted'; - $event_id = $old_event->id; + $event_id = $old_event['id']; $msgtype = '"calendar";'; break; case MSG_MODIFIED: $action = 'Modified'; - $event_id = $old_event->id; + $event_id = $old_event['id']; $msgtype = '"calendar"; Version="'.$version.'"; Id="'.$new_event->id.'"'; break; case MSG_ADDED: $action = 'Added'; - $event_id = $new_event->id; + $event_id = $new_event['id']; $msgtype = '"calendar"; Version="'.$version.'"; Id="'.$new_event->id.'"'; break; case MSG_REJECTED: $action = 'Rejected'; - $event_id = $old_event->id; + $event_id = $old_event['id']; $msgtype = '"calendar";'; break; case MSG_TENTATIVE: $action = 'Tentative'; - $event_id = $old_event->id; + $event_id = $old_event['id']; $msgtype = '"calendar";'; break; case MSG_ACCEPTED: $action = 'Tentative'; - $event_id = $old_event->id; + $event_id = $old_event['id']; $msgtype = '"calendar";'; break; } @@ -1484,7 +1525,7 @@ if($new_event != False) { - $new_event_datetime = mktime($new_event->start->hour,$new_event->start->min,$new_event->start->sec,$new_event->start->month,$new_event->start->mday,$new_event->start->year) - $this->datetime->tz_offset; + $new_event_datetime = $this->maketime($new_event['start']) - $this->datetime->tz_offset; } while(list($userid,$statusid) = each($participants)) @@ -1560,9 +1601,9 @@ function prepare_recipients(&$new_event,$old_event) { // Find modified and deleted users..... - while(list($old_userid,$old_status) = each($old_event->participants)) + while(list($old_userid,$old_status) = each($old_event['participants'])) { - if(isset($new_event->participants[$old_userid])) + if(isset($new_event['participants'][$old_userid])) { if($this->debug) { @@ -1580,16 +1621,16 @@ } } // Find new users..... - while(list($new_userid,$new_status) = each($new_event->participants)) + while(list($new_userid,$new_status) = each($new_event['participants'])) { - if(!isset($old_event->participants[$new_userid])) + if(!isset($old_event['participants'][$new_userid])) { if($this->debug) { echo "Adding event for user ".$new_userid."
\n"; } $this->added[$new_userid] = 'U'; - $new_event->participants[$new_userid] = 'U'; + $new_event['participants'][$new_userid] = 'U'; } } diff --git a/calendar/inc/class.socalendar.inc.php b/calendar/inc/class.socalendar.inc.php index 5980e3a6a6..20bddc3906 100755 --- a/calendar/inc/class.socalendar.inc.php +++ b/calendar/inc/class.socalendar.inc.php @@ -208,24 +208,6 @@ $this->cal->set_status($id,$this->owner,$status); } - function get_lastid() - { - $this->makeobj(); - $entry = $this->cal->read_last_entry(); - $ab_id = $entry[0]['id']; - return $ab_id; - } - - function update_entry($userid,$fields) - { - $this->makeobj(); - if ($this->rights & PHPGW_ACL_EDIT) - { - $this->cal->update($fields['ab_id'],$userid,$fields,$fields['access'],$fields['cat_id']); - } - return; - } - /* Begin mcal equiv functions */ function get_cached_event() { diff --git a/calendar/inc/class.socalendar__.inc.php b/calendar/inc/class.socalendar__.inc.php index 0fd836747d..8e8e60c129 100755 --- a/calendar/inc/class.socalendar__.inc.php +++ b/calendar/inc/class.socalendar__.inc.php @@ -72,132 +72,134 @@ class socalendar__ function event_init() { - CreateObject('calendar.calendar_item'); - $this->event = new calendar_item; - $this->event->start = new calendar_time; - $this->event->end = new calendar_time; - $this->event->mod = new calendar_time; - $this->event->recur_enddate = new calendar_time; +// CreateObject('calendar.calendar_item'); + $this->event = Array(); +// $this->event['start'] = Array(); +// $this->event['end'] = Array(); +// $this->event['mod'] = Array(); +// $this->event['recur_enddate'] = Array(); $this->add_attribute('owner',intval($this->user)); } function set_category($category='') { - $this->event->category = $category; + $this->add_attribute('category',$category); } function set_title($title='') { - $this->event->title = $title; + $this->add_attribute('title',$title); } function set_description($description='') { - $this->event->description = $description; + $this->add_attribute('description',$description); + } + + function set_date($element,$year,$month,$day=0,$hour=0,$min=0,$sec=0) + { + $this->add_attribute($element,intval($year),'year'); + $this->add_attribute($element,intval($month),'month'); + $this->add_attribute($element,intval($day),'mday'); + $this->add_attribute($element,intval($hour),'hour'); + $this->add_attribute($element,intval($min),'min'); + $this->add_attribute($element,intval($sec),'sec'); + $this->add_attribute($element,0,'alarm'); } function set_start($year,$month,$day=0,$hour=0,$min=0,$sec=0) { - $this->event->start->year = intval($year); - $this->event->start->month = intval($month); - $this->event->start->mday = intval($day); - $this->event->start->hour = intval($hour); - $this->event->start->min = intval($min); - $this->event->start->sec = intval($sec); - $this->event->start->alarm = 0; + $this->set_date('start',$year,$month,$day,$hour,$min,$sec); } function set_end($year,$month,$day=0,$hour=0,$min=0,$sec=0) { - $this->event->end->year = intval($year); - $this->event->end->month = intval($month); - $this->event->end->mday = intval($day); - $this->event->end->hour = intval($hour); - $this->event->end->min = intval($min); - $this->event->end->sec = intval($sec); - $this->event->end->alarm = 0; + $this->set_date('end',$year,$month,$day,$hour,$min,$sec); } function set_alarm($alarm) { - $this->event->alarm = intval($alarm); + $this->add_attribute('alarm',intval($alarm)); } function set_class($class) { - $this->event->public = $class; + $this->add_attribute('public',$class); } - function set_common_recur($year,$month,$day,$interval) + function set_common_recur($year=0,$month=0,$day=0,$interval) { - $this->event->recur_interval = intval($interval); - if(intval($day) == 0 && intval($month) == 0 && intval($year) == 0) - { - $this->event->recur_enddate->year = 0; - $this->event->recur_enddate->month = 0; - $this->event->recur_enddate->mday = 0; - } - else - { - $this->event->recur_enddate->year = intval($year); - $this->event->recur_enddate->month = intval($month); - $this->event->recur_enddate->mday = intval($day); - } - $this->event->recur_enddate->hour = 0; - $this->event->recur_enddate->min = 0; - $this->event->recur_enddate->sec = 0; - $this->event->recur_enddate->alarm = 0; - $this->event->recur_data = 0; + $this->add_attribute('recur_interval',intval(interval)); + $this->set_date('recur_enddate',$year,$month,$day,0,0,0); + $this->add_attribute('recur_data',0); } function set_recur_none() { $this->set_common_recur(0,0,0,0); - $this->event->recur_type = MCAL_RECUR_NONE; + $this->add_attribute('recur_type',MCAL_RECUR_NONE); } function set_recur_daily($year,$month,$day,$interval) { $this->set_common_recur(intval($year),intval($month),intval($day),$interval); - $this->event->recur_type = MCAL_RECUR_DAILY; + $this->add_attribute('recur_type',MCAL_RECUR_DAILY); } function set_recur_weekly($year,$month,$day,$interval,$weekdays) { $this->set_common_recur(intval($year),intval($month),intval($day),$interval); - $this->event->recur_type = MCAL_RECUR_WEEKLY; - $this->event->recur_data = intval($weekdays); + $this->add_attribute('recur_type',MCAL_RECUR_WEEKLY); + $this->add_attribute('recur_data',intval($weekdays)); } function set_recur_monthly_mday($year,$month,$day,$interval) { $this->set_common_recur(intval($year),intval($month),intval($day),$interval); - $this->event->recur_type = MCAL_RECUR_MONTHLY_MDAY; + $this->add_attribute('recur_type',MCAL_RECUR_MONTHLY_MDAY); } function set_recur_monthly_wday($year,$month,$day,$interval) { $this->set_common_recur(intval($year),intval($month),intval($day),$interval); - $this->event->recur_type = MCAL_RECUR_MONTHLY_WDAY; + $this->add_attribute('recur_type',MCAL_RECUR_MONTHLY_WDAY); } function set_recur_yearly($year,$month,$day,$interval) { $this->set_common_recur(intval($year),intval($month),intval($day),$interval); - $this->event->recur_type = MCAL_RECUR_YEARLY; + $this->add_attribute('recur_type',MCAL_RECUR_YEARLY); } function fetch_current_stream_event() { - return $this->fetch_event($this->event->id); + return $this->fetch_event($this->event['id']); } - function add_attribute($attribute,$value,$element='') + function add_attribute($attribute,$value,$element='False') { if(is_array($value)) { reset($value); } - eval("\$this->event->".$attribute." = ".$value.";"); + if($element!='False') + { + if(is_int($element)) + { + eval("\$this->event['".$attribute."'][".$element."] = ".$value.";"); + } + else + { + eval("\$this->event['".$attribute."']['".$element."'] = ".$value.";"); + } + } + elseif(is_int($value)) + { + eval("\$this->event['".$attribute."'] = ".$value.";"); + } + elseif(is_string($value)) + { + eval("\$this->event['".$attribute."'] = '".$value."';"); + } } } diff --git a/calendar/inc/class.socalendar_sql.inc.php b/calendar/inc/class.socalendar_sql.inc.php index f88ce87309..dc8f2638ec 100755 --- a/calendar/inc/class.socalendar_sql.inc.php +++ b/calendar/inc/class.socalendar_sql.inc.php @@ -124,22 +124,16 @@ class socalendar_ extends socalendar__ //$this->event->alarm = intval($this->stream->f('alarm')); // But until then, do it this way... //Legacy Support (New) - $this->event->alarm = 0; + $this->set_alarm(0); - $this->add_attribute('datetime',intval($this->stream->f('datetime'))); +// $this->add_attribute('datetime',intval($this->stream->f('datetime'))); $datetime = $this->datetime->localdates($this->stream->f('datetime')); $this->set_start($datetime['year'],$datetime['month'],$datetime['day'],$datetime['hour'],$datetime['minute'],$datetime['second']); $datetime = $this->datetime->localdates($this->stream->f('mdatetime')); - $this->event->mod->year = $datetime['year']; - $this->event->mod->month = $datetime['month']; - $this->event->mod->mday = $datetime['day']; - $this->event->mod->hour = $datetime['hour']; - $this->event->mod->min = $datetime['minute']; - $this->event->mod->sec = $datetime['second']; - $this->event->mod->alarm = 0; + $this->set_date('modtime',$datetime['year'],$datetime['month'],$datetime['day'],$datetime['hour'],$datetime['minute'],$datetime['second']); - $this->add_attribute('edatetime',intval($this->stream->f('edatetime'))); +// $this->add_attribute('edatetime',intval($this->stream->f('edatetime'))); $datetime = $this->datetime->localdates($this->stream->f('edatetime')); $this->set_end($datetime['year'],$datetime['month'],$datetime['day'],$datetime['hour'],$datetime['minute'],$datetime['second']); @@ -150,7 +144,7 @@ class socalendar_ extends socalendar__ $groups = explode(',',$this->stream->f('groups')); for($j=1;$jevent->groups[] = $groups[$j]; + $this->add_attribute('groups',$groups[$j],$j-1); } } @@ -159,32 +153,31 @@ class socalendar_ extends socalendar__ { $this->stream->next_record(); - $this->event->recur_type = intval($this->stream->f('recur_type')); - $this->event->recur_interval = intval($this->stream->f('recur_interval')); + $this->add_attribute('recur_type',intval($this->stream->f('recur_type'))); + $this->add_attribute('recur_interval',intval($this->stream->f('recur_interval'))); $enddate = $this->stream->f('recur_enddate'); if($enddate != 0 && $enddate != Null) { $datetime = $this->datetime->localdates($enddate); - $this->event->recur_enddate->year = $datetime['year']; - $this->event->recur_enddate->month = $datetime['month']; - $this->event->recur_enddate->mday = $datetime['day']; - $this->event->recur_enddate->hour = $datetime['hour']; - $this->event->recur_enddate->min = $datetime['minute']; - $this->event->recur_enddate->sec = $datetime['second']; - $this->event->recur_enddate->alarm = 0; + $this->add_attribute('recur_enddate',$datetime['year'],'year'); + $this->add_attribute('recur_enddate',$datetime['month'],'month'); + $this->add_attribute('recur_enddate',$datetime['day'],'mday'); + $this->add_attribute('recur_enddate',$datetime['hour'],'hour'); + $this->add_attribute('recur_enddate',$datetime['minute'],'min'); + $this->add_attribute('recur_enddate',$datetime['second'],'sec'); } else { - $this->event->recur_enddate->year = 0; - $this->event->recur_enddate->month = 0; - $this->event->recur_enddate->mday = 0; - $this->event->recur_enddate->hour = 0; - $this->event->recur_enddate->min = 0; - $this->event->recur_enddate->sec = 0; - $this->event->recur_enddate->alarm = 0; + $this->add_attribute('recur_enddate',0,'year'); + $this->add_attribute('recur_enddate',0,'month'); + $this->add_attribute('recur_enddate',0,'mday'); + $this->add_attribute('recur_enddate',0,'hour'); + $this->add_attribute('recur_enddate',0,'min'); + $this->add_attribute('recur_enddate',0,'sec'); } -// echo 'Event ID#'.$this->event->id.' : Enddate = '.$enddate."
\n"; - $this->event->recur_data = $this->stream->f('recur_data'); + $this->add_attribute('recur_enddate',0,'alarm'); +// echo 'Event ID#'.$this->event['id'].' : Enddate = '.$enddate."
\n"; + $this->add_attribute('recur_data',$this->stream->f('recur_data')); } //Legacy Support @@ -195,11 +188,12 @@ class socalendar_ extends socalendar__ { if(intval($this->stream->f('cal_login')) == intval($this->user)) { - $this->event->users_status = $this->stream->f('cal_status'); + $this->add_attribute('users_status',$this->stream->f('cal_status')); } // $this->event->participants[$this->stream->f('cal_login')] = $this->stream->f('cal_status'); -// $this->add_attribute('participants',$this->stream->f('cal_status'),intval($this->stream->f('cal_login'))); - $this->add_attribute('participants['.intval($this->stream->f('cal_login')).']',$this->stream->f('cal_status')); + $this->add_attribute('participants',$this->stream->f('cal_status'),intval($this->stream->f('cal_login'))); +// $this->add_attribute('participants',array(intval($this->stream->f('cal_login'))=>$this->stream->f('cal_status'))); +// $this->add_attribute('participants['.intval($this->stream->f('cal_login')).']',$this->stream->f('cal_status')); } } } @@ -242,7 +236,7 @@ class socalendar_ extends socalendar__ { $this->save_event($this->event); $this->send_update(MSG_ADDED,$this->event->participants,'',$this->event); - return $this->event->id; + return $this->event['id']; } function store_event() @@ -346,22 +340,22 @@ class socalendar_ extends socalendar__ 'phpgw_cal_repeats' ); $this->stream->lock($locks); - if($event->id == 0) + if($event['id'] == 0) { $temp_name = tempnam($phpgw_info['server']['temp_dir'],'cal'); $this->stream->query('INSERT INTO phpgw_cal(title,owner,priority,is_public) ' - . "values('".$temp_name."',".$event->owner.",".$event->priority.",".$event->public.")"); + . "values('".$temp_name."',".$event['owner'].",".$event['priority'].",".$event['public'].")"); $this->stream->query("SELECT cal_id FROM phpgw_cal WHERE title='".$temp_name."'"); $this->stream->next_record(); - $event->id = $this->stream->f('cal_id'); + $event['id'] = $this->stream->f('cal_id'); } - $date = mktime($event->start->hour,$event->start->min,$event->start->sec,$event->start->month,$event->start->mday,$event->start->year) - $this->datetime->tz_offset; - $enddate = mktime($event->end->hour,$event->end->min,$event->end->sec,$event->end->month,$event->end->mday,$event->end->year) - $this->datetime->tz_offset; + $date = $this->maketime($event['start']) - $this->datetime->tz_offset; + $enddate = $this->maketime($event['end']) - $this->datetime->tz_offset; $today = time() - $this->datetime->tz_offset; // $today = time(); - if($event->recur_type != MCAL_RECUR_NONE) + if($event['recur_type'] != MCAL_RECUR_NONE) { $type = 'M'; } @@ -370,71 +364,65 @@ class socalendar_ extends socalendar__ $type = 'E'; } - $cat = ''; - if($event->category != 0) - { - $cat = 'category='.$event->category.', '; - } - $sql = 'UPDATE phpgw_cal SET ' - . 'owner='.$event->owner.', ' + . 'owner='.$event['owner'].', ' . 'datetime='.$date.', ' . 'mdatetime='.$today.', ' . 'edatetime='.$enddate.', ' - . 'priority='.$event->priority.', ' - . $cat + . 'priority='.$event['priority'].', ' + . ($event['category'] != 0?'category='.$event['category'].', ':'') . "cal_type='".$type."', " - . 'is_public='.$event->public.', ' - . "title='".addslashes($event->title)."', " - . "description='".addslashes($event->description)."' " - . 'WHERE cal_id='.$event->id; + . 'is_public='.$event['public'].', ' + . "title='".addslashes($event['title'])."', " + . "description='".addslashes($event['description'])."' " + . 'WHERE cal_id='.$event['id']; $this->stream->query($sql,__LINE__,__FILE__); - $this->stream->query('DELETE FROM phpgw_cal_user WHERE cal_id='.$event->id,__LINE__,__FILE__); + $this->stream->query('DELETE FROM phpgw_cal_user WHERE cal_id='.$event['id'],__LINE__,__FILE__); - reset($event->participants); - while (list($key,$value) = each($event->participants)) + reset($event['participants']); + while (list($key,$value) = each($event['participants'])) { if(intval($key) == intval($this->user)) { $value = 'A'; } $this->stream->query('INSERT INTO phpgw_cal_user(cal_id,cal_login,cal_status) ' - . 'VALUES('.$event->id.','.intval($key).",'".$value."')",__LINE__,__FILE__); + . 'VALUES('.$event['id'].','.intval($key).",'".$value."')",__LINE__,__FILE__); } - if($event->recur_type != MCAL_RECUR_NONE) + if($event['recur_type'] != MCAL_RECUR_NONE) { - if($event->recur_enddate->month != 0 && $event->recur_enddate->mday != 0 && $event->recur_enddate->year != 0) + if($event['recur_enddate']['month'] != 0 && $event['recur_enddate']['mday'] != 0 && $event['recur_enddate']['year'] != 0) { - $end = mktime($event->recur_enddate->hour,$event->recur_enddate->min,$event->recur_enddate->sec,$event->recur_enddate->month,$event->recur_enddate->mday,$event->recur_enddate->year) - $this->datetime->tz_offset; + $end = $this->maketime($event['recur_enddate']) - $this->datetime->tz_offset; } else { $end = 0; } - $this->stream->query('SELECT count(cal_id) FROM phpgw_cal_repeats WHERE cal_id='.$event->id,__LINE__,__FILE__); + $this->stream->query('SELECT count(cal_id) FROM phpgw_cal_repeats WHERE cal_id='.$event['id'],__LINE__,__FILE__); $this->stream->next_record(); $num_rows = $this->stream->f(0); if($num_rows == 0) { $this->stream->query('INSERT INTO phpgw_cal_repeats(cal_id,recur_type,recur_enddate,recur_data,recur_interval) ' - .'VALUES('.$event->id.','.$event->recur_type.','.$end.','.$event->recur_data.','.$event->recur_interval.')',__LINE__,__FILE__); + .'VALUES('.$event['id'].','.$event['recur_type'].','.$end.','.$event['recur_data'].','.$event['recur_interval'].')',__LINE__,__FILE__); } else { $this->stream->query('UPDATE phpgw_cal_repeats ' - .'SET recur_type='.$event->recur_type.', ' + .'SET recur_type='.$event['recur_type'].', ' .'recur_enddate='.$end.', ' - .'recur_data='.$event->recur_data.', recur_interval='.$event->recur_interval.' ' - .'WHERE cal_id='.$event->id,__LINE__,__FILE__); + .'recur_data='.$event['recur_data'].', recur_interval='.$event['recur_interval'].' ' + .'WHERE cal_id='.$event['id'],__LINE__,__FILE__); } } else { - $this->stream->query('DELETE FROM phpgw_cal_repeats WHERE cal_id='.$event->id,__LINE__,__FILE__); + $this->stream->query('DELETE FROM phpgw_cal_repeats WHERE cal_id='.$event['id'],__LINE__,__FILE__); } $this->stream->unlock(); @@ -456,6 +444,11 @@ class socalendar_ extends socalendar__ // End of ICal style support....... + function maketime($time) + { + return mktime($time['hour'],$time['min'],$time['sec'],$time['month'],$time['mday'],$time['year']); + } + function group_search($owner=0) { global $phpgw, $phpgw_info; diff --git a/calendar/inc/class.uicalendar.inc.php b/calendar/inc/class.uicalendar.inc.php index c57ba742f4..300aafdde7 100755 --- a/calendar/inc/class.uicalendar.inc.php +++ b/calendar/inc/class.uicalendar.inc.php @@ -434,51 +434,45 @@ $event = $this->bo->read_entry($cal_id); - if(!isset($event->id)) + if(!isset($event['id'])) { echo lang("Sorry, this event does not exist").'.'.''; return; } echo $this->view_event($event); - - if ($this->bo->owner == $event->owner && $this->bo->check_perms(PHPGW_ACL_EDIT) == True) + + if($this->bo->owner == $event['owner']) { $p = CreateObject('phpgwapi.Template',$this->template_dir); $templates = Array( 'form_button' => 'form_button_script.tpl' ); $p->set_file($templates); - - $var = Array( - 'action_url_button' => $this->page('edit','&cal_id='.$cal_id), - 'action_text_button' => lang('Edit'), - 'action_confirm_button' => '', - 'action_extra_field' => '' - ); - $p->set_var($var); - echo $p->fp('out','form_button'); - } - if ($this->bo->owner == $event->owner && $this->bo->check_perms(PHPGW_ACL_DELETE) == True) - { - if(!is_object($p)) - { - $p = CreateObject('phpgwapi.Template',$this->template_dir); - $templates = Array( - 'form_button' => 'form_button_script.tpl' - ); - $p->set_file($templates); - } - - $var = Array( - 'action_url_button' => $this->page('delete','&cal_id='.$cal_id), - 'action_text_button' => lang('Delete'), - 'action_confirm_button' => "onClick=\"return confirm('".lang("Are you sure\\nyou want to\\ndelete this entry ?\\n\\nThis will delete\\nthis entry for all users.")."')\"", - 'action_extra_field' => '' - ); - $p->set_var($var); - echo $p->fp('out','form_button'); + if ($this->bo->check_perms(PHPGW_ACL_EDIT)) + { + $var = Array( + 'action_url_button' => $this->page('edit','&cal_id='.$cal_id), + 'action_text_button' => lang('Edit'), + 'action_confirm_button' => '', + 'action_extra_field' => '' + ); + $p->set_var($var); + echo $p->fp('out','form_button'); + } + + if ($this->bo->check_perms(PHPGW_ACL_DELETE)) + { + $var = Array( + 'action_url_button' => $this->page('delete','&cal_id='.$cal_id), + 'action_text_button' => lang('Delete'), + 'action_confirm_button' => "onClick=\"return confirm('".lang("Are you sure\\nyou want to\\ndelete this entry ?\\n\\nThis will delete\\nthis entry for all users.")."')\"", + 'action_extra_field' => '' + ); + $p->set_var($var); + echo $p->fp('out','form_button'); + } } echo ''; } @@ -523,7 +517,7 @@ if(isset($readsess)) { $event = $this->bo->restore_from_appsession; - if($event->owner == 0) + if(!$event['owner']) { $this->bo->add_attribute('owner',$this->bo->owner); } @@ -551,7 +545,7 @@ { $this->bo->set_class(True); } - $this->bo->add_attribute('participants['.$this->bo->owner.']','A'); + $this->bo->add_attribute('participants','A',$this->bo->owner); $this->bo->set_recur_none(); $event = $this->bo->get_cached_event(); } @@ -562,9 +556,9 @@ { global $cal_id; $event = $this->bo->read_entry(intval($cal_id)); - if(($cal_id > 0) && ($event->owner == $this->bo->owner) && ($this->bo->check_perms(PHPGW_ACL_DELETE) == True)) + if(($cal_id > 0) && ($event['owner'] == $this->bo->owner) && !$this->bo->check_perms(PHPGW_ACL_DELETE)) { - $date = sprintf("%04d%02d%02d",$event->start->year,$event->start->month,$event->start->mday); + $date = sprintf("%04d%02d%02d",$event['start']['year'],$event['start']['month'],$event['start']['mday']); $cd = $this->bo->delete_entry(intval($cal_id)); $this->bo->expunge(); @@ -757,7 +751,6 @@ ); $p->set_var($var); - $p->pparse('out','day_t'); } @@ -773,7 +766,7 @@ $event = $this->bo->read_entry($cal_id); - reset($event->participants); + reset($event['participants']); if(!$event->participants[$this->bo->owner]) { @@ -787,12 +780,12 @@ return; } - $freetime = $this->bo->datetime->localdates(mktime(0,0,0,$event->start->month,$event->start->mday,$event->start->year) - $this->bo->datetime->tz_offset); - echo $this->timematrix($freetime,$this->bo->splittime('000000',False),0,$event->participants); + $freetime = $this->bo->datetime->localdates(mktime(0,0,0,$event['start']['month'],$event['start']['mday'],$event['start']['year']) - $this->bo->datetime->tz_offset); + echo $this->timematrix($freetime,$this->bo->splittime('000000',False),0,$event['participants']); echo $this->view_event($event); - echo $this->get_response($event->id); + echo $this->get_response($event['id']); } function set_action() @@ -869,28 +862,28 @@ for($g=0;$gbo->datetime->localdates($event->datetime); - $end = $this->bo->datetime->localdates($event->edatetime); + $start = $this->bo->datetime->gmtdate($this->bo->maketime($event['start'])); + $end = $this->bo->datetime->gmtdate($this->bo->maketime($event['end'])); $view = $html->link('/index.php', array( 'menuaction' => 'calendar.uicalendar.view', - 'cal_id' => $event->id + 'cal_id' => $event['id'] ) ); $start_cell = $intervals_per_day * (intval(substr($v,6,2)) - 1); - $start_cell += $interval[$event->start->hour]; + $start_cell += $interval[$event['start']['hour']]; $end_cell = $interval_per_day = $intervals_per_day * (intval(substr($v,6,2))-1); - $end_cell += $interval[$event->end->hour]; + $end_cell += $interval[$event['end']['hour']]; $i = 0; // search for row of parent category do { ++$i; - if ($c = $event->category) + if ($c = $event['category']) { - $cat = $this->planner_category($event->category); + $cat = $this->planner_category($event['category']); if ($cat['parent']) { $pcat = $this->planner_category($c = $cat['parent']); @@ -926,11 +919,11 @@ if ($akt_cell < $start_cell) { $row[$event->id.'_1'] = ' '; - $row['.'.$event->id.'_1'] = 'colspan='.($start_cell-$akt_cell); + $row['.'.$event['id'].'_1'] = 'colspan='.($start_cell-$akt_cell); } - $opt = &$row['.'.$event->id.'_2']; - $cel = &$row[$event->id.'_2']; + $opt = &$row['.'.$event['id'].'_2']; + $cel = &$row[$event['id'].'_2']; if ($start_cell < $end_cell) { $opt .= "colspan=".(1 + $end_cell - $start_cell); @@ -940,18 +933,18 @@ { $opt .= " bgcolor=$bgcolor"; } - $opt .= ' title="'.$event->title; - if ($event->description) + $opt .= ' title="'.$event['title']; + if ($event['description']) { - $opt .= " \n".$event->description; + $opt .= " \n".$event['description']; } $opt .= '" onClick="location=\''.$view.'\'"'; $cel = ''; - if ($event->priority == 3) + if ($event['priority'] == 3) { $cel .= $html->image('calendar','mini-calendar-bar.gif','','border=0'); } - $cel .= $html->image('calendar',count($event->participants)>1?'multi_3.gif':'single.gif',$this->planner_participants($event->participants),'border=0'); + $cel .= $html->image('calendar',count($event['participants)']>1?'multi_3.gif':'single.gif',$this->planner_participants($event['participants']),'border=0'); $cel .= ''; $akt_cell = $end_cell + 1; @@ -1211,10 +1204,10 @@ { $event = $this->bo->read_entry($id); - $datetime = mktime($event->start->hour,$event->start->min,$event->start->sec,$event->start->month,$event->start->mday,$event->start->year) - $phpgw->calendar->datetime->tz_offset; + $datetime = $this->bo->maketime($event['start']) - $phpgw->calendar->datetime->tz_offset; - $ids[strval($event->id)]++; - $info[strval($event->id)] = $phpgw->common->show_date($datetime).$this->link_to_entry($event,$event->start->month,$event->start->mday,$event->start->year); + $ids[strval($event['id'])]++; + $info[strval($event['id'])] = $phpgw->common->show_date($datetime).$this->link_to_entry($event,$event['start']['month'],$event['start']['mday'],$event['start']['year']); } $matches = count($event_ids); @@ -1371,8 +1364,6 @@ if (@$this->bo->printer_friendly) { return; -// $phpgw->common->phpgw_footer(); -// $phpgw->common->phpgw_exit(); } $p = CreateObject('phpgwapi.Template',$this->template_dir); @@ -1502,8 +1493,8 @@ $p->set_block('link_picture','link_close','link_close'); $p->set_block('link_picture','link_text','link_text'); - $starttime = mktime($event->start->hour,$event->start->min,$event->start->sec,$event->start->month,$event->start->mday,$event->start->year) - $this->bo->datetime->tz_offset; - $endtime = mktime($event->end->hour,$event->end->min,$event->end->sec,$event->end->month,$event->end->mday,$event->end->year) - $this->bo->datetime->tz_offset; + $starttime = $this->bo->maketime($event['start']) - $this->bo->datetime->tz_offset; + $endtime = $this->bo->maketime($event['end']) - $this->bo->datetime->tz_offset; $rawdate = mktime(0,0,0,$month,$day,$year); $rawdate_offset = $rawdate - $this->bo->datetime->tz_offset; $nextday = mktime(0,0,0,$month,$day + 1,$year) - $this->bo->datetime->tz_offset; @@ -1517,7 +1508,7 @@ } elseif (intval($phpgw->common->show_date($starttime,'Hi')) || $starttime != $endtime) { - if($starttime < $rawdate_offset && $event->recur_type==MCAL_RECUR_NONE) + if($starttime < $rawdate_offset && $event['recur_type']==MCAL_RECUR_NONE) { $start_time = $phpgw->common->show_date($rawdate_offset,$this->bo->users_timeformat); } @@ -1543,17 +1534,17 @@ $text = '';; if(!$is_private) { - $text .= $this->bo->display_status($event->users_status); + $text .= $this->bo->display_status($event['users_status']); } $text = ''.$time.' '.$this->bo->get_short_field($event,$is_private,'title').$text.''.$phpgw->browser->br; if ($editable) { - $p->set_var('link_link',$this->page('view','&cal_id='.$event->id)); + $p->set_var('link_link',$this->page('view','&cal_id='.$event['id'])); $p->set_var('lang_view',lang('View this entry')); $p->parse('picture','link_open',True); - if($event->priority == 3) + if($event['priority'] == 3) { $picture[] = Array( 'pict' => $phpgw->common->image('calendar','high.gif'), @@ -1561,7 +1552,7 @@ 'height' => 17 ); } - if($event->recur_type == MCAL_RECUR_NONE) + if($event['recur_type'] == MCAL_RECUR_NONE) { $picture[] = Array( 'pict' => $phpgw->common->image('calendar','circle.gif'), @@ -1577,7 +1568,7 @@ 'height' => 12 ); } - if(count($event->participants) > 1) + if(count($event['participants']) > 1) { $picture[] = Array( 'pict' => $phpgw->common->image('calendar','multi_3.gif'), @@ -1585,7 +1576,7 @@ 'height' => 14 ); } - if($event->public == 0) + if($event['public'] == 0) { $picture[] = Array( 'pict' => $phpgw->common->image('calendar','private.gif'), @@ -1632,7 +1623,7 @@ $year = $event->start->year; $start = mktime($event->start->hour,$event->start->min,$event->start->sec,$month,$mday,$year) - $this->bo->datetime->tz_offset; - $end = mktime($event->end->hour,$event->end->min,$event->end->sec,$event->end->month,$event->end->mday,$event->end->year) - $this->bo->datetime->tz_offset; + $end = $this->bo->maketime($event['end']) - $this->bo->datetime->tz_offset; $overlap = ''; for($i=0;$idescription)) + if (nl2br($event['description'])) { $var[] = Array( 'field' => lang('Description'), - 'data' => nl2br($event->description) + 'data' => nl2br($event['description']) ); } - if ($event->category) + if ($event['category']) { $this->cat->categories($this->bo->owner,'calendar'); - $cat = $this->cat->return_single($event->category); + $cat = $this->cat->return_single($event['category']); $var[] = Array( 'field' => lang('Category'), 'data' => $cat[0]['name'] @@ -2037,44 +2028,44 @@ $var[] = Array( 'field' => lang('Start Date/Time'), - 'data' => $phpgw->common->show_date(mktime($event->start->hour,$event->start->min,$event->start->sec,$event->start->month,$event->start->mday,$event->start->year) - $this->bo->datetime->tz_offset) + 'data' => $phpgw->common->show_date($this->bo->maketime($event['start']) - $this->bo->datetime->tz_offset) ); $var[] = Array( 'field' => lang('End Date/Time'), - 'data' => $phpgw->common->show_date(mktime($event->end->hour,$event->end->min,$event->end->sec,$event->end->month,$event->end->mday,$event->end->year) - $this->bo->datetime->tz_offset) + 'data' => $phpgw->common->show_date($this->bo->maketime($event['end']) - $this->bo->datetime->tz_offset) ); $var[] = Array( 'field' => lang('Priority'), - 'data' => $pri[$event->priority] + 'data' => $pri[$event['priority']] ); $var[] = Array( 'field' => lang('Created By'), - 'data' => $phpgw->common->grab_owner_name($event->owner) + 'data' => $phpgw->common->grab_owner_name($event['owner']) ); $var[] = Array( 'field' => lang('Updated'), - 'data' => $phpgw->common->show_date(mktime($event->mod->hour,$event->mod->min,$event->mod->sec,$event->mod->month,$event->mod->mday,$event->mod->year) - $this->bo->datetime->tz_offset) + 'data' => $phpgw->common->show_date($this->bo->maketime($event['modtime']) - $this->bo->datetime->tz_offset) ); $var[] = Array( 'field' => lang('Private'), - 'data' => $event->public==True?'False':'True' + 'data' => $event['public']==True?'False':'True' ); if($event->groups[0]) { $cal_grps = ''; - for($i=0;$igroups);$i++) + for($i=0;$i0) { $cal_grps .= '
'; } - $cal_grps .= $phpgw->accounts->id2name($event->groups[$i]); + $cal_grps .= $phpgw->accounts->id2name($event['groups'][$i]); } $var[] = Array( @@ -2084,8 +2075,8 @@ } $str = ''; - reset($event->participants); - while (list($user,$short_status) = each($event->participants)) + reset($event['participants']); + while (list($user,$short_status) = each($event['participants'])) { if($phpgw->accounts->exists($user)) { @@ -2113,56 +2104,56 @@ MCAL_RECUR_MONTHLY_MDAY => 'monthlybydate', MCAL_RECUR_YEARLY => 'yearly' ); - $str = lang($rpt_type[$event->recur_type]); - if($event->recur_type <> MCAL_RECUR_NONE) + $str = lang($rpt_type[$event['recur_type']]); + if($event['recur_type'] <> MCAL_RECUR_NONE) { $str_extra = ''; - if ($event->recur_enddate->mday != 0 && $event->recur_enddate->month != 0 && $event->recur_enddate->year != 0) + if ($event['recur_enddate']['mday'] != 0 && $event['recur_enddate']['month'] != 0 && $event['recur_enddate']['year'] != 0) { - $recur_end = mktime($event->recur_enddate->hour,$event->recur_enddate->min,$event->recur_enddate->sec,$event->recur_enddate->month,$event->recur_enddate->mday,$event->recur_enddate->year); + $recur_end = $this-bo->maketime($event['recur_enddate']); if($recur_end != 0) { $recur_end -= $this->bo->datetime->tz_offset; $str_extra .= lang('ends').': '.lang($phpgw->common->show_date($recur_end,'l')).', '.lang($phpgw->common->show_date($recur_end,'F')).' '.$phpgw->common->show_date($recur_end,'d, Y').' '; } } - if($event->recur_type == MCAL_RECUR_WEEKLY || $event->recur_type == MCAL_RECUR_DAILY) + if($event['recur_type'] == MCAL_RECUR_WEEKLY || $event['recur_type'] == MCAL_RECUR_DAILY) { $repeat_days = ''; if($this->bo->prefs['calendar']['weekdaystarts'] == 'Sunday') { - if (!!($event->recur_data & MCAL_M_SUNDAY) == True) + if (!!($event['recur_data'] & MCAL_M_SUNDAY) == True) { $this->view_add_day(lang('Sunday'),$repeat_days); } } - if (!!($event->recur_data & MCAL_M_MONDAY) == True) + if (!!($event['recur_data'] & MCAL_M_MONDAY) == True) { $this->view_add_day(lang('Monday'),$repeat_days); } - if (!!($event->recur_data & MCAL_M_TUESDAY) == True) + if (!!($event['recur_data'] & MCAL_M_TUESDAY) == True) { $this->view_add_day(lang('Tuesday'),$repeat_days); } - if (!!($event->recur_data & MCAL_M_WEDNESDAY) == True) + if (!!($event['recur_data'] & MCAL_M_WEDNESDAY) == True) { $this->view_add_day(lang('Wednesday'),$repeat_days); } - if (!!($event->recur_data & MCAL_M_THURSDAY) == True) + if (!!($event['recur_data'] & MCAL_M_THURSDAY) == True) { $this->view_add_day(lang('Thursday'),$repeat_days); } - if (!!($event->recur_data & MCAL_M_FRIDAY) == True) + if (!!($event['recur_data'] & MCAL_M_FRIDAY) == True) { $this->view_add_day(lang('Friday'),$repeat_days); } - if (!!($event->recur_data & MCAL_M_SATURDAY) == True) + if (!!($event['recur_data'] & MCAL_M_SATURDAY) == True) { $this->view_add_day(lang('Saturday'),$repeat_days); } if($this->bo->prefs['calendar']['weekdaystarts'] == 'Monday') { - if (!!($event->recur_data & MCAL_M_SUNDAY) == True) + if (!!($event['recur_data'] & MCAL_M_SUNDAY) == True) { $this->view_add_day(lang('Sunday'),$repeat_days); } @@ -2172,9 +2163,9 @@ $str_extra .= lang('days repeated').': '.$repeat_days; } } - if($event->recur_interval) + if($event['recur_interval']) { - $str_extra .= lang('Interval').': '.$event->recur_interval; + $str_extra .= lang('Interval').': '.$event['recur_interval']; } if($str_extra) @@ -2196,10 +2187,6 @@ return $p->fp('out','view_event'); } - function html_for_day($event,&$time,$month,$day,$year,&$rowspan,&$rowspan_arr) - { - } - function print_day($year,$month,$day) { global $phpgw, $phpgw_info; @@ -2254,9 +2241,6 @@ $rowspan_arr[$i] = 0; } - $events = Array( - CreateObject('calendar.calendar_item') - ); $date_to_eval = sprintf("%04d%02d%02d",$year,$month,$day); $time = Array(); @@ -2270,7 +2254,7 @@ for($i=0;$i<$c_events;$i++) { $event = $events[$i]; - $ind = intval($event->start->hour); + $ind = intval($event['start']['hour']); if($ind < (int)$this->bo->prefs['calendar']['workdaystarts'] || $ind > (int)$this->bo->prefs['calendar']['workdayends']) { @@ -2284,8 +2268,8 @@ $time[$ind] .= $this->link_to_entry($event,$month,$day,$year); - $starttime = mktime($event->start->hour,$event->start->min,$event->start->sec,$event->start->month,$event->start->mday,$event->start->year); - $endtime = mktime($event->end->hour,$event->end->min,$event->end->sec,$event->end->month,$event->end->mday,$event->end->year); + $starttime = $this->bo->maketime($event['start']); + $endtime = $this->bo->maketime($event['end']); if ($starttime <> $endtime) { @@ -2585,8 +2569,8 @@ $sb = CreateObject('phpgwapi.sbox'); - $start = mktime($event->start->hour,$event->start->min,$event->start->sec,$event->start->month,$event->start->mday,$event->start->year) - $this->bo->datetime->tz_offset; - $end = mktime($event->end->hour,$event->end->min,$event->end->sec,$event->end->month,$event->end->mday,$event->end->year) - $this->bo->datetime->tz_offset; + $start = $this->bo->maketime($event['start']) - $this->bo->datetime->tz_offset; + $end = $this->bo->maketime($event['end']) - $this->bo->datetime->tz_offset; unset($phpgw_info['flags']['noheader']); unset($phpgw_info['flags']['nonavbar']); @@ -2609,9 +2593,9 @@ 'font' => $phpgw_info['theme']['font'], 'bg_color' => $phpgw_info['theme']['bg_text'], 'calendar_action' => ($event->id?lang('Calendar - Edit'):lang('Calendar - Add')), -/* 'action_url' => $phpgw->link('/index.php','menuaction=calendar.bocalendar.'.($event->id?'update':'add')), */ +/* 'action_url' => $phpgw->link('/index.php','menuaction=calendar.bocalendar.'.($event['id']?'update':'add')), */ 'action_url' => $phpgw->link('/index.php','menuaction=calendar.bocalendar.update'), - 'common_hidden' => ''."\n" + 'common_hidden' => ''."\n" . ''."\n", 'errormsg' => ($cd?$phpgw->common->check_code($cd):'') ); @@ -2620,19 +2604,19 @@ // Brief Description $var[] = Array( 'field' => lang('Title'), - 'data' => '' + 'data' => '' ); // Full Description $var[] = Array( 'field' => lang('Full Description'), - 'data' => '' + 'data' => '' ); // Display Categories $var[] = Array( 'field' => lang('Category'), - 'data' => '' + 'data' => '' ); // Date @@ -2680,13 +2664,13 @@ // Priority $var[] = Array( 'field' => lang('Priority'), - 'data' => $sb->getPriority('cal[priority]',$event->priority) + 'data' => $sb->getPriority('cal[priority]',$event['priority']) ); // Access $var[] = Array( 'field' => lang('Private'), - 'data' => 'public?' checked':'').'>' + 'data' => '' ); // Participants @@ -2701,7 +2685,7 @@ { if(intval($id) != intval($this->bo->owner)) { - $str .= ' '."\n"; + $str .= ' '."\n"; } } $var[] = Array( @@ -2710,7 +2694,7 @@ ); // I Participate - if((($cal_id > 0) && isset($event->participants[$this->bo->owner])) || !isset($cal_id)) + if((($cal_id > 0) && isset($event['participants'][$this->bo->owner])) || !isset($cal_id)) { $checked = ' checked'; } @@ -2754,22 +2738,22 @@ $str = ''; for($l=0;$lrecur_type==$rpt_type[$l]?' selected':'').'>'.lang($rpt_type_out[$rpt_type[$l]]).''; + $str .= ''; } $var[] = Array( 'field' => lang('Repeat Type'), 'data' => ''."\n" ); - if($event->recur_enddate->year != 0 && $event->recur_enddate->month != 0 && $event->recur_enddate->mday != 0) + if($event['recur_enddate']['year'] != 0 && $event['recur_enddate']['month'] != 0 && $event['recur_enddate']['mday'] != 0) { $checked = ' checked'; - $recur_end = mktime($event->recur_enddate->hour,$event->recur_enddate->min,$event->recur_enddate->sec,$event->recur_enddate->month,$event->recur_enddate->mday,$event->recur_enddate->year) - $this->bo->datetime->tz_offset; + $recur_end = $this->bo->maketime($event['recur_enddate']) - $this->bo->datetime->tz_offset; } else { $checked = ''; - $recur_end = mktime($event->start->hour,$event->start->min,$event->start->sec,$event->start->month,$event->start->mday,$event->start->year) + 86400 - $this->bo->datetime->tz_offset; + $recur_end = $this->bo->maketime($event['start']) + 86400 - $this->bo->datetime->tz_offset; } $var[] = Array( @@ -2784,18 +2768,18 @@ $var[] = Array( 'field' => lang('Repeat Day').'
'.lang('(for weekly)'), - 'data' => 'recur_data & MCAL_M_SUNDAY) ?' checked':'').'> '.lang('Sunday').' ' - . 'recur_data & MCAL_M_MONDAY) ?' checked':'').'> '.lang('Monday').' ' - . 'recur_data & MCAL_M_TUESDAY) ?' checked':'').'> '.lang('Tuesday').' ' - . 'recur_data & MCAL_M_WEDNESDAY) ?' checked':'').'> '.lang('Wednesday').'
' - . 'recur_data & MCAL_M_THURSDAY) ?' checked':'').'> '.lang('Thursday').' ' - . 'recur_data & MCAL_M_FRIDAY) ?' checked':'').'> '.lang('Friday').' ' - . 'recur_data & MCAL_M_SATURDAY) ?' checked':'').'> '.lang('Saturday').' ' + 'data' => ' '.lang('Sunday').' ' + . ' '.lang('Monday').' ' + . ' '.lang('Tuesday').' ' + . ' '.lang('Wednesday').'
' + . ' '.lang('Thursday').' ' + . ' '.lang('Friday').' ' + . ' '.lang('Saturday').' ' ); $var[] = Array( 'field' => lang('Frequency'), - 'data' => '' + 'data' => '' ); for($i=0;$i * +* -------------------------------------------- * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 2 of the License, or (at your * +* option) any later version. * +\**************************************************************************/ + + /* $Id$ */ + + $phpgw_info['flags'] = array( + 'disable_template_class' => True, +// 'login' => True, + 'currentapp' => 'calendar', + 'noheader' => True, + 'nofooter' => True); + + include('../header.inc.php'); + include('../soap/vars.php'); + + $method_params = Array(); + $server['calendar.bocalendar.read_entry'] = array( + 'soapaction' => "urn:soapinterop", + 'endpoint' => "http://devel/phpgroupware/calendar/soap_server.php?sessionid=c849d2572fe94cbccdf67c5a33ef7d15&kp3=dc6d2b287cce75e8794fec51ee78c3cb&domain=default", +// 'endpoint' => "http://devel/phpgroupware/calendar/soap_server.php", + 'methodNamespace' => "http://soapinterop.org", + 'soapactionNeedsMethod' => 0, + 'name' => 'phpGW calendar - read_entry' + ); + + $server['calendar.bocalendar.store_to_cache'] = array( + 'soapaction' => "urn:soapinterop", + 'endpoint' => "http://devel/phpgroupware/calendar/soap_server.php?sessionid=c849d2572fe94cbccdf67c5a33ef7d15&kp3=dc6d2b287cce75e8794fec51ee78c3cb&domain=default", +// 'endpoint' => "http://devel/phpgroupware/calendar/soap_server.php", + 'methodNamespace' => "http://soapinterop.org", + 'soapactionNeedsMethod' => 0, + 'name' => 'phpGW calendar - store_to_cache' + ); + + + $method_params['calendar.bocalendar.read_entry']['id'] = 85; + + $method_params['calendar.bocalendar.store_to_cache']['syear'] = 2001; + $method_params['calendar.bocalendar.store_to_cache']['smonth'] = 7; + $method_params['calendar.bocalendar.store_to_cache']['sday'] = 9; + $method_params['calendar.bocalendar.store_to_cache']['eyear'] = 2001; + $method_params['calendar.bocalendar.store_to_cache']['emonth'] = 7; + $method_params['calendar.bocalendar.store_to_cache']['eday'] = 10; + +// $method = 'calendar.bocalendar.read_entry'; + $method = 'calendar.bocalendar.store_to_cache'; + + print "METHOD: ".$method."
"; + $soap_message = CreateObject('phpgwapi.soapmsg',$method,$method_params[$method],$server[$method]['methodNamespace']); + print_r($soap_message); + $soap = CreateObject('phpgwapi.soap_client',$server[$method]['endpoint']); + if($return = $soap->send($soap_message,$server[$method]['soapaction'])){ + // check for valid response + if(get_class($return) == 'soapval'){ + print 'Correctly decoded server\'s response
'; + // fault? + if(eregi('fault',$return->name)){ + $status = 'failed'; + } else { + $status = 'passed'; + } + } else { + print 'Client could not decode server\'s response
'; + } + } else { + print 'Was unable to send or receive.'; + } + + //$soap->incoming_payload .= "\n\n"; + print 'Request:
'.$soap->outgoing_payload.'
'; + print 'Response:
'.$soap->incoming_payload.''; +// print_r($return); +?> diff --git a/calendar/soap_server.php b/calendar/soap_server.php new file mode 100755 index 0000000000..ed4f4c5536 --- /dev/null +++ b/calendar/soap_server.php @@ -0,0 +1,50 @@ + * +* -------------------------------------------- * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 2 of the License, or (at your * +* option) any later version. * +\**************************************************************************/ + + /* $Id$ */ + +// $login = 'skeeter'; +// $passwd = 'Mast\!Mage'; +// $sessionid = 'c849d2572fe94cbccdf67c5a33ef7d15'; +// $kp3 = 'dc6d2b287cce75e8794fec51ee78c3cb'; +// $domain = 'default'; + + $phpgw_info['flags'] = array( + 'disable_template_class' => True, +// 'login' => True, + 'currentapp' => 'calendar', + 'noheader' => True, + 'nofooter' => True); + + include('../header.inc.php'); + include('../soap/vars.php'); + +// 1. include client and server +// 2. instantiate server object + +// function read_entry($id) +// { +// $cal = CreateObject('calendar.bocalendar'); +// return CreateObject('soap.soapval',"event","array",$cal->assoc_array($cal->read_entry($id))); +// } + $server = CreateObject('phpgwapi.soap_server'); +// CreateObject('phpgwapi.soap_client'); + +// $server->add_to_map( +// "read_entry", +// array("int"), +// array("array") +// ); + $server->service($HTTP_RAW_POST_DATA); + +// $cal = CreateObject('calendar.soap_calendar'); +?>