18 require_once SQ_INCLUDE_PATH.
'/asset_edit/asset_edit_fns.inc';
19 require_once SQ_PACKAGES_PATH.
'/calendar/calendar_events/calendar_event_single/calendar_event_single_edit_fns.inc';
20 require_once SQ_PACKAGES_PATH.
'/calendar/calendar_events/calendar_event_recurring/calendar_event_recurring_edit_fns.inc';
61 $wa = $asset->writeAccess(
'attributes');
63 <style type=
"text/css">
64 td.single table td, td.recurring table td {
70 <table border=
"1" cellspacing=
"0" cellpadding=
"4" class=
"sq-backend-table">
87 $children = $GLOBALS[
'SQ_SYSTEM']->am->getChildren($asset->id, Array(
'calendar_event_single',
'calendar_event_recurring'));
88 foreach ($children as $id => $type) {
89 $_type = $type[0][
'type_code'];
90 $event_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($id, $_type);
101 <script type=
"text/javascript" src=
"<?php echo sq_web_path('data'); ?>/asset_types/calendar_event_multi_date/js/dates_chooser.js"></script>
103 normal_button(
'',
'More Dates...',
'addDate()');
123 $GLOBALS[
'SQ_SYSTEM']->am->acquireLock($event_asset->id,
'attributes');
125 $GLOBALS[
'SQ_SYSTEM']->am->releaseLock($event_asset->id,
'attributes');
127 $type_name = str_replace(
'calendar_event_',
'', $event_asset->type());
128 if (is_a($event_asset,
'calendar_event_single') || is_a($event_asset,
'calendar_event_recurring')) {
132 <a href=
"<?php echo $event_asset->getBackendHref('details'); ?>">
133 <?php echo ucfirst($type_name); ?> Instance #<?php echo $event_asset->id; ?>
136 <td
class=
"<?php echo $type_name; ?>">
138 if (is_a($event_asset,
'calendar_event_single')) {
139 $this->_tmp[
'single_edit_fns']->paintSingleStartEndChooser($event_asset, $o, $prefix.
'_existing_'.$event_asset->id);
140 }
else if (is_a($event_asset,
'calendar_event_recurring')) {
142 $this->_tmp[
'rec_edit_fns']->paintRecurringStartEndChooser($event_asset, $o, $prefix.
'_existing_'.$event_asset->id);
144 echo
'<br />Recurs<br />';
145 $this->_tmp[
'rec_edit_fns']->paintFrequencyField($event_asset, $o, $prefix.
'_existing_'.$event_asset->id);
149 $this->_tmp[
'rec_edit_fns']->paintFrequencyField($event_asset, $o, $prefix.
'_existing_'.$event_asset->id);
150 $res = ob_get_clean();
151 echo strtolower($res{0}).substr($res, 1);
156 <td style=
"display: none"></td>
160 <td><?php check_box($prefix.
'_existing_'.$event_asset->id.
'_delete'); ?></td>
182 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'calendar_event_recurring');
184 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'calendar_event_single');
187 <tr
id=
"template" style=
"display: none">
188 <td style=
"white-space: nowrap; vertical-align: top">
190 radio_button($prefix.
'_new_type_template',
'single', TRUE,
'setEventType(this)',
'id="'.$prefix.
'_new_type_template_single"');
191 label(
'Single Instance', $prefix.
'_new_type_template_single');
193 radio_button($prefix.
'_new_type_template',
'recurring', FALSE,
'setEventType(this)',
'id="'.$prefix.
'_new_type_template_recurring"');
194 label(
'Recurring Instance', $prefix.
'_new_type_template_recurring');
200 $this->_tmp[
'single_edit_fns']->paintSingleStartEndChooser($fake_single_event, $o, $prefix.
'_new_single_template');
203 <td
class=
"recurring" style=
"display: none">
205 $this->_tmp[
'rec_edit_fns']->paintRecurringStartEndChooser($fake_rec_event, $o, $prefix.
'_new_recurring_template');
206 echo
'<br />Recurs<br />';
207 $this->_tmp[
'rec_edit_fns']->paintFrequencyField($fake_rec_event, $o, $prefix.
'_new_recurring_template');
211 <?php sq_print_icon(sq_web_path(
'lib').
'/web/images/icons/delete.png', 16, 16,
'Delete New Row',
'Delete New Row',
'onclick="if (confirm(\'Delete new instance?\')) deleteRow(this)" style="cursor: pointer"'); ?>
233 if (!$asset->writeAccess(
'attributes'))
return FALSE;
234 $children = $GLOBALS[
'SQ_SYSTEM']->am->getChildren($asset->id, Array(
'calendar_event_single',
'calendar_event_recurring'));
235 foreach ($children as $id => $type) {
237 if (strpos($id,
':') !== FALSE)
continue;
239 if (isset($_POST[$prefix.
'_existing_'.$id.
'_delete'])) {
240 if ($GLOBALS[
'SQ_SYSTEM']->am->trashAsset($id)) {
241 $instance = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($id);
242 $instance->saveWebPaths(Array(), FALSE);
245 $type = $type[0][
'type_code'];
246 $event_asset = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($id, $type);
248 if ($type ==
'calendar_event_single') {
249 $need_save |= $this->_tmp[
'single_edit_fns']->processSingleStartEndChooser($event_asset, $o, $prefix.
'_existing_'.$event_asset->id);
252 $need_save |= $this->_tmp[
'rec_edit_fns']->processRecurringStartEndChooser($event_asset, $o, $prefix.
'_existing_'.$event_asset->id);
253 $need_save |= $this->_tmp[
'rec_edit_fns']->processFrequencyField($event_asset, $o, $prefix.
'_existing_'.$event_asset->id);
256 $GLOBALS[
'SQ_SYSTEM']->am->acquireLock($event_asset->id,
'attributes');
257 $event_asset->saveAttributes();
259 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($id);
265 if ($asset->status & SQ_SC_STATUS_SAFE_EDITING) {
266 if (!file_exists($asset->data_path.
'/.safe_edit_before')) {
267 $child_events = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_TYPE_3, Array(
'calendar_event_single',
'calendar_event_recurring'), FALSE);
268 file_put_contents($asset->data_path.
'/.safe_edit_before', serialize($child_events));
274 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'calendar_event_single');
275 $GLOBALS[
'SQ_SYSTEM']->am->includeAsset(
'calendar_event_recurring');
276 while (isset($_POST[$prefix.
'_new_type_'.$i])) {
277 if (!empty($_POST[$prefix.
'_new_type_'.$i])) {
278 switch ($_POST[$prefix.
'_new_type_'.$i]) {
281 $this->_tmp[
'single_edit_fns']->processSingleStartEndChooser($new_asset, $o, $prefix.
'_new_single_'.$i);
286 $this->_tmp[
'rec_edit_fns']->processRecurringStartEndChooser($new_asset, $o, $prefix.
'_new_recurring_'.$i);
287 $this->_tmp[
'rec_edit_fns']->processFrequencyField($new_asset, $o, $prefix.
'_new_recurring_'.$i);
290 $new_asset->setAttrValue(
'name', $asset->attr(
'name'));
293 'link_type' => SQ_LINK_TYPE_3,
296 'is_dependant' => TRUE,
297 'is_exclusive' => TRUE,
300 $new_asset->create($link);
302 if ($asset->status & SQ_SC_STATUS_SAFE_EDITING) {
303 if ($new_asset->status != SQ_STATUS_EDITING) {
305 $GLOBALS[
'SQ_SYSTEM']->setRunLevel(191);
306 $new_asset->saveSystemVersion();
307 $new_asset->processStatusChange(SQ_STATUS_EDITING, FALSE);
308 $GLOBALS[
'SQ_SYSTEM']->restoreRunLevel();
313 $asset->addPendingChild($new_asset, $link);
317 $GLOBALS[
'SQ_SYSTEM']->am->forgetAsset($new_asset);
321 if ($asset->status & SQ_SC_STATUS_SAFE_EDITING){
322 $child_events = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_TYPE_3, Array(
'calendar_event_single',
'calendar_event_recurring'), FALSE);
323 file_put_contents($asset->data_path.
'/.safe_edit_after', serialize($child_events));
342 $bodycopy_link = $GLOBALS[
'SQ_SYSTEM']->am->getLinks($asset->id, SQ_LINK_TYPE_2,
'bodycopy', TRUE,
'major', NULL,
'1',
'0');
343 $bodycopy = $GLOBALS[
'SQ_SYSTEM']->am->getAsset($bodycopy_link[0][
'minorid'],
'bodycopy');
345 if (is_null($bodycopy)) {
346 trigger_localised_error(
'CORE0016', E_USER_ERROR, $asset->name);
351 $o->setRedirect($bodycopy->getBackendHref(
'contents'));
355 $_SESSION[
'sq_nav_history'][(count($_SESSION[
'sq_nav_history']) - 1)][
'screen'] =
'details';