/**
  * Checks for the chosen chronicle and displays it if it exists
  *
  * @param int $id           chronicle Event ID
  */
 public function actionDetail($id)
 {
     $template = $this->template;
     $template->title = "Kronika";
     $chronicle = $this->events->get($id);
     if (!$chronicle) {
         $this->flashMessage('Vybraná kronika neexistuje.');
         $this->redirect('Chronicle:');
     } elseif ($chronicle->showchronicle === 0) {
         $this->flashMessage('Vybraná kornika momentálně není přístupná.');
         $this->redirect('Chronicle:');
     }
     $template->chronicle = $chronicle;
 }
 /**
  * Processing of Chronicle Form
  *
  * @Privilege("edit")
  *
  * @param Form $form
  */
 public function editChronicleFormSucceded(Form $form)
 {
     $values = $form->getValues(TRUE);
     if ($this->user->isAllowed('Admin:Default:Chronicle', 'show')) {
         //User can choose
         $values['showchronicle'] = $values['showchronicle'] ? 1 : 0;
         //translate TRUE/FALSE to 1/0
     } else {
         $values['showchronicle'] = 0;
         //default value
     }
     $this->events->get($values['id'])->update($values);
     $this->flashMessage('Kronika byla úspěšně upravena.');
     $this->redirect('default');
 }
 /**
  * Processing of Event Edit form
  *
  * @Privilege("edit")
  *
  * @param Form $form
  */
 public function editEventFormSucceded(Form $form)
 {
     $values = $form->getValues(TRUE);
     //error checking (multiple meetings with same type)
     $event_meetings = $values['event_meeting'];
     $error = FALSE;
     $meeting_places = [];
     foreach ($event_meetings as $meeting) {
         if (in_array($meeting['comment'], $meeting_places)) {
             $error = TRUE;
         } else {
             array_push($meeting_places, $meeting['comment']);
         }
     }
     //error checking complete
     if ($error) {
         $form->addError('Nemůžete mít dva srazy stejného typu.');
     } else {
         //form processing
         $meeting = $this->database->table('event_meeting');
         $meeting->where('event_id', $values['id'])->delete();
         foreach ($event_meetings as $event_meeting) {
             $event_meeting['event_id'] = $values['id'];
             $meeting->insert($event_meeting);
         }
         unset($values['event_meeting']);
         unset($values['send']);
         if ($this->user->isAllowed('Admin:Default:Event', 'show')) {
             // User can choose
             $values['showevent'] = $values['showevent'] ? 1 : 0;
             //translate TRUE/FALSE to 1/0
         } else {
             $values['showevent'] = 0;
             //default value
         }
         $this->events->get($values['id'])->update($values);
         $this->flashMessage('Lísteček byl úspěšně upraven.');
         $this->redirect('default');
     }
 }