From 77dc66bb7797ebf109a8e1dbfcc1816f395a7700 Mon Sep 17 00:00:00 2001 From: skeeter Date: Wed, 1 Aug 2001 11:06:17 +0000 Subject: [PATCH] This brings the hook_email and the hook_deleteaccount in line with the n-tier. --- calendar/inc/class.bocalendar.inc.php | 19 +++++++++++++++ calendar/inc/class.socalendar.inc.php | 16 +++++++++++++ calendar/inc/hook_deleteaccount.inc.php | 7 +++--- calendar/inc/hook_email.inc.php | 32 ++++++++----------------- 4 files changed, 48 insertions(+), 26 deletions(-) diff --git a/calendar/inc/class.bocalendar.inc.php b/calendar/inc/class.bocalendar.inc.php index a20472e95e..03f1ffb873 100755 --- a/calendar/inc/class.bocalendar.inc.php +++ b/calendar/inc/class.bocalendar.inc.php @@ -19,6 +19,7 @@ var $public_functions = Array( 'read_entry' => True, 'delete_entry' => True, + 'delete_calendar' => True, 'update' => True, 'preferences' => True, 'store_to_cache' => True @@ -249,6 +250,24 @@ return $cd; } + function delete_calendar($owner) + { + global $phpgw_info; + if($phpgw_info['user']['apps']['admin']) + { + $this->so->delete_calendar($owner); + } + } + + function change_owner($account_id,$new_owner) + { + global $phpgw_info; + if($phpgw_info['server']['calendar_type'] == 'sql') + { + $this->so->change_owner($account_id,$new_owner); + } + } + function expunge() { if($this->check_perms(PHPGW_ACL_DELETE)) diff --git a/calendar/inc/class.socalendar.inc.php b/calendar/inc/class.socalendar.inc.php index 20bddc3906..49e35c2047 100755 --- a/calendar/inc/class.socalendar.inc.php +++ b/calendar/inc/class.socalendar.inc.php @@ -202,6 +202,22 @@ $this->cal->expunge(); } + function delete_calendar($owner) + { + $this->makeobj(); + $this->cal->delete_calendar($owner); + } + + function change_owner($account_id,$new_owner) + { + global $phpgw_info; + if($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); + } + } + function set_status($id,$status) { $this->makeobj(); diff --git a/calendar/inc/hook_deleteaccount.inc.php b/calendar/inc/hook_deleteaccount.inc.php index 7cceafec0c..73ee2728be 100755 --- a/calendar/inc/hook_deleteaccount.inc.php +++ b/calendar/inc/hook_deleteaccount.inc.php @@ -17,15 +17,14 @@ global $account_id, $new_owner; } - $calendar = CreateObject('calendar.calendar'); - $calendar->open('INBOX',$account_id,''); + $cal = CreateObject('calendar.bocalendar'); if(intval($new_owner)==0) { - $calendar->delete_calendar(intval($account_id)); + $cal->delete_calendar(intval($account_id)); } else { - $calendar->change_owner(intval($account_id),intval($new_owner)); + $cal->change_owner(intval($account_id),intval($new_owner)); } ?> diff --git a/calendar/inc/hook_email.inc.php b/calendar/inc/hook_email.inc.php index 7205d8596f..57bb54be78 100755 --- a/calendar/inc/hook_email.inc.php +++ b/calendar/inc/hook_email.inc.php @@ -14,7 +14,7 @@ /* $Id$ */ - global $owner, $rights, $calendar_id; + global $calendar_id; $d1 = strtolower(substr($phpgw_info['server']['app_inc'],0,3)); if($d1 == 'htt' || $d1 == 'ftp') @@ -24,38 +24,26 @@ } unset($d1); - $tmp_app_inc = $phpgw_info['server']['app_inc']; - $phpgw_info['server']['app_inc'] = $phpgw->common->get_inc_dir('calendar'); + $cal = CreateObject('calendar.uicalendar'); + echo 'Event ID: '.$calendar_id."
\n"; - include($phpgw_info['server']['app_inc'].'/functions.inc.php'); + $event = $cal->bo->read_entry($calendar_id); - $str = ''; - - $id = $calendar_id; - - echo 'Event ID: '.$id."
\n"; - - $cal_stream = $phpgw->calendar->open('INBOX',$owner,''); - $event = $phpgw->calendar->fetch_event($id); - - reset($event->participants); - while(list($particpants,$status) = each($event->participants)) + reset($event['participants']); + while(list($particpants,$status) = each($event['participants'])) { $parts[] = $participants; } @reset($parts); - $freetime = $phpgw->calendar->localdates(mktime(0,0,0,$event->start->month,$event->start->mday,$event->start->year) - $phpgw->calendar->tz_offset); - echo $phpgw->calendar->timematrix($freetime,$phpgw->calendar->splittime('000000',False),0,$parts); + $freetime = $cal->bo->datetime->localdates(mktime(0,0,0,$event['start']['month'],$event['start']['mday'],$event['start']['year']) - $phpgw->calendar->tz_offset); + echo $cal->timematrix($freetime,$cal->bo->splittime('000000',False),0,$parts); echo ''; - echo $phpgw->calendar->view_event($event); + echo $cal->view_event($event); echo ''; - $phpgw->calendar->fetch_event($id); - echo $phpgw->calendar->get_response(); - - $phpgw_info['server']['app_inc'] = $tmp_app_inc; + echo $cal->get_response($calendar_id); ?>