From 9472646729b0a11ef47f43dfc4d75ae61ba5d00b Mon Sep 17 00:00:00 2001 From: skeeter Date: Sat, 28 Jul 2001 13:17:30 +0000 Subject: [PATCH] This should provide all neccessary functions to the calendar in n-tier layout. Just need to debug it out for any minor problems. --- calendar/inc/class.bocalendar.inc.php | 409 +++- calendar/inc/class.boholiday.inc.php | 239 +- calendar/inc/class.socalendar.inc.php | 42 +- calendar/inc/class.soholiday.inc.php | 147 +- calendar/inc/class.uicalendar.inc.php | 2259 ++++++++++--------- calendar/inc/class.uiholiday.inc.php | 559 +++++ calendar/templates/default/header.inc.php | 13 +- calendar/templates/default/year.tpl | 35 + calendar/templates/idsociety/header.inc.php | 10 +- calendar/templates/justweb/header.inc.php | 10 +- calendar/templates/verdilak/header.inc.php | 10 +- 11 files changed, 2560 insertions(+), 1173 deletions(-) create mode 100755 calendar/inc/class.uiholiday.inc.php create mode 100755 calendar/templates/default/year.tpl diff --git a/calendar/inc/class.bocalendar.inc.php b/calendar/inc/class.bocalendar.inc.php index 3c09b003b3..c0a1a9795e 100755 --- a/calendar/inc/class.bocalendar.inc.php +++ b/calendar/inc/class.bocalendar.inc.php @@ -19,9 +19,9 @@ var $public_functions = Array( 'read_entries' => True, 'read_entry' => True, - 'add_entry' => True, 'delete_entry' => True, - 'update_entry' => True + 'update' => True, + 'preferences' => True ); var $debug = False; @@ -53,7 +53,7 @@ function bocalendar($session=0) { - global $phpgw, $phpgw_info, $date, $year, $month, $day, $owner, $filter, $fcat_id, $friendly; + global $phpgw, $phpgw_info, $date, $year, $month, $day, $owner, $filter, $cat_id, $friendly; $phpgw->nextmatchs = CreateObject('phpgwapi.nextmatchs'); @@ -96,10 +96,7 @@ $this->holiday_color = (substr($phpgw_info['theme']['bg07'],0,1)=='#'?'':'#').$phpgw_info['theme']['bg07']; - if($friendly == 1) - { - $this->printer_friendly = True; - } + $this->printer_friendly = ($friendly == 1?True:False); if(isset($filter)) { $this->filter = $filter; } if(isset($cat_id)) { $this->cat_id = $cat_id; } @@ -158,6 +155,7 @@ if ($this->use_session) { global $phpgw; + if($this->debug) { echo '
Save:'; _debug_array($data); } $phpgw->session->appsession('session_data','calendar',$data); } @@ -186,35 +184,22 @@ } } - function add_entry($event) - { - if($this->check_perms(PHPGW_ACL_ADD)) - { - $this->so->add_entry($event); - $this->send_update(MSG_ADDED,$event->participants,'',$this->get_cached_event()); - } - } - - function update_entry($event) - { - if($this->check_perms(PHPGW_ACL_EDIT)) - { - if($event->id != 0) - { - $new_event = $event; - $old_event = $this->read_entry($new_event->id); - $this->prepare_recipients($new_event,$old_event); - } - $this->so->add_entry($event); - } - } - function delete_entry($id) { if($this->check_perms(PHPGW_ACL_DELETE)) { - $this->so->delete_entry($id); + $temp_event = $this->read_entry($id); + if($this->owner == $temp_event->owner) + { + $this->so->delete_entry($id); + $cd = 16; + } + else + { + $cd = 60; + } } + return $cd; } function expunge() @@ -230,11 +215,285 @@ $this->so->expunge(); } } - /* Private functions */ + function search_keywords($keywords) + { + return $this->so->list_events_keyword($keywords); +/* + $event_ids = $this->so->list_events_keyword($keywords); + $event_ids_repeating = $this->so->list_repeated_events_keyword($keywords); + + $c_event_ids = count($cached_event_ids); + $c_event_ids_repeating = count($cached_event_ids_repeating); + + if($this->debug) + { + echo "events cached : $c_event_ids : for : ".sprintf("%04d%02d%02d",$syear,$smonth,$sday)."
\n"; + echo "repeating events cached : $c_event_ids_repeating : for : ".sprintf("%04d%02d%02d",$syear,$smonth,$sday)."
\n"; + } + + if($c_cached_ids) + { + for($i=0;$i<$c_cached_ids;$i++) + { + $cached_events[] = $this->so->read_entry($event_ids[$i]); + } + } + + if($c_event_ids_repeating) + { + for($i=0;$i<$c_event_ids_repeating;$i++) + { + $cached_events[] = $this->so->read_entry($event_ids_repeating[$i]); + } + } +*/ + } + + function update($p_cal=Array(),$p_start=Array(),$p_end=Array(),$p_recur_enddata=Array()) + { + global $phpgw, $phpgw_info, $readsess, $cal, $participants, $start, $end, $recur_enddate; + + $cal = ($p_cal?$p_cal:$cal); + $start = ($p_start?$p_start:$start); + $end = ($p_end?$p_end:$end); + $recur_enddate = ($p_recur_enddate?$p_recur_enddate:$recur_enddate); + + $overlapping_events = False; + + $ui = CreateObject('calendar.uicalendar'); + + if(isset($readsess)) + { + $event = $this->restore_from_appsession(); + $datetime_check = $this->validate_update($event); + if($datetime_check) + { + $ui->edit($datetime_check,True); + } + } + else + { + + if(!$cal['id'] && !$this->check_perms(PHPGW_ACL_ADD)) + { + $ui->index(); + } + elseif($cal['id'] && !$this->check_perms(PHPGW_ACL_EDIT)) + { + $ui->index(); + } + + $this->fix_update_time($start); + $this->fix_update_time($end); + + if(!isset($cal['private'])) + { + $cal['private'] = 'public'; + } + + $is_public = ($cal['private'] == 'public'?1:0); + $this->so->event_init(); + $this->so->set_category($cal['category']); + $this->so->set_title($cal['title']); + $this->so->set_description($cal['description']); + $this->so->set_start($start['year'],$start['month'],$start['mday'],$start['hour'],$start['min'],0); + $this->so->set_end($end['year'],$end['month'],$end['mday'],$end['hour'],$end['min'],0); + $this->so->set_class($is_public); + if($cal['id']) + { + $this->so->add_attribute('id',$cal['id']); + } + + if($cal['rpt_use_end'] != 'y') + { + $recur_enddate['year'] = 0; + $recur_enddate['month'] = 0; + $recur_enddate['mday'] = 0; + } + $cal['recur_data'] = $cal['rpt_sun'] + $cal['rpt_mon'] + $cal['rpt_tue'] + $cal['rpt_wed'] + $cal['rpt_thu'] + $cal['rpt_fri'] + $cal['rpt_sat']; + + switch($cal['recur_type']) + { + case MCAL_RECUR_NONE: + $this->so->set_recur_none(); + break; + case MCAL_RECUR_DAILY: + $this->so->set_recur_daily($recur_enddate['year'],$recur_enddate['month'],$recur_enddate['mday'],$cal['recur_interval']); + break; + case MCAL_RECUR_WEEKLY: + $this->so->set_recur_weekly($recur_enddate['year'],$recur_enddate['month'],$recur_enddate['mday'],$cal['recur_interval'],$cal['recur_data']); + break; + case MCAL_RECUR_MONTHLY_MDAY: + $this->so->set_recur_monthly_mday($recur_enddate['year'],$recur_enddate['month'],$recur_enddate['mday'],$cal['recur_interval']); + break; + case MCAL_RECUR_MONTHLY_WDAY: + $this->so->set_recur_monthly_wday($recur_enddate['year'],$recur_enddate['month'],$recur_enddate['mday'],$cal['recur_interval']); + break; + case MCAL_RECUR_YEARLY: + $this->so->set_recur_yearly($recur_enddate['year'],$recur_enddate['month'],$recur_enddate['mday'],$cal['recur_interval']); + break; + } + + $parts = $participants; + $minparts = min($participants); + $part = Array(); + for($i=0;$iaccounts->get_type(intval($parts[$i])); + if($acct_type == 'u') + { + $part[$parts[$i]] = 1; + } + elseif($acct_type == 'g') + { + /* This pulls ALL users of a group and makes them as participants to the event */ + /* I would like to turn this back into a group thing. */ + $acct = CreateObject('phpgwapi.accounts',intval($parts[$i])); + $members = $acct->members(intval($parts[$i])); + unset($acct); + if($members == False) + { + continue; + } + while($member = each($members)) + { + $part[$member[1]['account_id']] = 1; + } + } + } + + @reset($part); + while(list($key,$value) = each($part)) + { + $this->so->add_attribute('participants['.$key.']','U'); + } + + reset($participants); + $event = $this->get_cached_event(); + if(!@$event->participants[$cal['owner']]) + { + $this->so->add_attribute('owner',$minparts); + } + $this->so->add_attribute('priority',$cal['priority']); + $event = $this->get_cached_event(); + + $this->store_to_appsession($event); + $datetime_check = $this->validate_update($event); + if($datetime_check) + { + $ui = CreateObject('calendar.uicalendar'); + $ui->edit($datetime_check,True); + } + + settype($start,'integer'); + settype($end,'integer'); + $start = mktime($event->start->hour,$event->start->min,$event->start->sec,$event->start->month,$event->start->mday,$event->start->year) - $this->datetime->tz_offset; + $end = mktime($event->end->hour,$event->end->min,$event->end->sec,$event->end->month,$event->end->mday,$event->end->year) - $this->datetime->tz_offset; + + $overlapping_events = $this->overlap($start,$end,$event->participants,$event->owner,$event->id); + } + + if($overlapping_events) + { + $ui->overlap($overlapping_events,$event); + } + else + { + if(!$event->id) + { + $this->so->add_entry($event); + $this->send_update(MSG_ADDED,$event->participants,'',$this->get_cached_event()); + } + else + { + $new_event = $event; + $old_event = $this->read_entry($new_event->id); + $this->prepare_recipients($new_event,$old_event); + $this->so->add_entry($event); + } + $date = sprintf("%04d%02d%02d",$event->start->year,$event->start->month,$event->start->mday); + $ui->index(); + } + } + + function preferences() + { + global $phpgw, $phpgw_info, $submit, $prefs; + if ($submit) + { + $phpgw->preferences->read_repository(); + $phpgw->preferences->add('calendar','weekdaystarts',$prefs['weekdaystarts']); + $phpgw->preferences->add('calendar','workdaystarts',$prefs['workdaystarts']); + $phpgw->preferences->add('calendar','workdayends',$prefs['workdayends']); + $phpgw->preferences->add('calendar','defaultcalendar',$prefs['defaultcalendar']); + $phpgw->preferences->add('calendar','defaultfilter',$prefs['defaultfilter']); + $phpgw->preferences->add('calendar','interval',$prefs['interval']); + if ($prefs['mainscreen_showevents'] == True) + { + $phpgw->preferences->add('calendar','mainscreen_showevents',$prefs['mainscreen_showevents']); + } + else + { + $phpgw->preferences->delete('calendar','mainscreen_showevents'); + } + if ($prefs['send_updates'] == True) + { + $phpgw->preferences->add('calendar','send_updates',$prefs['send_updates']); + } + else + { + $phpgw->preferences->delete('calendar','send_updates'); + } + + if ($prefs['display_status'] == True) + { + $phpgw->preferences->add('calendar','display_status',$prefs['display_status']); + } + else + { + $phpgw->preferences->delete('calendar','display_status'); + } + + if ($prefs['default_private'] == True) + { + $phpgw->preferences->add('calendar','default_private',$prefs['default_private']); + } + else + { + $phpgw->preferences->delete('calendar','default_private'); + } + + if ($prefs['display_minicals'] == True) + { + $phpgw->preferences->add('calendar','display_minicals',$prefs['display_minicals']); + } + else + { + $phpgw->preferences->delete('calendar','display_minicals'); + } + + if ($prefs['print_black_white'] == True) + { + $phpgw->preferences->add('calendar','print_black_white',$prefs['print_black_white']); + } + else + { + $phpgw->preferences->delete('calendar','print_black_white'); + } + + $phpgw->preferences->save_repository(True); + + Header('Location: '.$phpgw->link('/preferences/index.php')); + $phpgw->common->phpgw_exit(); + } + } + + /* Private functions */ function read_holidays() { - $holiday = CreateObject('calendar.boholiday',$this->year,$this->owner); + $holiday = CreateObject('calendar.boholiday'); + $holiday->prepare_read_holidays($this->year,$this->owner); $this->cached_holidays = $holiday->read_holiday(); unset($holiday); } @@ -262,28 +521,26 @@ function fix_update_time(&$time_param) { - global $phpgw_info; - if ($this->prefs['common']['timeformat'] == '12') { - if ($time_param[ampm] == 'pm') + if ($time_param['ampm'] == 'pm') { - if ($time_param[hour] <> 12) + if ($time_param['hour'] <> 12) { - $time_param[hour] += 12; + $time_param['hour'] += 12; } } - elseif ($time_param[ampm] == 'am') + elseif ($time_param['ampm'] == 'am') { - if ($time_param[hour] == 12) + if ($time_param['hour'] == 12) { - $time_param[hour] -= 12; + $time_param['hour'] -= 12; } } - if($time_param[hour] > 24) + if($time_param['hour'] > 24) { - $time_param[hour] -= 12; + $time_param['hour'] -= 12; } } } @@ -472,30 +729,33 @@ { global $phpgw, $phpgw_info; - if($owner == 0) { $owner = $this->owner; } - if ($owner == $phpgw_info['user']['account_id'] || ($this->check_perms(PHPGW_ACL_PRIVATE,$owner) && $event->public==0) || ($event->public == 1)) + if($owner == 0) { - $is_private = False; + $owner = $this->owner; + } + if ($owner == $phpgw_info['user']['account_id'] || ($event->public==1) || ($this->check_perms(PHPGW_ACL_PRIVATE,$owner) && $event->public==0)) + { + return False; } elseif($event->public == 0) { - $is_private = True; + return True; } elseif($event->public == 2) { $is_private = True; $groups = $phpgw->accounts->memberships($owner); - while ($group = each($groups)) + while (list($key,$group) = each($groups)) { - if (strpos(' '.implode($event->groups,',').' ',$group[1]['account_id'])) + if (strpos(' '.implode($event->groups,',').' ',$group['account_id'])) { - $is_private = False; + return False; } } } else { - $is_private = False; + return False; } return $is_private; @@ -505,18 +765,37 @@ { if ($is_private) { - $str = 'private'; + return 'private'; } elseif (strlen($event->$field) > 19) { - $str = substr($event->$field, 0 , 19) . '...'; + return substr($event->$field, 0 , 19) . '...'; } else { - $str = $event->$field; + return $event->$field; } + } - return $str; + function get_week_label() + { + $first = $this->datetime->gmtdate($this->datetime->get_weekday_start($this->year, $this->month, $this->day)); + $last = $this->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; } function normalizeminutes(&$minutes) @@ -574,8 +853,7 @@ global $phpgw_info; $time = $this->splittime($fixed_time); - $str = ''; - $str .= $time['hour'].':'.((int)$time['minute']<=9?'0':'').$time['minute']; + $str = $time['hour'].':'.((int)$time['minute']<=9?'0':'').$time['minute']; if ($this->prefs['common']['timeformat'] == '12') { @@ -1285,12 +1563,18 @@ { if(isset($new_event->participants[$old_userid])) { -// echo "Modifying event for user ".$old_userid."
\n"; + if($this->debug) + { + echo "Modifying event for user ".$old_userid."
\n"; + } $this->modified[intval($old_userid)] = $new_status; } else { -// echo "Deleting user ".$old_userid." from the event
\n"; + if($this->debug) + { + echo "Deleting user ".$old_userid." from the event
\n"; + } $this->deleted[intval($old_userid)] = $old_status; } } @@ -1299,7 +1583,10 @@ { if(!isset($old_event->participants[$new_userid])) { -// echo "Adding event for user ".$new_userid."
\n"; + if($this->debug) + { + echo "Adding event for user ".$new_userid."
\n"; + } $this->added[$new_userid] = 'U'; $new_event->participants[$new_userid] = 'U'; } @@ -1322,8 +1609,6 @@ } } - - function _debug_array($data) { echo '
UI:'; diff --git a/calendar/inc/class.boholiday.inc.php b/calendar/inc/class.boholiday.inc.php index c6dae0c70d..d9c2ad90ef 100755 --- a/calendar/inc/class.boholiday.inc.php +++ b/calendar/inc/class.boholiday.inc.php @@ -15,6 +15,11 @@ class boholiday { var $public_functions = Array( + 'add' => True, + 'delete_holiday' => True, + 'delete_locale' => True, + 'accept_holiday' => True, + 'read_entries' => True, 'read_entry' => True, 'add_entry' => True, @@ -22,24 +27,196 @@ ); var $debug = False; + var $base_url = '/index.php'; + var $ui; var $so; - var $owner; - var $year; + + var $id; + var $total; + var $start; + var $query; + var $sort; var $locales = Array(); var $holidays; var $cached_holidays; - function boholiday($year,$owner=0) + function boholiday() { - global $phpgw_info; + global $phpgw_info, $locale, $start, $query, $sort, $order, $id; $this->so = CreateObject('calendar.soholiday'); - $this->year = $year; + if(isset($locale)) { $this->locales[] = $locale; } + + if(isset($start)) { $this->start = $start; } else { $this->start = 0; } + + if(isset($query)) { $this->query = $query; } + + if(isset($sort)) { $this->sort = $sort; } + + if(isset($order)) { $this->order = $order; } + + if(isset($id)) { $this->id = $id; } + + if($this->debug) + { + echo "Locale = ".$this->locales[0]."
\n"; + } + + $this->total = $this->so->holiday_total($this->locales[0],$this->query); + } + + /* Begin Calendar functions */ + function read_entry($id=0) + { + + if($this->debug) + { + echo "BO : Reading Holiday ID : ".$id."
\n"; + } + + if(!$id) + { + if(!$this->id) + { + return Array(); + } + else + { + $id = $this->id; + } + } + + return $this->so->read_holiday($id); + } + + function delete_holiday($id=0) + { + if(!$id) + { + if($this->id) + { + $id = $this->id; + } + } + + $this->ui = CreateObject('calendar.uiholiday'); + if($id) + { + $this->so->delete_holiday($id); + $this->ui->edit_locale(); + } + else + { + $this->ui->admin(); + } + } + + function delete_locale($locale='') + { + if(!$locale) + { + if($this->locales[0]) + { + $locale = $this->locales[0]; + } + } + + if($locale) + { + $this->so->delete_locale($locale); + } + $this->ui = CreateObject('calendar.uiholiday'); + $this->ui->admin(); + } + + function accept_holiday() + { + global $HTTP_REFERER; + global $name, $day, $month, $occurence, $dow, $observance; + + $send_back_to = str_replace('submitlocale','holiday_admin',$HTTP_REFERER); + if(!@$this->locales[0]) + { + Header('Location: '.$send_back_to); + } + + $send_back_to = str_replace('&locale='.$this->locales[0],'',$send_back_to); + $file = './holidays.'.$this->locales[0]; + if(!file_exists($file) && count($name)) + { + $c_holidays = count($name); + $fp = fopen($file,'w'); + for($i=0;$i<$c_holidays;$i++) + { + fwrite($fp,$this->locales[0]."\t".$name[$i]."\t".$day[$i]."\t".$month[$i]."\t".$occurence[$i]."\t".$dow[$i]."\t".$observance[$i]."\n"); + } + fclose($fp); + } + Header('Location: '.$send_back_to); + } + + function get_holiday_list($locale='', $sort='', $order='', $query='', $total='') + { + if(!$locale) + { + $locale = $this->locales[0]; + } + + if(!$sort) + { + $sort = $this->sort; + } + + if(!$order) + { + $order = $this->order; + } + + if(!$query) + { + $query = $this->query; + } + + return $this->so->read_holidays($locale,$query,$order); + } + + function get_locale_list($sort='', $order='', $query='') + { + if(!$sort) + { + $sort = $this->sort; + } + + if(!$order) + { + $order = $this->order; + } + + if(!$query) + { + $query = $this->query; + } + + return $this->so->get_locale_list($sort,$order,$query); + } + + function prepare_read_holidays($year=0,$owner=0) + { + global $phpgw_info; + + if($year==0) + { + $this->year = date('Y'); + } + else + { + $this->year = $year; + } if($owner == 0) { @@ -48,8 +225,8 @@ else { $this->owner = $owner; - } - + } + if(@$phpgw_info['user']['preferences']['common']['country']) { $this->locales[] = $phpgw_info['user']['preferences']['common']['country']; @@ -83,11 +260,10 @@ } } } - - /* Begin Calendar functions */ + function auto_load_holidays($locale) { - if($this->so->count_of_holidays($locale) == 0) + if($this->so->holiday_total($locale) == 0) { global $phpgw_info, $HTTP_HOST, $SERVER_PORT; @@ -149,6 +325,49 @@ } } + function save_holiday($holiday) + { + $this->so->save_holiday($holiday); + } + + function add() + { + global $phpgw, $submit, $holiday, $locale; + + if(@$submit) + { + if(empty($holiday['mday'])) + { + $holiday['mday'] = 0; + } + if(!isset($this->bo->locales[0]) || $this->bo->locales[0]=='') + { + $this->bo->locales[0] = $holiday['locale']; + } + elseif(!isset($holiday['locale']) || $holiday['locale']=='') + { + $holiday['locale'] = $this->bo->locales[0]; + } + if(!isset($holiday['hol_id'])) + { + $holiday['hol_id'] = $this->bo->id; + } + + // Still need to put some validation in here..... + + $this->ui = CreateObject('calendar.uiholiday'); + if (is_array($errors)) + { + $this->ui->add($errors,$holiday); + } + else + { + $this->so->save_holiday($holiday); + $this->ui->edit_locale(); + } + } + } + function sort_holidays_by_date($holidays) { $c_holidays = count($holidays); diff --git a/calendar/inc/class.socalendar.inc.php b/calendar/inc/class.socalendar.inc.php index b9668014f7..5980e3a6a6 100755 --- a/calendar/inc/class.socalendar.inc.php +++ b/calendar/inc/class.socalendar.inc.php @@ -124,9 +124,47 @@ echo "SO list_repeated_events : SQL : ".$sql."
\n"; } - $events = $this->get_event_ids(True,$sql); + return $this->get_event_ids(True,$sql); + } - return $events; + function list_events_keyword($keywords) + { + $this->makeobj(); + + $sql = 'AND (phpgw_cal_user.cal_login='.$this->owner.') '; + + $words = split(' ',$keywords); + for ($i=0;$i0) + { + $sql .= ' OR '; + } + $sql .= "(UPPER(phpgw_cal.title) LIKE UPPER('%".$words[$i]."%') OR " + . "UPPER(phpgw_cal.description) LIKE UPPER('%".$words[$i]."%'))"; + + if($i==count($words) - 1) + { + $sql .= ') '; + } + } + + if(strpos($this->filter,'private')) + { + $sql .= 'AND phpgw_cal.is_public=0 '; + } + + if($this->cat_id) + { + $sql .= 'AND phpgw_cal.category = '.$this->cat_id.' '; + } + + $sql .= 'ORDER BY phpgw_cal.datetime ASC, phpgw_cal.edatetime ASC, phpgw_cal.priority ASC'; + return $this->get_event_ids(False,$sql); } function read_from_store($startYear,$startMonth,$startDay,$endYear='',$endMonth='',$endDay='') diff --git a/calendar/inc/class.soholiday.inc.php b/calendar/inc/class.soholiday.inc.php index e8a6b0a583..fac6bc1548 100755 --- a/calendar/inc/class.soholiday.inc.php +++ b/calendar/inc/class.soholiday.inc.php @@ -14,6 +14,7 @@ class soholiday { + var $debug = False; var $db; function soholiday() @@ -26,21 +27,50 @@ /* Begin Holiday functions */ function save_holiday($holiday) { - if(isset($holiday['hol_id']) && $holiday['hol_id']) + if(@$holiday['hol_id']) { -// echo "Updating LOCALE='".$holiday['locale']."' NAME='".$holiday['name']."' extra=(".$holiday['mday'].'/'.$holiday['month_num'].'/'.$holiday['occurence'].'/'.$holiday['dow'].'/'.$holiday['observance_rule'].")
\n"; + if($this->debug) + { + echo "Updating LOCALE='".$holiday['locale']."' NAME='".$holiday['name']."' extra=(".$holiday['mday'].'/'.$holiday['month_num'].'/'.$holiday['occurence'].'/'.$holiday['dow'].'/'.$holiday['observance_rule'].")
\n"; + } $sql = "UPDATE phpgw_cal_holidays SET name='".$holiday['name']."', mday=".$holiday['mday'].', month_num='.$holiday['month_num'].', occurence='.$holiday['occurence'].', dow='.$holiday['dow'].', observance_rule='.intval($holiday['observance_rule']).' WHERE hol_id='.$holiday['hol_id']; } else { -// echo "Inserting LOCALE='".$holiday['locale']."' NAME='".$holiday['name']."' extra=(".$holiday['mday'].'/'.$holiday['month_num'].'/'.$holiday['occurence'].'/'.$holiday['dow'].'/'.$holiday['observance_rule'].")
\n"; + if($this->debug) + { + echo "Inserting LOCALE='".$holiday['locale']."' NAME='".$holiday['name']."' extra=(".$holiday['mday'].'/'.$holiday['month_num'].'/'.$holiday['occurence'].'/'.$holiday['dow'].'/'.$holiday['observance_rule'].")
\n"; + } $sql = 'INSERT INTO phpgw_cal_holidays(locale,name,mday,month_num,occurence,dow,observance_rule) ' . "VALUES('".strtoupper($holiday['locale'])."','".$holiday['name']."',".$holiday['mday'].','.$holiday['month_num'].','.$holiday['occurence'].','.$holiday['dow'].','.intval($holiday['observance_rule']).")"; } $this->db->query($sql,__LINE__,__FILE__); } - function read_holidays($locales='') + function store_to_array(&$holidays) + { + global $phpgw; + + while($this->db->next_record()) + { + $holidays[] = Array( + 'index' => $this->db->f('hol_id'), + 'locale' => $this->db->f('locale'), + 'name' => $phpgw->strip_html($this->db->f('name')), + 'day' => intval($this->db->f('mday')), + 'month' => intval($this->db->f('month_num')), + 'occurence' => intval($this->db->f('occurence')), + 'dow' => intval($this->db->f('dow')), + 'observance_rule' => $this->db->f('observance_rule') + ); + if($this->debug) + { + echo "Holiday ID: ".$this->db->f("hol_id")."
\n"; + } + } + } + + function read_holidays($locales='',$query='',$order='') { global $phpgw; @@ -50,7 +80,46 @@ { return $holidays; } - + + $sql = $this->build_query($locales,$query,$order); + + if($this->debug) + { + echo "Read Holidays : ".$sql."
\n"; + } + + $this->db->query($sql,__LINE__,__FILE__); + $this->store_to_array($holidays); + return $holidays; + } + + function read_holiday($id) + { + $holidays = Array(); + if($this->debug) + { + echo "Reading Holiday ID : ".$id."
\n"; + } + $this->db->query('SELECT * FROM phpgw_cal_holidays WHERE hol_id='.$id,__LINE__,__FILE__); + $this->store_to_array($holidays); + @reset($holidays); + return $holidays[0]; + } + + function delete_holiday($id) + { + $this->db->query('DELETE FROM phpgw_cal_holidays WHERE hol_id='.$id,__LINE__,__FILE__); + } + + function delete_locale($locale) + { + $this->db->query("DELETE FROM phpgw_cal_holidays WHERE locale='".$locale."'",__LINE__,__FILE__); + } + + /* Private functions */ + function build_query($locales,$query='',$order='') + { + if(is_string($locales)) { $find = "'".$locales."'"; @@ -68,32 +137,62 @@ } } - $sql = 'SELECT * FROM phpgw_cal_holidays WHERE locale in ('.$find.')'; - - $this->db->query($sql,__LINE__,__FILE__); - while($this->db->next_record()) + $querymethod = ''; + if($query) { - $holidays[] = Array( - 'index' => $this->db->f('hol_id'), - 'locale' => $this->db->f('locale'), - 'name' => $phpgw->strip_html($this->db->f('name')), - 'day' => intval($this->db->f('mday')), - 'month' => intval($this->db->f('month_num')), - 'occurence' => intval($this->db->f('occurence')), - 'dow' => intval($this->db->f('dow')), - 'observance_rule' => $this->db->f('observance_rule') - ); + $querymethod = " AND name like '%".$query."%'"; } - return $holidays; + + if($order) + { + $querymethod .= ' ORDER BY '.$order; + } + + return 'SELECT * FROM phpgw_cal_holidays WHERE locale in ('.$find.')'.$querymethod; } - /* Private functions */ - function count_of_holidays($locale) + function get_locale_list($sort='', $order='', $query='') { - $sql = "SELECT count(*) FROM phpgw_cal_holidays WHERE locale='".$locale."'"; + $querymethod = ''; + if($query) + { + $querymethod .= " WHERE locale like '%".$query."%'"; + } + + if($order) + { + $querymethod .= ' ORDER BY '.$order; + } + $this->db->query("SELECT DISTINCT locale FROM phpgw_cal_holidays".$querymethod,__LINE__,__FILE__); + while($this->db->next_record()) + { + $locale[] = $this->db->f('locale'); + } + return $locale; + } + + function holiday_total($locale,$query='') + { + $querymethod=''; + if($query) + { + $querymethod = " AND name like '%".$query."%'"; + } + $sql = "SELECT count(*) FROM phpgw_cal_holidays WHERE locale='".$locale."'".$querymethod; + + if($this->debug) + { + echo "HOLIDAY_TOTAL : ".$sql."
\n"; + } + $this->db->query($sql,__LINE__,__FILE__); $this->db->next_record(); - return $this->db->f(0); + $retval = intval($this->db->f(0)); + if($this->debug) + { + echo 'Total Holidays for : '.$locale.' : '.$retval."
\n"; + } + return $retval; } } ?> diff --git a/calendar/inc/class.uicalendar.inc.php b/calendar/inc/class.uicalendar.inc.php index 78aba50afb..c57ba742f4 100755 --- a/calendar/inc/class.uicalendar.inc.php +++ b/calendar/inc/class.uicalendar.inc.php @@ -36,14 +36,17 @@ 'week' => True, 'year' => True, 'view' => True, - 'add' => True, 'edit' => True, - 'update' => True, + 'add' => True, 'delete' => True, 'preferences' => True, 'day' => True, 'edit_status' => True, 'set_action' => True, + 'planner' => True, + 'matrixselect' => True, + 'viewmatrix' => True, + 'search' => True, 'header' => True, 'footer' => True ); @@ -170,7 +173,10 @@ @reset($daily); while(list($date,$day_params) = each($daily)) { -// echo 'Mini-Cal Date : '.$date."
\n"; + if($this->debug) + { + echo 'Mini-Cal Date : '.$date."
\n"; + } $year = intval(substr($date,0,4)); $month = intval(substr($date,4,2)); $day = intval(substr($date,6,2)); @@ -206,13 +212,11 @@ return $return_value; } - function index() + function index($params='') { - global $phpgw; + global $phpgw, $phpgw_info; - Header('Location: '. $this->page()); - $phpgw_info['flags']['nofooter'] = True; - $phpgw->common->phpgw_exit(); + Header('Location: '. $this->page('',$params)); } function month() @@ -221,21 +225,14 @@ $this->bo->read_holidays(); - $p = CreateObject('phpgwapi.Template',$this->template_dir); - $p->set_unknowns('remove'); - - $templates = Array( - 'index_t' => 'index.tpl' - ); - - $p->set_file($templates); - $m = mktime(0,0,0,$this->bo->month,1,$this->bo->year); if (!$this->bo->printer_friendly) { unset($phpgw_info['flags']['noheader']); unset($phpgw_info['flags']['nonavbar']); + unset($phpgw_info['flags']['noappheader']); + unset($phpgw_info['flags']['noappfooter']); $phpgw->common->phpgw_header(); $printer = ''; $param = '&year='.$this->bo->year.'&month='.$this->bo->month.'&friendly=1'; @@ -247,7 +244,7 @@ { $printer = ''; $print = ''; - if($this->bo->prefs['calendar']['display_minicals'] == 'Y' || $this->bo->prefs['calendar']['display_minicals']) + if(@$this->bo->prefs['calendar']['display_minicals']) { $minical_prev = $this->mini_calendar(1,$this->bo->month - 1,$this->bo->year,'day'); $minical_next = $this->mini_calendar(1,$this->bo->month + 1,$this->bo->year,'day'); @@ -257,25 +254,28 @@ $minical_prev = ''; $minical_next = ''; } + $phpgw_info['flags']['nofooter'] = True; } $var = Array( 'printer_friendly' => $printer, 'bg_text' => $phpgw_info['theme']['bg_text'], 'small_calendar_prev' => $minical_prev, - 'month_identifier' => lang(strftime("%B",$m)) . ' ' . $this->bo->year, + 'month_identifier' => lang(strftime("%B",$m)).' '.$this->bo->year, 'username' => $phpgw->common->grab_owner_name($this->bo->owner), 'small_calendar_next' => $minical_next, 'large_month' => $this->display_month($this->bo->month,$this->bo->year,True,$this->bo->owner), 'print' => $print ); + $p = CreateObject('phpgwapi.Template',$this->template_dir); + $p->set_unknowns('remove'); + $templates = Array( + 'index_t' => 'index.tpl' + ); + $p->set_file($templates); $p->set_var($var); $p->pparse('out','index_t'); - if($this->bo->printer_friendly) - { - $phpgw_info['flags']['nofooter'] = True; - } } function week() @@ -288,42 +288,15 @@ $next = $this->bo->datetime->makegmttime(0,0,0,$this->bo->month,$this->bo->day + 7,$this->bo->year); $prev = $this->bo->datetime->makegmttime(0,0,0,$this->bo->month,$this->bo->day - 7,$this->bo->year); - $nextmonth = $this->bo->datetime->makegmttime(0,0,0,$this->bo->month + 1,1,$this->bo->year); - $prevmonth = $this->bo->datetime->makegmttime(0,0,0,$this->bo->month - 1,1,$this->bo->year); - - $first = $this->bo->datetime->gmtdate($this->bo->datetime->get_weekday_start($this->bo->year, $this->bo->month, $this->bo->day)); - $last = $this->bo->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']; - - $p = CreateObject('phpgwapi.Template',$this->template_dir); - $templates = Array( - 'week_t' => 'week.tpl' - ); - - $p->set_file($templates); - if (!$this->bo->printer_friendly) { unset($phpgw_info['flags']['noheader']); unset($phpgw_info['flags']['nonavbar']); $phpgw->common->phpgw_header(); $printer = ''; - $prev_week_link = '<<'; - $next_week_link = '>>'; - $param = '&year='.$this->bo->year.'&month='.$this->bo->month.'&day='.$this->bo->day.'&friendly=1'; - $print = '[".lang('Printer Friendly').']'; + $prev_week_link = '<<'; + $next_week_link = '>>'; + $print = '[".lang('Printer Friendly').']'; $minical_this = $this->mini_calendar($this->bo->day,$this->bo->month,$this->bo->year,'day','none',False); $minical_prev = $this->mini_calendar(1,$this->bo->month - 1,$this->bo->year,'day','left',False); $minical_next = $this->mini_calendar(1,$this->bo->month + 1,$this->bo->year,'day','right',False); @@ -334,7 +307,7 @@ $prev_week_link = '<<'; $next_week_link = '>>'; $print = ''; - if($this->bo->prefs['calendar']['display_minicals'] == 'Y' || $this->bo->prefs['calendar']['display_minicals']) + if(@$this->bo->prefs['calendar']['display_minicals']) { $minical_this = $this->mini_calendar($this->bo->day,$this->bo->month,$this->bo->year,'day'); $minical_prev = $this->mini_calendar(1,$this->bo->month - 1,$this->bo->year,'day'); @@ -346,6 +319,7 @@ $minical_prev = ''; $minical_next = ''; } + $phpgw_info['flags']['nofooter'] = True; } $var = Array( @@ -354,7 +328,7 @@ 'small_calendar_prev' => $minical_prev, 'prev_week_link' => $prev_week_link, 'small_calendar_this' => $minical_this, - 'week_identifier' => $week_id, + 'week_identifier' => $this->bo->get_week_label(), 'next_week_link' => $next_week_link, 'username' => $phpgw->common->grab_owner_name($this->bo->owner), 'small_calendar_next' => $minical_next, @@ -362,234 +336,214 @@ 'print' => $print ); + $p = CreateObject('phpgwapi.Template',$this->template_dir); + $templates = Array( + 'week_t' => 'week.tpl' + ); + + $p->set_file($templates); $p->set_var($var); $p->pparse('out','week_t'); - flush(); - if($this->bo->printer_friendly) - { - $phpgw_info['flags']['nofooter'] = True; - } } function year() { global $phpgw, $phpgw_info; - - if ($this->bo->printer_friendly) - { - echo ''; - } - else + + if(!$this->bo->printer_friendly) { unset($phpgw_info['flags']['noheader']); unset($phpgw_info['flags']['nonavbar']); $phpgw->common->phpgw_header(); - } -?> - -
- - -bo->printer_friendly) - { - echo ' - - -bo->printer_friendly) - { - echo ' - - -bo->printer_friendly) - { + $print = ''; + $left_link = '<<'; + $right_link = '>>'; $link = 'day.php'; + $printer = '['.lang('Printer Friendly').']'; } else { + $print = ''; + $left_link = ''; + $right_link = ''; $link = ''; - } - for($i=1;$i<13;$i++) - { - echo ''; - } - } -?> - -
<<'; - } -?> - - bo->year; ?> - >>'; - } -?> -
'; - echo $this->mini_calendar($i,$i,$this->bo->year,$link,'none',False); - if($i % 3 == 0) - { - echo '
-
-bo->printer_friendly) - { + $printer = ''; $phpgw_info['flags']['nofooter'] = True; } - else + + $var = Array( + 'print' => $print, + 'left_link' => $left_link, + 'font' => $phpgw_info['theme']['font'], + 'year_text' => $this->bo->year, + 'right_link'=> $right_link, + 'printer_friendly'=> $printer + ); + + $p = CreateObject('phpgwapi.Template',$this->template_dir); + $templates = Array( + 'year_t' => 'year.tpl' + ); + $p->set_file($templates); + $p->set_block('year_t','year','year'); + $p->set_block('year_t','month','month'); + $p->set_block('year_t','month_sep','month_sep'); + $p->set_var($var); + + for($i=1;$i<=12;$i++) { - echo ' ['.lang('Printer Friendly').']'; + $p->set_var('mini_month',$this->mini_calendar(1,$i,$this->bo->year,$link,'none',False)); + $p->parse('row','month',True); + $p->set_var('mini_month',''); + if(($i % 3) == 0) + { + $p->parse('row','month_sep',True); + } } + $p->pparse('out','year_t'); } - function view() + function view($vcal_id=0) { global $phpgw,$phpgw_info,$cal_id,$submit,$referer; - unset($phpgw_info['flags']['noheader']); - unset($phpgw_info['flags']['nonavbar']); - $phpgw->common->phpgw_header(); + unset($phpgw_info['flags']['noheader']); + unset($phpgw_info['flags']['nonavbar']); + $phpgw->common->phpgw_header(); + + echo '
'; + if(!@$cal_id && $vcal_id) + { + $cal_id = $vcal_id; + } + + // First, make sure they have permission to this entry if ($cal_id < 1) { - echo lang('Invalid entry id.'); - $phpgw->common->phpgw_footer(); - $phpgw->common->phpgw_exit(); + echo lang('Invalid entry id.').'
'; + return; } - if($this->bo->check_perms(PHPGW_ACL_READ) == False) + if(!$this->bo->check_perms(PHPGW_ACL_READ)) { - echo lang('You do not have permission to read this record!'); - $phpgw->common->phpgw_footer(); - $phpgw->common->phpgw_exit(); + echo lang('You do not have permission to read this record!').''; + return; } $event = $this->bo->read_entry($cal_id); + + if(!isset($event->id)) + { + echo lang("Sorry, this event does not exist").'.'.''; + return; + } + + echo $this->view_event($event); - echo '
'; - - if(isset($event->id)) + if ($this->bo->owner == $event->owner && $this->bo->check_perms(PHPGW_ACL_EDIT) == True) { - echo $this->view_event($event); - - $thisyear = $event->start->year; - $thismonth = $event->start->month; - $thisday = $event->start->mday; - - $p = CreateObject('phpgwapi.Template',$this->template_dir); - - $templates = Array( - 'form_button' => 'form_button_script.tpl' + $p = CreateObject('phpgwapi.Template',$this->template_dir); + $templates = Array( + 'form_button' => 'form_button_script.tpl' + ); + $p->set_file($templates); + + $var = Array( + 'action_url_button' => $this->page('edit','&cal_id='.$cal_id), + 'action_text_button' => lang('Edit'), + 'action_confirm_button' => '', + 'action_extra_field' => '' ); - $p->set_file($templates); - - if ($this->bo->owner == $event->owner && $this->bo->check_perms(PHPGW_ACL_EDIT) == True) - { - $var = Array( - 'action_url_button' => $this->page('edit','&cal_id='.$cal_id), - 'action_text_button' => lang('Edit'), - 'action_confirm_button' => '', - 'action_extra_field' => '' - ); - $p->set_var($var); - echo $p->fp('out','form_button'); - } - - if ($this->bo->owner == $event->owner && $this->bo->check_perms(PHPGW_ACL_DELETE) == True) - { - $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'); - } + $p->set_var($var); + echo $p->fp('out','form_button'); } - else + + if ($this->bo->owner == $event->owner && $this->bo->check_perms(PHPGW_ACL_DELETE) == True) { - echo lang("Sorry, the owner has just deleted this event").'.'; + if(!is_object($p)) + { + $p = CreateObject('phpgwapi.Template',$this->template_dir); + $templates = Array( + 'form_button' => 'form_button_script.tpl' + ); + $p->set_file($templates); + } + + $var = Array( + 'action_url_button' => $this->page('delete','&cal_id='.$cal_id), + 'action_text_button' => lang('Delete'), + 'action_confirm_button' => "onClick=\"return confirm('".lang("Are you sure\\nyou want to\\ndelete this entry ?\\n\\nThis will delete\\nthis entry for all users.")."')\"", + 'action_extra_field' => '' + ); + $p->set_var($var); + echo $p->fp('out','form_button'); } - echo '
'; + echo ''; } - function edit() + function edit($cd=0,$readsess=0) { - global $phpgw, $phpgw_info, $cal_id, $readsess, $hour, $minute, $cd; + global $phpgw, $phpgw_info, $cal_id, $hour, $minute; - $sb = CreateObject('phpgwapi.sbox'); - if ($this->bo->prefs['common']['timeformat'] == '12') + if(!$this->bo->check_perms(PHPGW_ACL_EDIT)) { - $hourformat = 'h'; + $this->no_edit(); } - else + + if(@$readsess) { - $hourformat = 'H'; + $event = $this->bo->restore_from_appsession; + $can_edit = True; } - - if ($cal_id > 0) + elseif($cal_id) { $event = $this->bo->read_entry(intval($cal_id)); $can_edit = $this->bo->can_user_edit($event); - if($can_edit == False) + if(!$can_edit) { - header('Location: '.$this->page('view','&cal_id='.$cal_id)); + $this->view($cal_id); } } - elseif(isset($readsess)) + $this->edit_form($event); + } + + function add($cd,$readsess) + { + global $phpgw, $phpgw_info, $cal_id, $hour, $minute; + + if(!$this->bo->check_perms(PHPGW_ACL_ADD)) + { + $this->index(); + } + + if(isset($readsess)) { $event = $this->bo->restore_from_appsession; - if($event->owner == 0) { $this->bo->add_attribute('owner',$this->bo->owner); } - $can_edit = True; } else { - if(!$this->bo->check_perms(PHPGW_ACL_ADD)) - { - header('Location: '.$this->page('view','&cal_id='.$cal_id)); - } - $this->bo->event_init(); $this->bo->add_attribute('id',0); $can_edit = True; - if (!isset($hour)) - { - $thishour = 0; - } - else - { - $thishour = (int)$hour; - } - - if (!isset($minute)) - { - $thisminute = 00; - } - else - { - $thisminute = (int)$minute; - } - + $thishour = (isset($hour)?(int)$hour:0); + $thisminute = (isset($minute)?(int)$minute:0); $this->bo->set_start($this->bo->year,$this->bo->month,$this->bo->day,$thishour,$thisminute,0); $this->bo->set_end($this->bo->year,$this->bo->month,$this->bo->day,$thishour,$thisminute,0); $this->bo->set_title(''); $this->bo->set_description(''); $this->bo->add_attribute('priority',2); - if($this->bo->prefs['calendar']['default_private'] == 'Y' || $this->bo->prefs['calendar']['default_private'] == True) + if(@$this->bo->prefs['calendar']['default_private']) { $this->bo->set_class(False); } @@ -597,536 +551,11 @@ { $this->bo->set_class(True); } - + $this->bo->add_attribute('participants['.$this->bo->owner.']','A'); $this->bo->set_recur_none(); $event = $this->bo->get_cached_event(); } - - $start = mktime($event->start->hour,$event->start->min,$event->start->sec,$event->start->month,$event->start->mday,$event->start->year) - $this->bo->datetime->tz_offset; - $end = mktime($event->end->hour,$event->end->min,$event->end->sec,$event->end->month,$event->end->mday,$event->end->year) - $this->bo->datetime->tz_offset; - - unset($phpgw_info['flags']['noheader']); - unset($phpgw_info['flags']['nonavbar']); - $phpgw->common->phpgw_header(); - - $p = CreateObject('phpgwapi.Template',$this->template_dir); - $templates = Array( - 'edit' => 'edit.tpl', - 'form_button' => 'form_button_script.tpl' - ); - $p->set_file($templates); - $p->set_block('edit','edit_entry','edit_entry'); - $p->set_block('edit','list','list'); - $p->set_block('edit','hr','hr'); - - if($cal_id > 0) - { - $action = lang('Calendar - Edit'); - } - else - { - $action = lang('Calendar - Add'); - } - - if($cd) - { - $errormsg = $phpgw->common->check_code($cd); - } - else - { - $errormsg = ''; - } - - $common_hidden = ''."\n" - . ''."\n"; - - $vars = Array( - 'font' => $phpgw_info['theme']['font'], - 'bg_color' => $phpgw_info['theme']['bg_text'], - 'calendar_action' => $action, - 'action_url' => $this->page('update'), - 'common_hidden' => $common_hidden, - 'errormsg' => $errormsg - ); - - $p->set_var($vars); - -// Brief Description - $var[] = Array( - 'field' => lang('Title'), - 'data' => '' - ); - -// Full Description - $var[] = Array( - 'field' => lang('Full Description'), - 'data' => '' - ); - -// Display Categories - $var[] = Array( - 'field' => lang('Category'), - 'data' => '' - ); - -// Date - $day_html = $sb->getDays('start[mday]',intval($phpgw->common->show_date($start,'d'))); - $month_html = $sb->getMonthText('start[month]',intval($phpgw->common->show_date($start,'n'))); - $year_html = $sb->getYears('start[year]',intval($phpgw->common->show_date($start,'Y')),intval($phpgw->common->show_date($start,'Y'))); - $var[] = Array( - 'field' => lang('Start Date'), - 'data' => $phpgw->common->dateformatorder($year_html,$month_html,$day_html) - ); - -// Time - $amsel = ' checked'; $pmsel = ''; - if ($this->bo->prefs['common']['timeformat'] == '12') - { - if ($event->start->hour >= 12) - { - $amsel = ''; $pmsel = ' checked'; - } - } - $str = ':'; - if ($this->bo->prefs['common']['timeformat'] == '12') - { - $str .= 'am'; - $str .= 'pm'; - } - $var[] = Array( - 'field' => lang('Start Time'), - 'data' => $str - ); - -// End Date - $day_html = $sb->getDays('end[mday]',intval($phpgw->common->show_date($end,'d'))); - $month_html = $sb->getMonthText('end[month]',intval($phpgw->common->show_date($end,'n'))); - $year_html = $sb->getYears('end[year]',intval($phpgw->common->show_date($end,'Y')),intval($phpgw->common->show_date($end,'Y'))); - $var[] = Array( - 'field' => lang('End Date'), - 'data' => $phpgw->common->dateformatorder($year_html,$month_html,$day_html) - ); - -// End Time - $amsel = ' checked'; $pmsel = ''; - if ($this->bo->prefs['common']['timeformat'] == '12') - { - if ($event->end->hour >= 12) - { - $amsel = ''; $pmsel = ' checked'; - } - } - - $str = ':'; - if ($this->bo->prefs['common']['timeformat'] == '12') - { - $str .= 'am'; - $str .= 'pm'; - } - $var[] = Array( - 'field' => lang("End Time"), - 'data' => $str - ); - -// Priority - $var[] = Array( - 'field' => lang('Priority'), - 'data' => $sb->getPriority('cal[priority]',$event->priority) - ); - -// Access - $str = 'public != True) - { - $str .= ' checked'; - } - $str .= '>'; - $var[] = Array( - 'field' => lang('Private'), - 'data' => $str - ); - - function build_part_list(&$users,$accounts,$owner) - { - global $phpgw; - if($accounts == False) - { - return; - } - while(list($index,$id) = each($accounts)) - { - if(intval($id) == $owner) - { - continue; - } - if(!isset($users[intval($id)])) - { - if($phpgw->accounts->exists(intval($id)) == True) - { - $users[intval($id)] = $phpgw->common->grab_owner_name(intval($id)); - } - if($phpgw->accounts->get_type(intval($id)) == 'g') - { - build_part_list($users,$phpgw->acl->get_ids_for_location(intval($id),1,'phpgw_group'),$owner); - } - } - } - } - -// Participants - $accounts = $phpgw->acl->get_ids_for_location('run',1,'calendar'); - $users = Array(); - build_part_list($users,$accounts,$owner); - while(list($key,$status) = each($event->participants)) - { - $parts[$key] = ' selected'; - } - - $str = "\n".' '; - $var[] = Array( - 'field' => lang('Participants'), - 'data' => $str - ); - -// I Participate - $str = ' 0) && isset($event->participants[$this->bo->owner])) || !isset($cal_id)) - { - $str .= ' checked'; - } - $str .= '>'; - $var[] = Array( - 'field' => $phpgw->common->grab_owner_name($this->bo->owner).' '.lang('Participates'), - 'data' => $str - ); - - for($i=0;$ioutput_template_array($p,'row','list',$var[$i]); - } - - unset($var); - -// Repeat Type - $p->set_var('hr_text','
'); - $p->parse('row','hr',True); - $p->set_var('hr_text','
'.lang('Repeating Event Information').'

'); - $p->parse('row','hr',True); - $rpt_type = Array( - MCAL_RECUR_NONE, - MCAL_RECUR_DAILY, - MCAL_RECUR_WEEKLY, - MCAL_RECUR_MONTHLY_WDAY, - MCAL_RECUR_MONTHLY_MDAY, - MCAL_RECUR_YEARLY - ); - $rpt_type_out = Array( - MCAL_RECUR_NONE => 'None', - MCAL_RECUR_DAILY => 'Daily', - MCAL_RECUR_WEEKLY => 'Weekly', - MCAL_RECUR_MONTHLY_WDAY => 'Monthly (by day)', - MCAL_RECUR_MONTHLY_MDAY => 'Monthly (by date)', - MCAL_RECUR_YEARLY => 'Yearly' - ); - $str = ''; - $var[] = Array( - 'field' => lang('Repeat Type'), - 'data' => $str - ); - - $str = 'recur_enddate->year != 0 && $event->recur_enddate->month != 0 && $event->recur_enddate->mday != 0) - { - $str .= ' checked'; - $recur_end = mktime($event->recur_enddate->hour,$event->recur_enddate->min,$event->recur_enddate->sec,$event->recur_enddate->month,$event->recur_enddate->mday,$event->recur_enddate->year) - $this->bo->datetime->tz_offset; - } - else - { - $recur_end = mktime($event->start->hour,$event->start->min,$event->start->sec,$event->start->month,$event->start->mday,$event->start->year) + 86400 - $this->bo->datetime->tz_offset; - } - - $str .= '>'.lang('Use End Date').' '; - - $day_html = $sb->getDays('recur_enddate[mday]',intval($phpgw->common->show_date($recur_end,'d'))); - $month_html = $sb->getMonthText('recur_enddate[month]',intval($phpgw->common->show_date($recur_end,'n'))); - $year_html = $sb->getYears('recur_enddate[year]',intval($phpgw->common->show_date($recur_end,'Y')),intval($phpgw->common->show_date($recur_end,'Y'))); - $str .= $phpgw->common->dateformatorder($year_html,$month_html,$day_html); - - $var[] = Array( - 'field' => lang('Repeat End Date'), - 'data' => $str - ); - - $str = 'recur_data & MCAL_M_SUNDAY) ?' checked':'').'> '.lang('Sunday').' '; - $str .= 'recur_data & MCAL_M_MONDAY) ?' checked':'').'> '.lang('Monday').' '; - $str .= 'recur_data & MCAL_M_TUESDAY) ?' checked':'').'> '.lang('Tuesday').' '; - $str .= 'recur_data & MCAL_M_WEDNESDAY) ?' checked':'').'> '.lang('Wednesday').'
'; - $str .= 'recur_data & MCAL_M_THURSDAY) ?' checked':'').'> '.lang('Thursday').' '; - $str .= 'recur_data & MCAL_M_FRIDAY) ?' checked':'').'> '.lang('Friday').' '; - $str .= 'recur_data & MCAL_M_SATURDAY) ?' checked':'').'> '.lang('Saturday').' '; - - $var[] = Array( - 'field' => lang('Repeat Day').'
'.lang('(for weekly)'), - 'data' => $str - ); - - $var[] = Array( - 'field' => lang('Frequency'), - 'data' => '' - ); - - for($i=0;$ioutput_template_array($p,'row','list',$var[$i]); - } - - $p->set_var('submit_button',lang('Submit')); - - if ($cal_id > 0) - { - $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.")."')\""; - $var = Array( - 'action_url_button' => $action_url_button, - 'action_text_button' => $action_text_button, - 'action_confirm_button' => $action_confirm_button, - 'action_extra_field' => '' - ); - $p->set_var($var); - $p->parse('delete_button','form_button'); - } - else - { - $p->set_var('delete_button',''); - } - $p->pparse('out','edit_entry'); - } - - function update() - { - global $phpgw, $phpgw_info, $readsess, $cal, $participants, $start, $end, $recur_enddate; - - if(!isset($readsess)) - { - $this->bo->fix_update_time($start); - $this->bo->fix_update_time($end); - - if(!isset($cal[private])) - { - $cal[private] = 'public'; - } - - $is_public = ($private == 'public'?1:0); - $this->bo->event_init(); - $this->bo->set_category($cal[category]); - $this->bo->set_title($cal[title]); - $this->bo->set_description($cal[description]); - $this->bo->set_start($start[year],$start[month],$start[mday],$start[hour],$start[min],0); - $this->bo->set_end($end[year],$end[month],$end[mday],$end[hour],$end[min],0); - $this->bo->set_class($is_public); - if($cal[id] != 0) - { - $this->bo->add_attribute('id',$cal[id]); - } - - if($cal[rpt_use_end] != 'y') - { - $recur_enddate[year] = 0; - $recur_enddate[month] = 0; - $recur_enddate[mday] = 0; - } - $cal[recur_data] = $cal[rpt_sun] + $cal[rpt_mon] + $cal[rpt_tue] + $cal[rpt_wed] + $cal[rpt_thu] + $cal[rpt_fri] + $cal[rpt_sat]; - - switch($cal[recur_type]) - { - case MCAL_RECUR_NONE: - $this->bo->set_recur_none(); - break; - case MCAL_RECUR_DAILY: - $this->bo->set_recur_daily($recur_enddate[year],$recur_enddate[month],$recur_enddate[mday],$cal[recur_interval]); - break; - case MCAL_RECUR_WEEKLY: - $this->bo->set_recur_weekly($recur_enddate[year],$recur_enddate[month],$recur_enddate[mday],$cal[recur_interval],$cal[recur_data]); - break; - case MCAL_RECUR_MONTHLY_MDAY: - $this->bo->set_recur_monthly_mday($recur_enddate[year],$recur_enddate[month],$recur_enddate[mday],$cal[recur_interval]); - break; - case MCAL_RECUR_MONTHLY_WDAY: - $this->bo->set_recur_monthly_wday($recur_enddate[year],$recur_enddate[month],$recur_enddate[mday],$cal[recur_interval]); - break; - case MCAL_RECUR_YEARLY: - $this->bo->set_recur_yearly($recur_enddate[year],$recur_enddate[month],$recur_enddate[mday],$cal[recur_interval]); - break; - } - - $parts = $participants; - $minparts = min($participants); - $part = Array(); - for($i=0;$iaccounts->get_type(intval($parts[$i])); - if($acct_type == 'u') - { - $part[$parts[$i]] = 1; - } - elseif($acct_type == 'g') - { - /* This pulls ALL users of a group and makes them as participants to the event */ - /* I would like to turn this back into a group thing. */ - $acct = CreateObject('phpgwapi.accounts',intval($parts[$i])); - $members = $acct->members(intval($parts[$i])); - unset($acct); - if($members == False) - { - continue; - } - while($member = each($members)) - { - $part[$member[1]['account_id']] = 1; - } - } - } - - @reset($part); - while(list($key,$value) = each($part)) - { - $this->bo->add_attribute('participants['.$key.']','U'); - } - - reset($participants); - $event = $this->bo->get_cached_event(); - if(!@$event->participants[$cal[owner]]) - { - $this->bo->add_attribute('owner',$minparts); - } - $this->bo->add_attribute('priority',$cal[priority]); - $event = $this->bo->get_cached_event(); - - $this->bo->store_to_appsession($event); - $datetime_check = $this->bo->validate_update($event); - if($datetime_check) - { - Header('Location: '.$this->page('edit','&readsess='.$event->id.'&cd='.$datetime_check)); - } - - $start = mktime($event->start->hour,$event->start->min,$event->start->sec,$event->start->month,$event->start->mday,$event->start->year) - $this->bo->datetime->tz_offset; - $end = mktime($event->end->hour,$event->end->min,$event->end->sec,$event->end->month,$event->end->mday,$event->end->year) - $this->bo->datetime->tz_offset; - - $overlapping_events = $this->bo->overlap($start,$end,$event->participants,$event->owner,$event->id); - } - else - { - $event = $this->bo->restore_from_appsession(); - $datetime_check = $this->bo->validate_update($event); - $overlapping_events = False; - if($datetime_check) - { - Header('Location: '.$this->page('edit','&readsess='.$event->id.'&cd='.$datetime_check)); - } - } - - if(count($overlapping_events) > 0 && $overlapping_events != False) - { - unset($phpgw_info['flags']['noheader']); - unset($phpgw_info['flags']['nonavbar']); - $phpgw->common->phpgw_header(); - - $p = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('calendar')); - $templates = Array( - 'overlap' => 'overlap.tpl', - 'form_button' => 'form_button_script.tpl' - ); - $p->set_file($templates); - - $p->set_var('color',$phpgw_info['theme']['bg_text']); - $p->set_var('overlap_title',lang('Scheduling Conflict')); - - $overlap = ''; - for($i=0;$ibo->read_entry($overlapping_events[$i]); - $overlap .= '
  • '.$this->link_to_entry($over,$event->start->month,$event->start->mday,$event->start->year); - } - if(strlen($overlap) > 0) - { - $var = Array( - 'overlap_text' => lang('Your suggested time of x - x conflicts with the following existing calendar entries:',$phpgw->common->show_date($start),$phpgw->common->show_date($end)), - 'overlap_list' => $overlap - ); - } - else - { - $var = Array( - 'overlap_text' => '', - 'overlap_list' => '' - ); - } - - $p->set_var($var); -// $phpgw->calendar->event = $event; - - $var = Array( - 'action_url_button' => $this->page('update','&readsess='.$event->id.'&year='.$event->start->year.'&month='.$event->start->month.'&day='.$event->start->mday), - 'action_text_button' => lang('Ignore Conflict'), - 'action_confirm_button' => '', - 'action_extra_field' => '' - ); - $p->set_var($var); - - $p->parse('resubmit_button','form_button'); - - $var = Array( - 'action_url_button' => $this->page('update','&readsess='.$event->id.'&year='.$event->start->year.'&month='.$event->start->month.'&day='.$event->start->mday), - 'action_text_button' => lang('Re-Edit Event'), - 'action_confirm_button' => '', - 'action_extra_field' => '' - ); - $p->set_var($var); - - $p->parse('reedit_button','form_button'); - - $p->pparse('out','overlap'); - } - else - { - if(!$event->id) - { - $this->bo->add_entry($event); - } - elseif($event->id) - { - $this->bo->update_entry($event); - } - - Header('Location: '.$this->page('','&year='.$event->start->year.'&month='.$event->start->month.'&day='.$event->start->mday.'&cd=14&owner='.$this->bo->owner)); - } + $this->edit_form($event); } function delete() @@ -1137,106 +566,42 @@ { $date = sprintf("%04d%02d%02d",$event->start->year,$event->start->month,$event->start->mday); - $this->bo->delete_entry(intval($cal_id)); + $cd = $this->bo->delete_entry(intval($cal_id)); $this->bo->expunge(); } else { $date = sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day); + $cd = ''; } - Header('Location: '.$this->page('','&date='.$date)); + Header('Location: '.$this->page('','&date'.$date.($cd?'&cd='.$cd:''))); } function preferences() { - global $phpgw, $phpgw_info, $submit, $prefs; - if ($submit) - { - $phpgw->preferences->read_repository(); - $phpgw->preferences->add('calendar','weekdaystarts',$prefs[weekdaystarts]); - $phpgw->preferences->add('calendar','workdaystarts',$prefs[workdaystarts]); - $phpgw->preferences->add('calendar','workdayends',$prefs[workdayends]); - $phpgw->preferences->add('calendar','defaultcalendar',$prefs[defaultcalendar]); - $phpgw->preferences->add('calendar','defaultfilter',$prefs[defaultfilter]); - $phpgw->preferences->add('calendar','interval',$prefs[interval]); - if ($prefs[mainscreen_showevents] == True) - { - $phpgw->preferences->add('calendar','mainscreen_showevents',$prefs[mainscreen_showevents]); - } - else - { - $phpgw->preferences->delete('calendar','mainscreen_showevents'); - } - if ($prefs[send_updates] == True) - { - $phpgw->preferences->add('calendar','send_updates',$prefs[send_updates]); - } - else - { - $phpgw->preferences->delete('calendar','send_updates'); - } - - if ($prefs[display_status] == True) - { - $phpgw->preferences->add('calendar','display_status',$prefs[display_status]); - } - else - { - $phpgw->preferences->delete('calendar','display_status'); - } - - if ($prefs[default_private] == True) - { - $phpgw->preferences->add('calendar','default_private',$prefs[default_private]); - } - else - { - $phpgw->preferences->delete('calendar','default_private'); - } - - if ($prefs[display_minicals] == True) - { - $phpgw->preferences->add('calendar','display_minicals',$prefs[display_minicals]); - } - else - { - $phpgw->preferences->delete('calendar','display_minicals'); - } - - if ($prefs[print_black_white] == True) - { - $phpgw->preferences->add('calendar','print_black_white',$prefs[print_black_white]); - } - else - { - $phpgw->preferences->delete('calendar','print_black_white'); - } - - $phpgw->preferences->save_repository(True); - - Header('Location: '.$phpgw->link('/preferences/index.php')); - $phpgw->common->phpgw_exit(); - } + global $phpgw, $phpgw_info; unset($phpgw_info['flags']['noheader']); unset($phpgw_info['flags']['nonavbar']); $phpgw_info['flags']['noappheader'] = True; + $phpgw_info['flags']['noappfooter'] = True; $phpgw->common->phpgw_header(); $p = CreateObject('phpgwapi.Template',$this->template_dir); - $templates = Array( - 'pref' => 'pref.tpl', - 'pref_colspan' => 'pref_colspan.tpl', - 'pref_list' => 'pref_list.tpl' + $p->set_file( + Array( + 'pref' =>'pref.tpl', + 'pref_colspan' =>'pref_colspan.tpl', + 'pref_list' =>'pref_list.tpl' + ) ); - $p->set_file($templates); $var = Array( - 'title' => lang('Calendar preferences'), - 'action_url' => $this->page('preferences'), - 'bg_color' => $phpgw_info['theme']['th_bg'], + 'title' => lang('Calendar preferences'), + 'action_url' => $phpgw->link('/index.php','menuaction=calendar.bocalendar.preferences'), + 'bg_color ' => $phpgw_info['theme']['th_bg'], 'submit_lang' => lang('submit'), - 'text' => ' ' + 'text' => ' ' ); $this->output_template_array($p,'row','pref_colspan',$var); @@ -1246,37 +611,33 @@ // echo '

    ' . $phpgw->common->error_list($errors) . '
    '; // } - $str = 'bo->prefs['calendar']['mainscreen_showevents'] == 'Y' || $this->bo->prefs['calendar']['mainscreen_showevents'] == True?' checked':'').'>'; - $this->display_item($p,lang('show day view on main screen'),$str); + $this->display_item($p,lang('show day view on main screen'),'bo->prefs['calendar']['mainscreen_showevents']?' checked':'').'>'); - $t_weekday[$this->bo->prefs['calendar']['weekdaystarts']] = ' selected'; - $str = ''; - $this->display_item($p,lang('weekday starts on'),$str); + $days = Array( + 'Monday', + 'Sunday', + 'Saturday' + ); + $str = ''; + for($i=0;$ibo->prefs['calendar']['weekdaystarts']==$days[$i]?' selected':'').'>'.lang($days[$i]).''."\n"; + } + $this->display_item($p,lang('weekday starts on'),''."\n"); - $t_workdaystarts[$this->bo->prefs['calendar']['workdaystarts']] = ' selected'; - $str = ''; - $this->display_item($p,lang('work day starts on'),$str); + $this->display_item($p,lang('work day starts on'),''."\n"); - $t_workdayends[$this->bo->prefs['calendar']['workdayends']] = ' selected'; - $str = ''; - $this->display_item($p,lang('work day ends on'),$str); + $this->display_item($p,lang('work day ends on'),''."\n"); if(strpos('.',$this->bo->prefs['calendar']['defaultcalendar'])) { @@ -1298,7 +659,7 @@ $selected = array(); $selected[$this->bo->prefs['calendar']['defaultfilter']] = ' selected'; - if (! isset($this->bo->prefs['calendar']['defaultfilter']) || $this->bo->prefs['calendar']['defaultfilter'] == 'private') + if (!isset($this->bo->prefs['calendar']['defaultfilter']) || $this->bo->prefs['calendar']['defaultfilter'] == 'private') { $selected['private'] = ' selected'; } @@ -1313,12 +674,6 @@ . ''; $this->display_item($p,lang('Default calendar filter'),$str); - $selected = array(); - $selected[intval($this->bo->prefs['calendar']['interval'])] = ' selected'; - if (! isset($this->bo->prefs['calendar']['interval'])) - { - $selected[60] = ' selected'; - } $var = Array( 5 => '5', 10 => '10', @@ -1329,31 +684,24 @@ 60 => '60' ); - $str = ''; - $this->display_item($p,lang('Display interval in Day View'),$str); + $this->display_item($p,lang('Display interval in Day View'),''."\n"); - $str = 'bo->prefs['calendar']['send_updates'] == 'Y' || $this->bo->prefs['calendar']['send_updates'] == True?' checked':'').'>'; - $this->display_item($p,lang('Send/receive updates via email'),$str); + $this->display_item($p,lang('Send/receive updates via email'),'bo->prefs['calendar']['send_updates']?' checked':'').'>'."\n"); - $str = 'bo->prefs['calendar']['display_status'] == 'Y' || $this->bo->prefs['calendar']['display_status'] == True?' checked':'').'>'; - $this->display_item($p,lang('Display status of events'),$str); + $this->display_item($p,lang('Display status of events'),'bo->prefs['calendar']['display_status']?' checked':'').'>'."\n"); - $str = 'bo->prefs['calendar']['default_private'] == 'Y' || $this->bo->prefs['calendar']['default_private'] == True?' checked':'').'>'; - $this->display_item($p,lang('When creating new events default set to private'),$str); + $this->display_item($p,lang('When creating new events default set to private'),'bo->prefs['calendar']['default_private']?' checked':'').'>'."\n"); - $str = 'bo->prefs['calendar']['display_minicals'] == 'Y' || $this->bo->prefs['calendar']['display_minicals'] == True?' checked':'').'>'; - $this->display_item($p,lang('Display mini calendars when printing'),$str); + $this->display_item($p,lang('Display mini calendars when printing'),'bo->prefs['calendar']['display_minicals']?' checked':'').'>'."\n"); - $str = 'bo->prefs['calendar']['print_black_white'] == 'Y' || $this->bo->prefs['calendar']['print_black_white'] == True?' checked':'').'>'; - $this->display_item($p,lang('Print calendars in black & white'),$str); + $this->display_item($p,lang('Print calendars in black & white'),'bo->prefs['calendar']['print_black_white']?' checked':'').'>'."\n"); $p->pparse('out','pref'); - $phpgw_info['flags']['noappfooter'] = True; } function day() @@ -1374,6 +722,7 @@ } else { + $phpgw_info['flags']['nofooter'] = True; $printer = ''; $print = ''; if($this->bo->prefs['calendar']['display_minicals'] == 'Y' || $this->bo->prefs['calendar']['display_minicals']) @@ -1386,16 +735,16 @@ } } - $now = $this->bo->datetime->makegmttime(0, 0, 0, $this->bo->month, $this->bo->day, $this->bo->year); $now['raw'] += $this->bo->datetime->tz_offset; $m = mktime(0,0,0,$this->bo->month,1,$this->bo->year); $p = CreateObject('phpgwapi.Template',$this->template_dir); - $template = Array( - 'day_t' => 'day.tpl' - ); - $p->set_file($template); + $p->set_file( + Array( + 'day_t' => 'day.tpl' + ) + ); $var = Array( 'printer_friendly' => $printer, @@ -1410,10 +759,6 @@ $p->set_var($var); $p->pparse('out','day_t'); - if($this->bo->printer_friendly) - { - $phpgw_info['flags']['nofooter'] = True; - } } function edit_status() @@ -1423,6 +768,7 @@ unset($phpgw_info['flags']['noheader']); unset($phpgw_info['flags']['nonavbar']); $phpgw_info['flags']['noappheader'] = True; + $phpgw_info['flags']['noappfooter'] = True; $phpgw->common->phpgw_header(); $event = $this->bo->read_entry($cal_id); @@ -1432,13 +778,13 @@ if(!$event->participants[$this->bo->owner]) { echo '
    The user '.$phpgw->common->grab_owner_name($this->bo->owner).' is not participating in this event!
    '; - $phpgw->common->footer(); + return; } if(!$this->bo->check_perms(PHPGW_ACL_EDIT)) { - echo '
    You do not have permission to edit this appointment!
    '; - $phpgw->common->footer(); + $this->no_edit(); + return; } $freetime = $this->bo->datetime->localdates(mktime(0,0,0,$event->start->month,$event->start->mday,$event->start->year) - $this->bo->datetime->tz_offset); @@ -1447,7 +793,6 @@ echo $this->view_event($event); echo $this->get_response($event->id); - $phpgw_info['flags']['noappfooter'] = True; } function set_action() @@ -1456,11 +801,8 @@ if(!$this->bo->check_perms(PHPGW_ACL_EDIT)) { - unset($phpgw_info['flags']['noheader']); - unset($phpgw_info['flags']['nonavbar']); - $phpgw->common->phpgw_header(); - echo '
    You do not have permission to edit this appointment!
    '; - $phpgw->common->phpgw_exit(); + $this->no_edit(); + return; } $this->bo->set_status(intval($cal_id),intval($action)); @@ -1468,6 +810,473 @@ Header('Location: '.$this->page('','')); } + function planner() + { + global $phpgw, $phpgw_info; + + unset($phpgw_info['flags']['noheader']); + unset($phpgw_info['flags']['nonavbar']); + $phpgw->common->phpgw_header(); + + $html = CreateObject('infolog.html'); + $sbox = CreateObject('phpgwapi.sbox'); + + $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 + ); + + $startdate = mktime(0,0,0,$this->bo->month,1,$this->bo->year) - $this->bo->datetime->tz_offset; + $days = $this->bo->datetime->days_in_month($this->bo->month,$this->bo->year); + $enddate = mktime(23,59,59,$this->bo->month,$this->bo->days,$this->bo->year) - $this->bo->datetime->tz_offset; + + $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); + + $header['.'.$d] = "colspan=$intervals_per_day align=center"; + $header[$d] = 'bo->year,$this->bo->month,$d) + ) + ).'">'.$dayname.'
    '.$d.'
    '; + } + $last_cell = $intervals_per_day * $days - 1; + + $this->bo->store_to_cache($this->bo->year,$this->bo->month,1,0,0,1); + $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 + 1,0,$this->bo->year))); + + for($v=$firstday;$v<=$lastday;$v += 1) + { + $daily = $this->bo->cached_events[$v]; + @reset($daily); + if($this->debug) + { + echo "For Date : $v : Count of items : ".count($daily)."
    \n"; + } + for($g=0;$gbo->datetime->localdates($event->datetime); + $end = $this->bo->datetime->localdates($event->edatetime); + + $view = $html->link('/index.php', + array( + 'menuaction' => 'calendar.uicalendar.view', + 'cal_id' => $event->id + ) + ); + + $start_cell = $intervals_per_day * (intval(substr($v,6,2)) - 1); + $start_cell += $interval[$event->start->hour]; + + $end_cell = $interval_per_day = $intervals_per_day * (intval(substr($v,6,2))-1); + $end_cell += $interval[$event->end->hour]; + + $i = 0; // search for row of parent category + 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; + $ka = '.nr_'.$k; + if (!isset($rows[$k])) + { + if ($i > 1) // further line - no name + { + $rows[$k] = array(); + $rows[$c.'_1']['._name'] = "rowspan=$i"; + } + else + { + $rows[$k]['_name'] = $pcat['name']; + } + $rows[$ka] = 0; + } + $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 ($start_cell < $end_cell) + { + $opt .= "colspan=".(1 + $end_cell - $start_cell); + } + + if ($bgcolor=$cat['color']) + { + $opt .= " bgcolor=$bgcolor"; + } + $opt .= ' title="'.$event->title; + if ($event->description) + { + $opt .= " \n".$event->description; + } + $opt .= '" onClick="location=\''.$view.'\'"'; + $cel = ''; + if ($event->priority == 3) + { + $cel .= $html->image('calendar','mini-calendar-bar.gif','','border=0'); + } + $cel .= $html->image('calendar',count($event->participants)>1?'multi_3.gif':'single.gif',$this->planner_participants($event->participants),'border=0'); + $cel .= ''; + + $akt_cell = $end_cell + 1; + } + reset($rows); + ksort($rows); + reset($rows); + while (list($k,$r) = each($rows)) + { + if (is_array($r)) + { + $rows['.'.$k] = 'bgcolor='.$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); + } + } + } + } + $bgcolor = 'bgcolor='.$phpgw_info['theme']['th_bg']; + echo $html->table( + array( + '_h' => $header, + '._h' => $bgcolor + )+$rows, + 'width="100%" cols='.(1+$days*$intervals_per_day) + ); + } + + function matrixselect() + { + global $phpgw, $phpgw_info; + + $datetime = mktime(0,0,0,$this->bo->month,$this->bo->day,$this->bo->year) - $this->bo->datetime->tz_offset; + + $sb = CreateObject('phpgwapi.sbox'); + + unset($phpgw_info['flags']['noheader']); + unset($phpgw_info['flags']['nonavbar']); + $phpgw->common->phpgw_header(); + + $p = CreateObject('phpgwapi.Template',$this->template_dir); + $p->set_file( + Array( + 'mq' => 'matrix_query.tpl', + 'form_button' => 'form_button_script.tpl' + ) + ); + $p->set_block('mq','matrix_query','matrix_query'); + $p->set_block('mq','list','list'); + + $vars = Array( + 'matrix_action' => lang('Daily Matrix View'), + 'action_url' => $this->page('viewmatrix') + ); + + $p->set_var($vars); + +// Date + $var[] = Array( + 'field' => lang('Date'), + 'data' => $phpgw->common->dateformatorder( + $sb->getYears('year',intval($phpgw->common->show_date($datetime,'Y')),intval($phpgw->common->show_date($datetime,'Y'))), + $sb->getMonthText('month',intval($phpgw->common->show_date($datetime,'n'))), + $sb->getDays('day',intval($phpgw->common->show_date($datetime,'d'))) + ) + ); + +// View type + $var[] = Array( + 'field' => lang('View'), + 'data' => ''."\n" + ); + +// Participants + $accounts = $phpgw->acl->get_ids_for_location('run',1,'calendar'); + $users = Array(); + for($i=0;$icommon->grab_owner_name($user); + if($phpgw->accounts->get_type($user) == 'g') + { + $group_members = $phpgw->acl->get_ids_for_location($user,1,'phpgw_group'); + if($group_members != False) + { + for($j=0;$jcommon->grab_owner_name($group_members[$j]); + } + } + } + } + } + } + + if ($num_users > 50) + { + $size = 15; + } + elseif ($num_users > 5) + { + $size = 5; + } + else + { + $size = $num_users; + } + $str = ''; + @asort($users); + @reset($users); + while ($user = each($users)) + { + if(($phpgw->accounts->exists($user[0]) && $this->bo->check_perms(PHPGW_ACL_READ,$user[0])) || $phpgw->accounts->get_type($user[0]) == 'g') + { + $str .= ' '."\n"; + } + } + $var[] = Array( + 'field' => lang('Participants'), + 'data' => "\n".' '."\n" + ); + + for($i=0;$ioutput_template_array($p,'rows','list',$var[$i]); + } + + $vars = Array( + 'submit_button' => lang('Submit'), + 'action_url_button' => '', + 'action_text_button' => lang('Cancel'), + 'action_confirm_button' => 'onClick="history.back(-1)"', + 'action_extra_field' => '' + ); + + $p->set_var($vars); + $p->parse('cancel_button','form_button'); + $p->pparse('out','matrix_query'); + } + + function viewmatrix() + { + global $phpgw, $phpgw_info, $participants, $matrixtype; + + $parts = Array(); + $acct = CreateObject('phpgwapi.accounts',$this->bo->owner); + for($i=0;$iaccounts->get_type($participants[$i])) + { + case 'g': + $members = $acct->members(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']])) + { + $parts[$member['account_id']] = 1; + } + } + break; + case 'u': + if($this->bo->check_perms(PHPGW_ACL_READ,$participants[$i]) && !isset($parts[$participants[$i]])) + { + $parts[$participants[$i]] = 1; + } + break; + } + } + unset($acct); + + $participants = Array(); + reset($parts); + while(list($key,$value) = each($parts)) + { + $participants[] = $key; + } + + reset($participants); + + unset($phpgw_info['flags']['noheader']); + unset($phpgw_info['flags']['nonavbar']); + $phpgw->common->phpgw_header(); + + switch($matrixtype) + { + case 'free/busy': + $freetime = $this->bo->datetime->makegmttime(0,0,0,$this->bo->month,$this->bo->day,$this->bo->year); + echo $this->timematrix($freetime,$this->bo->splittime('000000',False),0,$parts); + break; + case 'weekly': + echo $this->display_weekly($this->bo->day,$this->bo->month,$this->bo->year,true,$participants); + break; + } + echo "\n".'
    '."\n"; + echo '
    '."\n"; + echo ' '."\n"; + echo ' '."\n"; + echo ' '."\n"; + echo ' '."\n"; + for ($i=0;$i'."\n"; + } + echo ' '."\n"; + echo ' '."\n"; + echo '
    '."\n"; + } + + function search() + { + global $phpgw, $phpgw_info, $keywords, $from; + + if (! $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: ' . $phpgw->link($from,'owner='.$owner.'&month='.$month.'&day='.$day.'&year='.$year)); + } + else + { + unset($phpgw_info['flags']['noheader']); + unset($phpgw_info['flags']['nonavbar']); + $phpgw->common->phpgw_header(); + } + + $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. + // It spits back out the date it was entered. I would like to to say that + // it is a repeated event. + + // This has been solved by the little icon indicator for recurring events. + + $event_ids = $this->bo->search_keywords($keywords); + $ids = Array(); + while(list($key,$id) = each($event_ids)) + { + $event = $this->bo->read_entry($id); + + $datetime = mktime($event->start->hour,$event->start->min,$event->start->sec,$event->start->month,$event->start->mday,$event->start->year) - $phpgw->calendar->datetime->tz_offset; + + $ids[strval($event->id)]++; + $info[strval($event->id)] = $phpgw->common->show_date($datetime).$this->link_to_entry($event,$event->start->month,$event->start->mday,$event->start->year); + + } + $matches = count($event_ids); + + if ($matches > 0) + { + $matches = count($ids); + } + + if ($matches == 1) + { + $quantity = lang('1 match found').'.'; + } + elseif ($matches > 0) + { + $quantity = lang('x matches found',$matches).'.'; + } + else + { + echo ''.lang('Error').':'; + echo lang('no matches found.'); + return; + } + + $p = CreateObject('phpgwapi.Template',$this->template_dir); + $p->set_file( + Array( + 'search_form' => 'search.tpl' + ) + ); + $p->set_block('search_form','search','search'); + $p->set_block('search_form','search_list_header','search_list_header'); + $p->set_block('search_form','search_list','search_list'); + $p->set_block('search_form','search_list_footer','search_list_footer'); + + $var = Array( + 'color' => $phpgw_info['theme']['bg_text'], + 'search_text' => lang('Search Results'), + 'quantity' => $quantity + ); + $p->set_var($var); + + if($matches > 0) + { + $p->parse('rows','search_list_header',True); + } + // now sort by number of hits + arsort($ids); + for(reset($ids);$key=key($ids);next($ids)) + { + $p->set_var('result_desc',$info[$key]); + $p->parse('rows','search_list',True); + } + + if($matches > 0) + { + $p->parse('rows','search_list_footer',True); + } + + $p->pparse('out','search'); + } + /* Private functions */ function _debug_sqsof() { @@ -1505,7 +1314,8 @@ function display_item(&$p,$field,$data) { - global $phpgw, $tr_color; + global $phpgw; + static $tr_color; $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color); $var = Array( 'bg_color' => $tr_color, @@ -1554,12 +1364,15 @@ function footer() { - global $phpgw; + global $phpgw, $menuaction; + + list(,,$method) = explode('.',$menuaction); if (@$this->bo->printer_friendly) { - $phpgw->common->phpgw_footer(); - $phpgw->common->phpgw_exit(); + return; +// $phpgw->common->phpgw_footer(); +// $phpgw->common->phpgw_exit(); } $p = CreateObject('phpgwapi.Template',$this->template_dir); @@ -1576,11 +1389,10 @@ $y = $this->bo->year; $d_time = mktime(0,0,0,$m,1,$y); - $thisdate = date('Ymd', $d_time); + $thisdate = date('Ymd',$d_time); $y--; $str = ''; - for ($i = 0; $i < 25; $i++) { $m++; @@ -1590,16 +1402,11 @@ $y++; } $d = mktime(0,0,0,$m,1,$y); - $str .= ''."\n"; } $var = Array( - 'action_url' => $this->page('month',''), + 'action_url' => $this->page($method,''), 'form_name' => 'SelectMonth', 'label' => lang('Month'), 'form_label' => 'date', @@ -1607,37 +1414,27 @@ 'row' => $str, 'go' => lang('Go!') ); - $this->output_template_array($p,'table_row','footer_row',$var); - $str = ''; - $y = $this->bo->year; $m = $this->bo->month; $d = $this->bo->day; - unset($thisdate); - $thisdate = $this->bo->datetime->makegmttime(0,0,0,$m,$d,$y); $sun = $this->bo->datetime->get_weekday_start($y,$m,$d) - $this->bo->datetime->tz_offset - 7200; $str = ''; - for ($i = -7; $i <= 7; $i++) { $begin = $sun + (3600 * 24 * 7 * $i); $end = $begin + (3600 * 24 * 6); - $str .= ''."\n"; } $var = Array( - 'action_url' => $this->page('week',''), + 'action_url' => $this->page($method,''), 'form_name' => 'SelectWeek', 'label' => lang('Week'), 'form_label' => 'date', @@ -1651,16 +1448,11 @@ $str = ''; for ($i = ($y - 3); $i < ($y + 3); $i++) { - $str .= ''."\n"; } $var = Array( - 'action_url' => $this->page('year',''), + 'action_url' => $this->page($method,''), 'form_name' => 'SelectYear', 'label' => lang('Year'), 'form_label' => 'year', @@ -1668,13 +1460,28 @@ 'row' => $str, 'go' => lang('Go!') ); - $this->output_template_array($p,'table_row','footer_row',$var); $p->pparse('out','footer_table'); unset($p); } + function no_edit() + { + global $phpgw, $phpgw_info; + + if(!$isset($phpgw_info['flags']['noheader'])) + { + unset($phpgw_info['flags']['noheader']); + unset($phpgw_info['flags']['nonavbar']); + $phpgw_info['flags']['noappheader'] = True; + $phpgw_info['flags']['noappfooter'] = True; + $phpgw->common->phpgw_header(); + } + echo '
    You do not have permission to edit this appointment!
    '; + return; + } + function link_to_entry($event,$month,$day,$year) { global $phpgw, $phpgw_info, $grants; @@ -1684,16 +1491,16 @@ $editable = ((!$this->bo->printer_friendly) && (($is_private && $this->bo->check_perms(PHPGW_ACL_PRIVATE)) || !$is_private)); $p = CreateObject('phpgwapi.Template',$this->template_dir); $p->set_unknowns('remove'); - $templates = Array( - 'link_picture' => 'link_pict.tpl' + $p->set_file( + Array( + 'link_picture' => 'link_pict.tpl' + ) ); - $p->set_file($templates); $p->set_block('link_picture','link_pict','link_pict'); $p->set_block('link_picture','pict','pict'); $p->set_block('link_picture','link_open','link_open'); $p->set_block('link_picture','link_close','link_close'); $p->set_block('link_picture','link_text','link_text'); - $description = $this->bo->get_short_field($event,$is_private,'description'); $starttime = mktime($event->start->hour,$event->start->min,$event->start->sec,$event->start->month,$event->start->mday,$event->start->year) - $this->bo->datetime->tz_offset; $endtime = mktime($event->end->hour,$event->end->min,$event->end->sec,$event->end->month,$event->end->mday,$event->end->year) - $this->bo->datetime->tz_offset; @@ -1733,13 +1540,12 @@ { $time = ''; } - $text = ''.$time.' '.$this->bo->get_short_field($event,$is_private,'title'); + $text = '';; if(!$is_private) { $text .= $this->bo->display_status($event->users_status); } - $text .= ''.$phpgw->browser->br; - + $text = ''.$time.' '.$this->bo->get_short_field($event,$is_private,'title').$text.''.$phpgw->browser->br; if ($editable) { @@ -1788,6 +1594,7 @@ ); } + $description = $this->bo->get_short_field($event,$is_private,'description'); for($i=0;$istart->month; + $mday = $event->start->mday; + $year = $event->start->year; + + $start = mktime($event->start->hour,$event->start->min,$event->start->sec,$month,$mday,$year) - $this->bo->datetime->tz_offset; + $end = mktime($event->end->hour,$event->end->min,$event->end->sec,$event->end->month,$event->end->mday,$event->end->year) - $this->bo->datetime->tz_offset; + + $overlap = ''; + for($i=0;$ilink_to_entry($this->bo->read_entry($overlapping_events[$i]),$month,$mday,$year); + } + + unset($phpgw_info['flags']['noheader']); + unset($phpgw_info['flags']['nonavbar']); + $phpgw->common->phpgw_header(); + + $p = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('calendar')); + $p->set_file( + Array( + 'overlap' => 'overlap.tpl', + 'form_button' => 'form_button_script.tpl' + ) + ); + + $var = Array( + 'color' => $phpgw_info['theme']['bg_text'], + 'overlap_title' => lang('Scheduling Conflict'), + 'overlap_text' => lang('Your suggested time of x - x conflicts with the following existing calendar entries:',$phpgw->common->show_date($start),$phpgw->common->show_date($end)), + 'overlap_list' => $overlap + ); + $p->set_var($var); + + $date = sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->mday); + $var = Array( + 'action_url_button' => $phpgw->link('/index.php',Array('menuaction'=>'calendar.bocalendar.update','readsess'=>1,'date'=>$date)), + 'action_text_button' => lang('Ignore Conflict'), + 'action_confirm_button' => '', + 'action_extra_field' => '' + ); + $this->output_template_array($p,'resubmit_button','form_button',$var); + + $var = Array( + 'action_url_button' => $phpgw->link('/index.php',Array('menuaction'=>'calendar.uicalendar.edit','readsess'=>1,'date'=>$date)), + 'action_text_button' => lang('Re-Edit Event'), + 'action_confirm_button' => '', + 'action_extra_field' => '' + ); + $this->output_template_array($p,'resubmit_button','form_button',$var); + $p->pparse('out','overlap'); + } + + function planner_participants($parts) + { + global $phpgw; + static $id2lid = array(); + + $names = ''; + while (list($id,$status) = each($parts)) + { + if (!isset($id2lid[$id])) + { + $id2lid[$id] = $phpgw->common->grab_owner_name($id); + } + if (strlen($names)) + { + $names .= ",\n"; + } + $names .= $id2lid[$id]." ($status)"; + } + if($this->debug) + { + echo "Inside participants() : $names
    \n"; + } + return $names; + } + + function planner_category($id) + { + global $phpgw; + static $cats = array(); + + if (!isset($cats[$id])) + { + $cat_arr = $this->cat->return_single( $id ); + $cats[$id] = $cat_arr[0]; + $cats[$id]['color'] = strstr($cats[$id]['description'],'#'); + } + return $cats[$id]; + } + function week_header($month,$year,$display_name = False) { global $phpgw_info; @@ -1824,10 +1726,11 @@ $p = CreateObject('phpgwapi.Template',$this->template_dir); $p->set_unknowns('remove'); - $templates = Array ( - 'month_header' => 'month_header.tpl' + $p->set_file( + Array ( + 'month_header' => 'month_header.tpl' + ) ); - $p->set_file($templates); $p->set_block('month_header','monthly_header','monthly_header'); $p->set_block('month_header','column_title','column_title'); @@ -1873,11 +1776,12 @@ $p = CreateObject('phpgwapi.Template',$this->template_dir); $p->set_unknowns('keep'); - $templates = Array ( - 'month_header' => 'month_header.tpl', - 'month_day' => 'month_day.tpl' - ); - $p->set_file($templates); + $p->set_file( + Array ( + 'month_header' => 'month_header.tpl', + 'month_day' => 'month_day.tpl' + ) + ); $p->set_block('month_header','monthly_header','monthly_header'); $p->set_block('month_header','month_column','month_column'); $p->set_block('month_day','month_daily','month_daily'); @@ -1885,7 +1789,6 @@ $p->set_block('month_day','event','event'); $p->set_var('extra',''); - $p->set_var('col_width','14'); if($display_name) { @@ -1893,8 +1796,6 @@ $p->parse('column_header','month_column',True); $p->set_var('col_width','12'); } - $gr_events = CreateObject('calendar.calendar_item'); - $lr_events = CreateObject('calendar.calendar_item'); $today = date('Ymd',time()); $daily = $this->bo->set_week_array($startdate,$cellcolor,$weekly); @reset($daily); @@ -1912,7 +1813,7 @@ { if ($day_params['new_event']) { - $new_event_link = '' + $new_event_link = '' . ''.lang('New Entry').'' . ''; $day_number = ''.$day.''; @@ -1966,17 +1867,9 @@ $p->set_var('events',''); if($day_params['week']) { - if(!$this->bo->printer_friendly) - { - $str = '' .$day_params['week'].''; - } - else - { - $str = $day_params['week']; - } $var = Array( 'week_day_font_size' => '-2', - 'events' => $str + 'events' => (!$this->bo->printer_friendly?'' .$day_params['week'].'':$day_params['week']) ); $this->output_template_array($p,'column_data','day_event',$var); $p->set_var('events',''); @@ -2003,16 +1896,20 @@ $p = CreateObject('phpgwapi.Template',$this->template_dir); $p->set_unknowns('keep'); - $templates = Array( - 'week' => 'month_day.tpl' - ); - $p->set_file($templates); + $p->set_file( + Array( + 'week' => 'month_day.tpl' + ) + ); $p->set_block('week','m_w_table','m_w_table'); $p->set_block('week','event','event'); - $p->set_var('cols','7'); - $p->set_var('day_events',$this->week_header($month,$year,False)); - $p->parse('row','event',True); + + $var = Array( + 'cols' => 7, + 'day_events'=> $this->week_header($month,$year,False) + ); + $this->output_template_array($p,'row','event',$var); $cellcolor = $phpgw_info['theme']['row_on']; @@ -2034,10 +1931,11 @@ $p = CreateObject('phpgwapi.Template',$this->template_dir); $p->set_unknowns('keep'); - $templates = Array( - 'week' => 'month_day.tpl' + $p->set_file( + Array( + 'week' => 'month_day.tpl' + ) ); - $p->set_file($templates); $p->set_block('week','m_w_table','m_w_table'); $p->set_block('week','event','event'); @@ -2052,17 +1950,20 @@ $display_name = True; $counter = count($owners); $owners_array = $owners; - $p->set_var('cols','8'); + $cols = 8; } else { $display_name = False; $counter = 1; $owners_array[0] = $owners; - $p->set_var('cols','7'); + $cols = 7; } - $p->set_var('day_events',$this->week_header($month,$year,$display_name)); - $p->parse('row','event',True); + $var = Array( + 'cols' => $cols, + 'day_events' => $this->week_header($month,$year,$display_name) + ); + $this->output_template_array($p,'row','event',$var); $original_owner = $this->bo->owner; for($i=0;$i<$counter;$i++) @@ -2099,15 +2000,16 @@ $p = CreateObject('phpgwapi.Template',$this->template_dir); $p->set_unknowns('keep'); - $templates = Array( - 'view' => 'view.tpl' - ); - $p->set_file($templates); + $p->set_file( + Array( + 'view' => 'view.tpl' + ) + ); $p->set_block('view','view_event','view_event'); $p->set_block('view','list','list'); $var = Array( - 'bg_text' => $phpgw_info['theme']['bg_text'], + 'bg_text'=> $phpgw_info['theme']['bg_text'], 'name' => $event->title ); $p->set_var($var); @@ -2194,17 +2096,7 @@ $long_status = $this->bo->get_long_status($short_status); - $str .= $phpgw->common->grab_owner_name($user).' ('; - - if($this->bo->check_perms(PHPGW_ACL_EDIT,$user) == True) - { - $str .= ''.$long_status.''; - } - else - { - $str .= $long_status; - } - $str .= ')'."\n"; + $str .= $phpgw->common->grab_owner_name($user).' ('.($this->bo->check_perms(PHPGW_ACL_EDIT,$user)?''.$long_status.'':$long_status).')'."\n"; } } $var[] = Array( @@ -2231,9 +2123,7 @@ if($recur_end != 0) { $recur_end -= $this->bo->datetime->tz_offset; - $str_extra .= lang('ends').': '.lang($phpgw->common->show_date($recur_end,'l')); - $str_extra .= ', '.lang($phpgw->common->show_date($recur_end,'F')); - $str_extra .= ' '.$phpgw->common->show_date($recur_end,'d, Y').' '; + $str_extra .= lang('ends').': '.lang($phpgw->common->show_date($recur_end,'l')).', '.lang($phpgw->common->show_date($recur_end,'F')).' '.$phpgw->common->show_date($recur_end,'d, Y').' '; } } if($event->recur_type == MCAL_RECUR_WEEKLY || $event->recur_type == MCAL_RECUR_DAILY) @@ -2308,38 +2198,6 @@ function html_for_day($event,&$time,$month,$day,$year,&$rowspan,&$rowspan_arr) { - $ind = intval($event->start->hour); - - if($ind < (int)$this->bo->prefs['calendar']['workdaystarts'] || $ind > (int)$this->bo->prefs['calendar']['workdayends']) - { - $ind = 99; - } - - if(!@$time[$ind]) - { - $time[$ind] = ''; - } - - $time[$ind] .= $this->link_to_entry($event,$month,$day,$year); - - $starttime = mktime($event->start->hour,$event->start->min,$event->start->sec,$event->start->month,$event->start->mday,$event->start->year); - $endtime = mktime($event->end->hour,$event->end->min,$event->end->sec,$event->end->month,$event->end->mday,$event->end->year); - - if ($starttime <> $endtime) - { - $rowspan = (int)(($endtime - $starttime) / 3600); - $mins = (int)((($endtime - $starttime) / 60) % 60); - - if ($mins <> 0) - { - $rowspan += 1; - } - - if ($rowspan > $rowspan_arr[$ind] && $rowspan > 1) - { - $rowspan_arr[$ind] = $rowspan; - } - } } function print_day($year,$month,$day) @@ -2371,30 +2229,15 @@ $this->bo->prefs['calendar']['workdayends'] = 16; } - $t_format = $this->bo->prefs['common']['time_format']; $phpgw->browser->browser(); $browser_agent = $phpgw->browser->get_agent(); if($browser_agent == 'MOZILLA') { - if($t_format == '12') - { - $time_width=12; - } - else - { - $time_width=8; - } + $time_width = ($this->bo->prefs['common']['time_format'] == '12'?12:8); } else { - if($t_format == '12') - { - $time_width=10; - } - else - { - $time_width=7; - } + $time_width = ($this->bo->prefs['common']['time_format'] == '12'?10:7); } $var = Array( 'time_width' => $time_width, @@ -2408,7 +2251,7 @@ for ($i=0;$i<24;$i++) { - $this->rowspan_arr[$i] = 0; + $rowspan_arr[$i] = 0; } $events = Array( @@ -2418,10 +2261,7 @@ $time = Array(); - $cellcolor = $phpgw_info['theme']['row_on']; - $daily = $this->bo->set_week_array($this->bo->datetime->get_weekday_start($year, $month, $day),$cellcolor,True); - -// $events = $this->bo->cached_events[$date_to_eval]; + $daily = $this->bo->set_week_array($this->bo->datetime->get_weekday_start($year, $month, $day),$phpgw_info['theme']['row_on'],True); if($daily[$date_to_eval]['appts']) { @@ -2429,7 +2269,39 @@ $c_events = count($events); for($i=0;$i<$c_events;$i++) { - $this->html_for_day($events[$i],$time,$month,$day,$year,$rowspan,$rowspan_arr); + $event = $events[$i]; + $ind = intval($event->start->hour); + + if($ind < (int)$this->bo->prefs['calendar']['workdaystarts'] || $ind > (int)$this->bo->prefs['calendar']['workdayends']) + { + $ind = 99; + } + + if(!@$time[$ind]) + { + $time[$ind] = ''; + } + + $time[$ind] .= $this->link_to_entry($event,$month,$day,$year); + + $starttime = mktime($event->start->hour,$event->start->min,$event->start->sec,$event->start->month,$event->start->mday,$event->start->year); + $endtime = mktime($event->end->hour,$event->end->min,$event->end->sec,$event->end->month,$event->end->mday,$event->end->year); + + if ($starttime <> $endtime) + { + $rowspan = (int)(($endtime - $starttime) / 3600); + $mins = (int)((($endtime - $starttime) / 60) % 60); + + if ($mins <> 0) + { + $rowspan += 1; + } + + if ($rowspan > $rowspan_arr[$ind] && $rowspan > 1) + { + $rowspan_arr[$ind] = $rowspan; + } + } } } @@ -2535,23 +2407,19 @@ if(!$this->bo->printer_friendly && $this->bo->check_perms(PHPGW_ACL_ADD)) { $new_hour = intval(substr($dtime,0,strpos($dtime,':'))); - if ($this->bo->prefs['common']['timeformat'] == '12' && $i >= 12) + if ($this->bo->prefs['common']['timeformat'] == '12' && $i > 12) { $new_hour += 12; } - $new_minute = substr($dtime,strpos($dtime,':')+1,2); - - $open_link .= ''; + $open_link .= ''; $close_link = ''; } $var = Array( 'open_link' => $open_link, - 'time' => (intval(substr($dtime,0,strpos($dtime,':'))) < 10 ? '0'.$dtime : $dtime), + 'time' => (intval(substr($dtime,0,strpos($dtime,':')))<10?'0'.$dtime:$dtime), 'close_link' => $close_link ); @@ -2578,12 +2446,13 @@ $interval = (int)(60 / $increment); $pix = $phpgw->common->image('calendar','pix.gif'); - $str = '
    '.lang($phpgw->common->show_date($date['raw'],'l')); - $str .= ', '.lang($phpgw->common->show_date($date['raw'],'F')); - $str .= ' '.$phpgw->common->show_date($date['raw'],'d, Y').'
    '; - $str .= ''; - $str .= ''; - $str .= ''; + + $str = '
    '.lang($phpgw->common->show_date($date['raw'],'l')) + . ', '.lang($phpgw->common->show_date($date['raw'],'F')) + . ' '.$phpgw->common->show_date($date['raw'],'d, Y').'
    ' + . '
    '.lang('Participant').'
    ' + . '' + . ''; for($i=0;$i<24;$i++) { for($j=0;$j<$interval;$j++) @@ -2607,20 +2476,20 @@ { $k .= substr(strval($i),strlen(strval($i)) - 1,1); } - $str .= ''; + $str .= ''; break; default: - $str .= ''; + $str .= ''; break; } } } - $str .= ''; - $str .= ''; + $str .= '' + . ''; if(!$endtime) { $endtime = $starttime; @@ -2628,8 +2497,8 @@ $owner = $this->bo->owner; while(list($part,$status) = each($participants)) { - $str .= ''; - $str .= ''; + $str .= '' + . ''; $this->bo->cached_events = Array(); $this->bo->owner = $part; @@ -2668,27 +2537,24 @@ } } } - $str .= ''; - $str .= ''; + $str .= '' + . ''; } - $str .= '
    '.lang('Participant').''; - $str .= '"; - $str .= $k.'' + . '" + . $k.''; - $str .= '"; - $str .= ' ' + . '" + . ' 
    '.$this->bo->get_fullname($participants[$i]).'
    '.$this->bo->get_fullname($part).'
    '; $this->bo->owner = $owner; $this->so->owner = $owner; - return $str; + return $str.''."\n"; } function get_response($cal_id) { global $phpgw; - $str = ''; - $p = CreateObject('phpgwapi.Template',$this->template_dir); - - $templates = Array( - 'form_button' => 'form_button_script.tpl' + $p->set_file( + Array( + 'form_button' => 'form_button_script.tpl' + ) ); - $p->set_file($templates); $response_choices = Array( ACCEPTED => lang('Accept'), @@ -2696,10 +2562,11 @@ TENTATIVE => lang('Tentative'), NO_RESPONSE => lang('No Response') ); + $str = ''; while(list($param,$text) = each($response_choices)) { $var = Array( - 'action_url_button' => $this->page('set_action','&cal_id='.$cal_id.'&action='.$param), + 'action_url_button' => $this->page('set_action',Array('cal_id'=>$cal_id,'action'=>$param)), 'action_text_button' => ' '.$text.' ', 'action_confirm_button' => '', 'action_extra_field' => '' @@ -2707,8 +2574,280 @@ $p->set_var($var); $str .= ''."\n"; } - $str .= '
    '.$p->fp('out','form_button').'
    '; - return $str; + return ''."\n".$str.'
    '."\n"; + } + + function edit_form($event) + { + global $phpgw, $phpgw_info; + + $hourformat = substr($this->bo->users_timeformat,0,1); + + $sb = CreateObject('phpgwapi.sbox'); + + $start = mktime($event->start->hour,$event->start->min,$event->start->sec,$event->start->month,$event->start->mday,$event->start->year) - $this->bo->datetime->tz_offset; + $end = mktime($event->end->hour,$event->end->min,$event->end->sec,$event->end->month,$event->end->mday,$event->end->year) - $this->bo->datetime->tz_offset; + + unset($phpgw_info['flags']['noheader']); + unset($phpgw_info['flags']['nonavbar']); + $phpgw_info['flags']['noappheader'] = True; + $phpgw_info['flags']['noappfooter'] = True; + $phpgw->common->phpgw_header(); + + $p = CreateObject('phpgwapi.Template',$this->template_dir); + $p->set_file( + Array( + 'edit' => 'edit.tpl', + 'form_button' => 'form_button_script.tpl' + ) + ); + $p->set_block('edit','edit_entry','edit_entry'); + $p->set_block('edit','list','list'); + $p->set_block('edit','hr','hr'); + + $vars = Array( + 'font' => $phpgw_info['theme']['font'], + 'bg_color' => $phpgw_info['theme']['bg_text'], + 'calendar_action' => ($event->id?lang('Calendar - Edit'):lang('Calendar - Add')), +/* 'action_url' => $phpgw->link('/index.php','menuaction=calendar.bocalendar.'.($event->id?'update':'add')), */ + 'action_url' => $phpgw->link('/index.php','menuaction=calendar.bocalendar.update'), + 'common_hidden' => ''."\n" + . ''."\n", + 'errormsg' => ($cd?$phpgw->common->check_code($cd):'') + ); + $p->set_var($vars); + +// Brief Description + $var[] = Array( + 'field' => lang('Title'), + 'data' => '' + ); + +// Full Description + $var[] = Array( + 'field' => lang('Full Description'), + 'data' => '' + ); + +// Display Categories + $var[] = Array( + 'field' => lang('Category'), + 'data' => '' + ); + +// Date + $var[] = Array( + 'field' => lang('Start Date'), + 'data' => $phpgw->common->dateformatorder( + $sb->getYears('start[year]',intval($phpgw->common->show_date($start,'Y')),intval($phpgw->common->show_date($start,'Y'))), + $sb->getMonthText('start[month]',intval($phpgw->common->show_date($start,'n'))), + $sb->getDays('start[mday]',intval($phpgw->common->show_date($start,'d'))) + ) + ); + +// Time + if ($this->bo->prefs['common']['timeformat'] == '12') + { + $str .= 'start->hour >= 12?'':' checked').'>am'."\n" + . 'start->hour >= 12?' checked':'').'>pm'."\n"; + } + $var[] = Array( + 'field' => lang('Start Time'), + 'data' => ':'."\n".$str + ); + +// End Date + $var[] = Array( + 'field' => lang('End Date'), + 'data' => $phpgw->common->dateformatorder( + $sb->getYears('end[year]',intval($phpgw->common->show_date($end,'Y')),intval($phpgw->common->show_date($end,'Y'))), + $sb->getMonthText('end[month]',intval($phpgw->common->show_date($end,'n'))), + $sb->getDays('end[mday]',intval($phpgw->common->show_date($end,'d'))) + ) + ); + +// End Time + if ($this->bo->prefs['common']['timeformat'] == '12') + { + $str = 'end->hour >= 12?'':' checked').'>am'."\n" + . 'end->hour >= 12?' checked':'').'>pm'."\n"; + } + $var[] = Array( + 'field' => lang("End Time"), + 'data' => ':'."\n".$str + ); + +// Priority + $var[] = Array( + 'field' => lang('Priority'), + 'data' => $sb->getPriority('cal[priority]',$event->priority) + ); + +// Access + $var[] = Array( + 'field' => lang('Private'), + 'data' => 'public?' checked':'').'>' + ); + +// Participants + $accounts = $phpgw->acl->get_ids_for_location('run',1,'calendar'); + $users = Array(); + $this->build_part_list($users,$accounts,$owner); + + $str = ''; + @asort($users); + @reset($users); + while (list($id,$name) = each($users)) + { + if(intval($id) != intval($this->bo->owner)) + { + $str .= ' '."\n"; + } + } + $var[] = Array( + 'field' => lang('Participants'), + 'data' => "\n".' ' + ); + +// I Participate + if((($cal_id > 0) && isset($event->participants[$this->bo->owner])) || !isset($cal_id)) + { + $checked = ' checked'; + } + else + { + $checked = ''; + } + $var[] = Array( + 'field' => $phpgw->common->grab_owner_name($this->bo->owner).' '.lang('Participates'), + 'data' => '' + ); + + for($i=0;$ioutput_template_array($p,'row','list',$var[$i]); + } + + unset($var); + +// Repeat Type + $p->set_var('hr_text','
    '); + $p->parse('row','hr',True); + $p->set_var('hr_text','
    '.lang('Repeating Event Information').'

    '); + $p->parse('row','hr',True); + $rpt_type = Array( + MCAL_RECUR_NONE, + MCAL_RECUR_DAILY, + MCAL_RECUR_WEEKLY, + MCAL_RECUR_MONTHLY_WDAY, + MCAL_RECUR_MONTHLY_MDAY, + MCAL_RECUR_YEARLY + ); + $rpt_type_out = Array( + MCAL_RECUR_NONE => 'None', + MCAL_RECUR_DAILY => 'Daily', + MCAL_RECUR_WEEKLY => 'Weekly', + MCAL_RECUR_MONTHLY_WDAY => 'Monthly (by day)', + MCAL_RECUR_MONTHLY_MDAY => 'Monthly (by date)', + MCAL_RECUR_YEARLY => 'Yearly' + ); + $str = ''; + for($l=0;$lrecur_type==$rpt_type[$l]?' selected':'').'>'.lang($rpt_type_out[$rpt_type[$l]]).''; + } + $var[] = Array( + 'field' => lang('Repeat Type'), + 'data' => ''."\n" + ); + + if($event->recur_enddate->year != 0 && $event->recur_enddate->month != 0 && $event->recur_enddate->mday != 0) + { + $checked = ' checked'; + $recur_end = mktime($event->recur_enddate->hour,$event->recur_enddate->min,$event->recur_enddate->sec,$event->recur_enddate->month,$event->recur_enddate->mday,$event->recur_enddate->year) - $this->bo->datetime->tz_offset; + } + else + { + $checked = ''; + $recur_end = mktime($event->start->hour,$event->start->min,$event->start->sec,$event->start->month,$event->start->mday,$event->start->year) + 86400 - $this->bo->datetime->tz_offset; + } + + $var[] = Array( + 'field' => lang('Repeat End Date'), + 'data' => ''.lang('Use End Date').' ' + .$phpgw->common->dateformatorder( + $sb->getYears('recur_enddate[year]',intval($phpgw->common->show_date($recur_end,'Y')),intval($phpgw->common->show_date($recur_end,'Y'))), + $sb->getMonthText('recur_enddate[month]',intval($phpgw->common->show_date($recur_end,'n'))), + $sb->getDays('recur_enddate[mday]',intval($phpgw->common->show_date($recur_end,'d'))) + ) + ); + + $var[] = Array( + 'field' => lang('Repeat Day').'
    '.lang('(for weekly)'), + 'data' => 'recur_data & MCAL_M_SUNDAY) ?' checked':'').'> '.lang('Sunday').' ' + . 'recur_data & MCAL_M_MONDAY) ?' checked':'').'> '.lang('Monday').' ' + . 'recur_data & MCAL_M_TUESDAY) ?' checked':'').'> '.lang('Tuesday').' ' + . 'recur_data & MCAL_M_WEDNESDAY) ?' checked':'').'> '.lang('Wednesday').'
    ' + . 'recur_data & MCAL_M_THURSDAY) ?' checked':'').'> '.lang('Thursday').' ' + . 'recur_data & MCAL_M_FRIDAY) ?' checked':'').'> '.lang('Friday').' ' + . 'recur_data & MCAL_M_SATURDAY) ?' checked':'').'> '.lang('Saturday').' ' + ); + + $var[] = Array( + 'field' => lang('Frequency'), + 'data' => '' + ); + + for($i=0;$ioutput_template_array($p,'row','list',$var[$i]); + } + + $p->set_var('submit_button',lang('Submit')); + + if ($cal_id > 0) + { + $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); + $p->parse('delete_button','form_button'); + } + else + { + $p->set_var('delete_button',''); + } + $p->pparse('out','edit_entry'); + } + + function build_part_list(&$users,$accounts,$owner) + { + global $phpgw; + if($accounts == False) + { + return; + } + while(list($index,$id) = each($accounts)) + { + if(intval($id) == $owner) + { + continue; + } + if(!isset($users[intval($id)])) + { + if($phpgw->accounts->exists(intval($id)) == True) + { + $users[intval($id)] = $phpgw->common->grab_owner_name(intval($id)); + } + if($phpgw->accounts->get_type(intval($id)) == 'g') + { + $this->build_part_list($users,$phpgw->acl->get_ids_for_location(intval($id),1,'phpgw_group'),$owner); + } + } + } } } ?> diff --git a/calendar/inc/class.uiholiday.inc.php b/calendar/inc/class.uiholiday.inc.php new file mode 100755 index 0000000000..ff1c974efb --- /dev/null +++ b/calendar/inc/class.uiholiday.inc.php @@ -0,0 +1,559 @@ + * + * http://www.radix.net/~cknudsen * + * Modified 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$ */ + + class uiholiday + { + var $debug = False; + var $base_url; + var $bo; + var $template_dir; + var $holidays; + var $cat_id; + + var $public_functions = array( + 'admin' => True, + 'edit_locale' => True, + 'edit_holiday' => True, + 'add_holiday' => True, + 'delete_holiday' => True, + 'delete_locale' => True + ); + + function uiholiday() + { + global $phpgw, $phpgw_info; + + $phpgw->nextmatchs = CreateObject('phpgwapi.nextmatchs'); + + $this->bo = CreateObject('calendar.boholiday'); + $this->base_url = $this->bo->base_url; + $this->template_dir = $phpgw->common->get_tpl_dir('calendar'); + } + + function admin() + { + global $phpgw, $phpgw_info; + + unset($phpgw_info['flags']['noheader']); + unset($phpgw_info['flags']['nonavbar']); + $phpgw_info['flags']['noappfooter'] = True; + $phpgw->common->phpgw_header(); + + $p = CreateObject('phpgwapi.Template',$this->template_dir); + $p->set_file(Array('locales'=>'locales.tpl')); + $p->set_block('locales','list','list'); + $p->set_block('locales','row','row'); + $p->set_block('locales','row_empty','row_empty'); + $p->set_block('locales','submit_column','submit_column'); + + $var = Array( + 'th_bg' => $phpgw_info['theme']['th_bg'], + 'left_next_matchs' => $phpgw->nextmatchs->left('/calendar/'.basename($SCRIPT_FILENAME),$this->bo->start,$this->bo->total), + 'right_next_matchs' => $phpgw->nextmatchs->right('/calendar/'.basename($SCRIPT_FILENAME),$this->bo->start,$this->bo->total), + 'lang_groups' => lang('Countries'), + 'sort_name' => $phpgw->nextmatchs->show_sort_order($this->bo->sort,'locale',$this->bo->order,'/calendar/'.basename($SCRIPT_FILENAME),lang('Country')), + 'header_edit' => lang('Edit'), + 'header_delete' => lang('Delete'), + 'submit_extra' => '', + 'submit_link' => lang('Submit to Repository'), + 'back_button' => '' + ); + + $p->set_var($var); + $p->parse('header_submit','submit_column',False); + + $locales = $this->bo->get_locale_list($this->bo->sort, $this->bo->order, $this->bo->query, $this->bo->total); + @reset($locales); + if (!$locales) + { + $p->set_var('message',lang('No matchs found')); + $p->parse('rows','row_empty',True); + } + else + { + $p->set_var('submit_extra',' width="5%"'); + while (list(,$value) = each($locales)) + { + $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color); + if (! $value) $value = ' '; + + $var = Array( + 'tr_color' => $tr_color, + 'group_name' => $value, + 'edit_link' => ' '.lang('Edit').' ', + 'delete_link' => ' '.lang('Delete').' ', + 'submit_link' => ' '.lang('Submit').' ' + ); + $p->set_var($var); + $p->parse('submit_link_column','submit_column',False); + $p->parse('rows','row',True); + } + } + + $var = Array( + 'new_action' => $phpgw->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.add_holiday','id'=>0)), + 'lang_add' => lang('add'), + 'search_action' => $phpgw->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.admin')), + 'lang_search' => lang('search') + ); + + $p->set_var($var); + $p->pparse('out','list'); + } + + function edit_locale() + { + global $phpgw, $phpgw_info; + + if(!$this->bo->total && !isset($this->bo->query)) + { + $link_params = Array( + 'menuaction' => 'calendar.uiholiday.admin' + ); + Header('Location: ' . $phpgw->link($this->base_url,$link_params)); + } + + unset($phpgw_info['flags']['noheader']); + unset($phpgw_info['flags']['nonavbar']); + $phpgw_info['flags']['noappfooter'] = True; + $phpgw->common->phpgw_header(); + $p = CreateObject('phpgwapi.Template',$this->template_dir); + $p->set_file(Array('locale'=>'locales.tpl')); + $p->set_block('locale','list','list'); + $p->set_block('locale','row','row'); + $p->set_block('locale','row_empty','row_empty'); + $p->set_block('locale','back_button_form','back_button_form'); + + $var = Array( + 'th_bg' => $phpgw_info['theme']['th_bg'], + 'left_next_matchs' => $phpgw->nextmatchs->left('/calendar/'.basename($SCRIPT_FILENAME),$this->bo->start,$this->bo->total,'&locale='.$this->bo->locales[0]), + 'right_next_matchs' => $phpgw->nextmatchs->right('/calendar/'.basename($SCRIPT_FILENAME),$this->bo->start,$this->bo->total,'&locale='.$this->bo->locales[0]), + 'lang_groups' => lang('Holidays').' ('.$this->bo->locales[0].')', + 'sort_name' => $phpgw->nextmatchs->show_sort_order($this->bo->sort,'name',$this->bo->order,'/calendar/'.basename($SCRIPT_FILENAME),lang('Holiday'),'&locale='.$this->bo->locales[0]), + 'header_edit' => lang('Edit'), + 'header_delete' => lang('Delete'), + 'header_submit' => '', + 'submit_link_column' => '' + ); + + $p->set_var($var); + + $holidays = $this->bo->get_holiday_list(); + + if (!count($holidays)) + { + $p->set_var('message',lang('No matchs found')); + $p->parse('rows','row_empty',True); + } + else + { + for($i=0;$inextmatchs->alternate_row_color($tr_color); + if (!$holidays[$i]['name']) + { + $holidays[$i]['name'] = ' '; + } + + $var = Array( + 'tr_color' => $tr_color, + 'header_delete'=> lang('Delete'), + 'group_name' => $holidays[$i]['name'], + 'edit_link' => ' '.lang('Edit').' ', + 'delete_link' => ' '.lang('Delete').' ' + ); + + $p->set_var($var); + $p->parse('rows','row',True); + } + } + + $var = Array( + 'new_action' => $phpgw->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.add_holiday','locale'=>$this->bo->locales[0],'id'=>0)), + 'lang_add' => lang('add'), + 'back_action' => $phpgw->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.admin')), + 'lang_back' => lang('Back'), + 'search_action'=> $phpgw->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.edit_locale','locale'=>$this->bo->locales[0])), + 'lang_search' => lang('search') + ); + $p->set_var($var); + $p->parse('back_button','back_button_form',False); + $p->pparse('out','list'); + } + + function edit_holiday() + { + global $phpgw, $phpgw_info; + if(@$this->bo->id) + { + $holiday = $this->bo->read_entry($this->bo->id); + } + if(!$holiday || !@$this->bo->id) + { + Header('Location: ' . $phpgw->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.edit_locale','locale'=>$this->bo->locales[0]))); + } + + unset($phpgw_info['flags']['noheader']); + unset($phpgw_info['flags']['nonavbar']); + $phpgw_info['flags']['noappfooter'] = True; + $phpgw->common->phpgw_header(); + + $sb = CreateObject('phpgwapi.sbox'); + + $t = CreateObject('phpgwapi.Template',$this->template_dir); + $t->set_file(Array('holiday'=>'holiday.tpl','form_button'=>'form_button_script.tpl')); + $t->set_block('holiday','form','form'); + $t->set_block('holiday','list','list'); + + if (@$errorcount) + { + $message = $phpgw->common->error_list($error); + } + else + { + $message = ''; + } + + $var = Array( + 'title_holiday'=> lang('Edit').' '.lang('Holiday'), + 'message' => $message, + 'actionurl' => $phpgw->link($this->base_url,'menuaction=calendar.boholiday.add'), + 'hidden_vars' => ''."\n" + . ''."\n" + ); + $t->set_var($var); + +// Locale + $this->display_item($t,lang('Country'),''); + +// Title/Name + $this->display_item($t,lang('title'),''); + +// Date + $this->display_item($t,lang('Date'),$phpgw->common->dateformatorder('',$sb->getMonthText('holiday[month_num]',$holiday['month']),$sb->getDays('holiday[mday]',$holiday['day']))); + +// Occurence + $occur = Array( + 0 => '0', + 1 => '1st', + 2 => '2nd', + 3 => '3rd', + 4 => '4th', + 5 => '5th', + 99 => 'Last' + ); + $out = ''; + while(list($key,$value) = each($occur)) + { + $out .= ''."\n"; + } + $occurence_html = ''."\n"; + + $dow = Array( + 0 => lang('Sun'), + 1 => lang('Mon'), + 2 => lang('Tue'), + 3 => lang('Wed'), + 4 => lang('Thu'), + 5 => lang('Fri'), + 6 => lang('Sat') + ); + $out = ''; + for($i=0;$i<7;$i++) + { + $out .= ''."\n"; + } + $dow_html = ''."\n"; + $this->display_item($t,lang('Occurence'),$occurence_html.' '.$dow_html); + $this->display_item($t,lang('Observance Rule'),''); + + $t->set_var('lang_add',lang('Save')); + $t->set_var('lang_reset',lang('Reset')); + + if(@$this->bo->locales[0]) + { + $link_params = Array( + 'menuaction' => 'calendar.uiholiday.edit_locale', + 'locale' => $this->bo->locales[0] + ); + } + else + { + $link_params = Array( + 'menuaction' => 'calendar.uiholiday.admin' + ); + } + + $var = Array( + 'action_url_button' => $phpgw->link($this->base_url,$link_params), + 'action_text_button' => lang('Cancel'), + 'action_confirm_button' => '', + 'action_extra_field' => '' + ); + $t->set_var($var); + $t->parse('cancel_button','form_button'); + $t->pparse('out','form'); + } + + + function add_holiday($messages='',$holiday='') + { + global $phpgw, $phpgw_info; + + unset($phpgw_info['flags']['noheader']); + unset($phpgw_info['flags']['nonavbar']); + $phpgw_info['flags']['noappfooter'] = True; + $phpgw->common->phpgw_header(); + + $sb = CreateObject('phpgwapi.sbox'); + + $t = CreateObject('phpgwapi.Template',$this->template_dir); + $t->set_file(Array('holiday'=>'holiday.tpl','form_button'=>'form_button_script.tpl')); + $t->set_block('holiday','form','form'); + $t->set_block('holiday','list','list'); + + if($messages) + { + if (is_array($messages)) + { + $message = $phpgw->common->error_list($messages); + } + else + { + $message = ''; + } + } + + $var = Array( + 'title_holiday' => lang('Add').' '.lang('Holiday'), + 'message' => $message, + 'actionurl' => $phpgw->link($this->base_url,'menuaction=calendar.boholiday.add'), + 'hidden_vars' => ''."\n" + . ''."\n" + . ''."\n" + . ''."\n" + ); + + $t->set_var($var); + +// Locale + if($this->bo->locales[0]) + { + $holiday['locale'] = $this->bo->locales[0]; + } + $this->display_item($t,lang('Country'),''); + +// Title/Name + $this->display_item($t,lang('title'),''); + +// Date + $day_html = $sb->getDays('holiday[mday]',$holiday['day']); + $month_html = $sb->getMonthText('holiday[month_num]',$holiday['month']); + $year_html = ''; + $this->display_item($t,lang('Date'),$phpgw->common->dateformatorder($year_html,$month_html,$day_html)); + +// Occurence + $occur = Array( + 0 => '0', + 1 => '1st', + 2 => '2nd', + 3 => '3rd', + 4 => '4th', + 5 => '5th', + 99 => 'Last' + ); + $out = ''; + while(list($key,$value) = each($occur)) + { + $out .= ''."\n"; + } + $occurence_html = ''."\n"; + + $dow = Array( + 0 => lang('Sun'), + 1 => lang('Mon'), + 2 => lang('Tue'), + 3 => lang('Wed'), + 4 => lang('Thu'), + 5 => lang('Fri'), + 6 => lang('Sat') + ); + $out = ''; + for($i=0;$i<7;$i++) + { + $out .= ''."\n"; + } + $dow_html = ''."\n"; + $this->display_item($t,lang('Occurence'),$occurence_html.' '.$dow_html); + $this->display_item($t,lang('Observance Rule'),''); + + $t->set_var('lang_add',lang('Save')); + $t->set_var('lang_reset',lang('Reset')); + if(@$this->bo->locales[0]) + { + $link_params = Array( + 'menuaction' => 'calendar.uiholiday.edit_locale', + 'locale' => $this->bo->locales[0] + ); + } + else + { + $link_params = Array( + 'menuaction' => 'calendar.uiholiday.admin' + ); + } + $var = Array( + 'action_url_button' => $phpgw->link($this->base_url,$link_params), + 'action_text_button' => lang('Cancel'), + 'action_confirm_button' => '', + 'action_extra_field' => '' + ); + $t->set_var($var); + $t->parse('cancel_button','form_button'); + $t->pparse('out','form'); + } + + function delete_locale() + { + global $phpgw, $phpgw_info; + + if(!$this->bo->total) + { + $this->admin(); + } + + unset($phpgw_info['flags']['noheader']); + unset($phpgw_info['flags']['nonavbar']); + $phpgw_info['flags']['noappfooter'] = True; + $phpgw->common->phpgw_header(); + + $p = CreateObject('phpgwapi.Template',$this->template_dir); + $p->set_file(Array('form'=>'delete_common.tpl','form_button'=>'form_button_script.tpl')); + + $p->set_var('messages',lang('Are you sure you want to delete this Country ?')."
    ".$this->bo->locales[0]); + + $var = Array( + 'action_url_button' => $phpgw->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.admin')), + 'action_text_button' => lang('No'), + 'action_confirm_button' => '', + 'action_extra_field' => '' + ); + $p->set_var($var); + $p->parse('no','form_button'); + + $var = Array( + 'action_url_button' => $phpgw->link($this->base_url,Array('menuaction'=>'calendar.boholiday.delete_locale','locale'=>$this->bo->locales[0])), + 'action_text_button' => lang('Yes'), + 'action_confirm_button' => '', + 'action_extra_field' => '' + ); + $p->set_var($var); + $p->parse('yes','form_button'); + + $p->pparse('out','form'); + } + + function delete_holiday() + { + global $phpgw, $phpgw_info; + + $holiday = $this->bo->read_entry($this->bo->id); + + if(!$holiday) + { + $this->edit_locale(); + } + + unset($phpgw_info['flags']['noheader']); + unset($phpgw_info['flags']['nonavbar']); + $phpgw_info['flags']['noappfooter'] = True; + $phpgw->common->phpgw_header(); + + $p = CreateObject('phpgwapi.Template',$this->template_dir); + $p->set_file(Array('form'=>'delete_common.tpl','form_button'=>'form_button_script.tpl')); + + $p->set_var('messages',lang('Are you sure you want to delete this holiday ?')."
    ".$holiday['name'].' ('.$this->bo->locales[0].')'); + + $var = Array( + 'action_url_button' => $phpgw->link($this->base_url,Array('menuaction'=>'calendar.uiholiday.edit_locale','locale'=>$this->bo->locales[0])), + 'action_text_button' => lang('No'), + 'action_confirm_button' => '', + 'action_extra_field' => '' + ); + $p->set_var($var); + $p->parse('no','form_button'); + + $var = Array( + 'action_url_button' => $phpgw->link($this->base_url,Array('menuaction'=>'calendar.boholiday.delete_holiday','locale'=>$this->bo->locales[0],'id'=>$this->bo->id)), + 'action_text_button' => lang('Yes'), + 'action_confirm_button' => '', + 'action_extra_field' => '' + ); + $p->set_var($var); + $p->parse('yes','form_button'); + + $p->pparse('out','form'); + } + + function submit() + { + global $phpgw, $phpgw_info; + if(!@$this->bo->locales[0]) + { + $this->admin(); + } + $holidays = $this->bo->get_holiday_list(); + $phpgw_info['flags']['noappheader'] = True; + $phpgw_info['flags']['noappfooter'] = True; + $phpgw_info['flags']['nofooter'] = True; + $phpgw->common->phpgw_header(); + + echo ''."\n"; + if($this->debug) + { + echo '
    '."\n"; + } + else + { + echo ''."\n"; + } + + $c_holidays = count($holidays); + echo ''."\n"; + for($i=0;$i<$c_holidays;$i++) + { + echo ''."\n" + . ''."\n" + . ''."\n" + . ''."\n" + . ''."\n" + . ''."\n"; + } + echo "
    \n\n"; + } + + /* private functions */ + function display_item(&$p,$field,$data) + { + $var = Array( + 'field' => $field, + 'data' => $data + ); + $p->set_var($var); + $p->parse('rows','list',True); + } + } +?> diff --git a/calendar/templates/default/header.inc.php b/calendar/templates/default/header.inc.php index 9bf787286e..bbf42d27f2 100755 --- a/calendar/templates/default/header.inc.php +++ b/calendar/templates/default/header.inc.php @@ -58,14 +58,18 @@ $str = ' '.add_image_ahref($link,'year.gif',lang('This Year')).''; add_col($tpl,$str); + $link = $this->page('planner','&date='.$today); + $str = ' '.add_image_ahref($link,'planner.gif',lang('Planner')).''; + add_col($tpl,$str); + $link = $this->page('matrixselect'); $str = ' '.add_image_ahref($link,'view.gif',lang('Daily Matrix View')).''; add_col($tpl,$str); - $remainder = 65; + $remainder = 63; if($this->bo->check_perms(PHPGW_ACL_PRIVATE)) { - $remainder -= 30; + $remainder -= 28; $hidden_vars = ''."\n"; if(isset($date) && $date) { @@ -94,7 +98,7 @@ $form_options .= ' '."\n"; $var = Array( - 'form_width' => '30', + 'form_width' => '28', 'form_link' => $this->page($referrer), 'form_name' => 'filter', 'title' => lang('Filter'), @@ -175,7 +179,4 @@ $button = $tpl->fp('out','form_button'); $tpl->set_var('str',''.$button.''); $tpl->parse('header_column','head_col',True); - - echo $tpl->fp('out','head'); - unset($tpl); ?> diff --git a/calendar/templates/default/year.tpl b/calendar/templates/default/year.tpl new file mode 100755 index 0000000000..4504447813 --- /dev/null +++ b/calendar/templates/default/year.tpl @@ -0,0 +1,35 @@ + +{print} +
    + + + + + + + + {row} + +
    + {left_link} + + {year_text} + + {right_link} +
    +
    +

    +

    +{printer_friendly} +


    + + + + {mini_month} + + + + + + + diff --git a/calendar/templates/idsociety/header.inc.php b/calendar/templates/idsociety/header.inc.php index a5a5d9fd1e..bbf42d27f2 100755 --- a/calendar/templates/idsociety/header.inc.php +++ b/calendar/templates/idsociety/header.inc.php @@ -58,14 +58,18 @@ $str = ' '.add_image_ahref($link,'year.gif',lang('This Year')).''; add_col($tpl,$str); + $link = $this->page('planner','&date='.$today); + $str = ' '.add_image_ahref($link,'planner.gif',lang('Planner')).''; + add_col($tpl,$str); + $link = $this->page('matrixselect'); $str = ' '.add_image_ahref($link,'view.gif',lang('Daily Matrix View')).''; add_col($tpl,$str); - $remainder = 65; + $remainder = 63; if($this->bo->check_perms(PHPGW_ACL_PRIVATE)) { - $remainder -= 30; + $remainder -= 28; $hidden_vars = ''."\n"; if(isset($date) && $date) { @@ -94,7 +98,7 @@ $form_options .= ' '."\n"; $var = Array( - 'form_width' => '30', + 'form_width' => '28', 'form_link' => $this->page($referrer), 'form_name' => 'filter', 'title' => lang('Filter'), diff --git a/calendar/templates/justweb/header.inc.php b/calendar/templates/justweb/header.inc.php index a5a5d9fd1e..bbf42d27f2 100755 --- a/calendar/templates/justweb/header.inc.php +++ b/calendar/templates/justweb/header.inc.php @@ -58,14 +58,18 @@ $str = ' '.add_image_ahref($link,'year.gif',lang('This Year')).''; add_col($tpl,$str); + $link = $this->page('planner','&date='.$today); + $str = ' '.add_image_ahref($link,'planner.gif',lang('Planner')).''; + add_col($tpl,$str); + $link = $this->page('matrixselect'); $str = ' '.add_image_ahref($link,'view.gif',lang('Daily Matrix View')).''; add_col($tpl,$str); - $remainder = 65; + $remainder = 63; if($this->bo->check_perms(PHPGW_ACL_PRIVATE)) { - $remainder -= 30; + $remainder -= 28; $hidden_vars = ''."\n"; if(isset($date) && $date) { @@ -94,7 +98,7 @@ $form_options .= ' '."\n"; $var = Array( - 'form_width' => '30', + 'form_width' => '28', 'form_link' => $this->page($referrer), 'form_name' => 'filter', 'title' => lang('Filter'), diff --git a/calendar/templates/verdilak/header.inc.php b/calendar/templates/verdilak/header.inc.php index a5a5d9fd1e..bbf42d27f2 100755 --- a/calendar/templates/verdilak/header.inc.php +++ b/calendar/templates/verdilak/header.inc.php @@ -58,14 +58,18 @@ $str = ' '.add_image_ahref($link,'year.gif',lang('This Year')).''; add_col($tpl,$str); + $link = $this->page('planner','&date='.$today); + $str = ' '.add_image_ahref($link,'planner.gif',lang('Planner')).''; + add_col($tpl,$str); + $link = $this->page('matrixselect'); $str = ' '.add_image_ahref($link,'view.gif',lang('Daily Matrix View')).''; add_col($tpl,$str); - $remainder = 65; + $remainder = 63; if($this->bo->check_perms(PHPGW_ACL_PRIVATE)) { - $remainder -= 30; + $remainder -= 28; $hidden_vars = ''."\n"; if(isset($date) && $date) { @@ -94,7 +98,7 @@ $form_options .= ' '."\n"; $var = Array( - 'form_width' => '30', + 'form_width' => '28', 'form_link' => $this->page($referrer), 'form_name' => 'filter', 'title' => lang('Filter'),