new functionality - can set status

This commit is contained in:
skeeter 2001-03-12 03:18:02 +00:00
parent 3769cef710
commit 629790873c
7 changed files with 388 additions and 249 deletions

36
calendar/action.php Executable file
View File

@ -0,0 +1,36 @@
<?php
/**************************************************************************\
* phpGroupWare - Calendar *
* http://www.phpgroupware.org *
* Based on Webcalendar by Craig Knudsen <cknudsen@radix.net> *
* http://www.radix.net/~cknudsen *
* Modified by Mark Peters <skeeter@phpgroupware.org> *
* -------------------------------------------- *
* 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 '<center>You do not have permission to edit this appointment!</center>';
$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);
?>

56
calendar/edit_status.php Executable file
View File

@ -0,0 +1,56 @@
<?php
/**************************************************************************\
* phpGroupWare - Calendar *
* http://www.phpgroupware.org *
* Based on Webcalendar by Craig Knudsen <cknudsen@radix.net> *
* http://www.radix.net/~cknudsen *
* Modified by Mark Peters <skeeter@phpgroupware.org> *
* -------------------------------------------- *
* 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;$j<count($event->participants);$j++)
{
if($event->participants[$j] == $owner)
{
$participating = True;
}
}
if($participating == False)
{
echo '<center>The user '.$phpgw->common->grab_owner($owner).' is not participating in this event!</center>';
$phpgw->common->footer();
$phpgw->common->phpgw_exit();
}
if($phpgw->calendar->check_perms(PHPGW_ACL_EDIT) == False)
{
echo '<center>You do not have permission to edit this appointment!</center>';
$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();
?>

View File

@ -1333,6 +1333,271 @@ class calendar extends calendar_
return $p->finish($p->parse('out','day_cal')); return $p->finish($p->parse('out','day_cal'));
} // end function } // 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;$j<count($event->participants);$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;$i<count($event->participants);$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;$i<count($event->groups);$i++)
{
if($i>0)
{
$cal_grps .= '<br>';
}
$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;$i<count($event->participants);$i++)
{
if($i)
{
$str .= '<br>';
}
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 .= '<a href="'.$phpgw->link('/calendar/edit_status.php','owner='.$this->owner.'&id='.$event->id).'">'.$status.'</a>';
}
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 = '<table width="100%" cols="4"><tr align="center">';
$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 .= '<td>'.$p->finish($p->parse('out','form_button')).'</td>'."\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 .= '<td>'.$p->finish($p->parse('out','form_button')).'</td>'."\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 .= '<td>'.$p->finish($p->parse('out','form_button')).'</td>'."\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 .= '<td>'.$p->finish($p->parse('out','form_button')).'</td>'."\n";
$str .= '</tr></table>';
return $str;
}
function timematrix($date,$starttime,$endtime,$participants) function timematrix($date,$starttime,$endtime,$participants)
{ {
global $phpgw, $phpgw_info; global $phpgw, $phpgw_info;

View File

@ -42,6 +42,11 @@ define('MSG_DELETED',0);
define('MSG_MODIFIED',1); define('MSG_MODIFIED',1);
define('MSG_ADDED',2); define('MSG_ADDED',2);
define('REJECTED',0);
define('NO_RESPONSE',1);
define('TENTATIVE',2);
define('ACCEPTED',3);
class calendar__ class calendar__
{ {
var $event; var $event;

View File

@ -450,5 +450,15 @@ class calendar_ extends calendar__
return True; 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;
}
} }

View File

@ -911,6 +911,18 @@ class calendar_ extends calendar__
return True; 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....... // End of ICal style support.......
function group_search($owner=0) function group_search($owner=0)

View File

@ -48,256 +48,11 @@
echo '</td></tr><tr><td>'; echo '</td></tr><tr><td>';
function add_day(&$repeat_days,$day) echo $phpgw->calendar->view_event($event);
{
if($repeat_days)
{
$repeat_days .= ', ';
}
$repeat_days .= $day;
}
function display_item($p,$field,$data) echo '</td></tr><td align="center"><tr>';
{
// global $p;
$p->set_var('field',$field); echo $phpgw->calendar->get_response();
$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;$j<count($event->participants);$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;$i<count($event->participants);$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;$i<count($event->groups);$i++)
{
if($i>0)
{
$cal_grps .= '<br>';
}
$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;$i<count($event->participants);$i++)
{
if($i)
{
$str .= '<br>';
}
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 '</td></tr><td align="center"><tr><table width="100%" cols="4"><tr align="center">';
$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 '<td>'.$p->finish($p->parse('out','form_button')).'</td>'."\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 '<td>'.$p->finish($p->parse('out','form_button')).'</td>'."\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 '<td>'.$p->finish($p->parse('out','form_button')).'</td>'."\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 '<td>'.$p->finish($p->parse('out','form_button')).'</td>'."\n";
echo '</tr></table>';
$phpgw_info['server']['app_inc'] = $tmp_app_inc; $phpgw_info['server']['app_inc'] = $tmp_app_inc;
?> ?>