diff --git a/calendar/action.php b/calendar/action.php new file mode 100755 index 0000000000..510f618519 --- /dev/null +++ b/calendar/action.php @@ -0,0 +1,36 @@ + * + * http://www.radix.net/~cknudsen * + * Modified 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$ */ + $phpgw_flags = Array( + 'currentapp' => 'calendar', + 'noheader' => True, + 'nonavbar' => True + ); + $phpgw_info['flags'] = $phpgw_flags; + include('../header.inc.php'); + + if($phpgw->calendar->check_perms(PHPGW_ACL_EDIT) != True) + { + echo '
You do not have permission to edit this appointment!
'; + $phpgw->common->footer(); + $phpgw->common->phpgw_exit(); + } + + $phpgw->calendar->open('INBOX',$owner,''); + + $phpgw->calendar->set_status(intval($id),$owner,intval($action)); + + Header('Location: '.$HTTP_REFERER); +?> diff --git a/calendar/edit_status.php b/calendar/edit_status.php new file mode 100755 index 0000000000..4eab8dde20 --- /dev/null +++ b/calendar/edit_status.php @@ -0,0 +1,56 @@ + * + * http://www.radix.net/~cknudsen * + * Modified 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$ */ + $phpgw_info['flags']['currentapp'] = 'calendar'; + include('../header.inc.php'); + + $cal_stream = $phpgw->calendar->open('INBOX',$owner,''); + $event = $phpgw->calendar->fetch_event($cal_stream,$id); + + reset($event->participants); + $participating = False; + for($j=0;$jparticipants);$j++) + { + if($event->participants[$j] == $owner) + { + $participating = True; + } + } + + if($participating == False) + { + echo '
The user '.$phpgw->common->grab_owner($owner).' is not participating in this event!
'; + $phpgw->common->footer(); + $phpgw->common->phpgw_exit(); + } + + if($phpgw->calendar->check_perms(PHPGW_ACL_EDIT) == False) + { + echo '
You do not have permission to edit this appointment!
'; + $phpgw->common->footer(); + $phpgw->common->phpgw_exit(); + } + + 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 $phpgw->calendar->view_event($event); + + echo $phpgw->calendar->get_response(); + $phpgw->common->phpgw_footer(); +?> diff --git a/calendar/inc/class.calendar.inc.php b/calendar/inc/class.calendar.inc.php index 4ecb63b42b..4d579db76e 100755 --- a/calendar/inc/class.calendar.inc.php +++ b/calendar/inc/class.calendar.inc.php @@ -1333,6 +1333,271 @@ class calendar extends calendar_ return $p->finish($p->parse('out','day_cal')); } // end function + function view_add_day(&$repeat_days,$day) + { + if($repeat_days) + { + $repeat_days .= ', '; + } + $repeat_days .= $day; + } + + function view_event($event) + { + global $phpgw, $phpgw_info; + + $tz_offset = ((60 * 60) * intval($phpgw_info['user']['preferences']['common']['tz_offset'])); + + $pri = Array( + 1 => lang('Low'), + 2 => lang('Normal'), + 3 => lang('High') + ); + + 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); + } + + $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 'T': + $status = 'Tentative'; + break; + case 'U': + $status = 'No Response'; + break; + } + + $str .= $phpgw->common->grab_owner_name($event->participants[$i]).' ('; + + if($event->participants[$i] == $this->owner && $this->check_perms(PHPGW_ACL_EDIT) == True) + { + $str .= ''.$status.''; + } + else + { + $str .= $status; + } + $str .= ')'; + } + $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); + } + + return $p->finish($p->parse('out','view_end')); + } + + function get_response() + { + global $phpgw; + + $str = ''; + + $p = CreateObject('phpgwapi.Template',$this->template_dir); + + $templates = Array( + 'form_button' => 'form_button_script.tpl' + ); + $p->set_file($templates); + + $p->set_var('action_url_button',$phpgw->link('/calendar/action.php','id='.$this->event->id.'&action='.ACCEPTED)); + $p->set_var('action_text_button',' '.lang('Accept').' '); + $p->set_var('action_confirm_button',''); + $str .= ''."\n"; + + $p->set_var('action_url_button',$phpgw->link('/calendar/action.php','id='.$this->event->id.'&action='.REJECTED)); + $p->set_var('action_text_button',' '.lang('Reject').' '); + $p->set_var('action_confirm_button',''); + $str .= ''."\n"; + + $p->set_var('action_url_button',$phpgw->link('/calendar/action.php','id='.$this->event->id.'&action='.TENTATIVE)); + $p->set_var('action_text_button',' '.lang('Tentative').' '); + $p->set_var('action_confirm_button',''); + $str .= ''."\n"; + + $p->set_var('action_url_button',$phpgw->link('/calendar/action.php','id='.$this->event->id.'&action='.NO_RESPONSE)); + $p->set_var('action_text_button',' '.lang('No Response').' '); + $p->set_var('action_confirm_button',''); + $str .= ''."\n"; + + $str .= '
'.$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')).'
'; + + return $str; + } + function timematrix($date,$starttime,$endtime,$participants) { global $phpgw, $phpgw_info; diff --git a/calendar/inc/class.calendar__.inc.php b/calendar/inc/class.calendar__.inc.php index 3dfa5da7a6..f23a4339a7 100755 --- a/calendar/inc/class.calendar__.inc.php +++ b/calendar/inc/class.calendar__.inc.php @@ -42,6 +42,11 @@ define('MSG_DELETED',0); define('MSG_MODIFIED',1); define('MSG_ADDED',2); +define('REJECTED',0); +define('NO_RESPONSE',1); +define('TENTATIVE',2); +define('ACCEPTED',3); + class calendar__ { var $event; diff --git a/calendar/inc/class.calendar_icap.inc.php b/calendar/inc/class.calendar_icap.inc.php index 5622a431ca..f1e95c3f4a 100755 --- a/calendar/inc/class.calendar_icap.inc.php +++ b/calendar/inc/class.calendar_icap.inc.php @@ -450,5 +450,15 @@ class calendar_ extends calendar__ return True; } - + function set_status($id,$owner,$status) + { + $status_code_short = Array( + REJECTED => 'R', + NO_RESPONSE => 'U', + TENTATIVE => 'T', + ACCEPTED => 'A' + ); +// $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; + } } diff --git a/calendar/inc/class.calendar_sql.inc.php b/calendar/inc/class.calendar_sql.inc.php index 32164a5fc7..e2525b37cc 100755 --- a/calendar/inc/class.calendar_sql.inc.php +++ b/calendar/inc/class.calendar_sql.inc.php @@ -910,6 +910,18 @@ class calendar_ extends calendar__ $this->event->participants = $participants; return True; } + + function set_status($id,$owner,$status) + { + $status_code_short = Array( + REJECTED => 'R', + NO_RESPONSE => 'U', + TENTATIVE => 'T', + ACCEPTED => 'A' + ); + $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; + } // End of ICal style support....... diff --git a/calendar/inc/hook_calendar_email.inc.php b/calendar/inc/hook_calendar_email.inc.php index e9bc01471c..6563e3d3ac 100755 --- a/calendar/inc/hook_calendar_email.inc.php +++ b/calendar/inc/hook_calendar_email.inc.php @@ -48,256 +48,11 @@ echo ''; - function add_day(&$repeat_days,$day) - { - if($repeat_days) - { - $repeat_days .= ', '; - } - $repeat_days .= $day; - } + echo $phpgw->calendar->view_event($event); - function display_item($p,$field,$data) - { -// global $p; + echo ''; - $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); + echo $phpgw->calendar->get_response(); - $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; ?>