/** * Generates a day and a slot if there is none * * @return void */ public function generateInitialProgramData() { if (empty($this->with_program)) { return; } if ($this->hasEventDays()) { return; } $day = new \ColdTrick\EventManager\Event\Day(); $day->title = elgg_echo('event_manager:event:initial:day:title'); $day->container_guid = $this->getGUID(); $day->owner_guid = $this->getGUID(); $day->access_id = $this->access_id; $day->save(); $day->date = $this->getStartTimestamp(); $day->addRelationship($this->getGUID(), 'event_day_relation'); $slot = new \ColdTrick\EventManager\Event\Slot(); $slot->title = elgg_echo('event_manager:event:initial:slot:title'); $slot->description = elgg_echo('event_manager:event:initial:slot:description'); $slot->container_guid = $this->container_guid; $slot->owner_guid = $this->owner_guid; $slot->access_id = $this->access_id; $slot->save(); $slot->location = $this->location; $slot->start_time = mktime('08', '00', 1, 0, 0, 0); $slot->end_time = mktime('09', '00', 1, 0, 0, 0); $slot->addRelationship($day->getGUID(), 'event_day_slot_relation'); }
if (!$slot instanceof \ColdTrick\EventManager\Event\Slot) { register_error(elgg_echo('event_manager:action:slot:not_found')); forward(REFERER); } $edit = true; } else { // create new $slot = new \ColdTrick\EventManager\Event\Slot(); } $slot->title = $title; $slot->description = $description; $slot->container_guid = $day->container_guid; $slot->owner_guid = $day->owner_guid; $slot->access_id = $day->access_id; $slot->start_time = $start_time; $slot->end_time = $end_time; $slot->location = $location; $slot->max_attendees = $max_attendees; if (!$slot->save()) { register_error(elgg_echo('event_manager:action:slot:cannot_save')); forward(REFERER); } if (!empty($slot_set)) { $slot->slot_set = $slot_set; } if (!$edit) { $slot->addRelationship($day->getGUID(), 'event_day_slot_relation'); } system_message(elgg_echo('event_manager:action:slot:saved')); $result = array('edit' => $edit, 'guid' => $slot->guid, 'parent_guid' => $parent_guid, 'content' => elgg_view('event_manager/program/elements/slot', array('entity' => $slot))); echo json_encode($result);