From febb03c9f1aac81b710f3c048f4137f6b3006574 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Sun, 22 Aug 2004 17:56:26 +0000 Subject: [PATCH] fixed probs pointed out by Joxean Koret --- calendar/inc/class.bocalendar.inc.php | 101 ++++------- calendar/inc/class.uicalendar.inc.php | 63 +++---- calendar/templates/default/header.inc.php | 203 ++++++++++++++++++++++ 3 files changed, 264 insertions(+), 103 deletions(-) create mode 100755 calendar/templates/default/header.inc.php diff --git a/calendar/inc/class.bocalendar.inc.php b/calendar/inc/class.bocalendar.inc.php index 41d3d93fb7..2b005c394f 100755 --- a/calendar/inc/class.bocalendar.inc.php +++ b/calendar/inc/class.bocalendar.inc.php @@ -199,17 +199,17 @@ unset($this->save_owner); } - if(isset($owner) && $owner!='' && substr($owner,0,2) == 'g_') + if(isset($owner) && substr($owner,0,2) == 'g_') { - $this->set_owner_to_group(substr($owner,2)); + $this->set_owner_to_group((int) substr($owner,2)); } - elseif(isset($owner) && $owner!='') + elseif(isset($owner) && $owner) { - $this->owner = (int)$owner; + $this->owner = (int) $owner; } - elseif(!@isset($this->owner) || !@$this->owner) + if(!@isset($this->owner) || !@$this->owner) { - $this->owner = (int)$GLOBALS['phpgw_info']['user']['account_id']; + $this->owner = (int) $GLOBALS['phpgw_info']['user']['account_id']; } elseif(isset($this->owner) && $GLOBALS['phpgw']->accounts->get_type($this->owner) == 'g') { @@ -228,24 +228,27 @@ } $this->holiday_color = (substr($GLOBALS['phpgw_info']['theme']['bg07'],0,1)=='#'?'':'#').$GLOBALS['phpgw_info']['theme']['bg07']; - $friendly = (isset($_GET['friendly'])?$_GET['friendly']:''); - $friendly = ($friendly=='' && isset($_POST['friendly'])?$_POST['friendly']:$friendly); + $friendly = (int) get_var('friendly',array('GET','POST'),0); $this->printer_friendly = ((int)$friendly == 1?True:False); - if(isset($_POST['filter'])) { $this->filter = $_POST['filter']; } - if(isset($_POST['sortby'])) { $this->sortby = $_POST['sortby']; } - if(isset($_POST['cat_id'])) { $this->cat_id = $_POST['cat_id']; } - - if(!isset($this->filter)) + if(isset($_POST['filter']) && ($_POST['filter'] == ' all ' || $_POST['filter'] == ' privat ')) + { + $this->filter = $_POST['filter']; + } + else { $this->filter = ' '.$this->prefs['calendar']['defaultfilter'].' '; } - - if(!isset($this->sortby)) + if(isset($_POST['sortby']) && ($_POST['sortby'] == 'user' || $_POST['sortby'] == 'category')) + { + $this->sortby = $_POST['sortby']; + } + else { $this->sortby = $this->prefs['calendar']['defaultcalendar'] == 'planner_user' ? 'user' : 'category'; } + if(isset($_POST['cat_id'])) { $this->cat_id = (int) $_POST['cat_id']; } if($GLOBALS['phpgw']->accounts->get_type($this->owner)=='g') { @@ -291,65 +294,23 @@ $localtime = $GLOBALS['phpgw']->datetime->users_localtime; - $date = (isset($GLOBALS['date'])?$GLOBALS['date']:''); - $date = (isset($_GET['date'])?$_GET['date']:$date); - $date = ($date=='' && isset($_POST['date'])?$_POST['date']:$date); + $num_months = (int) get_var('num_month',array('GET','POST'),1); - $year = (isset($_GET['year'])?$_GET['year']:''); - $year = ($year=='' && isset($_POST['year'])?$_POST['year']:$year); - - $month = (isset($_GET['month'])?$_GET['month']:''); - $month = ($month=='' && isset($_POST['month'])?$_POST['month']:$month); - - $day = (isset($_GET['day'])?$_GET['day']:''); - $day = ($day=='' && isset($_POST['day'])?$_POST['day']:''); - - $num_months = (isset($_GET['num_months'])?$_GET['num_months']:''); - $num_months = ($num_months=='' && isset($_POST['num_months'])?$_POST['num_months']:$num_months); - - if(isset($date) && $date!='') + $this->date = (int) get_var('date',array('GET','POST')); + if($this->date) { - $this->year = (int)(substr($date,0,4)); - $this->month = (int)(substr($date,4,2)); - $this->day = (int)(substr($date,6,2)); + $this->year = (int) substr($this->date,0,4); + $this->month = (int) substr($this->date,4,2); + $this->day = (int) substr($this->date,6,2); } else { - if(isset($year) && $year!='') + foreach(array('year' => 'Y','month' => 'm','day' => 'd') as $var => $pat) { - $this->year = $year; - } - else - { - $this->year = date('Y',$localtime); - } - if(isset($month) && $month!='') - { - $this->month = $month; - } - else - { - $this->month = date('m',$localtime); - } - if(isset($day) && $day!='') - { - $this->day = $day; - } - else - { - $this->day = date('d',$localtime); + $this->$var = (int) get_var($var,array('POST','GET'),date($pat,$localtime)); } + $this->date = sprintf('%04d%02d%02d',$this->year,$this->month,$this->day); } - - if(isset($num_months) && $num_months!='') - { - $this->num_months = $num_months; - } - elseif($this->num_months == 0) - { - $this->num_months = 1; - } - $this->today = date('Ymd',$GLOBALS['phpgw']->datetime->users_localtime); if(DEBUG_APP) @@ -871,6 +832,10 @@ { $this->so->set_category(strval($l_categories[0])); } + foreach(array('title','description','location') as $name) + { + $l_cal[$name] = strip_tags($l_cal[$name]); + } $this->so->set_title($l_cal['title']); $this->so->set_description($l_cal['description']); $this->so->set_start($l_start['year'],$l_start['month'],$l_start['mday'],$l_start['hour'],$l_start['min'],0); @@ -914,6 +879,10 @@ $l_cal['recur_data'] |= (int)$mask; } } + if (!$l_cal['recur_data']) // no day set ==> use the day of the startdate + { + $l_cal['recur_data'] = array_search(date('l',$this->maketime($l_start)-$GLOBALS['phpgw']->datetime->tz_offset),$this->rpt_day); + } $this->so->set_recur_weekly((int)$l_recur_enddate['year'],(int)$l_recur_enddate['month'],(int)$l_recur_enddate['mday'],(int)$l_cal['recur_interval'],$l_cal['recur_data']); break; case MCAL_RECUR_MONTHLY_MDAY: diff --git a/calendar/inc/class.uicalendar.inc.php b/calendar/inc/class.uicalendar.inc.php index 0d862b2663..7412cef83e 100755 --- a/calendar/inc/class.uicalendar.inc.php +++ b/calendar/inc/class.uicalendar.inc.php @@ -729,7 +729,7 @@ $cal_id = get_var('cal_id',array('GET','POST'),$vcal_id); $date = $cal_date ? $cal_date : 0; - $date = $date ? $date : (int)$_GET['date']; + $date = $date ? $date : (int)$this->bo->date; // First, make sure they have permission to this entry if ($cal_id < 1) @@ -1037,7 +1037,7 @@ $extra_field_text .= ''.lang('please enter a filename !!!')."\n"; } if(isset($_POST['cal_id'])) - $extra_field_text .= ' '."\n"; + $extra_field_text .= ' '.$this->html->input_hidden('cal_id',(int)$_POST['cal_id']); if (!isset($_POST['cal_id']) || !$_POST['cal_id']) { @@ -2365,13 +2365,14 @@ } echo "\n
\n".'
'."\n"; echo ' '); + + add_col($tpl,' '); + + add_col($tpl,' '); + + add_col($tpl,' '); + + add_col($tpl,' '); + + if(floor(phpversion()) >= 4) + { + add_col($tpl,' '); + $col_width += 2; + } + + add_col($tpl,' '); + + add_col($tpl,' '); + + $tpl->parse('row','head_table',True); + + $tpl->set_var('header_column',''); + $tpl->set_var('cols',$cols); + + if($referrer!='view') + { + $remainder = 72; + + $base_hidden_vars = $this->html->input_hidden('from',$_GET['menuaction']); + if(isset($_GET['cal_id']) && (int) $_GET['cal_id']) + { + $base_hidden_vars .= ' '.$this->html->input_hidden('cal_id',(int)$_GET['cal_id']); + } + if(isset($_POST['matrixtype']) && ($_POST['matrixtype'] == 'free/busy' || $_POST['matrixtype'] == 'weekly')) + { + $base_hidden_vars .= ' '.$this->html->input_hidden('matrixtype',$_POST['matrixtype']); + } + if($this->bo->date) + { + $base_hidden_vars .= ' '.$this->html->input_hidden('date',$this->bo->date); + } + $base_hidden_vars .= ' '.$this->html->input_hidden('month',$this->bo->month); + $base_hidden_vars .= ' '.$this->html->input_hidden('day',$this->bo->day); + $base_hidden_vars .= ' '.$this->html->input_hidden('year',$this->bo->year); + + if(isset($_POST['participants']) && $_POST['participants']) + { + foreach ($_POST['participants'] as $part) + { + $base_hidden_vars .= ' '.$this->html->input_hidden('participants[]', + substr($part,0,2) == 'g_' ? 'g_'.(int)substr($part,2) : (int) $part); + } + } + $base_hidden_vars_no_keywords = $base_hidden_vars; + + if(isset($_POST['keywords']) && $_POST['keywords']) + { + $base_hidden_vars .= ' '.$this->html->input_hidden('keywords',$_POST['keywords']); + } + + $var = Array( + 'form_width' => '28', + 'form_link' => $this->page($referrer), + 'form_name' => 'cat_id', + 'title' => lang('Category'), + 'hidden_vars' => $base_hidden_vars, + 'form_options' => ''.$this->cat->formated_list('select','all',$this->bo->cat_id,'True'), + 'button_value' => lang('Go!') + ); + $tpl->set_var($var); + $tpl->set_var('str',$tpl->fp('out','form_button_dropdown')); + $tpl->parse('header_column','head_col',True); + + if($_GET['menuaction'] == 'calendar.uicalendar.planner') + { + $remainder -= 28; + print_debug('Sort By',$this->bo->sortby); + + $form_options = ''."\n"; + $form_options .= ' '."\n"; + + $var = Array( + 'form_width' => '28', + 'form_link' => $this->page($referrer), + 'form_name' => 'sortby', + 'title' => lang('Sort By'), + 'hidden_vars' => $base_hidden_vars, + 'form_options' => $form_options, + 'button_value' => lang('Go!') + ); + $tpl->set_var($var); + $tpl->set_var('str',$tpl->fp('out','form_button_dropdown')); + $tpl->parse('header_column','head_col',True); + } + + if($this->bo->check_perms(PHPGW_ACL_PRIVATE)) + { + $remainder -= 28; + $form_options = ''."\n"; + $form_options .= ' '."\n"; + + $var = Array( + 'form_width' => '28', + 'form_link' => $this->page($referrer), + 'form_name' => 'filter', + 'title' => lang('Filter'), + 'hidden_vars' => $base_hidden_vars, + 'form_options' => $form_options, + 'button_value' => lang('Go!') + ); + $tpl->set_var($var); + $tpl->set_var('str',$tpl->fp('out','form_button_dropdown')); + $tpl->parse('header_column','head_col',True); + } + + if((!isset($GLOBALS['phpgw_info']['server']['deny_user_grants_access']) || !$GLOBALS['phpgw_info']['server']['deny_user_grants_access']) && count($this->bo->grants) > 0) + { + $form_options = ''; + $drop_down = $this->bo->list_cals(); + foreach($drop_down as $key => $grant) + { + $form_options .= ' '."\n"; + } + + $var = Array( + 'form_width' => $remainder, + 'form_link' => $this->page($referrer), + 'form_name' => 'owner', + 'title' => lang('User'), + 'hidden_vars' => $base_hidden_vars, + 'form_options' => $form_options, + 'button_value' => lang('Go!') + ); + $tpl->set_var($var); + $tpl->set_var('str',$tpl->fp('out','form_button_dropdown')); + $tpl->parse('header_column','head_col',True); + } + } + + $var = Array( + 'action_url_button' => $this->page('search'), + 'action_text_button' => lang('Search'), + 'action_confirm_button' => '', + 'action_extra_field' => $base_hidden_vars_no_keywords . ' '.$this->html->input('keywords',$_POST['keywords']) + ); + $tpl->set_var($var); + $button = $tpl->fp('out','form_button'); + $tpl->set_var('str',''); + $tpl->parse('header_column','head_col',True); + $tpl->parse('row','head_table',True); +?>
'."\n"; - echo ' '."\n"; - echo ' '."\n"; - echo ' '."\n"; - echo ' '."\n"; + echo ' '.$this->html->input_hidden('year',$this->bo->year); + echo ' '.$this->html->input_hidden('month',$this->bo->month); + echo ' '.$this->html->input_hidden('day',$this->bo->day); + echo ' '.$this->html->input_hidden('matrixtype',$_POST['matrixtype']); foreach($participants as $part) { - echo ' '."\n"; + $part = substr($part,0,2) == 'g_' ? 'g_'.(int) substr($part,2) : (int) $part; + echo ' '.$this->html->input_hidden('participants[]',$part); } echo ' '."\n"; echo ' '."\n"; @@ -2682,13 +2683,13 @@ $str = ''; $date_str = ''; - if(isset($_GET['date']) && $_GET['date']) + if($this->bo->date) { - $date_str .= ' '."\n"; + $date_str .= ' '.$this->html->input_hidden('date',$this->bo->date); } - $date_str .= ' '."\n"; - $date_str .= ' '."\n"; - $date_str .= ' '."\n"; + $date_str .= ' '.$this->html->input_hidden('month',$this->bo->month); + $date_str .= ' '.$this->html->input_hidden('day',$this->bo->day); + $date_str .= ' '.$this->html->input_hidden('year',$this->bo->year); for($i=1; $i<=6; $i++) { @@ -3911,13 +3912,13 @@ 'font' => $this->theme['font'], 'bg_color' => $this->theme['bg_text'], 'action_url' => $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.bocalendar.update')), - 'common_hidden' => ''."\n" - . ''."\n" - . ''."\n" - . ($_GET['cal_id'] && $event['id'] == 0?''."\n": - (@isset($event['reference'])?''."\n":'')) + 'common_hidden' => $this->html->input_hidden('cal[id]',$event['id']) + . $this->html->input_hidden('cal[owner]',$event['owner']) + . $this->html->input_hidden('cal[uid]',$event['uid']) + . ($_GET['cal_id'] && $event['id'] == 0?$this->html->input_hidden('cal[reference]',$_GET['cal_id']) : + (@isset($event['reference'])?$this->html->input_hidden('cal[reference]',$event['reference']):'')) . (@isset($GLOBALS['phpgw_info']['server']['deny_user_grants_access']) && $GLOBALS['phpgw_info']['server']['deny_user_grants_access']? - ''."\n":''), + $this->html->input_hidden('participants[]',$this->bo->owner):''), 'errormsg' => ($param['cd']?$GLOBALS['phpgw']->common->check_code($param['cd']):'') ); $p->set_var($vars); @@ -4000,14 +4001,8 @@ $start = $this->bo->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset; $var['startdate'] = Array( 'field' => lang('Start Date'), -/* - 'data' => $GLOBALS['phpgw']->common->dateformatorder( - $sb->getYears('start[year]',(int)$GLOBALS['phpgw']->common->show_date($start,'Y')), - $sb->getMonthText('start[month]',(int)$GLOBALS['phpgw']->common->show_date($start,'n')), - $sb->getDays('start[mday]',(int)$GLOBALS['phpgw']->common->show_date($start,'d')) - ) -*/ - 'data' => $jscal->input('start[str]',$start) + + 'data' => $jscal->input('start[str]',$start) ); // Time @@ -4025,14 +4020,8 @@ $end = $this->bo->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; $var['enddate'] = Array( 'field' => lang('End Date'), -/* - 'data' => $GLOBALS['phpgw']->common->dateformatorder( - $sb->getYears('end[year]',(int)$GLOBALS['phpgw']->common->show_date($end,'Y')), - $sb->getMonthText('end[month]',(int)$GLOBALS['phpgw']->common->show_date($end,'n')), - $sb->getDays('end[mday]',(int)$GLOBALS['phpgw']->common->show_date($end,'d')) - ) -*/ - 'data' => $jscal->input('end[str]',$end) + + 'data' => $jscal->input('end[str]',$end) ); // End Time @@ -4104,9 +4093,9 @@ // DEBUG START . ''."\n" // DEBUG END - . ''."\n" - . ''."\n"; + . $this->html->input_hidden('ext_part_id" value="'.$part.'">'."\n"; $var[] = Array( 'field' => "\n".lang('External Participants'), @@ -4330,7 +4319,7 @@ if (is_array($preserved)) { //echo "preserving
"; print_r($preserved); echo "
\n"; - $p->set_var('common_hidden',$p->get_var('common_hidden').''."\n"); + $p->set_var('common_hidden',$p->get_var('common_hidden').$this->html->input_hidden('preserved',serialize($preserved))); } $p->set_var('submit_button',lang('Save')); diff --git a/calendar/templates/default/header.inc.php b/calendar/templates/default/header.inc.php new file mode 100755 index 0000000000..fe159d8677 --- /dev/null +++ b/calendar/templates/default/header.inc.php @@ -0,0 +1,203 @@ +set_var('str',$str); + $tpl->parse('header_column','head_col',True); + } + + function add_image_ahref($link,$image,$alt) + { + return ''.$alt.''; + } + + $refer = explode('.',$_GET['menuaction']); + $referrer = $refer[2]; + + $templates = Array( + 'head_tpl' => 'head.tpl', + 'form_button_dropdown' => 'form_button_dropdown.tpl', + 'form_button_script' => 'form_button_script.tpl' + ); + $tpl->set_file($templates); + $tpl->set_block('head_tpl','head','head'); + $tpl->set_block('head_tpl','head_table','head_table'); + $tpl->set_block('head_tpl','head_col','head_col'); + $tpl->set_block('form_button_script','form_button'); + + if(floor(phpversion()) >= 4) + { + $tpl->set_var('cols',8); + } + else + { + $tpl->set_var('cols',7); + } + + $today = date('Ymd',$GLOBALS['phpgw']->datetime->users_localtime); + + $col_width = 12; + + add_col($tpl,'
 '.add_image_ahref($this->page('day','&date='.$today),'today',lang('Today')).''.add_image_ahref($this->page('week','&date='.$today),'week',lang('This week')).''.add_image_ahref($this->page('month','&date='.$today),'month',lang('This month')).''.add_image_ahref($this->page('year','&date='.$today),'year',lang('This Year')).''.add_image_ahref($this->page('planner','&date='.$today),'planner',lang('Planner')).''.add_image_ahref($this->page('matrixselect'),'view',lang('Daily Matrix View')).' '.$button.'