17 require_once dirname(__FILE__).
'/../../calendar_event/calendar_event.inc';
18 require_once dirname(__FILE__).
'/../calendar_event_recurring/calendar_event_recurring.inc';
61 $parent =& $link[
'asset'];
62 if (!is_a($parent,
'calendar_event_recurring')) {
63 trigger_localised_error(
'CAL0054', E_USER_WARNING);
71 if (!parent::_preCreateCheck($link))
return FALSE;
74 trigger_localised_error(
'CAL0053', E_USER_WARNING);
93 protected function _getName($short_name=FALSE, $contextid=NULL)
96 if ($contextid === NULL) {
97 $contextid = $GLOBALS[
'SQ_SYSTEM']->getContextId();
101 return translate(
'cal_event_cancelled_date', date(
'd M Y', iso8601_ts($this->
attr(
'start_date'))));
105 $values = $GLOBALS[
'SQ_SYSTEM']->am->getAttributeValuesByName(
'name', $this->
type(), Array($this->
id), $contextid);
106 if (empty($values) === TRUE) {
107 return parent::_getName($short_name, $contextid);
109 return $values[$this->id];
123 $links = parent::_getAllowedLinks();
124 $links[SQ_LINK_TYPE_2][
'calendar_event_single'] = Array(
'card' => 1,
'exclusive' => FALSE);
142 if (!$parent->hasOccurrenceOnDate($this->getStartDate())) {
143 trigger_localised_error(
'CAL0055', E_USER_WARNING, $this->
getStartDate());
149 $st = $parent->getStartTime();
153 if ($duration = $parent->getDuration()) {
154 $this->
setAttrValue(
'end_date', date(
'Y-m-d', iso8601_ts($this->
attr(
'start_date')) + $duration).substr($parent->attr(
'end_date'), 10));
157 $this->
setAttrValue(
'name', translate(
'cal_event_cancelled_date', date(
'd M Y', iso8601_ts($this->
attr(
'start_date')))).
': '.$parent->attr(
'name'));
177 trigger_localised_error(
'CAL0056', E_USER_WARNING);
181 $replacement_event = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($existing_link[
'minorid']);
184 $parent_link = $GLOBALS[
'SQ_SYSTEM']->am->getLink($this->
id, NULL,
'', TRUE, NULL,
'minor');
185 $parent_info = reset($GLOBALS[
'SQ_SYSTEM']->am->getAssetInfo(Array($parent_link[
'majorid'])));
186 $new_type_code = str_replace(
'recurring',
'single', $parent_info[
'type_code']);
187 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset($new_type_code);
188 $replacement_event =
new $new_type_code();
190 $replacement_event->setAttrValue(
'start_date', $start_date);
191 $replacement_event->setAttrValue(
'end_date', $end_date);
192 $replacement_event->setAttrValue(
'description', $description);
193 if (!$replacement_event->id) {
194 $link = Array(
'asset' => &$this,
'link_type' => SQ_LINK_TYPE_2,
'is_dependant' => 1,
'is_exclusive' => 1);
195 $replacement_event->create($link);
197 if (!$GLOBALS[
'SQ_SYSTEM']->am->acquireLock($replacement_event->id,
'attributes')) {
198 trigger_localised_error(
'CAL0057', E_USER_WARNING, $replacement_event->name);
201 $replacement_event->saveAttributes();
202 $GLOBALS[
'SQ_SYSTEM']->am->releaseLock($replacement_event->id,
'attributes');
204 if ($replacement_event->id) {
205 $replacement_event->processStatusChange($this->status);
206 return $replacement_event;
229 if (is_null($id)) $id = $this->id;
230 $child_links = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($id, SQ_SC_LINK_ALL,
'calendar_event_single', FALSE,
'major');
231 return current($child_links);
247 switch ($action_name) {
248 case 'addreplacement':
249 $parent_assetids = array_keys($GLOBALS[
'SQ_SYSTEM']->am->getParents($this->id,
'calendar_event_recurring'));
250 $parent_object = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($parent_assetids[0]);
252 $res =
'<form method="POST" action="?SQ_CALENDAR_VIEW=event&SQ_CALENDAR_EVENT_ID='.$this->id.
'&SQ_CALENDAR_EVENT_ACTION=addreplacement2&SQ_CALENDAR_DATE='.$_REQUEST[
'SQ_CALENDAR_DATE'].
'"><table cellpadding="4" border="0">';
253 $res .=
'<tr><td style="vertical-align: top">'.translate(
'cal_event_start_and_end').
'</td><td>';
256 $edit_fns->paintStartEndChooser($this,
'event');
257 $res .= ob_get_contents();
259 $res .=
'</td></tr>';
261 $res .=
'<tr><td style="vertical-align: top">'.translate(
'description').
': </td><td><textarea name="event_description">';
262 $res .= $parent_object->attr(
'description');
263 $res .=
'</textarea></td></tr>';
264 $res .=
'<tr><td colspan="2"><input type="submit" value="'.translate(
'cal_event_add_replacement').
'"/> <input type="button" value="'.translate(
'cancel').
'" onclick="document.location=\''.$_SERVER[
'PHP_SELF'].
'?SQ_CALENDAR_EVENT_ID='.$parent_object->id.
'&SQ_CALENDAR_VIEW=event&SQ_CALENDAR_DATE='.$_REQUEST[
'SQ_CALENDAR_DATE'].
'\'" /></td></tr></table></form>';
267 case 'addreplacement2':
268 if (!isset($_REQUEST['event_start_time_enabled'])) {
269 $_REQUEST['event_start_hours'] = '--';
270 $_REQUEST['event_start_minutes'] = '--';
272 if ($_REQUEST['event_start_is_pm'] && ($_REQUEST['event_start_hours'] != 12)) {
273 $_REQUEST['event_start_hours'] += 12;
276 if (!isset($_REQUEST['event_end_time_enabled'])) {
277 $_REQUEST['event_end_hours'] = '--';
278 $_REQUEST['event_end_minutes'] = '--';
280 if ($_REQUEST['event_end_is_pm'] && ($_REQUEST['event_end_hours'] != 12)) {
281 $_REQUEST['event_end_hours'] += 12;
284 if (!isset($_REQUEST['event_end_date_enabled'])) {
285 $_REQUEST['event_end_year'] = '----';
286 $_REQUEST['event_end_month'] = '--';
287 $_REQUEST['event_end_day'] = '--';
290 $replacement_event = $this->addReplacement(sprintf('%04s-%02s-%02s %02s:%02s:--', $_REQUEST['event_start_year'], $_REQUEST['event_start_month'], $_REQUEST['event_start_day'], $_REQUEST['event_start_hours'], $_REQUEST['event_start_minutes']), sprintf('%04s-%02s-%02s %02s:%02s:--', $_REQUEST['event_end_year'], $_REQUEST['event_end_month'], $_REQUEST['event_end_day'], $_REQUEST['event_end_hours'], $_REQUEST['event_end_minutes']), $_REQUEST['event_description']);
291 if ($replacement_event) {
292 $res = '<p>'.translate('cal_event_replacement_event_added').'</p>';
297 $res = parent::processEventAction($action_name);
302 }//end processEventAction()
315 function saveAttributes($dont_run_updated=FALSE)
319 if (!$dont_run_updated) {
321 // get the parent recurring event asset
322 $recurring_event_ids = array_keys($GLOBALS['SQ_SYSTEM']->am->getParents($this->id, 'calendar_event_recurring', FALSE));
323 if (empty($recurring_event_ids)) {
324 trigger_localised_error('CAL0054', E_USER_ERROR);
327 $recurring_event = $GLOBALS['SQ_SYSTEM']->am->getAsset($recurring_event_ids[0]);
329 if (!$this->synchronizeWithParent($recurring_event)) {
334 return parent::saveAttributes($dont_run_updated);
337 }//end saveAttributes()
348 $root_url = array_values($GLOBALS['SQ_SYSTEM']->am->getRootURL());
349 if (is_array($root_url)) $root_url = $root_url[0];
350 require_once SQ_FUDGE_PATH.'/general/datetime.inc';
352 <table border="0
" cellspacing="2
" cellpadding="2
">
354 <td><b><?php echo translate('name') ?></b></td>
355 <td><?php echo $this->attr('name'); ?></td>
358 <td><b><?php echo translate('cancels') ?></b></td>
360 // get the parent recurring event asset
361 if ($recurring_events = $GLOBALS['SQ_SYSTEM']->am->getParents($this->id, 'calendar_event_recurring', FALSE)) {
362 $recurring_events = array_keys($recurring_events);
363 $recurring_event = $GLOBALS['SQ_SYSTEM']->am->getAsset($recurring_events[0]);
364 echo '<a href="'.$root_url.'?a=
'.$recurring_events[0].'">'.$recurring_event->attr('name').'</a>';
370 <td><b><?php echo translate('cal_event_cancelled_start_date'); ?></b></td>
371 <td><?php echo $this->getFriendlyStart(); ?></td>
374 <td><b><?php echo translate('cal_event_cancelled_end_date'); ?></b></td>
375 <td><?php echo $this->getFriendlyEnd(); ?></td>
378 <td><b><?php echo translate('cal_event_reason_for_cancellation'); ?></b></td>
379 <td><?php echo $this->attr('description'); ?></td>