Massive intval and formatting update - previous version in tag 'cal_008-2'

This commit is contained in:
Miles Lott 2004-01-04 00:47:37 +00:00
parent 27f2acb285
commit 94ea6c3c0a
24 changed files with 4975 additions and 4966 deletions

View File

@ -62,64 +62,70 @@
$CPre = '|['; $CPreReg = '\|\['; // |{csv-fieldname} is expanded to the value of the csv-field $CPre = '|['; $CPreReg = '\|\['; // |{csv-fieldname} is expanded to the value of the csv-field
$CPos = ']'; $CPosReg = '\]'; // if used together with @ (replacement is eval-ed) value gets autom. quoted $CPos = ']'; $CPosReg = '\]'; // if used together with @ (replacement is eval-ed) value gets autom. quoted
function addr_id( $n_family,$n_given,$org_name ) function addr_id( $n_family,$n_given,$org_name )
{ // find in Addressbook, at least n_family AND (n_given OR org_name) have to match { // find in Addressbook, at least n_family AND (n_given OR org_name) have to match
$contacts = createobject('phpgwapi.contacts'); $contacts = createobject('phpgwapi.contacts');
$addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,n_given=$n_given,org_name=$org_name" ); $addrs = $contacts->read(0,0,array('id'),'',"n_family=$n_family,n_given=$n_given,org_name=$org_name");
if (!count($addrs)) if(!count($addrs))
$addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,n_given=$n_given" ); {
if (!count($addrs)) $addrs = $contacts->read(0,0,array('id'),'',"n_family=$n_family,n_given=$n_given");
$addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,org_name=$org_name" ); }
if(!count($addrs))
{
$addrs = $contacts->read(0,0,array('id'),'',"n_family=$n_family,org_name=$org_name");
}
if (count($addrs)) if (count($addrs))
return $addrs[0]['id']; {
return $addrs[0]['id'];
}
return False; return False;
}
$cat2id = array( );
function cat_id($cats)
{
if (!$cats)
{
return '';
} }
$cats = split('[,;]',$cats); $cat2id = array( );
foreach($cats as $k => $cat) function cat_id($cats)
{ {
if (isset($cat2id[$cat])) if (!$cats)
{ {
$ids[$cat] = $cat2id[$cat]; // cat is in cache return '';
} }
else
$cats = split('[,;]',$cats);
foreach($cats as $k => $cat)
{ {
if (!is_object($GLOBALS['phpgw']->categories)) if (isset($cat2id[$cat]))
{ {
$GLOBALS['phpgw']->categories = createobject('phpgwapi.categories'); $ids[$cat] = $cat2id[$cat]; // cat is in cache
}
if ($id = $GLOBALS['phpgw']->categories->name2id( addslashes($cat) ))
{ // cat exists
$cat2id[$cat] = $ids[$cat] = $id;
} }
else else
{ // create new cat {
$GLOBALS['phpgw']->categories->add( array('name' => $cat,'descr' => $cat )); if (!is_object($GLOBALS['phpgw']->categories))
$cat2id[$cat] = $ids[$cat] = $GLOBALS['phpgw']->categories->name2id( addslashes($cat) ); {
$GLOBALS['phpgw']->categories = createobject('phpgwapi.categories');
}
if ($id = $GLOBALS['phpgw']->categories->name2id( addslashes($cat) ))
{ // cat exists
$cat2id[$cat] = $ids[$cat] = $id;
}
else
{ // create new cat
$GLOBALS['phpgw']->categories->add( array('name' => $cat,'descr' => $cat ));
$cat2id[$cat] = $ids[$cat] = $GLOBALS['phpgw']->categories->name2id( addslashes($cat) );
}
} }
} }
} $id_str = implode( ',',$ids );
$id_str = implode( ',',$ids );
if (count($ids) > 1) // multiple cats need to be in ',' if (count($ids) > 1) // multiple cats need to be in ','
{ {
$id_str = ",$id_str,"; $id_str = ",$id_str,";
}
return $id_str;
} }
return $id_str;
}
if (!is_object($GLOBALS['phpgw']->html)) if (!is_object($GLOBALS['phpgw']->html))
{ {
@ -168,12 +174,12 @@ function cat_id($cats)
'start' => 'Start Date: start: Timestamp or eg. YYYY-MM-DD hh:mm', 'start' => 'Start Date: start: Timestamp or eg. YYYY-MM-DD hh:mm',
'end' => 'End Date: start', 'end' => 'End Date: start',
'participants' => 'Participants: comma separated user-id\'s or -names', 'participants' => 'Participants: comma separated user-id\'s or -names',
'category' => 'Categories: id\'s or names, comma separated (new ones got created)', 'category' => 'Categories: id\'s or names, comma separated (new ones got created)',
'priority' => 'Priority: 1=Low, 2=Normal, 3=High', 'priority' => 'Priority: 1=Low, 2=Normal, 3=High',
'public' => 'Access: 1=public, 0=private', 'public' => 'Access: 1=public, 0=private',
'owner' => 'Owner: int(11) user-id/-name', 'owner' => 'Owner: int(11) user-id/-name',
'modtime' => 'Modification date', 'modtime' => 'Modification date',
// 'groups' => 'Groups (dont know what this field is for)', // 'groups' => 'Groups (dont know what this field is for)',
// 'cal_type' => 'cal_type: single_event=E (default) else M', // 'cal_type' => 'cal_type: single_event=E (default) else M',
); );
@ -187,7 +193,7 @@ function cat_id($cats)
} }
$csv_fields = fgetcsv($fp,8000,$_POST['fieldsep']); $csv_fields = fgetcsv($fp,8000,$_POST['fieldsep']);
$csv_fields = $GLOBALS['phpgw']->translation->convert($csv_fields,$_POST['charset']); $csv_fields = $GLOBALS['phpgw']->translation->convert($csv_fields,$_POST['charset']);
$csv_fields[] = 'no CSV 1'; // eg. for static assignments $csv_fields[] = 'no CSV 1'; // eg. for static assignments
$csv_fields[] = 'no CSV 2'; $csv_fields[] = 'no CSV 2';
$csv_fields[] = 'no CSV 3'; $csv_fields[] = 'no CSV 3';
foreach($csv_fields as $csv_idx => $csv_field) foreach($csv_fields as $csv_idx => $csv_field)
@ -222,7 +228,7 @@ function cat_id($cats)
'fieldsep'=> $_POST['fieldsep'], 'fieldsep'=> $_POST['fieldsep'],
'charset' => $_POST['charset'] 'charset' => $_POST['charset']
)); ));
$help_on_trans = "<a name=\"help\"></a><b>How to use Translation's</b><p>". $help_on_trans = "<a name=\"help\"></a><b>How to use Translation's</b><p>".
"Translations enable you to change / adapt the content of each CSV field for your needs. <br>". "Translations enable you to change / adapt the content of each CSV field for your needs. <br>".
"General syntax is: <b>pattern1 ${ASep} replacement1 ${PSep} ... ${PSep} patternN ${ASep} replacementN</b><br>". "General syntax is: <b>pattern1 ${ASep} replacement1 ${PSep} ... ${PSep} patternN ${ASep} replacementN</b><br>".
"If the pattern-part of a pair is ommited it will match everything ('^.*$'), which is only ". "If the pattern-part of a pair is ommited it will match everything ('^.*$'), which is only ".
@ -276,7 +282,7 @@ function cat_id($cats)
$fp=fopen($csvfile,'r'); $fp=fopen($csvfile,'r');
$csv_fields = fgetcsv($fp,8000,$_POST['fieldsep']); $csv_fields = fgetcsv($fp,8000,$_POST['fieldsep']);
$csv_fields = $GLOBALS['phpgw']->translation->convert($csv_fields,$_POST['charset']); $csv_fields = $GLOBALS['phpgw']->translation->convert($csv_fields,$_POST['charset']);
$csv_fields[] = 'no CSV 1'; // eg. for static assignments $csv_fields[] = 'no CSV 1'; // eg. for static assignments
$csv_fields[] = 'no CSV 2'; $csv_fields[] = 'no CSV 2';
$csv_fields[] = 'no CSV 3'; $csv_fields[] = 'no CSV 3';
@ -334,7 +340,7 @@ function cat_id($cats)
$start = $_POST['start'] < 1 ? 1 : $_POST['start']; $start = $_POST['start'] < 1 ? 1 : $_POST['start'];
// ignore empty lines, is_null($fields[0]) is returned on empty lines !!! // ignore empty lines, is_null($fields[0]) is returned on empty lines !!!
for($i = 1; $i < $start; ++$i) // overread lines before our start-record for($i = 1; $i < $start; ++$i) // overread lines before our start-record
{ {
while(($fields = fgetcsv($fp,8000,$_POST['fieldsep'])) && is_null($fields[0])) ; while(($fields = fgetcsv($fp,8000,$_POST['fieldsep'])) && is_null($fields[0])) ;
} }

View File

@ -36,7 +36,7 @@
function boalarm() function boalarm()
{ {
$cal_id = (isset($_POST['cal_id'])?intval($_POST['cal_id']):''); $cal_id = (isset($_POST['cal_id'])?(int)$_POST['cal_id']:'');
if($cal_id) if($cal_id)
{ {
$this->cal_id = $cal_id; $this->cal_id = $cal_id;
@ -71,7 +71,7 @@
function read_entry($cal_id) function read_entry($cal_id)
{ {
return $this->bo->read_entry(intval($cal_id)); return $this->bo->read_entry((int)$cal_id);
} }
/*! /*!
@ -168,7 +168,7 @@
{ {
return -1; return -1;
} }
$alarm['enabled'] = intval(!$alarm['enabled']); $alarm['enabled'] = (int)(!$alarm['enabled']);
if ($this->so->save_alarm($alarm['cal_id'],$alarm)) if ($this->so->save_alarm($alarm['cal_id'],$alarm))
{ {
++$enabled; ++$enabled;

View File

@ -170,9 +170,9 @@
ereg('menuaction=([a-zA-Z.]+)',$_SERVER['HTTP_REFERER'],$regs); ereg('menuaction=([a-zA-Z.]+)',$_SERVER['HTTP_REFERER'],$regs);
$from = $regs[1]; $from = $regs[1];
if ((substr($_SERVER['PHP_SELF'],-8) == 'home.php' && substr($this->prefs['calendar']['defaultcalendar'],0,7) == 'planner' if ((substr($_SERVER['PHP_SELF'],-8) == 'home.php' && substr($this->prefs['calendar']['defaultcalendar'],0,7) == 'planner'
|| $_GET['menuaction'] == 'calendar.uicalendar.planner' && || $_GET['menuaction'] == 'calendar.uicalendar.planner' &&
$from != 'calendar.uicalendar.planner' && !$this->save_owner) $from != 'calendar.uicalendar.planner' && !$this->save_owner)
&& intval($this->prefs['calendar']['planner_start_with_group']) > 0) && (int)$this->prefs['calendar']['planner_start_with_group'] > 0)
{ {
// entering planner for the first time ==> saving owner in save_owner, setting owner to default // entering planner for the first time ==> saving owner in save_owner, setting owner to default
// //
@ -180,11 +180,11 @@
$owner = 'g_'.$this->prefs['calendar']['planner_start_with_group']; $owner = 'g_'.$this->prefs['calendar']['planner_start_with_group'];
} }
elseif ($_GET['menuaction'] != 'calendar.uicalendar.planner' && elseif ($_GET['menuaction'] != 'calendar.uicalendar.planner' &&
$this->save_owner) $this->save_owner)
{ {
// leaving planner with an unchanged user/owner ==> setting owner back to save_owner // leaving planner with an unchanged user/owner ==> setting owner back to save_owner
// //
$owner = intval(isset($_GET['owner']) ? $_GET['owner'] : $this->save_owner); $owner = (int)(isset($_GET['owner']) ? $_GET['owner'] : $this->save_owner);
unset($this->save_owner); unset($this->save_owner);
} }
elseif (!empty($owner) && $owner != $this->owner && $from == 'calendar.uicalendar.planner') elseif (!empty($owner) && $owner != $this->owner && $from == 'calendar.uicalendar.planner')
@ -200,15 +200,15 @@
} }
elseif(isset($owner) && $owner!='') elseif(isset($owner) && $owner!='')
{ {
$this->owner = intval($owner); $this->owner = (int)$owner;
} }
elseif(!@isset($this->owner) || !@$this->owner) elseif(!@isset($this->owner) || !@$this->owner)
{ {
$this->owner = intval($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') elseif(isset($this->owner) && $GLOBALS['phpgw']->accounts->get_type($this->owner) == 'g')
{ {
$this->set_owner_to_group(intval($this->owner)); $this->set_owner_to_group((int)$this->owner);
} }
$this->prefs['common'] = $GLOBALS['phpgw_info']['user']['preferences']['common']; $this->prefs['common'] = $GLOBALS['phpgw_info']['user']['preferences']['common'];
@ -226,7 +226,7 @@
$friendly = (isset($_GET['friendly'])?$_GET['friendly']:''); $friendly = (isset($_GET['friendly'])?$_GET['friendly']:'');
$friendly = ($friendly=='' && isset($_POST['friendly'])?$_POST['friendly']:$friendly); $friendly = ($friendly=='' && isset($_POST['friendly'])?$_POST['friendly']:$friendly);
$this->printer_friendly = (intval($friendly) == 1?True:False); $this->printer_friendly = ((int)$friendly == 1?True:False);
if(isset($_POST['filter'])) { $this->filter = $_POST['filter']; } if(isset($_POST['filter'])) { $this->filter = $_POST['filter']; }
if(isset($_POST['sortby'])) { $this->sortby = $_POST['sortby']; } if(isset($_POST['sortby'])) { $this->sortby = $_POST['sortby']; }
@ -239,7 +239,7 @@
if(!isset($this->sortby)) if(!isset($this->sortby))
{ {
$this->sortby = $this->prefs['calendar']['defaultcalendar'] == 'planner_user' ? 'user' : 'category'; $this->sortby = $this->prefs['calendar']['defaultcalendar'] == 'planner_user' ? 'user' : 'category';
} }
if($GLOBALS['phpgw']->accounts->get_type($this->owner)=='g') if($GLOBALS['phpgw']->accounts->get_type($this->owner)=='g')
@ -304,9 +304,9 @@
if(isset($date) && $date!='') if(isset($date) && $date!='')
{ {
$this->year = intval(substr($date,0,4)); $this->year = (int)(substr($date,0,4));
$this->month = intval(substr($date,4,2)); $this->month = (int)(substr($date,4,2));
$this->day = intval(substr($date,6,2)); $this->day = (int)(substr($date,6,2));
} }
else else
{ {
@ -435,7 +435,7 @@
function set_owner_to_group($owner) function set_owner_to_group($owner)
{ {
print_debug('calendar::bocalendar::set_owner_to_group:owner',$owner); print_debug('calendar::bocalendar::set_owner_to_group:owner',$owner);
$this->owner = intval($owner); $this->owner = (int)$owner;
$this->is_group = True; $this->is_group = True;
$this->g_owner = Array(); $this->g_owner = Array();
$members = $GLOBALS['phpgw']->accounts->member($owner); $members = $GLOBALS['phpgw']->accounts->member($owner);
@ -512,12 +512,12 @@
$this->filter = $data['filter']; $this->filter = $data['filter'];
$this->cat_id = $data['cat_id']; $this->cat_id = $data['cat_id'];
$this->sortby = $data['sortby']; $this->sortby = $data['sortby'];
$this->owner = intval($data['owner']); $this->owner = (int)$data['owner'];
$this->save_owner = intval($data['save_owner']); $this->save_owner = (int)$data['save_owner'];
$this->year = intval($data['year']); $this->year = (int)$data['year'];
$this->month = intval($data['month']); $this->month = (int)$data['month'];
$this->day = intval($data['day']); $this->day = (int)$data['day'];
$this->num_months = intval($data['num_months']); $this->num_months = (int)$data['num_months'];
$this->return_to = $data['return_to']; $this->return_to = $data['return_to'];
} }
@ -533,7 +533,7 @@
$event = $this->so->read_entry($id); $event = $this->so->read_entry($id);
if(!isset($event['participants'][$this->owner]) && $this->user_is_a_member($event,$this->owner)) if(!isset($event['participants'][$this->owner]) && $this->user_is_a_member($event,$this->owner))
{ {
$this->so->add_attribute('participants','U',intval($this->owner)); $this->so->add_attribute('participants','U',(int)$this->owner);
$this->so->add_entry($event); $this->so->add_entry($event);
$event = $this->get_cached_event(); $event = $this->get_cached_event();
} }
@ -544,14 +544,14 @@
function delete_single($param) function delete_single($param)
{ {
if($this->check_perms(PHPGW_ACL_DELETE,intval($param['id']))) if($this->check_perms(PHPGW_ACL_DELETE,(int)$param['id']))
{ {
$temp_event = $this->get_cached_event(); $temp_event = $this->get_cached_event();
$event = $this->read_entry(intval($param['id'])); $event = $this->read_entry((int)$param['id']);
// if($this->owner == $event['owner']) // if($this->owner == $event['owner'])
// { // {
$exception_time = mktime($event['start']['hour'],$event['start']['min'],0,$param['month'],$param['day'],$param['year']) - $GLOBALS['phpgw']->datetime->tz_offset; $exception_time = mktime($event['start']['hour'],$event['start']['min'],0,$param['month'],$param['day'],$param['year']) - $GLOBALS['phpgw']->datetime->tz_offset;
$event['recur_exception'][] = intval($exception_time); $event['recur_exception'][] = (int)$exception_time;
$this->so->cal->event = $event; $this->so->cal->event = $event;
// print_debug('exception time',$event['recur_exception'][count($event['recur_exception']) -1]); // print_debug('exception time',$event['recur_exception'][count($event['recur_exception']) -1]);
// print_debug('count event exceptions',count($event['recur_exception'])); // print_debug('count event exceptions',count($event['recur_exception']));
@ -600,17 +600,17 @@
{ {
while(list($key,$value) = each($params['reinstate_index'])) while(list($key,$value) = each($params['reinstate_index']))
{ {
print_debug('reinstate_index ['.$key.']',intval($value)); print_debug('reinstate_index ['.$key.']',(int)$value);
print_debug('exception time',$event['recur_exception'][intval($value)]); print_debug('exception time',$event['recur_exception'][(int)$value]);
unset($event['recur_exception'][intval($value)]); unset($event['recur_exception'][(int)$value]);
print_debug('count event exceptions',count($event['recur_exception'])); print_debug('count event exceptions',count($event['recur_exception']));
} }
} }
else else
{ {
print_debug('reinstate_index[0]',intval($params['reinstate_index'][0])); print_debug('reinstate_index[0]',(int)$params['reinstate_index'][0]);
print_debug('exception time',$event['recur_exception'][intval($params['reinstate_index'][0])]); print_debug('exception time',$event['recur_exception'][(int)$params['reinstate_index'][0]]);
unset($event['recur_exception'][intval($params['reinstate_index'][0])]); unset($event['recur_exception'][(int)$params['reinstate_index'][0]]);
print_debug('count event exceptions',count($event['recur_exception'])); print_debug('count event exceptions',count($event['recur_exception']));
} }
$this->so->cal->event = $event; $this->so->cal->event = $event;
@ -808,7 +808,7 @@
$l_categories = 0; $l_categories = 0;
} }
$is_public = intval(isset($l_cal['public']) ? $l_cal['public'] : $l_cal['private'] == 'public'); $is_public = (int)(isset($l_cal['public']) ? $l_cal['public'] : $l_cal['private'] == 'public');
$this->so->event_init(); $this->so->event_init();
$this->add_attribute('uid',$l_cal['uid']); $this->add_attribute('uid',$l_cal['uid']);
if(count($l_categories) >= 2) if(count($l_categories) >= 2)
@ -842,36 +842,36 @@
$l_recur_enddate = $this->jscal->input2date($l_recur_enddate['str'],False,'mday'); $l_recur_enddate = $this->jscal->input2date($l_recur_enddate['str'],False,'mday');
} }
switch(intval($l_cal['recur_type'])) switch((int)$l_cal['recur_type'])
{ {
case MCAL_RECUR_NONE: case MCAL_RECUR_NONE:
$this->so->set_recur_none(); $this->so->set_recur_none();
break; break;
case MCAL_RECUR_DAILY: case MCAL_RECUR_DAILY:
$this->so->set_recur_daily(intval($l_recur_enddate['year']),intval($l_recur_enddate['month']),intval($l_recur_enddate['mday']),intval($l_cal['recur_interval'])); $this->so->set_recur_daily((int)$l_recur_enddate['year'],(int)$l_recur_enddate['month'],(int)$l_recur_enddate['mday'],(int)$l_cal['recur_interval']);
break; break;
case MCAL_RECUR_WEEKLY: case MCAL_RECUR_WEEKLY:
foreach(array('rpt_sun','rpt_mon','rpt_tue','rpt_wed','rpt_thu','rpt_fri','rpt_sat') as $rpt_day) foreach(array('rpt_sun','rpt_mon','rpt_tue','rpt_wed','rpt_thu','rpt_fri','rpt_sat') as $rpt_day)
{ {
$l_cal['recur_data'] += intval($l_cal[$rpt_day]); $l_cal['recur_data'] += (int)$l_cal[$rpt_day];
} }
if (is_array($l_cal['rpt_day'])) if (is_array($l_cal['rpt_day']))
{ {
foreach ($l_cal['rpt_day'] as $mask) foreach ($l_cal['rpt_day'] as $mask)
{ {
$l_cal['recur_data'] |= intval($mask); $l_cal['recur_data'] |= (int)$mask;
} }
} }
$this->so->set_recur_weekly(intval($l_recur_enddate['year']),intval($l_recur_enddate['month']),intval($l_recur_enddate['mday']),intval($l_cal['recur_interval']),$l_cal['recur_data']); $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; break;
case MCAL_RECUR_MONTHLY_MDAY: case MCAL_RECUR_MONTHLY_MDAY:
$this->so->set_recur_monthly_mday(intval($l_recur_enddate['year']),intval($l_recur_enddate['month']),intval($l_recur_enddate['mday']),intval($l_cal['recur_interval'])); $this->so->set_recur_monthly_mday((int)$l_recur_enddate['year'],(int)$l_recur_enddate['month'],(int)$l_recur_enddate['mday'],(int)$l_cal['recur_interval']);
break; break;
case MCAL_RECUR_MONTHLY_WDAY: case MCAL_RECUR_MONTHLY_WDAY:
$this->so->set_recur_monthly_wday(intval($l_recur_enddate['year']),intval($l_recur_enddate['month']),intval($l_recur_enddate['mday']),intval($l_cal['recur_interval'])); $this->so->set_recur_monthly_wday((int)$l_recur_enddate['year'],(int)$l_recur_enddate['month'],(int)$l_recur_enddate['mday'],(int)$l_cal['recur_interval']);
break; break;
case MCAL_RECUR_YEARLY: case MCAL_RECUR_YEARLY:
$this->so->set_recur_yearly(intval($l_recur_enddate['year']),intval($l_recur_enddate['month']),intval($l_recur_enddate['mday']),intval($l_cal['recur_interval'])); $this->so->set_recur_yearly((int)$l_recur_enddate['year'],(int)$l_recur_enddate['month'],(int)$l_recur_enddate['mday'],(int)$l_cal['recur_interval']);
break; break;
} }
@ -882,23 +882,23 @@
$part = Array(); $part = Array();
for($i=0;$i<count($parts);$i++) for($i=0;$i<count($parts);$i++)
{ {
if (($accept_type = substr($parts[$i],-1,1)) == '0' || intval($accept_type) > 0) if (($accept_type = substr($parts[$i],-1,1)) == '0' || (int)$accept_type > 0)
{ {
$accept_type = 'U'; $accept_type = 'U';
} }
$acct_type = $GLOBALS['phpgw']->accounts->get_type(intval($parts[$i])); $acct_type = $GLOBALS['phpgw']->accounts->get_type((int)$parts[$i]);
if($acct_type == 'u') if($acct_type == 'u')
{ {
$part[intval($parts[$i])] = $accept_type; $part[(int)$parts[$i]] = $accept_type;
} }
elseif($acct_type == 'g') elseif($acct_type == 'g')
{ {
$part[intval($parts[$i])] = $accept_type; $part[(int)$parts[$i]] = $accept_type;
$groups[] = $parts[$i]; $groups[] = $parts[$i];
/* This pulls ALL users of a group and makes them as participants to the event */ /* 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. */ /* I would like to turn this back into a group thing. */
$acct = CreateObject('phpgwapi.accounts',intval($parts[$i])); $acct = CreateObject('phpgwapi.accounts',(int)$parts[$i]);
$members = $acct->member(intval($parts[$i])); $members = $acct->member((int)$parts[$i]);
unset($acct); unset($acct);
if($members == False) if($members == False)
{ {
@ -921,14 +921,14 @@
@reset($part); @reset($part);
while(list($key,$accept_type) = each($part)) while(list($key,$accept_type) = each($part))
{ {
$this->so->add_attribute('participants',$accept_type,intval($key)); $this->so->add_attribute('participants',$accept_type,(int)$key);
} }
} }
if($groups) if($groups)
{ {
@reset($groups); @reset($groups);
$this->so->add_attribute('groups',intval($group_id)); $this->so->add_attribute('groups',(int)$group_id);
} }
$event = $this->get_cached_event(); $event = $this->get_cached_event();
@ -1027,10 +1027,10 @@
unset($GLOBALS['phpgw_info']['flags']['noheader']); unset($GLOBALS['phpgw_info']['flags']['noheader']);
unset($GLOBALS['phpgw_info']['flags']['nonavbar']); unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
ExecMethod('calendar.uicalendar.overlap', ExecMethod('calendar.uicalendar.overlap',
Array( Array(
'o_events' => $overlapping_events, 'o_events' => $overlapping_events,
'this_event' => $event 'this_event' => $event
) )
); );
$GLOBALS['phpgw']->common->phpgw_exit(True); $GLOBALS['phpgw']->common->phpgw_exit(True);
} }
@ -1055,7 +1055,7 @@
// if old event has alarm and the start-time changed => update them // if old event has alarm and the start-time changed => update them
//echo "<p>checking ".count($old_event['alarm'])." alarms of event #$event[id] start moved from ".print_r($old_event['start'],True)." to ".print_r($event['start'],True)."</p>\n"; //echo "<p>checking ".count($old_event['alarm'])." alarms of event #$event[id] start moved from ".print_r($old_event['start'],True)." to ".print_r($event['start'],True)."</p>\n";
if ($old_event['alarm'] && if ($old_event['alarm'] &&
$this->maketime($old_event['start']) != $this->maketime($event['start'])) $this->maketime($old_event['start']) != $this->maketime($event['start']))
{ {
$this->so->delete_alarms($old_event['id']); $this->so->delete_alarms($old_event['id']);
foreach($old_event['alarm'] as $id => $alarm) foreach($old_event['alarm'] as $id => $alarm)
@ -1083,7 +1083,7 @@
} }
else else
{ {
return intval($event['id']); return (int)$event['id'];
} }
} }
return True; return True;
@ -1141,13 +1141,13 @@
function time2array($time,$alarm = 0) function time2array($time,$alarm = 0)
{ {
return array( return array(
'year' => intval(date('Y',$time)), 'year' => (int)(date('Y',$time)),
'month' => intval(date('m',$time)), 'month' => (int)(date('m',$time)),
'mday' => intval(date('d',$time)), 'mday' => (int)(date('d',$time)),
'hour' => intval(date('H',$time)), 'hour' => (int)(date('H',$time)),
'min' => intval(date('i',$time)), 'min' => (int)(date('i',$time)),
'sec' => intval(date('s',$time)), 'sec' => (int)(date('s',$time)),
'alarm' => intval($alarm) 'alarm' => (int)($alarm)
); );
} }
@ -1245,7 +1245,7 @@
{ {
//echo "testing event[participants][uid=$uid] = '".$event['participants'][$uid]."'<br>\n"; //echo "testing event[participants][uid=$uid] = '".$event['participants'][$uid]."'<br>\n";
if (isset($event['participants'][$uid]) && $event['participants'][$uid] != 'R' && if (isset($event['participants'][$uid]) && $event['participants'][$uid] != 'R' &&
$status != 'R') $status != 'R')
{ {
return True; // found not rejected participant in event return True; // found not rejected participant in event
} }
@ -1265,14 +1265,14 @@
$temp_cache_events = $this->cached_events; $temp_cache_events = $this->cached_events;
} }
// $temp_start = intval($GLOBALS['phpgw']->common->show_date($starttime,'Ymd')); // $temp_start = (int)$GLOBALS['phpgw']->common->show_date($starttime,'Ymd');
// $temp_start_time = intval($GLOBALS['phpgw']->common->show_date($starttime,'Hi')); // $temp_start_time = (int)($GLOBALS['phpgw']->common->show_date($starttime,'Hi');
// $temp_end = intval($GLOBALS['phpgw']->common->show_date($endtime,'Ymd')); // $temp_end = (int)$GLOBALS['phpgw']->common->show_date($endtime,'Ymd');
// $temp_end_time = intval($GLOBALS['phpgw']->common->show_date($endtime,'Hi')); // $temp_end_time = (int)$GLOBALS['phpgw']->common->show_date($endtime,'Hi');
$temp_start = intval(date('Ymd',$starttime)); $temp_start = (int)(date('Ymd',$starttime));
$temp_start_time = intval(date('Hi',$starttime)); $temp_start_time = (int)(date('Hi',$starttime));
$temp_end = intval(date('Ymd',$endtime)); $temp_end = (int)(date('Ymd',$endtime));
$temp_end_time = intval(date('Hi',$endtime)); $temp_end_time = (int)(date('Hi',$endtime));
if($this->debug) if($this->debug)
{ {
echo '<!-- Temp_Start: '.$temp_start.' -->'."\n"; echo '<!-- Temp_Start: '.$temp_start.' -->'."\n";
@ -1352,16 +1352,16 @@
$temp_event_end = sprintf("%d%02d",$event['end']['hour'],$event['end']['min']); $temp_event_end = sprintf("%d%02d",$event['end']['hour'],$event['end']['min']);
// if((($temp_start_time <= $temp_event_start) && ($temp_end_time >= $temp_event_start) && ($temp_end_time <= $temp_event_end)) || // if((($temp_start_time <= $temp_event_start) && ($temp_end_time >= $temp_event_start) && ($temp_end_time <= $temp_event_end)) ||
if(($temp_start_time <= $temp_event_start && if(($temp_start_time <= $temp_event_start &&
$temp_end_time > $temp_event_start && $temp_end_time > $temp_event_start &&
$temp_end_time <= $temp_event_end || $temp_end_time <= $temp_event_end ||
$temp_start_time >= $temp_event_start && $temp_start_time >= $temp_event_start &&
$temp_start_time < $temp_event_end && $temp_start_time < $temp_event_end &&
$temp_end_time >= $temp_event_end || $temp_end_time >= $temp_event_end ||
$temp_start_time <= $temp_event_start && $temp_start_time <= $temp_event_start &&
$temp_end_time >= $temp_event_end || $temp_end_time >= $temp_event_end ||
$temp_start_time >= $temp_event_start && $temp_start_time >= $temp_event_start &&
$temp_end_time <= $temp_event_end) && $temp_end_time <= $temp_event_end) &&
$this->participants_not_rejected($participants,$event)) $this->participants_not_rejected($participants,$event))
{ {
if($this->debug) if($this->debug)
{ {
@ -1447,7 +1447,7 @@
{ {
$access = $user == $owner || $grants & $needed && (!$private || $grants & PHPGW_ACL_PRIVATE); $access = $user == $owner || $grants & $needed && (!$private || $grants & PHPGW_ACL_PRIVATE);
} }
//echo "<p>".function_backtrace()." check_perms($needed,$event_id,$other) for user $user and needed_acl $needed: event='$event[title]': owner=$owner, privat=$private, grants=$grants ==> access=$access</p>\n"; //echo "<p>".function_backtrace()." check_perms($needed,$event_id,$other) for user $user and needed_acl $needed: event='$event[title]': owner=$owner, private=$private, grants=$grants ==> access=$access</p>\n";
return $access; return $access;
} }
@ -1618,7 +1618,7 @@
function normalizeminutes(&$minutes) function normalizeminutes(&$minutes)
{ {
$hour = 0; $hour = 0;
$min = intval($minutes); $min = (int)$minutes;
if($min >= 60) if($min >= 60)
{ {
$hour += $min / 60; $hour += $min / 60;
@ -1633,9 +1633,9 @@
{ {
$temp = array('hour','minute','second','ampm'); $temp = array('hour','minute','second','ampm');
$time = strrev($time); $time = strrev($time);
$second = intval(strrev(substr($time,0,2))); $second = (int)(strrev(substr($time,0,2)));
$minute = intval(strrev(substr($time,2,2))); $minute = (int)(strrev(substr($time,2,2)));
$hour = intval(strrev(substr($time,4))); $hour = (int)(strrev(substr($time,4)));
$hour += $this->normalizeminutes(&$minute); $hour += $this->normalizeminutes(&$minute);
$temp['second'] = $second; $temp['second'] = $second;
$temp['minute'] = $minute; $temp['minute'] = $minute;
@ -1654,9 +1654,9 @@
{ {
$temp['hour'] = (int)((int)$temp['hour'] - 12); $temp['hour'] = (int)((int)$temp['hour'] - 12);
$temp['ampm'] = 'pm'; $temp['ampm'] = 'pm';
} }
elseif ((int)$temp['hour'] == 12) elseif ((int)$temp['hour'] == 12)
{ {
$temp['ampm'] = 'pm'; $temp['ampm'] = 'pm';
} }
} }
@ -1671,12 +1671,12 @@
$exceptions = explode(',',$exception_str); $exceptions = explode(',',$exception_str);
for($exception_count=0;$exception_count<count($exceptions);$exception_count++) for($exception_count=0;$exception_count<count($exceptions);$exception_count++)
{ {
$exception[] = intval($exceptions[$exception_count]); $exception[] = (int)$exceptions[$exception_count];
} }
} }
elseif($exception_str != '') elseif($exception_str != '')
{ {
$exception[] = intval($exception_str); $exception[] = (int)$exception_str;
} }
return $exception; return $exception;
} }
@ -1699,7 +1699,7 @@
$inserted = False; $inserted = False;
if(isset($event['recur_exception'])) if(isset($event['recur_exception']))
{ {
$event_time = mktime($event['start']['hour'],$event['start']['min'],0,intval(substr($date,4,2)),intval(substr($date,6,2)),intval(substr($date,0,4))) - $GLOBALS['phpgw']->datetime->tz_offset; $event_time = mktime($event['start']['hour'],$event['start']['min'],0,(int)(substr($date,4,2)),(int)(substr($date,6,2)),(int)(substr($date,0,4))) - $GLOBALS['phpgw']->datetime->tz_offset;
while($inserted == False && list($key,$exception_time) = each($event['recur_exception'])) while($inserted == False && list($key,$exception_time) = each($event['recur_exception']))
{ {
if($this->debug) if($this->debug)
@ -2028,7 +2028,7 @@
return; return;
} }
$cache_start = intval(sprintf("%04d%02d%02d",$syear,$smonth,$sday)); $cache_start = (int)(sprintf("%04d%02d%02d",$syear,$smonth,$sday));
if($c_cached_ids) if($c_cached_ids)
{ {
for($i=0;$i<$c_cached_ids;$i++) for($i=0;$i<$c_cached_ids;$i++)
@ -2038,15 +2038,15 @@
{ {
continue; // fetch recuring events only in 2. loop continue; // fetch recuring events only in 2. loop
} }
$startdate = intval(date('Ymd',$this->maketime($event['start']))); $startdate = (int)(date('Ymd',$this->maketime($event['start'])));
$enddate = intval(date('Ymd',$this->maketime($event['end']))); $enddate = (int)(date('Ymd',$this->maketime($event['end'])));
$this->cached_events[$startdate][] = $event; $this->cached_events[$startdate][] = $event;
if($startdate != $enddate) if($startdate != $enddate)
{ {
$start['year'] = intval(substr($startdate,0,4)); $start['year'] = (int)(substr($startdate,0,4));
$start['month'] = intval(substr($startdate,4,2)); $start['month'] = (int)(substr($startdate,4,2));
$start['mday'] = intval(substr($startdate,6,2)); $start['mday'] = (int)(substr($startdate,6,2));
for($j=$startdate,$k=0;$j<=$enddate;$k++,$j=intval(date('Ymd',mktime(0,0,0,$start['month'],$start['mday'] + $k,$start['year'])))) for($j=$startdate,$k=0;$j<=$enddate;$k++,$j=(int)(date('Ymd',mktime(0,0,0,$start['month'],$start['mday'] + $k,$start['year']))))
{ {
$c_evt_day = count($this->cached_events[$j]) - 1; $c_evt_day = count($this->cached_events[$j]) - 1;
if($c_evt_day < 0) if($c_evt_day < 0)
@ -2206,7 +2206,7 @@
{ {
foreach(array('year','month','mday','hour','min','sec') as $n => $name) foreach(array('year','month','mday','hour','min','sec') as $n => $name)
{ {
$date[$name] = intval($arr[$n]); $date[$name] = (int)$arr[$n];
} }
return $timestamp ? mktime($date['hour'],$date['min'],$date['sec'], return $timestamp ? mktime($date['hour'],$date['min'],$date['sec'],
$date['month'],$date['mday'],$date['year']) : $date; $date['month'],$date['mday'],$date['year']) : $date;
@ -2336,7 +2336,7 @@
for($m=0;$m<$interval;$m++) for($m=0;$m<$interval;$m++)
{ {
$minutes = $increment * $m; $minutes = $increment * $m;
if(intval($starttemp['minute']) > $minutes && intval($starttemp['minute']) < ($minutes + $increment)) if((int)$starttemp['minute'] > $minutes && (int)$starttemp['minute'] < ($minutes + $increment))
{ {
$subminute = ($starttemp['minute'] - $minutes) * 100; $subminute = ($starttemp['minute'] - $minutes) * 100;
} }
@ -2362,11 +2362,11 @@
$startminute = 0; $startminute = 0;
$endminute = $interval; $endminute = $interval;
$hour = $h * 10000; $hour = $h * 10000;
if($h == intval($starttemp['hour'])) if($h == (int)$starttemp['hour'])
{ {
$startminute = ($starttemp['minute'] / $increment); $startminute = ($starttemp['minute'] / $increment);
} }
if($h == intval($endtemp['hour'])) if($h == (int)$endtemp['hour'])
{ {
$endminute = ($endtemp['minute'] / $increment); $endminute = ($endtemp['minute'] / $increment);
} }
@ -2453,7 +2453,7 @@
} }
case 'add_cancel': case 'add_cancel':
if ($old_event['owner'] == $userid && $msg_is_response || if ($old_event['owner'] == $userid && $msg_is_response ||
$msg_type == MSG_DELETED || $msg_type == MSG_ADDED) $msg_type == MSG_DELETED || $msg_type == MSG_ADDED)
{ {
++$want_update; ++$want_update;
} }
@ -2495,7 +2495,7 @@
$temp_timeformat = $this->prefs['common']['timeformat']; $temp_timeformat = $this->prefs['common']['timeformat'];
$temp_dateformat = $this->prefs['common']['dateformat']; $temp_dateformat = $this->prefs['common']['dateformat'];
$tz_offset = ((60 * 60) * intval($temp_tz_offset)); $tz_offset = ((60 * 60) * (int)$temp_tz_offset);
if($old_event != False) if($old_event != False)
{ {
@ -2593,7 +2593,7 @@
foreach($to_notify as $userid => $statusid) foreach($to_notify as $userid => $statusid)
{ {
$userid = intval($userid); $userid = (int)$userid;
if ($statusid == 'R') if ($statusid == 'R')
{ {
@ -2626,7 +2626,7 @@
$GLOBALS['phpgw_info']['user']['preferences']['common']['timeformat'] = $part_prefs['common']['timeformat']; $GLOBALS['phpgw_info']['user']['preferences']['common']['timeformat'] = $part_prefs['common']['timeformat'];
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'] = $part_prefs['common']['dateformat']; $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'] = $part_prefs['common']['dateformat'];
$GLOBALS['phpgw']->datetime->tz_offset = ((60 * 60) * intval($GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset'])); $GLOBALS['phpgw']->datetime->tz_offset = ((60 * 60) * (int)$GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset']);
if($old_starttime) if($old_starttime)
{ {
@ -2773,12 +2773,12 @@
if(isset($new_event['participants'][$old_userid])) if(isset($new_event['participants'][$old_userid]))
{ {
print_debug('Modifying event for user',$old_userid); print_debug('Modifying event for user',$old_userid);
$this->modified[intval($old_userid)] = $new_status; $this->modified[(int)$old_userid] = $new_status;
} }
else else
{ {
print_debug('Deleting user from the event',$old_userid); print_debug('Deleting user from the event',$old_userid);
$this->deleted[intval($old_userid)] = $old_status; $this->deleted[(int)$old_userid] = $old_status;
} }
} }
// Find new users..... // Find new users.....
@ -2878,8 +2878,8 @@
function rejected_no_show($event) function rejected_no_show($event)
{ {
$ret = !$this->prefs['calendar']['show_rejected'] && $ret = !$this->prefs['calendar']['show_rejected'] &&
$event['owner'] != $this->owner && $event['owner'] != $this->owner &&
$event['participants'][$this->owner] == 'R'; $event['participants'][$this->owner] == 'R';
//echo "<p>rejected_no_show($event[title])='$ret': user=$this->owner, event-owner=$event[owner], status='".$event['participants'][$this->owner]."', show_rejected='".$this->prefs['calendar']['show_rejected']."'</p>\n"; //echo "<p>rejected_no_show($event[title])='$ret': user=$this->owner, event-owner=$event[owner], status='".$event['participants'][$this->owner]."', show_rejected='".$this->prefs['calendar']['show_rejected']."'</p>\n";
return $ret; return $ret;
} }
@ -2994,7 +2994,7 @@
$pri = Array( $pri = Array(
1 => lang('Low'), 1 => lang('Low'),
2 => lang('Normal'), 2 => lang('Normal'),
3 => lang('High') 3 => lang('High')
); );
$var['priority'] = Array( $var['priority'] = Array(
'field' => lang('Priority'), 'field' => lang('Priority'),
@ -3013,7 +3013,7 @@
$var['access'] = Array( $var['access'] = Array(
'field' => lang('Access'), 'field' => lang('Access'),
'data' => $event['public'] ? lang('Public') : lang('Privat') 'data' => $event['public'] ? lang('Public') : lang('Private')
); );
if(@isset($event['groups'][0])) if(@isset($event['groups'][0]))

View File

@ -48,7 +48,7 @@
{ {
$this->so = CreateObject('calendar.soholiday'); $this->so = CreateObject('calendar.soholiday');
$this->start = intval(get_var('start',array('POST','GET'))); $this->start = (int)get_var('start',array('POST','GET'));
$this->query = get_var('query',array('POST','GET')); $this->query = get_var('query',array('POST','GET'));
$this->sort = get_var('sort',array('POST','GET')); $this->sort = get_var('sort',array('POST','GET'));
$this->order = get_var('order',array('POST','GET')); $this->order = get_var('order',array('POST','GET'));
@ -270,11 +270,11 @@
{ {
$holiday['locale'] = $holiday[0]; $holiday['locale'] = $holiday[0];
$holiday['name'] = $GLOBALS['phpgw']->db->db_addslashes($holiday[1]); $holiday['name'] = $GLOBALS['phpgw']->db->db_addslashes($holiday[1]);
$holiday['mday'] = intval($holiday[2]); $holiday['mday'] = (int)$holiday[2];
$holiday['month_num'] = intval($holiday[3]); $holiday['month_num'] = (int)$holiday[3];
$holiday['occurence'] = intval($holiday[4]); $holiday['occurence'] = (int)$holiday[4];
$holiday['dow'] = intval($holiday[5]); $holiday['dow'] = (int)$holiday[5];
$holiday['observance_rule'] = intval($holiday[6]); $holiday['observance_rule'] = (int)$holiday[6];
$holiday['hol_id'] = 0; $holiday['hol_id'] = 0;
$this->so->save_holiday($holiday); $this->so->save_holiday($holiday);
} }
@ -322,11 +322,10 @@
} }
else else
{ {
$holiday['occurence'] = intval($holiday['occurence'] ? $holiday['occurence'] : $holiday['year']); $holiday['occurence'] = (int)($holiday['occurence'] ? $holiday['occurence'] : $holiday['year']);
unset($holiday['year']); unset($holiday['year']);
} }
// Still need to put some validation in here..... // Still need to put some validation in here.....
$this->ui = CreateObject('calendar.uiholiday'); $this->ui = CreateObject('calendar.uiholiday');

File diff suppressed because it is too large Load Diff

View File

@ -12,310 +12,303 @@
/* $Id$ */ /* $Id$ */
class calendar_holiday class calendar_holiday
{
var $db;
var $year;
var $tz_offset;
var $holidays = Array();
var $index = Array();
var $users = Array();
var $datetime;
function calendar_holiday($owner='')
{ {
global $phpgw, $phpgw_info; var $db;
var $year;
var $tz_offset;
var $holidays = Array();
var $index = Array();
var $users = Array();
var $datetime;
$this->datetime = CreateObject('phpgwapi.datetime'); function calendar_holiday($owner='')
$this->db = $phpgw->db;
if(@$phpgw_info['user']['preferences']['common']['country'])
{ {
$this->users['user'] = $phpgw_info['user']['preferences']['common']['country']; $this->datetime = CreateObject('phpgwapi.datetime');
} $this->db = $GLOBALS['phpgw']->db;
else if(@$GLOBALS['phpgw_info']['user']['preferences']['common']['country'])
{
$this->users['user'] = 'US';
}
$owner_id = get_account_id($owner);
if($owner_id != $phpgw_info['user']['account_id'])
{
$owner_pref = CreateObject('phpgwapi.preferences',$owner_id);
$owner_prefs = $owner_pref->read_repository();
if(isset($owner_prefs['calendar']['locale']) && $owner_prefs['common']['country'])
{ {
$this->users['owner'] = $owner_prefs['common']['country']; $this->users['user'] = $GLOBALS['phpgw_info']['user']['preferences']['common']['country'];
} }
else else
{ {
$this->users['owner'] = 'US'; $this->users['user'] = 'US';
} }
$owner_id = get_account_id($owner);
} if($owner_id != $GLOBALS['phpgw_info']['user']['account_id'])
if($phpgw_info['server']['auto_load_holidays'] == True)
{
while(list($key,$value) = each($this->users))
{ {
$this->is_network_load_needed($value); $owner_pref = CreateObject('phpgwapi.preferences',$owner_id);
} $owner_prefs = $owner_pref->read_repository();
} if(isset($owner_prefs['calendar']['locale']) && $owner_prefs['common']['country'])
}
function is_network_load_needed($locale)
{
$sql = "SELECT count(*) FROM phpgw_cal_holidays WHERE locale='".$locale."'";
$this->db->query($sql,__LINE__,__FILE__);
$this->db->next_record();
$rows = $this->db->f(0);
if($rows==0)
{
$this->load_from_network($locale);
}
}
function save_holiday($holiday)
{
if(isset($holiday['hol_id']) && $holiday['hol_id'])
{
// echo "Updating LOCALE='".$holiday['locale']."' NAME='".$holiday['name']."' extra=(".$holiday['mday'].'/'.$holiday['month_num'].'/'.$holiday['occurence'].'/'.$holiday['dow'].'/'.$holiday['observance_rule'].")<br>\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'].")<br>\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 delete_holiday($id)
{
$sql = 'DELETE FROM phpgw_cal_holidays WHERE hol_id='.$id;
$this->db->query($sql,__LINE__,__FILE__);
}
function delete_locale($locale)
{
$sql = "DELETE FROM phpgw_cal_holidays WHERE locale='".$locale."'";
$this->db->query($sql,__LINE__,__FILE__);
}
function load_from_network($locale)
{
global $phpgw_info, $HTTP_HOST, $SERVER_PORT;
@set_time_limit(0);
// get the file that contains the calendar events for your locale
// "http://www.phpgroupware.org/headlines.rdf";
$network = CreateObject('phpgwapi.network');
if(isset($phpgw_info['server']['holidays_url_path']) && $phpgw_info['server']['holidays_url_path'] != 'localhost')
{
$load_from = $phpgw_info['server']['holidays_url_path'];
}
else
{
$pos = strpos(' '.$phpgw_info['server']['webserver_url'],$HTTP_HOST);
if($pos == 0)
{
switch($SERVER_PORT)
{ {
case 80: $this->users['owner'] = $owner_prefs['common']['country'];
$http_protocol = 'http://';
break;
case 443:
$http_protocol = 'https://';
break;
}
$server_host = $http_protocol.$HTTP_HOST.$phpgw_info['server']['webserver_url'];
}
else
{
$server_host = $phpgw_info['server']['webserver_url'];
}
$load_from = $server_host.'/calendar/setup';
}
// echo 'Loading from: '.$load_from.'/holidays.'.strtoupper($locale)."<br>\n";
$lines = $network->gethttpsocketfile($load_from.'/holidays.'.strtoupper($locale));
if (!$lines) return false;
$c_lines = count($lines);
for($i=0;$i<$c_lines;$i++)
{
// echo 'Line #'.$i.' : '.$lines[$i]."<br>\n";
$holiday = explode("\t",$lines[$i]);
if(count($holiday) == 7)
{
$holiday['locale'] = $holiday[0];
$holiday['name'] = addslashes($holiday[1]);
$holiday['mday'] = intval($holiday[2]);
$holiday['month_num'] = intval($holiday[3]);
$holiday['occurence'] = intval($holiday[4]);
$holiday['dow'] = intval($holiday[5]);
$holiday['observance_rule'] = intval($holiday[6]);
$holiday['hol_id'] = 0;
$this->save_holiday($holiday);
}
}
}
function read_holiday()
{
global $phpgw, $phpgw_info;
$this->year = intval($phpgw->calendar->tempyear);
$sql = $this->build_holiday_query();
if($sql == False)
{ return False;
}
$this->holidays = Null;
$this->db->query($sql,__LINE__,__FILE__);
$i = 0;
$temp_locale = $phpgw_info['user']['preferences']['common']['country'];
while($this->db->next_record())
{
$this->index[$this->db->f('hol_id')] = $i;
$this->holidays[$i]['locale'] = $this->db->f('locale');
$this->holidays[$i]['name'] = $phpgw->strip_html($this->db->f('name'));
$this->holidays[$i]['day'] = intval($this->db->f('mday'));
$this->holidays[$i]['month'] = intval($this->db->f('month_num'));
$this->holidays[$i]['occurence'] = intval($this->db->f('occurence'));
$this->holidays[$i]['dow'] = intval($this->db->f('dow'));
$this->holidays[$i]['observance_rule'] = $this->db->f('observance_rule');
if(count($this->users) == 2 && $this->users[0] != $this->users[1])
{
if($this->holidays[$i]['locale'] == $this->users[1])
{
$this->holidays[$i]['owner'] = 'user';
} }
else else
{ {
$this->holidays[$i]['owner'] = 'owner'; $this->users['owner'] = 'US';
} }
} }
if($GLOBALS['phpgw_info']['server']['auto_load_holidays'] == True)
{
while(list($key,$value) = each($this->users))
{
$this->is_network_load_needed($value);
}
}
}
function is_network_load_needed($locale)
{
$sql = "SELECT count(*) FROM phpgw_cal_holidays WHERE locale='".$locale."'";
$this->db->query($sql,__LINE__,__FILE__);
$this->db->next_record();
$rows = $this->db->f(0);
if($rows==0)
{
$this->load_from_network($locale);
}
}
function save_holiday($holiday)
{
if(isset($holiday['hol_id']) && $holiday['hol_id'])
{
// echo "Updating LOCALE='".$holiday['locale']."' NAME='".$holiday['name']."' extra=(".$holiday['mday'].'/'.$holiday['month_num'].'/'.$holiday['occurence'].'/'.$holiday['dow'].'/'.$holiday['observance_rule'].")<br>\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='.(int)$holiday['observance_rule'].' WHERE hol_id='.$holiday['hol_id'];
}
else else
{ {
$this->holidays[$i]['owner'] = 'user'; // echo "Inserting LOCALE='".$holiday['locale']."' NAME='".$holiday['name']."' extra=(".$holiday['mday'].'/'.$holiday['month_num'].'/'.$holiday['occurence'].'/'.$holiday['dow'].'/'.$holiday['observance_rule'].")<br>\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'].','.(int)$holiday['observance_rule'].")";
} }
$c = $i; $this->db->query($sql,__LINE__,__FILE__);
$phpgw_info['user']['preferences']['common']['country'] = $this->holidays[$i]['locale']; }
$holidaycalc = CreateObject('calendar.holidaycalc');
$this->holidays[$i]['date'] = $holidaycalc->calculate_date($this->holidays[$i], $this->holidays, $this->year, $this->datetime, $c); function delete_holiday($id)
unset($holidaycalc); {
if($c != $i) $sql = 'DELETE FROM phpgw_cal_holidays WHERE hol_id='.$id;
$this->db->query($sql,__LINE__,__FILE__);
}
function delete_locale($locale)
{
$sql = "DELETE FROM phpgw_cal_holidays WHERE locale='".$locale."'";
$this->db->query($sql,__LINE__,__FILE__);
}
function load_from_network($locale)
{
@set_time_limit(0);
// get the file that contains the calendar events for your locale
// "http://www.phpgroupware.org/headlines.rdf";
$network = CreateObject('phpgwapi.network');
if(isset($GLOBALS['phpgw_info']['server']['holidays_url_path']) && $GLOBALS['phpgw_info']['server']['holidays_url_path'] != 'localhost')
{ {
$i = $c; $load_from = $GLOBALS['phpgw_info']['server']['holidays_url_path'];
} }
$i++; else
}
$this->holidays = $this->sort_by_date($this->holidays);
$phpgw_info['user']['preferences']['common']['country'] = $temp_locale;
return $this->holidays;
}
function build_list_for_submission($locale)
{
global $phpgw;
$i = -1;
$this->db->query("SELECT * FROM phpgw_cal_holidays WHERE locale='".$locale."'");
while($this->db->next_record())
{
$i++;
$holidays[$i]['locale'] = $this->db->f('locale');
$holidays[$i]['name'] = $phpgw->strip_html($this->db->f('name'));
$holidays[$i]['day'] = intval($this->db->f('mday'));
$holidays[$i]['month'] = intval($this->db->f('month_num'));
$holidays[$i]['occurence'] = intval($this->db->f('occurence'));
$holidays[$i]['dow'] = intval($this->db->f('dow'));
$holidays[$i]['observance_rule'] = $this->db->f('observance_rule');
}
return $holidays;
}
function build_holiday_query()
{
if(!isset($this->users) || count($this->users) == 0)
{
return False;
}
$sql = 'SELECT * FROM phpgw_cal_holidays WHERE locale in (';
$find_it = '';
reset($this->users);
while(list($key,$value) = each($this->users))
{
if($find_it)
{ {
$find_it .= ','; $pos = strpos(' '.$GLOBALS['phpgw_info']['server']['webserver_url'],$_SERVER['HTTP_HOST']);
} if($pos == 0)
$find_it .= "'".$value."'";
}
$sql .= $find_it.')';
return $sql;
}
function sort_by_date($holidays)
{
$c_holidays = count($holidays);
for($outer_loop=0;$outer_loop<($c_holidays - 1);$outer_loop++)
{
$outer_date = $holidays[$outer_loop]['date'];
for($inner_loop=$outer_loop;$inner_loop<$c_holidays;$inner_loop++)
{
$inner_date = $holidays[$inner_loop]['date'];
if($outer_date > $inner_date)
{ {
$temp = $holidays[$inner_loop]; switch($_SERVER['SERVER_PORT'])
$holidays[$inner_loop] = $holidays[$outer_loop]; {
$holidays[$outer_loop] = $temp; case 80:
$http_protocol = 'http://';
break;
case 443:
$http_protocol = 'https://';
break;
}
$server_host = $http_protocol.$_SERVER['HTTP_HOST'].$GLOBALS['phpgw_info']['server']['webserver_url'];
}
else
{
$server_host = $GLOBALS['phpgw_info']['server']['webserver_url'];
}
$load_from = $server_host.'/calendar/setup';
}
// echo 'Loading from: '.$load_from.'/holidays.'.strtoupper($locale)."<br>\n";
$lines = $network->gethttpsocketfile($load_from.'/holidays.'.strtoupper($locale));
if(!$lines)
{
return False;
}
$c_lines = count($lines);
for($i=0;$i<$c_lines;$i++)
{
// echo 'Line #'.$i.' : '.$lines[$i]."<br>\n";
$holiday = explode("\t",$lines[$i]);
if(count($holiday) == 7)
{
$holiday['locale'] = $holiday[0];
$holiday['name'] = addslashes($holiday[1]);
$holiday['mday'] = (int)$holiday[2];
$holiday['month_num'] = (int)$holiday[3];
$holiday['occurence'] = (int)$holiday[4];
$holiday['dow'] = (int)$holiday[5];
$holiday['observance_rule'] = (int)$holiday[6];
$holiday['hol_id'] = 0;
$this->save_holiday($holiday);
} }
} }
} }
return $holidays;
}
function find_date($date) function read_holiday()
{
global $phpgw;
if($this->holidays == Null)
{ {
return False; $this->year = (int)$GLOBALS['phpgw']->calendar->tempyear;
$sql = $this->build_holiday_query();
if($sql == False)
{
return False;
}
$this->holidays = Null;
$this->db->query($sql,__LINE__,__FILE__);
$i = 0;
$temp_locale = $GLOBALS['phpgw_info']['user']['preferences']['common']['country'];
while($this->db->next_record())
{
$this->index[$this->db->f('hol_id')] = $i;
$this->holidays[$i]['locale'] = $this->db->f('locale');
$this->holidays[$i]['name'] = $GLOBALS['phpgw']->strip_html($this->db->f('name'));
$this->holidays[$i]['day'] = (int)$this->db->f('mday');
$this->holidays[$i]['month'] = (int)$this->db->f('month_num');
$this->holidays[$i]['occurence'] = (int)$this->db->f('occurence');
$this->holidays[$i]['dow'] = (int)$this->db->f('dow');
$this->holidays[$i]['observance_rule'] = $this->db->f('observance_rule');
if(count($this->users) == 2 && $this->users[0] != $this->users[1])
{
if($this->holidays[$i]['locale'] == $this->users[1])
{
$this->holidays[$i]['owner'] = 'user';
}
else
{
$this->holidays[$i]['owner'] = 'owner';
}
}
else
{
$this->holidays[$i]['owner'] = 'user';
}
$c = $i;
$GLOBALS['phpgw_info']['user']['preferences']['common']['country'] = $this->holidays[$i]['locale'];
$holidaycalc = CreateObject('calendar.holidaycalc');
$this->holidays[$i]['date'] = $holidaycalc->calculate_date($this->holidays[$i], $this->holidays, $this->year, $this->datetime, $c);
unset($holidaycalc);
if($c != $i)
{
$i = $c;
}
$i++;
}
$this->holidays = $this->sort_by_date($this->holidays);
$GLOBALS['phpgw_info']['user']['preferences']['common']['country'] = $temp_locale;
return $this->holidays;
} }
$c_holidays = count($this->holidays); function build_list_for_submission($locale)
for($i=0;$i<$c_holidays;$i++)
{ {
if($this->holidays[$i]['date'] > $date) $i = -1;
$this->db->query("SELECT * FROM phpgw_cal_holidays WHERE locale='".$locale."'");
while($this->db->next_record())
{ {
$i = $c_holidays + 1; $i++;
$holidays[$i]['locale'] = $this->db->f('locale');
$holidays[$i]['name'] = $GLOBALS['phpgw']->strip_html($this->db->f('name'));
$holidays[$i]['day'] = (int)$this->db->f('mday');
$holidays[$i]['month'] = (int)$this->db->f('month_num');
$holidays[$i]['occurence'] = (int)$this->db->f('occurence');
$holidays[$i]['dow'] = (int)$this->db->f('dow');
$holidays[$i]['observance_rule'] = $this->db->f('observance_rule');
} }
elseif($this->holidays[$i]['date'] == $date) return $holidays;
}
function build_holiday_query()
{
if(!isset($this->users) || count($this->users) == 0)
{ {
$return_value[] = $i; return False;
}
$sql = 'SELECT * FROM phpgw_cal_holidays WHERE locale in (';
$find_it = '';
reset($this->users);
while(list($key,$value) = each($this->users))
{
if($find_it)
{
$find_it .= ',';
}
$find_it .= "'".$value."'";
}
$sql .= $find_it.')';
return $sql;
}
function sort_by_date($holidays)
{
$c_holidays = count($holidays);
for($outer_loop=0;$outer_loop<($c_holidays - 1);$outer_loop++)
{
$outer_date = $holidays[$outer_loop]['date'];
for($inner_loop=$outer_loop;$inner_loop<$c_holidays;$inner_loop++)
{
$inner_date = $holidays[$inner_loop]['date'];
if($outer_date > $inner_date)
{
$temp = $holidays[$inner_loop];
$holidays[$inner_loop] = $holidays[$outer_loop];
$holidays[$outer_loop] = $temp;
}
}
}
return $holidays;
}
function find_date($date)
{
if($this->holidays == Null)
{
return False;
}
$c_holidays = count($this->holidays);
for($i=0;$i<$c_holidays;$i++)
{
if($this->holidays[$i]['date'] > $date)
{
$i = $c_holidays + 1;
}
elseif($this->holidays[$i]['date'] == $date)
{
$return_value[] = $i;
}
}
// echo 'Searching for '.$GLOBALS['phpgw']->common->show_date($date).' Found = '.count($return_value)."<br>\n";
if(isset($return_value))
{
return $return_value;
}
else
{
return False;
} }
} }
// echo 'Searching for '.$phpgw->common->show_date($date).' Found = '.count($return_value)."<br>\n";
if(isset($return_value)) function get_holiday($index)
{ {
return $return_value; return $this->holidays[$index];
} }
else
function get_name($id)
{ {
return False; return $this->holidays[$id]['name'];
} }
} }
function get_holiday($index)
{
return $this->holidays[$index];
}
function get_name($id)
{
return $this->holidays[$id]['name'];
}
}
?> ?>

View File

@ -12,334 +12,330 @@
/* $Id$ */ /* $Id$ */
if (isset($phpgw_info['flags']['included_classes']['calendar_']) && if (isset($GLOBALS['phpgw_info']['flags']['included_classes']['calendar_']) &&
$phpgw_info['flags']['included_classes']['calendar_'] == True) $GLOBALS['phpgw_info']['flags']['included_classes']['calendar_'] == True)
{
return;
}
$phpgw_info['flags']['included_classes']['calendar_'] = True;
class calendar_ extends calendar__
{
function open($calendar='',$user='',$passwd='',$options='')
{ {
global $phpgw, $phpgw_info; return;
if($user=='')
{
$user = $phpgw_info['user']['account_lid'];
}
elseif(is_int($user))
{
$this->user = $phpgw->accounts->id2name($user);
}
elseif(is_string($user))
{
$this->user = $user;
}
if($options != '')
{
$this->stream = mcal_open('{'.$phpgw_info['server']['icap_server'].'/'.$phpgw_info['server']['icap_type'].'}'.$calendar,$this->user,$passwd,$options);
}
else
{
$this->stream = mcal_open('{'.$phpgw_info['server']['icap_server'].'/'.$phpgw_info['server']['icap_type'].'}'.$calendar,$this->user,$passwd);
}
} }
function popen($calendar='',$user='',$passwd='',$options='') $GLOBALS['phpgw_info']['flags']['included_classes']['calendar_'] = True;
class calendar_ extends calendar__
{ {
global $phpgw, $phpgw_info; function open($calendar='',$user='',$passwd='',$options='')
if($user=='')
{ {
$this->user = $phpgw_info['user']['account_lid']; if($user=='')
}
elseif(is_int($user))
{
$this->user = $phpgw->accounts->id2name($user);
}
elseif(is_string($user))
{
$this->user = $user;
}
if($options != '')
{
$this->stream = mcal_popen('{'.$phpgw_info['server']['icap_server'].'/'.$phpgw_info['server']['icap_type'].'}'.$calendar,$this->user,$passwd,$options);
}
else
{
$this->stream = mcal_popen('{'.$phpgw_info['server']['icap_server'].'/'.$phpgw_info['server']['icap_type'].'}'.$calendar,$this->user,$passwd);
}
}
function reopen($calendar,$options='')
{
if($options != '')
{
$this->stream = mcal_reopen($calendar,$options);
}
else
{
$this->stream = mcal_reopen($calendar);
}
}
function close($options='')
{
if($options != '')
{
return mcal_close($this->stream,$options);
}
else
{
return mcal_close($this->stream);
}
}
function create_calendar($calendar)
{
return mcal_create_calendar($this->stream,$calendar);
}
function rename_calendar($old_name,$new_name)
{
return mcal_rename_calendar($this->stream,$old_name,$new_name);
}
function delete_calendar($calendar)
{
return mcal_delete_calendar($this->stream,$calendar);
}
function fetch_event($event_id,$options='')
{
if(!isset($this->stream))
{
return False;
}
$this->event = CreateObject('calendar.calendar_item');
if($options != '')
{
$this->event = mcal_fetch_event($this->stream,$event_id,$options);
}
else
{
$this->event = mcal_fetch_event($this->stream,$event_id);
}
// Need to load the $this->event variable with the $event structure from
// the mcal_fetch_event() call
// Use http://www.php.net/manual/en/function.mcal-fetch-event.php as the reference
// This only needs legacy support
return $this->event;
}
function list_events($startYear,$startMonth,$startDay,$endYear='',$endMonth='',$endYear='')
{
if($endYear != '' && $endMonth != '' && $endDay != '')
{
$events = mcal_list_events($this->stream,$startYear,$startMonth,$startDay,$endYear,$endMonth,$endYear);
}
else
{
$events = mcal_list_events($this->stream,$startYear,$startMonth,$startDay);
}
return $events;
}
function append_event()
{
return mcal_append_event($this->stream);
}
function store_event()
{
return mcal_store_event($this->stream);
}
function delete_event($event_id)
{
return mcal_delete_event($this->stream,$event_id);
}
function snooze($event_id)
{
return mcal_snooze($this->stream,$event_id);
}
function list_alarms($begin_year='',$begin_month='',$begin_day='',$end_year='',$end_month='',$end_day='')
{
if($end_day == '')
{
if($end_month == '')
{ {
if($end_year == '') $user = $GLOBALS['phpgw_info']['user']['account_lid'];
}
elseif(is_int($user))
{
$this->user = $GLOBALS['phpgw']->accounts->id2name($user);
}
elseif(is_string($user))
{
$this->user = $user;
}
if($options != '')
{
$this->stream = mcal_open('{'.$GLOBALS['phpgw_info']['server']['icap_server'].'/'.$GLOBALS['phpgw_info']['server']['icap_type'].'}'.$calendar,$this->user,$passwd,$options);
}
else
{
$this->stream = mcal_open('{'.$GLOBALS['phpgw_info']['server']['icap_server'].'/'.$GLOBALS['phpgw_info']['server']['icap_type'].'}'.$calendar,$this->user,$passwd);
}
}
function popen($calendar='',$user='',$passwd='',$options='')
{
if($user=='')
{
$this->user = $GLOBALS['phpgw_info']['user']['account_lid'];
}
elseif(is_int($user))
{
$this->user = $GLOBALS['phpgw']->accounts->id2name($user);
}
elseif(is_string($user))
{
$this->user = $user;
}
if($options != '')
{
$this->stream = mcal_popen('{'.$GLOBALS['phpgw_info']['server']['icap_server'].'/'.$GLOBALS['phpgw_info']['server']['icap_type'].'}'.$calendar,$this->user,$passwd,$options);
}
else
{
$this->stream = mcal_popen('{'.$GLOBALS['phpgw_info']['server']['icap_server'].'/'.$GLOBALS['phpgw_info']['server']['icap_type'].'}'.$calendar,$this->user,$passwd);
}
}
function reopen($calendar,$options='')
{
if($options != '')
{
$this->stream = mcal_reopen($calendar,$options);
}
else
{
$this->stream = mcal_reopen($calendar);
}
}
function close($options='')
{
if($options != '')
{
return mcal_close($this->stream,$options);
}
else
{
return mcal_close($this->stream);
}
}
function create_calendar($calendar)
{
return mcal_create_calendar($this->stream,$calendar);
}
function rename_calendar($old_name,$new_name)
{
return mcal_rename_calendar($this->stream,$old_name,$new_name);
}
function delete_calendar($calendar)
{
return mcal_delete_calendar($this->stream,$calendar);
}
function fetch_event($event_id,$options='')
{
if(!isset($this->stream))
{
return False;
}
$this->event = CreateObject('calendar.calendar_item');
if($options != '')
{
$this->event = mcal_fetch_event($this->stream,$event_id,$options);
}
else
{
$this->event = mcal_fetch_event($this->stream,$event_id);
}
// Need to load the $this->event variable with the $event structure from
// the mcal_fetch_event() call
// Use http://www.php.net/manual/en/function.mcal-fetch-event.php as the reference
// This only needs legacy support
return $this->event;
}
function list_events($startYear,$startMonth,$startDay,$endYear='',$endMonth='',$endYear='')
{
if($endYear != '' && $endMonth != '' && $endDay != '')
{
$events = mcal_list_events($this->stream,$startYear,$startMonth,$startDay,$endYear,$endMonth,$endYear);
}
else
{
$events = mcal_list_events($this->stream,$startYear,$startMonth,$startDay);
}
return $events;
}
function append_event()
{
return mcal_append_event($this->stream);
}
function store_event()
{
return mcal_store_event($this->stream);
}
function delete_event($event_id)
{
return mcal_delete_event($this->stream,$event_id);
}
function snooze($event_id)
{
return mcal_snooze($this->stream,$event_id);
}
function list_alarms($begin_year='',$begin_month='',$begin_day='',$end_year='',$end_month='',$end_day='')
{
if($end_day == '')
{
if($end_month == '')
{ {
if($begin_day == '') if($end_year == '')
{ {
if($begin_month == '') if($begin_day == '')
{ {
if($begin_year == '') if($begin_month == '')
{ {
return mcal_list_alarms($this->stream); if($begin_year == '')
{
return mcal_list_alarms($this->stream);
}
else
{
return mcal_list_alarms($this->stream,$begin_year);
}
} }
else else
{ {
return mcal_list_alarms($this->stream,$begin_year); return mcal_list_alarms($this->stream,$begin_year,$begin_month);
} }
} }
else else
{ {
return mcal_list_alarms($this->stream,$begin_year,$begin_month); return mcal_list_alarms($this->stream,$begin_year,$begin_month,$begin_day);
} }
} }
else else
{ {
return mcal_list_alarms($this->stream,$begin_year,$begin_month,$begin_day); return mcal_list_alarms($this->stream,$begin_year,$begin_month,$begin_day,$end_year);
} }
} }
else else
{ {
return mcal_list_alarms($this->stream,$begin_year,$begin_month,$begin_day,$end_year); return mcal_list_alarms($this->stream,$begin_year,$begin_month,$begin_day,$end_year,$end_month);
} }
} }
else else
{ {
return mcal_list_alarms($this->stream,$begin_year,$begin_month,$begin_day,$end_year,$end_month); return mcal_list_alarms($this->stream,$begin_year,$begin_month,$begin_day,$end_year,$end_month,$end_day);
} }
} }
else
function event_init()
{ {
return mcal_list_alarms($this->stream,$begin_year,$begin_month,$begin_day,$end_year,$end_month,$end_day); $this->event = CreateObject('calendar.calendar_item');
return mcal_event_init($this->stream);
}
function set_category($category='')
{
calendar__::set_category($category);
return mcal_event_set_category($this->stream,$category);
}
function set_title($title='')
{
calendar__::set_title($title);
return mcal_event_set_title($this->stream,$title);
}
function set_description($description='')
{
calendar__::set_description($description);
return mcal_event_set_description($this->stream,$description);
}
function set_start($year,$month,$day=0,$hour=0,$min=0,$sec=0)
{
calendar__::set_start($year,$month,$day,$hour,$min,$sec);
return mcal_event_set_start($this->stream,$year,$month,$day,$hour,$min,$sec);
}
function set_end($year,$month,$day=0,$hour=0,$min=0,$sec=0)
{
calendar__::set_end($year,$month,$day,$hour,$min,$sec);
return mcal_event_set_end($this->stream,$year,$month,$day,$hour,$min,$sec);
}
function set_alarm($alarm)
{
calendar__::set_alarm($alarm);
return mcal_event_set_alarm ($this->stream,$alarm);
}
function set_class($class)
{
calendar__::set_class($class);
return mcal_event_set_class($this->stream,$class);
}
// The function definition doesn't look correct...
// Need more information for this function
function next_recurrence($weekstart,$next)
{
return mcal_next_recurrence($this->stream,$weekstart,$next);
}
function set_recur_none()
{
calendar__::set_recur_none();
return mcal_event_set_recur_none($this->stream);
}
function set_recur_daily($year,$month,$day,$interval)
{
calendar__::set_recur_daily($year,$month,$day,$interval);
return mcal_event_set_recur_daily($this->stream,$year,$month,$day,$interval);
}
function set_recur_weekly($year,$month,$day,$interval,$weekdays)
{
calendar__::set_recur_weekly($year,$month,$day,$interval,$weekdays);
return mcal_event_set_recur_weekly($this->stream,$year,$month,$day,$interval,$weekdays);
}
function set_recur_monthly_mday($year,$month,$day,$interval)
{
calendar__::set_recur_monthly_mday($year,$month,$day,$interval);
return mcal_event_set_recur_monthly_mday($this->stream,$year,$month,$day,$interval);
}
function set_recur_monthly_wday($year,$month,$day,$interval)
{
calendar__::set_recur_monthly_wday($year,$month,$day,$interval);
return mcal_event_set_recur_monthly_wday($this->stream,$year,$month,$day,$interval);
}
function set_recur_yearly($year,$month,$day,$interval)
{
calendar__::set_recur_yearly($year,$month,$day,$interval);
return mcal_event_set_recur_yearly($this->stream,$year,$month,$day,$interval);
}
function fetch_current_stream_event()
{
$this->event = mcal_fetch_current_stream_event($this->stream);
return $this->event
}
function add_attribute($attribute,$value)
{
calendar__::add_attribute($attribute,$value);
return mcal_event_add_attribute($this->stream,$attribute,$value);
}
function expunge()
{
return mcal_expunge($this->stream);
}
/**************** Local functions for ICAL based Calendar *****************/
function set_status($id,$owner,$status)
{
$status_code_short = Array(
REJECTED => 'R',
NO_RESPONSE => 'U',
TENTATIVE => 'T',
ACCEPTED => 'A'
);
$this->add_attribute('status['.$owner.']',$status_code_short[$status]);
// $this->stream->query("UPDATE calendar_entry_user SET cal_status='".$status_code_short[$status]."' WHERE cal_id=".$id." AND cal_login=".$owner,__LINE__,__FILE__);
return True;
} }
} }
function event_init()
{
$this->event = CreateObject('calendar.calendar_item');
return mcal_event_init($this->stream);
}
function set_category($category='')
{
calendar__::set_category($category);
return mcal_event_set_category($this->stream,$category);
}
function set_title($title='')
{
calendar__::set_title($title);
return mcal_event_set_title($this->stream,$title);
}
function set_description($description='')
{
calendar__::set_description($description);
return mcal_event_set_description($this->stream,$description);
}
function set_start($year,$month,$day=0,$hour=0,$min=0,$sec=0)
{
calendar__::set_start($year,$month,$day,$hour,$min,$sec);
return mcal_event_set_start($this->stream,$year,$month,$day,$hour,$min,$sec);
}
function set_end($year,$month,$day=0,$hour=0,$min=0,$sec=0)
{
calendar__::set_end($year,$month,$day,$hour,$min,$sec);
return mcal_event_set_end($this->stream,$year,$month,$day,$hour,$min,$sec);
}
function set_alarm($alarm)
{
calendar__::set_alarm($alarm);
return mcal_event_set_alarm ($this->stream,$alarm);
}
function set_class($class)
{
calendar__::set_class($class);
return mcal_event_set_class($this->stream,$class);
}
// The function definition doesn't look correct...
// Need more information for this function
function next_recurrence($weekstart,$next)
{
return mcal_next_recurrence($this->stream,$weekstart,$next);
}
function set_recur_none()
{
calendar__::set_recur_none();
return mcal_event_set_recur_none($this->stream);
}
function set_recur_daily($year,$month,$day,$interval)
{
calendar__::set_recur_daily($year,$month,$day,$interval);
return mcal_event_set_recur_daily($this->stream,$year,$month,$day,$interval);
}
function set_recur_weekly($year,$month,$day,$interval,$weekdays)
{
calendar__::set_recur_weekly($year,$month,$day,$interval,$weekdays);
return mcal_event_set_recur_weekly($this->stream,$year,$month,$day,$interval,$weekdays);
}
function set_recur_monthly_mday($year,$month,$day,$interval)
{
calendar__::set_recur_monthly_mday($year,$month,$day,$interval);
return mcal_event_set_recur_monthly_mday($this->stream,$year,$month,$day,$interval);
}
function set_recur_monthly_wday($year,$month,$day,$interval)
{
calendar__::set_recur_monthly_wday($year,$month,$day,$interval);
return mcal_event_set_recur_monthly_wday($this->stream,$year,$month,$day,$interval);
}
function set_recur_yearly($year,$month,$day,$interval)
{
calendar__::set_recur_yearly($year,$month,$day,$interval);
return mcal_event_set_recur_yearly($this->stream,$year,$month,$day,$interval);
}
function fetch_current_stream_event()
{
$this->event = mcal_fetch_current_stream_event($this->stream);
return $this->event
}
function add_attribute($attribute,$value)
{
calendar__::add_attribute($attribute,$value);
return mcal_event_add_attribute($this->stream,$attribute,$value);
}
function expunge()
{
return mcal_expunge($this->stream);
}
/**************** Local functions for ICAL based Calendar *****************/
function set_status($id,$owner,$status)
{
$status_code_short = Array(
REJECTED => 'R',
NO_RESPONSE => 'U',
TENTATIVE => 'T',
ACCEPTED => 'A'
);
$this->add_attribute('status['.$owner.']',$status_code_short[$status]);
// $this->stream->query("UPDATE calendar_entry_user SET cal_status='".$status_code_short[$status]."' WHERE cal_id=".$id." AND cal_login=".$owner,__LINE__,__FILE__);
return True;
}
}

View File

@ -13,141 +13,141 @@
/* $Id$ */ /* $Id$ */
class holidaycalc { class holidaycalc
function calculate_date($holiday, &$holidays, $year, &$i)
{ {
static $cached_month; function calculate_date($holiday, &$holidays, $year, &$i)
static $cached_day;
static $cached_observance_rule;
if ($holiday['day'] == 0 && $holiday['dow'] != 0 && $holiday['occurence'] != 0)
{ {
$dow = $GLOBALS['phpgw']->datetime->day_of_week($year, $holiday['month'], 1); static $cached_month;
$dayshift = (($holiday['dow'] + 7) - $dow) % 7; static $cached_day;
$day = ($holiday['occurence'] - 1) * 7 + $dayshift + 1; static $cached_observance_rule;
// Happy monday law. if ($holiday['day'] == 0 && $holiday['dow'] != 0 && $holiday['occurence'] != 0)
if ($holiday['month'] == 1)
{ {
if ($year < 2000) $dow = $GLOBALS['phpgw']->datetime->day_of_week($year, $holiday['month'], 1);
$dayshift = (($holiday['dow'] + 7) - $dow) % 7;
$day = ($holiday['occurence'] - 1) * 7 + $dayshift + 1;
// Happy monday law.
if ($holiday['month'] == 1)
{ {
$day = 15; if ($year < 2000)
{
$day = 15;
}
}
elseif ($holiday['month'] == 7)
{
if ($year < 2003)
{
$day = 20;
}
}
elseif ($holiday['month'] == 9)
{
if ($year < 2003)
{
$day = 15;
}
}
elseif ($holiday['month'] == 10)
{
if ($year < 2000)
{
$day = 10;
}
} }
} }
elseif ($holiday['month'] == 7) elseif ($holiday['day'] == 0 && $holiday['dow'] == 0 && $holiday['occurence'] == 0)
{ {
if ($year < 2003) // For the next generation.
// over 2151, please set $factor...
if ($holiday['month'] == 3)
{ {
$day = 20; // for Vernal Equinox
if ($year >= 1980 && $year <= 2099)
{
$factor = 20.8431;
}
elseif ($year >= 2100 && $year <= 2150)
{
$factor = 21.851;
}
} }
elseif ($holiday['month'] == 9)
{
// for Autumnal Equinox
if ($year >= 1980 && $year <= 2099)
{
$factor = 23.2488;
}
elseif ($year >= 2100 && $year <= 2150)
{
$factor = 24.2488;
}
}
$day = (int)($factor + 0.242194 * ($year - 1980)
- (int)(($year - 1980) / 4));
} }
elseif ($holiday['month'] == 9) else
{ {
if ($year < 2003) // normal holiday
{ $day = $holiday['day'];
$day = 15;
}
} }
elseif ($holiday['month'] == 10)
if ($year >= 1985 && $holiday['month'] == $cached_month && $day == $cached_day + 2 && $cached_observance_rule == True && $holiday['observance_rule'] == True)
{ {
if ($year < 2000) $pdow = $GLOBALS['phpgw']->datetime->day_of_week($year,$holiday['month'],$day-1);
if ($pdow != 0)
{ {
$day = 10; $addcnt = count($holidays) + 1;
} $holidays[$addcnt]['locale'] = $holiday['locale'];
} if ($pdow == 1)
} {
elseif ($holiday['day'] == 0 && $holiday['dow'] == 0 && $holiday['occurence'] == 0) $holidays[$addcnt]['name'] = lang('overlap holiday');
{ }
// For the next generation. else
// over 2151, please set $factor... {
if ($holiday['month'] == 3) $holidays[$addcnt]['name'] = lang('people holiday');
{ }
// for Vernal Equinox $holidays[$addcnt]['day'] = $day - 1;
if ($year >= 1980 && $year <= 2099) $holidays[$addcnt]['month'] = $holiday['month'];
{ $holidays[$addcnt]['occurence'] = 0;
$factor = 20.8431; $holidays[$addcnt]['dow'] = 0;
} $holidays[$addcnt]['date'] = mktime(0,0,0,$holiday['month'],$day-1,$year);
elseif ($year >= 2100 && $year <= 2150) $holidays[$addcnt]['observance_rule'] = 0;
{
$factor = 21.851;
}
}
elseif ($holiday['month'] == 9)
{
// for Autumnal Equinox
if ($year >= 1980 && $year <= 2099)
{
$factor = 23.2488;
}
elseif ($year >= 2100 && $year <= 2150)
{
$factor = 24.2488;
} }
} }
$day = (int)($factor + 0.242194 * ($year - 1980) $cached_month = $holiday['month'];
- (int)(($year - 1980) / 4)); $cached_day = $day;
} $cached_observance_rule = $holiday['observance_rule'];
else
{
// normal holiday
$day = $holiday['day'];
}
if ($year >= 1985 && $holiday['month'] == $cached_month && $day == $cached_day + 2 && $cached_observance_rule == True && $holiday['observance_rule'] == True) if ($year >= 1985 && $holiday['month'] == 5 && $day == 3)
{
$pdow = $GLOBALS['phpgw']->datetime->day_of_week($year,$holiday['month'],$day-1);
if ($pdow != 0)
{ {
$addcnt = count($holidays) + 1; ;
$holidays[$addcnt]['locale'] = $holiday['locale']; }
if ($pdow == 1) elseif ($holiday['observance_rule'] == True)
{
$dow = $GLOBALS['phpgw']->datetime->day_of_week($year,$holiday['month'],$day);
// This now calulates Observed holidays and creates a new entry for them.
if($dow == 0)
{ {
$addcnt = count($holidays) + 1;
$holidays[$addcnt]['locale'] = $holiday['locale'];
$holidays[$addcnt]['name'] = lang('overlap holiday'); $holidays[$addcnt]['name'] = lang('overlap holiday');
$holidays[$addcnt]['day'] = $day + 1;
$holidays[$addcnt]['month'] = $holiday['month'];
$holidays[$addcnt]['occurence'] = $holiday['occurence'];
$holidays[$addcnt]['dow'] = $holiday['dow'];
$holidays[$addcnt]['date'] = mktime(0,0,0,$holiday['month'],$day+1,$year);
$holidays[$addcnt]['observance_rule'] = 0;
} }
else
{
$holidays[$addcnt]['name'] = lang('people holiday');
}
$holidays[$addcnt]['day'] = $day - 1;
$holidays[$addcnt]['month'] = $holiday['month'];
$holidays[$addcnt]['occurence'] = 0;
$holidays[$addcnt]['dow'] = 0;
$holidays[$addcnt]['date'] = mktime(0,0,0,$holiday['month'],$day-1,$year);
$holidays[$addcnt]['observance_rule'] = 0;
} }
$date = mktime(0,0,0,$holiday['month'],$day,$year);
return $date;
} }
$cached_month = $holiday['month'];
$cached_day = $day;
$cached_observance_rule = $holiday['observance_rule'];
if ($year >= 1985 && $holiday['month'] == 5 && $day == 3)
{
;
}
elseif ($holiday['observance_rule'] == True)
{
$dow = $GLOBALS['phpgw']->datetime->day_of_week($year,$holiday['month'],$day);
// This now calulates Observed holidays and creates a new entry for them.
if($dow == 0)
{
$addcnt = count($holidays) + 1;
$holidays[$addcnt]['locale'] = $holiday['locale'];
$holidays[$addcnt]['name'] = lang('overlap holiday');
$holidays[$addcnt]['day'] = $day + 1;
$holidays[$addcnt]['month'] = $holiday['month'];
$holidays[$addcnt]['occurence'] = $holiday['occurence'];
$holidays[$addcnt]['dow'] = $holiday['dow'];
$holidays[$addcnt]['date'] = mktime(0,0,0,$holiday['month'],$day+1,$year);
$holidays[$addcnt]['observance_rule'] = 0;
}
}
$date = mktime(0,0,0,$holiday['month'],$day,$year);
return $date;
} }
}
?> ?>

View File

@ -13,73 +13,73 @@
/* $Id$ */ /* $Id$ */
class holidaycalc { class holidaycalc
function calculate_date($holiday, &$holidays, $year, &$i)
{ {
// if($holiday['day'] == 0 && $holiday['dow'] != 0 && $holiday['occurence'] != 0) function calculate_date($holiday, &$holidays, $year, &$i)
if($holiday['day'] == 0 && $holiday['occurence'] != 0)
{ {
if($holiday['occurence'] != 99) // if($holiday['day'] == 0 && $holiday['dow'] != 0 && $holiday['occurence'] != 0)
if($holiday['day'] == 0 && $holiday['occurence'] != 0)
{ {
$dow = $GLOBALS['phpgw']->datetime->day_of_week($year,$holiday['month'],1); if($holiday['occurence'] != 99)
$day = (((7 * $holiday['occurence']) - 6) + ((($holiday['dow'] + 7) - $dow) % 7));
$day += ($day < 1 ? 7 : 0);
// What is the point of this?
// Add 7 when the holiday falls on a Monday???
//$day += ($holiday['dow']==1 ? 7 : 0);
// Sometimes the 5th occurance of a weekday (ie the 5th monday)
// can spill over to the next month. This prevents that.
$ld = $GLOBALS['phpgw']->datetime->days_in_month($holiday['month'],$year);
if ($day > $ld)
{ {
return; $dow = $GLOBALS['phpgw']->datetime->day_of_week($year,$holiday['month'],1);
$day = (((7 * $holiday['occurence']) - 6) + ((($holiday['dow'] + 7) - $dow) % 7));
$day += ($day < 1 ? 7 : 0);
// What is the point of this?
// Add 7 when the holiday falls on a Monday???
//$day += ($holiday['dow']==1 ? 7 : 0);
// Sometimes the 5th occurance of a weekday (ie the 5th monday)
// can spill over to the next month. This prevents that.
$ld = $GLOBALS['phpgw']->datetime->days_in_month($holiday['month'],$year);
if ($day > $ld)
{
return;
}
}
else
{
$ld = $GLOBALS['phpgw']->datetime->days_in_month($holiday['month'],$year);
$dow = $GLOBALS['phpgw']->datetime->day_of_week($year,$holiday['month'],$ld);
$day = $ld - (($dow + 7) - $holiday['dow']) % 7 ;
} }
} }
else else
{ {
$ld = $GLOBALS['phpgw']->datetime->days_in_month($holiday['month'],$year); $day = $holiday['day'];
$dow = $GLOBALS['phpgw']->datetime->day_of_week($year,$holiday['month'],$ld); if($holiday['observance_rule'] == True)
$day = $ld - (($dow + 7) - $holiday['dow']) % 7 ;
}
}
else
{
$day = $holiday['day'];
if($holiday['observance_rule'] == True)
{
$dow = $GLOBALS['phpgw']->datetime->day_of_week($year,$holiday['month'],$day);
// This now calulates Observed holidays and creates a new entry for them.
if($dow == 0)
{ {
$i++; $dow = $GLOBALS['phpgw']->datetime->day_of_week($year,$holiday['month'],$day);
$holidays[$i]['locale'] = $holiday['locale']; // This now calulates Observed holidays and creates a new entry for them.
$holidays[$i]['name'] = $holiday['name'].' (Observed)'; if($dow == 0)
$holidays[$i]['day'] = $holiday['day'] + 1; {
$holidays[$i]['month'] = $holiday['month']; $i++;
$holidays[$i]['occurence'] = $holiday['occurence']; $holidays[$i]['locale'] = $holiday['locale'];
$holidays[$i]['dow'] = $holiday['dow']; $holidays[$i]['name'] = $holiday['name'].' (Observed)';
$holidays[$i]['date'] = mktime(0,0,0,$holiday['month'],$day+1,$year); $holidays[$i]['day'] = $holiday['day'] + 1;
$holidays[$i]['obervance_rule'] = 0; $holidays[$i]['month'] = $holiday['month'];
} $holidays[$i]['occurence'] = $holiday['occurence'];
elseif($dow == 6) $holidays[$i]['dow'] = $holiday['dow'];
{ $holidays[$i]['date'] = mktime(0,0,0,$holiday['month'],$day+1,$year);
$i++; $holidays[$i]['obervance_rule'] = 0;
$holidays[$i]['locale'] = $holiday['locale']; }
$holidays[$i]['name'] = $holiday['name'].' (Observed)'; elseif($dow == 6)
$holidays[$i]['day'] = $holiday['day'] - 1; {
$holidays[$i]['month'] = $holiday['month']; $i++;
$holidays[$i]['occurence'] = $holiday['occurence']; $holidays[$i]['locale'] = $holiday['locale'];
$holidays[$i]['dow'] = $holiday['dow']; $holidays[$i]['name'] = $holiday['name'].' (Observed)';
$holidays[$i]['date'] = mktime(0,0,0,$holiday['month'],$day-1,$year); $holidays[$i]['day'] = $holiday['day'] - 1;
$holidays[$i]['obervance_rule'] = 0; $holidays[$i]['month'] = $holiday['month'];
$holidays[$i]['occurence'] = $holiday['occurence'];
$holidays[$i]['dow'] = $holiday['dow'];
$holidays[$i]['date'] = mktime(0,0,0,$holiday['month'],$day-1,$year);
$holidays[$i]['obervance_rule'] = 0;
}
} }
} }
} $date = mktime(0,0,0,$holiday['month'],$day,$year);
$date = mktime(0,0,0,$holiday['month'],$day,$year);
return $date; return $date;
}
} }
}
?> ?>

View File

@ -55,7 +55,7 @@
function open_box($owner) function open_box($owner)
{ {
$this->cal->open('INBOX',intval($owner)); $this->cal->open('INBOX',(int)$owner);
} }
function maketime($time) function maketime($time)
@ -90,7 +90,7 @@
$owner_id = $this->is_group ? $this->g_owner : $this->owner; $owner_id = $this->is_group ? $this->g_owner : $this->owner;
} }
if($GLOBALS['phpgw_info']['server']['calendar_type'] != 'sql' || if($GLOBALS['phpgw_info']['server']['calendar_type'] != 'sql' ||
!count($owner_id)) // happens with empty groups !count($owner_id)) // happens with empty groups
{ {
return Array(); return Array();
} }
@ -130,7 +130,7 @@
$members[] = $this->owner; $members[] = $this->owner;
} }
$sql = 'AND (phpgw_cal_user.cal_login IN ('.implode(',',$members).')) AND '. $sql = 'AND (phpgw_cal_user.cal_login IN ('.implode(',',$members).')) AND '.
'(phpgw_cal_user.cal_login='.intval($this->owner).' OR phpgw_cal.is_public=1) AND ('; '(phpgw_cal_user.cal_login=' . (int)$this->owner . ' OR phpgw_cal.is_public=1) AND (';
$words = split(' ',$keywords); $words = split(' ',$keywords);
foreach($words as $i => $word) foreach($words as $i => $word)
@ -286,7 +286,7 @@
{ {
while($this->cal->next_record()) while($this->cal->next_record())
{ {
$arr[] = intval($this->cal->f('datetime')); $arr[] = (int)$this->cal->f('datetime');
} }
} }
if(count($arr) == 0) if(count($arr) == 0)

View File

@ -14,187 +14,187 @@
/* $Id$ */ /* $Id$ */
if (@$GLOBALS['phpgw_info']['flags']['included_classes']['socalendar__']) if (@$GLOBALS['phpgw_info']['flags']['included_classes']['socalendar__'])
{
return;
}
$GLOBALS['phpgw_info']['flags']['included_classes']['socalendar__'] = True;
/* include(PHPGW_SERVER_ROOT.'/calendar/setup/setup.inc.php'); */
if(extension_loaded('mcal') == False)
{
define('MCAL_RECUR_NONE',0);
define('MCAL_RECUR_DAILY',1);
define('MCAL_RECUR_WEEKLY',2);
define('MCAL_RECUR_MONTHLY_MDAY',3);
define('MCAL_RECUR_MONTHLY_WDAY',4);
define('MCAL_RECUR_YEARLY',5);
define('MCAL_M_SUNDAY',1);
define('MCAL_M_MONDAY',2);
define('MCAL_M_TUESDAY',4);
define('MCAL_M_WEDNESDAY',8);
define('MCAL_M_THURSDAY',16);
define('MCAL_M_FRIDAY',32);
define('MCAL_M_SATURDAY',64);
define('MCAL_M_WEEKDAYS',62);
define('MCAL_M_WEEKEND',65);
define('MCAL_M_ALLDAYS',127);
}
define('MSG_DELETED',0);
define('MSG_MODIFIED',1);
define('MSG_ADDED',2);
define('MSG_REJECTED',3);
define('MSG_TENTATIVE',4);
define('MSG_ACCEPTED',5);
define('MSG_ALARM',6);
define('REJECTED',0);
define('NO_RESPONSE',1);
define('TENTATIVE',2);
define('ACCEPTED',3);
class socalendar__
{
var $event;
var $stream;
var $user;
var $users_status;
var $debug = False;
// var $debug = True;
function socalendar__()
{ {
return;
} }
function maketime($time) $GLOBALS['phpgw_info']['flags']['included_classes']['socalendar__'] = True;
/* include(PHPGW_SERVER_ROOT.'/calendar/setup/setup.inc.php'); */
if(extension_loaded('mcal') == False)
{ {
return mktime($time['hour'],$time['min'],$time['sec'],$time['month'],$time['mday'],$time['year']); define('MCAL_RECUR_NONE',0);
define('MCAL_RECUR_DAILY',1);
define('MCAL_RECUR_WEEKLY',2);
define('MCAL_RECUR_MONTHLY_MDAY',3);
define('MCAL_RECUR_MONTHLY_WDAY',4);
define('MCAL_RECUR_YEARLY',5);
define('MCAL_M_SUNDAY',1);
define('MCAL_M_MONDAY',2);
define('MCAL_M_TUESDAY',4);
define('MCAL_M_WEDNESDAY',8);
define('MCAL_M_THURSDAY',16);
define('MCAL_M_FRIDAY',32);
define('MCAL_M_SATURDAY',64);
define('MCAL_M_WEEKDAYS',62);
define('MCAL_M_WEEKEND',65);
define('MCAL_M_ALLDAYS',127);
} }
function get_cached_event() define('MSG_DELETED',0);
{ define('MSG_MODIFIED',1);
return $this->event; define('MSG_ADDED',2);
} define('MSG_REJECTED',3);
define('MSG_TENTATIVE',4);
define('MSG_ACCEPTED',5);
define('MSG_ALARM',6);
function event_init() define('REJECTED',0);
{ define('NO_RESPONSE',1);
$this->event = Array(); define('TENTATIVE',2);
$this->add_attribute('owner',intval($this->user)); define('ACCEPTED',3);
}
function set_category($category='') class socalendar__
{ {
$this->add_attribute('category',$category); var $event;
} var $stream;
var $user;
var $users_status;
var $debug = False;
// var $debug = True;
function set_title($title='') function socalendar__()
{
$this->add_attribute('title',$title);
}
function set_description($description='')
{
$this->add_attribute('description',$description);
}
function set_date($element,$year,$month,$day=0,$hour=0,$min=0,$sec=0)
{
$this->add_attribute($element,intval($year),'year');
$this->add_attribute($element,intval($month),'month');
$this->add_attribute($element,intval($day),'mday');
$this->add_attribute($element,intval($hour),'hour');
$this->add_attribute($element,intval($min),'min');
$this->add_attribute($element,intval($sec),'sec');
$this->add_attribute($element,0,'alarm');
}
function set_start($year,$month,$day=0,$hour=0,$min=0,$sec=0)
{
$this->set_date('start',$year,$month,$day,$hour,$min,$sec);
}
function set_end($year,$month,$day=0,$hour=0,$min=0,$sec=0)
{
$this->set_date('end',$year,$month,$day,$hour,$min,$sec);
}
function set_alarm($alarm)
{
$this->add_attribute('alarm',intval($alarm));
}
function set_class($class)
{
$this->add_attribute('public',$class);
}
function set_common_recur($year=0,$month=0,$day=0,$interval=0)
{
$this->add_attribute('recur_interval',intval($interval));
$this->set_date('recur_enddate',$year,$month,$day,0,0,0);
$this->add_attribute('recur_data',0);
}
function set_recur_none()
{
$this->set_common_recur(0,0,0,0);
$this->add_attribute('recur_type',MCAL_RECUR_NONE);
}
function set_recur_daily($year,$month,$day,$interval)
{
$this->set_common_recur(intval($year),intval($month),intval($day),$interval);
$this->add_attribute('recur_type',MCAL_RECUR_DAILY);
}
function set_recur_weekly($year,$month,$day,$interval,$weekdays)
{
$this->set_common_recur(intval($year),intval($month),intval($day),$interval);
$this->add_attribute('recur_type',MCAL_RECUR_WEEKLY);
$this->add_attribute('recur_data',intval($weekdays));
}
function set_recur_monthly_mday($year,$month,$day,$interval)
{
$this->set_common_recur(intval($year),intval($month),intval($day),$interval);
$this->add_attribute('recur_type',MCAL_RECUR_MONTHLY_MDAY);
}
function set_recur_monthly_wday($year,$month,$day,$interval)
{
$this->set_common_recur(intval($year),intval($month),intval($day),$interval);
$this->add_attribute('recur_type',MCAL_RECUR_MONTHLY_WDAY);
}
function set_recur_yearly($year,$month,$day,$interval)
{
$this->set_common_recur(intval($year),intval($month),intval($day),$interval);
$this->add_attribute('recur_type',MCAL_RECUR_YEARLY);
}
function fetch_current_stream_event()
{
return $this->fetch_event($this->event['id']);
}
function add_attribute($attribute,$value,$element='**(**')
{
if(is_array($value))
{ {
reset($value);
} }
if($element!='**(**')
function maketime($time)
{ {
$this->event[$attribute][$element] = $value; return mktime($time['hour'],$time['min'],$time['sec'],$time['month'],$time['mday'],$time['year']);
} }
else
function get_cached_event()
{ {
$this->event[$attribute] = $value; return $this->event;
}
function event_init()
{
$this->event = Array();
$this->add_attribute('owner',(int)$this->user);
}
function set_category($category='')
{
$this->add_attribute('category',$category);
}
function set_title($title='')
{
$this->add_attribute('title',$title);
}
function set_description($description='')
{
$this->add_attribute('description',$description);
}
function set_date($element,$year,$month,$day=0,$hour=0,$min=0,$sec=0)
{
$this->add_attribute($element,(int)$year,'year');
$this->add_attribute($element,(int)$month,'month');
$this->add_attribute($element,(int)$day,'mday');
$this->add_attribute($element,(int)$hour,'hour');
$this->add_attribute($element,(int)$min,'min');
$this->add_attribute($element,(int)$sec,'sec');
$this->add_attribute($element,0,'alarm');
}
function set_start($year,$month,$day=0,$hour=0,$min=0,$sec=0)
{
$this->set_date('start',$year,$month,$day,$hour,$min,$sec);
}
function set_end($year,$month,$day=0,$hour=0,$min=0,$sec=0)
{
$this->set_date('end',$year,$month,$day,$hour,$min,$sec);
}
function set_alarm($alarm)
{
$this->add_attribute('alarm',(int)$alarm);
}
function set_class($class)
{
$this->add_attribute('public',$class);
}
function set_common_recur($year=0,$month=0,$day=0,$interval=0)
{
$this->add_attribute('recur_interval',(int)$interval);
$this->set_date('recur_enddate',$year,$month,$day,0,0,0);
$this->add_attribute('recur_data',0);
}
function set_recur_none()
{
$this->set_common_recur(0,0,0,0);
$this->add_attribute('recur_type',MCAL_RECUR_NONE);
}
function set_recur_daily($year,$month,$day,$interval)
{
$this->set_common_recur((int)$year,(int)$month,(int)$day,$interval);
$this->add_attribute('recur_type',MCAL_RECUR_DAILY);
}
function set_recur_weekly($year,$month,$day,$interval,$weekdays)
{
$this->set_common_recur((int)$year,(int)$month,(int)$day,$interval);
$this->add_attribute('recur_type',MCAL_RECUR_WEEKLY);
$this->add_attribute('recur_data',(int)$weekdays);
}
function set_recur_monthly_mday($year,$month,$day,$interval)
{
$this->set_common_recur((int)$year,(int)$month,(int)$day,$interval);
$this->add_attribute('recur_type',MCAL_RECUR_MONTHLY_MDAY);
}
function set_recur_monthly_wday($year,$month,$day,$interval)
{
$this->set_common_recur((int)$year,(int)$month,(int)$day,$interval);
$this->add_attribute('recur_type',MCAL_RECUR_MONTHLY_WDAY);
}
function set_recur_yearly($year,$month,$day,$interval)
{
$this->set_common_recur((int)$year,(int)$month,(int)$day,$interval);
$this->add_attribute('recur_type',MCAL_RECUR_YEARLY);
}
function fetch_current_stream_event()
{
return $this->fetch_event($this->event['id']);
}
function add_attribute($attribute,$value,$element='**(**')
{
if(is_array($value))
{
reset($value);
}
if($element!='**(**')
{
$this->event[$attribute][$element] = $value;
}
else
{
$this->event[$attribute] = $value;
}
} }
} }
}

File diff suppressed because it is too large Load Diff

View File

@ -31,7 +31,7 @@
{ {
echo "Updating LOCALE='".$holiday['locale']."' NAME='".$holiday['name']."' extra=(".$holiday['mday'].'/'.$holiday['month_num'].'/'.$holiday['occurence'].'/'.$holiday['dow'].'/'.$holiday['observance_rule'].")<br>\n"; echo "Updating LOCALE='".$holiday['locale']."' NAME='".$holiday['name']."' extra=(".$holiday['mday'].'/'.$holiday['month_num'].'/'.$holiday['occurence'].'/'.$holiday['dow'].'/'.$holiday['observance_rule'].")<br>\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']; $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='.(int)$holiday['observance_rule'].' WHERE hol_id='.$holiday['hol_id'];
} }
else else
{ {
@ -40,7 +40,7 @@
echo "Inserting LOCALE='".$holiday['locale']."' NAME='".$holiday['name']."' extra=(".$holiday['mday'].'/'.$holiday['month_num'].'/'.$holiday['occurence'].'/'.$holiday['dow'].'/'.$holiday['observance_rule'].")<br>\n"; echo "Inserting LOCALE='".$holiday['locale']."' NAME='".$holiday['name']."' extra=(".$holiday['mday'].'/'.$holiday['month_num'].'/'.$holiday['occurence'].'/'.$holiday['dow'].'/'.$holiday['observance_rule'].")<br>\n";
} }
$sql = 'INSERT INTO phpgw_cal_holidays(locale,name,mday,month_num,occurence,dow,observance_rule) ' $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']).")"; . "VALUES('".strtoupper($holiday['locale'])."','".$holiday['name']."',".$holiday['mday'].','.$holiday['month_num'].','.$holiday['occurence'].','.$holiday['dow'].','.(int)$holiday['observance_rule'].")";
} }
$this->db->query($sql,__LINE__,__FILE__); $this->db->query($sql,__LINE__,__FILE__);
} }
@ -53,10 +53,10 @@
'index' => $this->db->f('hol_id'), 'index' => $this->db->f('hol_id'),
'locale' => $this->db->f('locale'), 'locale' => $this->db->f('locale'),
'name' => $GLOBALS['phpgw']->strip_html($this->db->f('name')), 'name' => $GLOBALS['phpgw']->strip_html($this->db->f('name')),
'day' => intval($this->db->f('mday')), 'day' => (int)$this->db->f('mday'),
'month' => intval($this->db->f('month_num')), 'month' => (int)$this->db->f('month_num'),
'occurence' => intval($this->db->f('occurence')), 'occurence' => (int)$this->db->f('occurence'),
'dow' => intval($this->db->f('dow')), 'dow' => (int)$this->db->f('dow'),
'observance_rule' => $this->db->f('observance_rule') 'observance_rule' => $this->db->f('observance_rule')
); );
if($this->debug) if($this->debug)
@ -136,7 +136,7 @@
{ {
$querymethod = " AND name like '%".$query."%'"; $querymethod = " AND name like '%".$query."%'";
} }
if (intval($year) > 1900) if ((int)$year > 1900)
{ {
$querymethod .= " AND (occurence < 1900 OR occurence = $year)"; $querymethod .= " AND (occurence < 1900 OR occurence = $year)";
} }
@ -172,7 +172,7 @@
{ {
$querymethod = " AND name like '%".$query."%'"; $querymethod = " AND name like '%".$query."%'";
} }
if (intval($year) >= 1900) if ((int)$year >= 1900)
{ {
$querymethod .= " AND (occurence < 1900 OR occurence = $year)"; $querymethod .= " AND (occurence < 1900 OR occurence = $year)";
} }
@ -185,7 +185,7 @@
$this->db->query($sql,__LINE__,__FILE__); $this->db->query($sql,__LINE__,__FILE__);
$this->db->next_record(); $this->db->next_record();
$retval = intval($this->db->f(0)); $retval = (int)$this->db->f(0);
if($this->debug) if($this->debug)
{ {
echo 'Total Holidays for : '.$locale.' : '.$retval."<br>\n"; echo 'Total Holidays for : '.$locale.' : '.$retval."<br>\n";

View File

@ -57,7 +57,7 @@
function prep_page() function prep_page()
{ {
if ($this->bo->cal_id <= 0 || if ($this->bo->cal_id <= 0 ||
!$this->event = $this->bo->read_entry($this->bo->cal_id)) !$this->event = $this->bo->read_entry($this->bo->cal_id))
{ {
$GLOBALS['phpgw']->redirect_link('/index.php',Array( $GLOBALS['phpgw']->redirect_link('/index.php',Array(
'menuaction' => 'calendar.uicalendar.index' 'menuaction' => 'calendar.uicalendar.index'
@ -122,9 +122,9 @@
if ($_POST['add']) if ($_POST['add'])
{ {
$time = intval($_POST['time']['days'])*24*3600 + $time = (int)($_POST['time']['days'])*24*3600 +
intval($_POST['time']['hours'])*3600 + (int)($_POST['time']['hours'])*3600 +
intval($_POST['time']['mins'])*60; (int)($_POST['time']['mins'])*60;
if ($time > 0 && !$this->bo->add($this->event,$time,$_POST['owner'])) if ($time > 0 && !$this->bo->add($this->event,$time,$_POST['owner']))
{ {
@ -184,7 +184,7 @@
} }
$this->template->parse('rows','buttons',True); $this->template->parse('rows','buttons',True);
} }
if (isset($this->event['participants'][intval($GLOBALS['phpgw_info']['user']['account_id'])])) if (isset($this->event['participants'][(int)$GLOBALS['phpgw_info']['user']['account_id']]))
{ {
$this->template->set_var(Array( $this->template->set_var(Array(
'input_days' => $this->html->select('time[days]',$_POST['time']['days'],range(0,31),True).' '.lang('days'), 'input_days' => $this->html->select('time[days]',$_POST['time']['days'],range(0,31),True).' '.lang('days'),

View File

@ -108,9 +108,9 @@
$this->link_tpl = CreateObject('phpgwapi.Template',$this->template_dir); $this->link_tpl = CreateObject('phpgwapi.Template',$this->template_dir);
$this->link_tpl->set_unknowns('remove'); $this->link_tpl->set_unknowns('remove');
$this->link_tpl->set_file( $this->link_tpl->set_file(
Array( Array(
'link_picture' => 'link_pict.tpl' 'link_picture' => 'link_pict.tpl'
) )
); );
$this->link_tpl->set_block('link_picture','link_pict','link_pict'); $this->link_tpl->set_block('link_picture','link_pict','link_pict');
$this->link_tpl->set_block('link_picture','pict','pict'); $this->link_tpl->set_block('link_picture','pict','pict');
@ -176,10 +176,10 @@
$this->bo->read_holidays($params['year']); $this->bo->read_holidays($params['year']);
$date = $GLOBALS['phpgw']->datetime->makegmttime(0,0,0,$params['month'],$params['day'],$params['year']); $date = $GLOBALS['phpgw']->datetime->makegmttime(0,0,0,$params['month'],$params['day'],$params['year']);
$month_ago = intval(date('Ymd',mktime(0,0,0,$params['month'] - 1,$params['day'],$params['year']))); $month_ago = (int)(date('Ymd',mktime(0,0,0,$params['month'] - 1,$params['day'],$params['year'])));
$month_ahead = intval(date('Ymd',mktime(0,0,0,$params['month'] + 1,$params['day'],$params['year']))); $month_ahead = (int)(date('Ymd',mktime(0,0,0,$params['month'] + 1,$params['day'],$params['year'])));
$monthstart = intval(date('Ymd',mktime(0,0,0,$params['month'],1,$params['year']))); $monthstart = (int)(date('Ymd',mktime(0,0,0,$params['month'],1,$params['year'])));
$monthend = intval(date('Ymd',mktime(0,0,0,$params['month'] + 1,0,$params['year']))); $monthend = (int)(date('Ymd',mktime(0,0,0,$params['month'] + 1,0,$params['year'])));
$weekstarttime = $GLOBALS['phpgw']->datetime->get_weekday_start($params['year'],$params['month'],1); $weekstarttime = $GLOBALS['phpgw']->datetime->get_weekday_start($params['year'],$params['month'],1);
@ -269,9 +269,9 @@
foreach($daily as $date => $day_params) foreach($daily as $date => $day_params)
{ {
print_debug('Mini-Cal Date',$date); print_debug('Mini-Cal Date',$date);
$year = intval(substr($date,0,4)); $year = (int)(substr($date,0,4));
$month = intval(substr($date,4,2)); $month = (int)(substr($date,4,2));
$day = intval(substr($date,6,2)); $day = (int)(substr($date,6,2));
$str = ''; $str = '';
if(($date >= $monthstart && $date <= $monthend) || $params['outside_month'] == True) if(($date >= $monthstart && $date <= $monthend) || $params['outside_month'] == True)
{ {
@ -701,8 +701,8 @@
$cal_id = get_var('cal_id',array('GET','POST'),$vcal_id); $cal_id = get_var('cal_id',array('GET','POST'),$vcal_id);
$date = $cal_date?$cal_date:0; $date = $cal_date ? $cal_date : 0;
$date = $date?$date:intval($_GET['date']); $date = $date ? $date : (int)$_GET['date'];
// First, make sure they have permission to this entry // First, make sure they have permission to this entry
if ($cal_id < 1) if ($cal_id < 1)
@ -948,7 +948,7 @@
} }
elseif(isset($_GET['cal_id'])) elseif(isset($_GET['cal_id']))
{ {
$cal_id = intval($_GET['cal_id']); $cal_id = (int)$_GET['cal_id'];
$event = $this->bo->read_entry($cal_id); $event = $this->bo->read_entry($cal_id);
if(!$this->bo->check_perms(PHPGW_ACL_EDIT,$event)) if(!$this->bo->check_perms(PHPGW_ACL_EDIT,$event))
@ -1018,20 +1018,20 @@
// $vfs->mkdir('.calendar',array(RELATIVE_USER)); // $vfs->mkdir('.calendar',array(RELATIVE_USER));
// } // }
$content = ExecMethod('calendar.boicalendar.export', $content = ExecMethod('calendar.boicalendar.export', Array(
Array( 'l_event_id' => $_POST['cal_id'],
'l_event_id' => $_POST['cal_id'], 'chunk_split' => False,
'chunk_split' => False, ));
)
);
$vfs->cd(array('string' => '/', $vfs->cd(array(
'relatives' => array(RELATIVE_USER) 'string' => '/',
)); 'relatives' => array(RELATIVE_USER)
$vfs->write(array('string' => $output_file, ));
'relatives' => array (RELATIVE_USER), $vfs->write(array(
'content' => $content 'string' => $output_file,
)); 'relatives' => array (RELATIVE_USER),
'content' => $content
));
if($this->debug) if($this->debug)
{ {
@ -1055,7 +1055,7 @@
{ {
if(!$this->bo->check_perms(PHPGW_ACL_EDIT)) if(!$this->bo->check_perms(PHPGW_ACL_EDIT))
{ {
$this->no_edit(); $this->no_edit();
} }
elseif(!$this->bo->check_perms(PHPGW_ACL_ADD)) elseif(!$this->bo->check_perms(PHPGW_ACL_ADD))
{ {
@ -1144,17 +1144,17 @@
{ {
if(!$this->bo->check_perms(PHPGW_ACL_EDIT)) if(!$this->bo->check_perms(PHPGW_ACL_EDIT))
{ {
$this->no_edit(); $this->no_edit();
} }
elseif(!$this->bo->check_perms(PHPGW_ACL_ADD)) elseif(!$this->bo->check_perms(PHPGW_ACL_ADD))
{ {
$this->index(); $this->index();
} }
$cal_id = (isset($params['cal_id'])?intval($params['cal_id']):''); $cal_id = (isset($params['cal_id']) ? (int)$params['cal_id'] : '');
$cal_id = ($cal_id==''?intval($_GET['cal_id']):$cal_id); $cal_id = ($cal_id == '' ? (int)$_GET['cal_id'] : $cal_id);
$reinstate_index = (isset($params['reinstate_index'])?intval($params['reinstate_index']):''); $reinstate_index = (isset($params['reinstate_index']) ? (int)$params['reinstate_index'] : '');
$reinstate_index = ($reinstate_index==''?intval($_POST['reinstate_index']):$reinstate_index); $reinstate_index = ($reinstate_index == '' ? (int)$_POST['reinstate_index'] : $reinstate_index);
if($this->debug) if($this->debug)
{ {
echo '<!-- Calling bo->reinstate -->'."\n"; echo '<!-- Calling bo->reinstate -->'."\n";
@ -1203,9 +1203,9 @@
$can_edit = True; $can_edit = True;
$starthour = intval(get_var('hour',array('GET'),$this->bo->prefs['calendar']['workdaystarts'])); $starthour = (int)(get_var('hour',array('GET'),$this->bo->prefs['calendar']['workdaystarts']));
$startmin = intval(get_var('minute',array('GET'),0)); $startmin = (int)(get_var('minute',array('GET'),0));
$endmin = $startmin + intval($this->bo->prefs['calendar']['defaultlength']); $endmin = $startmin + (int)$this->bo->prefs['calendar']['defaultlength'];
$endhour = $starthour + $this->bo->normalizeminutes($endmin); $endhour = $starthour + $this->bo->normalizeminutes($endmin);
; ;
$this->bo->set_start($this->bo->year,$this->bo->month,$this->bo->day,$starthour,$startmin,0); $this->bo->set_start($this->bo->year,$this->bo->month,$this->bo->day,$starthour,$startmin,0);
@ -1244,7 +1244,7 @@
} }
$date = sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day); $date = sprintf("%04d%02d%02d",$this->bo->year,$this->bo->month,$this->bo->day);
if($this->bo->check_perms(PHPGW_ACL_DELETE,$cal_id=intval($_GET['cal_id']))) if($this->bo->check_perms(PHPGW_ACL_DELETE,$cal_id = (int)$_GET['cal_id']))
{ {
if(isset($_POST['delete_type']) && $_POST['delete_type'] == 'single') if(isset($_POST['delete_type']) && $_POST['delete_type'] == 'single')
{ {
@ -1368,7 +1368,7 @@
$label=$todo_label; $label=$todo_label;
$showall=true; $showall=true;
} }
$maxshow = intval($GLOBALS['phpgw_info']['user']['preferences']['infolog']['mainscreen_maxshow']); $maxshow = (int)$GLOBALS['phpgw_info']['user']['preferences']['infolog']['mainscreen_maxshow'];
if($maxshow<=0) if($maxshow<=0)
{ {
$maxshow=10; $maxshow=10;
@ -1433,8 +1433,8 @@
if(!$this->bo->check_perms(PHPGW_ACL_EDIT)) if(!$this->bo->check_perms(PHPGW_ACL_EDIT))
{ {
$this->no_edit(); $this->no_edit();
return; return;
} }
$freetime = $GLOBALS['phpgw']->datetime->localdates(mktime(0,0,0,$event['start']['month'],$event['start']['mday'],$event['start']['year']) - $GLOBALS['phpgw']->datetime->tz_offset); $freetime = $GLOBALS['phpgw']->datetime->localdates(mktime(0,0,0,$event['start']['month'],$event['start']['mday'],$event['start']['year']) - $GLOBALS['phpgw']->datetime->tz_offset);
@ -1462,7 +1462,7 @@
return; return;
} }
$this->bo->set_status(intval($_GET['cal_id']),intval($_GET['action'])); $this->bo->set_status((int)$_GET['cal_id'],(int)$_GET['action']);
if ($this->bo->return_to) if ($this->bo->return_to)
{ {
@ -1660,8 +1660,8 @@
$this->planner_end_month = $m - 1; $this->planner_end_month = $m - 1;
$this->planner_end_year = $y; $this->planner_end_year = $y;
$this->planner_days_in_end_month = $GLOBALS['phpgw']->datetime->days_in_month($this->planner_end_month,$this->planner_end_year); $this->planner_days_in_end_month = $GLOBALS['phpgw']->datetime->days_in_month($this->planner_end_month,$this->planner_end_year);
$this->planner_firstday = intval(date('Ymd',mktime(0,0,0,$this->bo->month,1,$this->bo->year))); $this->planner_firstday = (int)(date('Ymd',mktime(0,0,0,$this->bo->month,1,$this->bo->year)));
$this->planner_lastday = intval(date('Ymd',mktime(0,0,0,$this->planner_end_month,$this->planner_days_in_end_month,$this->planner_end_year))); $this->planner_lastday = (int)(date('Ymd',mktime(0,0,0,$this->planner_end_month,$this->planner_days_in_end_month,$this->planner_end_year)));
// generate line with calendar weeks in observed interval // generate line with calendar weeks in observed interval
// //
@ -1669,9 +1669,9 @@
$w = date('W', $d); $w = date('W', $d);
if ($w == 'W') // php < 4.1 if ($w == 'W') // php < 4.1
{ {
$w = 1 + intval(date('z',$d) / 7); // a bit simplistic $w = 1 + (int)(date('z',$d) / 7); // a bit simplistic
} }
$offset = (7-date("w", $d)+1)%7; $offset = (7-date('w', $d)+1)%7;
$offset = $offset == 0 ? 7 : $offset; $offset = $offset == 0 ? 7 : $offset;
$color = $this->theme[$w % 2 ? 'th_bg' : 'row_on']; $color = $this->theme[$w % 2 ? 'th_bg' : 'row_on'];
@ -1691,7 +1691,7 @@
$w = date('W', $d); $w = date('W', $d);
if ($w == 'W') // php < 4.1 if ($w == 'W') // php < 4.1
{ {
$w = 1 + intval(date('z',$d) / 7); // a bit simplistic $w = 1 + (int)(date('z',$d) / 7); // a bit simplistic
} }
$w += (isset($hdr[1][$w]))?1:0; // bug in "date('W')" ? $w += (isset($hdr[1][$w]))?1:0; // bug in "date('W')" ?
@ -1777,7 +1777,7 @@
if (!$is_private) if (!$is_private)
{ {
$max_chars = intval(3*$colspan/$intervals_per_day-2); $max_chars = (int)(3*$colspan/$intervals_per_day-2);
$min_chars = 3; // minimum for max_chars to display -> this should be configurable $min_chars = 3; // minimum for max_chars to display -> this should be configurable
if ($max_chars >= $min_chars) if ($max_chars >= $min_chars)
@ -1878,12 +1878,18 @@
// caluculate start and end of event // caluculate start and end of event
// //
$event_start = intval(date('Ymd',mktime(0,0,0,$event['start']['month'], $event_start = (int)(date('Ymd',mktime(
$event['start']['mday'], 0,0,0,
$event['start']['year']))); $event['start']['month'],
$event_end = intval(date('Ymd',mktime(0,0,0,$event['end']['month'], $event['start']['mday'],
$event['end']['mday'], $event['start']['year']
$event['end']['year']))); )));
$event_end = (int)(date('Ymd',mktime(
0,0,0,
$event['end']['month'],
$event['end']['mday'],
$event['end']['year']
)));
// calculate first cell of event within observed interval // calculate first cell of event within observed interval
// //
@ -2096,9 +2102,9 @@
$var[] = Array( $var[] = Array(
'field' => lang('Date'), 'field' => lang('Date'),
'data' => $GLOBALS['phpgw']->common->dateformatorder( 'data' => $GLOBALS['phpgw']->common->dateformatorder(
$sb->getYears('year',intval($GLOBALS['phpgw']->common->show_date($datetime,'Y')),intval($GLOBALS['phpgw']->common->show_date($datetime,'Y'))), $sb->getYears('year',(int)$GLOBALS['phpgw']->common->show_date($datetime,'Y'),(int)$GLOBALS['phpgw']->common->show_date($datetime,'Y')),
$sb->getMonthText('month',intval($GLOBALS['phpgw']->common->show_date($datetime,'n'))), $sb->getMonthText('month',(int)$GLOBALS['phpgw']->common->show_date($datetime,'n')),
$sb->getDays('day',intval($GLOBALS['phpgw']->common->show_date($datetime,'d'))) $sb->getDays('day',(int)$GLOBALS['phpgw']->common->show_date($datetime,'d'))
) )
); );
@ -2201,7 +2207,7 @@
switch ($GLOBALS['phpgw']->accounts->get_type($participant)) switch ($GLOBALS['phpgw']->accounts->get_type($participant))
{ {
case 'g': case 'g':
if ($members = $acct->member(intval($participant))) if ($members = $acct->member((int)$participant))
{ {
foreach($members as $member) foreach($members as $member)
{ {
@ -2425,7 +2431,7 @@
} }
} }
if($GLOBALS['phpgw_info']['flags']['currentapp'] == 'home' || if($GLOBALS['phpgw_info']['flags']['currentapp'] == 'home' ||
strstr($GLOBALS['phpgw_info']['flags']['currentapp'],'mail')) // email, felamimail, ... strstr($GLOBALS['phpgw_info']['flags']['currentapp'],'mail')) // email, felamimail, ...
{ {
$page_app = 'calendar'; $page_app = 'calendar';
} }
@ -2472,7 +2478,7 @@
if (@$this->bo->printer_friendly) if (@$this->bo->printer_friendly)
{ {
return; return;
} }
$p = $GLOBALS['phpgw']->template; $p = $GLOBALS['phpgw']->template;
@ -2531,8 +2537,8 @@
$end = $begin + 6*24*60*60; $end = $begin + 6*24*60*60;
// echo "<br>$i: ".date('d.m.Y H:i',$begin).' - '.date('d.m.Y H:i',$end); // echo "<br>$i: ".date('d.m.Y H:i',$begin).' - '.date('d.m.Y H:i',$end);
$str .= '<option value="' . $GLOBALS['phpgw']->common->show_date($begin,'Ymd') . '"'.($begin <= $thisdate && $end >= $thisdate?' selected':'').'>' $str .= '<option value="' . $GLOBALS['phpgw']->common->show_date($begin,'Ymd') . '"'.($begin <= $thisdate && $end >= $thisdate?' selected':'').'>'
. $GLOBALS['phpgw']->common->show_date($begin,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']) . ' - ' . $GLOBALS['phpgw']->common->show_date($begin,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']) . ' - '
. $GLOBALS['phpgw']->common->show_date($end,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']); . $GLOBALS['phpgw']->common->show_date($end,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
} }
$var = Array( $var = Array(
@ -2616,11 +2622,11 @@
$GLOBALS['phpgw']->browser->browser(); $GLOBALS['phpgw']->browser->browser();
if($GLOBALS['phpgw']->browser->get_agent() == 'MOZILLA') if($GLOBALS['phpgw']->browser->get_agent() == 'MOZILLA')
{ {
$time_width = (intval($this->bo->prefs['common']['time_format']) == 12?12:8); $time_width = ((int)($this->bo->prefs['common']['time_format']) == 12?12:8);
} }
else else
{ {
$time_width = (intval($this->bo->prefs['common']['time_format']) == 12?10:7); $time_width = ((int)($this->bo->prefs['common']['time_format']) == 12?10:7);
} }
return 'A.minicalendar { color: #000000; font: x-small '.$this->theme['font'].' }'."\n" return 'A.minicalendar { color: #000000; font: x-small '.$this->theme['font'].' }'."\n"
@ -2665,7 +2671,7 @@
$rawdate = mktime(0,0,0,$month,$day,$year); $rawdate = mktime(0,0,0,$month,$day,$year);
$rawdate_offset = $rawdate - $GLOBALS['phpgw']->datetime->tz_offset; $rawdate_offset = $rawdate - $GLOBALS['phpgw']->datetime->tz_offset;
$nextday = mktime(0,0,0,$month,$day + 1,$year) - $GLOBALS['phpgw']->datetime->tz_offset; $nextday = mktime(0,0,0,$month,$day + 1,$year) - $GLOBALS['phpgw']->datetime->tz_offset;
if (intval($GLOBALS['phpgw']->common->show_date($starttime,'Hi')) && $starttime == $endtime) if ((int)$GLOBALS['phpgw']->common->show_date($starttime,'Hi') && $starttime == $endtime)
{ {
$time = $GLOBALS['phpgw']->common->show_date($starttime,$this->bo->users_timeformat); $time = $GLOBALS['phpgw']->common->show_date($starttime,$this->bo->users_timeformat);
} }
@ -2673,9 +2679,9 @@
{ {
$time = '[ '.lang('All Day').' ]'; $time = '[ '.lang('All Day').' ]';
} }
elseif (intval($GLOBALS['phpgw']->common->show_date($starttime,'Hi')) || $starttime != $endtime) elseif ((int)$GLOBALS['phpgw']->common->show_date($starttime,'Hi') || $starttime != $endtime)
{ {
if($starttime < $rawdate_offset && $event['recur_type']==MCAL_RECUR_NONE) if($starttime < $rawdate_offset && $event['recur_type'] == MCAL_RECUR_NONE)
{ {
$start_time = $GLOBALS['phpgw']->common->show_date($rawdate_offset,$this->bo->users_timeformat); $start_time = $GLOBALS['phpgw']->common->show_date($rawdate_offset,$this->bo->users_timeformat);
} }
@ -2781,8 +2787,8 @@
if($this->bo->alarm_today($event,$rawdate_offset,$starttime)) if($this->bo->alarm_today($event,$rawdate_offset,$starttime))
{ {
$picture[] = Array( $picture[] = Array(
'pict' => $GLOBALS['phpgw']->common->image('calendar','alarm'), 'pict' => $GLOBALS['phpgw']->common->image('calendar','alarm'),
'width' => 13, 'width' => 13,
'height'=> 13, 'height'=> 13,
'title' => lang('alarm') 'title' => lang('alarm')
); );
@ -2793,10 +2799,10 @@
for($i=0;$i<count($picture);$i++) for($i=0;$i<count($picture);$i++)
{ {
$var = Array( $var = Array(
'pic_image' => $picture[$i]['pict'], 'pic_image' => $picture[$i]['pict'],
'width' => $picture[$i]['width'], 'width' => $picture[$i]['width'],
'height' => $picture[$i]['height'], 'height' => $picture[$i]['height'],
'title' => $picture[$i]['title'] 'title' => $picture[$i]['title']
); );
$this->output_template_array($this->link_tpl,'picture','pict',$var); $this->output_template_array($this->link_tpl,'picture','pict',$var);
} }
@ -3030,12 +3036,12 @@
$daily = $this->set_week_array($startdate - $GLOBALS['phpgw']->datetime->tz_offset,$cellcolor,$weekly); $daily = $this->set_week_array($startdate - $GLOBALS['phpgw']->datetime->tz_offset,$cellcolor,$weekly);
foreach($daily as $date => $day_params) foreach($daily as $date => $day_params)
{ {
$year = intval(substr($date,0,4)); $year = (int)substr($date,0,4);
$month = intval(substr($date,4,2)); $month = (int)substr($date,4,2);
$day = intval(substr($date,6,2)); $day = (int)substr($date,6,2);
$var = Array( $var = Array(
'column_data' => '', 'column_data' => '',
'extra' => '' 'extra' => ''
); );
$p->set_var($var); $p->set_var($var);
if ($weekly || ($date >= $monthstart && $date <= $monthend)) if ($weekly || ($date >= $monthstart && $date <= $monthend))
@ -3132,8 +3138,8 @@
) )
); );
$monthstart = intval(date('Ymd',mktime(0,0,0,$month ,1,$year))); $monthstart = (int)(date('Ymd',mktime(0,0,0,$month ,1,$year)));
$monthend = intval(date('Ymd',mktime(0,0,0,$month + 1,0,$year))); $monthend = (int)(date('Ymd',mktime(0,0,0,$month + 1,0,$year)));
$start = $GLOBALS['phpgw']->datetime->get_weekday_start($year, $month, 1); $start = $GLOBALS['phpgw']->datetime->get_weekday_start($year, $month, 1);
@ -3148,13 +3154,12 @@
$p->set_file( $p->set_file(
Array( Array(
'week' => 'month_day.tpl' 'week' => 'month_day.tpl'
) )
); );
$p->set_block('week','m_w_table','m_w_table'); $p->set_block('week','m_w_table','m_w_table');
$p->set_block('week','event','event'); $p->set_block('week','event','event');
$var = Array( $var = Array(
'cols' => 7, 'cols' => 7,
'day_events'=> $this->week_header($month,$year,False) 'day_events'=> $this->week_header($month,$year,False)
@ -3163,7 +3168,7 @@
$cellcolor = $this->theme['row_on']; $cellcolor = $this->theme['row_on'];
for ($i=intval($start + $GLOBALS['phpgw']->datetime->tz_offset);intval(date('Ymd',$i)) <= $monthend;$i += 604800) for($i = (int)($start + $GLOBALS['phpgw']->datetime->tz_offset);(int)(date('Ymd',$i)) <= $monthend;$i += 604800)
{ {
$cellcolor = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($cellcolor); $cellcolor = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($cellcolor);
$var = Array( $var = Array(
@ -3219,8 +3224,8 @@
$cols = 7; $cols = 7;
} }
$var = Array( $var = Array(
'cols' => $cols, 'cols' => $cols,
'day_events' => $this->week_header($month,$year,$display_name) 'day_events' => $this->week_header($month,$year,$display_name)
); );
$this->output_template_array($p,'row','event',$var); $this->output_template_array($p,'row','event',$var);
@ -3275,7 +3280,7 @@
{ {
if ($this->bo->check_perms(PHPGW_ACL_EDIT,0,$user) && ereg('^(.*) \((.*)\)$',$str,$parts)) if ($this->bo->check_perms(PHPGW_ACL_EDIT,0,$user) && ereg('^(.*) \((.*)\)$',$str,$parts))
{ {
$vars['participants']['data'][$user] = $parts[1].' (<a href="'.$this->page('edit_status','&cal_id='.$event['id'].'&owner='.$user).'">'.$parts[2].'</a>)'; $vars['participants']['data'][$user] = $parts[1].' (<a href="'.$this->page('edit_status','&cal_id='.$event['id'].'&owner='.$user).'">'.$parts[2].'</a>)';
} }
} }
$vars['participants']['data'] = implode("<br>\n",$vars['participants']['data']); $vars['participants']['data'] = implode("<br>\n",$vars['participants']['data']);
@ -3328,7 +3333,7 @@
{ {
$time = $day_end; $time = $day_end;
} }
$slot = intval(($time - $day_start) / $interval); $slot = (int)(($time - $day_start) / $interval);
return $slot < 0 ? 0 : 1+$slot; return $slot < 0 ? 0 : 1+$slot;
} }
@ -3483,7 +3488,7 @@
} }
else else
{ {
$rowspan = intval($row_span[$slot]); $rowspan = (int)$row_span[$slot];
if ($rowspan > 1) if ($rowspan > 1)
{ {
$p->set_var('extras',' rowspan="'.$rowspan.'"'); $p->set_var('extras',' rowspan="'.$rowspan.'"');
@ -3728,12 +3733,12 @@
'action_url' => $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.bocalendar.update')), 'action_url' => $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.bocalendar.update')),
'accounts_link' => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uicalendar.accounts_popup'), 'accounts_link' => $GLOBALS['phpgw']->link('/index.php','menuaction=calendar.uicalendar.accounts_popup'),
'common_hidden' => '<input type="hidden" name="cal[id]" value="'.$event['id'].'">'."\n" '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[owner]" value="'.$event['owner'].'">'."\n"
. '<input type="hidden" name="cal[uid]" value="'.$event['uid'].'">'."\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": . ($_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":'')) (@isset($event['reference'])?'<input type="hidden" name="cal[reference]" value="'.$event['reference'].'">'."\n":''))
. (@isset($GLOBALS['phpgw_info']['server']['deny_user_grants_access']) && $GLOBALS['phpgw_info']['server']['deny_user_grants_access']? . (@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":''), '<input type="hidden" name="participants[]" value="'.$this->bo->owner.'">'."\n":''),
'errormsg' => ($param['cd']?$GLOBALS['phpgw']->common->check_code($param['cd']):'') 'errormsg' => ($param['cd']?$GLOBALS['phpgw']->common->check_code($param['cd']):'')
); );
$p->set_var($vars); $p->set_var($vars);
@ -3758,12 +3763,12 @@
@reset($temp_cats); @reset($temp_cats);
while(list($key,$value) = each($temp_cats)) while(list($key,$value) = each($temp_cats))
{ {
$check_cats[] = intval($value); $check_cats[] = (int)$value;
} }
} }
elseif($event['category']) elseif($event['category'])
{ {
$check_cats[] = intval($event['category']); $check_cats[] = (int)$event['category'];
} }
else else
{ {
@ -3787,9 +3792,9 @@
'field' => lang('Start Date'), 'field' => lang('Start Date'),
/* /*
'data' => $GLOBALS['phpgw']->common->dateformatorder( 'data' => $GLOBALS['phpgw']->common->dateformatorder(
$sb->getYears('start[year]',intval($GLOBALS['phpgw']->common->show_date($start,'Y'))), $sb->getYears('start[year]',(int)$GLOBALS['phpgw']->common->show_date($start,'Y')),
$sb->getMonthText('start[month]',intval($GLOBALS['phpgw']->common->show_date($start,'n'))), $sb->getMonthText('start[month]',(int)$GLOBALS['phpgw']->common->show_date($start,'n')),
$sb->getDays('start[mday]',intval($GLOBALS['phpgw']->common->show_date($start,'d'))) $sb->getDays('start[mday]',(int)$GLOBALS['phpgw']->common->show_date($start,'d'))
) )
*/ */
'data' => $jscal->input('start[str]',$start) 'data' => $jscal->input('start[str]',$start)
@ -3812,9 +3817,9 @@
'field' => lang('End Date'), 'field' => lang('End Date'),
/* /*
'data' => $GLOBALS['phpgw']->common->dateformatorder( 'data' => $GLOBALS['phpgw']->common->dateformatorder(
$sb->getYears('end[year]',intval($GLOBALS['phpgw']->common->show_date($end,'Y'))), $sb->getYears('end[year]',(int)$GLOBALS['phpgw']->common->show_date($end,'Y')),
$sb->getMonthText('end[month]',intval($GLOBALS['phpgw']->common->show_date($end,'n'))), $sb->getMonthText('end[month]',(int)$GLOBALS['phpgw']->common->show_date($end,'n')),
$sb->getDays('end[mday]',intval($GLOBALS['phpgw']->common->show_date($end,'d'))) $sb->getDays('end[mday]',(int)$GLOBALS['phpgw']->common->show_date($end,'d'))
) )
*/ */
'data' => $jscal->input('end[str]',$end) 'data' => $jscal->input('end[str]',$end)
@ -3859,7 +3864,7 @@
case 'popup': case 'popup':
while (is_array($event['participants']) && list($id) = each($event['participants'])) while (is_array($event['participants']) && list($id) = each($event['participants']))
{ {
if($id != intval($event['owner'])) if($id != (int)$event['owner'])
{ {
$str .= '<option value="' . $id.$event['participants'][$id] . '"'.($event['participants'][$id]?' selected':'').'>('.$GLOBALS['phpgw']->accounts->get_type($id) $str .= '<option value="' . $id.$event['participants'][$id] . '"'.($event['participants'][$id]?' selected':'').'>('.$GLOBALS['phpgw']->accounts->get_type($id)
.') ' . $GLOBALS['phpgw']->common->grab_owner_name($id) . '</option>' . "\n"; .') ' . $GLOBALS['phpgw']->common->grab_owner_name($id) . '</option>' . "\n";
@ -3875,7 +3880,7 @@
default: default:
foreach($users as $id => $user_array) foreach($users as $id => $user_array)
{ {
if($id != intval($event['owner'])) if($id != (int)$event['owner'])
{ {
$str .= ' <option value="' . $id.$event['participants'][$id] . '"'.($event['participants'][$id]?' selected':'').'>('.$user_array['type'].') '.$user_array['name'].'</option>'."\n"; $str .= ' <option value="' . $id.$event['participants'][$id] . '"'.($event['participants'][$id]?' selected':'').'>('.$user_array['type'].') '.$user_array['name'].'</option>'."\n";
} }
@ -3970,10 +3975,10 @@
@reset($event['alarm']); @reset($event['alarm']);
// just get the first one see above!!! // just get the first one see above!!!
list($key,$alarm) = @each($event['alarm']); list($key,$alarm) = @each($event['alarm']);
$diff = $start - $alarm['time']; $diff = $start - $alarm['time'];
$days = intval($diff / (24*3600)); $days = (int)($diff / (24*3600));
$hours = intval(($diff - ($days * 24 * 3600))/3600); $hours = (int)(($diff - ($days * 24 * 3600))/3600);
$min = intval(($diff - ($days * 24 * 3600) - ($hours * 3600))/60); $min = (int)(($diff - ($days * 24 * 3600) - ($hours * 3600))/60);
} }
// days // days
@ -4032,9 +4037,9 @@
'data' => '<input type="checkbox" name="cal[rpt_use_end]" value="y"'.$checked.'>'.lang('Use End Date').' '. 'data' => '<input type="checkbox" name="cal[rpt_use_end]" value="y"'.$checked.'>'.lang('Use End Date').' '.
/* /*
$GLOBALS['phpgw']->common->dateformatorder( $GLOBALS['phpgw']->common->dateformatorder(
$sb->getYears('recur_enddate[year]',intval($GLOBALS['phpgw']->common->show_date($recur_end,'Y'))), $sb->getYears('recur_enddate[year]',(int)$GLOBALS['phpgw']->common->show_date($recur_end,'Y')),
$sb->getMonthText('recur_enddate[month]',intval($GLOBALS['phpgw']->common->show_date($recur_end,'n'))), $sb->getMonthText('recur_enddate[month]',(int)$GLOBALS['phpgw']->common->show_date($recur_end,'n')),
$sb->getDays('recur_enddate[mday]',intval($GLOBALS['phpgw']->common->show_date($recur_end,'d'))) $sb->getDays('recur_enddate[mday]',(int)$GLOBALS['phpgw']->common->show_date($recur_end,'d'))
) )
*/ */
$jscal->input('recur_enddate[str]',$recur_end) $jscal->input('recur_enddate[str]',$recur_end)
@ -4228,11 +4233,11 @@
for ($i=0; $i<count($control_data['part']); $i++) for ($i=0; $i<count($control_data['part']); $i++)
{ {
$id = $control_data['part'][$i]; $id = $control_data['part'][$i];
list($contact) = $this->read_contact($id); list($contact) = $this->read_contact($id);
$participant[$id] = array(); $participant[$id] = array();
$participant[$id]['name'] = $contact['n_given'].' '.$contact['n_family']; $participant[$id]['name'] = $contact['n_given'].' '.$contact['n_family'];
} }
if ($control_data['action'] == lang('Delete selected contacts')) if ($control_data['action'] == lang('Delete selected contacts'))
@ -4247,7 +4252,7 @@
if ($control_data['action'] == lang('Add Contact')) if ($control_data['action'] == lang('Add Contact'))
{ {
$id = $_POST['id_addr']; $id = $_POST['id_addr'];
if (isset($id) && intval($id) != 0) if (isset($id) && (int)$id != 0)
{ {
list($contact) = $this->read_contact($id); list($contact) = $this->read_contact($id);
$participant[$id] = array(); $participant[$id] = array();
@ -4299,7 +4304,7 @@
$charset = lang('charset'); $charset = lang('charset');
$p->set_var('charset',$charset); $p->set_var('charset',$charset);
$p->set_var('page_title',$GLOBALS['phpgw_flags']['currentapp'] $p->set_var('page_title',$GLOBALS['phpgw_flags']['currentapp']
. ' - ' .lang('External Participants')); . ' - ' .lang('External Participants'));
$p->set_var('font_family',$GLOBALS['phpgw_info']['theme']['font']); $p->set_var('font_family',$GLOBALS['phpgw_info']['theme']['font']);
$p->set_var('body_tags',$body_tags); $p->set_var('body_tags',$body_tags);
$p->set_var('form_method','POST'); $p->set_var('form_method','POST');
@ -4325,7 +4330,7 @@
'email_home' => 'email_home' 'email_home' => 'email_home'
); );
/* /*
if ($this->rights & PHPGW_ACL_READ) if ($this->rights & PHPGW_ACL_READ)
{ {
return $this->contacts->read_single_entry($id,$fields); return $this->contacts->read_single_entry($id,$fields);
@ -4335,10 +4340,10 @@
$rtrn = array(0 => array('No access' => 'No access')); $rtrn = array(0 => array('No access' => 'No access'));
return $rtrn; return $rtrn;
} }
*/ */
$contacts = CreateObject('phpgwapi.contacts', False); $contacts = CreateObject('phpgwapi.contacts', False);
return $contacts->read_single_entry($id,$query_fields); return $contacts->read_single_entry($id,$query_fields);
} }
function build_part_list(&$users,$accounts,$owner) function build_part_list(&$users,$accounts,$owner)
@ -4349,7 +4354,7 @@
} }
foreach($accounts as $id) foreach($accounts as $id)
{ {
$id = intval($id); $id = (int)$id;
if($id == $owner) if($id == $owner)
{ {
continue; continue;

View File

@ -129,8 +129,8 @@
$ordered[$order] = array( $ordered[$order] = array(
'field' => $field, 'field' => $field,
'name' => stripslashes($_POST['name'][$field]), 'name' => stripslashes($_POST['name'][$field]),
'length' => intval($_POST['length'][$field]), 'length' => (int)$_POST['length'][$field],
'shown' => intval($_POST['shown'][$field]), 'shown' => (int)$_POST['shown'][$field],
'title' => !!$_POST['title'][$field], 'title' => !!$_POST['title'][$field],
'disabled' => !!$_POST['disabled'][$field] 'disabled' => !!$_POST['disabled'][$field]
); );
@ -158,8 +158,8 @@
$ordered[$order] = array( $ordered[$order] = array(
'field' => '#'.$name, 'field' => '#'.$name,
'name' => $name, 'name' => $name,
'length' => intval($_POST['length']['***new***']), 'length' => (int)$_POST['length']['***new***'],
'shown' => intval($_POST['shown']['***new***']), 'shown' => (int)$_POST['shown']['***new***'],
'title' => !!$_POST['title']['***new***'], 'title' => !!$_POST['title']['***new***'],
'disabled' => !!$_POST['disabled']['***new***'] 'disabled' => !!$_POST['disabled']['***new***']
); );

View File

@ -264,11 +264,11 @@
} }
$var = Array( $var = Array(
'title_holiday'=> ($this->bo->id ? lang('Edit') : lang('Add')).' '.lang('Holiday'), 'title_holiday' => ($this->bo->id ? lang('Edit') : lang('Add')).' '.lang('Holiday'),
'message' => $message, 'message' => $message,
'actionurl' => $GLOBALS['phpgw']->link($this->base_url,'menuaction=calendar.boholiday.add&year='.$this->bo->year), 'actionurl' => $GLOBALS['phpgw']->link($this->base_url,'menuaction=calendar.boholiday.add&year='.$this->bo->year),
'hidden_vars' => '<input type="hidden" name="holiday[hol_id]" value="'.$this->bo->id.'">'."\n" 'hidden_vars' => '<input type="hidden" name="holiday[hol_id]" value="'.$this->bo->id.'">'."\n"
. '<input type="hidden" name="holiday[locales]" value="'.$this->bo->locales[0].'">'."\n" . '<input type="hidden" name="holiday[locales]" value="'.$this->bo->locales[0].'">'."\n"
); );
$t->set_var($var); $t->set_var($var);

View File

@ -12,11 +12,11 @@
/* $Id$ */ /* $Id$ */
global $pref; global $pref;
$pref->change("calendar","weekstarts","Monday"); $pref->change('calendar','weekstarts','Monday');
$pref->change("calendar","workdaystarts","9"); $pref->change('calendar','workdaystarts','9');
$pref->change("calendar","workdayends","17"); $pref->change('calendar','workdayends','17');
$pref->change("calendar","defaultcalendar","month.php"); $pref->change('calendar','defaultcalendar','month.php');
$pref->change("calendar","defaultfilter","all"); $pref->change('calendar','defaultfilter',"all');
$pref->change("calendar","mainscreen_showevents","Y"); $pref->change('calendar','mainscreen_showevents','Y');
?> ?>

View File

@ -12,16 +12,16 @@
/* $Id$ */ /* $Id$ */
// Delete all records for a user // Delete all records for a user
if(intval($GLOBALS['HTTP_POST_VARS']['new_owner'])==0) if((int)$_POST['new_owner'] == 0)
{ {
ExecMethod('calendar.bocalendar.delete_calendar',intval($GLOBALS['HTTP_POST_VARS']['account_id'])); ExecMethod('calendar.bocalendar.delete_calendar',(int)$_POST['account_id']);
} }
else else
{ {
ExecMethod('calendar.bocalendar.change_owner', ExecMethod('calendar.bocalendar.change_owner',
Array( Array(
'old_owner' => intval($GLOBALS['HTTP_POST_VARS']['account_id']), 'old_owner' => (int)$_POST['account_id'],
'new_owner' => intval($GLOBALS['HTTP_POST_VARS']['new_owner']) 'new_owner' => (int)$_POST['new_owner']
) )
); );
} }

View File

@ -22,7 +22,7 @@
} }
unset($d1); unset($d1);
$showevents = intval($GLOBALS['phpgw_info']['user']['preferences']['calendar']['mainscreen_showevents']); $showevents = (int)$GLOBALS['phpgw_info']['user']['preferences']['calendar']['mainscreen_showevents'];
if($showevents>0) if($showevents>0)
{ {
$GLOBALS['phpgw']->translation->add_app('calendar'); $GLOBALS['phpgw']->translation->add_app('calendar');

View File

@ -11,7 +11,7 @@
/* $Id$ */ /* $Id$ */
$phpgw_flags = Array( $GLOBALS['phpgw']_flags = Array(
'currentapp' => 'calendar', 'currentapp' => 'calendar',
'enable_nextmatchs_class' => True, 'enable_nextmatchs_class' => True,
'noheader' => True, 'noheader' => True,
@ -20,82 +20,82 @@
'noappfooter' => True 'noappfooter' => True
); );
$phpgw_info['flags'] = $phpgw_flags; $GLOBALS['phpgw_info']['flags'] = $GLOBALS['phpgw']_flags;
include('../header.inc.php'); include('../header.inc.php');
if ($submit) if ($submit)
{ {
$phpgw->preferences->read_repository(); $GLOBALS['phpgw']->preferences->read_repository();
$phpgw->preferences->add('calendar','weekdaystarts'); $GLOBALS['phpgw']->preferences->add('calendar','weekdaystarts');
$phpgw->preferences->add('calendar','workdaystarts'); $GLOBALS['phpgw']->preferences->add('calendar','workdaystarts');
$phpgw->preferences->add('calendar','workdayends'); $GLOBALS['phpgw']->preferences->add('calendar','workdayends');
$phpgw->preferences->add('calendar','defaultcalendar'); $GLOBALS['phpgw']->preferences->add('calendar','defaultcalendar');
$phpgw->preferences->add('calendar','defaultfilter'); $GLOBALS['phpgw']->preferences->add('calendar','defaultfilter');
$phpgw->preferences->add('calendar','interval'); $GLOBALS['phpgw']->preferences->add('calendar','interval');
if ($mainscreen_showevents == True) if ($mainscreen_showevents == True)
{ {
$phpgw->preferences->add('calendar','mainscreen_showevents'); $GLOBALS['phpgw']->preferences->add('calendar','mainscreen_showevents');
} }
else else
{ {
$phpgw->preferences->delete('calendar','mainscreen_showevents'); $GLOBALS['phpgw']->preferences->delete('calendar','mainscreen_showevents');
} }
if ($send_updates == True) if ($send_updates == True)
{ {
$phpgw->preferences->add('calendar','send_updates'); $GLOBALS['phpgw']->preferences->add('calendar','send_updates');
} }
else else
{ {
$phpgw->preferences->delete('calendar','send_updates'); $GLOBALS['phpgw']->preferences->delete('calendar','send_updates');
} }
if ($display_status == True) if ($display_status == True)
{ {
$phpgw->preferences->add('calendar','display_status'); $GLOBALS['phpgw']->preferences->add('calendar','display_status');
} }
else else
{ {
$phpgw->preferences->delete('calendar','display_status'); $GLOBALS['phpgw']->preferences->delete('calendar','display_status');
} }
if ($default_private == True) if ($default_private == True)
{ {
$phpgw->preferences->add('calendar','default_private'); $GLOBALS['phpgw']->preferences->add('calendar','default_private');
} }
else else
{ {
$phpgw->preferences->delete('calendar','default_private'); $GLOBALS['phpgw']->preferences->delete('calendar','default_private');
} }
if ($display_minicals == True) if ($display_minicals == True)
{ {
$phpgw->preferences->add('calendar','display_minicals'); $GLOBALS['phpgw']->preferences->add('calendar','display_minicals');
} }
else else
{ {
$phpgw->preferences->delete('calendar','display_minicals'); $GLOBALS['phpgw']->preferences->delete('calendar','display_minicals');
} }
if ($print_black_white == True) if ($print_black_white == True)
{ {
$phpgw->preferences->add('calendar','print_black_white'); $GLOBALS['phpgw']->preferences->add('calendar','print_black_white');
} }
else else
{ {
$phpgw->preferences->delete('calendar','print_black_white'); $GLOBALS['phpgw']->preferences->delete('calendar','print_black_white');
} }
$phpgw->preferences->save_repository(True); $GLOBALS['phpgw']->preferences->save_repository(True);
Header('Location: '.$phpgw->link('/preferences/index.php')); Header('Location: '.$GLOBALS['phpgw']->link('/preferences/index.php'));
$phpgw->common->phpgw_exit(); $GLOBALS['phpgw']->common->phpgw_exit();
} }
function display_item($field,$data) function display_item($field,$data)
{ {
global $phpgw, $p, $tr_color; global $GLOBALS['phpgw'], $p, $tr_color;
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color); $tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color);
$var = Array( $var = Array(
'bg_color' => $tr_color, 'bg_color' => $tr_color,
'field' => $field, 'field' => $field,
@ -105,10 +105,10 @@
$p->parse('row','pref_list',True); $p->parse('row','pref_list',True);
} }
$phpgw->common->phpgw_header(); $GLOBALS['phpgw']->common->phpgw_header();
echo parse_navbar(); echo parse_navbar();
$p = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('calendar')); $p = CreateObject('phpgwapi.Template',$GLOBALS['phpgw']->common->get_tpl_dir('calendar'));
$templates = Array( $templates = Array(
'pref' => 'pref.tpl', 'pref' => 'pref.tpl',
'pref_colspan' => 'pref_colspan.tpl', 'pref_colspan' => 'pref_colspan.tpl',
@ -118,8 +118,8 @@
$var = Array( $var = Array(
'title' => lang('Calendar preferences'), 'title' => lang('Calendar preferences'),
'action_url' => $phpgw->link('/'.$phpgw_info['flags']['currentapp'].'/preferences.php'), 'action_url' => $GLOBALS['phpgw']->link('/'.$GLOBALS['phpgw_info']['flags']['currentapp'].'/preferences.php'),
'bg_color' => $phpgw_info['theme']['th_bg'], 'bg_color' => $GLOBALS['phpgw_info']['theme']['th_bg'],
'submit_lang' => lang('submit') 'submit_lang' => lang('submit')
); );
@ -129,13 +129,13 @@
// if ($totalerrors) // if ($totalerrors)
// { // {
// echo '<p><center>' . $phpgw->common->error_list($errors) . '</center>'; // echo '<p><center>' . $GLOBALS['phpgw']->common->error_list($errors) . '</center>';
// } // }
$str = '<input type="checkbox" name="mainscreen_showevents" value="True"'.($phpgw_info['user']['preferences']['calendar']['mainscreen_showevents'] == 'Y' || $phpgw_info['user']['preferences']['calendar']['mainscreen_showevents'] == True?' checked':'').'>'; $str = '<input type="checkbox" name="mainscreen_showevents" value="True"'.($GLOBALS['phpgw_info']['user']['preferences']['calendar']['mainscreen_showevents'] == 'Y' || $GLOBALS['phpgw_info']['user']['preferences']['calendar']['mainscreen_showevents'] == True?' checked':'').'>';
display_item(lang('show day view on main screen'),$str); display_item(lang('show day view on main screen'),$str);
$t_weekday[$phpgw_info['user']['preferences']['calendar']['weekdaystarts']] = ' selected'; $t_weekday[$GLOBALS['phpgw_info']['user']['preferences']['calendar']['weekdaystarts']] = ' selected';
$str = '<select name="weekdaystarts">' $str = '<select name="weekdaystarts">'
. '<option value="Monday"'.$t_weekday['Monday'].'>'.lang('Monday').'</option>' . '<option value="Monday"'.$t_weekday['Monday'].'>'.lang('Monday').'</option>'
. '<option value="Sunday"'.$t_weekday['Sunday'].'>'.lang('Sunday').'</option>' . '<option value="Sunday"'.$t_weekday['Sunday'].'>'.lang('Sunday').'</option>'
@ -144,28 +144,28 @@
. '</select>'; . '</select>';
display_item(lang('weekday starts on'),$str); display_item(lang('weekday starts on'),$str);
$t_workdaystarts[$phpgw_info['user']['preferences']['calendar']['workdaystarts']] = ' selected'; $t_workdaystarts[$GLOBALS['phpgw_info']['user']['preferences']['calendar']['workdaystarts']] = ' selected';
$str = '<select name="workdaystarts">'; $str = '<select name="workdaystarts">';
for ($i=0; $i<24; $i++) for ($i=0; $i<24; $i++)
{ {
$str .= '<option value="'.$i.'"'.$t_workdaystarts[$i].'>' $str .= '<option value="'.$i.'"'.$t_workdaystarts[$i].'>'
. $phpgw->common->formattime($i,'00') . '</option>'; . $GLOBALS['phpgw']->common->formattime($i,'00') . '</option>';
} }
$str .= '</select>'; $str .= '</select>';
display_item(lang('work day starts on'),$str); display_item(lang('work day starts on'),$str);
$t_workdayends[$phpgw_info['user']['preferences']['calendar']['workdayends']] = ' selected'; $t_workdayends[$GLOBALS['phpgw_info']['user']['preferences']['calendar']['workdayends']] = ' selected';
$str = '<select name="workdayends">'; $str = '<select name="workdayends">';
for ($i=0; $i<24; $i++) for ($i=0; $i<24; $i++)
{ {
$str .= '<option value="'.$i.'"'.$t_workdayends[$i].'>' $str .= '<option value="'.$i.'"'.$t_workdayends[$i].'>'
. $phpgw->common->formattime($i,'00') . '</option>'; . $GLOBALS['phpgw']->common->formattime($i,'00') . '</option>';
} }
$str .= '</select>'; $str .= '</select>';
display_item(lang('work day ends on'),$str); display_item(lang('work day ends on'),$str);
$selected[$phpgw_info['user']['preferences']['calendar']['defaultcalendar']] = ' selected'; $selected[$GLOBALS['phpgw_info']['user']['preferences']['calendar']['defaultcalendar']] = ' selected';
if (!isset($phpgw_info['user']['preferences']['calendar']['defaultcalendar'])) if (!isset($GLOBALS['phpgw_info']['user']['preferences']['calendar']['defaultcalendar']))
{ {
$selected['month.php'] = ' selected'; $selected['month.php'] = ' selected';
} }
@ -179,8 +179,8 @@
$selected = array(); $selected = array();
$selected[$phpgw_info['user']['preferences']['calendar']['defaultfilter']] = ' selected'; $selected[$GLOBALS['phpgw_info']['user']['preferences']['calendar']['defaultfilter']] = ' selected';
if (! isset($phpgw_info['user']['preferences']['calendar']['defaultfilter']) || $phpgw_info['user']['preferences']['calendar']['defaultfilter'] == 'private') if (! isset($GLOBALS['phpgw_info']['user']['preferences']['calendar']['defaultfilter']) || $GLOBALS['phpgw_info']['user']['preferences']['calendar']['defaultfilter'] == 'private')
{ {
$selected['private'] = ' selected'; $selected['private'] = ' selected';
} }
@ -196,8 +196,8 @@
display_item(lang('Default calendar filter'),$str); display_item(lang('Default calendar filter'),$str);
$selected = array(); $selected = array();
$selected[intval($phpgw_info['user']['preferences']['calendar']['interval'])] = ' selected'; $selected[intval($GLOBALS['phpgw_info']['user']['preferences']['calendar']['interval'])] = ' selected';
if (! isset($phpgw_info['user']['preferences']['calendar']['interval'])) if (! isset($GLOBALS['phpgw_info']['user']['preferences']['calendar']['interval']))
{ {
$selected[60] = ' selected'; $selected[60] = ' selected';
} }
@ -219,21 +219,21 @@
$str .= '</select>'; $str .= '</select>';
display_item(lang('Display interval in Day View'),$str); display_item(lang('Display interval in Day View'),$str);
$str = '<input type="checkbox" name="send_updates" value="True"'.($phpgw_info['user']['preferences']['calendar']['send_updates'] == 'Y' || $phpgw_info['user']['preferences']['calendar']['send_updates'] == True?' checked':'').'>'; $str = '<input type="checkbox" name="send_updates" value="True"'.($GLOBALS['phpgw_info']['user']['preferences']['calendar']['send_updates'] == 'Y' || $GLOBALS['phpgw_info']['user']['preferences']['calendar']['send_updates'] == True?' checked':'').'>';
display_item(lang('Send/receive updates via email'),$str); display_item(lang('Send/receive updates via email'),$str);
$str = '<input type="checkbox" name="display_status" value="True"'.($phpgw_info['user']['preferences']['calendar']['display_status'] == 'Y' || $phpgw_info['user']['preferences']['calendar']['display_status'] == True?' checked':'').'>'; $str = '<input type="checkbox" name="display_status" value="True"'.($GLOBALS['phpgw_info']['user']['preferences']['calendar']['display_status'] == 'Y' || $GLOBALS['phpgw_info']['user']['preferences']['calendar']['display_status'] == True?' checked':'').'>';
display_item(lang('Display status of events'),$str); display_item(lang('Display status of events'),$str);
$str = '<input type="checkbox" name="default_private" value="True"'.($phpgw_info['user']['preferences']['calendar']['default_private'] == 'Y' || $phpgw_info['user']['preferences']['calendar']['default_private'] == True?' checked':'').'>'; $str = '<input type="checkbox" name="default_private" value="True"'.($GLOBALS['phpgw_info']['user']['preferences']['calendar']['default_private'] == 'Y' || $GLOBALS['phpgw_info']['user']['preferences']['calendar']['default_private'] == True?' checked':'').'>';
display_item(lang('When creating new events default set to private'),$str); display_item(lang('When creating new events default set to private'),$str);
$str = '<input type="checkbox" name="display_minicals" value="True"'.($phpgw_info['user']['preferences']['calendar']['display_minicals'] == 'Y' || $phpgw_info['user']['preferences']['calendar']['display_minicals'] == True?' checked':'').'>'; $str = '<input type="checkbox" name="display_minicals" value="True"'.($GLOBALS['phpgw_info']['user']['preferences']['calendar']['display_minicals'] == 'Y' || $GLOBALS['phpgw_info']['user']['preferences']['calendar']['display_minicals'] == True?' checked':'').'>';
display_item(lang('Display mini calendars when printing'),$str); display_item(lang('Display mini calendars when printing'),$str);
$str = '<input type="checkbox" name="print_black_white" value="True"'.($phpgw_info['user']['preferences']['calendar']['print_black_white'] == 'Y' || $phpgw_info['user']['preferences']['calendar']['print_black_white'] == True?' checked':'').'>'; $str = '<input type="checkbox" name="print_black_white" value="True"'.($GLOBALS['phpgw_info']['user']['preferences']['calendar']['print_black_white'] == 'Y' || $GLOBALS['phpgw_info']['user']['preferences']['calendar']['print_black_white'] == True?' checked':'').'>';
display_item(lang('Print calendars in black & white'),$str); display_item(lang('Print calendars in black & white'),$str);
$p->pparse('out','pref'); $p->pparse('out','pref');
$phpgw->common->phpgw_footer(); $GLOBALS['phpgw']->common->phpgw_footer();
?> ?>