diff --git a/calendar/inc/class.bocalendar.inc.php b/calendar/inc/class.bocalendar.inc.php index 9817780d00..d44a6021ce 100755 --- a/calendar/inc/class.bocalendar.inc.php +++ b/calendar/inc/class.bocalendar.inc.php @@ -191,7 +191,12 @@ $this->printer_friendly = (intval(get_var('friendly',Array('HTTP_GET_VARS','HTTP_POST_VARS','DEFAULT'),0)) == 1?True:False); $this->filter = get_var('filter',Array('HTTP_POST_VARS','DEFAULT'),' '.$this->prefs['calendar']['defaultfilter'].' '); - $this->sortby = get_var('sortby',Array('HTTP_POST_VARS')); + if($GLOBALS['phpgw']->accounts->get_type($this->owner)=='g') + { + $this->filter = ' all '; + } + + $this->sortby = get_var('sortby',Array('HTTP_POST_VARS','DEFAULT'),'category'); $this->cat_id = get_var('cat_id',Array('HTTP_POST_VARS')); $this->so = CreateObject('calendar.socalendar', @@ -388,7 +393,7 @@ function read_entry($id) { - if($this->check_perms(PHPGW_ACL_READ)) + if($this->check_perms(PHPGW_ACL_READ,$id)) { $event = $this->so->read_entry($id); if(!isset($event['participants'][$this->owner]) && $this->user_is_a_member($event,$this->owner)) @@ -403,8 +408,7 @@ function delete_single($param) { - - if($this->check_perms(PHPGW_ACL_DELETE)) + if($this->check_perms(PHPGW_ACL_DELETE,intval($param['id']))) { $temp_event = $this->get_cached_event(); $event = $this->read_entry(intval($param['id'])); @@ -430,7 +434,7 @@ function delete_entry($id) { - if($this->check_perms(PHPGW_ACL_DELETE)) + if($this->check_perms(PHPGW_ACL_DELETE,$id)) { $temp_event = $this->read_entry($id); // if($this->owner == $temp_event['owner']) @@ -448,7 +452,7 @@ function reinstate($params='') { - if($this->check_perms(PHPGW_ACL_EDIT) && isset($params['cal_id']) && isset($params['reinstate_index'])) + if($this->check_perms(PHPGW_ACL_EDIT,$params['cal_id']) && isset($params['reinstate_index'])) { $event = $this->so->read_entry($params['cal_id']); @reset($params['reinstate_index']); @@ -538,13 +542,10 @@ $send_to_ui = False; } - if($this->debug) - { - echo ''."\n"; - } + print_debug('ID',$l_cal['id']); - if(isset($GLOBALS['HTTP_GET_VARS']['readsess'])) - { + if(get_var('readsess',Array('GET'))) + { $event = $this->restore_from_appsession(); $event['title'] = stripslashes($event['title']); $event['description'] = stripslashes($event['description']); @@ -557,22 +558,19 @@ 'readsess' => 1 ) ); - $GLOBALS['phpgw']->common->phpgw_exit(True); + $GLOBALS['phpgw']->common->phpgw_exit(True); } $overlapping_events = False; - } - else + } + else { - if((!$l_cal['id'] && !$this->check_perms(PHPGW_ACL_ADD)) || ($l_cal['id'] && !$this->check_perms(PHPGW_ACL_EDIT))) - { - ExecMethod('calendar.uicalendar.index'); - $GLOBALS['phpgw']->common->phpgw_exit(); - } - - if($this->debug) + if((!$l_cal['id'] && !$this->check_perms(PHPGW_ACL_ADD)) || ($l_cal['id'] && !$this->check_perms(PHPGW_ACL_EDIT,$l_cal['id']))) { - echo ''."\n"; + ExecMethod('calendar.uicalendar.index'); + $GLOBALS['phpgw']->common->phpgw_exit(); } + + print_debug('prior to fix_update_time()'); $this->fix_update_time($l_start); $this->fix_update_time($l_end); @@ -653,12 +651,10 @@ $acct_type = $GLOBALS['phpgw']->accounts->get_type(intval($parts[$i])); if($acct_type == 'u') { -// $part[$parts[$i]] = 1; $part[intval($parts[$i])] = $accept_type; } elseif($acct_type == 'g') { -// $part[$parts[$i]] = 1; $part[intval($parts[$i])] = $accept_type; $groups[] = $parts[$i]; /* This pulls ALL users of a group and makes them as participants to the event */ @@ -672,8 +668,7 @@ } while($member = each($members)) { -// $part[$member[1]['account_id']] = 1; -+ $part[$member[1]['account_id']] = $accept_type; + $part[$member[1]['account_id']] = $accept_type; } } } @@ -850,23 +845,7 @@ function can_user_edit($event) { - $can_edit = False; - - if(($event['owner'] == $this->owner) && ($this->check_perms(PHPGW_ACL_EDIT) == True)) - { - if($event['public'] == False || $event['public'] == 0) - { - if($this->check_perms(PHPGW_ACL_PRIVATE) == True) - { - $can_edit = True; - } - } - else - { - $can_edit = True; - } - } - return $can_edit; + return $this->check_perms(PHPGW_ACL_EDIT,$event); } function fix_update_time(&$time_param) @@ -1129,22 +1108,49 @@ // } } - function check_perms($needed,$user=0) +// function check_perms($needed,$user=0) +// { +// if($user == 0) +// { +// $allowed = !!($this->grants[$this->owner] & $needed); +// if($this->debug) +// { +// echo ''."\n"; +// } +// return $allowed; +// } +// else +// { +// return !!($this->grants[intval($user)] & $needed); +// } +// } + + function check_perms($needed,$event=0) { - if($user == 0) + if (is_int($event) && $event == 0) { - $allowed = !!($this->grants[$this->owner] & $needed); - if($this->debug) - { - echo ''."\n"; - } - - return $allowed; + $owner = $this->owner; } else { - return !!($this->grants[intval($user)] & $needed); + if (!is_array($event)) + { + $event = $this->so->read_entry((int) $event); + } + if (!is_array($event)) + { + return False; + } + $owner = $event['owner']; + $private = $event['public'] == False || $event['public'] == 0; } + $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"; + + return $access; } function get_fullname($accountid) @@ -1235,7 +1241,8 @@ { return 'private'; } - elseif(strlen($event[$field]) > 19 && !$this->printer_friendly) +// elseif(strlen($event[$field]) > 19 && !$this->printer_friendly) + elseif(strlen($event[$field]) > 19 && $this->printer_friendly) { return substr($event[$field], 0 , 19) . '...'; } @@ -2031,11 +2038,8 @@ ) ) { - if($this->debug) - { - echo ''."\n"; - echo ''."\n"; - } + print_debug('Msg Type',$msg_type); + print_debug('UserID',$userid); if(!is_object($send)) { $send = CreateObject('phpgwapi.send'); @@ -2049,11 +2053,8 @@ } $part_prefs = $preferences->create_email_preferences(intval($userid)); $to = $part_prefs['email']['address']; - - if($this->debug) - { - echo ''."\n"; - } + + print_debug('Email being sent to',$to); $GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset'] = $part_prefs['common']['tz_offset']; $GLOBALS['phpgw_info']['user']['preferences']['common']['timeformat'] = $part_prefs['common']['timeformat']; @@ -2128,26 +2129,17 @@ $t_time = $this->maketime($t_appt) - $GLOBALS['phpgw']->datetime->tz_offset; $y_time = $t_time - 86400; $tt_time = $t_time + 86399; - if($this->debug) - { - echo ''."\n"; - echo ''."\n"; - echo ''."\n"; - } + print_debug('T_TIME',$t_time.' : '.$GLOBALS['phpgw']->common->show_date($t_time)); + print_debug('Y_TIME',$y_time.' : '.$GLOBALS['phpgw']->common->show_date($y_time)); + print_debug('TT_TIME',$tt_time.' : '.$GLOBALS['phpgw']->common->show_date($tt_time)); while(list($key,$alarm) = each($event['alarm'])) { if($alarm['enabled']) { - if($this->debug) - { - echo ''."\n"; - } + print_debug('TIME',$alarm['time'].' : '.$GLOBALS['phpgw']->common->show_date($alarm['time']).' ('.$event['id'].')'); if($event['recur_type'] != MCAL_RECUR_NONE) /* Recurring Event */ { - if($this->debug) - { - echo ''."\n"; - } + print_debug('Recurring Event'); if($alarm['time'] > $y_time && $GLOBALS['phpgw']->common->show_date($alarm['time'],'Hi') < $starttime_hi && $alarm['time'] < $t_time) { $found = True; @@ -2159,10 +2151,7 @@ } } } - if($this->debug) - { - echo ''."\n"; - } + print_debug('Found',$found); return $found; } @@ -2173,18 +2162,12 @@ { if(isset($new_event['participants'][$old_userid])) { - if($this->debug) - { - echo ''."\n"; - } + print_debug('Modifying event for user',$old_userid); $this->modified[intval($old_userid)] = $new_status; } else { - if($this->debug) - { - echo ''."\n"; - } + print_debug('Deleting user from the event',$old_userid); $this->deleted[intval($old_userid)] = $old_status; } } @@ -2193,17 +2176,14 @@ { if(!isset($old_event['participants'][$new_userid])) { - if($this->debug) - { - echo ''."\n"; - } + print_debug('Adding event for user',$new_userid); $this->added[$new_userid] = 'U'; $new_event['participants'][$new_userid] = 'U'; } } - - if(count($this->added) > 0 || count($this->modified) > 0 || count($this->deleted) > 0) - { + + if(count($this->added) > 0 || count($this->modified) > 0 || count($this->deleted) > 0) + { if(count($this->added) > 0) { $this->send_update(MSG_ADDED,$this->added,'',$new_event); @@ -2222,6 +2202,7 @@ function remove_doubles_in_cache($firstday,$lastday) { $already_moved = Array(); + $has_category = Array(); // remove only multiple occurences of a category per event/day for($v=$firstday;$v<=$lastday;$v++) { if (!$this->cached_events[$v]) @@ -2231,10 +2212,13 @@ while (list($g,$event) = each($this->cached_events[$v])) { $start = sprintf('%04d%02d%02d',$event['start']['year'],$event['start']['month'],$event['start']['mday']); - if($this->debug) + print_debug('EVENT',print_r($event,False)); + print_debug('start',$start); + print_debug('v',$v); + + if($start < $firstday) { - echo "

Event:
"; print_r($event); echo "

"; - echo ' remove it @@ -2243,11 +2227,16 @@ unset($this->cached_events[$v][$g]); if($g != count($this->cached_events[$v])) { + if ($has_category[$event['id']]['category'] != True) + { + continue; // we need at least one evidence for this category + } for($h=$g + 1;$h<$c_daily;$h++) { $this->cached_events[$v][$h - 1] = $this->cached_events[$v][$h]; } unset($this->cached_events[$v][$h]); + $has_category[$event['id']]['category'] = True; } // if ($start < $firstday && $event['recur_type'] == MCAL_RECUR_NONE) // start before period --> move it to the beginning @@ -2267,28 +2256,22 @@ { $this->cached_events[$firstday][] = $event; $already_moved[$event['id']] = 1; - if($this->debug) - { - echo 'moved --> '."\n"; - } + print_debug('Event moved'); } else { $already_moved[$event['id']] = 2; - if($this->debug) - { - echo 'removed (not moved) -->'."\n"; - } + print_debug('Event removed (not moved)'); } - } - elseif($this->debug) + } + else { - echo 'removed -->'."\n"; + print_debug('Event removed'); } } - elseif($this->debug) + else { - echo 'ok -->'."\n"; + print_debug('Event OK'); } } flush(); @@ -2301,4 +2284,4 @@ _debug_array($data); } } -?> +?> \ No newline at end of file diff --git a/calendar/inc/class.bopreferences.inc.php b/calendar/inc/class.bopreferences.inc.php index 07ee19d52e..1bba6ca66f 100755 --- a/calendar/inc/class.bopreferences.inc.php +++ b/calendar/inc/class.bopreferences.inc.php @@ -41,7 +41,8 @@ 'workdayends', 'defaultcalendar', 'defaultfilter', - 'interval' + 'interval', + 'planner_intervals_per_day' ); for($i=0;$i +?> \ No newline at end of file diff --git a/calendar/inc/class.socalendar.inc.php b/calendar/inc/class.socalendar.inc.php index 4d3784f2d1..bcc285fb59 100755 --- a/calendar/inc/class.socalendar.inc.php +++ b/calendar/inc/class.socalendar.inc.php @@ -135,7 +135,26 @@ function list_events_keyword($keywords) { - $sql = 'AND (phpgw_cal_user.cal_login='.$this->owner.') '; +// $sql = 'AND (phpgw_cal_user.cal_login='.$this->owner.') '; + $o = $this->owner; + $type = $GLOBALS['phpgw']->accounts->get_type($o); + + if($type == 'g') + { + $members = $GLOBALS['phpgw']->acl->get_ids_for_location($o, 1, 'phpgw_group'); + } + else + { + $members[0] = $o; + } + + $sql = 'AND (phpgw_cal_user.cal_login='.$members[0]; + + for($i=1; $ical->stream; + $this->cal->stream->query('SELECT cal_id FROM phpgw_cal_user WHERE cal_login='.$account_id,__LINE__,__FILE__) + while($this->cal->stream->next_record()) + { + $id = $this->cal->stream->f('cal_id'); + $db2->query('SELECT count(*) FROM phpgw_cal_user WHERE cal_id='.$id.' AND cal_login='.$new_owner,__LINE__,__FILE__); + if($db2->f(0) == 0) + { + $db2->query('UPDATE phpgw_cal_user SET cal_login='.$new_owner.' WHERE cal_id='.$id.' AND cal_login='.$account_id,__LINE__,__FILE__); + } + else + { + $db2->query('DELETE FROM phpgw_cal_user WHERE cal_id='.$id.' AND cal_login='.$account_id,__LINE__,__FILE__); + } + } $this->cal->stream->query('UPDATE phpgw_cal SET owner='.$new_owner.' WHERE owner='.$account_id,__LINE__,__FILE__); - $this->cal->stream->query('UPDATE phpgw_cal_user SET cal_login='.$new_owner.' WHERE cal_login='.$account_id); } } @@ -349,4 +382,4 @@ /* End mcal equiv functions */ } -?> +?> \ No newline at end of file diff --git a/calendar/inc/class.uicalendar.inc.php b/calendar/inc/class.uicalendar.inc.php index 20d8ad3a50..6f08bf97a2 100755 --- a/calendar/inc/class.uicalendar.inc.php +++ b/calendar/inc/class.uicalendar.inc.php @@ -32,6 +32,22 @@ var $theme; var $link_tpl; + // planner related variables + var $planner_html; + + var $planner_header; + var $planner_rows; + + var $planner_group_members; + + var $planner_firstday; + var $planner_lastday; + var $planner_days; + + var $planner_end_month; + var $planner_end_year; + var $planner_days_in_end_month; + var $public_functions = array( 'mini_calendar' => True, 'index' => True, @@ -621,16 +637,12 @@ unset($GLOBALS['phpgw_info']['flags']['noheader']); unset($GLOBALS['phpgw_info']['flags']['nonavbar']); $GLOBALS['phpgw']->common->phpgw_header(); - + echo '
'; - $cal_id = ($vcal_id?$vcal_id:''); - $cal_id = (isset($GLOBALS['HTTP_POST_VARS']['cal_id'])?$GLOBALS['HTTP_POST_VARS']['cal_id']:$cal_id); - $cal_id = (isset($GLOBALS['HTTP_GET_VARS']['cal_id'])?$GLOBALS['HTTP_GET_VARS']['cal_id']:$cal_id); - - $date = $cal_date?$cal_date:0; - $date = $date?$date:intval($GLOBALS['HTTP_GET_VARS']['date']); - + $cal_id = get_var('cal_id',Array('GET','POST','DEFAULT'),$vcal_id); + $date = get_var('date',Array('GET','DEFAULT'),$cal_date); + // First, make sure they have permission to this entry if ($cal_id < 1) { @@ -638,7 +650,7 @@ $GLOBALS['phpgw']->common->phpgw_exit(True); } - if(!$this->bo->check_perms(PHPGW_ACL_READ)) + if(!$this->bo->check_perms(PHPGW_ACL_READ,$cal_id)) { echo lang('You do not have permission to read this record!').'
'."\n"; $GLOBALS['phpgw']->common->phpgw_exit(True); @@ -688,99 +700,100 @@ ) ); - if($this->bo->owner == $event['owner'] || $this->bo->member_of_group($this->bo->owner)) +// if($this->bo->owner == $event['owner'] || $this->bo->member_of_group($this->bo->owner)) + if($this->bo->check_perms(PHPGW_ACL_EDIT,$event)) { - if ($this->bo->check_perms(PHPGW_ACL_EDIT,$event['owner'])) +// if ($this->bo->check_perms(PHPGW_ACL_EDIT,$event['owner'])) +// { + if($event['recur_type'] != MCAL_RECUR_NONE) { - if($event['recur_type'] != MCAL_RECUR_NONE) - { - $var = Array( - 'action_url_button' => $this->page('edit','&cal_id='.$cal_id), - 'action_text_button' => lang('Edit Single'), - 'action_confirm_button' => '', - 'action_extra_field' => ''."\n" - . '' - ); - $p->set_var($var); - echo $p->fp('out','form_button'); - - $var = Array( - 'action_url_button' => $this->page('edit','&cal_id='.$cal_id), - 'action_text_button' => lang('Edit Series'), - 'action_confirm_button' => '', - 'action_extra_field' => '' - ); - $p->set_var($var); - echo $p->fp('out','form_button'); - } - else - { - $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'); - } + $var = Array( + 'action_url_button' => $this->page('edit','&cal_id='.$cal_id), + 'action_text_button' => lang('Edit Single'), + 'action_confirm_button' => '', + 'action_extra_field' => ''."\n" + . '' + ); + $p->set_var($var); + echo $p->fp('out','form_button'); $var = Array( - 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uialarm.manager'), - 'action_text_button' => lang('Alarm Management'), + 'action_url_button' => $this->page('edit','&cal_id='.$cal_id), + 'action_text_button' => lang('Edit Series'), 'action_confirm_button' => '', - 'action_extra_field' => '' + 'action_extra_field' => '' + ); + $p->set_var($var); + echo $p->fp('out','form_button'); + } + else + { + $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,$event['owner'])) + $var = Array( + 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uialarm.manager'), + 'action_text_button' => lang('Alarm Management'), + 'action_confirm_button' => '', + 'action_extra_field' => '' + ); + $p->set_var($var); + echo $p->fp('out','form_button'); + } + + if ($this->bo->check_perms(PHPGW_ACL_DELETE,$event)) + { + if($event['recur_type'] != MCAL_RECUR_NONE) { - if($event['recur_type'] != MCAL_RECUR_NONE) + $var = Array( + 'action_url_button' => $this->page('delete','&cal_id='.$cal_id), + 'action_text_button' => lang('Delete Single'), + 'action_confirm_button' => "onClick=\"return confirm('".lang("Are you sure\\nyou want to\\ndelete this single occurence ?\\n\\nThis will delete\\nthis entry for all users.")."')\"", + 'action_extra_field' => '' + ); + $p->set_var($var); + echo $p->fp('out','form_button'); + + $var = Array( + 'action_url_button' => $this->page('delete','&cal_id='.$cal_id), + 'action_text_button' => lang('Delete Series'), + '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($event['recur_exception']) { $var = Array( - 'action_url_button' => $this->page('delete','&cal_id='.$cal_id), - 'action_text_button' => lang('Delete Single'), - 'action_confirm_button' => "onClick=\"return confirm('".lang("Are you sure\\nyou want to\\ndelete this single occurence ?\\n\\nThis will delete\\nthis entry for all users.")."')\"", - 'action_extra_field' => '' - ); - $p->set_var($var); - echo $p->fp('out','form_button'); - - $var = Array( - 'action_url_button' => $this->page('delete','&cal_id='.$cal_id), - 'action_text_button' => lang('Delete Series'), - '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($event['recur_exception']) - { - $var = Array( - 'action_url_button' => $this->page('reinstate_list','&cal_id='.$cal_id), - 'action_text_button' => lang('Reinstate'), - 'action_confirm_button' => '', - 'action_extra_field' => '' - ); - $p->set_var($var); - echo $p->fp('out','form_button'); - } - } - else - { - $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_url_button' => $this->page('reinstate_list','&cal_id='.$cal_id), + 'action_text_button' => lang('Reinstate'), + 'action_confirm_button' => '', 'action_extra_field' => '' ); $p->set_var($var); echo $p->fp('out','form_button'); } } + else + { + $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'); + } +// } } $var = Array( @@ -791,6 +804,8 @@ ); $p->set_var($var); echo $p->fp('out','form_button').''; + + $GLOBALS['phpgw']->hooks->process('calendar_view'); } function edit($params='') @@ -1093,7 +1108,8 @@ function delete() { - if(!isset($GLOBALS['HTTP_GET_VARS']['cal_id'])) + $cal_id = get_var('cal_id',Array('GET')); + if(!$cal_id) { Header('Location: '.$this->page('','&date='.sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day))); $GLOBALS['phpgw']->common->phpgw_exit(); @@ -1101,23 +1117,25 @@ $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(($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(isset($GLOBALS['HTTP_POST_VARS']['delete_type']) && $GLOBALS['HTTP_POST_VARS']['delete_type'] == 'single') + $delete_type = get_var('delete_type',Array('POST')); + if($delete_type == 'single') { $cd = $this->bo->delete_single( Array( - 'id' => intval($GLOBALS['HTTP_GET_VARS']['cal_id']), + 'id' => intval($cal_id), 'year' => $this->bo->year, 'month' => $this->bo->month, 'day' => $this->bo->day ) ); } - elseif((isset($GLOBALS['HTTP_POST_VARS']['delete_type']) && $GLOBALS['HTTP_POST_VARS']['delete_type'] == 'series') || !isset($GLOBALS['HTTP_POST_VARS']['delete_type'])) +// 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($GLOBALS['HTTP_GET_VARS']['cal_id'])); + $cd = $this->bo->delete_entry(intval($cal_id)); $this->bo->expunge(); } } @@ -1252,125 +1270,228 @@ function planner() { + if(floor(phpversion()) == 4) + { + eval(' - if(floor(phpversion()) == 4) - { - eval(' + // generate header and set global/member variables + // + $this->planner_prepare(); - unset($GLOBALS[\'phpgw_info\'][\'flags\'][\'noheader\']); - unset($GLOBALS[\'phpgw_info\'][\'flags\'][\'nonavbar\']); - $GLOBALS[\'phpgw\']->common->phpgw_header(); + // process events within selected interval + // + $this->planner_process_interval(); + + // generate the planner view + // + $this->planner_print_rows(); + '); + } + } + + /** + * planner_prepare - prepare the planner view + * + * - 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() + { + 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); - $html = CreateObject(\'calendar.html\'); -// $html = CreateObject(\'infolog.html\'); - $sbox = CreateObject(\'phpgwapi.sbox\'); + 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; + } + } - $intervals_per_day = 3; // this should be configurable - $interval = Array( - 14 => 1, - 15 => 1, - 16 => 1, - 17 => 1, - 18 => 2, - 19 => 2, - 20 => 2, - 21 => 2, - 22 => 2, - 23 => 2 - ); + // create/initialize variables directly used for HTML code generation + // + $this->planner_html = CreateObject(\'calendar.html\'); + $this->planner_header = array(); + $this->planner_rows = array(); - $startdate = mktime(0,0,0,$this->bo->month,1,$this->bo->year) - $GLOBALS[\'phpgw\']->datetime->tz_offset; - $days = $GLOBALS[\'phpgw\']->datetime->days_in_month($this->bo->month,$this->bo->year); - $enddate = mktime(23,59,59,$this->bo->month,$this->bo->days,$this->bo->year) - $GLOBALS[\'phpgw\']->datetime->tz_offset; + // generate header lines with days and associated months + // + $hdr = &$this->planner_header; + $hdr[0][\'0\'] = $title; + $hdr[0][\'.0\'] = \'rowspan="3"\'; - $header[] = lang(\'Category\'); - for ($d = 1; $d <= $days; $d++) - { - $dayname = substr(lang(date(\'D\',mktime(0,0,0,$this->bo->month,$d,$this->bo->year))),0,2); + $this->planner_days = 0; // reset - $header[\'.\'.$d] = \'colspan="\'.$intervals_per_day.\'" align="center"\'; - $header[$d] = \'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"\'; + $hdr[2][$index] = \'bo->year,$this->bo->month,$d) + \'date\' => sprintf("%04d%02d%02d",$y,$m,$d) ) ).\'">\'.$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; + '); } - $last_cell = $intervals_per_day * $days - 1; + } - $this->bo->store_to_cache( - Array( - \'syear\' => $this->bo->year, - \'smonth\' => $this->bo->month, - \'sday\' => 1, - \'eyear\' => $this->bo->year, - \'emonth\' => $this->bo->month, - \'eday\' => $days - ) - ); - $firstday = intval(date(\'Ymd\',mktime(0,0,0,$this->bo->month,1,$this->bo->year))); - $lastday = intval(date(\'Ymd\',mktime(0,0,0,$this->bo->month,$days,$this->bo->year))); - - $this->bo->remove_doubles_in_cache($firstday,$lastday); - - $rows = array(); - for($v=$firstday;$v<=$lastday;$v++) + /** + * planner_update_row - update a row of the planner view + * + * parameters are: + * - index (e.g. user id, category id, ...) of the row + * - name/title of the row (e.g. user name, category name) + * - the event to be integrated + * - list of categories associated with the event + * - first and last cell of the row + */ + function planner_update_row($params) + { + if(floor(phpversion()) == 4) { - $daily = $this->bo->cached_events[$v]; - @reset($daily); - if($this->debug) - { - echo \'\'."\n"; - } - while (list($nul,$event) = @each($daily)) - { - $view = $html->link(\'/index.php\', + 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\'] ) ); - $start_cell = $intervals_per_day * ($event[\'start\'][\'mday\'] - 1); - $start_cell += $interval[$event[\'start\'][\'hour\']]; - - $end_cell = $intervals_per_day * ($event[\'end\'][\'mday\'] - 1); - $end_cell += $interval[$event[\'end\'][\'hour\']]; - - $i = 0; // search for row of parent category + // check how many lines are needed for this "row" (currently: user or category) + $i = 0; do { ++$i; - if ($c = $event[\'category\']) - { - $cat = $this->planner_category($event[\'category\']); - if ($cat[\'parent\']) - { - $pcat = $this->planner_category($c = $cat[\'parent\']); - } - else - { - $pcat = $cat; - } - } - else - { - $cat = $pcat = array( \'name\' => lang(\'none\')); - } - $k = $c.\'_\'.$i; + + $k = $index.\'_\'.$i; $ka = \'.nr_\'.$k; + if (!isset($rows[$k])) { if ($i > 1) // further line - no name { $rows[$k] = array(); - $rows[$c.\'_1\'][\'._name\'] = \'rowspan="\'.$i.\'"\'; + $rows[$index.\'_1\'][\'._name\'] = \'rowspan="\'.$i.\'"\'; } else { - $rows[$k][\'_name\'] = $pcat[\'name\']; + $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); @@ -1380,67 +1501,339 @@ $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) { - $opt .= "colspan=".(1 + $end_cell - $start_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.\'"\'; } - $opt .= \' title="\'.$event[\'title\']; - if ($event[\'description\']) + if (!$is_private) { - $opt .= " \n".$event[\'description\']; + $opt .= \' title="\'.lang(\'Title\').": ".$event[\'title\']; + if ($event[\'description\']) + { + $opt .= " \n".lang(\'Description\').": ".$event[\'description\']; + } } - $opt .= \'" onClick="location=\\\'\'.$view.\'\\\'"\'; - $cel = \'\'; + 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 .= $html->image(\'calendar\',\'mini-calendar-bar.gif\',\'\',\'border="0"\'); + $cel .= $this->planner_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 .= $this->planner_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; - } - } - 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 (isset($event[\'print_title\']) && $event[\'print_title\'] == \'yes\') { - $row[\'3\'] = \' \'; - $row[\'.3\'] = \'colspan="\'.(1+$last_cell-$akt_cell).\'"\'; + $cel .= \' \'.$title.\' \'; + } + if (isset($event[\'print_description\']) && $event[\'print_description\'] == \'yes\') + { + $cel .= \' - \'.$event[\'description\'].\' \'; } - } - } - $bgcolor = \'bgcolor="\'.$this->theme[\'th_bg\'].\'"\'; - if ($this->debug) - { - _debug_array($rows); - reset($rows); + $akt_cell = $end_cell + 1; + + return $rows; + '); } - echo $html->table( - array( - \'_h\' => $header, - \'._h\' => $bgcolor - )+$rows, - \'width="100%" cols="\'.(1+$days*$intervals_per_day).\'"\' - ); - '); } + function planner_process_event($event) + { + if(floor(phpversion()) == 4) + { + eval(' + $intervals_per_day = $this->bo->prefs[\'calendar\'][\'planner_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) + { + $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\']]; + } + 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) + { + eval(' + $rows = &$this->planner_rows; + + if ($this->bo->sortby == \'user\') + { + // 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; + } + } + } + + // 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)) + { + 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).\'"\'; + } + } + } + '); + } + } + + 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\']; + + 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).\'"\' + ); + '); + } + } + + function planner_process_interval() + { + if(floor(phpversion()) == 4) + { + 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); + + // 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)); + + // process all events on day $v + // + while (list($nul,$event) = @each($daily)) + { + $this->planner_process_event($event); + } + } + $this->planner_pad_rows(); + '); + } } function matrixselect() @@ -1548,7 +1941,7 @@ { $this->output_template_array($p,'rows','list',$var[$i]); } - + $vars = Array( 'submit_button' => lang('Submit'), 'action_url_button' => '', @@ -1605,7 +1998,8 @@ unset($GLOBALS['phpgw_info']['flags']['nonavbar']); $GLOBALS['phpgw']->common->phpgw_header(); - switch($GLOBALS['HTTP_POST_VARS']['matrixtype']) + $matrixtype = get_var('matrixtype',Array('POST')); + switch($matrixtype) { case 'free/busy': $freetime = $GLOBALS['phpgw']->datetime->gmtdate(mktime(0,0,0,$this->bo->month,$this->bo->day,$this->bo->year)); @@ -1633,7 +2027,7 @@ echo ' '."\n"; echo ' '."\n"; echo ' '."\n"; - echo ' '."\n"; + echo ' '."\n"; reset($parts); while(list($key,$value) = each($parts)) { @@ -1646,7 +2040,8 @@ function search() { - if (!$GLOBALS['HTTP_POST_VARS']['keywords']) + $keywords = get_var('keywords',Array('POST')); + if (!$keywords) { // If we reach this, it is because they didn't search for anything, // attempt to send them back to where they where. @@ -1660,13 +2055,13 @@ $error = ''; - if (strlen($GLOBALS['HTTP_POST_VARS']['keywords']) == 0) + 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. @@ -1675,14 +2070,19 @@ // This has been solved by the little icon indicator for recurring events. - $event_ids = $this->bo->search_keywords($GLOBALS['HTTP_POST_VARS']['keywords']); + $event_ids = $this->bo->search_keywords($keywords); $ids = Array(); while(list($key,$id) = each($event_ids)) { $event = $this->bo->read_entry($id); - + + if(!$event['public'] && !$this->bo->check_perms(PHPGW_ACL_READ,$event)) + { + continue; + } + $datetime = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset; - + $ids[strval($event['id'])]++; $info[strval($event['id'])] = $GLOBALS['phpgw']->common->show_date($datetime).$this->link_to_entry($event,$event['start']['month'],$event['start']['mday'],$event['start']['year']); @@ -1796,7 +2196,7 @@ { $page_ = explode('.',$this->bo->prefs['calendar']['defaultcalendar']); $_page = $page_[0]; - if ($_page=='index' || ($_page != 'day' && $_page != 'week' && $_page != 'month' && $_page != 'year')) + if ($_page=='index' || ($_page != 'day' && $_page != 'week' && $_page != 'month' && $_page != 'year' && $_page != 'planner')) { $_page = 'month'; $GLOBALS['phpgw']->preferences->add('calendar','defaultcalendar','month'); @@ -1833,7 +2233,7 @@ function footer() { - list(,,$method) = explode('.',$GLOBALS['HTTP_GET_VARS']['menuaction']); + list(,,$method) = explode('.',MENUACTION); if (@$this->bo->printer_friendly) { @@ -1883,33 +2283,34 @@ ); $this->output_template_array($p,'table_row','footer_row',$var); - unset($thisdate); - $thisdate = mktime(0,0,0,$this->bo->month,$this->bo->day,$this->bo->year) - $GLOBALS['phpgw']->datetime->tz_offset; - $sun = $GLOBALS['phpgw']->datetime->get_weekday_start($this->bo->year,$this->bo->month,$this->bo->day) - $GLOBALS['phpgw']->datetime->tz_offset; - - $str = ''; - for ($i = -7; $i <= 7; $i++) + if(MENUACTION == 'calendar.uicalendar.week') { - $begin = $sun + (604800 * $i); - $end = $begin + 604799; - $str .= ''."\n"; - } - - $var = Array( - 'action_url' => $this->page($method,''), - 'form_name' => 'SelectWeek', - 'label' => lang('Week'), - 'form_label' => 'date', - 'form_onchange' => 'document.SelectWeek.submit()', - 'row' => $str, - 'go' => lang('Go!') - ); + unset($thisdate); + $thisdate = mktime(0,0,0,$this->bo->month,$this->bo->day,$this->bo->year) - $GLOBALS['phpgw']->datetime->tz_offset; + $sun = $GLOBALS['phpgw']->datetime->get_weekday_start($this->bo->year,$this->bo->month,$this->bo->day) - $GLOBALS['phpgw']->datetime->tz_offset; - $this->output_template_array($p,'table_row','footer_row',$var); + $str = ''; + for ($i = -7; $i <= 7; $i++) + { + $begin = $sun + (604800 * $i); + $end = $begin + 604799; + $str .= ''."\n"; + } + + $var = Array( + 'action_url' => $this->page($method,''), + 'form_name' => 'SelectNumberOfMonths', + 'label' => lang('Number of Months'), + 'hidden_vars' => $date_str, + 'form_label' => 'num_months', + 'form_onchange' => 'document.SelectNumberOfMonths.submit()', + 'action_extra_field' => $date_str, + 'row' => $str, + 'go' => lang('Go!') + ); + $this->output_template_array($p,'table_row','footer_row',$var); + } + $var = Array( 'submit_button' => lang('Submit'), 'action_url_button' => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uiicalendar.import'), @@ -1986,8 +2420,10 @@ function link_to_entry($event,$month,$day,$year) { $str = ''; - $is_private = $this->bo->is_private($event,$event['owner']); - $editable = ((!$this->bo->printer_friendly) && (($is_private && $this->bo->check_perms(PHPGW_ACL_PRIVATE)) || !$is_private)); +// $is_private = $this->bo->is_private($event,$event['owner']); +// $editable = ((!$this->bo->printer_friendly) && (($is_private && $this->bo->check_perms(PHPGW_ACL_PRIVATE)) || !$is_private)); + $is_private = !$event['public'] && !$this->bo->check_perms(PHPGW_ACL_READ,$event); + $editable = !$this->bo->printer_friendly && $this->bo->check_perms(PHPGW_ACL_READ,$event); $starttime = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset; $endtime = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; @@ -2032,7 +2468,8 @@ { $text .= $this->bo->display_status($event['users_status']); } - $text = ''.$time.' '.$this->bo->get_short_field($event,$is_private,'title').$text.''.$GLOBALS['phpgw']->browser->br; +// $text = ''.$time.' '.$this->bo->get_short_field($event,$is_private,'title').$text.''.$GLOBALS['phpgw']->browser->br; + $text = ' '.$time.'  '.$this->bo->get_short_field($event,$is_private,'title').$text.': '.$this->bo->get_short_field($event,$is_private,'description').''.$GLOBALS['phpgw']->browser->br; if ($editable) { @@ -2046,7 +2483,9 @@ $picture[] = Array( 'pict' => $GLOBALS['phpgw']->common->image('calendar','high'), 'width' => 8, - 'height'=> 17 + 'height'=> 17, + 'alt' => lang('high priority'), + 'title' => lang('high priority') ); } if($event['recur_type'] == MCAL_RECUR_NONE) @@ -2054,7 +2493,9 @@ $picture[] = Array( 'pict' => $GLOBALS['phpgw']->common->image('calendar','circle'), 'width' => 5, - 'height'=> 7 + 'height'=> 7, + 'alt' => lang('single event'), + 'title' => lang('single event') ); } else @@ -2062,15 +2503,31 @@ $picture[] = Array( 'pict' => $GLOBALS['phpgw']->common->image('calendar','recur'), 'width' => 12, - 'height'=> 12 + 'height'=> 12, + 'alt' => lang('recurring event'), + 'title' => lang('recurring event') ); } + + $participants = $this->planner_participants($event['participants']); if(count($event['participants']) > 1) { $picture[] = Array( 'pict' => $GLOBALS['phpgw']->common->image('calendar','multi_3'), 'width' => 14, - 'height'=> 14 + 'height'=> 14, + 'alt' => $participants, + 'title' => $participants + ); + } + else + { + $picture[] = Array( + 'pict' => $GLOBALS['phpgw']->common->image('calendar','single'), + 'width' => 14, + 'height'=> 14, + 'alt' => $participants, + 'title' => $participants ); } if($event['public'] == 0) @@ -2078,7 +2535,9 @@ $picture[] = Array( 'pict' => $GLOBALS['phpgw']->common->image('calendar','private'), 'width' => 13, - 'height'=> 13 + 'height'=> 13, + 'alt' => lang('private'), + 'title' => lang('private') ); } if(@isset($event['alarm']) && count($event['alarm']) >= 1) @@ -2088,7 +2547,9 @@ $picture[] = Array( 'pict' => $GLOBALS['phpgw']->common->image('calendar','alarm'), 'width' => 13, - 'height'=> 13 + 'height'=> 13, + 'alt' => lang('alarm'), + 'title' => lang('alarm') ); } } @@ -2097,10 +2558,11 @@ for($i=0;$i $picture[$i]['pict'], - 'width' => $picture[$i]['width'], - 'height' => $picture[$i]['height'], - 'description' => $description + 'pic_image' => $picture[$i]['pict'], + 'width' => $picture[$i]['width'], + 'height' => $picture[$i]['height'], + 'alt' => $picture[$i]['alt'], + 'title' => $picture[$i]['title'] ); $this->output_template_array($this->link_tpl,'picture','pict',$var); } @@ -2175,7 +2637,7 @@ ); $p->set_var($var); - $date = sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->mday); + $date = sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->mday); $var = Array( 'action_url_button' => $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.bocalendar.update','readsess'=>1)), 'action_text_button' => lang('Ignore Conflict'), @@ -2574,7 +3036,8 @@ function view_event($event,$alarms=False) { - if((!$event['participants'][$this->bo->owner] && !$this->bo->member_of_group()) || (!$event['public'] && !$this->bo->check_perms(PHPGW_ACL_PRIVATE))) +// if((!$event['participants'][$this->bo->owner] && !$this->bo->member_of_group()) || (!$event['public'] && !$this->bo->check_perms(PHPGW_ACL_PRIVATE))) + if((!$event['participants'][$this->bo->owner] && !$this->bo->check_perms(PHPGW_ACL_READ,$event))) { return '
'.lang('You do not have permission to read this record!').'
'; } @@ -2828,10 +3291,7 @@ $this->index(); } - if($this->debug) - { - echo ''."\n"; - } + print_debug('in print_day()'); $this->bo->store_to_cache( Array( @@ -2876,10 +3336,7 @@ $this->bo->prefs['calendar']['interval'] = 60; } - if($this->debug) - { - echo ''."\n"; - } + print_debug('Interval set to',intval($this->bo->prefs['calendar']['interval'])); for ($i=0;$i<24;$i++) { @@ -2895,20 +3352,15 @@ $time = Array(); $daily = $this->set_week_array($GLOBALS['phpgw']->datetime->get_weekday_start($params['year'],$params['month'],$params['day']),$this->theme['row_on'],True); - if($this->debug) - { - echo ''."\n"; - } + print_debug('Date to Eval',$date_to_eval); if($daily[$date_to_eval]['appts']) { $starttime = 0; $endtime = 0; $events = $this->bo->cached_events[$date_to_eval]; $c_events = count($events); - if($this->debug) - { - echo ''."\n"; - } + print_debug('Date',$date_to_eval); + print_debug('Count',$c_events); for($i=0;$i<$c_events;$i++) { if($events[$i]['recur_type'] == MCAL_RECUR_NONE) @@ -2932,11 +3384,8 @@ { $ind = intval($events[$i]['start']['hour']); $interval_start = intval($events[$i]['start']['min'] / intval($this->bo->prefs['calendar']['interval'])); - if($this->debug) - { - echo ''."\n"; - echo ''."\n"; - } + print_debug('Start Time Minutes',$events[$i]['start']['min']); + print_debug('Interval',$interval_start); } } else @@ -2952,28 +3401,19 @@ } if((($ind <> 99) && ($ind <> 0)) && (($starttime <> 0) && ($endtime <> 0))) { - if($this->debug) - { - echo ''."\n"; - } + print_debug('IND before',$ind); if(($ind >= date('H',$last_starttime)) && ($ind <= date('H',$last_endtime))) { $ind = $last_ind; $interval_start = $last_interval_start; } - if($this->debug) - { - echo ''."\n"; - } + print_debug('IND after',$ind); } $time[$ind][$interval_start] .= $this->link_to_entry($events[$i],$params['month'],$params['day'],$params['year']); - if($this->debug) - { - echo ''."\n"; - echo ''."\n"; - } + 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']); @@ -2996,10 +3436,8 @@ { $rowspan += 1; } - if($this->debug) - { - echo ''."\n"; - } + + print_debug('Rowspan being set to',$rowspan); if ($rowspan > $rowspan_arr[$ind][$interval_start] && $rowspan > 1) { @@ -3010,10 +3448,9 @@ $last_interval_start = $interval_start; $last_starttime = $starttime; $last_endtime = $endtime; - if($this->debug) - { - echo ''."\n"; - } + 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); + print_debug('Interval #',$interval_start); } } @@ -3117,7 +3554,7 @@ $open_link = ' - '; $close_link = ''; - + if(!$this->bo->printer_friendly && $this->bo->check_perms(PHPGW_ACL_ADD)) { $new_hour = intval(substr($dtime,0,strpos($dtime,':'))); @@ -3125,9 +3562,9 @@ { $new_hour += 12; } - + $open_link .= ''; - + $close_link = ''; } @@ -3136,7 +3573,7 @@ 'time' => (intval(substr($dtime,0,strpos($dtime,':')))<10?'0'.$dtime:$dtime), 'close_link' => $close_link ); - + $this->output_template_array($p,'item','day_time',$var); $p->parse('row','day_row',True); $p->set_var('event',''); diff --git a/calendar/inc/class.uipreferences.inc.php b/calendar/inc/class.uipreferences.inc.php index eebf15a597..bf4c3916ea 100755 --- a/calendar/inc/class.uipreferences.inc.php +++ b/calendar/inc/class.uipreferences.inc.php @@ -103,6 +103,7 @@ $selected['month'] = ' selected'; } $str = ''."\n".$str.''."\n"); + $var = Array( + 1 => '1', + 2 => '2', + 3 => '3', + 4 => '4', + ); + + $str = ''; + while(list($key,$value) = each($var)) + { + $str .= ''."\n"; + } + $this->display_item(lang('Number of Intervals per Day in Planner View'),''."\n"); + $checkboxes = Array( 'send_updates' => lang('Send/receive updates via email'), 'weekdays_only' => lang('Display week days only in Month/Week View'), @@ -178,4 +193,4 @@ ); $this->output_template_array('row','pref_list',$var); } - } + } \ No newline at end of file diff --git a/calendar/templates/default/link_pict.tpl b/calendar/templates/default/link_pict.tpl index 48dc9c3461..a2aa910f16 100755 --- a/calendar/templates/default/link_pict.tpl +++ b/calendar/templates/default/link_pict.tpl @@ -6,7 +6,7 @@ - {description} + {alt} {text}