/** * page register / subcribe * @param \library\httpRequest $request * @return void */ public function registerAction(\library\httpRequest $request) { $this->currentEntity->setCreationDate(date("Y-m-d")); //create register form $formBuilder = new \applications\modules\users\forms\registerForm($this->currentEntity); $formBuilder->build(); $formRegister = $formBuilder->getForm(); if ($request->getData('register') && $formRegister->isValid()) { $this->currentService->register($this->currentEntity); } $this->page->addVar('formRegister', $formRegister->createView()); //create subscribe form $formBuilder = new \applications\modules\users\forms\subscribeForm($this->currentEntity); $formBuilder->build(); $formSubscribe = $formBuilder->getForm(); if ($request->getData('subscribe') && $formSubscribe->isValid()) { $this->currentService->add($this->currentEntity); } $this->page->addVar('formSubscribe', $formSubscribe->createView()); }
/** * 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); }
/** * 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); } }
/** * edit a answer * @param \library\httpRequest $request * @return void */ public function editAnswersAction(\library\httpRequest $request) { //define the layout $this->page->setLayout('modal'); //complete currentEntity $this->currentEntity->hydrate($this->currentService->getAnswersById($request->getGET('id'))); if ($request->isPosted()) { $this->currentEntity->setForumsAnswersTitle($request->getData('forumsanswerstitle')); $this->currentEntity->setForumsAnswersDescr($request->getData('forumsanswersdescr')); } //create form $formBuilder = new \applications\modules\instances\forms\forumsForm($this->currentEntity); $formBuilder->build(); $form = $formBuilder->getForm(); if ($request->isPosted() && $form->isValid()) { if ($this->currentService->add($this->currentEntity)) { $this->page->addVar('msgSuccess', "réponse mise à jour avec succès"); } } $this->page->addVar('form', $form->createView()); }