Tons of major fixes to the n-tier calendar. Still need to incorporate ralfbeckers enhancements to the planner.

This commit is contained in:
skeeter 2001-08-06 02:41:36 +00:00
parent 1edb9cfbaf
commit 1609677f71
5 changed files with 123 additions and 106 deletions

View File

@ -237,7 +237,7 @@
if($this->check_perms(PHPGW_ACL_DELETE))
{
$temp_event = $this->read_entry($id);
if($this->owner == $temp_event->owner)
if($this->owner == $temp_event['owner'])
{
$this->so->delete_entry($id);
$cd = 16;
@ -272,6 +272,7 @@
{
if($this->check_perms(PHPGW_ACL_DELETE))
{
reset($this->so->cal->delete_events);
for($i=0;$i<count($this->so->cal->deleted_events);$i++)
{
$event_id = $this->so->cal->deleted_events[$i];
@ -298,12 +299,15 @@
$recur_enddate = ($p_recur_enddate?$p_recur_enddate:$recur_enddate);
$send_to_ui = True;
if($p_cal && $p_participants && $p_start && $p_end && $p_recur_enddata)
if($p_cal || $p_participants || $p_start || $p_end || $p_recur_enddata)
{
$send_to_ui = False;
}
$overlapping_events = False;
if($this->debug)
{
echo "ID : ".$cal['id']."<br>\n";
}
$ui = CreateObject('calendar.uicalendar');
@ -313,12 +317,12 @@
$datetime_check = $this->validate_update($event);
if($datetime_check)
{
$ui->edit($datetime_check,True);
$ui->edit($datetime_check,1);
}
$overlapping_events = False;
}
else
{
if(!$cal['id'] && !$this->check_perms(PHPGW_ACL_ADD))
{
$ui->index();
@ -410,15 +414,20 @@
@reset($part);
while(list($key,$value) = each($part))
{
$this->so->add_attribute('participants','U',$key);
$this->so->add_attribute('participants','U',intval($key));
}
reset($participants);
// reset($participants);
$event = $this->get_cached_event();
if(!@$event['participants'][$cal['owner']])
{
$this->so->add_attribute('owner',$minparts);
}
else
{
$this->so->add_attribute('owner',$cal['owner']);
}
$this->so->add_attribute('priority',$cal['priority']);
$event = $this->get_cached_event();
@ -426,23 +435,27 @@
$datetime_check = $this->validate_update($event);
if($datetime_check)
{
$ui = CreateObject('calendar.uicalendar');
$ui->edit($datetime_check,True);
$ui->edit($datetime_check,1);
}
settype($start,'integer');
settype($end,'integer');
$start = $this->maketime($event['start']) - $this->datetime->tz_offset;
$end = $this->maketime($event['end']) - $this->datetime->tz_offset;
$overlapping_events = $this->overlap($start,$end,$event['participants'],$event->owner,$event->id);
$overlapping_events = $this->overlap(
$this->maketime($event['start']) - $this->datetime->tz_offset,
$this->maketime($event['end']) - $this->datetime->tz_offset,
$event['participants'],
$event['owner'],
$event['id']
);
}
if($overlapping_events)
{
if($send_to_ui)
{
unset($phpgw_info['flags']['noheader']);
unset($phpgw_info['flags']['nonavbar']);
$ui->overlap($overlapping_events,$event);
$phpgw_info['flags']['nofooter'] = True;
return;
}
else
{
@ -459,8 +472,9 @@
else
{
$new_event = $event;
$old_event = $this->read_entry($new_event['id']);
$old_event = $this->read_entry($event['id']);
$this->prepare_recipients($new_event,$old_event);
$this->so->cal->event = $event;
$this->so->add_entry($event);
}
$date = sprintf("%04d%02d%02d",$event['start']['year'],$event['start']['month'],$event['start']['mday']);
@ -561,9 +575,9 @@
{
$can_edit = False;
if(($event->owner == $this->owner) && ($this->check_perms(PHPGW_ACL_EDIT) == True))
if(($event['owner'] == $this->owner) && ($this->check_perms(PHPGW_ACL_EDIT) == True))
{
if($event->public != True)
if($event['public'] != True)
{
if($this->check_perms(PHPGW_ACL_PRIVATE) == True)
{
@ -608,7 +622,7 @@
{
$error = 0;
// do a little form verifying
if ($event->title == '')
if ($event['title'] == '')
{
$error = 40;
}
@ -1144,12 +1158,21 @@
for($i=0;$i<$c_cached_ids;$i++)
{
$event = $this->so->read_entry($cached_event_ids[$i]);
$starttime = $this->maketime($event['start']);
$endtime = $this->maketime($event['end']);
$this->cached_events[date('Ymd',$starttime)][] = $event;
if($this->cached_events[date('Ymd',$endtime)][count($this->cached_events[date('Ymd',$starttime)]) - 1] != $event)
{
$this->cached_events[date('Ymd',$endtime)][] = $event;
$startdate = intval(date('Ymd',$this->maketime($event['start'])));
$enddate= intval(date('Ymd',$this->maketime($event['end'])));
$this->cached_events[$startdate][] = $event;
// if($startdate != $enddate)
// {
$start['year'] = intval(substr($startdate,0,4));
$start['month'] = intval(substr($startdate,4,2));
$start['day'] = intval(substr($startdate,6,2));
for($j=$startdate,$k=0;$j<=$enddate;$k++,$j=intval(date('Ymd',mktime(0,0,0,$start['month'],$start['day'] + $k,$start['year']))))
{
if($this->cached_events[$j][count($this->cached_events[$j]) - 1] != $event)
{
$this->cached_events[$j][] = $event;
}
// }
}
}
}
@ -1181,7 +1204,8 @@
{
global $phpgw;
$this->event_init();
$event = unserialize(str_replace('O:8:"stdClass"','O:13:"calendar_time"',serialize($phpgw->session->appsession('entry','calendar'))));
// $event = unserialize(str_replace('O:8:"stdClass"','O:13:"calendar_time"',serialize($phpgw->session->appsession('entry','calendar'))));
$event = $phpgw->session->appsession('entry','calendar');
$this->so->cal->event = $event;
return $event;
}
@ -1500,8 +1524,6 @@
$phpgw_info['user']['preferences'] = $phpgw->common->create_emailpreferences($phpgw_info['user']['preferences'],$user);
$send = CreateObject('phpgwapi.send');
switch($msg_type)
{
case MSG_DELETED:
@ -1552,6 +1574,11 @@
{
// echo "Msg Type = ".$msg_type."<br>\n";
// echo "userid = ".$userid."<br>\n";
if(!is_object($send))
{
$send = CreateObject('phpgwapi.send');
}
$preferences = CreateObject('phpgwapi.preferences',intval($userid));
$part_prefs = $preferences->read_repository();
if(!isset($part_prefs['calendar']['send_updates']) || !$part_prefs['calendar']['send_updates'])

View File

@ -230,9 +230,9 @@
return $this->cal->event;
}
function add_attribute($var,$value)
function add_attribute($var,$value,$element='False')
{
$this->cal->add_attribute($var,$value);
$this->cal->add_attribute($var,$value,$element);
}
function event_init()

View File

@ -184,22 +184,11 @@ class socalendar__
}
if($element!='False')
{
if(is_int($element))
{
eval("\$this->event['".$attribute."'][".$element."] = ".$value.";");
}
else
{
eval("\$this->event['".$attribute."']['".$element."'] = ".$value.";");
}
$this->event[$attribute][$element] = $value;
}
elseif(is_int($value))
else
{
eval("\$this->event['".$attribute."'] = ".$value.";");
}
elseif(is_string($value))
{
eval("\$this->event['".$attribute."'] = '".$value."';");
$this->event[$attribute] = $value;
}
}
}

View File

@ -35,7 +35,7 @@ class socalendar_ extends socalendar__
if($user=='')
{
settype($user,'integer');
$user = $phpgw_info['user']['account_id'];
$this->user = $phpgw_info['user']['account_id'];
}
elseif(is_int($user))
{
@ -270,6 +270,7 @@ class socalendar_ extends socalendar__
function expunge()
{
reset($this->deleted_events);
if(count($this->deleted_events) <= 0)
{
return 1;

View File

@ -103,10 +103,11 @@
$p = CreateObject('phpgwapi.Template',$this->template_dir);
$p->set_unknowns('remove');
$templates = Array(
'mini_calendar' => 'mini_cal.tpl'
$p->set_file(
Array(
'mini_calendar' => 'mini_cal.tpl'
)
);
$p->set_file($templates);
$p->set_block('mini_calendar','mini_cal','mini_cal');
$p->set_block('mini_calendar','mini_week','mini_week');
$p->set_block('mini_calendar','mini_day','mini_day');
@ -161,8 +162,11 @@
for($i=0;$i<7;$i++)
{
$p->set_var('dayname','<b>' . substr(lang($this->bo->datetime->days[$i]),0,2) . '</b>');
$p->parse('daynames','mini_day',True);
$var = Array(
'dayname' => '<b>' . substr(lang($this->bo->datetime->days[$i]),0,2) . '</b>',
'day_image' => ''
);
$this->output_template_array($p,'daynames','mini_day',$var);
}
$today = date('Ymd',time());
unset($date);
@ -270,10 +274,11 @@
$p = CreateObject('phpgwapi.Template',$this->template_dir);
$p->set_unknowns('remove');
$templates = Array(
'index_t' => 'index.tpl'
$p->set_file(
Array(
'index_t' => 'index.tpl'
)
);
$p->set_file($templates);
$p->set_var($var);
$p->pparse('out','index_t');
}
@ -337,11 +342,11 @@
);
$p = CreateObject('phpgwapi.Template',$this->template_dir);
$templates = Array(
'week_t' => 'week.tpl'
$p->set_file(
Array(
'week_t' => 'week.tpl'
)
);
$p->set_file($templates);
$p->set_var($var);
$p->pparse('out','week_t');
}
@ -381,10 +386,11 @@
);
$p = CreateObject('phpgwapi.Template',$this->template_dir);
$templates = Array(
'year_t' => 'year.tpl'
$p->set_file(
Array(
'year_t' => 'year.tpl'
)
);
$p->set_file($templates);
$p->set_block('year_t','year','year');
$p->set_block('year_t','month','month');
$p->set_block('year_t','month_sep','month_sep');
@ -413,7 +419,7 @@
echo '<center>';
if(!@$cal_id && $vcal_id)
if(!isset($cal_id) && $vcal_id)
{
$cal_id = $vcal_id;
}
@ -445,10 +451,11 @@
if($this->bo->owner == $event['owner'])
{
$p = CreateObject('phpgwapi.Template',$this->template_dir);
$templates = Array(
'form_button' => 'form_button_script.tpl'
$p->set_file(
Array(
'form_button' => 'form_button_script.tpl'
)
);
$p->set_file($templates);
if ($this->bo->check_perms(PHPGW_ACL_EDIT))
{
@ -502,10 +509,10 @@
$this->view($cal_id);
}
}
$this->edit_form($event);
$this->edit_form($event,$cd);
}
function add($cd,$readsess)
function add($cd=0,$readsess=0)
{
global $phpgw, $phpgw_info, $cal_id, $hour, $minute;
@ -514,7 +521,7 @@
$this->index();
}
if(isset($readsess))
if($readsess)
{
$event = $this->bo->restore_from_appsession;
if(!$event['owner'])
@ -549,14 +556,15 @@
$this->bo->set_recur_none();
$event = $this->bo->get_cached_event();
}
$this->edit_form($event);
$this->edit_form($event,$cd);
}
function delete()
{
global $cal_id;
$event = $this->bo->read_entry(intval($cal_id));
if(($cal_id > 0) && ($event['owner'] == $this->bo->owner) && !$this->bo->check_perms(PHPGW_ACL_DELETE))
if(($cal_id > 0) && ($event['owner'] == $this->bo->owner) && $this->bo->check_perms(PHPGW_ACL_DELETE))
{
$date = sprintf("%04d%02d%02d",$event['start']['year'],$event['start']['month'],$event['start']['mday']);
@ -837,7 +845,7 @@
{
$dayname = substr(lang(date('D',mktime(0,0,0,$this->bo->month,$d,$this->bo->year))),0,2);
$header['.'.$d] = "colspan=$intervals_per_day align=center";
$header['.'.$d] = 'colspan="'.$intervals_per_day.'" align="center"';
$header[$d] = '<a href="'.$html->link('/index.php',
array(
'menuaction' => 'calendar.uicalendar.add',
@ -904,7 +912,7 @@
if ($i > 1) // further line - no name
{
$rows[$k] = array();
$rows[$c.'_1']['._name'] = "rowspan=$i";
$rows[$c.'_1']['._name'] = 'rowspan="'.$i.'"';
}
else
{
@ -919,7 +927,7 @@
if ($akt_cell < $start_cell)
{
$row[$event->id.'_1'] = '&nbsp;';
$row['.'.$event['id'].'_1'] = 'colspan='.($start_cell-$akt_cell);
$row['.'.$event['id'].'_1'] = 'colspan="'.($start_cell-$akt_cell).'"';
}
$opt = &$row['.'.$event['id'].'_2'];
@ -962,7 +970,7 @@
if ($akt_cell <= $last_cell)
{
$row['3'] = '&nbsp';
$row['.3'] = 'colspan='.(1+$last_cell-$akt_cell);
$row['.3'] = 'colspan="'.(1+$last_cell-$akt_cell).'"';
}
}
}
@ -973,7 +981,7 @@
'_h' => $header,
'._h' => $bgcolor
)+$rows,
'width="100%" cols='.(1+$days*$intervals_per_day)
'width="100%" cols="'.(1+$days*$intervals_per_day).'"'
);
}
@ -1368,11 +1376,11 @@
$p = CreateObject('phpgwapi.Template',$this->template_dir);
$templates = Array(
'footer' => 'footer.tpl'
$p->set_file(
Array(
'footer' => 'footer.tpl'
)
);
$p->set_file($templates);
$p->set_block('footer','footer_table','footer_table');
$p->set_block('footer','footer_row','footer_row');
@ -1618,11 +1626,11 @@
{
global $phpgw, $phpgw_info;
$month = $event->start->month;
$mday = $event->start->mday;
$year = $event->start->year;
$month = $event['start']['month'];
$mday = $event['start']['mday'];
$year = $event['start']['year'];
$start = mktime($event->start->hour,$event->start->min,$event->start->sec,$month,$mday,$year) - $this->bo->datetime->tz_offset;
$start = mktime($event['start']['hour'],$event['start']['min'],$event['start']['sec'],$month,$mday,$year) - $this->bo->datetime->tz_offset;
$end = $this->bo->maketime($event['end']) - $this->bo->datetime->tz_offset;
$overlap = '';
@ -1633,9 +1641,10 @@
unset($phpgw_info['flags']['noheader']);
unset($phpgw_info['flags']['nonavbar']);
$phpgw_info['flags']['nofooter'] = True;
$phpgw->common->phpgw_header();
$p = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('calendar'));
$p = CreateObject('phpgwapi.Template',$this->template_dir);
$p->set_file(
Array(
'overlap' => 'overlap.tpl',
@ -1666,7 +1675,7 @@
'action_confirm_button' => '',
'action_extra_field' => ''
);
$this->output_template_array($p,'resubmit_button','form_button',$var);
$this->output_template_array($p,'reedit_button','form_button',$var);
$p->pparse('out','overlap');
}
@ -1804,7 +1813,7 @@
{
if ($day_params['new_event'])
{
$new_event_link = '<a href="'.$this->page('add','&date'.$date).'">'
$new_event_link = '<a href="'.$this->page('add','&date='.$date).'">'
. '<img src="'.$phpgw->common->image('calendar','new.gif').'" width="10" height="10" alt="'.lang('New Entry').'" border="0" align="center">'
. '</a>';
$day_number = '<a href="'.$this->page('day','&month='.$month.'&day='.$day.'&year='.$year).'">'.$day.'</a>';
@ -2066,11 +2075,10 @@
$cal_grps = '';
for($i=0;$i<count($event['groups']);$i++)
{
if($i>0)
if($phpgw->accounts->exists($event['groups'][$i]))
{
$cal_grps .= '<br>';
$cal_grps .= ($i>0?'<br>':'').$phpgw->accounts->id2name($event['groups'][$i]);
}
$cal_grps .= $phpgw->accounts->id2name($event['groups'][$i]);
}
$var[] = Array(
@ -2085,14 +2093,7 @@
{
if($phpgw->accounts->exists($user))
{
if($str)
{
$str .= '<br>';
}
$long_status = $this->bo->get_long_status($short_status);
$str .= $phpgw->common->grab_owner_name($user).' ('.($this->bo->check_perms(PHPGW_ACL_EDIT,$user)?'<a href="'.$this->page('edit_status','&cal_id='.$event->id.'&owner='.$user).'">'.$long_status.'</a>':$long_status).')'."\n";
$str .= ($str?'<br>':'').$phpgw->common->grab_owner_name($user).' ('.($this->bo->check_perms(PHPGW_ACL_EDIT,$user)?'<a href="'.$this->page('edit_status','&cal_id='.$event['id'].'&owner='.$user).'">'.$this->bo->get_long_status($short_status).'</a>':$this->bo->get_long_status($short_status)).')'."\n";
}
}
$var[] = Array(
@ -2566,7 +2567,7 @@
return '<table width="100%" cols="4"><tr align="center">'."\n".$str.'</tr></table>'."\n";
}
function edit_form($event)
function edit_form($event,$cd)
{
global $phpgw, $phpgw_info;
@ -2574,9 +2575,6 @@
$sb = CreateObject('phpgwapi.sbox');
$start = $this->bo->maketime($event['start']) - $this->bo->datetime->tz_offset;
$end = $this->bo->maketime($event['end']) - $this->bo->datetime->tz_offset;
unset($phpgw_info['flags']['noheader']);
unset($phpgw_info['flags']['nonavbar']);
$phpgw_info['flags']['noappheader'] = True;
@ -2625,6 +2623,7 @@
);
// Date
$start = $this->bo->maketime($event['start']) - $this->bo->datetime->tz_offset;
$var[] = Array(
'field' => lang('Start Date'),
'data' => $phpgw->common->dateformatorder(
@ -2637,8 +2636,8 @@
// Time
if ($this->bo->prefs['common']['timeformat'] == '12')
{
$str .= '<input type="radio" name="start[ampm]" value="am"'.($event->start->hour >= 12?'':' checked').'>am'."\n"
. '<input type="radio" name="start[ampm]" value="pm"'.($event->start->hour >= 12?' checked':'').'>pm'."\n";
$str .= '<input type="radio" name="start[ampm]" value="am"'.($event['start']['hour'] >= 12?'':' checked').'>am'."\n"
. '<input type="radio" name="start[ampm]" value="pm"'.($event['start']['hour'] >= 12?' checked':'').'>pm'."\n";
}
$var[] = Array(
'field' => lang('Start Time'),
@ -2646,6 +2645,7 @@
);
// End Date
$end = $this->bo->maketime($event['end']) - $this->bo->datetime->tz_offset;
$var[] = Array(
'field' => lang('End Date'),
'data' => $phpgw->common->dateformatorder(
@ -2658,8 +2658,8 @@
// End Time
if ($this->bo->prefs['common']['timeformat'] == '12')
{
$str = '<input type="radio" name="end[ampm]" value="am"'.($event->end->hour >= 12?'':' checked').'>am'."\n"
. '<input type="radio" name="end[ampm]" value="pm"'.($event->end->hour >= 12?' checked':'').'>pm'."\n";
$str = '<input type="radio" name="end[ampm]" value="am"'.($event['end']['hour'] >= 12?'':' checked').'>am'."\n"
. '<input type="radio" name="end[ampm]" value="pm"'.($event['end']['hour'] >= 12?' checked':'').'>pm'."\n";
}
$var[] = Array(
'field' => lang("End Time"),
@ -2681,7 +2681,7 @@
// Participants
$accounts = $phpgw->acl->get_ids_for_location('run',1,'calendar');
$users = Array();
$this->build_part_list($users,$accounts,$owner);
$this->build_part_list($users,$accounts,$event['owner']);
$str = '';
@asort($users);
@ -2699,7 +2699,7 @@
);
// I Participate
if((($cal_id > 0) && isset($event['participants'][$this->bo->owner])) || !isset($cal_id))
if((($event['id'] > 0) && isset($event['participants'][$this->bo->owner])) || !$event['id'])
{
$checked = ' checked';
}