From 1609677f717cfa4ffbe91fdbede4d13fc12b2e66 Mon Sep 17 00:00:00 2001 From: skeeter Date: Mon, 6 Aug 2001 02:41:36 +0000 Subject: [PATCH] Tons of major fixes to the n-tier calendar. Still need to incorporate ralfbeckers enhancements to the planner. --- calendar/inc/class.bocalendar.inc.php | 83 ++++++++++----- calendar/inc/class.socalendar.inc.php | 4 +- calendar/inc/class.socalendar__.inc.php | 17 +-- calendar/inc/class.socalendar_sql.inc.php | 3 +- calendar/inc/class.uicalendar.inc.php | 122 +++++++++++----------- 5 files changed, 123 insertions(+), 106 deletions(-) diff --git a/calendar/inc/class.bocalendar.inc.php b/calendar/inc/class.bocalendar.inc.php index f14fbd46d8..d7cbd2e181 100755 --- a/calendar/inc/class.bocalendar.inc.php +++ b/calendar/inc/class.bocalendar.inc.php @@ -237,7 +237,7 @@ if($this->check_perms(PHPGW_ACL_DELETE)) { $temp_event = $this->read_entry($id); - if($this->owner == $temp_event->owner) + if($this->owner == $temp_event['owner']) { $this->so->delete_entry($id); $cd = 16; @@ -272,6 +272,7 @@ { if($this->check_perms(PHPGW_ACL_DELETE)) { + reset($this->so->cal->delete_events); for($i=0;$iso->cal->deleted_events);$i++) { $event_id = $this->so->cal->deleted_events[$i]; @@ -298,12 +299,15 @@ $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) + if($p_cal || $p_participants || $p_start || $p_end || $p_recur_enddata) { $send_to_ui = False; } - $overlapping_events = False; + if($this->debug) + { + echo "ID : ".$cal['id']."
\n"; + } $ui = CreateObject('calendar.uicalendar'); @@ -313,12 +317,12 @@ $datetime_check = $this->validate_update($event); if($datetime_check) { - $ui->edit($datetime_check,True); + $ui->edit($datetime_check,1); } + $overlapping_events = False; } else { - if(!$cal['id'] && !$this->check_perms(PHPGW_ACL_ADD)) { $ui->index(); @@ -410,15 +414,20 @@ @reset($part); while(list($key,$value) = each($part)) { - $this->so->add_attribute('participants','U',$key); + $this->so->add_attribute('participants','U',intval($key)); } - reset($participants); +// reset($participants); $event = $this->get_cached_event(); + if(!@$event['participants'][$cal['owner']]) { $this->so->add_attribute('owner',$minparts); } + else + { + $this->so->add_attribute('owner',$cal['owner']); + } $this->so->add_attribute('priority',$cal['priority']); $event = $this->get_cached_event(); @@ -426,23 +435,27 @@ $datetime_check = $this->validate_update($event); if($datetime_check) { - $ui = CreateObject('calendar.uicalendar'); - $ui->edit($datetime_check,True); + $ui->edit($datetime_check,1); } - settype($start,'integer'); - settype($end,'integer'); - $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( + $this->maketime($event['start']) - $this->datetime->tz_offset, + $this->maketime($event['end']) - $this->datetime->tz_offset, + $event['participants'], + $event['owner'], + $event['id'] + ); } if($overlapping_events) { if($send_to_ui) { + unset($phpgw_info['flags']['noheader']); + unset($phpgw_info['flags']['nonavbar']); $ui->overlap($overlapping_events,$event); + $phpgw_info['flags']['nofooter'] = True; + return; } else { @@ -459,8 +472,9 @@ else { $new_event = $event; - $old_event = $this->read_entry($new_event['id']); + $old_event = $this->read_entry($event['id']); $this->prepare_recipients($new_event,$old_event); + $this->so->cal->event = $event; $this->so->add_entry($event); } $date = sprintf("%04d%02d%02d",$event['start']['year'],$event['start']['month'],$event['start']['mday']); @@ -561,9 +575,9 @@ { $can_edit = False; - if(($event->owner == $this->owner) && ($this->check_perms(PHPGW_ACL_EDIT) == True)) + if(($event['owner'] == $this->owner) && ($this->check_perms(PHPGW_ACL_EDIT) == True)) { - if($event->public != True) + if($event['public'] != True) { if($this->check_perms(PHPGW_ACL_PRIVATE) == True) { @@ -608,7 +622,7 @@ { $error = 0; // do a little form verifying - if ($event->title == '') + if ($event['title'] == '') { $error = 40; } @@ -1144,12 +1158,21 @@ for($i=0;$i<$c_cached_ids;$i++) { $event = $this->so->read_entry($cached_event_ids[$i]); - $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) - { - $this->cached_events[date('Ymd',$endtime)][] = $event; + $startdate = intval(date('Ymd',$this->maketime($event['start']))); + $enddate= intval(date('Ymd',$this->maketime($event['end']))); + $this->cached_events[$startdate][] = $event; +// if($startdate != $enddate) +// { + $start['year'] = intval(substr($startdate,0,4)); + $start['month'] = intval(substr($startdate,4,2)); + $start['day'] = intval(substr($startdate,6,2)); + for($j=$startdate,$k=0;$j<=$enddate;$k++,$j=intval(date('Ymd',mktime(0,0,0,$start['month'],$start['day'] + $k,$start['year'])))) + { + if($this->cached_events[$j][count($this->cached_events[$j]) - 1] != $event) + { + $this->cached_events[$j][] = $event; + } +// } } } } @@ -1181,7 +1204,8 @@ { global $phpgw; $this->event_init(); - $event = unserialize(str_replace('O:8:"stdClass"','O:13:"calendar_time"',serialize($phpgw->session->appsession('entry','calendar')))); +// $event = unserialize(str_replace('O:8:"stdClass"','O:13:"calendar_time"',serialize($phpgw->session->appsession('entry','calendar')))); + $event = $phpgw->session->appsession('entry','calendar'); $this->so->cal->event = $event; return $event; } @@ -1500,8 +1524,6 @@ $phpgw_info['user']['preferences'] = $phpgw->common->create_emailpreferences($phpgw_info['user']['preferences'],$user); - $send = CreateObject('phpgwapi.send'); - switch($msg_type) { case MSG_DELETED: @@ -1552,6 +1574,11 @@ { // echo "Msg Type = ".$msg_type."
\n"; // echo "userid = ".$userid."
\n"; + if(!is_object($send)) + { + $send = CreateObject('phpgwapi.send'); + } + $preferences = CreateObject('phpgwapi.preferences',intval($userid)); $part_prefs = $preferences->read_repository(); if(!isset($part_prefs['calendar']['send_updates']) || !$part_prefs['calendar']['send_updates']) diff --git a/calendar/inc/class.socalendar.inc.php b/calendar/inc/class.socalendar.inc.php index 49e35c2047..f7c89f397d 100755 --- a/calendar/inc/class.socalendar.inc.php +++ b/calendar/inc/class.socalendar.inc.php @@ -230,9 +230,9 @@ return $this->cal->event; } - function add_attribute($var,$value) + function add_attribute($var,$value,$element='False') { - $this->cal->add_attribute($var,$value); + $this->cal->add_attribute($var,$value,$element); } function event_init() diff --git a/calendar/inc/class.socalendar__.inc.php b/calendar/inc/class.socalendar__.inc.php index 8e8e60c129..a24500fc64 100755 --- a/calendar/inc/class.socalendar__.inc.php +++ b/calendar/inc/class.socalendar__.inc.php @@ -184,22 +184,11 @@ class socalendar__ } if($element!='False') { - if(is_int($element)) - { - eval("\$this->event['".$attribute."'][".$element."] = ".$value.";"); - } - else - { - eval("\$this->event['".$attribute."']['".$element."'] = ".$value.";"); - } + $this->event[$attribute][$element] = $value; } - elseif(is_int($value)) + else { - eval("\$this->event['".$attribute."'] = ".$value.";"); - } - elseif(is_string($value)) - { - eval("\$this->event['".$attribute."'] = '".$value."';"); + $this->event[$attribute] = $value; } } } diff --git a/calendar/inc/class.socalendar_sql.inc.php b/calendar/inc/class.socalendar_sql.inc.php index dc8f2638ec..d876418982 100755 --- a/calendar/inc/class.socalendar_sql.inc.php +++ b/calendar/inc/class.socalendar_sql.inc.php @@ -35,7 +35,7 @@ class socalendar_ extends socalendar__ if($user=='') { settype($user,'integer'); - $user = $phpgw_info['user']['account_id']; + $this->user = $phpgw_info['user']['account_id']; } elseif(is_int($user)) { @@ -270,6 +270,7 @@ class socalendar_ extends socalendar__ function expunge() { + reset($this->deleted_events); if(count($this->deleted_events) <= 0) { return 1; diff --git a/calendar/inc/class.uicalendar.inc.php b/calendar/inc/class.uicalendar.inc.php index 6bbccf27da..1a642f90c5 100755 --- a/calendar/inc/class.uicalendar.inc.php +++ b/calendar/inc/class.uicalendar.inc.php @@ -103,10 +103,11 @@ $p = CreateObject('phpgwapi.Template',$this->template_dir); $p->set_unknowns('remove'); - $templates = Array( - 'mini_calendar' => 'mini_cal.tpl' + $p->set_file( + Array( + 'mini_calendar' => 'mini_cal.tpl' + ) ); - $p->set_file($templates); $p->set_block('mini_calendar','mini_cal','mini_cal'); $p->set_block('mini_calendar','mini_week','mini_week'); $p->set_block('mini_calendar','mini_day','mini_day'); @@ -161,8 +162,11 @@ for($i=0;$i<7;$i++) { - $p->set_var('dayname','' . substr(lang($this->bo->datetime->days[$i]),0,2) . ''); - $p->parse('daynames','mini_day',True); + $var = Array( + 'dayname' => '' . substr(lang($this->bo->datetime->days[$i]),0,2) . '', + 'day_image' => '' + ); + $this->output_template_array($p,'daynames','mini_day',$var); } $today = date('Ymd',time()); unset($date); @@ -270,10 +274,11 @@ $p = CreateObject('phpgwapi.Template',$this->template_dir); $p->set_unknowns('remove'); - $templates = Array( - 'index_t' => 'index.tpl' + $p->set_file( + Array( + 'index_t' => 'index.tpl' + ) ); - $p->set_file($templates); $p->set_var($var); $p->pparse('out','index_t'); } @@ -337,11 +342,11 @@ ); $p = CreateObject('phpgwapi.Template',$this->template_dir); - $templates = Array( - 'week_t' => 'week.tpl' + $p->set_file( + Array( + 'week_t' => 'week.tpl' + ) ); - - $p->set_file($templates); $p->set_var($var); $p->pparse('out','week_t'); } @@ -381,10 +386,11 @@ ); $p = CreateObject('phpgwapi.Template',$this->template_dir); - $templates = Array( - 'year_t' => 'year.tpl' + $p->set_file( + Array( + 'year_t' => 'year.tpl' + ) ); - $p->set_file($templates); $p->set_block('year_t','year','year'); $p->set_block('year_t','month','month'); $p->set_block('year_t','month_sep','month_sep'); @@ -413,7 +419,7 @@ echo '
'; - if(!@$cal_id && $vcal_id) + if(!isset($cal_id) && $vcal_id) { $cal_id = $vcal_id; } @@ -445,10 +451,11 @@ if($this->bo->owner == $event['owner']) { $p = CreateObject('phpgwapi.Template',$this->template_dir); - $templates = Array( - 'form_button' => 'form_button_script.tpl' + $p->set_file( + Array( + 'form_button' => 'form_button_script.tpl' + ) ); - $p->set_file($templates); if ($this->bo->check_perms(PHPGW_ACL_EDIT)) { @@ -502,10 +509,10 @@ $this->view($cal_id); } } - $this->edit_form($event); + $this->edit_form($event,$cd); } - function add($cd,$readsess) + function add($cd=0,$readsess=0) { global $phpgw, $phpgw_info, $cal_id, $hour, $minute; @@ -514,7 +521,7 @@ $this->index(); } - if(isset($readsess)) + if($readsess) { $event = $this->bo->restore_from_appsession; if(!$event['owner']) @@ -549,14 +556,15 @@ $this->bo->set_recur_none(); $event = $this->bo->get_cached_event(); } - $this->edit_form($event); + $this->edit_form($event,$cd); } function delete() { 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)) + 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']); @@ -837,7 +845,7 @@ { $dayname = substr(lang(date('D',mktime(0,0,0,$this->bo->month,$d,$this->bo->year))),0,2); - $header['.'.$d] = "colspan=$intervals_per_day align=center"; + $header['.'.$d] = 'colspan="'.$intervals_per_day.'" align="center"'; $header[$d] = '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']; @@ -962,7 +970,7 @@ if ($akt_cell <= $last_cell) { $row['3'] = ' '; - $row['.3'] = 'colspan='.(1+$last_cell-$akt_cell); + $row['.3'] = 'colspan="'.(1+$last_cell-$akt_cell).'"'; } } } @@ -973,7 +981,7 @@ '_h' => $header, '._h' => $bgcolor )+$rows, - 'width="100%" cols='.(1+$days*$intervals_per_day) + 'width="100%" cols="'.(1+$days*$intervals_per_day).'"' ); } @@ -1368,11 +1376,11 @@ $p = CreateObject('phpgwapi.Template',$this->template_dir); - $templates = Array( - 'footer' => 'footer.tpl' + $p->set_file( + Array( + 'footer' => 'footer.tpl' + ) ); - - $p->set_file($templates); $p->set_block('footer','footer_table','footer_table'); $p->set_block('footer','footer_row','footer_row'); @@ -1618,11 +1626,11 @@ { global $phpgw, $phpgw_info; - $month = $event->start->month; - $mday = $event->start->mday; - $year = $event->start->year; + $month = $event['start']['month']; + $mday = $event['start']['mday']; + $year = $event['start']['year']; - $start = mktime($event->start->hour,$event->start->min,$event->start->sec,$month,$mday,$year) - $this->bo->datetime->tz_offset; + $start = mktime($event['start']['hour'],$event['start']['min'],$event['start']['sec'],$month,$mday,$year) - $this->bo->datetime->tz_offset; $end = $this->bo->maketime($event['end']) - $this->bo->datetime->tz_offset; $overlap = ''; @@ -1633,9 +1641,10 @@ unset($phpgw_info['flags']['noheader']); unset($phpgw_info['flags']['nonavbar']); + $phpgw_info['flags']['nofooter'] = True; $phpgw->common->phpgw_header(); - $p = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('calendar')); + $p = CreateObject('phpgwapi.Template',$this->template_dir); $p->set_file( Array( 'overlap' => 'overlap.tpl', @@ -1666,7 +1675,7 @@ 'action_confirm_button' => '', 'action_extra_field' => '' ); - $this->output_template_array($p,'resubmit_button','form_button',$var); + $this->output_template_array($p,'reedit_button','form_button',$var); $p->pparse('out','overlap'); } @@ -1804,7 +1813,7 @@ { if ($day_params['new_event']) { - $new_event_link = '' + $new_event_link = '' . ''.lang('New Entry').'' . ''; $day_number = ''.$day.''; @@ -2066,11 +2075,10 @@ $cal_grps = ''; for($i=0;$i0) + if($phpgw->accounts->exists($event['groups'][$i])) { - $cal_grps .= '
'; + $cal_grps .= ($i>0?'
':'').$phpgw->accounts->id2name($event['groups'][$i]); } - $cal_grps .= $phpgw->accounts->id2name($event['groups'][$i]); } $var[] = Array( @@ -2085,14 +2093,7 @@ { if($phpgw->accounts->exists($user)) { - if($str) - { - $str .= '
'; - } - - $long_status = $this->bo->get_long_status($short_status); - - $str .= $phpgw->common->grab_owner_name($user).' ('.($this->bo->check_perms(PHPGW_ACL_EDIT,$user)?''.$long_status.'':$long_status).')'."\n"; + $str .= ($str?'
':'').$phpgw->common->grab_owner_name($user).' ('.($this->bo->check_perms(PHPGW_ACL_EDIT,$user)?''.$this->bo->get_long_status($short_status).'':$this->bo->get_long_status($short_status)).')'."\n"; } } $var[] = Array( @@ -2566,7 +2567,7 @@ return ''."\n".$str.'
'."\n"; } - function edit_form($event) + function edit_form($event,$cd) { global $phpgw, $phpgw_info; @@ -2574,9 +2575,6 @@ $sb = CreateObject('phpgwapi.sbox'); - $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']); $phpgw_info['flags']['noappheader'] = True; @@ -2625,6 +2623,7 @@ ); // Date + $start = $this->bo->maketime($event['start']) - $this->bo->datetime->tz_offset; $var[] = Array( 'field' => lang('Start Date'), 'data' => $phpgw->common->dateformatorder( @@ -2637,8 +2636,8 @@ // Time if ($this->bo->prefs['common']['timeformat'] == '12') { - $str .= 'start->hour >= 12?'':' checked').'>am'."\n" - . 'start->hour >= 12?' checked':'').'>pm'."\n"; + $str .= '= 12?'':' checked').'>am'."\n" + . '= 12?' checked':'').'>pm'."\n"; } $var[] = Array( 'field' => lang('Start Time'), @@ -2646,6 +2645,7 @@ ); // End Date + $end = $this->bo->maketime($event['end']) - $this->bo->datetime->tz_offset; $var[] = Array( 'field' => lang('End Date'), 'data' => $phpgw->common->dateformatorder( @@ -2658,8 +2658,8 @@ // End Time if ($this->bo->prefs['common']['timeformat'] == '12') { - $str = 'end->hour >= 12?'':' checked').'>am'."\n" - . 'end->hour >= 12?' checked':'').'>pm'."\n"; + $str = '= 12?'':' checked').'>am'."\n" + . '= 12?' checked':'').'>pm'."\n"; } $var[] = Array( 'field' => lang("End Time"), @@ -2681,7 +2681,7 @@ // Participants $accounts = $phpgw->acl->get_ids_for_location('run',1,'calendar'); $users = Array(); - $this->build_part_list($users,$accounts,$owner); + $this->build_part_list($users,$accounts,$event['owner']); $str = ''; @asort($users); @@ -2699,7 +2699,7 @@ ); // I Participate - if((($cal_id > 0) && isset($event['participants'][$this->bo->owner])) || !isset($cal_id)) + if((($event['id'] > 0) && isset($event['participants'][$this->bo->owner])) || !$event['id']) { $checked = ' checked'; }