Ejemplo n.º 1
0
    private function userForm()
    {
        $result = '<form method="POST" action="#" id="" class="pure-form pure-form-aligned centered">
    <div class="pure-controls">
        <input name="id" type="hidden" />
    </div>
    <div class="pure-control-group">
        <label for="username">Nom d\'utilisateur</label>
        <input name="username" type="text" />
    </div>
    <div class="pure-control-group">
        <label for="firstname">Prénom</label>
        <input name="firstname" type="text" />
    </div>
    <div class="pure-controls">
        <input name="submit" type="submit" value="Envoyer" class="pure-button pure-button-primary" />
    </div>
</form>';
        $form = FormHelper::generate('user', '#');
        $this->assertEquals($form->getFormHTML(array('username' => 'Nom d\'utilisateur', 'firstname' => 'Prénom')), $result);
    }
Ejemplo n.º 2
0
 public function modifyPOST()
 {
     if (!Authentication::getInstance()->isAuthenticated()) {
         throw new NotAuthenticatedException();
     }
     $form = FormHelper::generate('article', '/article/modify');
     $result = $form->validate(['id' => '', 'title' => 'Titre de l\'Actualité', 'text' => 'Contenu']);
     $article = $this->articleModel->getOneNewsById($result['id']);
     if (empty($article)) {
         throw new ArticleNotFoundException($result['id']);
     }
     if ($article['user'] != Authentication::getInstance()->getUserId() && !(Authentication::getInstance()->getOptionOr('accessLevel', 0) == 1)) {
         throw new NotYourArticleException($result['id']);
     }
     $this->articleModel->updateNews($result);
     $this->getView()->redirect('/article/show/' . $result['id']);
 }
Ejemplo n.º 3
0
 public function modifyPOST()
 {
     if (!Authentication::getInstance()->isAuthenticated()) {
         throw new NotAuthenticatedException();
     }
     $form = FormHelper::generate('event', '/event/modify');
     $form->setClass('pure-form pure-form-stacked');
     $result = $form->validate(['id' => '', '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']);
     $id = $result['id'];
     $event = $this->eventModel->get($id);
     if (empty($event)) {
         throw new EventNotFoundException($id);
     }
     if (!Authentication::getInstance()->getOptionOr('accessLevel', 0) && $event['user'] != Authentication::getInstance()->getUserId()) {
         throw new NotYourEventException($id);
     }
     $eventtime = new \DateTime();
     $eventtime = $eventtime->createFromFormat('d/m/Y', $result['eventtime']);
     $result['eventtime'] = $eventtime->format('Y-m-d H:i:s');
     $this->eventModel->updateEventById($result);
     $this->getView()->redirect('/event');
 }