Ejemplo n.º 1
0
 /**
  * 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');
 }
Ejemplo n.º 2
0
$slot_set = get_input('slot_set');
if (empty($title) || empty($start_time) || empty($end_time)) {
    register_error(elgg_echo('event_manager:action:slot:missing_fields'));
    forward(REFERER);
}
if ($guid) {
    // edit existing
    $slot = get_entity($guid);
    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)) {