From f370c71909e4a79f680213712afcb25e495f571e Mon Sep 17 00:00:00 2001 From: skeeter Date: Sun, 11 Mar 2001 04:20:24 +0000 Subject: [PATCH] first app to support app specific email --- calendar/inc/hook_calendar_email.inc.php | 303 +++++++++++++++++++++++ 1 file changed, 303 insertions(+) create mode 100755 calendar/inc/hook_calendar_email.inc.php diff --git a/calendar/inc/hook_calendar_email.inc.php b/calendar/inc/hook_calendar_email.inc.php new file mode 100755 index 0000000000..e9bc01471c --- /dev/null +++ b/calendar/inc/hook_calendar_email.inc.php @@ -0,0 +1,303 @@ + * + * http://www.radix.net/~cknudsen * + * Written by Mark Peters * + * -------------------------------------------- * + * This program is free software; you can redistribute it and/or modify it * + * under the terms of the GNU General Public License as published by the * + * Free Software Foundation; either version 2 of the License, or (at your * + * option) any later version. * + \**************************************************************************/ + + /* $Id$ */ + + global $msgtype, $owner, $rights; + + $d1 = strtolower(substr($phpgw_info['server']['app_inc'],0,3)); + if($d1 == 'htt' || $d1 == 'ftp') + { + echo 'Failed attempt to break in via an old Security Hole!
'."\n"; + $phpgw->common->phpgw_exit(); + } + unset($d1); + + $tmp_app_inc = $phpgw_info['server']['app_inc']; + $phpgw_info['server']['app_inc'] = $phpgw->common->get_inc_dir('calendar'); + + include($phpgw_info['server']['app_inc'].'/functions.inc.php'); + + $str = ''; + + $msg_type = explode(';',$msgtype); + $id_array = explode('=',$msg_type[2]); + $id = intval(substr($id_array[1],1,strlen($id_array[1])-2)); + + echo 'Event ID: '.$id."
\n"; + + $cal_stream = $phpgw->calendar->open('INBOX',$owner,''); + $event = $phpgw->calendar->fetch_event($cal_stream,$id); + + reset($event->participants); + + $tz_offset = ((60 * 60) * intval($phpgw_info['user']['preferences']['common']['tz_offset'])); + $freetime = $phpgw->calendar->localdates(mktime(0,0,0,$event->start->month,$event->start->mday,$event->start->year) - $tz_offset); + echo $phpgw->calendar->timematrix($freetime,$phpgw->calendar->splittime('000000',False),0,$event->participants); + + echo ''; + + function add_day(&$repeat_days,$day) + { + if($repeat_days) + { + $repeat_days .= ', '; + } + $repeat_days .= $day; + } + + function display_item($p,$field,$data) + { +// global $p; + + $p->set_var('field',$field); + $p->set_var('data',$data); + $p->parse('output','list',True); + } + + $pri = Array( + 1 => lang('Low'), + 2 => lang('Normal'), + 3 => lang('High') + ); + + $db = $phpgw->db; + + reset($event->participants); + $participating = False; + for($j=0;$jparticipants);$j++) + { + if($event->participants[$j] == $owner) + { + $participating = True; + } + } + + $p = CreateObject('phpgwapi.Template',$phpgw->calendar->template_dir); + + $templates = Array( + 'view_begin' => 'view.tpl', + 'list' => 'list.tpl', + 'view_end' => 'view.tpl', + 'form_button' => 'form_button_script.tpl' + ); + $p->set_file($templates); + + $var = Array( + 'bg_text' => $phpgw_info['theme']['bg_text'], + 'name' => $event->name + ); + $p->set_var($var); + $p->parse('out','view_begin'); + + // Some browser add a \n when its entered in the database. Not a big deal + // this will be printed even though its not needed. + if (nl2br($event->description)) + { + $var = Array( + 'field' => lang('Description'), + 'data' => nl2br($event->description) + ); + $p->set_var($var); + $p->parse('output','list',True); + } + + $tz_offset = ((60 * 60) * intval($phpgw_info['user']['preferences']['common']['tz_offset'])); + + $start = mktime($event->start->hour,$event->start->min,$event->start->sec,$event->start->month,$event->start->mday,$event->start->year) - $tz_offset; + $var = Array( + 'field' => lang('Start Date/Time'), + 'data' => $phpgw->common->show_date($start) + ); + $p->set_var($var); + $p->parse('output','list',True); + + $end = mktime($event->end->hour,$event->end->min,$event->end->sec,$event->end->month,$event->end->mday,$event->end->year) - $tz_offset; + $var = Array( + 'field' => lang('End Date/Time'), + 'data' => $phpgw->common->show_date($end) + ); + $p->set_var($var); + $p->parse('output','list',True); + + $var = Array( + 'field' => lang('Priority'), + 'data' => $pri[$event->priority] + ); + $p->set_var($var); + $p->parse('output','list',True); + + $participate = False; + for($i=0;$iparticipants);$i++) + { + if($event->participants[$i] == $phpgw_info['user']['account_id']) + { + $participate = True; + } + } + $var = Array( + 'field' => lang('Created By'), + 'data' => $phpgw->common->grab_owner_name($event->owner) + ); + $p->set_var($var); + $p->parse('output','list',True); + + $var = Array( + 'field' => lang('Updated'), + 'data' => $phpgw->common->show_date($event->mdatetime) + ); + $p->set_var($var); + $p->parse('output','list',True); + + if($event->groups[0]) + { + $cal_grps = ''; + for($i=0;$igroups);$i++) + { + if($i>0) + { + $cal_grps .= '
'; + } + $cal_grps .= $phpgw->accounts->id2name($event->groups[$i]); + } + + $var = Array( + 'field' => lang('Groups'), + 'data' => $cal_grps + ); + $p->set_var($var); + $p->parse('output','list',True); + } + + $str = ''; + for($i=0;$iparticipants);$i++) + { + if($i) + { + $str .= '
'; + } + switch ($event->status[$i]) + { + case 'A': + $status = 'Accepted'; + break; + case 'R': + $status = 'Rejected'; + break; + case 'P': + $status = 'Pending'; + break; + case 'U': + $status = 'No Response'; + break; + } + $str .= $phpgw->common->grab_owner_name($event->participants[$i]).' ('.$status.')'; + } + $var = Array( + 'field' => lang('Participants'), + 'data' => $str + ); + $p->set_var($var); + $p->parse('output','list',True); + +// Repeated Events + $str = $event->rpt_type; + if($event->recur_type <> RECUR_NONE || ($event->recur_enddate->mday != 0 && $event->recur_enddate->month != 0 && $event->recur_enddate->year != 0)) + { + $str .= ' ('; + $recur_end = mktime(0,0,0,$event->recur_enddate->month,$event->recur_enddate->mday,$event->recur_enddate->year); + if($recur_end != 0) + { + $str .= lang('ends').': '.$phpgw->common->show_date($recur_end,'l, F d, Y').' '; + } + if($event->recur_type == RECUR_WEEKLY || $event->recur_type == RECUR_DAILY) + { + $repeat_days = ''; + if ($event->recur_data & M_SUNDAY) + { + add_day($repeat_days,lang('Sunday ')); + } + if ($event->recur_data & M_MONDAY) + { + add_day($repeat_days,lang('Monday ')); + } + if ($event->recur_data & M_TUESDAY) + { + add_day($repeat_days,lang('Tuesay ')); + } + if ($event->recur_data & M_WEDNESDAY) + { + add_day($repeat_days,lang('Wednesday ')); + } + if ($event->recur_data & M_THURSDAY) + { + add_day($repeat_days,lang('Thursday ')); + } + if ($event->recur_data & M_FRIDAY) + { + add_day($repeat_days,lang('Friday ')); + } + if ($event->recur_data & M_SATURDAY) + { + add_day($repeat_days,lang('Saturday ')); + } + $str .= lang('days repeated').': '.$repeat_days; + } + if($event->recur_interval) + { + $str .= lang('frequency').' '.$event->recur_interval; + } + $str .= ')'; + + $var = Array( + 'field' => lang('Repitition'), + 'data' => $str + ); + $p->set_var($var); + $p->parse('output','list',True); + } + + echo $p->finish($p->parse('out','view_end')); + + echo ''; + + $templates = Array( + 'form_button' => 'form_button_script.tpl' + ); + $p->set_file($templates); + + $p->set_var('action_url_button',$phpgw->link('/calendar/action.php','id='.$id.'&owner='.$owner.'&action=accept')); + $p->set_var('action_text_button',' '.lang('Accept').' '); + $p->set_var('action_confirm_button',''); + echo ''."\n"; + + $p->set_var('action_url_button',$phpgw->link('/calendar/action.php','id='.$id.'&owner='.$owner.'&action=reject')); + $p->set_var('action_text_button',' '.lang('Reject').' '); + $p->set_var('action_confirm_button',''); + echo ''."\n"; + + $p->set_var('action_url_button',$phpgw->link('/calendar/action.php','id='.$id.'&owner='.$owner.'&action=tentative')); + $p->set_var('action_text_button',' '.lang('Tentative').' '); + $p->set_var('action_confirm_button',''); + echo ''."\n"; + + $p->set_var('action_url_button',$phpgw->link('/calendar/action.php','id='.$id.'&owner='.$owner.'&action=noresponse')); + $p->set_var('action_text_button',' '.lang('No Response').' '); + $p->set_var('action_confirm_button',''); + echo ''."\n"; + + echo '
'.$p->finish($p->parse('out','form_button')).''.$p->finish($p->parse('out','form_button')).''.$p->finish($p->parse('out','form_button')).''.$p->finish($p->parse('out','form_button')).'
'; + + $phpgw_info['server']['app_inc'] = $tmp_app_inc; +?>