diff --git a/calendar/inc/class.boalarm.inc.php b/calendar/inc/class.boalarm.inc.php index 219e4ff96a..bbb57553c0 100755 --- a/calendar/inc/class.boalarm.inc.php +++ b/calendar/inc/class.boalarm.inc.php @@ -67,11 +67,5 @@ { return $this->cal->read_entry($cal_id); } - - function can_user_edit($event) - { - return $this->cal->can_user_edit($event); - } - /* Public functions */ } diff --git a/calendar/inc/class.bocalendar.inc.php b/calendar/inc/class.bocalendar.inc.php index c4e6225e90..e0b5efc60e 100755 --- a/calendar/inc/class.bocalendar.inc.php +++ b/calendar/inc/class.bocalendar.inc.php @@ -143,22 +143,42 @@ $this->read_sessiondata(); $this->use_session = True; } - print_debug('BO Filter',$this->filter); print_debug('Owner',$this->owner); $this->prefs['calendar'] = $GLOBALS['phpgw_info']['user']['preferences']['calendar']; + + $owner = (isset($GLOBALS['owner'])?$GLOBALS['owner']:''); + $owner = (isset($GLOBALS['HTTP_GET_VARS']['owner'])?$GLOBALS['HTTP_GET_VARS']['owner']:$owner); + $owner = ($owner=='' && isset($GLOBALS['HTTP_POST_VARS']['owner'])?$GLOBALS['HTTP_POST_VARS']['owner']:$owner); - $owner = get_var('owner',Array('GLOBAL','GET','POST')); - - if ((!isset($owner) || $owner == '') - && MENUACTION == 'calendar.uicalendar.planner' - && get_var('from',Array('POST')) != 'calendar.uicalendar.planner' - && $this->prefs['calendar']['planner_start_with_group'] != '-1') + ereg('menuaction=([a-zA-Z.]+)',$GLOBALS['HTTP_REFERER'],$regs); + $from = $regs[1]; + if ((substr($GLOBALS['PHP_SELF'],-8) == 'home.php' && substr($this->prefs['calendar']['defaultcalendar'],0,7) == 'planner' + || $GLOBALS['HTTP_GET_VARS']['menuaction'] == 'calendar.uicalendar.planner' && + $from != 'calendar.uicalendar.planner' && !$this->save_owner) + && intval($this->prefs['calendar']['planner_start_with_group']) > 0) { - $owner = $this->prefs['calendar']['planner_start_with_group']; + // entering planner for the first time ==> saving owner in save_owner, setting owner to default + // + $this->save_owner = $this->owner; + $owner = 'g_'.$this->prefs['calendar']['planner_start_with_group']; } - + elseif ($GLOBALS['HTTP_GET_VARS']['menuaction'] != 'calendar.uicalendar.planner' && + $this->save_owner) + { + // leaving planner with an unchanged user/owner ==> setting owner back to save_owner + // + $owner = intval(isset($GLOBALS['HTTP_GET_VARS']['owner']) ? $GLOBALS['HTTP_GET_VARS']['owner'] : $this->save_owner); + unset($this->save_owner); + } + elseif (!empty($owner) && $owner != $this->owner && $from == 'calendar.uicalendar.planner') + { + // user/owner changed within planner ==> forgetting save_owner + // + unset($this->save_owner); + } + if(isset($owner) && $owner!='' && substr($owner,0,2) == 'g_') { $this->set_owner_to_group(substr($owner,2)); @@ -186,7 +206,6 @@ { $this->users_timeformat = 'H:i'; } - $this->holiday_color = (substr($GLOBALS['phpgw_info']['theme']['bg07'],0,1)=='#'?'':'#').$GLOBALS['phpgw_info']['theme']['bg07']; $this->printer_friendly = (intval(get_var('friendly',Array('GET','POST','DEFAULT'),0)) == 1?True:False); @@ -196,11 +215,7 @@ $this->sortby = get_var('sortby',Array('POST')); if(!isset($this->sortby)) { - $default_calender = $this->prefs['calendar']['defaultcalendar']; - if ($default_calender == 'planner_cat' || $default_calender == 'planner_user') - { - $this->sortby = ($default_calender == 'planner_cat' ? 'category' : 'user'); - } + $this->sortby = $this->prefs['calendar']['defaultcalendar'] == 'planner_user' ? 'user' : 'category'; } if($GLOBALS['phpgw']->accounts->get_type($this->owner)=='g') @@ -375,7 +390,7 @@ return False; } - function save_sessiondata($data) + function save_sessiondata($data='') { if ($this->use_session) { @@ -393,10 +408,12 @@ $this->cat_id = $data['cat_id']; $this->sortby = $data['sortby']; $this->owner = intval($data['owner']); + $this->save_owner = intval($data['save_owner']); $this->year = intval($data['year']); $this->month = intval($data['month']); $this->day = intval($data['day']); $this->num_months = intval($data['num_months']); + $this->return_to = $data['return_to']; } function read_entry($id) @@ -444,7 +461,7 @@ { if($this->check_perms(PHPGW_ACL_DELETE,$id)) { - $temp_event = $this->read_entry($id); +// $temp_event = $this->read_entry($id); // if($this->owner == $temp_event['owner']) // { $this->so->delete_entry($id); @@ -513,17 +530,20 @@ function expunge() { - if($this->check_perms(PHPGW_ACL_DELETE)) + reset($this->so->cal->deleted_events); + while(list($i,$event_id) = each($this->so->cal->deleted_events)) { - reset($this->so->cal->deleted_events); - for($i=0;$iso->cal->deleted_events);$i++) + $event = $this->so->read_entry($event_id); + if($this->check_perms(PHPGW_ACL_DELETE,$event)) { - $event_id = $this->so->cal->deleted_events[$i]; - $event = $this->so->read_entry($event_id); $this->send_update(MSG_DELETED,$event['participants'],$event); } - $this->so->expunge(); + else + { + unset($this->so->cal->deleted_events[$i]); + } } + $this->so->expunge(); } function search_keywords($keywords) @@ -795,6 +815,12 @@ $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) + { + header('Location: '.$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->return_to)); + $GLOBALS['phpgw']->common->phpgw_exit(); + } Execmethod('calendar.uicalendar.index'); // $GLOBALS['phpgw_info']['flags']['nodisplay'] = True; // exit; @@ -843,11 +869,6 @@ return mktime($time['hour'],$time['min'],$time['sec'],$time['month'],$time['mday'],$time['year']); } - function can_user_edit($event) - { - return $this->check_perms(PHPGW_ACL_EDIT,$event); - } - function fix_update_time(&$time_param) { if ($this->prefs['common']['timeformat'] == '12') @@ -1030,11 +1051,21 @@ return $retval; } - function check_perms($needed,$event=0) + /*! + @function check_perms( ) + @syntax check_perms($needed,$event=0,$other=0) + @abstract Checks if the current user has the necessary ACL rights + @author ralfbecker + @discussion The check is performed on an event or general on the cal of an other user + @param $needed necessary ACL right: PHPGW_ACL_{READ|EDIT|DELETE} + @param $event event as array or the event-id or 0 for general check + @param $other uid to check (if event==0) or 0 to check against $this->owner + */ + function check_perms($needed,$event=0,$other=0) { if (is_int($event) && $event == 0) { - $owner = $this->owner; + $owner = $other > 0 ? $other : $this->owner; } else { @@ -1052,8 +1083,15 @@ $user = $GLOBALS['phpgw_info']['user']['account_id']; $grants = $this->grants[$owner]; - $access = $user == $owner || $grants & $needed && (!$private || $grants & PHPGW_ACL_PRIVATE); - //echo "

rb_check_perms for user $user and needed_acl $needed: event=$event[title]: owner=$owner, privat=$privat, grants=$grants ==> access=$access

\n"; + if ($GLOBALS['phpgw']->accounts->get_type($owner) == 'g' && $needed == PHPGW_ACL_ADD) + { + $access = False; // a group can't be the owner of an event + } + else + { + $access = $user == $owner || $grants & $needed && (!$private || $grants & PHPGW_ACL_PRIVATE); + } + //echo "

rb_check_perms for user $user and needed_acl $needed: event=$event[title]: owner=$owner, privat=$private, grants=$grants ==> access=$access

\n"; return $access; } @@ -1076,8 +1114,10 @@ function display_status($user_status) { - if(@$this->prefs['calendar']['display_status']) + if(@$this->prefs['calendar']['display_status'] && $user_status) { + $user_status = substr($this->get_long_status($user_status),0,1); + return ' ('.$user_status.')'; } else @@ -1112,7 +1152,7 @@ { $owner = $this->owner; } - if ($owner == $GLOBALS['phpgw_info']['user']['account_id'] || ($event['public']==1) || ($this->check_perms(PHPGW_ACL_PRIVATE,$owner) && $event['public']==0) || $event['owner'] == $GLOBALS['phpgw_info']['user']['account_id']) + if ($owner == $GLOBALS['phpgw_info']['user']['account_id'] || ($event['public']==1) || ($this->check_perms(PHPGW_ACL_PRIVATE,$event) && $event['public']==0) || $event['owner'] == $GLOBALS['phpgw_info']['user']['account_id']) { return False; } @@ -1157,27 +1197,69 @@ } } + function long_date($first,$last=0) + { + $datefmt = $this->prefs['common']['dateformat']; + + $month_before_day = $datefmt[0] == 'm' || $datefmt[2] == 'm' && $datefmt[4] == 'd'; + + for ($i = 0; $i < 5; $i += 2) + { + switch($datefmt[$i]) + { + case 'd': + $range .= $first['day'] . ($datefmt[1] == '.' ? '.' : ''); + if ($first['month'] != $last['month'] || $first['year'] != $last['year']) + { + if (!$month_before_day) + { + $range .= ' '.lang(strftime('%B',$first['raw'])); + } + if ($first['year'] != $last['year'] && $datefmt[0] != 'Y') + { + $range .= ($datefmt[0] != 'd' ? ', ' : ' ') . $first['year']; + } + if (!$last) + { + return $range; + } + $range .= ' - '; + + if ($first['year'] != $last['year'] && $datefmt[0] == 'Y') + { + $range .= $last['year'] . ', '; + } + + if ($month_before_day) + { + $range .= lang(strftime('%B',$last['raw'])); + } + } + else + { + $range .= ' - '; + } + $range .= ' ' . $last['day'] . ($datefmt[1] == '.' ? '.' : ''); + break; + case 'm': + $range .= ' '.lang(strftime('%B',$month_before_day ? $first['raw'] : $last['raw'])) . ' '; + break; + case 'Y': + $range .= ($datefmt[0] == 'm' ? ', ' : ' ') . ($datefmt[0] == 'Y' ? $first['year'].', ' : $last['year'].' '); + break; + } + } + return $range; + } + function get_week_label() { $first = $GLOBALS['phpgw']->datetime->gmtdate($GLOBALS['phpgw']->datetime->get_weekday_start($this->year, $this->month, $this->day)); $last = $GLOBALS['phpgw']->datetime->gmtdate($first['raw'] + 518400); - -// Week Label - $week_id = lang(strftime("%B",$first['raw'])).' '.$first['day']; - if($first['month'] <> $last['month'] && $first['year'] <> $last['year']) - { - $week_id .= ', '.$first['year']; - } - $week_id .= ' - '; - if($first['month'] <> $last['month']) - { - $week_id .= lang(strftime("%B",$last['raw'])).' '; - } - $week_id .= $last['day'].', '.$last['year']; - - return $week_id; + + return ($this->long_date($first,$last)); } - + function normalizeminutes(&$minutes) { $hour = 0; @@ -1898,6 +1980,7 @@ if($new_event != False) { $new_event_datetime = $this->maketime($new_event['start']) - $GLOBALS['phpgw']->datetime->tz_offset; + $new_event_datetime_end = $this->maketime($new_event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; } //Added to construct the participant's list to an event @@ -1959,6 +2042,7 @@ if($new_event != False) { $new_event_date = $GLOBALS['phpgw']->common->show_date($new_event_datetime); + $new_event_end = $GLOBALS['phpgw']->common->show_date($new_event_datetime_end); } switch($msg_type) @@ -1986,6 +2070,7 @@ case MSG_ACCEPTED: $action_date = $old_event_date; $body = 'On '.$GLOBALS['phpgw']->common->show_date(time() - $GLOBALS['phpgw']->datetime->tz_offset).' '.$GLOBALS['phpgw']->common->grab_owner_name($GLOBALS['phpgw_info']['user']['account_id']).' '.$action.' your meeting request for '.$old_event_date; + $body = lang('On %1 %2 %3 your meeting request for %4',$GLOBALS['phpgw']->common->show_date(time() - $GLOBALS['phpgw']->datetime->tz_offset),$GLOBALS['phpgw']->common->grab_owner_name($GLOBALS['phpgw_info']['user']['account_id']),lang($action),$old_event_date); $event_head=$old_event['title']; $event_description=$old_event['description']; break; @@ -1996,6 +2081,7 @@ { $body .= "\n\n".'***'.lang('Please confirm,accept,reject or examine changes in the corresponding entry in your calendar').'***'."\n\n" . '----'.lang('Event Details Follow').'----'; + $body .= ($new_event_date ? "\n\n".lang('Start- and Enddates').":\n".$new_event_date.' -- '. $new_event_end : ''); $body .= ($event_head?"\n\n".lang('TITLE').':'."\n".' '.$event_head:''); $body .= ($event_description?"\n\n".lang('DESCRIPTION').':'."\n".' '.$event_description:''); $body .= ($event_participants?"\n\n".lang('Participants').':'."\n".' '.$event_participants:''); diff --git a/calendar/inc/class.socalendar_sql.inc.php b/calendar/inc/class.socalendar_sql.inc.php index ed425520c3..f8a40feac8 100755 --- a/calendar/inc/class.socalendar_sql.inc.php +++ b/calendar/inc/class.socalendar_sql.inc.php @@ -118,10 +118,10 @@ class socalendar_ extends socalendar__ $this->add_attribute('id',intval($this->stream->f('cal_id'))); $this->set_class(intval($this->stream->f('is_public'))); $this->set_category($this->stream->f('category')); - $this->set_title($GLOBALS['phpgw']->strip_html($this->stream->f('title'))); - $this->set_description($GLOBALS['phpgw']->strip_html($this->stream->f('description'))); + $this->set_title(stripslashes($GLOBALS['phpgw']->strip_html($this->stream->f('title')))); + $this->set_description(stripslashes($GLOBALS['phpgw']->strip_html($this->stream->f('description')))); $this->add_attribute('uid',$GLOBALS['phpgw']->strip_html($this->stream->f('uid'))); - $this->add_attribute('location',$GLOBALS['phpgw']->strip_html($this->stream->f('location'))); + $this->add_attribute('location',stripslashes($GLOBALS['phpgw']->strip_html($this->stream->f('location')))); $this->add_attribute('reference',intval($this->stream->f('reference'))); // This is the preferred method once everything is normalized... diff --git a/calendar/inc/class.uialarm.inc.php b/calendar/inc/class.uialarm.inc.php index e78a899f61..2b8901c2c6 100755 --- a/calendar/inc/class.uialarm.inc.php +++ b/calendar/inc/class.uialarm.inc.php @@ -54,8 +54,8 @@ { $this->event = $this->bo->read_entry($this->bo->cal_id); - $can_edit = $this->bo->can_user_edit($this->event); - + $can_edit = $this->bo->cal->check_perms(PHPGW_ACL_EDIT,$this->event); + if(!$can_edit) { Header('Location : '.$GLOBALS['phpgw']->link('/index.php', diff --git a/calendar/inc/class.uicalendar.inc.php b/calendar/inc/class.uicalendar.inc.php index 8bb02500fa..f690a3eb55 100755 --- a/calendar/inc/class.uicalendar.inc.php +++ b/calendar/inc/class.uicalendar.inc.php @@ -46,7 +46,16 @@ var $planner_end_month; var $planner_end_year; - var $planner_days_in_end_month; + var $planner_days_in_end_month; + + var $planner_intervals = array( // conversation hour and interval depending on intervals_per_day + // 1 1 1 1 1 1 1 1 1 1 2 2 2 2 + // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 + '1' => array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), // 0=0-23h + '2' => array(0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0), // 0=0-12h, 1=12-23h + '3' => array(0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,2,2,2,2,2,2), // 0=0-12h, 2=12-18h, 3=18-23h + '4' => array(0,0,0,0,0,0,0,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3) // 0=0-7, 7-12h, 3=12-18h, 4=18-23h + ); var $public_functions = array( 'mini_calendar' => True, @@ -110,9 +119,15 @@ if($this->bo->use_session) { - $this->save_sessiondata(); + // save return-fkt for add, view, ... + list(,,$fkt) = explode('.',$GLOBALS['HTTP_GET_VARS']['menuaction']); + if ($fkt == 'day' || $fkt == 'week' || $fkt == 'month' || $fkt == 'year' || $fkt == 'planner') + { + $this->bo->return_to = $GLOBALS['HTTP_GET_VARS']['menuaction']. + sprintf('&date=%04d%02d%02d',$this->bo->year,$this->bo->month,$this->bo->day); + } + $this->bo->save_sessiondata(); } - print_debug('UI',$this->_debug_sqsof()); } @@ -317,6 +332,7 @@ unset($GLOBALS['phpgw_info']['flags']['noappheader']); unset($GLOBALS['phpgw_info']['flags']['noappfooter']); $GLOBALS['phpgw']->common->phpgw_header(); + include(/*$this->template_dir*/PHPGW_APP_ROOT.'/templates/default'.'/header.inc.php'); $new_body = $this->bo->debug_string.$body; } return $new_body; @@ -799,7 +815,21 @@ 'action_extra_field' => '' ); $p->set_var($var); - echo $p->fp('out','form_button').''; + + echo $p->fp('out','form_button'); + + if ($this->bo->return_to) + { + $var = Array( + 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to), + 'action_text_button' => lang('Done'), + 'action_confirm_button' => '', + 'action_extra_field' => '' + ); + $p->set_var($var); + echo $p->fp('out','form_button'); + } + echo ''; $GLOBALS['phpgw']->hooks->process('calendar_view'); } @@ -841,10 +871,10 @@ } elseif(isset($GLOBALS['HTTP_GET_VARS']['cal_id'])) { - $cal_id = $GLOBALS['HTTP_GET_VARS']['cal_id']; - $event = $this->bo->read_entry(intval($GLOBALS['HTTP_GET_VARS']['cal_id'])); + $cal_id = intval($GLOBALS['HTTP_GET_VARS']['cal_id']); + $event = $this->bo->read_entry($cal_id); - if(!$this->bo->can_user_edit($event)) + if(!$this->bo->check_perms(PHPGW_ACL_EDIT,$event)) { Header('Location: '.$this->page('view','&cal_id='.$cal_id)); $GLOBALS['phpgw_info']['flags']['nodisplay'] = True; @@ -926,8 +956,14 @@ echo ''."\n"; echo ''."\n"; } - - Header('Location: '.$this->index()); + if ($this->bo->return_to) + { + Header('Location: '.$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to)); + } + else + { + Header('Location: '.$this->index()); + } $GLOBALS['phpgw_info']['flags']['nodisplay'] = True; exit; } @@ -1011,7 +1047,7 @@ echo $p->fp('out','form_button'); $var = Array( - 'action_url_button' => $this->page(''), + 'action_url_button' => $this->bo->return_to ? $GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to) : $this->page(''), 'action_text_button' => lang('Cancel'), 'action_confirm_button' => '', 'action_extra_field' => '' @@ -1049,7 +1085,14 @@ { echo ''."\n"; } - Header('Location: '.$this->page('',($cd?'&cd='.$cd:''))); + if ($this->bo->return_to) + { + Header('Location: '.$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to)); + } + else + { + Header('Location: '.$this->page('',($cd?'&cd='.$cd:''))); + } $GLOBALS['phpgw_info']['flags']['nodisplay'] = True; exit; } @@ -1117,12 +1160,10 @@ } $date = sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day); - $event = $this->bo->read_entry(intval($GLOBALS['HTTP_GET_VARS']['cal_id'])); -// if(($GLOBALS['HTTP_GET_VARS']['cal_id'] > 0) && ($event['owner'] == $this->bo->owner) && $this->bo->check_perms(PHPGW_ACL_DELETE)) - if ($this->bo->check_perms(PHPGW_ACL_DELETE,$event)) + if($this->bo->check_perms(PHPGW_ACL_DELETE,$cal_id)) { $delete_type = get_var('delete_type',Array('POST')); - if($delete_type == 'single') + if($deleted_type && $delete_type == 'single') { $cd = $this->bo->delete_single( Array( @@ -1133,7 +1174,6 @@ ) ); } -// elseif((isset($GLOBALS['HTTP_POST_VARS']['delete_type']) && $GLOBALS['HTTP_POST_VARS']['delete_type'] == 'series') || !isset($GLOBALS['HTTP_POST_VARS']['delete_type'])) else { $cd = $this->bo->delete_entry(intval($cal_id)); @@ -1144,7 +1184,14 @@ { $cd = ''; } - Header('Location: '.$this->page('','&date='.$date.($cd?'&cd='.$cd:''))); + if ($this->bo->return_to) + { + Header('Location: '.$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to)); + } + else + { + Header('Location: '.$this->page('','&date='.$date.($cd?'&cd='.$cd:''))); + } $GLOBALS['phpgw_info']['flags']['nodisplay'] = True; exit; } @@ -1184,7 +1231,6 @@ $now = $GLOBALS['phpgw']->datetime->makegmttime(0, 0, 0, $this->bo->month, $this->bo->day, $this->bo->year); $now['raw'] += $GLOBALS['phpgw']->datetime->tz_offset; - $m = mktime(0,0,0,$this->bo->month,1,$this->bo->year); $p = CreateObject('phpgwapi.Template',$this->template_dir); $p->set_file( @@ -1206,7 +1252,7 @@ ) ), 'small_calendar' => $minical, - 'date' => lang(date('F',$m)).' '.sprintf("%02d",$this->bo->day).', '.$this->bo->year, + 'date' => $this->bo->long_date($now), 'username' => $GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner), 'print' => $print ); @@ -1266,187 +1312,248 @@ $this->bo->set_status(intval($GLOBALS['HTTP_GET_VARS']['cal_id']),intval($GLOBALS['HTTP_GET_VARS']['action'])); - Header('Location: '.$this->page('','')); + if ($this->bo->return_to) + { + Header('Location: '.$GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to)); + } + else + { + Header('Location: '.$this->page('','')); + } $GLOBALS['phpgw_info']['flags']['nodisplay'] = True; exit; } function planner() { - if(floor(phpversion()) == 4) - { - eval(' + if(floor(phpversion()) < 4) + { + return; + } + $home = strstr($GLOBALS['PHP_SELF'],'home') !== False; + // generate header and set global/member variables + // + $this->planner_prepare($home); - // generate header and set global/member variables - // - $this->planner_prepare(); + // process events within selected interval + // + $this->planner_process_interval(); - // process events within selected interval - // - $this->planner_process_interval(); + // generate the planner view + // + if (!$home) + { + echo '

'.$this->planner_print_rows(); + } + else + { + return $this->planner_print_rows(); + } + } - // generate the planner view - // - $this->planner_print_rows(); - '); + function set_planner_group_members() + { + $type = $GLOBALS['phpgw']->accounts->get_type($this->bo->owner); + + if ($type == 'g') // display schedule of all group members + { + $members = array(); + $ids = $GLOBALS['phpgw']->acl->get_ids_for_location($this->bo->owner, 1, 'phpgw_group'); + while (list(,$id) = each($ids)) + { + if ($this->bo->check_perms(PHPGW_ACL_READ,0,$id)) + { + $members[$GLOBALS['phpgw']->common->grab_owner_name($id)] = $id; + } + } + ksort($members); + $this->planner_group_members = $members; + } + else + { + $this->planner_group_members = array( + $GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner) => $this->bo->owner + ); } } /** * planner_prepare - prepare the planner view * - * - sets global environment variables + * - sets global environment variables * - initializes class member variables used in multiple planner related functions * - generates header lines for the planner view (month, calendar week, days) */ - function planner_prepare() + function planner_prepare($no_header = False) { - if(floor(phpversion()) == 4) - { - eval(' - // set some globals - // - unset($GLOBALS[\'phpgw_info\'][\'flags\'][\'noheader\']); - unset($GLOBALS[\'phpgw_info\'][\'flags\'][\'nonavbar\']); - $GLOBALS[\'phpgw\']->common->phpgw_header(); - - // intervals_per_day can be configured in preferences now :-) - // - if (! $this->bo->prefs[\'calendar\'][\'planner_intervals_per_day\']) - { - $GLOBALS[\'phpgw\']->preferences->add(\'calendar\',\'planner_intervals_per_day\',3); - $GLOBALS[\'phpgw\']->preferences->save_repository(); - $this->bo->prefs[\'calendar\'][\'planner_intervals_per_day\'] = 3; - } - $intervals_per_day = $this->bo->prefs[\'calendar\'][\'planner_intervals_per_day\']; - - // set title for table and rows of planner view - // - if ($this->bo->sortby == \'category\') - { - $title = lang(\'Category\'); - } - elseif ($this->bo->sortby == \'user\') - { - $title = lang(\'User\'); - - $o = $this->bo->owner; - $type = $GLOBALS[\'phpgw\']->accounts->get_type($o); - - if ($type == \'g\') // display schedule of all group members - { - $this->planner_group_members = $GLOBALS[\'phpgw\']->acl->get_ids_for_location($o, 1, \'phpgw_group\'); - } - else // display schedule of owner only - { - $this->planner_group_members[0] = $o; - } - } - - // create/initialize variables directly used for HTML code generation - // - $this->planner_html = CreateObject(\'calendar.html\'); - $this->planner_header = array(); - $this->planner_rows = array(); - - // generate header lines with days and associated months - // - $hdr = &$this->planner_header; - $hdr[0][\'0\'] = $title; - $hdr[0][\'.0\'] = \'rowspan="3"\'; - - $this->planner_days = 0; // reset - - $m = $this->bo->month; - $y = $this->bo->year; - for ($i=1; $i<=$this->bo->num_months; $i++,$m++) - { - if ($m == 13) - { - $m = 1; $y++; // "wrap-around" into new year - } - $days = $GLOBALS[\'phpgw\']->datetime->days_in_month($m,$y); - - $d = mktime(0,0,0,$m,1,$y); - $month = lang(date(\'F\', $d)).strftime(\' %Y\', $d); - $color = $m%2==0?"ccffff":"ccffcc"; - $cols = $days * $intervals_per_day; - - $hdr[0][\'.\'.$i] = \'bgcolor="#\'.$color.\'" colspan="\'.$cols.\'" align="center"\'; - $hdr[0][$i] = \' \'.$month.\'\'; - - for ($d=1; $d<=$days; $d++) - { - $dayname = substr(lang(date(\'D\',mktime(0,0,0,$m,$d,$y))),0,2); - $index = $d + $this->planner_days; - - $hdr[2][\'.\'.$index] = \'colspan="\'.$intervals_per_day.\'" align="center"\'; - - // highlight saturdays and sundays using bgcolor - // FIXME: what about holidays? - // - $dow = $GLOBALS[\'phpgw\']->datetime->day_of_week($y,$m,$d); - if ($dow == 0 || $dow == 6) - { - $hdr[2][\'.\'.$index] .= \'" bgcolor=\'; - $hdr[2][\'.\'.$index] .= $dow == 0 ? \'"#ff8866"\' : \'"#ffcccc"\'; - } - - $hdr[2][$index] = \'\'.$dayname.\'
\'.$d.\'
\'; - } - $this->planner_days += $days; - } - - // create/initialize member variables describing the time interval to be displayed - // - $this->planner_end_month = $m - 1; - $this->planner_end_year = $y; - $this->planner_days_in_end_month = $GLOBALS[\'phpgw\']->datetime->days_in_month($this->planner_end_month,$this->planner_end_year); - $this->planner_firstday = intval(date(\'Ymd\',mktime(0,0,0,$this->bo->month,1,$this->bo->year))); - $this->planner_lastday = intval(date(\'Ymd\',mktime(0,0,0,$this->planner_end_month,$this->planner_days_in_end_month,$this->planner_end_year))); - - // generate line with calendar weeks in observed interval - // - $d = mktime(0,0,0,$this->bo->month,1,$this->bo->year); - $w = date(\'W\', $d); - $offset = (7-date("w", $d)+1)%7; - $offset = $offset == 0 ? 7 : $offset; - $color = $w%2==0?"ccccff":"ffffcc"; - - $hdr[1][\'.\'.$w] = \'bgcolor="#\'.$color.\'" colspan="\'.$intervals_per_day * $offset.\'" align="left"\'; - $hdr[1][$w] = \'\'; - if ($offset >= 3) - { - $hdr[1][$w] .= \' \'.lang(\'WN \').$w.\' \'; - } - $days_left = $this->planner_days - $offset; - - $colspan = 7 * $intervals_per_day; - while ($days_left > 0) - { - $colspan = ($days_left < 7) ? $days_left*$intervals_per_day : $colspan; - $d += 604800; // 7 days whith 24 hours (1h == 3600 seconds) each - $w = date(\'W\', $d); - $w += (isset($hdr[1][$w]))?1:0; // bug in "date(\'W\')" ? - - $color = $w%2==0?"ccccff":"ffffcc"; - $hdr[1][\'.\'.$w] = \'bgcolor="#\'.$color.\'" colspan="\'.$colspan.\'" align="left"\'; - $hdr[1][$w] = \'\'; - if ($days_left >= 3) - { - $hdr[1][$w] .= \' \'.lang(\'WN \').$w.\' \'; - } - - $days_left -= 7; - } - return $hdr; - '); + // set some globals + // + if (!$no_header) + { + unset($GLOBALS['phpgw_info']['flags']['noheader']); + unset($GLOBALS['phpgw_info']['flags']['nonavbar']); + $GLOBALS['phpgw']->common->phpgw_header(); } + + // intervals_per_day can be configured in preferences now :-) + // + if (! $this->bo->prefs['calendar']['planner_intervals_per_day']) + { + $GLOBALS['phpgw']->preferences->add('calendar','planner_intervals_per_day',3); + $GLOBALS['phpgw']->preferences->save_repository(); + $this->bo->prefs['calendar']['planner_intervals_per_day'] = 3; + } + $intervals_per_day = $this->bo->prefs['calendar']['planner_intervals_per_day']; + $this->bo->save_sessiondata(); // need to save $this->bo->save_owner + + // set title for table and rows of planner view + // + if ($this->bo->sortby == 'category') + { + $title = lang('Category'); + } + else + { + $title = lang('User'); + + $this->set_planner_group_members(); + } + + // create/initialize variables directly used for HTML code generation + // + $this->planner_html = CreateObject('calendar.html'); + $this->planner_header = array(); + $this->planner_rows = array(); + + // generate header lines with days and associated months + // + $hdr = &$this->planner_header; + $hdr[0]['0'] = $title; + $hdr[0]['.0'] = 'rowspan="3"'; + + $this->planner_days = 0; // reset + + $m = $this->bo->month; + $y = $this->bo->year; + $this->bo->read_holidays($y); + for ($i=1; $i<=$this->bo->num_months; $i++,$m++) + { + if ($m == 13) + { + $m = 1; $y++; // "wrap-around" into new year + $this->bo->read_holidays($y); + } + $days = $GLOBALS['phpgw']->datetime->days_in_month($m,$y); + + $d = mktime(0,0,0,$m,1,$y); + $month = lang(date('F', $d)).strftime(' %Y', $d); + $color = $this->theme[$m % 2 || $this->bo->num_months == 1 ? 'th_bg' : 'row_on']; + $cols = $days * $intervals_per_day; + + $hdr[0]['.'.$i] = 'bgcolor="'.$color.'" colspan="'.$cols.'" align="center"'; + $prev_month = sprintf('%04d%02d01',$y-($m==1),$m > 1?$m-1:12); + $next_month = sprintf('%04d%02d01',$y+($m==12),$m < 12?$m+1:1); + $prev_link = $GLOBALS['phpgw']->link('/index.php',"menuaction=calendar.uicalendar.planner&date=$prev_month"); + $next_link = $GLOBALS['phpgw']->link('/index.php',"menuaction=calendar.uicalendar.planner&date=$next_month"); + $hdr[0][$i] = "<<   $month   >>"; + + $add_owner = array(); // if no add-rights on the showed cal use own cal + if (!$this->bo->save_owner && !$this->bo->check_perms(PHPGW_ACL_ADD) || + !$this->bo->check_perms(PHPGW_ACL_ADD,0,$this->bo->save_owner)) + { + $add_owner = array( + 'owner' => $GLOBALS['phpgw_info']['user']['account_id'] + ); + } + for ($d=1; $d<=$days; $d++) + { + $dayname = substr(lang(date('D',mktime(0,0,0,$m,$d,$y))),0,2); + $index = $d + $this->planner_days; + + $hdr[2]['.'.$index] = 'colspan="'.$intervals_per_day.'" align="center"'; + + // highlight today, saturday, sunday and holidays + // + $color = $this->theme['row_off']; + $dow = $GLOBALS['phpgw']->datetime->day_of_week($y,$m,$d); + $date = sprintf("%04d%02d%02d",$y,$m,$d); + if ($date == date('Ymd')) + { + $color = $GLOBALS['phpgw_info']['theme']['cal_today']; + } + elseif ($this->bo->cached_holidays[$date]) + { + $color = $this->bo->holiday_color; + $hdr[2]['.'.$index] .= ' title="'.$this->bo->cached_holidays[$date][0]['name'].'"'; + } + elseif ($dow == 0 || $dow == 6) + { + $color = $this->bo->theme['th_bg']; + } + + $hdr[2]['.'.$index] .= " bgcolor=\"$color\""; + + $hdr[2][$index] = ''.$dayname.'
'.$d.'
'; + } + $this->planner_days += $days; + } + + // create/initialize member variables describing the time interval to be displayed + // + $this->planner_end_month = $m - 1; + $this->planner_end_year = $y; + $this->planner_days_in_end_month = $GLOBALS['phpgw']->datetime->days_in_month($this->planner_end_month,$this->planner_end_year); + $this->planner_firstday = intval(date('Ymd',mktime(0,0,0,$this->bo->month,1,$this->bo->year))); + $this->planner_lastday = intval(date('Ymd',mktime(0,0,0,$this->planner_end_month,$this->planner_days_in_end_month,$this->planner_end_year))); + + // generate line with calendar weeks in observed interval + // + $d = mktime(0,0,0,$this->bo->month,1,$this->bo->year); + $w = date('W', $d); + if ($w == 'W') // php < 4.1 + { + $w = 1 + intval(date('z',$d) / 7); // a bit simplistic + } + $offset = (7-date("w", $d)+1)%7; + $offset = $offset == 0 ? 7 : $offset; + $color = $this->theme[$w % 2 ? 'th_bg' : 'row_on']; + + $hdr[1]['.'.$w] = 'bgcolor="'.$color.'" colspan="'.$intervals_per_day * $offset.'" align="left"'; + $hdr[1][$w] = ''; + if ($offset >= 3) + { + $hdr[1][$w] .= ' '.lang('week').' '.$w.' '; + } + $days_left = $this->planner_days - $offset; + + $colspan = 7 * $intervals_per_day; + while ($days_left > 0) + { + $colspan = ($days_left < 7) ? $days_left*$intervals_per_day : $colspan; + $d += 604800; // 7 days whith 24 hours (1h == 3600 seconds) each + $w = date('W', $d); + if ($w == 'W') // php < 4.1 + { + $w = 1 + intval(date('z',$d) / 7); // a bit simplistic + } + $w += (isset($hdr[1][$w]))?1:0; // bug in "date('W')" ? + + $color = $this->theme[$w % 2 ? 'th_bg' : 'row_on']; + $hdr[1]['.'.$w] = 'bgcolor="'.$color.'" colspan="'.$colspan.'" align="left"'; + $hdr[1][$w] = ''; + if ($days_left >= 3) + { + $hdr[1][$w] .= ' '.lang('week').' '.$w.' '; + } + + $days_left -= 7; + } + return $hdr; } /** @@ -1459,395 +1566,340 @@ * - list of categories associated with the event * - first and last cell of the row */ - function planner_update_row($params) + function planner_update_row($index,$name,$event,$cat,$start_cell,$end_cell) { - if(floor(phpversion()) == 4) + $rows = &$this->planner_rows; + $intervals_per_day = $this->bo->prefs['calendar']['planner_intervals_per_day']; + $is_private = !$this->bo->check_perms(PHPGW_ACL_READ,$event); + + $view = $this->planner_html->link('/index.php', + array( + 'menuaction' => 'calendar.uicalendar.view', + 'cal_id' => $event['id'] + ) + ); + + // check how many lines are needed for this "row" (currently: user or category) + $i = 0; + do { + ++$i; + + $k = $index.'_'.$i; + $ka = '.nr_'.$k; + + if (!isset($rows[$k])) + { + if ($i > 1) // further line - no name + { + $rows[$k] = array(); + $rows[$index.'_1']['._name'] = 'rowspan="'.$i.'"'; + } + else + { + $rows[$k]['_name'] = $name; + } + $rows[$ka] = 0; + } + $rows[$index.'_1']['._name'] .= ' nowrap'; // title must be one row + + $row = &$rows[$k]; + $akt_cell = &$rows[$ka]; + } while ($akt_cell > $start_cell); + + if ($akt_cell < $start_cell) { - eval(' - $index = $params[\'index\']; - $name = $params[\'name\']; - $event = $params[\'event\']; - $cat = $params[\'category\']; - $start_cell = $params[\'start_cell\']; - $end_cell = $params[\'end_cell\']; - - $rows = &$this->planner_rows; - $intervals_per_day = $this->bo->prefs[\'calendar\'][\'planner_intervals_per_day\']; - $is_private = !$event[\'public\'] && $this->bo->owner != $event[\'owner\'] - || !$this->bo->check_perms(PHPGW_ACL_READ,$event); - - $view = $this->planner_html->link(\'/index.php\', - array( - \'menuaction\' => \'calendar.uicalendar.view\', - \'cal_id\' => $event[\'id\'] - ) - ); - - // check how many lines are needed for this "row" (currently: user or category) - $i = 0; - do { - ++$i; - - $k = $index.\'_\'.$i; - $ka = \'.nr_\'.$k; - - if (!isset($rows[$k])) - { - if ($i > 1) // further line - no name - { - $rows[$k] = array(); - $rows[$index.\'_1\'][\'._name\'] = \'rowspan="\'.$i.\'"\'; - } - else - { - $rows[$k][\'_name\'] = $name; - } - $rows[$ka] = 0; - } - $rows[$index.\'_1\'][\'._name\'] .= \' nowrap\'; // title must be one row - - $row = &$rows[$k]; - $akt_cell = &$rows[$ka]; - } while ($akt_cell > $start_cell); - - if ($akt_cell < $start_cell) - { - $row[$event[\'id\'].\'_1\'] = \' \'; - $row[\'.\'.$event[\'id\'].\'_1\'] = \'colspan="\'.($start_cell-$akt_cell).\'"\'; - } - $opt = &$row[\'.\'.$event[\'id\'].\'_2\']; - $cel = &$row[$event[\'id\'].\'_2\']; - - // if possible, display information about event within cells representing it - // - if ($start_cell < $end_cell) - { - $colspan = $end_cell - $start_cell; - $opt .= "colspan=".(1 + $colspan); - - if (!$is_private) - { - // FIXME: how many chars can be displayed in the event\'s cell? - // - $max_chars = 4*$colspan/$intervals_per_day-5; - $max_chars /= ($colspan<9 ? 2 : 1); - - $min_chars = 3; // minimum for max_chars to display -> this should be configurable - if ($max_chars >= $min_chars) - { - $len_title = strlen($event[\'title\']); - - if ($len_title < $max_chars) - { - $title = $event[\'title\']; - $max_chars -= $len_title - 3; // 3 chars for separator: " - " - $len_descr = strlen($event[\'description\']); - - if ($len_descr > 0 && $len_descr <= $max_chars) - { - $event[\'print_description\'] = \'yes\'; - } - } - else - { - $title = substr($event[\'title\'], 0 , $max_chars).\'...\'; - } - $event[\'print_title\'] = \'yes\'; - } - } - } - - if ($bgcolor=$cat[\'color\']) - { - $opt .= \' bgcolor="\'.$bgcolor.\'"\'; - } - if (!$is_private) - { - $opt .= \' title="\'.lang(\'Title\').": ".$event[\'title\']; - if ($event[\'description\']) - { - $opt .= " \n".lang(\'Description\').": ".$event[\'description\']; - } - } - else - { - $opt .= \' title="\'.lang(\'You do not have permission to read this record!\').\'"\'; - } - - $start = $GLOBALS[\'phpgw\']->common->show_date($this->bo->maketime($event[\'start\']) - $GLOBALS[\'phpgw\']->datetime->tz_offset); - $end = $GLOBALS[\'phpgw\']->common->show_date($this->bo->maketime($event[\'end\']) - $GLOBALS[\'phpgw\']->datetime->tz_offset); - $opt .= "\n".lang(\'Start Date/Time\').": ".$start."\n".lang(\'End Date/Time\').": ".$end; - - if ($event[\'location\']) - { - $opt .= " \n".lang(\'Location\').": ".$event[\'location\']; - } - - if (!$is_private) - { - $opt .= "\" onClick=\"location=\'".$view."\'\""; - $cel = \'\'; // FIXME - } - else - { - $cel = \'\'; - } - - if ($event[\'priority\'] == 3) - { - $cel .= $this->planner_html->image(\'calendar\',\'mini-calendar-bar.gif\',\'\',\'border="0"\'); - } - $cel .= $this->planner_html->image(\'calendar\',count($event[\'participants\'])>1?\'multi_3.gif\':\'single.gif\',$this->planner_participants($event[\'participants\']),\'border="0"\'); - $cel .= \'\'; - - if (isset($event[\'print_title\']) && $event[\'print_title\'] == \'yes\') - { - $cel .= \' \'.$title.\' \'; - } - if (isset($event[\'print_description\']) && $event[\'print_description\'] == \'yes\') - { - $cel .= \' - \'.$event[\'description\'].\' \'; - } - - $akt_cell = $end_cell + 1; - - return $rows; - '); + $row[$event['id'].'_1'] = ' '; + $row['.'.$event['id'].'_1'] = 'colspan="'.($start_cell-$akt_cell).'"'; } + $opt = &$row['.'.$event['id'].'_2']; + $cel = &$row[$event['id'].'_2']; + + // if possible, display information about event within cells representing it + // + if ($start_cell < $end_cell) + { + $colspan = $end_cell - $start_cell; + $opt .= "colspan=".(1 + $colspan); + + if (!$is_private) + { + $max_chars = 6*$colspan/$intervals_per_day-5; + $max_chars /= ($colspan<9 ? 2 : 1); + + $min_chars = 3; // minimum for max_chars to display -> this should be configurable + if ($max_chars >= $min_chars) + { + $len_title = strlen($event['title']); + + if ($len_title < $max_chars) + { + $title = $event['title']; + $max_chars -= $len_title - 3; // 3 chars for separator: " - " + $len_descr = strlen($event['description']); + + if ($len_descr > 0 && $len_descr <= $max_chars) + { + $event['print_description'] = 'yes'; + } + } + else + { + $title = substr($event['title'], 0 , $max_chars).'...'; + } + $event['print_title'] = 'yes'; + } + } + } + + if ($bgcolor=$cat['color']) + { + $opt .= ' bgcolor="'.$bgcolor.'"'; + } + if (!$is_private) + { + $opt .= ' title="'.lang('Title').": ".$event['title']; + if ($event['description']) + { + $opt .= "\n".lang('Description').": ".$event['description']; + } + } + else + { + $opt .= ' title="'.lang('You do not have permission to read this record!'); + } + + $start = $GLOBALS['phpgw']->common->show_date($this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset); + $end = $GLOBALS['phpgw']->common->show_date($this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset); + $opt .= "\n".lang('Start Date/Time').": ".$start."\n".lang('End Date/Time').": ".$end; + + if ($event['location'] && !$is_private) + { + $opt .= " \n".lang('Location').": ".$event['location']; + } + + if (!$is_private) + { + $opt .= "\" onClick=\"location='".$view."'\""; + $cel = ''; + } + else + { + $opt .= '"'; + $cel = ''; + } + + if ($event['priority'] == 3) + { + $cel .= $this->planner_html->image('calendar','mini-calendar-bar.gif','','border="0"'); + } + $cel .= $this->planner_html->image('calendar',count($event['participants'])>1?'multi_3.gif':'single.gif',$this->planner_participants($event['participants']),'border="0"'); + $cel .= ''; + + if (isset($event['print_title']) && $event['print_title'] == 'yes') + { + $cel .= ' '.$title.' '; + } + if (isset($event['print_description']) && $event['print_description'] == 'yes') + { + $cel .= ' - '.$event['description'].' '; + } + + $akt_cell = $end_cell + 1; + + return $rows; } function planner_process_event($event) { - if(floor(phpversion()) == 4) + $intervals_per_day = $this->bo->prefs['calendar']['planner_intervals_per_day']; + $interval = $this->planner_intervals[$intervals_per_day]; + $last_cell = $intervals_per_day * $this->planner_days - 1; + + $rows = &$this->planner_rows; + + // caluculate start and end of event + // + $event_start = intval(date('Ymd',mktime(0,0,0,$event['start']['month'], + $event['start']['mday'], + $event['start']['year']))); + $event_end = intval(date('Ymd',mktime(0,0,0,$event['end']['month'], + $event['end']['mday'], + $event['end']['year']))); + + // calculate first cell of event within observed interval + // + if ($event_start >= $this->planner_firstday) { - eval(' - $intervals_per_day = $this->bo->prefs[\'calendar\'][\'planner_intervals_per_day\']; - $last_cell = $intervals_per_day * $this->planner_days - 1; + $days_between = $GLOBALS['phpgw']->datetime->days_between($this->bo->month,1,$this->bo->year,$event['start']['month'],$event['start']['mday'],$event['start']['year']); - $rows = &$this->planner_rows; + $start_cell = $intervals_per_day * $days_between + $interval[$event['start']['hour']]; + } + else + { + $start_cell = 0; + } - // caluculate start and end of event - // - $event_start = intval(date(\'Ymd\',mktime(0,0,0,$event[\'start\'][\'month\'], - $event[\'start\'][\'mday\'], - $event[\'start\'][\'year\']))); - $event_end = intval(date(\'Ymd\',mktime(0,0,0,$event[\'end\'][\'month\'], - $event[\'end\'][\'mday\'], - $event[\'end\'][\'year\']))); + // calculate last cell of event within observed interval + // + if ($event_end <= $this->planner_lastday) + { + $days_between = $GLOBALS['phpgw']->datetime->days_between($this->bo->month,1,$this->bo->year,$event['end']['month'],$event['end']['mday'],$event['end']['year']); - // calculate first cell of event within observed interval - // - if ($event_start >= $this->planner_firstday) + $end_cell = $intervals_per_day * $days_between + $interval[$event['end']['hour']]; + if ($end_cell == $start_cell && $end_cell < $last_cell) + { + $end_cell++; // min. width 1 interval + } + } + else + { + $end_cell = $last_cell; + } + + // get the categories associated with event + // + if ($c = $event['category']) + { + list($cat) = $this->planner_category($event['category']); + if ($cat['parent']) + { + list($pcat) = $this->planner_category($c = $cat['parent']); + } + else + { + $pcat = $cat; + } + } + else + { + $cat = $pcat = array( 'name' => lang('none')); + } + + // add the event to it`s associated row(s) + // + if ($this->bo->sortby == 'category') + { + // event needs to show up in it`s category`s row + // + $this->planner_update_row($c,$pcat['name'],$event,$cat,$start_cell,$end_cell); + } + elseif ($this->bo->sortby == 'user') + { + // event needs to show up in rows of all participants that are also owners + // + reset($this->planner_group_members); + while(list($user_name,$id) = each($this->planner_group_members)) + { + $status = $event['participants'][$id]; + + if (isset($status) && $status != 'R') { - $days_between = $GLOBALS[\'phpgw\']->datetime->days_between($this->bo->month,1,$this->bo->year,$event[\'start\'][\'month\'],$event[\'start\'][\'mday\'],$event[\'start\'][\'year\']); - - $start_cell = $intervals_per_day * $days_between + $interval[$event[\'start\'][\'hour\']]; + $this->planner_update_row($user_name,$user_name,$event,$cat,$start_cell,$end_cell); } - else - { - $start_cell = 0; - } - - // calculate last cell of event within observed interval - // - if ($event_end <= $this->planner_lastday) - { - $days_between = $GLOBALS[\'phpgw\']->datetime->days_between($event[\'end\'][\'month\'],$event[\'end\'][\'mday\'],$event[\'end\'][\'year\'],$this->planner_end_month,$this->planner_days_in_end_month,$this->planner_end_year); - - $end_cell = $last_cell - $intervals_per_day * ($days_between+1) + $interval[$event[\'end\'][\'hour\']] + 1; - } - else - { - $end_cell = $last_cell; - } - - // get the categories associated with event - // - if ($c = $event[\'category\']) - { - list($cat) = $this->planner_category($event[\'category\']); - if ($cat[\'parent\']) - { - list($pcat) = $this->planner_category($c = $cat[\'parent\']); - } - else - { - $pcat = $cat; - } - } - else - { - $cat = $pcat = array( \'name\' => lang(\'none\')); - } - - // add the event to it`s associated row(s) - // - if ($this->bo->sortby == \'category\') - { - // event needs to show up in it`s category`s row - // - $this->planner_update_row( - Array( - \'index\' => $c, - \'name\' => $pcat[\'name\'], - \'event\' => $event, - \'category\' => $cat, - \'start_cell\' => $start_cell, - \'end_cell\' => $end_cell - ) - ); - } - elseif ($this->bo->sortby == \'user\') - { - // event needs to show up in rows of all participants that are also owners - // - for($j=0; $jplanner_group_members); $j++) - { - $id = $this->planner_group_members[$j]; - $status = $event[\'participants\'][$id]; - - if (isset($status) && $status != \'R\') - { - $user_name = $GLOBALS[\'phpgw\']->common->grab_owner_name($id); - - $this->planner_update_row( - Array( - \'index\' => $id, - \'name\' => $user_name, - \'event\' => $event, - \'category\' => $cat, - \'start_cell\' => $start_cell, - \'end_cell\' => $end_cell - ) - ); - } - } - } - '); + } } } function planner_pad_rows() { - if(floor(phpversion()) == 4) + $rows = &$this->planner_rows; + + if ($this->bo->sortby == 'user') { - eval(' - $rows = &$this->planner_rows; + // add empty rows for users that do not participante in any event + // + reset($this->planner_group_members); + while(list($user_name,$id) = each($this->planner_group_members)) + { + $k = $user_name.'_1'; + $ka = '.nr_'.$k; - if ($this->bo->sortby == \'user\') + if (!isset($rows[$k])) { - // add empty rows for users that do not participante in any event - // - for($j=0; $jplanner_group_members); $j++) - { - $id = $this->planner_group_members[$j]; - $k = $id.\'_1\'; - $ka = \'.nr_\'.$k; - - if (!isset($rows[$k])) - { - $rows[$k][\'_name\'] = $GLOBALS[\'phpgw\']->common->grab_owner_name($id); - $rows[$k][\'._name\'] .= \' nowrap\'; - $rows[$ka] = 0; - } - } + $rows[$k]['_name'] = $user_name; + $rows[$k]['._name'] .= ' nowrap'; + $rows[$ka] = 0; } + } + } - // fill the remaining cols - // - $last_cell = $this->bo->prefs[\'calendar\'][\'planner_intervals_per_day\'] * $this->planner_days - 1; + // fill the remaining cols + // + $last_cell = $this->bo->prefs['calendar']['planner_intervals_per_day'] * $this->planner_days - 1; - ksort($rows); - while (list($k,$r) = each($rows)) + ksort($rows); + while (list($k,$r) = each($rows)) + { + if (is_array($r)) + { + $rows['.'.$k] = 'bgcolor="'.$GLOBALS['phpgw']->nextmatchs->alternate_row_color().'"'; + $row = &$rows[$k]; + $akt_cell = &$rows['.nr_'.$k]; + if ($akt_cell < $last_cell) { - if (is_array($r)) - { - $rows[\'.\'.$k] = \'bgcolor="\'.$GLOBALS[\'phpgw\']->nextmatchs->alternate_row_color().\'"\'; - $row = &$rows[$k]; - $akt_cell = &$rows[\'.nr_\'.$k]; - if ($akt_cell <= $last_cell) - { - $row[\'3\'] = \' \'; - $row[\'.3\'] = \'colspan="\'.(1+$last_cell-$akt_cell).\'"\'; - } - } + $row['3'] = ' '; + $row['.3'] = 'colspan="'.(1+$last_cell-$akt_cell).'"'; } - '); + } } } function planner_print_rows() { - if(floor(phpversion()) == 4) - { - eval(' - $rows = &$this->planner_rows; - $bgcolor = \'bgcolor="\'.$this->theme[\'th_bg\'].\'"\'; - $intervals_per_day = $this->bo->prefs[\'calendar\'][\'planner_intervals_per_day\']; + $bgcolor = 'bgcolor="'.$this->theme['th_bg'].'"'; + $intervals_per_day = $this->bo->prefs['calendar']['planner_intervals_per_day']; - if ($this->debug) - { - _debug_array($rows); - reset($rows); - } - echo $this->planner_html->table( - array( - \'_hdr0\' => $this->planner_header[0], - \'._hdr0\' => $bgcolor - )+ - array( - \'_hdr1\' => $this->planner_header[1], - \'._hdr1\' => $bgcolor - )+ - array( - \'_hdr2\' => $this->planner_header[2], - \'._hdr2\' => $bgcolor - )+$rows, - \'width="100%" cols="\'.(1+$this->planner_days_in_end_month*$intervals_per_day).\'"\' - ); - '); + if ($this->debug) + { + _debug_array($this->planner_rows); + reset($this->planner_rows); } + return $this->planner_html->table( + array( + '_hdr0' => $this->planner_header[0], + '._hdr0' => $bgcolor, + '_hdr1' => $this->planner_header[1], + '._hdr1' => $bgcolor, + '_hdr2' => $this->planner_header[2], + '._hdr2' => $bgcolor + )+$this->planner_rows, + 'width="100%" cols="'.(1+$this->planner_days_in_end_month*$intervals_per_day).'"'); } function planner_process_interval() { - if(floor(phpversion()) == 4) + // generate duplicate free list of events within observed interval + // + $this->bo->store_to_cache( + Array( + 'syear' => $this->bo->year, + 'smonth' => $this->bo->month, + 'sday' => 1, + 'eyear' => $this->planner_end_year, + 'emonth' => $this->planner_end_month, + 'eday' => $this->planner_days_in_end_month + ) + ); + $this->bo->remove_doubles_in_cache($this->planner_firstday,$this->planner_lastday); + + // process all events within observed interval + // + for($v=$this->planner_firstday;$v<=$this->planner_lastday;$v++) { - eval(' - // generate duplicate free list of events within observed interval - // - $this->bo->store_to_cache( - Array( - \'syear\' => $this->bo->year, - \'smonth\' => $this->bo->month, - \'sday\' => 1, - \'eyear\' => $this->planner_end_year, - \'emonth\' => $this->planner_end_month, - \'eday\' => $this->planner_days_in_end_month - ) - ); - $this->bo->remove_doubles_in_cache($this->planner_firstday,$this->planner_lastday); + $daily = $this->bo->cached_events[$v]; + @reset($daily); - // process all events within observed interval - // - for($v=$this->planner_firstday;$v<=$this->planner_lastday;$v++) - { - $daily = $this->bo->cached_events[$v]; - @reset($daily); + print_debug('For Date',$v); + print_debug('Count of items',count($daily)); - print_debug(\'For Date\',$v); - print_debug(\'Count of items\',count($daily)); - - // process all events on day $v - // - while (list($nul,$event) = @each($daily)) - { - $this->planner_process_event($event); - } - } - $this->planner_pad_rows(); - '); - } + // process all events on day $v + // + while (list($nul,$event) = @each($daily)) + { + $this->planner_process_event($event); + } + } + $this->planner_pad_rows(); } function matrixselect() @@ -1941,7 +1993,7 @@ @reset($users); while ($user = each($users)) { - if(($GLOBALS['phpgw']->accounts->exists($user[0]) && $this->bo->check_perms(PHPGW_ACL_READ,$user[0])) || $GLOBALS['phpgw']->accounts->get_type($user[0]) == 'g') + if(($GLOBALS['phpgw']->accounts->exists($user[0]) && $this->bo->check_perms(PHPGW_ACL_READ,0,$user[0])) || $GLOBALS['phpgw']->accounts->get_type($user[0]) == 'g') { $str .= ' '."\n"; } @@ -1983,14 +2035,14 @@ $members = $acct->member(intval($participants[$i])); while($members != False && list($index,$member) = each($members)) { - if($this->bo->check_perms(PHPGW_ACL_READ,$member['account_id']) && !isset($parts[$member['account_id']])) + if($this->bo->check_perms(PHPGW_ACL_READ,0,$member['account_id']) && !isset($parts[$member['account_id']])) { $parts[$member['account_id']] = 1; } } break; case 'u': - if($this->bo->check_perms(PHPGW_ACL_READ,$participants[$i]) && !isset($parts[$participants[$i]])) + if($this->bo->check_perms(PHPGW_ACL_READ,0,$participants[$i]) && !isset($parts[$participants[$i]])) { $parts[$participants[$i]] = 1; } @@ -2055,11 +2107,14 @@ function search() { $keywords = get_var('keywords',Array('POST')); - if (!$keywords) + if (empty($keywords)) { // If we reach this, it is because they didn't search for anything, // attempt to send them back to where they where. - Header('Location: ' . $GLOBALS['phpgw']->link($from)); + Header('Location: ' . $GLOBALS['phpgw']->link('/index.php',array( + 'menuaction' => $GLOBALS['HTTP_POST_VARS']['from'], + 'date' => $GLOBALS['HTTP_POST_VARS']['year'].$GLOBALS['HTTP_POST_VARS']['month'].$GLOBALS['HTTP_POST_VARS']['day'] + ))); $GLOBALS['phpgw_info']['flags']['nodisplay'] = True; exit; } @@ -2070,13 +2125,6 @@ $error = ''; - if (strlen($keywords) == 0) - { - echo ''.lang('Error').':'; - echo lang('You must enter one or more search keywords.'); - return; - } - $matches = 0; // There is currently a problem searching in with repeated events. @@ -2177,23 +2225,6 @@ return _debug_array($data,False); } - /* Called only by get_list(), just prior to page footer. */ - function save_sessiondata() - { - $data = array( - 'filter' => $this->bo->filter, - 'cat_id' => $this->bo->cat_id, - 'owner' => $this->bo->owner, - 'year' => $this->bo->year, - 'month' => $this->bo->month, - 'day' => $this->bo->day, - 'date' => $this->bo->date, - 'sortby' => $this->bo->sortby, - 'num_months' => $this->bo->num_months - ); - $this->bo->save_sessiondata($data); - } - function output_template_array(&$p,$row,$list,$var) { if (!isset($var['hidden_vars'])) @@ -2290,13 +2321,10 @@ $str .= ''."\n"; } - $hidden_vars = ' '."\n"; - $var = Array( 'action_url' => $this->page($method,''), 'form_name' => 'SelectMonth', 'label' => lang('Month'), - 'hidden_vars' => $hidden_vars, 'form_label' => 'date', 'form_onchange' => 'document.SelectMonth.submit()', 'row' => $str, @@ -2324,7 +2352,6 @@ 'action_url' => $this->page($method,''), 'form_name' => 'SelectWeek', 'label' => lang('Week'), - 'hidden_vars' => $hidden_vars, 'form_label' => 'date', 'form_onchange' => 'document.SelectWeek.submit()', 'row' => $str, @@ -2339,12 +2366,11 @@ { $str .= ''."\n"; } - + $var = Array( 'action_url' => $this->page($method,''), 'form_name' => 'SelectYear', 'label' => lang('Year'), - 'hidden_vars' => $hidden_vars, 'form_label' => 'year', 'form_onchange' => 'document.SelectYear.submit()', 'row' => $str, @@ -2371,13 +2397,11 @@ $str .= ''."\n"; } - $hidden_vars .= $date_str; - $var = Array( 'action_url' => $this->page($method,''), 'form_name' => 'SelectNumberOfMonths', 'label' => lang('Number of Months'), - 'hidden_vars' => $hidden_vars, + 'hidden_vars' => $date_str, 'form_label' => 'num_months', 'form_onchange' => 'document.SelectNumberOfMonths.submit()', 'action_extra_field' => $date_str, @@ -2417,10 +2441,10 @@ . ' A.bminicalendar { color: #336699; font: italic bold xx-small '.$this->theme['font'].' }'."\n" . ' A.minicalendargrey { color: #999999; font: xx-small '.$this->theme['font'].' }'."\n" . ' A.bminicalendargrey { color: #336699; font: italic bold xx-small '.$this->theme['font'].' }'."\n" - . ' A.minicalhol { background: '.$this->holiday_color.'; color: #000000; font: xx-small '.$this->theme['font'].' }'."\n" - . ' A.bminicalhol { background: '.$this->holiday_color.'; color: #336699; font: italic bold xx-small '.$this->theme['font'].' }'."\n" - . ' A.minicalgreyhol { background: '.$this->holiday_color.'; color: #999999; font: xx-small '.$this->theme['font'].' }'."\n" - . ' A.bminicalgreyhol { background: '.$this->holiday_color.'; color: #999999; font: italic bold xx-small '.$this->theme['font'].' }'."\n" + . ' A.minicalhol { padding-left:3px; padding-right:3px; background: '.$this->holiday_color.'; color: #000000; font: xx-small '.$this->theme['font'].' }'."\n" + . ' A.bminicalhol { padding-left:3px; padding-right:3px; background: '.$this->holiday_color.'; color: #336699; font: italic bold xx-small '.$this->theme['font'].' }'."\n" + . ' A.minicalgreyhol { padding-left:3px; padding-right:3px; background: '.$this->holiday_color.'; color: #999999; font: xx-small '.$this->theme['font'].' }'."\n" + . ' A.bminicalgreyhol { padding-left:3px; padding-right:3px; background: '.$this->holiday_color.'; color: #999999; font: italic bold xx-small '.$this->theme['font'].' }'."\n" . ' .event-on { background: '.$this->theme['row_on'].'; color: '.$this->theme['bg_text'].'; font: 100 80%/110% '.$this->theme['font'].'; vertical-align: middle }'."\n" . ' .event-off { background: '.$this->theme['row_off'].'; color: '.$this->theme['bg_text'].'; font: 100 80%/110% '.$this->theme['font'].'; vertical-align: middle }'."\n" . ' .event-holiday { background: '.$this->theme['bg04'].'; color: '.$this->theme['bg_text'].'; font: 100 80%/110% '.$this->theme['font'].'; vertical-align: middle }'."\n" @@ -2688,6 +2712,8 @@ $names = ''; while (list($id,$status) = each($parts)) { + $status = substr($this->bo->get_long_status($status),0,1); + if (!isset($id2lid[$id])) { $id2lid[$id] = $GLOBALS['phpgw']->common->grab_owner_name($id); @@ -2851,7 +2877,7 @@ { if ($day_params['new_event']) { - $new_event_link = '' + $new_event_link = ' ' . ''.lang('New Entry').'' . ''; $day_number = ''.$day.''; @@ -2867,6 +2893,11 @@ 'new_event_link'=> $new_event_link, 'day_number' => $day_number ); + if($day_params['week']) + { + $var['new_event_link'] .= '   '. + (!$this->bo->printer_friendly?'' .$day_params['week'].'':$day_params['week']); + } $p->set_var($var); @@ -2903,7 +2934,7 @@ $p->parse('column_data','month_daily',True); $p->set_var('daily_events',''); $p->set_var('events',''); - if($day_params['week']) +/* if($day_params['week']) { $var = Array( 'week_day_font_size' => '-2', @@ -2911,7 +2942,7 @@ ); $this->output_template_array($p,'column_data','day_event',$var); $p->set_var('events',''); - } + } */ } $p->parse('column_header','month_column',True); $p->set_var('column_data',''); @@ -3187,7 +3218,7 @@ { if($GLOBALS['phpgw']->accounts->exists($user)) { - $str .= ($str?'
':'').$GLOBALS['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"; + $str .= ($str?'
':'').$GLOBALS['phpgw']->common->grab_owner_name($user).' ('.($this->bo->check_perms(PHPGW_ACL_EDIT,0,$user)?''.$this->bo->get_long_status($short_status).'':$this->bo->get_long_status($short_status)).')'."\n"; } } $var[] = Array( @@ -3380,6 +3411,8 @@ print_debug('Date to Eval',$date_to_eval); if($daily[$date_to_eval]['appts']) { + $day_start = mktime(intval($this->bo->prefs['calendar']['workdaystarts']-1),0,0,$params['month'],$params['day'],$params['year']); + $day_end = mktime(intval($this->bo->prefs['calendar']['workdayends']),0,1,$params['month'],$params['day'],$params['year']); $starttime = 0; $endtime = 0; $events = $this->bo->cached_events[$date_to_eval]; @@ -3388,24 +3421,22 @@ print_debug('Count',$c_events); for($i=0;$i<$c_events;$i++) { + $starttime = $this->bo->maketime($events[$i]['start']); + $endtime = $this->bo->maketime($events[$i]['end']); + if($events[$i]['recur_type'] == MCAL_RECUR_NONE) { $ind = 0; - $interval_start = 0; - if($events[$i]['start']['mday'] < $params['day']) + $interval_start = 0; + if ($starttime < $day_start) { - if($events[$i]['end']['mday'] > $params['day']) - { - $ind = 99; - $interval_start = 0; - } - elseif($events[$i]['end']['mday'] == $params['day']) - { - $ind = 0; - $interval_start = 0; - } + $ind = 0; } - elseif($events[$i]['start']['mday'] == $params['day']) + elseif ($starttime >= $day_end) + { + $ind = 99; + } + else { $ind = intval($events[$i]['start']['hour']); $interval_start = intval($events[$i]['start']['min'] / intval($this->bo->prefs['calendar']['interval'])); @@ -3421,57 +3452,63 @@ if(($ind < intval($this->bo->prefs['calendar']['workdaystarts'])) || ($ind > intval($this->bo->prefs['calendar']['workdayends']))) { - $ind = 99; + $ind = $ind < intval($this->bo->prefs['calendar']['workdaystarts']) ? 0 : 99; $interval_start = 0; } + if((($ind <> 99) && ($ind <> 0)) && (($starttime <> 0) && ($endtime <> 0))) { print_debug('IND before',$ind); - if(($ind >= date('H',$last_starttime)) && ($ind <= date('H',$last_endtime))) + if($ind <= date('H',$last_endtime-1)) // -1 to allow events to end on a full hour, without blocking the next hour-slot { $ind = $last_ind; $interval_start = $last_interval_start; } print_debug('IND after',$ind); } - $time[$ind][$interval_start] .= $this->link_to_entry($events[$i],$params['month'],$params['day'],$params['year']); print_debug('IND',$ind); print_debug('TIME',$time[$ind][$interval_start]); - $starttime = $this->bo->maketime($events[$i]['start']); - $endtime = $this->bo->maketime($events[$i]['end']); - + if ($starttime < $day_start) + { + $starttime = $day_start; + } + if ($endtime > $day_end) + { + $endtime = $day_end; + } if ($starttime <> $endtime) { $rowspan = $rowspan_arr[$ind][$interval_start]; - if($rowspan == 0) + if($rowspan == 0 || $last_endtime <= $starttime) { - $rowspan = intval(($endtime - $starttime) / (60 * intval($this->bo->prefs['calendar']['interval']))); + $rowspan = intval(round(($endtime - $starttime) / (60 * intval($this->bo->prefs['calendar']['interval'])))); } - elseif($last_endtime < $endtime) + elseif($last_endtime < $endtime && $last_starttime) { - $rowspan = intval(($endtime - $last_starttime) / (60 * intval($this->bo->prefs['calendar']['interval']))); + $rowspan = intval(round(($endtime - $last_starttime) / (60 * intval($this->bo->prefs['calendar']['interval'])))); } - $mins = (int)((($endtime - $starttime) / 60) % 60); if(($mins <> 0 && $mins <= intval(60 / intval($this->bo->prefs['calendar']['interval']))) || ($mins == 0 && date('i',$endtime) > intval($this->bo->prefs['calendar']['interval']))) { $rowspan += 1; } - print_debug('Rowspan being set to',$rowspan); - if ($rowspan > $rowspan_arr[$ind][$interval_start] && $rowspan > 1) + if ($rowspan > $rowspan_arr[$ind][$interval_start]) { $rowspan_arr[$ind][$interval_start] = $rowspan; } } $last_ind = $ind; $last_interval_start = $interval_start; - $last_starttime = $starttime; + if ($rowspan <= 1 || !$last_starttime) + { + $last_starttime = $starttime; + } $last_endtime = $endtime; print_debug('Time',$GLOBALS['phpgw']->common->show_date($this->bo->maketime($events[$i]['start']) - $GLOBALS['phpgw']->datetime->tz_offset).' - '.$GLOBALS['phpgw']->common->show_date($this->bo->maketime($events[$i]['end']) - $GLOBALS['phpgw']->datetime->tz_offset)); print_debug('Start',$ind); @@ -3499,14 +3536,19 @@ $row_to_print = '_holiday'; while(list($index,$name) = each($holiday_names)) { - $time[99][0] = '

'.$name.'
'.$time[99][0]; + $time[0][0] = '
'.$name.'
'.$time[0][0]; } } - if (isset($time[99][0])) + $rowspan = intval($rowspan_arr[0][0]); + // events before workdaystart + if (isset($time[0][0])) { - $var['event'] = $time[99][0]; - + $var = array('event' => $time[0][0]); + if ($rowspan > 1) + { + $var['extras'] = ' rowspan="'.$rowspan.'"'; + } $this->output_template_array($p,'item','day_event'.$row_to_print,$var); $var = Array( @@ -3518,7 +3560,7 @@ $p->parse('row','day_row',True); $p->set_var('item',''); } - $rowspan = 0; + // events between workdaystart and -end for ($i=(int)$this->bo->prefs['calendar']['workdaystarts'];$i<=(int)$this->bo->prefs['calendar']['workdayends'];$i++) { for($j=0;$j<(60 / intval($this->bo->prefs['calendar']['interval']));$j++) @@ -3605,6 +3647,29 @@ $p->set_var('item',''); } } // end for + // events after workdayend + if (isset($time[99][0])) + { + $var = array('event' => $time[99][0]); + if($GLOBALS['phpgw']->nextmatchs->alternate_row_color() == $this->theme['row_on']) + { + $row_to_print = '_on'; + } + else + { + $row_to_print = '_off'; + } + $this->output_template_array($p,'item','day_event'.$row_to_print,$var); + + $var = Array( + 'open_link' => '', + 'time' => ' ', + 'close_link' => '' + ); + $this->output_template_array($p,'item','day_time',$var); + $p->parse('row','day_row',True); + $p->set_var('item',''); + } return $p->fp('out','day'); } // end function @@ -3760,19 +3825,29 @@ $str = ''; while(list($param,$text) = each($response_choices)) { - if(!($param == REJECTED && $ev['owner'] == $this->bo->owner)) - { - $var = Array( - 'action_url_button' => $this->page('set_action','&cal_id='.$cal_id.'&action='.$param), - 'action_text_button' => ' '.$text.' ', - 'action_confirm_button' => '', - 'action_extra_field' => '' - ); - $p->set_var($var); - $str .= ''.$p->fp('out','form_button').''."\n"; - } + $var = Array( + 'action_url_button' => $this->page('set_action','&cal_id='.$cal_id.'&action='.$param), + 'action_text_button' => ' '.$text.' ', + 'action_confirm_button' => '', + 'action_extra_field' => '' + ); + $p->set_var($var); + $str .= ''.$p->fp('out','form_button').''."\n"; } - return ''."\n".$str.'
'."\n"; + if ($this->bo->return_to) + { + $var = Array( + 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to), + 'action_text_button' => lang('cancel'), + 'action_confirm_button' => '', + 'action_extra_field' => '' + ); + $p->set_var($var); + $str .= ''.$p->fp('out','form_button').''."\n"; + } + $str = ''.$GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner).":\n".$str; + + return ''."\n".$str.'
'."\n"; } function edit_form($param) @@ -3814,7 +3889,7 @@ 'calendar_action' => ($event['id']?lang('Calendar - Edit'):lang('Calendar - Add')), 'action_url' => $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.bocalendar.update')), 'common_hidden' => ''."\n" - . ''."\n" + . ''."\n" . ''."\n" . ($GLOBALS['HTTP_GET_VARS']['cal_id'] && $event['id'] == 0?''."\n": (@isset($event['reference'])?''."\n":'')) @@ -3856,7 +3931,7 @@ } $var[] = Array( 'field' => lang('Category'), - 'data' => '' + 'data' => '' ); // Location @@ -3926,16 +4001,16 @@ { $accounts = $GLOBALS['phpgw']->acl->get_ids_for_location('run',1,'calendar'); $users = Array(); - $this->build_part_list($users,$accounts,$this->bo->owner); + $this->build_part_list($users,$accounts,$event['owner']); $str = ''; @asort($users); @reset($users); while (list($id,$user_array) = each($users)) { - if($id != intval($this->bo->owner)) + if($id != intval($event['owner'])) { - $str .= ' '."\n"; + $str .= ' '."\n"; } } $var[] = Array( @@ -3944,7 +4019,7 @@ ); // I Participate - if((($event['id'] > 0) && isset($event['participants'][$this->bo->owner])) || !$event['id']) + if((($event['id'] > 0) && isset($event['participants'][$event['owner']])) || !$event['id']) { $checked = ' checked'; } @@ -3953,8 +4028,8 @@ $checked = ''; } $var[] = Array( - 'field' => $GLOBALS['phpgw']->common->grab_owner_name($this->bo->owner).' '.lang('Participates'), - 'data' => '' + 'field' => $GLOBALS['phpgw']->common->grab_owner_name($event['owner']).' '.lang('Participates'), + 'data' => '' ); } @@ -4037,7 +4112,7 @@ { $this->output_template_array($p,'row','list',$var[$i]); } - + $p->set_var('submit_button',lang('Submit')); if ($event['id'] > 0) @@ -4049,12 +4124,21 @@ 'action_extra_field' => '' ); $p->set_var($var); - $p->parse('delete_button','form_button'); + $extra_buttons = $p->fp('out','form_button'); } - else + if ($this->bo->return_to) { - $p->set_var('delete_button',''); + $var = Array( + 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction='.$this->bo->return_to), + 'action_text_button' => lang('Cancel'), + 'action_confirm_button' => '', + 'action_extra_field' => '' + ); + $p->set_var($var); + $extra_buttons .= ($event['id']>0?'
':'') . $p->fp('out','form_button'); } + $p->set_var('extra_buttons',$extra_buttons); + $p->pparse('out','edit_entry'); } @@ -4158,7 +4242,7 @@ } } $week = ''; - if (!$j || ($j && substr($date,6,2) == '01')) + if (!$j || (!$weekly && $j && substr($date,6,2) == '01')) { $week = lang('week').' '.(int)((date('z',($startdate+(24*3600*4)))+7)/7); } diff --git a/calendar/inc/class.uipreferences.inc.php b/calendar/inc/class.uipreferences.inc.php index 6e56fefec8..b5d9fcdebb 100755 --- a/calendar/inc/class.uipreferences.inc.php +++ b/calendar/inc/class.uipreferences.inc.php @@ -114,10 +114,10 @@ $user = $GLOBALS['phpgw_info']['user']['account_id']; $groups = $GLOBALS['phpgw']->accounts->membership($user); - $str = ''."\n"; + $str = ''."\n"; while (list($key,$group) = each($groups)) { - $str .= ''."\n"; + $str .= ''."\n"; } $this->display_item(lang('Preselected group for entering the planner'),''."\n"); diff --git a/calendar/inc/hook_home.inc.php b/calendar/inc/hook_home.inc.php index 73e77544e5..b2442b2ace 100755 --- a/calendar/inc/hook_home.inc.php +++ b/calendar/inc/hook_home.inc.php @@ -38,8 +38,8 @@ $GLOBALS['owner'] = $GLOBALS['phpgw_info']['user']['account_id']; $page_ = explode('.',$GLOBALS['phpgw_info']['user']['preferences']['calendar']['defaultcalendar']); - $_page = $page_[0]; - if ($_page=='index' || ($_page != 'day' && $_page != 'week' && $_page != 'month' && $_page != 'year')) + $_page = substr($page_[0],0,7); // makes planner from planner_{user|category} + if ($_page=='index' || ($_page != 'day' && $_page != 'week' && $_page != 'month' && $_page != 'year' && $_page != 'planner')) { $_page = 'month'; // $GLOBALS['phpgw']->preferences->add('calendar','defaultcalendar','month'); diff --git a/calendar/inc/hook_home_planner.inc.php b/calendar/inc/hook_home_planner.inc.php new file mode 100644 index 0000000000..bd229fc3d8 --- /dev/null +++ b/calendar/inc/hook_home_planner.inc.php @@ -0,0 +1,27 @@ + * + * http://www.radix.net/~cknudsen * + * Written by Mark Peters * + * -------------------------------------------- * + * 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$ */ + + $d1 = strtolower(substr(PHPGW_APP_INC,0,3)); + if($d1 == 'htt' || $d1 == 'ftp' ) + { + echo 'Failed attempt to break in via an old Security Hole!
'."\n"; + $GLOBALS['phpgw']->common->phpgw_exit(); + } + unset($d1); + + $GLOBALS['extra_data'] = '
'. + ExecMethod('calendar.uicalendar.planner').'
'; +?> diff --git a/calendar/templates/default/edit.tpl b/calendar/templates/default/edit.tpl index 5f46ed441b..b3c23210ed 100755 --- a/calendar/templates/default/edit.tpl +++ b/calendar/templates/default/edit.tpl @@ -18,9 +18,8 @@ -
-
-{delete_button} +
+{extra_buttons}