From 584c8dd637680da14cd422ee1fa98a05e5b9b3c3 Mon Sep 17 00:00:00 2001 From: skeeter Date: Thu, 15 Feb 2001 04:12:31 +0000 Subject: [PATCH] change of the initialization of the calendar --- calendar/inc/class.calendar.inc.php | 27 +++++++++++++++++++++++-- calendar/inc/class.calendar_sql.inc.php | 10 +++++---- calendar/inc/functions.inc.php | 14 ++++++++++--- 3 files changed, 42 insertions(+), 9 deletions(-) diff --git a/calendar/inc/class.calendar.inc.php b/calendar/inc/class.calendar.inc.php index 8574f0359f..31e06c74ae 100755 --- a/calendar/inc/class.calendar.inc.php +++ b/calendar/inc/class.calendar.inc.php @@ -19,9 +19,32 @@ class calendar extends calendar_ { - function calendar($p_friendly=False) + function calendar($params=False) { - $this->printer_friendly = $p_friendly; + global $phpgw_info; + + if(gettype($params)=="array") + { + while(list($key,$value) = each($params)) + { + $this->$key = $value; + } + } + else + { + $this->printer_friendly = $params; + } + + if(!$this->owner) + { + $this->owner = $phpgw_info['user']['account_id']; + } + + if(!isset($this->rights)) + { + $this->rights = PHPGW_ACL_READ + PHPGW_ACL_ADD + PHPGW_ACL_EDIT + PHPGW_ACL_DELETE + 16; + } + $this->today = $this->localdates(time()); } } diff --git a/calendar/inc/class.calendar_sql.inc.php b/calendar/inc/class.calendar_sql.inc.php index f278a43723..7c3ee82011 100755 --- a/calendar/inc/class.calendar_sql.inc.php +++ b/calendar/inc/class.calendar_sql.inc.php @@ -18,9 +18,13 @@ { var $stream; var $user; + + var $printer_friendly = False; + var $owner; + var $rights; + var $cal_event; var $today = Array('raw','day','month','year','full','dow','dm','bd'); - var $printer_friendly = False; var $repeated_events; var $checked_events; var $re = 0; @@ -133,9 +137,7 @@ function check_perms($needed) { - global $rights; - - if($rights & $needed) + if($this->rights & $needed) { return True; } diff --git a/calendar/inc/functions.inc.php b/calendar/inc/functions.inc.php index c50b06bc2c..898634d1f7 100755 --- a/calendar/inc/functions.inc.php +++ b/calendar/inc/functions.inc.php @@ -19,6 +19,8 @@ $filter = $phpgw_info["user"]["preferences"]["calendar"]["defaultfilter"]; } + // This is the initialization of the ACL usage + $grants = $phpgw->acl->get_grants('calendar'); if(!isset($owner)) @@ -36,16 +38,22 @@ if($grants[$owner]) { $rights = $grants[$owner]; - if (!($rights & PHPGW_ACL_READ)) + if ($rights == 0) { $owner = $phpgw_info['user']['account_id']; + $rights = PHPGW_ACL_READ + PHPGW_ACL_ADD + PHPGW_ACL_EDIT + PHPGW_ACL_DELETE + 16; } } } /* Load calendar class */ - $printer_friendly = ((isset($friendly) && ($friendly==1))?True:False); - $phpgw->calendar = CreateObject('calendar.calendar',$printer_friendly); + $parameters = Array( + 'printer_friendly' => ((isset($friendly) && ($friendly==1))?True:False), + 'owner' => $owner, + 'rights' => $rights + ); + + $phpgw->calendar = CreateObject('calendar.calendar',$parameters); if(!isset($phpgw_info['user']['preferences']['calendar']['weekdaystarts'])) $phpgw_info['user']['preferences']['calendar']['weekdaystarts'] = 'Sunday';