/**
  * add a category
  * @param \library\httpRequest $request
  * @return void
  */
 public function addAction(\library\httpRequest $request)
 {
     $formBuilder = new \applications\modules\instances\forms\categoriesForm($this->currentEntity);
     $formBuilder->build();
     $form = $formBuilder->getForm();
     if ($request->isPosted() && $form->isValid()) {
         $this->currentService->add($this->currentEntity);
         $this->page->addVar('msgSuccess', _TR_CategoriesSuccessfullyCreate);
     }
     $this->page->addVar('form', $form->createView());
 }
 /**
  * vote action
  * @param \library\httpRequest $request
  * @return void
  */
 public function voteAction(\library\httpRequest $request)
 {
     $this->page->setLayout('modal');
     //test if user is already connected
     if (isset($_SESSION['users'])) {
         //get vote
         if ($request->getGET('vote') == "voteFor") {
             $result = 1;
         }
         if ($request->getGET('vote') == "voteAgainst") {
             $result = -1;
         }
         if ($request->getGET('vote') == "voteWhite") {
             $result = 0;
         }
         //get instances informations
         $instancesService = new \applications\modules\instances\services\instancesService();
         $this->page->addVar('instances', $instancesService->getById($request->getGET('instances')));
         //check if a user is is posted for the vote
         if ($request->getData('userDelegationVote') != "") {
             if (is_array($request->getData('userDelegationVote'))) {
                 foreach ($request->getData('userDelegationVote') as $v) {
                     if ($this->currentService->vote($request->getGET('id'), $v, $result)) {
                         $this->page->addVar('msgSuccess', _TR_voteConsidered);
                     }
                 }
             } else {
                 if ($this->currentService->vote($request->getGET('id'), $request->getData('userDelegationVote'), $result)) {
                     $this->page->addVar('msgSuccess', _TR_voteConsidered);
                 }
             }
         }
     } else {
         $this->page->addVar('msgError', _TR_MustBeConnected);
     }
 }
 /**
  * delete a delegation
  * @param \library\httpRequest $request
  * @return void
  */
 public function deleteAction(\library\httpRequest $request)
 {
     $this->page->setLayout('modal');
     if ($request->getGET('categories') != "" && $request->getGET('instances') == "") {
         if ($this->currentService->deleteForCategories($request->getGET('categories'), $_SESSION['users']->id)) {
             $this->page->addVar('msgSuccess', _TR_DelegationDeletedSuccessfully);
         } else {
             $this->page->addVar('msgError', _TR_DelegationDeletedError);
         }
     }
     if ($request->getGET('instances') != "") {
         if ($this->currentService->deleteForInstances($request->getGET('instances'), $_SESSION['users']->id)) {
             $this->page->addVar('msgSuccess', _TR_DelegationDeletedSuccessfully);
         } else {
             $this->page->addVar('msgError', _TR_DelegationDeletedError);
         }
     }
 }
 /**
  * delete element(s)
  * @param \library\httpRequest $request
  */
 public function delete(\library\httpRequest $request)
 {
     foreach ($request->getData('id') as $key => $id) {
         $this->currentService->delete($id);
     }
     $this->page->addVar('msgSuccess', _TR_DeleteComplete);
 }
 /**
  * delete a forum
  * @param \library\httpRequest $request
  * @return void
  */
 public function deleteAnswersAction(\library\httpRequest $request)
 {
     //define the layout
     $this->page->setLayout('modal');
     $this->currentService->deleteAnswers($request->getGET('id'));
     $this->page->addVar('msgSuccess', _TR_elementsDeleted);
 }
 /**
  * active a user account
  * @param \library\httpRequest $request
  * @return void
  */
 public function activeAction(\library\httpRequest $request)
 {
     $this->currentService->active($request->getGET('email'), $request->getGET('code'));
 }
 /**
  * display an image
  * @param \library\httpRequest $request
  * return void
  */
 public function displayAction(\library\httpRequest $request)
 {
     // define the layout
     $this->page->setLayout('none');
     $this->page->addVar('path', $request->getGET('path'));
 }
 /**
  * delete an instance
  * @param \library\httpRequest $request
  * @return void
  */
 public function deleteAction(\library\httpRequest $request)
 {
     if ($this->currentService->delete($request->getGET('instances'))) {
         $this->page->addVar('msgSuccess', _TR_elementsDeleted);
     }
 }