From 4f422d46088bab2b0727fa5adc7f2e456fe9637e Mon Sep 17 00:00:00 2001 From: skeeter Date: Wed, 17 Apr 2002 23:43:29 +0000 Subject: [PATCH] Added GNU Feature Request #100744. --- calendar/inc/class.bopreferences.inc.php | 84 +++++++----------- calendar/inc/class.uicalendar.inc.php | 72 +++++++++------- calendar/inc/class.uipreferences.inc.php | 20 +++-- phpgwapi/inc/class.datetime.inc.php | 105 ++++++++++++++++++----- 4 files changed, 169 insertions(+), 112 deletions(-) diff --git a/calendar/inc/class.bopreferences.inc.php b/calendar/inc/class.bopreferences.inc.php index cdd94f1394..07ee19d52e 100755 --- a/calendar/inc/class.bopreferences.inc.php +++ b/calendar/inc/class.bopreferences.inc.php @@ -34,63 +34,41 @@ if (isset($GLOBALS['HTTP_POST_VARS']['submit'])) { $GLOBALS['phpgw']->preferences->read_repository(); - $GLOBALS['phpgw']->preferences->add('calendar','weekdaystarts',$GLOBALS['HTTP_POST_VARS']['prefs']['weekdaystarts']); - $GLOBALS['phpgw']->preferences->add('calendar','workdaystarts',intval($GLOBALS['HTTP_POST_VARS']['prefs']['workdaystarts'])); - $GLOBALS['phpgw']->preferences->add('calendar','workdayends',intval($GLOBALS['HTTP_POST_VARS']['prefs']['workdayends'])); - $GLOBALS['phpgw']->preferences->add('calendar','defaultcalendar',$GLOBALS['HTTP_POST_VARS']['prefs']['defaultcalendar']); - $GLOBALS['phpgw']->preferences->add('calendar','defaultfilter',$GLOBALS['HTTP_POST_VARS']['prefs']['defaultfilter']); - $GLOBALS['phpgw']->preferences->add('calendar','interval',intval($GLOBALS['HTTP_POST_VARS']['prefs']['interval'])); - if ($GLOBALS['HTTP_POST_VARS']['prefs']['mainscreen_showevents'] == True) + + $pref_list = Array( + 'weekdaystarts', + 'workdaystarts', + 'workdayends', + 'defaultcalendar', + 'defaultfilter', + 'interval' + ); + + for($i=0;$ipreferences->add('calendar','mainscreen_showevents',$GLOBALS['HTTP_POST_VARS']['prefs']['mainscreen_showevents']); - } - else - { - $GLOBALS['phpgw']->preferences->delete('calendar','mainscreen_showevents'); - } - if ($GLOBALS['HTTP_POST_VARS']['prefs']['send_updates'] == True) - { - $GLOBALS['phpgw']->preferences->add('calendar','send_updates',$GLOBALS['HTTP_POST_VARS']['prefs']['send_updates']); - } - else - { - $GLOBALS['phpgw']->preferences->delete('calendar','send_updates'); - } - - if ($GLOBALS['HTTP_POST_VARS']['prefs']['display_status'] == True) - { - $GLOBALS['phpgw']->preferences->add('calendar','display_status',$GLOBALS['HTTP_POST_VARS']['prefs']['display_status']); - } - else - { - $GLOBALS['phpgw']->preferences->delete('calendar','display_status'); + $GLOBALS['phpgw']->preferences->add('calendar',$pref_list[$i],$GLOBALS['HTTP_POST_VARS']['prefs'][$pref_list[$i]]); } - if ($GLOBALS['HTTP_POST_VARS']['prefs']['default_private'] == True) - { - $GLOBALS['phpgw']->preferences->add('calendar','default_private',$GLOBALS['HTTP_POST_VARS']['prefs']['default_private']); - } - else - { - $GLOBALS['phpgw']->preferences->delete('calendar','default_private'); - } + $pref_list = Array( + 'mainscreen_showevents', + 'send_updates', + 'display_status', + 'default_private', + 'display_minicals', + 'print_black_white', + 'weekdays_only' + ); - if ($GLOBALS['HTTP_POST_VARS']['prefs']['display_minicals'] == True) + for($i=0;$ipreferences->add('calendar','display_minicals',$GLOBALS['HTTP_POST_VARS']['prefs']['display_minicals']); - } - else - { - $GLOBALS['phpgw']->preferences->delete('calendar','display_minicals'); - } - - if ($GLOBALS['HTTP_POST_VARS']['prefs']['print_black_white'] == True) - { - $GLOBALS['phpgw']->preferences->add('calendar','print_black_white',$GLOBALS['HTTP_POST_VARS']['prefs']['print_black_white']); - } - else - { - $GLOBALS['phpgw']->preferences->delete('calendar','print_black_white'); + if ($GLOBALS['HTTP_POST_VARS']['prefs'][$pref_list[$i]] == True) + { + $GLOBALS['phpgw']->preferences->add('calendar',$pref_list[$i],$GLOBALS['HTTP_POST_VARS']['prefs'][$pref_list[$i]]); + } + else + { + $GLOBALS['phpgw']->preferences->delete('calendar',$pref_list[$i]); + } } $GLOBALS['phpgw']->preferences->save_repository(True); @@ -100,4 +78,4 @@ } } } - +?> diff --git a/calendar/inc/class.uicalendar.inc.php b/calendar/inc/class.uicalendar.inc.php index 107a218bd9..6c3db44def 100755 --- a/calendar/inc/class.uicalendar.inc.php +++ b/calendar/inc/class.uicalendar.inc.php @@ -206,7 +206,7 @@ for($i=0;$i<7;$i++) { $var = Array( - 'dayname' => '' . substr(lang($this->datetime->days[$i]),0,2) . '', + 'dayname' => '' . substr(lang($this->datetime->days[$i]['name']),0,2) . '', 'day_image' => '' ); $this->output_template_array($p,'daynames','mini_day',$var); @@ -373,12 +373,6 @@ function week() { - if (!$this->bo->printer_friendly) - { - unset($GLOBALS['phpgw_info']['flags']['noheader']); - unset($GLOBALS['phpgw_info']['flags']['nonavbar']); - $GLOBALS['phpgw']->common->phpgw_header(); - } echo $this->printer_friendly($this->get_week()); } @@ -546,16 +540,6 @@ function year() { - if(!$this->bo->printer_friendly) - { - unset($GLOBALS['phpgw_info']['flags']['noheader']); - unset($GLOBALS['phpgw_info']['flags']['nonavbar']); - $GLOBALS['phpgw']->common->phpgw_header(); - } - else - { - $GLOBALS['phpgw_info']['flags']['nofooter'] = True; - } echo $this->printer_friendly($this->get_year()); } @@ -1156,9 +1140,6 @@ if (!$this->bo->printer_friendly) { - unset($GLOBALS['phpgw_info']['flags']['noheader']); - unset($GLOBALS['phpgw_info']['flags']['nonavbar']); - $GLOBALS['phpgw']->common->phpgw_header(); $printer = ''; $param = '&date='.sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day).'&friendly=1'; $print = '[".lang('Printer Friendly').']'; @@ -1963,11 +1944,11 @@ . ' A.bminicalhol { background: '.$this->holiday_color.'; color: #336699; font: italic bold xx-small '.$this->theme['font'].' }'."\n" . ' A.minicalgreyhol { background: '.$this->holiday_color.'; color: #999999; font: xx-small '.$this->theme['font'].' }'."\n" . ' A.bminicalgreyhol { background: '.$this->holiday_color.'; color: #999999; font: italic bold xx-small '.$this->theme['font'].' }'."\n" - . ' .event-on { background: '.$this->theme['row_on'].'; color: '.$this->theme['bg_text'].'; font: 100 80%/110% '.$this->theme['font'].'; vertical-align: middle; }'."\n" - . ' .event-off { background: '.$this->theme['row_off'].'; color: '.$this->theme['bg_text'].'; font: 100 80%/110% '.$this->theme['font'].'; vertical-align: middle; }'."\n" - . ' .event-holiday { background: '.$this->theme['bg04'].'; color: '.$this->theme['bg_text'].'; font: 100 80%/110% '.$this->theme['font'].'; vertical-align: middle; }'."\n" + . ' .event-on { background: '.$this->theme['row_on'].'; color: '.$this->theme['bg_text'].'; font: 100 80%/110% '.$this->theme['font'].'; vertical-align: middle }'."\n" + . ' .event-off { background: '.$this->theme['row_off'].'; color: '.$this->theme['bg_text'].'; font: 100 80%/110% '.$this->theme['font'].'; vertical-align: middle }'."\n" + . ' .event-holiday { background: '.$this->theme['bg04'].'; color: '.$this->theme['bg_text'].'; font: 100 80%/110% '.$this->theme['font'].'; vertical-align: middle }'."\n" . ' .time { background: '.$this->theme['navbar_bg'].'; color: '.$this->theme['bg_text'].'; font: 65%/100% '.$this->theme['font'].'; width: '.$time_width.'%; border: 1px '.$this->theme['navbar_text'].'; vertical-align: middle; }'."\n" - . ' .tablecell { width: 80px; height: 80px }'."\n"; + . ' .tablecell { width: 80px; height: 80px }'; } function no_edit() @@ -2156,7 +2137,7 @@ $overlap = ''; for($i=0;$ibo->read_entry($overlapping_events[$i]) + $overlapped_event = $this->bo->read_entry($overlapping_events[$i]); $overlap .= '
  • ['.$GLOBALS['phpgw']->common->grab_owner_name($overlapped_event['owner']).'] '.$this->link_to_entry($overlapped_event,$month,$mday,$year); } @@ -2280,26 +2261,48 @@ ); } $p->set_var($var); - + + $col_width = 14; $p->set_var('col_width','14'); if($display_name == True) { $p->set_var('col_title',lang('name')); $p->parse('column_header','column_title',True); - $p->set_var('col_width','12'); + $col_width = 12; } + if($this->datetime->days[$i]['weekday']) + { + switch($col_width) + { + case 12: + $col_width = 16; + break; + case 14: + $col_width = 20; + break; + } + } + + $p->set_var('col_width',$col_width); + for($i=0;$i<7;$i++) { - $p->set_var('col_title',lang($this->datetime->days[$i])); - $p->parse('column_header','column_title',True); + if($this->bo->prefs['calendar']['weekdays_only'] && $this->datetime->days[$i]['weekday']) + { + $p->set_var('col_title',lang($this->datetime->days[$i]['name'])); + $p->parse('column_header','column_title',True); + } } return $p->fp('out','monthly_header'); } function display_week($startdate,$weekly,$cellcolor,$display_name = False,$owner=0,$monthstart=0,$monthend=0) { - if($owner == 0) { $owner = $GLOBALS['phpgw_info']['user']['account_id']; } + if($owner == 0) + { + $owner = $GLOBALS['phpgw_info']['user']['account_id']; + } $temp_owner = $this->bo->owner; $this->bo->owner = $owner; @@ -2336,6 +2339,11 @@ $year = intval(substr($date,0,4)); $month = intval(substr($date,4,2)); $day = intval(substr($date,6,2)); + $dow = $this->datetime->day_of_week($year,$month,$day); + if($this->bo->prefs['calendar']['weekdays_only'] && ($dow == 0 || $dow == 6)) + { + continue; + } $var = Array( 'column_data' => '', 'extra' => '' @@ -2515,6 +2523,10 @@ $owners_array[0] = $owners; $cols = 7; } + if($this->bo->prefs['calendar']['weekdays_only']) + { + $cols -= 2; + } $var = Array( 'cols' => $cols, 'day_events' => $this->week_header($month,$year,$display_name) diff --git a/calendar/inc/class.uipreferences.inc.php b/calendar/inc/class.uipreferences.inc.php index 1c27e59245..eebf15a597 100755 --- a/calendar/inc/class.uipreferences.inc.php +++ b/calendar/inc/class.uipreferences.inc.php @@ -144,15 +144,19 @@ } $this->display_item(lang('Display interval in Day View'),''."\n"); - $this->display_item(lang('Send/receive updates via email'),'bo->prefs['calendar']['send_updates']?' checked':'').'>'."\n"); + $checkboxes = Array( + 'send_updates' => lang('Send/receive updates via email'), + 'weekdays_only' => lang('Display week days only in Month/Week View'), + 'display_status' => lang('Display status of events'), + 'default_private' => lang('When creating new events default set to private'), + 'display_minicals' => lang('Display mini calendars when printing'), + 'print_black_white' => lang('Print calendars in black & white') + ); - $this->display_item(lang('Display status of events'),'bo->prefs['calendar']['display_status']?' checked':'').'>'."\n"); - - $this->display_item(lang('When creating new events default set to private'),'bo->prefs['calendar']['default_private']?' checked':'').'>'."\n"); - - $this->display_item(lang('Display mini calendars when printing'),'bo->prefs['calendar']['display_minicals']?' checked':'').'>'."\n"); - - $this->display_item(lang('Print calendars in black & white'),'bo->prefs['calendar']['print_black_white']?' checked':'').'>'."\n"); + while(list($pref_var,$desc) = each($checkboxes)) + { + $this->display_item($desc,'bo->prefs['calendar'][$pref_var]?' checked':'').'>'."\n"); + } $this->template->pparse('out','pref'); } diff --git a/phpgwapi/inc/class.datetime.inc.php b/phpgwapi/inc/class.datetime.inc.php index 694c227d93..60288a3e3b 100755 --- a/phpgwapi/inc/class.datetime.inc.php +++ b/phpgwapi/inc/class.datetime.inc.php @@ -120,13 +120,34 @@ // Saturday is for arabic support case 'Saturday': $this->days = Array( - 0 => 'Sat', - 1 => 'Sun', - 2 => 'Mon', - 3 => 'Tue', - 4 => 'Wed', - 5 => 'Thu', - 6 => 'Fri' + 0 => Array( + 'name' => 'Sat', + 'weekday' => 0 + ), + 1 => Array( + 'name' => 'Sun', + 'weekday' => 0 + ), + 2 => Array( + 'name' => 'Mon', + 'weekday' => 1 + ), + 3 => Array( + 'name' => 'Tue', + 'weekday' => 1 + ), + 4 => Array( + 'name' => 'Wed', + 'weekday' => 1 + ), + 5 => Array( + 'name' => 'Thu', + 'weekday' => 1 + ), + 6 => Array( + 'name' => 'Fri', + 'weekday' => 1 + ) ); switch($weekday) { @@ -143,13 +164,34 @@ break; case 'Monday': $this->days = Array( - 0 => 'Mon', - 1 => 'Tue', - 2 => 'Wed', - 3 => 'Thu', - 4 => 'Fri', - 5 => 'Sat', - 6 => 'Sun' + 0 => Array( + 'name' => 'Mon', + 'weekday' => 1 + ), + 1 => Array( + 'name' => 'Tue', + 'weekday' => 1 + ), + 2 => Array( + 'name' => 'Wed', + 'weekday' => 1 + ), + 3 => Array( + 'name' => 'Thu', + 'weekday' => 1 + ), + 4 => Array( + 'name' => 'Fri', + 'weekday' => 1 + ), + 5 => Array( + 'name' => 'Sat', + 'weekday' => 0 + ), + 6 => Array( + 'name' => 'Sun', + 'weekday' => 0 + ) ); switch($weekday) { @@ -167,13 +209,34 @@ case 'Sunday': default: $this->days = Array( - 0 => 'Sun', - 1 => 'Mon', - 2 => 'Tue', - 3 => 'Wed', - 4 => 'Thu', - 5 => 'Fri', - 6 => 'Sat' + 0 => Array( + 'name' => 'Sun', + 'weekday' => 0 + ), + 1 => Array( + 'name' => 'Mon', + 'weekday' => 1 + ), + 2 => Array( + 'name' => 'Tue', + 'weekday' => 1 + ), + 3 => Array( + 'name' => 'Wed', + 'weekday' => 1 + ), + 4 => Array( + 'name' => 'Thu', + 'weekday' => 1 + ), + 5 => Array( + 'name' => 'Fri', + 'weekday' => 1 + ), + 6 => Array( + 'name' => 'Sat', + 'weekday' => 0 + ) ); $sday = mktime(2,0,0,$month,$day - $weekday,$year); break;