fixed probs pointed out by Joxean Koret

This commit is contained in:
Ralf Becker 2004-08-22 17:56:26 +00:00
parent f5f35feb32
commit febb03c9f1
3 changed files with 264 additions and 103 deletions

View File

@ -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:

View File

@ -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 .= '<font color="red">'.lang('please enter a filename !!!')."</font>\n";
}
if(isset($_POST['cal_id']))
$extra_field_text .= ' <input type="hidden" name="cal_id" value="'.$_POST['cal_id'].'">'."\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<br>\n".'<form action="'.$this->page('viewmatrix').'" method="post" name="matrixform">'."\n";
echo ' <table cellpadding="5"><tr><td>'."\n";
echo ' <input type="hidden" name="year" value="'.$this->bo->year.'">'."\n";
echo ' <input type="hidden" name="month" value="'.$this->bo->month.'">'."\n";
echo ' <input type="hidden" name="day" value="'.$this->bo->day.'">'."\n";
echo ' <input type="hidden" name="matrixtype" value="'.$_POST['matrixtype'].'">'."\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 ' <input type="hidden" name="participants[]" value="'.$part.'">'."\n";
$part = substr($part,0,2) == 'g_' ? 'g_'.(int) substr($part,2) : (int) $part;
echo ' '.$this->html->input_hidden('participants[]',$part);
}
echo ' <input type="submit" name="refresh" value="'.lang('Refresh').'">'."\n";
echo ' </td><td>'."\n";
@ -2682,13 +2683,13 @@
$str = '';
$date_str = '';
if(isset($_GET['date']) && $_GET['date'])
if($this->bo->date)
{
$date_str .= ' <input type="hidden" name="date" value="'.$_GET['date'].'">'."\n";
$date_str .= ' '.$this->html->input_hidden('date',$this->bo->date);
}
$date_str .= ' <input type="hidden" name="month" value="'.$this->bo->month.'">'."\n";
$date_str .= ' <input type="hidden" name="day" value="'.$this->bo->day.'">'."\n";
$date_str .= ' <input type="hidden" name="year" value="'.$this->bo->year.'">'."\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' => '<input type="hidden" name="cal[id]" value="'.$event['id'].'">'."\n"
. '<input type="hidden" name="cal[owner]" value="'.$event['owner'].'">'."\n"
. '<input type="hidden" name="cal[uid]" value="'.$event['uid'].'">'."\n"
. ($_GET['cal_id'] && $event['id'] == 0?'<input type="hidden" name="cal[reference]" value="'.$_GET['cal_id'].'">'."\n":
(@isset($event['reference'])?'<input type="hidden" name="cal[reference]" value="'.$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']?
'<input type="hidden" name="participants[]" value="'.$this->bo->owner.'">'."\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
. '<input type="button" value="Status" onClick="javascript:show()">'."\n"
// DEBUG END
. '<input type="button" onClick="javascript:modify_window(\''.$url.'&part='.$part
. '<input type="button" onClick="javascript:modify_window(\$url.'&part='.$part
. '\')" value="'.lang('Modify List of External Participants').'">'."\n"
. '<input type="hidden" name="ext_part_id" value="'.$part.'">'."\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<pre>"; print_r($preserved); echo "</pre>\n";
$p->set_var('common_hidden',$p->get_var('common_hidden').'<input type="hidden" name="preserved" value="'.htmlspecialchars(serialize($preserved)).'">'."\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'));

View File

@ -0,0 +1,203 @@
<?php
/**************************************************************************\
* eGroupWare *
* http://www.egroupware.org *
* -------------------------------------------- *
* 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$ */
function add_col(&$tpl,$str)
{
$tpl->set_var('str',$str);
$tpl->parse('header_column','head_col',True);
}
function add_image_ahref($link,$image,$alt)
{
return '<a href="'.$link.'"><img src="'.$GLOBALS['phpgw']->common->image('calendar',$image).'" alt="'.$alt.'" title="'.$alt.'" border="0"></a>';
}
$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,' <td width="2%">&nbsp;</td>');
add_col($tpl,' <td width="2%">'.add_image_ahref($this->page('day','&date='.$today),'today',lang('Today')).'</td>');
add_col($tpl,' <td width="2%" align="left">'.add_image_ahref($this->page('week','&date='.$today),'week',lang('This week')).'</td>');
add_col($tpl,' <td width="2%" align="left">'.add_image_ahref($this->page('month','&date='.$today),'month',lang('This month')).'</td>');
add_col($tpl,' <td width="2%" align="left">'.add_image_ahref($this->page('year','&date='.$today),'year',lang('This Year')).'</td>');
if(floor(phpversion()) >= 4)
{
add_col($tpl,' <td width="2%" align="left">'.add_image_ahref($this->page('planner','&date='.$today),'planner',lang('Planner')).'</td>');
$col_width += 2;
}
add_col($tpl,' <td width="2%" align="left">'.add_image_ahref($this->page('matrixselect'),'view',lang('Daily Matrix View')).'</td>');
add_col($tpl,' <td width="'.(100 - $col_width).'%" align="left"'.(floor(phpversion()) < 4?' colspan="2"':'').'>&nbsp;</td>');
$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' => '<option value="0">'.lang('All').'</option>'.$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 = '<option value="user"'.($this->bo->sortby=='user'?' selected':'').'>'.lang('User').'</option>'."\n";
$form_options .= ' <option value="category"'.((!isset($this->bo->sortby) || !$this->bo->sortby) || $this->bo->sortby=='category'?' selected':'').'>'.lang('Category').'</option>'."\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 = '<option value=" all "'.($this->bo->filter==' all '?' selected':'').'>'.lang('All').'</option>'."\n";
$form_options .= ' <option value=" private "'.((!isset($this->bo->filter) || !$this->bo->filter) || $this->bo->filter==' private '?' selected':'').'>'.lang('Private Only').'</option>'."\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 .= ' <option value="'.$grant['value'].'"'.($grant['grantor']==$this->bo->owner?' selected':'').'>'.$grant['name'].'</option>'."\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','<td align="right" valign="bottom">'.$button.'</td>');
$tpl->parse('header_column','head_col',True);
$tpl->parse('row','head_table',True);
?>