forked from extern/egroupware
Optimizations to the calendar. Also cleaned up a little of the planner code.
This commit is contained in:
parent
c9ea092eae
commit
61f8227dcc
@ -73,6 +73,7 @@
|
||||
);
|
||||
|
||||
var $debug = False;
|
||||
// var $debug = True;
|
||||
|
||||
var $so;
|
||||
var $cached_events;
|
||||
@ -105,8 +106,6 @@
|
||||
|
||||
function bocalendar($session=0)
|
||||
{
|
||||
global $GLOBALS;
|
||||
|
||||
$GLOBALS['phpgw']->nextmatchs = CreateObject('phpgwapi.nextmatchs');
|
||||
|
||||
$this->grants = $GLOBALS['phpgw']->acl->get_grants('calendar');
|
||||
@ -214,17 +213,13 @@
|
||||
{
|
||||
if ($this->use_session)
|
||||
{
|
||||
global $phpgw;
|
||||
|
||||
if($this->debug) { echo '<br>Save:'; _debug_array($data); }
|
||||
$phpgw->session->appsession('session_data','calendar',$data);
|
||||
$GLOBALS['phpgw']->session->appsession('session_data','calendar',$data);
|
||||
}
|
||||
}
|
||||
|
||||
function read_sessiondata()
|
||||
{
|
||||
global $GLOBALS;
|
||||
|
||||
$data = $GLOBALS['phpgw']->session->appsession('session_data','calendar');
|
||||
if($this->debug) { echo '<br>Read:'; _debug_array($data); }
|
||||
|
||||
@ -265,8 +260,6 @@
|
||||
|
||||
function delete_calendar($owner)
|
||||
{
|
||||
global $GLOBALS;
|
||||
|
||||
if($GLOBALS['phpgw_info']['user']['apps']['admin'])
|
||||
{
|
||||
$this->so->delete_calendar($owner);
|
||||
@ -275,8 +268,6 @@
|
||||
|
||||
function change_owner($account_id,$new_owner)
|
||||
{
|
||||
global $GLOBALS;
|
||||
|
||||
if($GLOBALS['phpgw_info']['server']['calendar_type'] == 'sql')
|
||||
{
|
||||
$this->so->change_owner($account_id,$new_owner);
|
||||
@ -287,7 +278,7 @@
|
||||
{
|
||||
if($this->check_perms(PHPGW_ACL_DELETE))
|
||||
{
|
||||
reset($this->so->cal->delete_events);
|
||||
reset($this->so->cal->deleted_events);
|
||||
for($i=0;$i<count($this->so->cal->deleted_events);$i++)
|
||||
{
|
||||
$event_id = $this->so->cal->deleted_events[$i];
|
||||
@ -305,7 +296,7 @@
|
||||
|
||||
function update($p_cal=0,$p_participants=0,$p_start=0,$p_end=0,$p_recur_enddata=0)
|
||||
{
|
||||
global $GLOBALS, $HTTP_POST_VARS, $HTTP_GET_VARS;
|
||||
global $HTTP_POST_VARS, $HTTP_GET_VARS;
|
||||
|
||||
$l_cal = ($p_cal?$p_cal:$HTTP_POST_VARS['cal']);
|
||||
$l_participants = ($p_participants?$p_participants:$HTTP_POST_VARS['participants']);
|
||||
@ -599,8 +590,6 @@
|
||||
|
||||
function overlap($starttime,$endtime,$participants,$owner=0,$id=0)
|
||||
{
|
||||
global $GLOBALS;
|
||||
|
||||
$retval = Array();
|
||||
$ok = False;
|
||||
|
||||
@ -692,8 +681,6 @@
|
||||
|
||||
function get_fullname($accountid)
|
||||
{
|
||||
global $GLOBALS;
|
||||
|
||||
$account_id = get_account_id($accountid);
|
||||
if($GLOBALS['phpgw']->accounts->exists($account_id) == False)
|
||||
{
|
||||
@ -753,8 +740,6 @@
|
||||
|
||||
function is_private($event,$owner)
|
||||
{
|
||||
global $GLOBALS;
|
||||
|
||||
if($owner == 0)
|
||||
{
|
||||
$owner = $this->owner;
|
||||
@ -1093,6 +1078,11 @@
|
||||
if(!$emonth)
|
||||
{
|
||||
$emonth = $smonth + 1;
|
||||
if($emonth > 12)
|
||||
{
|
||||
$emonth = 1;
|
||||
$eyear++;
|
||||
}
|
||||
}
|
||||
if(!$eday)
|
||||
{
|
||||
@ -1143,20 +1133,20 @@
|
||||
for($j=$startdate,$k=0;$j<=$enddate;$k++,$j=intval(date('Ymd',mktime(0,0,0,$start['month'],$start['mday'] + $k,$start['year']))))
|
||||
{
|
||||
$c_evt_day = count($this->cached_events[$j]) - 1;
|
||||
// if($c_evt_day < 0)
|
||||
// {
|
||||
// $c_evt_day = 0;
|
||||
// }
|
||||
if($this->debug)
|
||||
if($c_evt_day < 0)
|
||||
{
|
||||
echo "Date: ".$j." Count : ".$c_evt_day."<br>\n";
|
||||
$c_evt_day = 0;
|
||||
}
|
||||
// if($this->debug)
|
||||
// {
|
||||
// echo "Date: ".$j." Count : ".$c_evt_day."<br>\n";
|
||||
// }
|
||||
if($this->cached_events[$j][$c_evt_day]['id'] != $event['id'])
|
||||
{
|
||||
if($this->debug)
|
||||
{
|
||||
echo "Adding Event for Date: ".$j."<br>\n";
|
||||
}
|
||||
// if($this->debug)
|
||||
// {
|
||||
// echo "Adding Event for Date: ".$j."<br>\n";
|
||||
// }
|
||||
$this->cached_events[$j][] = $event;
|
||||
}
|
||||
}
|
||||
@ -1177,6 +1167,7 @@
|
||||
$this->check_repeating_events($date);
|
||||
}
|
||||
}
|
||||
$retval = Array();
|
||||
for($j=date('Ymd',mktime(0,0,0,$smonth,$sday,$syear)),$k=0;$j<=date('Ymd',mktime(0,0,0,$emonth,$eday,$eyear));$k++,$j=date('Ymd',mktime(0,0,0,$smonth,$sday + $k,$syear)))
|
||||
{
|
||||
$retval[$j] = $this->cached_events[$j];
|
||||
@ -1188,15 +1179,12 @@
|
||||
/* Begin Appsession Data */
|
||||
function store_to_appsession($event)
|
||||
{
|
||||
global $GLOBALS;
|
||||
$GLOBALS['phpgw']->session->appsession('entry','calendar',$event);
|
||||
}
|
||||
|
||||
function restore_from_appsession()
|
||||
{
|
||||
global $GLOBALS;
|
||||
$this->event_init();
|
||||
// $event = unserialize(str_replace('O:8:"stdClass"','O:13:"calendar_time"',serialize($GLOBALS['phpgw']->session->appsession('entry','calendar'))));
|
||||
$event = $GLOBALS['phpgw']->session->appsession('entry','calendar');
|
||||
$this->so->cal->event = $event;
|
||||
return $event;
|
||||
@ -1287,8 +1275,6 @@
|
||||
|
||||
function set_week_array($startdate,$cellcolor,$weekly)
|
||||
{
|
||||
global $GLOBALS, $phpgw, $phpgw_info;
|
||||
|
||||
for ($j=0,$datetime=$startdate - $this->datetime->tz_offset;$j<7;$j++,$datetime += 86400)
|
||||
{
|
||||
$date = date('Ymd',$datetime);
|
||||
@ -1385,7 +1371,6 @@
|
||||
|
||||
function prepare_matrix($interval,$increment,$part,$status,$fulldate)
|
||||
{
|
||||
global $GLOBALS;
|
||||
for($h=0;$h<24;$h++)
|
||||
{
|
||||
for($m=0;$m<$interval;$m++)
|
||||
@ -1483,9 +1468,6 @@
|
||||
|
||||
function send_update($msg_type,$participants,$old_event=False,$new_event=False)
|
||||
{
|
||||
|
||||
global $GLOBALS;
|
||||
|
||||
$db = $GLOBALS['phpgw']->db;
|
||||
$db->query("SELECT app_version FROM phpgw_applications WHERE app_name='calendar'",__LINE__,__FILE__);
|
||||
$db->next_record();
|
||||
@ -1710,42 +1692,64 @@
|
||||
|
||||
function remove_doubles_in_cache($firstday,$lastday)
|
||||
{
|
||||
for($v=$firstday;$v<=$lastday;$v += 1)
|
||||
$already_moved = Array();
|
||||
for($v=$firstday;$v<=$lastday;$v++)
|
||||
{
|
||||
$daily = $this->cached_events[$v];
|
||||
|
||||
if($this->debug)
|
||||
{
|
||||
echo "<p>count(day $v)=".count($daily)."</p>\n";
|
||||
}
|
||||
if (!is_array($daily))
|
||||
if (!$this->cached_events[$v])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@reset($daily);
|
||||
while (list($g,$event) = each($daily))
|
||||
while (list($g,$event) = each($this->cached_events[$v]))
|
||||
{
|
||||
$start = sprintf('%04d%02d%02d',$event['start']['year'],$event['start']['month'],$event['start']['mday']);
|
||||
if($this->debug)
|
||||
{
|
||||
echo "<p>Event:<br>"; print_r($event); echo "</p>";
|
||||
}
|
||||
$start = sprintf('%04d%02d%02d',$event['start']['year'],$event['start']['month'],$event['start']['mday']);
|
||||
|
||||
if($this->debug)
|
||||
{
|
||||
echo "<p>start='$start', v='$v'";
|
||||
echo "<p>start='$start', v='$v' ";
|
||||
}
|
||||
|
||||
// if ($start != $v && $event['recur_type'] == MCAL_RECUR_NONE) // this is an enddate-entry --> remove it
|
||||
if ($start != $v) // this is an enddate-entry --> remove it
|
||||
{
|
||||
unset($this->cached_events[$v][$g]);
|
||||
if($g != count($this->cached_events[$v]))
|
||||
{
|
||||
for($h=$g + 1;$h<$c_daily;$h++)
|
||||
{
|
||||
$this->cached_events[$v][$h - 1] = $this->cached_events[$v][$h];
|
||||
}
|
||||
unset($this->cached_events[$v][$h]);
|
||||
}
|
||||
|
||||
// if ($start < $firstday && $event['recur_type'] == MCAL_RECUR_NONE) // start before period --> move it to the beginning
|
||||
if ($start < $firstday) // start before period --> move it to the beginning
|
||||
{
|
||||
$this->cached_events[$firstday][] = $event;
|
||||
if($this->debug)
|
||||
if($already_moved[$event['id']] > 0)
|
||||
{
|
||||
echo "moved</p>\n";
|
||||
continue;
|
||||
}
|
||||
$add_event = True;
|
||||
$c_events = count($this->cached_events[$firstday]);
|
||||
for($i=0;$i<$c_events;$i++)
|
||||
{
|
||||
$add_event = ($this->cached_events[$firstday][$i]['id'] == $event['id']?False:$add_event);
|
||||
}
|
||||
if($add_event)
|
||||
{
|
||||
$this->cached_events[$firstday][] = $event;
|
||||
$already_moved[$event['id']] = 1;
|
||||
if($this->debug)
|
||||
{
|
||||
echo "moved</p>\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$already_moved[$event['id']] = 2;
|
||||
if($this->debug)
|
||||
{
|
||||
echo "removed (not moved)</p>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif($this->debug)
|
||||
@ -1758,6 +1762,7 @@
|
||||
echo "ok</p>\n";
|
||||
}
|
||||
}
|
||||
flush();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,21 +46,19 @@
|
||||
|
||||
function boholiday()
|
||||
{
|
||||
global $phpgw_info, $locale, $start, $query, $sort, $order, $id;
|
||||
|
||||
$this->so = CreateObject('calendar.soholiday');
|
||||
|
||||
if(isset($locale)) { $this->locales[] = $locale; }
|
||||
if(isset($GLOBALS['locale'])) { $this->locales[] = $GLOBALS['locale']; }
|
||||
|
||||
if(isset($start)) { $this->start = $start; } else { $this->start = 0; }
|
||||
if(isset($GLOBALS['start'])) { $this->start = $GLOBALS['start']; } else { $this->start = 0; }
|
||||
|
||||
if(isset($query)) { $this->query = $query; }
|
||||
if(isset($GLOBALS['query'])) { $this->query = $GLOBALS['query']; }
|
||||
|
||||
if(isset($sort)) { $this->sort = $sort; }
|
||||
if(isset($GLOBALS['sort'])) { $this->sort = $GLOBALS['sort']; }
|
||||
|
||||
if(isset($order)) { $this->order = $order; }
|
||||
if(isset($GLOBALS['order'])) { $this->order = $GLOBALS['order']; }
|
||||
|
||||
if(isset($id)) { $this->id = $id; }
|
||||
if(isset($GLOBALS['id'])) { $this->id = $GLOBALS['id']; }
|
||||
|
||||
if($this->debug)
|
||||
{
|
||||
@ -73,7 +71,6 @@
|
||||
/* Begin Calendar functions */
|
||||
function read_entry($id=0)
|
||||
{
|
||||
|
||||
if($this->debug)
|
||||
{
|
||||
echo "BO : Reading Holiday ID : ".$id."<br>\n";
|
||||
@ -136,8 +133,7 @@
|
||||
|
||||
function accept_holiday()
|
||||
{
|
||||
global $HTTP_REFERER;
|
||||
global $name, $day, $month, $occurence, $dow, $observance;
|
||||
global $HTTP_POST_VARS, $HTTP_REFERER;
|
||||
|
||||
$send_back_to = str_replace('submitlocale','holiday_admin',$HTTP_REFERER);
|
||||
if(!@$this->locales[0])
|
||||
@ -147,13 +143,13 @@
|
||||
|
||||
$send_back_to = str_replace('&locale='.$this->locales[0],'',$send_back_to);
|
||||
$file = './holidays.'.$this->locales[0];
|
||||
if(!file_exists($file) && count($name))
|
||||
if(!file_exists($file) && count($HTTP_POST_VARS['name']))
|
||||
{
|
||||
$c_holidays = count($name);
|
||||
$c_holidays = count($HTTP_POST_VARS['name']);
|
||||
$fp = fopen($file,'w');
|
||||
for($i=0;$i<$c_holidays;$i++)
|
||||
{
|
||||
fwrite($fp,$this->locales[0]."\t".$name[$i]."\t".$day[$i]."\t".$month[$i]."\t".$occurence[$i]."\t".$dow[$i]."\t".$observance[$i]."\n");
|
||||
fwrite($fp,$this->locales[0]."\t".$HTTP_POST_VARS['name'][$i]."\t".$HTTP_POST_VARS['day'][$i]."\t".$HTTP_POST_VARS['month'][$i]."\t".$HTTP_POST_VARS['occurence'][$i]."\t".$HTTP_POST_VARS['dow'][$i]."\t".$HTTP_POST_VARS['observance'][$i]."\n");
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
@ -162,85 +158,40 @@
|
||||
|
||||
function get_holiday_list($locale='', $sort='', $order='', $query='', $total='')
|
||||
{
|
||||
if(!$locale)
|
||||
{
|
||||
$locale = $this->locales[0];
|
||||
}
|
||||
|
||||
if(!$sort)
|
||||
{
|
||||
$sort = $this->sort;
|
||||
}
|
||||
|
||||
if(!$order)
|
||||
{
|
||||
$order = $this->order;
|
||||
}
|
||||
|
||||
if(!$query)
|
||||
{
|
||||
$query = $this->query;
|
||||
}
|
||||
|
||||
$locale = ($locale?$locale:$this->locales[0]);
|
||||
$sort = ($sort?$sort:$this->sort);
|
||||
$order = ($order?$order:$this->order);
|
||||
$query = ($query?$query:$this->query);
|
||||
return $this->so->read_holidays($locale,$query,$order);
|
||||
}
|
||||
|
||||
function get_locale_list($sort='', $order='', $query='')
|
||||
{
|
||||
if(!$sort)
|
||||
{
|
||||
$sort = $this->sort;
|
||||
}
|
||||
|
||||
if(!$order)
|
||||
{
|
||||
$order = $this->order;
|
||||
}
|
||||
|
||||
if(!$query)
|
||||
{
|
||||
$query = $this->query;
|
||||
}
|
||||
|
||||
$sort = ($sort?$sort:$this->sort);
|
||||
$order = ($order?$order:$this->order);
|
||||
$query = ($query?$query:$$this->query);
|
||||
return $this->so->get_locale_list($sort,$order,$query);
|
||||
}
|
||||
|
||||
function prepare_read_holidays($year=0,$owner=0)
|
||||
{
|
||||
global $phpgw_info;
|
||||
|
||||
if($year==0)
|
||||
{
|
||||
$this->year = date('Y');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->year = $year;
|
||||
}
|
||||
$this->year = ($year?$year:$GLOBALS['phpgw']->common->show_date(time(),'Y'));
|
||||
$this->owner = ($owner?$owner:$GLOBALS['phpgw_info']['user']['account_id']);
|
||||
|
||||
if($owner == 0)
|
||||
if(@$GLOBALS['phpgw_info']['user']['preferences']['common']['country'])
|
||||
{
|
||||
$this->owner = $phpgw_info['user']['account_id'];
|
||||
$this->locales[] = $GLOBALS['phpgw_info']['user']['preferences']['common']['country'];
|
||||
}
|
||||
else
|
||||
elseif(@$GLOBALS['phpgw_info']['user']['preferences']['calendar']['locale'])
|
||||
{
|
||||
$this->owner = $owner;
|
||||
}
|
||||
|
||||
if(@$phpgw_info['user']['preferences']['common']['country'])
|
||||
{
|
||||
$this->locales[] = $phpgw_info['user']['preferences']['common']['country'];
|
||||
}
|
||||
elseif(@$phpgw_info['user']['preferences']['calendar']['locale'])
|
||||
{
|
||||
$this->locales[] = $phpgw_info['user']['preferences']['calendar']['locale'];
|
||||
$this->locales[] = $GLOBALS['phpgw_info']['user']['preferences']['calendar']['locale'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->locales[] = 'US';
|
||||
}
|
||||
|
||||
if($this->owner != $phpgw_info['user']['account_id'])
|
||||
if($this->owner != $GLOBALS['phpgw_info']['user']['account_id'])
|
||||
{
|
||||
$owner_pref = CreateObject('phpgwapi.preferences',$owner);
|
||||
$owner_prefs = $owner_pref->read_repository();
|
||||
@ -256,7 +207,7 @@
|
||||
}
|
||||
|
||||
@reset($this->locales);
|
||||
if($phpgw_info['server']['auto_load_holidays'] == True)
|
||||
if($GLOBALS['phpgw_info']['server']['auto_load_holidays'] == True)
|
||||
{
|
||||
while(list($key,$value) = each($this->locales))
|
||||
{
|
||||
@ -269,20 +220,20 @@
|
||||
{
|
||||
if($this->so->holiday_total($locale) == 0)
|
||||
{
|
||||
global $phpgw_info, $HTTP_HOST, $SERVER_PORT;
|
||||
global $HTTP_HOST, $SERVER_PORT;
|
||||
|
||||
@set_time_limit(0);
|
||||
|
||||
/* get the file that contains the calendar events for your locale */
|
||||
/* "http://www.phpgroupware.org/cal/holidays.US"; */
|
||||
$network = CreateObject('phpgwapi.network');
|
||||
if(isset($phpgw_info['server']['holidays_url_path']) && $phpgw_info['server']['holidays_url_path'] != 'localhost')
|
||||
if(isset($GLOBALS['phpgw_info']['server']['holidays_url_path']) && $GLOBALS['phpgw_info']['server']['holidays_url_path'] != 'localhost')
|
||||
{
|
||||
$load_from = $phpgw_info['server']['holidays_url_path'];
|
||||
$load_from = $GLOBALS['phpgw_info']['server']['holidays_url_path'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$pos = strpos(' '.$phpgw_info['server']['webserver_url'],$HTTP_HOST);
|
||||
$pos = strpos(' '.$GLOBALS['phpgw_info']['server']['webserver_url'],$HTTP_HOST);
|
||||
if($pos == 0)
|
||||
{
|
||||
switch($SERVER_PORT)
|
||||
@ -294,11 +245,11 @@
|
||||
$http_protocol = 'https://';
|
||||
break;
|
||||
}
|
||||
$server_host = $http_protocol.$HTTP_HOST.$phpgw_info['server']['webserver_url'];
|
||||
$server_host = $http_protocol.$HTTP_HOST.$GLOBALS['phpgw_info']['server']['webserver_url'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$server_host = $phpgw_info['server']['webserver_url'];
|
||||
$server_host = $GLOBALS['phpgw_info']['server']['webserver_url'];
|
||||
}
|
||||
$load_from = $server_host.'/calendar/setup';
|
||||
}
|
||||
@ -336,25 +287,25 @@
|
||||
|
||||
function add()
|
||||
{
|
||||
global $phpgw, $submit, $holiday, $locale;
|
||||
global $HTTP_POST_VARS;
|
||||
|
||||
if(@$submit)
|
||||
if(@$HTTP_POST_VARS['submit'])
|
||||
{
|
||||
if(empty($holiday['mday']))
|
||||
if(empty($HTTP_POST_VARS['holiday']['mday']))
|
||||
{
|
||||
$holiday['mday'] = 0;
|
||||
$HTTP_POST_VARS['holiday']['mday'] = 0;
|
||||
}
|
||||
if(!isset($this->bo->locales[0]) || $this->bo->locales[0]=='')
|
||||
{
|
||||
$this->bo->locales[0] = $holiday['locale'];
|
||||
$this->bo->locales[0] = $HTTP_POST_VARS['holiday']['locale'];
|
||||
}
|
||||
elseif(!isset($holiday['locale']) || $holiday['locale']=='')
|
||||
elseif(!isset($HTTP_POST_VARS['holiday']['locale']) || $HTTP_POST_VARS['holiday']['locale']=='')
|
||||
{
|
||||
$holiday['locale'] = $this->bo->locales[0];
|
||||
$HTTP_POST_VARS['holiday']['locale'] = $this->bo->locales[0];
|
||||
}
|
||||
if(!isset($holiday['hol_id']))
|
||||
if(!isset($HTTP_POST_VARS['holiday']['hol_id']))
|
||||
{
|
||||
$holiday['hol_id'] = $this->bo->id;
|
||||
$HTTP_POST_VARS['holiday']['hol_id'] = $this->bo->id;
|
||||
}
|
||||
|
||||
// Still need to put some validation in here.....
|
||||
@ -362,11 +313,11 @@
|
||||
$this->ui = CreateObject('calendar.uiholiday');
|
||||
if (is_array($errors))
|
||||
{
|
||||
$this->ui->add($errors,$holiday);
|
||||
$this->ui->add($errors,$HTTP_POST_VARS['holiday']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->so->save_holiday($holiday);
|
||||
$this->so->save_holiday($HTTP_POST_VARS['holiday']);
|
||||
$this->ui->edit_locale();
|
||||
}
|
||||
}
|
||||
@ -415,14 +366,12 @@
|
||||
return $holidays;
|
||||
}
|
||||
|
||||
global $phpgw_info;
|
||||
|
||||
$temp_locale = $phpgw_info['user']['preferences']['common']['country'];
|
||||
$temp_locale = $GLOBALS['phpgw_info']['user']['preferences']['common']['country'];
|
||||
$datetime = CreateObject('phpgwapi.datetime');
|
||||
for($i=0;$i<count($holidays);$i++)
|
||||
{
|
||||
$c = $i;
|
||||
$phpgw_info['user']['preferences']['common']['country'] = $holidays[$i]['locale'];
|
||||
$GLOBALS['phpgw_info']['user']['preferences']['common']['country'] = $holidays[$i]['locale'];
|
||||
$holidaycalc = CreateObject('calendar.holidaycalc');
|
||||
$holidays[$i]['date'] = $holidaycalc->calculate_date($holidays[$i], $holidays, $this->year, $datetime, $c);
|
||||
unset($holidaycalc);
|
||||
@ -434,24 +383,16 @@
|
||||
unset($datetime);
|
||||
$this->holidays = $this->sort_holidays_by_date($holidays);
|
||||
$this->cached_holidays = $this->set_holidays_to_date($this->holidays);
|
||||
$phpgw_info['user']['preferences']['common']['country'] = $temp_locale;
|
||||
$GLOBALS['phpgw_info']['user']['preferences']['common']['country'] = $temp_locale;
|
||||
return $this->cached_holidays;
|
||||
}
|
||||
/* End Calendar functions */
|
||||
|
||||
function check_admin()
|
||||
{
|
||||
global $phpgw, $phpgw_info;
|
||||
|
||||
$admin = False;
|
||||
if(@$phpgw_info['user']['apps']['admin'])
|
||||
if(!@$GLOBALS['phpgw_info']['user']['apps']['admin'])
|
||||
{
|
||||
$admin = True;
|
||||
}
|
||||
|
||||
if(!$admin)
|
||||
{
|
||||
Header('Location: ' . $phpgw->link('/index.php'));
|
||||
Header('Location: ' . $GLOBALS['phpgw']->link('/index.php'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,30 +26,12 @@
|
||||
|
||||
function socalendar($param)
|
||||
{
|
||||
global $phpgw, $phpgw_info;
|
||||
|
||||
$this->db = $phpgw->db;
|
||||
$this->db = $GLOBALS['phpgw']->db;
|
||||
$this->datetime = CreateObject('phpgwapi.datetime');
|
||||
|
||||
if(!isset($param['owner']) || $param['owner'] == 0)
|
||||
{
|
||||
$this->owner = $phpgw_info['user']['account_id'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->owner = $param['owner'];
|
||||
}
|
||||
|
||||
if(isset($param['filter']) && $param['filter'] != '')
|
||||
{
|
||||
$this->filter = $param['filter'];
|
||||
}
|
||||
|
||||
if(isset($param['category']) && $param['category'] != '')
|
||||
{
|
||||
$this->cat_id = $param['category'];
|
||||
}
|
||||
|
||||
$this->owner = (!isset($param['owner']) || $param['owner'] == 0?$GLOBALS['phpgw_info']['user']['account_id']:$param['owner']);
|
||||
$this->filter = (isset($param['filter']) && $param['filter'] != ''?$param['filter']:$this->filter);
|
||||
$this->cat_id = (isset($param['category']) && $param['category'] != ''?$param['category']:$this->cat_id);
|
||||
if($this->debug)
|
||||
{
|
||||
echo 'SO Filter : '.$this->filter."<br>\n";
|
||||
@ -76,25 +58,15 @@
|
||||
function list_events($startYear,$startMonth,$startDay,$endYear=0,$endMonth=0,$endDay=0)
|
||||
{
|
||||
$this->makeobj();
|
||||
|
||||
$extra = '';
|
||||
if(strpos($this->filter,'private'))
|
||||
{
|
||||
$extra .= 'AND phpgw_cal.is_public=0 ';
|
||||
}
|
||||
|
||||
if($this->cat_id)
|
||||
{
|
||||
$extra .= 'AND phpgw_cal.category = '.$this->cat_id.' ';
|
||||
}
|
||||
$extra .= (strpos($this->filter,'private')?'AND phpgw_cal.is_public=0 ':'');
|
||||
$extra .= ($this->cat_id?'AND phpgw_cal.category = '.$this->cat_id.' ':'');
|
||||
return $this->cal->list_events($startYear,$startMonth,$startDay,$endYear,$endMonth,$endDay,$extra,$this->datetime->tz_offset);
|
||||
}
|
||||
|
||||
function list_repeated_events($syear,$smonth,$sday,$eyear,$emonth,$eday)
|
||||
{
|
||||
global $phpgw, $phpgw_info;
|
||||
|
||||
if($phpgw_info['server']['calendar_type'] != 'sql')
|
||||
if($GLOBALS['phpgw_info']['server']['calendar_type'] != 'sql')
|
||||
{
|
||||
return Array();
|
||||
}
|
||||
@ -109,15 +81,9 @@
|
||||
// . 'AND (phpgw_cal.datetime <= '.$starttime.') '
|
||||
. 'AND (((phpgw_cal_repeats.recur_enddate >= '.$starttime.') AND (phpgw_cal_repeats.recur_enddate <= '.$endtime.')) OR (phpgw_cal_repeats.recur_enddate=0))) ';
|
||||
|
||||
if(strpos($this->filter,'private'))
|
||||
{
|
||||
$sql .= 'AND phpgw_cal.is_public=0 ';
|
||||
}
|
||||
$sql .= (strpos($this->filter,'private')?'AND phpgw_cal.is_public=0 ':'');
|
||||
|
||||
if($this->cat_id)
|
||||
{
|
||||
$sql .= 'AND phpgw_cal.category = '.$this->cat_id.' ';
|
||||
}
|
||||
$sql .= ($this->cat_id?'AND phpgw_cal.category = '.$this->cat_id.' ':'');
|
||||
|
||||
$sql .= 'ORDER BY phpgw_cal.datetime ASC, phpgw_cal.edatetime ASC, phpgw_cal.priority ASC';
|
||||
|
||||
@ -138,33 +104,15 @@
|
||||
$words = split(' ',$keywords);
|
||||
for ($i=0;$i<count($words);$i++)
|
||||
{
|
||||
if($i==0)
|
||||
{
|
||||
$sql .= ' AND (';
|
||||
}
|
||||
if($i>0)
|
||||
{
|
||||
$sql .= ' OR ';
|
||||
}
|
||||
$sql .= ($i==0?' AND (':'');
|
||||
$sql .= ($i>0?' OR ':'');
|
||||
$sql .= "(UPPER(phpgw_cal.title) LIKE UPPER('%".$words[$i]."%') OR "
|
||||
. "UPPER(phpgw_cal.description) LIKE UPPER('%".$words[$i]."%'))";
|
||||
|
||||
if($i==count($words) - 1)
|
||||
{
|
||||
$sql .= ') ';
|
||||
}
|
||||
}
|
||||
|
||||
if(strpos($this->filter,'private'))
|
||||
{
|
||||
$sql .= 'AND phpgw_cal.is_public=0 ';
|
||||
}
|
||||
|
||||
if($this->cat_id)
|
||||
{
|
||||
$sql .= 'AND phpgw_cal.category = '.$this->cat_id.' ';
|
||||
$sql .= ($i==count($words) - 1?') ':'');
|
||||
}
|
||||
|
||||
$sql .= (strpos($this->filter,'private')?'AND phpgw_cal.is_public=0 ':'');
|
||||
$sql .= ($this->cat_id?'AND phpgw_cal.category = '.$this->cat_id.' ':'');
|
||||
$sql .= 'ORDER BY phpgw_cal.datetime ASC, phpgw_cal.edatetime ASC, phpgw_cal.priority ASC';
|
||||
return $this->get_event_ids(False,$sql);
|
||||
}
|
||||
@ -212,8 +160,7 @@
|
||||
|
||||
function change_owner($account_id,$new_owner)
|
||||
{
|
||||
global $phpgw_info;
|
||||
if($phpgw_info['server']['calendar_type'] == 'sql')
|
||||
if($GLOBALS['phpgw_info']['server']['calendar_type'] == 'sql')
|
||||
{
|
||||
$this->so->cal->query('UPDATE phpgw_cal SET owner='.$new_owner.' WHERE owner='.$account_id,__LINE__,__FILE__);
|
||||
$this->so->cal->query('UPDATE phpgw_cal_user SET cal_login='.$new_owner.' WHERE cal_login='.$account_id);
|
||||
|
@ -14,16 +14,16 @@
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
if(@$phpgw_info['server']['calendar_type'] == 'mcal' &&
|
||||
if(@$GLOBALS['phpgw_info']['server']['calendar_type'] == 'mcal' &&
|
||||
extension_loaded('mcal') == False)
|
||||
{
|
||||
$phpgw_info['server']['calendar_type'] = 'sql';
|
||||
$GLOBALS['phpgw_info']['server']['calendar_type'] = 'sql';
|
||||
}
|
||||
// This will be elminated when ical is fully implemented
|
||||
else
|
||||
{
|
||||
$phpgw_info['server']['calendar_type'] = 'sql';
|
||||
$GLOBALS['phpgw_info']['server']['calendar_type'] = 'sql';
|
||||
}
|
||||
include(PHPGW_INCLUDE_ROOT.'/calendar/inc/class.socalendar__.inc.php');
|
||||
include(PHPGW_INCLUDE_ROOT.'/calendar/inc/class.socalendar_'.$phpgw_info['server']['calendar_type'].'.inc.php');
|
||||
include(PHPGW_INCLUDE_ROOT.'/calendar/inc/class.socalendar_'.$GLOBALS['phpgw_info']['server']['calendar_type'].'.inc.php');
|
||||
?>
|
||||
|
@ -21,7 +21,7 @@ if (@$GLOBALS['phpgw_info']['flags']['included_classes']['socalendar__'])
|
||||
|
||||
$GLOBALS['phpgw_info']['flags']['included_classes']['socalendar__'] = True;
|
||||
|
||||
include(PHPGW_SERVER_ROOT.'/calendar/setup/setup.inc.php');
|
||||
/* include(PHPGW_SERVER_ROOT.'/calendar/setup/setup.inc.php'); */
|
||||
|
||||
if(extension_loaded('mcal') == False)
|
||||
{
|
||||
|
@ -30,8 +30,6 @@ class socalendar_ extends socalendar__
|
||||
|
||||
function open($calendar='',$user='',$passwd='',$options='')
|
||||
{
|
||||
global $GLOBALS;
|
||||
|
||||
if($user=='')
|
||||
{
|
||||
settype($user,'integer');
|
||||
@ -95,8 +93,6 @@ class socalendar_ extends socalendar__
|
||||
|
||||
function fetch_event($event_id,$options='')
|
||||
{
|
||||
global $GLOBALS;
|
||||
|
||||
if(!isset($this->stream))
|
||||
{
|
||||
return False;
|
||||
@ -193,10 +189,7 @@ class socalendar_ extends socalendar__
|
||||
{
|
||||
$this->add_attribute('users_status',$this->stream->f('cal_status'));
|
||||
}
|
||||
// $this->event->participants[$this->stream->f('cal_login')] = $this->stream->f('cal_status');
|
||||
$this->add_attribute('participants',$this->stream->f('cal_status'),intval($this->stream->f('cal_login')));
|
||||
// $this->add_attribute('participants',array(intval($this->stream->f('cal_login'))=>$this->stream->f('cal_status')));
|
||||
// $this->add_attribute('participants['.intval($this->stream->f('cal_login')).']',$this->stream->f('cal_status'));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -360,8 +353,6 @@ class socalendar_ extends socalendar__
|
||||
|
||||
function save_event(&$event)
|
||||
{
|
||||
global $GLOBALS;
|
||||
|
||||
$locks = Array(
|
||||
'phpgw_cal',
|
||||
'phpgw_cal_user',
|
||||
@ -478,8 +469,6 @@ class socalendar_ extends socalendar__
|
||||
|
||||
function group_search($owner=0)
|
||||
{
|
||||
global $GLOBALS;
|
||||
|
||||
$owner = ($owner==$GLOBALS['phpgw_info']['user']['account_id']?0:$owner);
|
||||
$groups = substr($GLOBALS['phpgw']->common->sql_search('phpgw_cal.groups',intval($owner)),4);
|
||||
if (!$groups)
|
||||
|
@ -56,8 +56,6 @@
|
||||
|
||||
function uicalendar()
|
||||
{
|
||||
global $GLOBALS;
|
||||
|
||||
$GLOBALS['phpgw']->browser = CreateObject('phpgwapi.browser');
|
||||
$this->theme = $GLOBALS['phpgw_info']['theme'];
|
||||
|
||||
@ -92,8 +90,6 @@
|
||||
|
||||
function mini_calendar($params)
|
||||
{
|
||||
global $GLOBALS;
|
||||
|
||||
if(!is_array($params))
|
||||
{
|
||||
return;
|
||||
@ -242,16 +238,12 @@
|
||||
|
||||
function index($params='')
|
||||
{
|
||||
global $GLOBALS;
|
||||
|
||||
Header('Location: '. $this->page('',$params));
|
||||
$GLOBALS['phpgw']->common->phpgw_exit();
|
||||
}
|
||||
|
||||
function month()
|
||||
{
|
||||
global $GLOBALS;
|
||||
|
||||
$this->bo->read_holidays();
|
||||
|
||||
$m = mktime(0,0,0,$this->bo->month,1,$this->bo->year);
|
||||
@ -323,9 +315,6 @@
|
||||
|
||||
function week()
|
||||
{
|
||||
|
||||
global $GLOBALS;
|
||||
|
||||
$this->bo->read_holidays();
|
||||
|
||||
$next = $this->bo->datetime->makegmttime(0,0,0,$this->bo->month,$this->bo->day + 7,$this->bo->year);
|
||||
@ -422,8 +411,6 @@
|
||||
|
||||
function year()
|
||||
{
|
||||
global $GLOBALS;
|
||||
|
||||
if(!$this->bo->printer_friendly)
|
||||
{
|
||||
unset($GLOBALS['phpgw_info']['flags']['noheader']);
|
||||
@ -490,7 +477,7 @@
|
||||
|
||||
function view($vcal_id=0)
|
||||
{
|
||||
global $GLOBALS, $HTTP_GET_VARS;
|
||||
global $HTTP_GET_VARS;
|
||||
|
||||
unset($GLOBALS['phpgw_info']['flags']['noheader']);
|
||||
unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
|
||||
@ -653,7 +640,7 @@
|
||||
|
||||
function delete()
|
||||
{
|
||||
global $GLOBALS, $HTTP_GET_VARS;
|
||||
global $HTTP_GET_VARS;
|
||||
|
||||
if(!isset($HTTP_GET_VARS['cal_id']))
|
||||
{
|
||||
@ -680,8 +667,6 @@
|
||||
|
||||
function day()
|
||||
{
|
||||
global $GLOBALS;
|
||||
|
||||
$this->bo->read_holidays();
|
||||
|
||||
if (!$this->bo->printer_firendly || ($this->bo->printer_friendly && @$this->bo->prefs['calendar']['display_minicals']))
|
||||
@ -749,7 +734,7 @@
|
||||
|
||||
function edit_status()
|
||||
{
|
||||
global $GLOBALS, $HTTP_GET_VARS;
|
||||
global $HTTP_GET_VARS;
|
||||
|
||||
unset($GLOBALS['phpgw_info']['flags']['noheader']);
|
||||
unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
|
||||
@ -805,8 +790,6 @@
|
||||
|
||||
function planner()
|
||||
{
|
||||
global $GLOBALS;
|
||||
|
||||
unset($GLOBALS['phpgw_info']['flags']['noheader']);
|
||||
unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
|
||||
$GLOBALS['phpgw']->common->phpgw_header();
|
||||
@ -852,18 +835,18 @@
|
||||
'syear' => $this->bo->year,
|
||||
'smonth' => $this->bo->month,
|
||||
'sday' => 1,
|
||||
'eyear' => 0,
|
||||
'emonth' => 0,
|
||||
'eday' => 1
|
||||
'eyear' => $this->bo->year,
|
||||
'emonth' => $this->bo->month,
|
||||
'eday' => $days
|
||||
)
|
||||
);
|
||||
$firstday = intval(date('Ymd',mktime(0,0,0,$this->bo->month,1,$this->bo->year)));
|
||||
$lastday = intval(date('Ymd',mktime(0,0,0,$this->bo->month + 1,0,$this->bo->year)));
|
||||
$lastday = intval(date('Ymd',mktime(0,0,0,$this->bo->month,$days,$this->bo->year)));
|
||||
|
||||
$this->bo->remove_doubles_in_cache($firstday,$lastday);
|
||||
|
||||
$rows = array();
|
||||
for($v=$firstday;$v<=$lastday;$v += 1)
|
||||
for($v=$firstday;$v<=$lastday;$v++)
|
||||
{
|
||||
$daily = $this->bo->cached_events[$v];
|
||||
@reset($daily);
|
||||
@ -987,8 +970,6 @@
|
||||
|
||||
function matrixselect()
|
||||
{
|
||||
global $GLOBALS;
|
||||
|
||||
$datetime = mktime(0,0,0,$this->bo->month,$this->bo->day,$this->bo->year) - $this->tz_offset;
|
||||
|
||||
$sb = CreateObject('phpgwapi.sbox');
|
||||
@ -1106,7 +1087,7 @@
|
||||
|
||||
function viewmatrix()
|
||||
{
|
||||
global $GLOBALS, $HTTP_POST_VARS;
|
||||
global $HTTP_POST_VARS;
|
||||
|
||||
$participants = $HTTP_POST_VARS['participants'];
|
||||
$parts = Array();
|
||||
@ -1190,7 +1171,7 @@
|
||||
|
||||
function search()
|
||||
{
|
||||
global $GLOBALS, $HTTP_POST_VARS;
|
||||
global $HTTP_POST_VARS;
|
||||
|
||||
if (!$HTTP_POST_VARS['keywords'])
|
||||
{
|
||||
@ -1328,8 +1309,6 @@
|
||||
|
||||
function page($page='',$params='')
|
||||
{
|
||||
global $GLOBALS;
|
||||
|
||||
if($page == '')
|
||||
{
|
||||
$page_ = explode('.',$this->bo->prefs['calendar']['defaultcalendar']);
|
||||
@ -1354,7 +1333,7 @@
|
||||
|
||||
function header()
|
||||
{
|
||||
global $GLOBALS, $HTTP_POST_VARS, $HTTP_GET_VARS;
|
||||
global $HTTP_POST_VARS, $HTTP_GET_VARS;
|
||||
|
||||
$cols = 8;
|
||||
if($this->bo->check_perms(PHPGW_ACL_PRIVATE) == True)
|
||||
@ -1373,8 +1352,6 @@
|
||||
|
||||
function footer()
|
||||
{
|
||||
global $GLOBALS;
|
||||
|
||||
list(,,$method) = explode('.',$GLOBALS['menuaction']);
|
||||
|
||||
if (@$this->bo->printer_friendly)
|
||||
@ -1475,8 +1452,6 @@
|
||||
|
||||
function no_edit()
|
||||
{
|
||||
global $GLOBALS;
|
||||
|
||||
if(!$isset($GLOBALS['phpgw_info']['flags']['noheader']))
|
||||
{
|
||||
unset($GLOBALS['phpgw_info']['flags']['noheader']);
|
||||
@ -1491,8 +1466,6 @@
|
||||
|
||||
function link_to_entry($event,$month,$day,$year)
|
||||
{
|
||||
global $GLOBALS;
|
||||
|
||||
$str = '';
|
||||
$is_private = $this->bo->is_private($event,$this->bo->owner);
|
||||
$editable = ((!$this->bo->printer_friendly) && (($is_private && $this->bo->check_perms(PHPGW_ACL_PRIVATE)) || !$is_private));
|
||||
@ -1632,8 +1605,6 @@
|
||||
|
||||
function overlap($overlapping_events,$event)
|
||||
{
|
||||
global $GLOBALS;
|
||||
|
||||
$month = $event['start']['month'];
|
||||
$mday = $event['start']['mday'];
|
||||
$year = $event['start']['year'];
|
||||
@ -1689,8 +1660,7 @@
|
||||
|
||||
function planner_participants($parts)
|
||||
{
|
||||
global $GLOBALS;
|
||||
static $id2lid = array();
|
||||
static $id2lid;
|
||||
|
||||
$names = '';
|
||||
while (list($id,$status) = each($parts))
|
||||
@ -1714,7 +1684,7 @@
|
||||
|
||||
function planner_category($id)
|
||||
{
|
||||
static $cats = array();
|
||||
static $cats;
|
||||
|
||||
if (!isset($cats[$id]))
|
||||
{
|
||||
@ -1727,8 +1697,6 @@
|
||||
|
||||
function week_header($month,$year,$display_name = False)
|
||||
{
|
||||
global $GLOBALS;
|
||||
|
||||
$this->weekstarttime = $this->bo->datetime->get_weekday_start($year,$month,1);
|
||||
|
||||
$p = CreateObject('phpgwapi.Template',$this->template_dir);
|
||||
@ -1772,8 +1740,6 @@
|
||||
|
||||
function display_week($startdate,$weekly,$cellcolor,$display_name = False,$owner=0,$monthstart=0,$monthend=0)
|
||||
{
|
||||
global $GLOBALS;
|
||||
|
||||
if($owner == 0) { $owner = $GLOBALS['phpgw_info']['user']['account_id']; }
|
||||
|
||||
$temp_owner = $this->bo->owner;
|
||||
@ -1892,8 +1858,6 @@
|
||||
|
||||
function display_month($month,$year,$showyear,$owner=0)
|
||||
{
|
||||
global $GLOBALS;
|
||||
|
||||
$this->bo->store_to_cache(
|
||||
Array(
|
||||
'syear' => $year,
|
||||
@ -1940,8 +1904,6 @@
|
||||
|
||||
function display_weekly($params)
|
||||
{
|
||||
global $GLOBALS;
|
||||
|
||||
if(!is_array($params))
|
||||
{
|
||||
$this->index();
|
||||
@ -2020,8 +1982,6 @@
|
||||
|
||||
function view_event($event)
|
||||
{
|
||||
global $GLOBALS;
|
||||
|
||||
if(!$event['participants'][$this->bo->owner])
|
||||
{
|
||||
return '<center>'.lang('You do not have permission to read this record!').'</center>';
|
||||
@ -2226,8 +2186,6 @@
|
||||
|
||||
function print_day($params)
|
||||
{
|
||||
global $GLOBALS;
|
||||
|
||||
if(!is_array($params))
|
||||
{
|
||||
$this->index();
|
||||
@ -2533,8 +2491,6 @@
|
||||
|
||||
function timematrix($param)
|
||||
{
|
||||
global $GLOBALS;
|
||||
|
||||
if(!is_array($param))
|
||||
{
|
||||
$this->index();
|
||||
@ -2666,8 +2622,6 @@
|
||||
|
||||
function get_response($cal_id)
|
||||
{
|
||||
global $GLOBALS;
|
||||
|
||||
$p = CreateObject('phpgwapi.Template',$this->template_dir);
|
||||
$p->set_file(
|
||||
Array(
|
||||
@ -2698,8 +2652,6 @@
|
||||
|
||||
function edit_form($param)
|
||||
{
|
||||
global $GLOBALS;
|
||||
|
||||
if(!is_array($param))
|
||||
{
|
||||
$this-index();
|
||||
@ -2952,7 +2904,6 @@
|
||||
|
||||
function build_part_list(&$users,$accounts,$owner)
|
||||
{
|
||||
global $GLOBALS;
|
||||
if($accounts == False)
|
||||
{
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user