Пример #1
0
 public function loginAction()
 {
     $langue = $this->getEvent()->getRouteMatch()->getParam('langue');
     $token = VerifUser::tokenAction();
     if ($token != null) {
         $this->redirect()->toRoute('admin', array('action' => 'index', 'langue' => $langue));
     }
     $listeRubrique = SendLayout::fetchAllRubriques($this, 'login', $langue, $token);
     $form = new AdminForm();
     //formulaire de connexion
     $adminModel = new AdminModel();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $admin = new Admin();
         $form->setInputFilter($admin->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $admin->exchangeArray($form->getData());
             try {
                 $token = $adminModel->verifyUser($admin->login, $admin->password);
             } catch (\Exception $e) {
                 $token = null;
                 SendLayout::sendGeneral($this, $listeRubrique, 'login', $langue, $token);
                 return new ViewModel(array('form' => $form, 'listeRubrique' => $listeRubrique, 'langue' => $this->getEvent()->getRouteMatch()->getParam('langue'), 'exception' => $e->getMessage()));
             }
             $session = new Container('user');
             $session->token = $token;
             //Redirection vers l'interface d'administration
             $this->redirect()->toRoute('admin', array('action' => 'index', 'langue' => $langue));
             //echo $token;
         }
     }
     SendLayout::sendGeneral($this, $listeRubrique, 'login', $langue, $token);
     return new ViewModel(array('form' => $form, 'listeRubrique' => $listeRubrique, 'langue' => $langue));
 }
 public function deleteRubriqueAction()
 {
     $token = VerifUser::tokenAction();
     if ($token == null) {
         $this->redirect()->toRoute('home');
     }
     $adminModel = new AdminModel();
     $langue = $this->getEvent()->getRouteMatch()->getParam('langue');
     $msgSuccess = null;
     //try catch du fetchAll des rubriques
     $listeRubriques = SendLayout::fetchAllRubriques($this, 'admin', $langue, $token);
     try {
         $adminModel->deleteRubrique($token, $this->getEvent()->getRouteMatch()->getParam('id_menu'));
     } catch (\Exception $e) {
         $this->redirect()->toRoute('admin', array('action' => 'index', 'langue' => $langue, 'exSuppRubrique' => $e->getMessage()));
     }
     //Envoi des variables au layout
     SendLayout::sendGeneral($this, $listeRubriques, 'admin', $langue, $token);
     $msgSuccess = 'deleterubrique';
     $this->redirect()->toRoute('admin', array('action' => 'index', 'langue' => $langue), array('query' => array('successDltR' => $msgSuccess)));
 }
Пример #3
0
 public function deleteRubriqueAction()
 {
     //Token en brut pour tester -- Voir Mr. Salva
     $token = 'WU8nb/rCD6JgtiyxTW3ZP+s4n9Vg9liUllh5bZLoLQhAMMoCaHE72nYLQSsw12uhkgWJLDmgMmZVD+aIk6BsZw==';
     //-----------------------------------------------------------------------
     $rubriqueModel = new RubriqueModel();
     $listeRubrique = $rubriqueModel->fetchAll();
     $this->layout()->setVariable('listeRubrique', $listeRubrique);
     $this->layout()->setVariable('menu_id', 'admin');
     $langue = $this->getEvent()->getRouteMatch()->getParam('langue');
     $this->layout()->setVariable('langue', $langue);
     $idMenu = $this->getEvent()->getRouteMatch()->getParam('id_menu');
     $adminModel = new AdminModel();
     $adminModel->deleteRubrique($token, $idMenu);
     $this->redirect()->toRoute('admin', array('action' => 'index', 'langue' => $langue));
 }
 public function deletePublicationAction()
 {
     $token = VerifUser::tokenAction();
     if ($token == null) {
         $this->redirect()->toRoute('home');
     }
     $rubriqueModel = new RubriqueModel();
     $adminModel = new AdminModel();
     $langue = $this->getEvent()->getRouteMatch()->getParam('langue');
     $listeRubrique = null;
     $msgSuccess = null;
     $msgError = null;
     $listeRubrique = SendLayout::fetchAllRubriques($this, 'admin', $langue, $token);
     try {
         $adminModel->deletePublication($token, $this->getEvent()->getRouteMatch()->getParam('id_publication'));
     } catch (\Exception $e) {
         $msgError = 'errordeletepublication';
     }
     //Envoi des variables au layout
     SendLayout::sendGeneral($this, $listeRubrique, 'admin', $langue, $token);
     if (isset($msgError)) {
         $this->redirect()->toRoute('admin', array('action' => 'index', 'langue' => $langue), array('query' => array('errorDltP' => $msgError)));
     } else {
         $msgSuccess = 'deletepublication';
         $this->redirect()->toRoute('admin', array('langue' => $langue), array('query' => array('successDltP' => $msgSuccess)));
     }
 }
 public function deletePublicationAction()
 {
     $token = VerifUser::tokenAction();
     if ($token == null) {
         $this->redirect()->toRoute('home');
     }
     $rubriqueModel = new RubriqueModel();
     $adminModel = new AdminModel();
     $langue = $this->getEvent()->getRouteMatch()->getParam('langue');
     $listeRubrique = null;
     $msgSuccess = null;
     try {
         $listeRubrique = $rubriqueModel->fetchAll();
     } catch (\Exception $e) {
         LayoutExceptions::traiteExceptionsAllRubriques($this, $listeRubrique, 'admin', $langue, $token, $e->getMessage());
     }
     try {
         $adminModel->deletePublication($token, $this->getEvent()->getRouteMatch()->getParam('id_publication'));
     } catch (\Exception $e) {
         $this->redirect()->toRoute('admin', array('action' => 'index', 'langue' => $langue, 'exSuppPublication' => $e->getMessage()));
     }
     $this->layout()->setVariable('listeRubrique', $listeRubrique);
     $this->layout()->setVariable('menu_id', 'admin');
     $this->layout()->setVariable('langue', $langue);
     $this->layout()->setVariable('token', $token);
     $msgSuccess = 'deletepublication';
     $this->redirect()->toRoute('admin', array('langue' => $langue), array('query' => array('successDltP' => $msgSuccess)));
 }