Feature Request #229502 - Allow editing of a single occurence of a repeating event.

This commit is contained in:
skeeter 2001-08-27 01:30:40 +00:00
parent 079809436f
commit 3bf1728dc6
6 changed files with 110 additions and 40 deletions

View File

@ -340,15 +340,14 @@
return $this->so->list_events_keyword($keywords); return $this->so->list_events_keyword($keywords);
} }
function update($p_cal=0,$p_participants=0,$p_start=0,$p_end=0,$p_recur_enddata=0) function update($params)
{ {
global $HTTP_POST_VARS, $HTTP_GET_VARS; $l_cal = ($params['cal']?$params['cal']:$GLOBALS['HTTP_POST_VARS']['cal']);
$l_participants = ($params['participants']?$params['participants']:$GLOBALS['HTTP_POST_VARS']['participants']);
$l_cal = ($p_cal?$p_cal:$HTTP_POST_VARS['cal']); $l_start = ($params['start']?$params['start']:$GLOBALS['HTTP_POST_VARS']['start']);
$l_participants = ($p_participants?$p_participants:$HTTP_POST_VARS['participants']); $l_end = ($params['end']?$params['end']:$GLOBALS['HTTP_POST_VARS']['end']);
$l_start = ($p_start?$p_start:$HTTP_POST_VARS['start']); $l_recur_enddate = ($params['recur_enddate']?$params['recur_enddate']:$GLOBALS['HTTP_POST_VARS']['recur_enddate']);
$l_end = ($p_end?$p_end:$HTTP_POST_VARS['end']); $l_reference = ($params['reference']?$params['reference']:$GLOBALS['HTTP_POST_VARS']['reference']);
$l_recur_enddate = ($p_recur_enddate?$p_recur_enddate:$HTTP_POST_VARS['recur_enddate']);
$send_to_ui = True; $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)
@ -405,6 +404,7 @@
$this->so->set_start($l_start['year'],$l_start['month'],$l_start['mday'],$l_start['hour'],$l_start['min'],0); $this->so->set_start($l_start['year'],$l_start['month'],$l_start['mday'],$l_start['hour'],$l_start['min'],0);
$this->so->set_end($l_end['year'],$l_end['month'],$l_end['mday'],$l_end['hour'],$l_end['min'],0); $this->so->set_end($l_end['year'],$l_end['month'],$l_end['mday'],$l_end['hour'],$l_end['min'],0);
$this->so->set_class($is_public); $this->so->set_class($is_public);
$this->so->add_attribute('reference',($l_reference?$l_reference:0));
if($l_cal['id']) if($l_cal['id'])
{ {
$this->so->add_attribute('id',$l_cal['id']); $this->so->add_attribute('id',$l_cal['id']);
@ -508,12 +508,22 @@
); );
} }
$event_ids = Array();
if($event['id'])
{
$event_ids[] = $event['id'];
}
if($event['reference'])
{
$event_ids[] = $event['reference'];
}
$overlapping_events = $this->overlap( $overlapping_events = $this->overlap(
$this->maketime($event['start']) - $this->datetime->tz_offset, $this->maketime($event['start']) - $this->datetime->tz_offset,
$this->maketime($event['end']) - $this->datetime->tz_offset, $this->maketime($event['end']) - $this->datetime->tz_offset,
$event['participants'], $event['participants'],
$event['owner'], $event['owner'],
$event['id'] $event_ids
); );
} }
@ -651,6 +661,7 @@
$retval = Array(); $retval = Array();
$ok = False; $ok = False;
/* This needs some attention.. by commenting this chunk of code it will fix bug #444265 */
if($starttime == $endtime && $GLOBALS['phpgw']->common->show_date($starttime,'Hi') == 0) if($starttime == $endtime && $GLOBALS['phpgw']->common->show_date($starttime,'Hi') == 0)
{ {
$endtime = mktime(23,59,59,$GLOBALS['phpgw']->common->show_date($starttime,'m'),$GLOBALS['phpgw']->common->show_date($starttime,'d') + 1,$GLOBALS['phpgw']->common->show_date($starttime,'Y')) - $this->datetime->tz_offset; $endtime = mktime(23,59,59,$GLOBALS['phpgw']->common->show_date($starttime,'m'),$GLOBALS['phpgw']->common->show_date($starttime,'d') + 1,$GLOBALS['phpgw']->common->show_date($starttime,'Y')) - $this->datetime->tz_offset;
@ -673,7 +684,7 @@
} }
if($users) if($users)
{ {
$p_g .= 'phpgw_cal_user.cal_login in ('.implode(',',$users).')'; $p_g .= 'phpgw_cal_user.cal_login IN ('.implode(',',$users).')';
} }
} }
if($p_g) if($p_g)
@ -684,7 +695,8 @@
if($id) if($id)
{ {
$sql .= ' AND phpgw_cal.cal_id <> '.$id; @reset($id);
$sql .= ' AND phpgw_cal.cal_id NOT IN ('.(count($id)==1?$id[0]:implode(',',$id)).')';
} }
$sql .= ' ORDER BY phpgw_cal.datetime ASC, phpgw_cal.edatetime ASC, phpgw_cal.priority ASC'; $sql .= ' ORDER BY phpgw_cal.datetime ASC, phpgw_cal.edatetime ASC, phpgw_cal.priority ASC';
@ -945,7 +957,7 @@
for($i=0;$i<count($this->cached_events[$date]);$i++) for($i=0;$i<count($this->cached_events[$date]);$i++)
{ {
$events = $this->cached_events[$date][$i]; $events = $this->cached_events[$date][$i];
if($this->cached_events[$date][$i]['id'] == $event['id']) if($this->cached_events[$date][$i]['id'] == $event['id'] || $this->cached_events[$date][$i]['reference'] == $event['id'])
{ {
if($this->debug) if($this->debug)
{ {
@ -1195,16 +1207,16 @@
{ {
$c_evt_day = 0; $c_evt_day = 0;
} }
// if($this->debug) if($this->debug)
// { {
// echo "Date: ".$j." Count : ".$c_evt_day."<br>\n"; echo "Date: ".$j." Count : ".$c_evt_day."<br>\n";
// } }
if($this->cached_events[$j][$c_evt_day]['id'] != $event['id']) if($this->cached_events[$j][$c_evt_day]['id'] != $event['id'])
{ {
// if($this->debug) if($this->debug)
// { {
// echo "Adding Event for Date: ".$j."<br>\n"; echo "Adding Event for Date: ".$j."<br>\n";
// } }
$this->cached_events[$j][] = $event; $this->cached_events[$j][] = $event;
} }
} }
@ -1228,7 +1240,10 @@
$retval = Array(); $retval = Array();
for($j=date('Ymd',mktime(0,0,0,$smonth,$sday,$syear)),$k=0;$j<=date('Ymd',mktime(0,0,0,$emonth,$eday,$eyear));$k++,$j=date('Ymd',mktime(0,0,0,$smonth,$sday + $k,$syear))) for($j=date('Ymd',mktime(0,0,0,$smonth,$sday,$syear)),$k=0;$j<=date('Ymd',mktime(0,0,0,$emonth,$eday,$eyear));$k++,$j=date('Ymd',mktime(0,0,0,$smonth,$sday + $k,$syear)))
{ {
$retval[$j] = $this->cached_events[$j]; if(is_array($this->cached_events[$j]))
{
$retval[$j] = $this->cached_events[$j];
}
} }
return $retval; return $retval;
// return $this->cached_events; // return $this->cached_events;

View File

@ -115,6 +115,7 @@ class socalendar_ extends socalendar__
$this->set_category(intval($this->stream->f('category'))); $this->set_category(intval($this->stream->f('category')));
$this->set_title($GLOBALS['phpgw']->strip_html($this->stream->f('title'))); $this->set_title($GLOBALS['phpgw']->strip_html($this->stream->f('title')));
$this->set_description($GLOBALS['phpgw']->strip_html($this->stream->f('description'))); $this->set_description($GLOBALS['phpgw']->strip_html($this->stream->f('description')));
$this->add_attribute('reference',intval($this->stream->f('reference')));
// This is the preferred method once everything is normalized... // This is the preferred method once everything is normalized...
//$this->event->alarm = intval($this->stream->f('alarm')); //$this->event->alarm = intval($this->stream->f('alarm'));
@ -392,7 +393,8 @@ class socalendar_ extends socalendar__
. "cal_type='".$type."', " . "cal_type='".$type."', "
. 'is_public='.$event['public'].', ' . 'is_public='.$event['public'].', '
. "title='".addslashes($event['title'])."', " . "title='".addslashes($event['title'])."', "
. "description='".addslashes($event['description'])."' " . "description='".addslashes($event['description'])."', "
. 'reference='.$event['reference'].' '
. 'WHERE cal_id='.$event['id']; . 'WHERE cal_id='.$event['id'];
$this->stream->query($sql,__LINE__,__FILE__); $this->stream->query($sql,__LINE__,__FILE__);

View File

@ -512,14 +512,37 @@
if ($this->bo->check_perms(PHPGW_ACL_EDIT)) if ($this->bo->check_perms(PHPGW_ACL_EDIT))
{ {
$var = Array( if($event['recur_type'] != MCAL_RECUR_NONE)
'action_url_button' => $this->page('edit','&cal_id='.$cal_id), {
'action_text_button' => lang('Edit'), $var = Array(
'action_confirm_button' => '', 'action_url_button' => $this->page('edit','&cal_id='.$cal_id),
'action_extra_field' => '' 'action_text_button' => lang('Edit Single'),
); 'action_confirm_button' => '',
$p->set_var($var); 'action_extra_field' => '<input type="hidden" name="edit_type" value="single">'
echo $p->fp('out','form_button'); );
$p->set_var($var);
echo $p->fp('out','form_button');
$var = Array(
'action_url_button' => $this->page('edit','&cal_id='.$cal_id),
'action_text_button' => lang('Edit Series'),
'action_confirm_button' => '',
'action_extra_field' => '<input type="hidden" name="edit_type" value="series">'
);
$p->set_var($var);
echo $p->fp('out','form_button');
}
else
{
$var = Array(
'action_url_button' => $this->page('edit','&cal_id='.$cal_id),
'action_text_button' => lang('Edit'),
'action_confirm_button' => '',
'action_extra_field' => ''
);
$p->set_var($var);
echo $p->fp('out','form_button');
}
} }
if ($this->bo->check_perms(PHPGW_ACL_DELETE)) if ($this->bo->check_perms(PHPGW_ACL_DELETE))
@ -539,8 +562,6 @@
function edit($params='') function edit($params='')
{ {
global $HTTP_GET_VARS;
if(!$this->bo->check_perms(PHPGW_ACL_EDIT)) if(!$this->bo->check_perms(PHPGW_ACL_EDIT))
{ {
$this->no_edit(); $this->no_edit();
@ -557,16 +578,32 @@
) )
); );
} }
elseif(isset($HTTP_GET_VARS['cal_id'])) elseif(isset($GLOBALS['HTTP_GET_VARS']['cal_id']))
{ {
$cal_id = $HTTP_GET_VARS['cal_id']; $cal_id = $GLOBALS['HTTP_GET_VARS']['cal_id'];
$event = $this->bo->read_entry(intval($HTTP_GET_VARS['cal_id'])); $event = $this->bo->read_entry(intval($GLOBALS['HTTP_GET_VARS']['cal_id']));
$can_edit = $this->bo->can_user_edit($event); $can_edit = $this->bo->can_user_edit($event);
if(!$can_edit) if(!$can_edit)
{ {
$this->view(intval($HTTP_GET_VAR['cal_id'])); $this->view(intval($GLOBALS['HTTP_GET_VARS']['cal_id']));
}
if(@isset($GLOBALS['HTTP_POST_VARS']['edit_type']) && $GLOBALS['HTTP_POST_VARS']['edit_type'] == 'single')
{
$event['id'] = 0;
$event['start']['month'] = $this->bo->month;
$event['start']['mday'] = $this->bo->day;
$event['start']['year'] = $this->bo->year;
$event['end']['month'] = $this->bo->month;
$event['end']['mday'] = $this->bo->day;
$event['end']['year'] = $this->bo->year;
$event['recur_type'] = MCAL_RECUR_NONE;
$event['recur_interval'] = 0;
$event['recur_data'] = 0;
$event['recur_enddate']['month'] = 0;
$event['recur_enddate']['mday'] = 0;
$event['recur_enddate']['year'] = 0;
} }
$this->edit_form( $this->edit_form(
Array( Array(
@ -1521,7 +1558,8 @@
if ($editable) if ($editable)
{ {
$p->set_var('link_link',$this->page('view','&cal_id='.$event['id'])); $date = sprintf('%04d%02d%02d',$year,$month,$day);
$p->set_var('link_link',$this->page('view','&cal_id='.$event['id'].'&date='.$date));
$p->set_var('lang_view',lang('View this entry')); $p->set_var('lang_view',lang('View this entry'));
$p->parse('picture','link_open',True); $p->parse('picture','link_open',True);
@ -2681,7 +2719,8 @@
'calendar_action' => ($event['id']?lang('Calendar - Edit'):lang('Calendar - Add')), 'calendar_action' => ($event['id']?lang('Calendar - Edit'):lang('Calendar - Add')),
'action_url' => $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.bocalendar.update')), 'action_url' => $GLOBALS['phpgw']->link('/index.php',Array('menuaction'=>'calendar.bocalendar.update')),
'common_hidden' => '<input type="hidden" name="cal[id]" value="'.$event['id'].'">'."\n" 'common_hidden' => '<input type="hidden" name="cal[id]" value="'.$event['id'].'">'."\n"
. '<input type="hidden" name="cal[owner]" value="'.$this->bo->owner.'">'."\n", . '<input type="hidden" name="cal[owner]" value="'.$this->bo->owner.'">'."\n"
. ($GLOBALS['HTTP_GET_VARS']['cal_id'] && $event['id'] == 0?'<input type="hidden" name="reference" value="'.$GLOBALS['HTTP_GET_VARS']['cal_id'].'">'."\n":''),
'errormsg' => ($params['cd']?$GLOBALS['phpgw']->common->check_code($params['cd']):'') 'errormsg' => ($params['cd']?$GLOBALS['phpgw']->common->check_code($params['cd']):'')
); );
$p->set_var($vars); $p->set_var($vars);

View File

@ -13,7 +13,7 @@
$setup_info['calendar']['name'] = 'calendar'; $setup_info['calendar']['name'] = 'calendar';
$setup_info['calendar']['title'] = 'Calendar'; $setup_info['calendar']['title'] = 'Calendar';
$setup_info['calendar']['version'] = '0.9.13.002'; $setup_info['calendar']['version'] = '0.9.13.003';
$setup_info['calendar']['app_order'] = 3; $setup_info['calendar']['app_order'] = 3;
$setup_info['calendar']['enable'] = 1; $setup_info['calendar']['enable'] = 1;

View File

@ -25,7 +25,8 @@
'cal_type' => array('type' => 'varchar', 'precision' => 10,'nullable' => True), 'cal_type' => array('type' => 'varchar', 'precision' => 10,'nullable' => True),
'is_public' => array('type' => 'int', 'precision' => 8,'nullable' => False,'default' => 1), 'is_public' => array('type' => 'int', 'precision' => 8,'nullable' => False,'default' => 1),
'title' => array('type' => 'varchar', 'precision' => 80,'nullable' => False,'default' => '1'), 'title' => array('type' => 'varchar', 'precision' => 80,'nullable' => False,'default' => '1'),
'description' => array('type' => 'text','nullable' => True) 'description' => array('type' => 'text','nullable' => True),
'reference' => array('type' => 'int', 'precision' => 8, 'nullable' => False, 'default' => 0)
), ),
'pk' => array('cal_id'), 'pk' => array('cal_id'),
'fk' => array(), 'fk' => array(),

View File

@ -892,6 +892,7 @@
$setup_info['calendar']['currentver'] = '0.9.11.011'; $setup_info['calendar']['currentver'] = '0.9.11.011';
return $setup_info['calendar']['currentver']; return $setup_info['calendar']['currentver'];
} }
$test[] = '0.9.11.011'; $test[] = '0.9.11.011';
function calendar_upgrade0_9_11_011() function calendar_upgrade0_9_11_011()
{ {
@ -906,4 +907,16 @@
$setup_info['calendar']['currentver'] = '0.9.13.002'; $setup_info['calendar']['currentver'] = '0.9.13.002';
return $setup_info['calendar']['currentver']; return $setup_info['calendar']['currentver'];
} }
$test[] = '0.9.13.002';
function calendar_upgrade0_9_13_002()
{
global $setup_info, $phpgw_setup;
$phpgw_setup->oProc->AddColumn('phpgw_cal','reference',array('type' => 'int', 'precision' => 8,'nullable' => False, 'default' => '0'));
$setup_info['calendar']['currentver'] = '0.9.13.003';
return $setup_info['calendar']['currentver'];
}
?> ?>