Esempio n. 1
0
 public function passwd()
 {
     $token = $this->getParams()[0];
     $id = $this->userModel->getReset($token);
     if (empty($id)) {
         throw new NoUserFoundException($token);
     }
     $form = new Form('/user/passwd');
     $form->addField(new LabelField('passwd1'));
     $form->addField(new LabelField('passwd2'));
     $form->addField(new InputField('id', ['type' => 'hidden', 'value' => $id['id']]));
     $form->addField(new InputField('passwd1', ['type' => 'password']));
     $form->addField(new InputField('passwd2', ['type' => 'password']));
     $form->addField(new InputField('submit', ['type' => 'submit']));
     $html = $form->getFormHTML(['id' => '', 'passwd1' => 'Nouveau mot de passe', 'passwd2' => 'Confirmier le mot de passe']);
     $this->getView()->render('user/passwd', ['form' => $html]);
 }
 public function modify()
 {
     if (!Authentication::getInstance()->isAuthenticated() && !Authentication::getInstance()->getOptionOr('accessLevel', 0)) {
         throw new NotAuthenticatedException();
     }
     $id = (int) $this->getParams()[0];
     $event = $this->eventModel->get($id);
     if (empty($event)) {
         throw new EventNotFoundException($id);
     }
     if ($event['user'] != Authentication::getInstance()->getUserId() && !Authentication::getInstance()->getOptionOr('accessLevel', 0)) {
         throw new NotYourEventException($id);
     }
     $form = FormHelper::generate('event', '/event/modify');
     $form->getField('id')->addAttribute('value', $event['id']);
     $form->getField('name')->addAttribute('value', $event['name']);
     $form->getField('image')->addAttribute('value', $event['image']);
     $form->getField('description')->setContent($event['description']);
     $form->getField('address')->setContent($event['address']);
     $eventtime = new \DateTime();
     $eventtime = $eventtime->createFromFormat('Y-m-d H:i:s', $event['eventtime']);
     $form->getField('eventtime')->addAttribute('value', $eventtime->format('d/m/Y'));
     $form->getField('money')->addAttribute('value', $event['money']);
     $form->getField('personsmax')->addAttribute('value', $event['personsmax']);
     $html = $form->getFormHTML(['name' => 'Nom de l\'évènement', 'description' => 'Description', 'address' => 'Adresse', 'eventtime' => 'Date de l\'évènement', 'money' => 'Prix', 'personsmax' => 'Nombre maximum de participants', 'image' => 'Image']);
     $formDelete = new Form('/event/delete');
     $formDelete->setClass('pure-form centered');
     $formDelete->addField(new InputField('id', ['type' => 'hidden', 'value' => $id]));
     $formDelete->addField(new InputField('submit', ['type' => 'submit', 'value' => 'Supprimer', 'class' => 'pure-button button-error']));
     $this->getView()->render('event/modify', ['form' => $html, 'formDelete' => $formDelete->getFormHTML([])]);
 }