/** * @return mixed */ public function disableAction() { $mainLayout = $this->initializeAdminArea(); $id = $this->params()->fromRoute('id'); $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); $connection = $em->getConnection(); $userDetails = $this->layout()->getVariable('userDetails'); $helper = new ContrattiPubbliciControllerHelper(); $helper->setConnection($connection); try { $helper->getConnection()->beginTransaction(); $helper->updateAttivo($id, 0); $logWriter = new LogWriter($connection); $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::contratti_pubblici_id, 'message' => "Contratto reso disattivato sul sito pubblico. ID: " . $id, 'type' => 'info', 'backend' => 1)); $helper->getConnection()->commit(); if (is_object($this->getRequest()->getHeader('Referer'))) { return $this->redirect()->toUrl($this->getRequest()->getHeader('Referer')->getUri()); } } catch (\Exception $e) { $logWriter = new LogWriter($connection); $logWriter->writeLog(array('user_id' => isset($userDetails->id) ? $userDetails->id : 1, 'module_id' => ModulesContainer::contratti_pubblici_id, 'message' => "Errore nell'operazione di resa visibile bando di gara sul sito pubblico. ID: " . $id, 'type' => 'error', 'reference_id' => $id, 'backend' => 1)); $this->layout()->setVariables(array('messageType' => 'danger', 'messageTitle' => 'Errore verificato', 'messageText' => $e->getMessage(), 'templatePartial' => 'message.phtml')); $this->layout()->setTemplate($mainLayout); } }
public function indexAction() { $mainLayout = $this->initializeFrontendWebsite(); $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); $lang = $this->layout()->getVariable('lang'); $configurations = $this->layout()->getVariable('configurations'); try { $helper = new HomePageHelper(); $homePageWrapper = $helper->recoverWrapper(new HomePageGetterWrapper(new HomePageGetter($em)), array('onlyActiveModules' => 1, 'orderBy' => 'homePageBlocks.position ASC', 'languageAbbreviation' => $lang)); $homePageRecords = $homePageWrapper->getRecords(); $helper->checkRecords($homePageRecords, 'Nessun elemento in home page'); $sortedHomePageRecordsPerModuleCode = $helper->gatherReferenceIds($homePageWrapper->formatPerModuleCode($homePageRecords)); $helper->checkClassMapFromRecords($sortedHomePageRecordsPerModuleCode); $homePageElements = array(); foreach ($sortedHomePageRecordsPerModuleCode as $key => $value) { $obj = $helper->recoverClassMapKey($key); if (!empty($obj)) { /** * @var \ModelModule\Model\HomePage\HomePageBuilderAbstract $builder */ $builder = new $obj(); $builder->setEntityManager($em); $builder->setModuleRelatedRecords($value); $homePageElements[$key] = $builder->recoverHomePageElements(); } } } catch (NullException $e) { $logWriter = new LogWriter($em->getConnection()); $logWriter->writeLog(array('user_id' => 0, 'module_id' => ModulesContainer::contenuti_id, 'message' => "Errore visualizzazione home page", 'description' => $e->getMessage(), 'reference_id' => 0, 'type' => 'error', 'backend' => 0)); } $this->layout()->setVariables(array('configuraitions' => $configurations, 'homepage' => !empty($homePageElements) ? $homePageElements : null, 'templatePartial' => 'homepage/homepage.phtml')); $this->layout()->setTemplate($mainLayout); }
public function indexAction() { /** * @var \Doctrine\ORM\EntityManager $em */ $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); /** * @var \Doctrine\DBAL\Connection $connection */ $connection = $em->getConnection(); $request = $this->getRequest(); if (!($request->isXmlHttpRequest() or $request->isPost())) { return $this->redirect()->toRoute('main'); } $post = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray()); $userDetails = $this->recoverUserDetails(); $helper = new UsersRespProcControllerHelper(); $helper->setConnection($connection); $helper->getConnection()->beginTransaction(); $helper->insert($post['user']); $helper->getConnection()->commit(); $logWriter = new LogWriter($connection); $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::atti_concessione, 'message' => "Inserito nuovo responsabile di procedimento, utente " . $userDetails->id, 'type' => 'info', 'backend' => 1)); return $this->redirect()->toRoute('admin/users-responsabili-procedimento', array('lang' => $this->params()->fromRoute('lang'))); }
public function indexAction() { /** * @var \Doctrine\ORM\EntityManager $em */ $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); /** * @var \Doctrine\DBAL\Connection $connection */ $connection = $em->getConnection(); $request = $this->getRequest(); $post = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray()); if (!($request->isXmlHttpRequest() or $request->isPost())) { return $this->redirect()->toRoute('main'); } $mainLayout = $this->initializeAdminArea(); $configurations = $this->layout()->getVariable('configurations'); $userDetails = $this->recoverUserDetails(); $id = $post['deleteId']; $helper = new PostsControllerHelper(); $helper->setEntityManager($em); $helper->setConnection($connection); $helper->setLoggedUser($userDetails); try { $records = $helper->recoverWrapperRecordsById(new PostsGetterWrapper(new PostsGetter($em)), array('id' => $id, 'limit' => 1, 'fields' => 'p.image'), $id); $helper->checkRecords('Dati post corrente non trovati'); /* Delete images from file system */ $currentImage = isset($records[0]['image']) ? $records[0]['image'] : null; if ($currentImage) { $mediaDir = $helper->checkMediaDir($configurations); $mediaProject = $helper->checkMediaProject($configurations); /* Delete old image */ $oldImageThumbPath = $mediaDir . $mediaProject . '/blogs/thumbs/' . $currentImage; $oldImageBigPath = $mediaDir . $mediaProject . '/blogs/big/' . $currentImage; if (file_exists($oldImageThumbPath) and $currentImage != '') { unlink($oldImageThumbPath); } if (file_exists($oldImageBigPath) and $currentImage != '') { unlink($oldImageBigPath); } } /* Delete Post from database */ $helper->getConnection()->beginTransaction(); $helper->delete($id, ModulesContainer::blogs); $helper->getConnection()->commit(); $logWriter = new LogWriter($connection); $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::blogs, 'message' => "Eliminato post blog " . $id, 'type' => 'info', 'reference_id' => $id, 'backend' => 1)); return $this->redirect()->toUrl($this->url()->fromRoute('admin/blogs-summary', array('lang' => $this->params()->fromRoute('lang'), 'languageSelection' => $this->params()->fromRoute('languageSelection'), 'page' => $this->params()->fromRoute('page'), 'modulename' => $this->params()->fromRoute('modulename')))); } catch (\Exception $e) { try { $helper->getConnection()->rollBack(); } catch (\Doctrine\DBAL\ConnectionException $exDb) { } $logWriter = new LogWriter($connection); $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::blogs, 'message' => "Errore eliminazione blog post", 'type' => 'error', 'description' => $e->getMessage(), 'reference_id' => $id, 'backend' => 1)); $this->layout()->setVariables(array('messageType' => 'danger', 'messageTitle' => 'Errore eliminazione blog post', 'messageText' => $e->getMessage(), 'messageShowFormLink' => 1, 'messageShowForm' => "Torna all'elenco posts", 'templatePartial' => 'message.phtml')); $this->layout()->setTemplate($mainLayout); } }
public function indexAction() { /** * @var \Doctrine\ORM\EntityManager $em */ $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); /** * @var \Doctrine\DBAL\Connection $connection */ $connection = $em->getConnection(); $request = $this->getRequest(); $post = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray()); if (!($request->isXmlHttpRequest() or $request->isPost())) { return $this->redirect()->toRoute('main'); } $inputFilter = new UsersRolesFormInputFilter(); $form = new UsersRolesForm(); $form->setBindOnValidate(false); $form->setInputFilter($inputFilter->getInputFilter()); $form->setData($post); $this->initializeAdminArea(); $userDetails = $this->recoverUserDetails(); $helper = new UsersRolesControllerHelper(); $helper->setConnection($connection); $helper->getConnection()->beginTransaction(); try { if (!$form->isValid()) { throw new NullException("The form is not valid"); } $inputFilter->exchangeArray($form->getData()); $helper->setLoggedUser($userDetails); $userRoleRecord = $helper->recoverWrapperRecords(new UsersRolesGetterWrapper(new UsersRolesGetter($em)), array('name' => $inputFilter->name)); if (!empty($userRoleRecord)) { throw new NullException("Il nome ruolo inserito è già presente in archivio"); } $lastInsertId = $helper->insert($inputFilter); if ($inputFilter->adminAccess == 1 and empty($inputFilter->permissions)) { throw new NullException("Aggiungere almeno un permesso al ruolo"); } if (!empty($inputFilter->permissions)) { foreach ($inputFilter->permissions as $key => $value) { $helper->insertPermissionRelation($lastInsertId, $value); } } $logWriter = new LogWriter($connection); $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::contenuti_id, 'message' => "Inserito nuovo ruolo utente " . $inputFilter->name, 'type' => 'info', 'reference_id' => $lastInsertId, 'backend' => 1)); $this->layout()->setVariables(array('messageType' => 'success', 'messageTitle' => 'Ruolo utente inserito correttamente', 'messageText' => 'I dati sono stati processati correttamente dal sistema', 'showLinkResetFormAndShowIt' => 1, 'backToSummaryLink' => $this->url()->fromRoute('admin/users-roles-summary', array('lang' => $this->params()->fromRoute('lang'))), 'backToSummaryText' => "Elenco ruoli")); $helper->getConnection()->commit(); } catch (\Exception $e) { try { $helper->getConnection()->rollBack(); } catch (\Doctrine\DBAL\ConnectionException $e) { } $logWriter = new LogWriter($connection); $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::contenuti_id, 'message' => "Errore inserimento nuovo ruolo utente: " . $inputFilter->name, 'type' => 'error', 'description' => $e->getMessage(), 'backend' => 1)); $this->layout()->setVariables(array('messageType' => 'danger', 'messageTitle' => 'Errore inserimento nuovo ruolo utente', 'messageText' => $e->getMessage(), 'form' => $form, 'formInputFilter' => $inputFilter->getInputFilter(), 'messageShowFormLink' => 1, 'messageShowForm' => 'Torna al form di inserimento dati')); } $this->layout()->setTemplate($this->layout()->getVariable('templateDir') . 'message.phtml'); }
public function indexAction() { /** * @var \Doctrine\ORM\EntityManager $em */ $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); /** * @var \Doctrine\DBAL\Connection $connection */ $connection = $em->getConnection(); $request = $this->getRequest(); $post = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray()); if (!($request->isXmlHttpRequest() or $request->isPost())) { return $this->redirect()->toRoute('main'); } $inputFilter = new PostsCategoriesFormInputFilter(); $form = new PostsCategoriesForm(); $form->setBindOnValidate(false); $form->setInputFilter($inputFilter->getInputFilter()); $form->setData($post); $this->initializeAdminArea(); $userDetails = $this->recoverUserDetails(); $helper = new PostsCategoriesControllerHelper(); $helper->setConnection($connection); $helper->getConnection()->beginTransaction(); try { if (!$form->isValid()) { throw new NullException("The form is not valid"); } $inputFilter->exchangeArray($form->getData()); $helper->setLoggedUser($userDetails); $inputFilter->moduleId = ModulesContainer::recoverIdFromModuleCode($this->params()->fromRoute('modulename')); $languageRecords = $helper->recoverWrapperRecords(new LanguagesGetterWrapper(new LanguagesGetter($em)), array('abbrev1' => $this->params()->fromRoute('languageSelection'), 'fields' => 'languages.id')); $helper->checkRecords($languageRecords, 'Nessun dato relativo alle lingue'); $inputFilter->languageId = $languageRecords[0]['id']; $inputFilter->moduleId = ModulesContainer::recoverIdFromModuleCode($this->params()->fromRoute('formtype')); $lastInsertId = $helper->insert($inputFilter); $helper->getConnection()->commit(); $logWriter = new LogWriter($connection); $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::blogs, 'message' => "Inserita nuova categoria " . $this->params()->fromRoute('formtype') . ' ' . $inputFilter->name, 'type' => 'info', 'reference_id' => $lastInsertId, 'backend' => 1)); $this->layout()->setVariables(array('messageType' => 'success', 'messageTitle' => 'Categoria inserita correttamente', 'messageText' => 'I dati sono stati processati correttamente dal sistema', 'showLinkResetFormAndShowIt' => 1, 'backToSummaryLink' => $this->url()->fromRoute('admin/posts-categories-summary', array('lang' => $this->params()->fromRoute('lang'), 'languageSelection' => $this->params()->fromRoute('languageSelection'), 'moduleCode' => $this->params()->fromRoute('formtype'))), 'backToSummaryText' => "Elenco categorie")); } catch (\Exception $e) { try { $helper->getConnection()->rollBack(); } catch (\Doctrine\DBAL\ConnectionException $e) { } $logWriter = new LogWriter($connection); $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::contenuti_id, 'message' => "Errore inserimento nuova categoria: " . $inputFilter->name, 'type' => 'error', 'description' => $e->getMessage(), 'backend' => 1)); $this->layout()->setVariables(array('messageType' => 'danger', 'messageTitle' => 'Errore inserimento nuova categoria', 'messageText' => 'Messaggio generato: ' . $e->getMessage(), 'form' => $form, 'formInputFilter' => $inputFilter->getInputFilter(), 'messageShowFormLink' => 1, 'messageShowForm' => 'Torna al form di inserimento dati')); } $this->layout()->setTemplate($this->layout()->getVariable('templateDir') . 'message.phtml'); }
public function indexAction() { $id = $this->params()->fromPost('id'); /** * @var \Doctrine\ORM\EntityManager $em */ $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); /** * @var \Doctrine\DBAL\Connection $connection */ $connection = $em->getConnection(); $request = $this->getRequest(); $post = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray()); if (!($request->isXmlHttpRequest() or $request->isPost())) { return $this->redirect()->toRoute('main'); } $mainLayout = $this->initializeAdminArea(); $userDetails = $this->recoverUserDetails(); $helper = new AttachmentsControllerHelper(); $helper->setConnection($connection); $helper->getConnection()->beginTransaction(); try { $helper->setLoggedUser($userDetails); $attachmentRecord = $helper->recoverWrapperRecordsById(new AttachmentsGetterWrapper(new AttachmentsGetter($em)), array('id' => $post['deleteId'], 'limit' => 1), $post['deleteId']); $helper->checkRecords($attachmentRecord, 'Dati file allegato non trovati'); $configurations = $this->layout()->getVariable('configurations'); $s3 = new S3($configurations['amazon_s3_accesskey'], $configurations['amazon_s3_secretkey']); $s3->deleteObject($configurations['amazon_s3_bucket'], $this->params()->fromRoute('modulename') . '/' . $attachmentRecord[0]['name']); $helper->deleteAttachments($post['deleteId']); $helper->deleteAttachmentsRelations($post['deleteId']); $logWriter = new LogWriter($connection); $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::recoverIdFromModuleCode($this->params()->fromRoute('modulename')), 'message' => "Eliminato file allegato ", 'type' => 'info', 'reference_id' => $id, 'backend' => 1)); $helper->getConnection()->commit(); $referer = $this->getRequest()->getHeader('Referer'); if (is_object($referer)) { return $this->redirect()->toUrl($referer->getUri()); } } catch (\Exception $e) { try { $helper->getConnection()->rollBack(); } catch (\Doctrine\DBAL\ConnectionException $dbEx) { } $logWriter = new LogWriter($connection); $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::contenuti_id, 'message' => "Errore eliminazione file allegato", 'type' => 'error', 'description' => $e->getMessage(), 'reference_id' => $id, 'backend' => 1)); $referer = $this->getRequest()->getHeader('Referer'); if (is_object($referer)) { $refererLink = $referer->getUri(); } $this->layout()->setVariables(array('messageType' => 'danger', 'messageTitle' => 'Errore eliminazione file allegato', 'messageText' => $e->getMessage(), 'previousPageLink' => isset($refererLink) ? $refererLink : null, 'previousPageLabel' => "Torna all'elenco allegati", 'templatePartial' => "message.phtml")); } $this->layout()->setTemplate($mainLayout); }
public function indexAction() { /** * @var \Doctrine\ORM\EntityManager $em */ $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); /** * @var \Doctrine\DBAL\Connection $connection */ $connection = $em->getConnection(); $request = $this->getRequest(); $post = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray()); if (!($request->isXmlHttpRequest() or $request->isPost())) { return $this->redirect()->toRoute('main'); } $inputFilter = new OperatoriFormInputFilter(); $form = new OperatoriForm(); $form->setBindOnValidate(false); $form->setInputFilter($inputFilter->getInputFilter()); $form->setData($post); $this->initializeAdminArea(); $userDetails = $this->recoverUserDetails(); $helper = new OperatoriControllerHelper(); $helper->setConnection($connection); $helper->getConnection()->beginTransaction(); try { if (!$form->isValid()) { throw new NullException("The form is not valid"); } $inputFilter->exchangeArray($form->getData()); $helper->setLoggedUser($userDetails); if (!$helper->isValidCodiceFiscale($inputFilter->cf) and !$helper->isValidPartitaIVA($inputFilter->cf)) { throw new NullException("Codice fiscale o Partita IVA non valido"); } $lastInsertId = $helper->insert($inputFilter); $logWriter = new LogWriter($connection); $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::contratti_pubblici_id, 'message' => "Inserita nuova sezione " . $inputFilter->nome, 'type' => 'info', 'reference_id' => $lastInsertId, 'backend' => 1)); $this->layout()->setVariables(array('messageType' => 'success', 'messageTitle' => 'Azienda inserita correttamente', 'messageText' => 'I dati sono stati processati correttamente dal sistema', 'showLinkResetFormAndShowIt' => 1, 'backToSummaryLink' => $this->url()->fromRoute('admin/contratti-pubblici-operatori-summary', array('lang' => $this->params()->fromRoute('lang'))), 'backToSummaryText' => "Elenco aziende", 'insertAgainLabel' => "Inserisci un'altra azienda")); $helper->getConnection()->commit(); } catch (\Exception $e) { try { $helper->getConnection()->rollBack(); } catch (\Doctrine\DBAL\ConnectionException $e) { } $logWriter = new LogWriter($connection); $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::contratti_pubblici_id, 'message' => "Errore inserimento nuova azienda: " . $inputFilter->nome, 'type' => 'error', 'description' => $e->getMessage(), 'backend' => 1)); $this->layout()->setVariables(array('messageType' => 'danger', 'messageTitle' => 'Errore inserimento nuova azienda', 'messageText' => $e->getMessage(), 'form' => $form, 'formInputFilter' => $inputFilter->getInputFilter(), 'messageShowFormLink' => 1, 'messageShowForm' => 'Torna al form di inserimento dati')); } $this->layout()->setTemplate($this->layout()->getVariable('templateDir') . 'message.phtml'); }
public function indexAction() { /** * @var \Doctrine\ORM\EntityManager $em */ $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); /** * @var \Doctrine\DBAL\Connection $connection */ $connection = $em->getConnection(); $request = $this->getRequest(); $post = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray()); if (!($request->isXmlHttpRequest() or $request->isPost())) { return $this->redirect()->toRoute('main'); } $inputFilter = new SezioniFormInputFilter(); $form = new SezioniForm(); $form->setBindOnValidate(false); $form->setInputFilter($inputFilter->getInputFilter()); $form->setData($post); $this->initializeAdminArea(); $userDetails = $this->recoverUserDetails(); $helper = new SezioniControllerHelper(); $helper->setConnection($connection); $helper->getConnection()->beginTransaction(); $helper->setLoggedUser($userDetails); try { if (!$form->isValid()) { throw new NullException("The form is not valid"); } $inputFilter->exchangeArray($form->getData()); $helper->update($inputFilter); $helper->getConnection()->commit(); // TODO: upload icon, delete old icon if old icon is set and its file exists $logWriter = new LogWriter($connection); $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::contenuti_id, 'message' => "Aggiornata sezione " . $inputFilter->nome, 'type' => 'info', 'reference_id' => $inputFilter->id, 'backend' => 1)); $this->layout()->setVariables(array('messageType' => 'success', 'messageTitle' => 'Sezione aggiornata correttamente', 'messageText' => 'I dati sono stati processati correttamente dal sistema', 'messageShowFormLink' => 1, 'messageShowForm' => 'Torna alla sezione', 'backToSummaryLink' => $this->url()->fromRoute('admin/sezioni-summary', array('lang' => $this->params()->fromRoute('lang'), 'languageSelection' => $this->params()->fromRoute('languageSelection'), 'modulename' => $this->params()->fromRoute('modulename'))), 'backToSummaryText' => "Elenco sezioni")); $this->layout()->setTemplate($this->layout()->getVariable('templateDir') . 'message.phtml'); } catch (\Exception $e) { try { $helper->getConnection()->rollBack(); } catch (\Doctrine\DBAL\ConnectionException $exDb) { } $logWriter = new LogWriter($connection); $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::contenuti_id, 'message' => "Errore aggiornamento sezione ", 'type' => 'error', 'description' => $e->getMessage(), 'reference_id' => $inputFilter->id, 'backend' => 1)); $this->layout()->setVariables(array('messageType' => 'danger', 'messageTitle' => 'Errore aggiornamento sezione', 'messageText' => $e->getMessage(), 'form' => $form, 'formInputFilter' => $inputFilter->getInputFilter(), 'messageShowFormLink' => 1, 'messageShowForm' => 'Torna alla sezione')); $this->layout()->setTemplate($this->layout()->getVariable('templateDir') . 'message.phtml'); } }
public function indexAction() { /** * @var \Doctrine\ORM\EntityManager $em */ $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); /** * @var \Doctrine\DBAL\Connection $connection */ $connection = $em->getConnection(); $request = $this->getRequest(); $post = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray()); if (!($request->isXmlHttpRequest() or $request->isPost())) { return $this->redirect()->toRoute('main'); } $inputFilter = new AttiConcessioneFormInputFilter(); $form = new AttiConcessioneForm(); $form->setBindOnValidate(false); $form->setInputFilter($inputFilter->getInputFilter()); $form->setData($post); $this->initializeAdminArea(); $userDetails = $this->recoverUserDetails(); $helper = new AttiConcessioneControllerHelper(); $helper->setConnection($connection); $helper->getConnection()->beginTransaction(); try { if (!$form->isValid()) { throw new NullException("The form is not valid"); } $inputFilter->exchangeArray($form->getData()); $helper->setLoggedUser($userDetails); $inputFilter->progressivo = $helper->recoverNumeroProgressivo(new AttiConcessioneGetterWrapper(new AttiConcessioneGetter($em)), $inputFilter->anno); $lastInsertId = $helper->insert($inputFilter); $logWriter = new LogWriter($connection); $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::atti_concessione, 'message' => "Inserito nuovo atto concessione " . $inputFilter->titolo, 'type' => 'info', 'reference_id' => $lastInsertId, 'backend' => 1)); $this->layout()->setVariables(array('messageType' => 'success', 'messageTitle' => 'Atto concessione inserito correttamente', 'messageText' => 'I dati sono stati processati correttamente dal sistema', 'showLinkResetFormAndShowIt' => 1, 'backToSummaryLink' => $this->url()->fromRoute('admin/atti-concessione-summary', array('lang' => 'it', 'languageSelection' => 'it', 'modulename' => 'atti-concessione')), 'backToSummaryText' => "Elenco atti", 'insertAgainLabel' => "Inserisci un altro atto")); $helper->getConnection()->commit(); } catch (\Exception $e) { try { $helper->getConnection()->rollBack(); } catch (\Doctrine\DBAL\ConnectionException $e) { } $logWriter = new LogWriter($connection); $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::atti_concessione, 'message' => "Errore inserimento nuovo atto concessione: " . $inputFilter->titolo, 'type' => 'error', 'description' => $e->getMessage(), 'backend' => 1)); $this->layout()->setVariables(array('messageType' => 'danger', 'messageTitle' => 'Errore inserimento nuovo atto di concessione', 'messageText' => 'Messaggio generato: ' . $e->getMessage(), 'form' => $form, 'formInputFilter' => $inputFilter->getInputFilter(), 'messageShowFormLink' => 1, 'messageShowForm' => 'Torna al form di inserimento dati')); } $this->layout()->setTemplate($this->layout()->getVariable('templateDir') . 'message.phtml'); }
public function indexAction() { /** * @var \Doctrine\ORM\EntityManager $em */ $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); /** * @var \Doctrine\DBAL\Connection $connection */ $connection = $em->getConnection(); $request = $this->getRequest(); $post = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray()); if (!($request->isXmlHttpRequest() or $request->isPost())) { return $this->redirect()->toRoute('main'); } $inputFilter = new SezioniFormInputFilter(); $form = new SezioniForm(); $form->setBindOnValidate(false); $form->setInputFilter($inputFilter->getInputFilter()); $form->setData($post); $this->initializeAdminArea(); $userDetails = $this->recoverUserDetails(); $helper = new SezioniControllerHelper(); $helper->setConnection($connection); $helper->getConnection()->beginTransaction(); try { if (!$form->isValid()) { throw new NullException("The form is not valid"); } $inputFilter->exchangeArray($form->getData()); $helper->setLoggedUser($userDetails); $helper->insert($inputFilter); $lastInsertId = $helper->getConnection()->lastInsertId(); $helper->getConnection()->commit(); $logWriter = new LogWriter($connection); $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::albo_pretorio_id, 'message' => "Inserita nuova sezione " . $inputFilter->nome, 'type' => 'info', 'reference_id' => $lastInsertId, 'backend' => 1)); $this->layout()->setVariables(array('messageType' => 'success', 'messageTitle' => 'Sezione inserita correttamente', 'messageText' => 'Inserire almeno una sottosezione relativa o la stessa non sarà visibile sul sito web.', 'showLinkResetFormAndShowIt' => 1, 'backToSummaryLink' => $this->url()->fromRoute('admin/sezioni-summary', array('lang' => $this->params()->fromRoute('lang'), 'languageSelection' => $this->params()->fromRoute('languageSelection'), 'modulename' => $this->params()->fromRoute('modulename'))), 'backToSummaryText' => "Elenco sezioni", 'insertAgainLabel' => "Inserisci un'altra sezione")); } catch (\Exception $e) { try { $helper->getConnection()->rollBack(); } catch (\Doctrine\DBAL\ConnectionException $exDb) { } $logWriter = new LogWriter($connection); $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::contenuti_id, 'message' => "Errore inserimento nuova sezione: " . $inputFilter->nome, 'type' => 'error', 'description' => $e->getMessage(), 'backend' => 1)); $this->layout()->setVariables(array('messageType' => 'danger', 'messageTitle' => 'Errore inserimento nuova sezione', 'messageText' => 'Messaggio generato: ' . $e->getMessage(), 'form' => $form, 'formInputFilter' => $inputFilter->getInputFilter(), 'messageShowFormLink' => 1, 'messageShowForm' => 'Torna al form di inserimento dati')); } $this->layout()->setTemplate($this->layout()->getVariable('templateDir') . 'message.phtml'); }
public function indexAction() { /** * @var \Doctrine\ORM\EntityManager $em */ $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); /** * @var \Doctrine\DBAL\Connection $connection */ $connection = $em->getConnection(); $request = $this->getRequest(); $post = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray()); if (!($request->isXmlHttpRequest() or $request->isPost())) { return $this->redirect()->toRoute('main'); } $inputFilter = new AlboPretorioArticoliFormInputFilter(); $form = new AlboPretorioArticoliForm(); $form->setBindOnValidate(false); $form->setInputFilter($inputFilter->getInputFilter()); $form->setData($post); $this->initializeAdminArea(); $userDetails = $this->recoverUserDetails(); $helper = new AlboPretorioControllerHelper(); $helper->setConnection($connection); $helper->getConnection()->beginTransaction(); try { if (!$form->isValid()) { throw new NullException("The form is not valid"); } $inputFilter->exchangeArray($form->getData()); $helper->setLoggedUser($userDetails); $lastInsertId = $helper->insert($inputFilter); // TODO: insert in home page if homepage == 1, facebook post if facebook == 1 and all settings about fb are ok $helper->getConnection()->commit(); $logWriter = new LogWriter($connection); $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::albo_pretorio_id, 'message' => "Inserito nuovo atto albo pretorio " . $inputFilter->titolo, 'type' => 'info', 'reference_id' => $lastInsertId, 'backend' => 1)); $this->layout()->setVariables(array('messageType' => 'success', 'messageTitle' => 'Atto albo pretorio inserito correttamente', 'messageText' => 'I dati sono stati processati correttamente dal sistema', 'showLinkResetFormAndShowIt' => 1, 'backToSummaryLink' => $this->url()->fromRoute('admin/albo-pretorio-summary', array('lang' => $this->params()->fromRoute('lang'))), 'backToSummaryText' => "Elenco atti albo pretorio", 'insertAgainLabel' => "Inserisci un altro atto", 'attachmentsLink' => $this->url()->fromRoute('admin/attachments-summary', array('lang' => $this->params()->fromRoute('lang'), 'module' => 'albo-pretorio', 'referenceId' => $lastInsertId)))); } catch (\Exception $e) { try { $helper->getConnection()->rollBack(); } catch (\Doctrine\DBAL\ConnectionException $dbEx) { } $logWriter = new LogWriter($connection); $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::albo_pretorio_id, 'message' => "Errore inserimento atto albo pretorio " . $inputFilter->titolo, 'description' => $e->getMessage(), 'reference_id' => isset($lastInsertId) ? $lastInsertId : 0, 'type' => 'error', 'backend' => 1)); $this->layout()->setVariables(array('messageType' => 'danger', 'messageTitle' => 'Errore inserimento dati', 'messageText' => $e->getMessage(), 'form' => $form, 'formInputFilter' => $inputFilter->getInputFilter(), 'messageShowFormLink' => 1, 'messageShowForm' => 'Torna al form di inserimento dati')); } $this->layout()->setTemplate($this->layout()->getVariable('templateDir') . 'message.phtml'); }
public function indexAction() { $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); /** * @var \Doctrine\DBAL\Connection $connection */ $connection = $em->getConnection(); $request = $this->getRequest(); $post = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray()); if (!($request->isXmlHttpRequest() or $request->isPost())) { return $this->redirect()->toRoute('main'); } $modulename = $this->params()->fromRoute('modulename'); /* $modulenameLabel = str_replace("-", " ", $modulename); */ $inputFilter = new ContenutiFormInputFilter(); $form = new ContenutiForm(); $form->setBindOnValidate(false); $form->setInputFilter($inputFilter->getInputFilter()); $form->setData($post); $this->initializeAdminArea(); $userDetails = $this->recoverUserDetails(); try { if (!$form->isValid()) { throw new NullException("The form is not valid"); } $inputFilter->exchangeArray($form->getData()); $helper = new ContenutiControllerHelper(); $helper->setConnection($connection); $helper->setLoggedUser($userDetails); $helper->getConnection()->beginTransaction(); $lastInsertId = $helper->insert($inputFilter); // TODO: insert in home, update home field if home is selected $helper->setLogWriter(new LogWriter($connection)); $helper->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::contenuti_id, 'message' => "Inserito nuovo contenuto \\ articolo " . $inputFilter->titolo, 'type' => 'info', 'reference_id' => $lastInsertId, 'backend' => 1)); $this->layout()->setVariables(array('messageType' => 'success', 'messageTitle' => 'Articolo inserito correttamente', 'messageText' => 'I dati sono stati processati correttamente dal sistema', 'showLinkResetFormAndShowIt' => 1, 'backToSummaryLink' => $this->url()->fromRoute('admin/contenuti-summary', array('lang' => $this->params()->fromRoute('lang'), 'languageSelection' => $this->params()->fromRoute('languageSelection'), 'modulename' => $modulename)), 'backToSummaryText' => "Elenco contenuti", 'insertAgainLabel' => "Inserisci un altro articolo \\ contenuto", 'attachmentsLink' => $this->url()->fromRoute('admin/attachments-summary', array('lang' => $this->params()->fromRoute('languageSelection'), 'module' => 'contenuti', 'referenceId' => $lastInsertId)))); $helper->getConnection()->commit(); $this->layout()->setTemplate($this->layout()->getVariable('templateDir') . 'message.phtml'); } catch (\Exception $e) { $logWriter = new LogWriter($connection); $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::contenuti_id, 'message' => "Errore inserimento nuovo contenuto \\ articolo: " . $inputFilter->titolo, 'description' => $e->getMessage() . "; Titolo: " . $inputFilter->titolo . " Testo: " . $inputFilter->testo . ' Sottosezione: ' . $inputFilter->sottosezione, 'type' => 'error', 'backend' => 1)); $this->layout()->setVariables(array('messageType' => 'danger', 'messageTitle' => 'Errore inserimento contenuto \\ articolo', 'messageText' => $e->getMessage(), 'form' => $form, 'formInputFilter' => $inputFilter->getInputFilter(), 'messageShowFormLink' => 1, 'messageShowForm' => 'Torna al form di inserimento dati')); $this->layout()->setTemplate($this->layout()->getVariable('templateDir') . 'message.phtml'); } }
public function indexAction() { /** * @var \Doctrine\ORM\EntityManager $em */ $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); /** * @var \Doctrine\DBAL\Connection $connection */ $connection = $em->getConnection(); $request = $this->getRequest(); $post = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray()); if (!($request->isXmlHttpRequest() or $request->isPost())) { return $this->redirect()->toRoute('main'); } $inputFilter = new ContrattiPubbliciFormInputFilter(); $form = new ContrattiPubbliciForm(); $form->setBindOnValidate(false); $form->setInputFilter($inputFilter->getInputFilter()); $form->setData($post); $this->initializeAdminArea(); $userDetails = $this->recoverUserDetails(); try { if (!$form->isValid()) { throw new NullException("The form is not valid"); } $inputFilter->exchangeArray($form->getData()); $helper = new ContrattiPubbliciControllerHelper(); $helper->setConnection($connection); $helper->getConnection()->beginTransaction(); $helper->update($inputFilter); $helper->getConnection()->commit(); $helper->setLogWriter(new LogWriter($connection)); $helper->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::contenuti_id, 'message' => "Aggiornato il bando di gara " . $inputFilter->titolo, 'reference_id' => $userDetails->id, 'type' => 'info', 'backend' => 1)); $this->layout()->setVariables(array('messageType' => 'success', 'messageTitle' => 'Bando di gara aggiornato correttamente', 'messageText' => 'I dati sono stati processati correttamente dal sistema', 'messageShowFormLink' => 1, 'messageShowForm' => 'Torna al form', 'backToSummaryLink' => $this->url()->fromRoute('admin/contratti-pubblici-summary', array('lang' => $this->params()->fromRoute('lang'))), 'backToSummaryText' => "Elenco settori utente", 'attachmentsLink' => $this->url()->fromRoute('admin/attachments-summary', array('lang' => $this->params()->fromRoute('lang'), 'module' => 'contratti-pubblici', 'referenceId' => $inputFilter->id)))); $this->layout()->setTemplate($this->layout()->getVariable('templateDir') . 'message.phtml'); } catch (\Exception $e) { $logWriter = new LogWriter($connection); $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::contenuti_id, 'message' => "Errore nell'aggiornamento contratto pubblico " . $inputFilter->titolo, 'description' => $e->getMessage(), 'reference_id' => $inputFilter->id, 'type' => 'error', 'backend' => 1)); $this->layout()->setVariables(array('messageType' => 'danger', 'messageTitle' => 'Errore aggiornamento contratto pubblico', 'messageText' => $e->getMessage(), 'messageShowFormLink' => 1, 'messageShowForm' => "Torna ai dati del bando di gara", 'form' => $form, 'formInputFilter' => $inputFilter->getInputFilter())); } $this->layout()->setTemplate($this->layout()->getVariable('templateDir') . 'message.phtml'); }
/** * Contratto details */ public function detailsAction() { $mainLayout = $this->initializeFrontendWebsite(); $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); $id = $this->params()->fromRoute('id'); try { $helper = new ContrattiPubbliciControllerHelper(); $wrapper = $helper->recoverWrapperById(new ContrattiPubbliciGetterWrapper(new ContrattiPubbliciGetter($em)), array('id' => $id, 'attivo' => 1, 'limit' => 1), $id); $attoRecord = $wrapper->getRecords(); $helper->checkRecords($attoRecord, 'Nessun atto albo pretorio trovato'); $wrapper->setEntityManager($em); $records = $wrapper->addAttachmentsFromRecords($attoRecord, array('moduleId' => ModulesContainer::albo_pretorio_id, 'noScaduti' => 1, 'orderBy' => 'a.position')); $this->layout()->setVariables(array('records' => $records, 'templatePartial' => 'contratti-pubblici/contratti-pubblici-details.phtml')); } catch (\Exception $e) { $logWriter = new LogWriter($em->getConnection()); $logWriter->writeLog(array('user_id' => 0, 'module_id' => ModulesContainer::contratti_pubblici_id, 'message' => "Errore visualizzazione contratti pubblici sul sito pubblico", 'description' => $e->getMessage(), 'reference_id' => 0, 'type' => 'error', 'backend' => 0)); $this->layout()->setVariables(array('messageType' => 'secondary', 'moduleLabel' => "Bandi di gara e contratti", 'messageTitle' => "Nessun bando di gara in archivio", 'messageText' => "Impossibile visualizzare i dati richiesti", 'templatePartial' => 'message.phtml')); } $this->layout()->setTemplate($mainLayout); }
/** * @return \Zend\Http\Response */ public function indexAction() { $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); /** * @var \Doctrine\DBAL\Connection $connection */ $connection = $em->getConnection(); $request = $this->getRequest(); $post = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray()); if (!($request->isXmlHttpRequest() or $request->isPost())) { return $this->redirect()->toRoute('main'); } $inputFilter = new ContenutiTabellaFormInputFilter(); $form = new ContenutiTabellaForm(); $form->setBindOnValidate(false); $form->setInputFilter($inputFilter->getInputFilter()); $form->setData($post); $this->initializeAdminArea(); $userDetails = $this->recoverUserDetails(); try { if (!$form->isValid()) { throw new NullException("The form is not valid"); } $inputFilter->exchangeArray($form->getData()); $helper = new ContenutiControllerHelper(); $helper->setConnection($connection); $helper->getConnection()->beginTransaction(); $helper->updateTabella($inputFilter); $helper->getConnection()->commit(); $logWriter = new LogWriter($connection); $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::amministrazione_trasparente_id, 'message' => "Aggiornata tabella articolo " . $inputFilter->titolo, 'type' => 'info', 'reference_id' => $inputFilter->id, 'backend' => 1)); $this->layout()->setVariables(array('messageType' => 'success', 'messageTitle' => 'Articolo aggiornato correttamente', 'messageText' => 'I dati sono stati processati correttamente dal sistema', 'messageShowFormLink' => 1, 'messageShowForm' => "Torna alla tabella artcolo")); $this->layout()->setTemplate($this->layout()->getVariable('templateDir') . 'message.phtml'); } catch (\Exception $e) { $logWriter = new LogWriter($connection); $logWriter->writeLog(array('user_id' => isset($userDetails->id) ? $userDetails->id : null, 'module_id' => ModulesContainer::amministrazione_trasparente_id, 'message' => "Errore aggiornamento tabella articolo amm. trasparente ", 'type' => 'error', 'description' => $e->getMessage(), 'reference_id' => $inputFilter->id, 'backend' => 1)); $this->layout()->setVariables(array('messageType' => 'danger', 'messageTitle' => 'Errore aggiornamento tabella articolo amm. trasparente', 'messageText' => 'Messaggio generato: ' . $e->getMessage(), 'form' => $form, 'formInputFilter' => $inputFilter->getInputFilter(), 'messageShowFormLink' => 1, 'messageShowForm' => "Torna alla tabella dell'articolo amm. trasparente")); $this->layout()->setTemplate($this->layout()->getVariable('templateDir') . 'message.phtml'); } }
/** * @expectedException \ModelModule\Model\NullException */ public function testWriteLogThrowsExceptionForInvalidData() { unset($this->logToWrite['module_id']); $this->logWriter->writeLog($this->logToWrite); }
/** * @param array $logArray * @return bool */ protected function log(array $logArray) { $em = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager'); $log = new LogWriter($em->getConnection()); return $log->writeLog($logArray); }
/** * Delete element from home page: recover blockID, remove record from homepage, update related module home flag * * @return \Zend\Http\Response */ public function removeAction() { $mainLayout = $this->initializeAdminArea(); $referenceId = $this->params()->fromRoute('referenceid'); $moduleCode = $this->params()->fromRoute('modulecode'); $moduleId = ModulesContainer::recoverIdFromModuleCode($moduleCode); /** * @var \Doctrine\ORM\EntityManager $em */ $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); $connection = $em->getConnection(); $userDetails = $this->layout()->getVariable('userDetails'); $helper = new HomePagePutRemoveControllerHelper(); $helper->setConnection($em->getConnection()); $helper->getConnection()->beginTransaction(); try { $homePageBlocksRecords = $helper->recoverWrapperRecords(new HomePageBlocksGetterWrapper(new HomePageBlocksGetter($em)), array('fields' => 'homePageBlocks.id', 'moduleId' => $moduleId, 'limit' => 1)); $helper->checkRecords($homePageBlocksRecords, 'Impossibile recuperare i dati relativi al modulo in home page'); $helper->deleteFromHomePage($referenceId, $homePageBlocksRecords[0]['id']); $helper->updateHomeFlag(DbTableContainer::recoverMainTableFromModuleCode($moduleCode), $referenceId, $helper->recoverHomeFlagFromModuleCode($moduleCode), 0); $helper->getConnection()->commit(); $referer = $this->getRequest()->getHeader('Referer'); if (is_object($referer)) { return $this->redirect()->toUrl($referer->getUri()); } return $this->redirect()->toRoute('main'); } catch (\Exception $e) { try { $helper->getConnection()->rollBack(); } catch (\Doctrine\DBAL\ConnectionException $dbEx) { } $logWriter = new LogWriter($connection); $logWriter->writeLog(array('user_id' => isset($userDetails->id) ? $userDetails->id : 1, 'module_id' => ModulesContainer::contenuti_id, 'message' => "Errore nell'operazione di resa visibile bando di gara sul sito pubblico. ID: " . $referenceId, 'type' => 'error', 'reference_id' => $referenceId, 'backend' => 1)); $this->layout()->setVariables(array('messageType' => 'danger', 'messageTitle' => 'Errore verificato', 'messageText' => $e->getMessage(), 'templatePartial' => 'message.phtml')); } $this->layout()->setTemplate($mainLayout); }
public function indexAction() { $id = $this->params()->fromPost('id'); /** * @var \Doctrine\ORM\EntityManager $em */ $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); /** * @var \Doctrine\DBAL\Connection $connection */ $connection = $em->getConnection(); $request = $this->getRequest(); $post = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray()); if (!($request->isXmlHttpRequest() or $request->isPost())) { return $this->redirect()->toRoute('main'); } $mainLayout = $this->initializeAdminArea(); $configurations = $this->layout()->getVariable('configurations'); $userDetails = $this->recoverUserDetails(); $moduleId = $this->params()->fromRoute('modulename') == 'contenuti' ? ModulesContainer::contenuti_id : ModulesContainer::amministrazione_trasparente_id; $helper = new ContenutiControllerHelper(); try { $contentRecord = $helper->recoverWrapperRecordsById(new ContenutiGetterWrapper(new ContenutiGetter($em)), array('id' => $post['deleteId'], 'limit' => 1), $post['deleteId']); $helper->checkRecords($contentRecord, 'Articolo da eliminare non trovato'); $helper->setConnection($connection); $helper->getConnection()->beginTransaction(); $helper->delete($post['deleteId']); $helper->getConnection()->commit(); /* Delte Attachments files */ $attachmentsHelper = new AttachmentsControllerHelper(); $attachmentsHelper->setConnection($connection); $attachmentsRecords = $helper->recoverWrapperRecords(new AttachmentsGetterWrapper(new AttachmentsGetter($em)), array('referenceId' => $post['deleteId'], 'moduleId' => $moduleId)); if (!empty($attachmentsRecords)) { foreach ($attachmentsRecords as $attachmentRecord) { $attachmentsHelper->deleteAttachments($attachmentsRecords['id']); $attachmentsHelper->deleteAttachmentsRelations($attachmentsRecords['id']); $s3 = new S3($configurations['amazon_s3_accesskey'], $configurations['amazon_s3_secretkey']); $s3->deleteObject($configurations['amazon_s3_bucket'], $this->params()->fromRoute('modulename') . '/' . $attachmentRecord[0]['name']); } } /* Delete from home page */ $homeHelper = new HomePagePutRemoveControllerHelper(); $homePageRecords = $homeHelper->recoverWrapperRecords(new HomePageGetterWrapper(new HomePageGetter($em)), array('referenceId' => $post['deleteId'], 'moduleId' => $moduleId, 'moduleCode' => $this->params()->fromRoute('modulename'))); if (!empty($homePageRecords)) { $homePageBlocksRecords = $helper->recoverWrapperRecords(new HomePageBlocksGetterWrapper(new HomePageBlocksGetter($em)), array('fields' => 'homePageBlocks.id', 'moduleId' => $moduleId, 'limit' => 1)); $helper->checkRecords($homePageBlocksRecords, 'Impossibile recuperare i dati relativi al modulo in home page'); $homeHelper->setConnection($connection); $homeHelper->getConnection()->beginTransaction(); $homeHelper->deleteFromHomePage($post['deleteId'], $homePageBlocksRecords[0]['id']); $homeHelper->getConnection()->commit(); } $logWriter = new LogWriter($connection); $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::recoverIdFromModuleCode($this->params()->fromRoute('modulename')), 'message' => "Eliminato articolo " . $contentRecord[0]['titolo'], 'type' => 'info', 'reference_id' => $id, 'backend' => 1)); $referer = $this->getRequest()->getHeader('Referer'); if (is_object($referer)) { return $this->redirect()->toUrl($referer->getUri()); } } catch (\Exception $e) { try { // $helper->getConnection()->rollBack(); } catch (\Doctrine\DBAL\ConnectionException $dbEx) { } $logWriter = new LogWriter($connection); $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::contenuti_id, 'message' => "Errore eliminazione file articolo ", 'type' => 'error', 'description' => $e->getMessage(), 'reference_id' => $id, 'backend' => 1)); $referer = $this->getRequest()->getHeader('Referer'); if (is_object($referer)) { $refererLink = $referer->getUri(); } $this->layout()->setVariables(array('messageType' => 'danger', 'messageTitle' => 'Errore eliminazione contenuto', 'messageText' => $e->getMessage(), 'previousPageLink' => isset($refererLink) ? $refererLink : null, 'previousPageLabel' => "Torna all'elenco", 'templatePartial' => "message.phtml")); } $this->layout()->setTemplate($mainLayout); }
public function indexAction() { /** * @var \Doctrine\ORM\EntityManager $em */ $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); /** * @var \Doctrine\DBAL\Connection $connection */ $connection = $em->getConnection(); $request = $this->getRequest(); if (!($request->isXmlHttpRequest() or $request->isPost())) { return $this->redirect()->toRoute('main'); } $post = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray()); $inputFilter = new AttachmentsFormInputFilter(); $moduleCode = $this->params()->fromRoute('modulename'); $form = new AttachmentsForm(); $form->setBindOnValidate(false); $form->setInputFilter($inputFilter->getInputFilter()); $form->setData($post); $this->initializeAdminArea(); $userDetails = $this->recoverUserDetails(); $helper = new AttachmentsControllerHelper(); $helper->setConnection($connection); $helper->getConnection()->beginTransaction(); $s3Helper = new S3Helper(); try { if (!$form->isValid()) { throw new NullException("The form is not valid"); } $inputFilter->exchangeArray($form->getData()); $helper->setLoggedUser($userDetails); $configurations = $this->layout()->getVariable('configurations'); $s3AccessKey = isset($configurations['amazon_s3_accesskey']) ? $configurations['amazon_s3_accesskey'] : null; $s3SecretKey = isset($configurations['amazon_s3_secretkey']) ? $configurations['amazon_s3_secretkey'] : null; $s3Helper->setAccessKey($s3AccessKey); $s3Helper->setSecretKey($s3SecretKey); $s3Helper->setBucket(isset($configurations['amazon_s3_bucket']) ? $configurations['amazon_s3_bucket'] : null); $s3Helper->setS3Directory($inputFilter->s3_directory); $s3Helper->setS3(new S3($s3AccessKey, $s3SecretKey)); $mimeRecords = $helper->recoverWrapperRecords(new AttachmentsMimetypeGetterWrapper(new AttachmentsMimetypeGetter($em)), array('mimetype' => $inputFilter->attachmentFile['type'], 'limit' => 1)); $helper->checkRecords($mimeRecords, "Il tipo di file inserito non è supportato. Per ulteriori informazioni contattare l'amministrazione"); $lastInsertId = $helper->insertAttachments($inputFilter, $mimeRecords[0]['id']); $attachmentFileName = $s3Helper->assignFileName($inputFilter->attachmentFile['name'], $lastInsertId); $helper->updateAttachmentsFilename($lastInsertId, $attachmentFileName); $helper->insertAttachmentsRelations($inputFilter, $lastInsertId); $s3Helper->upload($inputFilter->attachmentFile['tmp_name'], $attachmentFileName); $logWriter = new LogWriter($connection); $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::recoverIdFromModuleCode($moduleCode), 'message' => "Inserito nuovo allegato " . $inputFilter->title, 'type' => 'info', 'reference_id' => $lastInsertId, 'backend' => 1)); $this->layout()->setVariables(array('messageType' => 'success', 'messageTitle' => 'Allegato inserito correttamente', 'messageText' => 'I dati sono stati processati correttamente dal sistema', 'showLinkResetFormAndShowIt' => 1, 'backToSummaryText' => "Elenco file allegati", 'insertAgainLabel' => "Inserisci un altro file allegato", 'attachmentsLabel' => 'Elenco allegati', 'attachmentsLink' => $this->url()->fromRoute('admin/attachments-summary', array('lang' => $this->params()->fromRoute('lang'), 'module' => $moduleCode, 'referenceId' => $inputFilter->referenceId)))); $helper->getConnection()->commit(); } catch (\Exception $e) { try { $helper->getConnection()->rollBack(); } catch (\Doctrine\DBAL\ConnectionException $dbEx) { } $logWriter = new LogWriter($connection); $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::recoverIdFromModuleCode($moduleCode), 'message' => "Errore inserimento nuovo file allegato: " . $inputFilter->title, 'type' => 'error', 'description' => $e->getMessage(), 'backend' => 1)); $this->layout()->setVariables(array('messageType' => 'danger', 'messageTitle' => 'Errore inserimento file allegato', 'messageText' => $e->getMessage(), 'form' => $form, 'formInputFilter' => $inputFilter->getInputFilter(), 'messageShowFormLink' => 1, 'messageShowForm' => 'Torna al form di inserimento dati')); } $this->layout()->setTemplate($this->layout()->getVariable('templateDir') . 'message.phtml'); }
public function indexAction() { /** * @var \Doctrine\ORM\EntityManager $em */ $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); /** * @var \Doctrine\DBAL\Connection $connection */ $connection = $em->getConnection(); $request = $this->getRequest(); $post = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray()); if (!($request->isXmlHttpRequest() or $request->isPost())) { return $this->redirect()->toRoute('main'); } $inputFilter = new TicketsFormInputFilter(); $form = new TicketsForm(); $form->setBindOnValidate(false); $form->setInputFilter($inputFilter->getInputFilter()); $form->setData($post); $this->initializeAdminArea(); $userDetails = $this->recoverUserDetails(); $configurations = $this->layout()->getVariable('configurations'); $helper = new TicketsControllerHelper(); $helper->setConnection($connection); $helper->getConnection()->beginTransaction(); try { if (!$form->isValid()) { throw new NullException("The form is not valid"); } $inputFilter->exchangeArray($form->getData()); $helper->setLoggedUser($userDetails); $helper->insertTicket($inputFilter); $lastInsertId = $helper->getConnection()->lastInsertId(); $helper->insertTicketMessage($inputFilter, $lastInsertId); $helper->getConnection()->commit(); /* $usersRecords = $helper->recoverWrapperRecords( new UsersGetterWrapper(new UsersGetter($em)), array('roleName' => 'WebMaster') ); $helper->checkRecords($usersRecords, 'Nessun utente a cui inviare la segnalazione è stato trovato'); foreach($usersRecords as $user) { $message = new Message(); $message->addTo($user['email']) ->addFrom('*****@*****.**') ->setSubject('Nuova richiesta di assistenza da '.$configurations['sitename']) ->setBody($inputFilter->message); $transport = new SendmailTransport(); $transport->send($message); } */ /* Send email */ $message = new Message(); $message->addTo('*****@*****.**')->addFrom('*****@*****.**')->setSubject('Nuova richiesta di assistenza da ' . $configurations['sitename'])->setBody($inputFilter->message); $transport = new SendmailTransport(); $transport->send($message); $logWriter = new LogWriter($connection); $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::contenuti_id, 'message' => "Nuova richiesta assistenza " . $inputFilter->subject, 'type' => 'info', 'reference_id' => $lastInsertId, 'backend' => 1)); $this->layout()->setVariables(array('messageType' => 'success', 'messageTitle' => 'Nuova richiesta assistenza inviata correttamente', 'messageText' => 'Riceverete una risposta nel più breve tempo possibile', 'showLinkResetFormAndShowIt' => 1, 'backToSummaryLink' => $this->url()->fromRoute('admin/tickets-summary', array('lang' => $this->params()->fromRoute('lang'))), 'backToSummaryText' => "Elenco richieste")); } catch (\Exception $e) { try { $helper->getConnection()->rollBack(); } catch (\Doctrine\DBAL\ConnectionException $ex) { } $logWriter = new LogWriter($connection); $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::contenuti_id, 'message' => "Errore inserimento nuova richiesta assistenza: " . $inputFilter->subject, 'type' => 'error', 'description' => $e->getMessage(), 'backend' => 1)); $this->layout()->setVariables(array('messageType' => 'danger', 'messageTitle' => 'Errore inserimento nuova richiesta assistenza', 'messageText' => $e->getMessage(), 'form' => $form, 'formInputFilter' => $inputFilter->getInputFilter(), 'messageShowFormLink' => 1, 'messageShowForm' => 'Torna al form di inserimento dati')); } $this->layout()->setTemplate($this->layout()->getVariable('templateDir') . 'message.phtml'); }
public function indexAction() { /** * @var \Doctrine\ORM\EntityManager $em */ $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); /** * @var \Doctrine\DBAL\Connection $connection */ $connection = $em->getConnection(); $request = $this->getRequest(); $post = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray()); if (!($request->isXmlHttpRequest() or $request->isPost())) { return $this->redirect()->toRoute('main'); } $inputFilter = new PostsFormInputFilter(); $form = new PostsForm(); $form->setBindOnValidate(false); $form->setInputFilter($inputFilter->getInputFilter()); $form->setData($post); $this->initializeAdminArea(); $userDetails = $this->recoverUserDetails(); $configurations = $this->layout()->getVariable('configurations'); $helper = new PostsControllerHelper(); $helper->setConnection($connection); $helper->getConnection()->beginTransaction(); try { if (!$form->isValid()) { throw new NullException("The form is not valid"); } $inputFilter->exchangeArray($form->getData()); $publicDirPath = $helper->recoverPublicDirPath($this->layout()->getVariable('isPublicDirOnRoot')); $mediaDir = $helper->checkMediaDir($configurations); $mediaProject = $helper->checkMediaProject($configurations); $helper->checkMediaSubDir($configurations); $languageRecords = $helper->recoverWrapperRecords(new LanguagesGetterWrapper(new LanguagesGetter($em)), array('abbrev1' => $this->params()->fromRoute('languageSelection'), 'fields' => 'languages.id')); $helper->checkRecords($languageRecords, 'Nessun dato relativo alle lingue'); $inputFilter->languageId = $languageRecords[0]['id']; $inputFilter->moduleId = ModulesContainer::blogs; $helper->setLoggedUser($userDetails); $helper->insert($inputFilter); $lastInsertId = $helper->getConnection()->lastInsertId(); /* Create thumbnail and upload big image*/ if ($inputFilter->image) { $imagePathInfo = pathinfo($inputFilter->image['name']); $newFilename = $lastInsertId . '_' . uniqid() . '.' . $imagePathInfo['extension']; $thumbWitdth = isset($configurations['blogs_image_width']) ? $configurations['blogs_image_width'] : 160; $thumbHeight = isset($configurations['blogs_image_height']) ? $configurations['blogs_image_height'] : 130; $imagine = new \Imagine\Gd\Imagine(); $imagine->open($inputFilter->image['tmp_name'])->thumbnail(new \Imagine\Image\Box($thumbWitdth, $thumbHeight), \Imagine\Image\ImageInterface::THUMBNAIL_INSET)->save($publicDirPath . $mediaDir . $mediaProject . '/blogs/thumbs/' . $newFilename); move_uploaded_file($inputFilter->image['tmp_name'], $publicDirPath . $mediaDir . $mediaProject . '/blogs/big/' . $newFilename); $helper->updateImage($lastInsertId, $newFilename); } /* Insert Relations */ foreach ($inputFilter->categories as $category) { $helper->insertRelation($inputFilter, $lastInsertId, $category); } $logWriter = new LogWriter($connection); $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::blogs, 'message' => "Inserita nuovo blog post " . $inputFilter->title, 'type' => 'info', 'reference_id' => $lastInsertId, 'backend' => 1)); $this->layout()->setVariables(array('messageType' => 'success', 'messageTitle' => 'Blog post inserito correttamente', 'messageText' => 'I dati sono stati processati correttamente dal sistema', 'showLinkResetFormAndShowIt' => 1, 'backToSummaryLink' => $this->url()->fromRoute('admin/blogs-summary', array('lang' => $this->params()->fromRoute('lang'), 'languageSelection' => $this->params()->fromRoute('languageSelection'))), 'backToSummaryText' => "Elenco posts", 'attachmentsLink' => $this->url()->fromRoute('admin/attachments-summary', array('lang' => $this->params()->fromRoute('lang'), 'module' => 'blogs', 'referenceId' => $lastInsertId)), 'insertAgainLabel' => "Inserisci un altro post")); $helper->getConnection()->commit(); } catch (\Exception $e) { try { $helper->getConnection()->rollBack(); } catch (\Doctrine\DBAL\ConnectionException $ex) { } $logWriter = new LogWriter($connection); $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::blogs, 'message' => "Errore inserimento nuovo blog post: " . $inputFilter->title, 'type' => 'error', 'description' => $e->getMessage(), 'backend' => 1)); $this->layout()->setVariables(array('messageType' => 'danger', 'messageTitle' => 'Errore inserimento nuovo blog post', 'messageText' => 'Messaggio generato: ' . $e->getMessage(), 'form' => $form, 'formInputFilter' => $inputFilter->getInputFilter(), 'messageShowFormLink' => 1, 'messageShowForm' => 'Torna al form di inserimento dati')); } $this->layout()->setTemplate($this->layout()->getVariable('templateDir') . 'message.phtml'); }
/** * Form login user authentication * * @return Redirect * @throws Exception */ public function authenticateAction() { $redirect = 'login'; $request = $this->getRequest(); $entityManager = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); $appServiceLoader = $this->recoverAppServiceLoader(); $configurations = $appServiceLoader->recoverService('configurations'); $helper = new SetupAbstractControllerHelper(); $helper->setConfigurations($configurations); $helper->setRequest($request); $helper->setupZf2appDir(); $helper->setupAppDirRelativePath(); $formValidator = new UserFormAuthenticationInputFilter(); $form = new UserFormAuthentication(); $form->setInputFilter($formValidator->getInputFilter()); if ($request->isPost()) { $form->setData($request->getPost()); if ($form->isValid()) { // Check authentication... $this->getAuthService()->getAdapter()->setIdentity($request->getPost('username'))->setCredential($request->getPost('password')); $result = $this->getAuthService()->authenticate(); foreach ($result->getMessages() as $message) { $this->flashmessenger()->addMessage($message); } if ($result->isValid()) { $redirect = 'admin'; // set session timeout stored in MyAuthStorage class... $this->getSessionStorage()->setRememberMe(); // set storage into the auth service $this->getAuthService()->setStorage($this->getSessionStorage()); $this->getAuthService()->getStorage()->write($request->getPost('username')); // Search user into db $usersGetterWrapper = new UsersGetterWrapper(new UsersGetter($entityManager)); $usersGetterWrapper->setInput(array('username' => $request->getPost('username'), 'password' => $request->getPost('password'), 'adminAccess' => 1, 'limit' => 1)); $usersGetterWrapper->setupQueryBuilder(); $records = $usersGetterWrapper->getRecords(); if (isset($records) and count($records) == 1) { $records = $records[0]; // Set ACL $aclSetter = new AclSetter(new Acl()); $aclSetter->setUsersRolesGetterWrapper(new UsersRolesGetterWrapper(new UsersRolesGetter($entityManager))); $aclSetter->addRoles($aclSetter->recoverRoles(array())); if ($records['roleName'] === 'WebMaster') { // Assign all permissions $aclSetter->getAcl()->allow($records['roleName']); $wrapper = new UsersRolesPermissionsGetterWrapper(new UsersRolesPermissionsGetter($entityManager)); $wrapper->setInput(array()); $wrapper->setupQueryBuilder(); $permissionsRecords = $wrapper->getRecords(); if (empty($permissionsRecords)) { throw new NullException("Error: no permissions stored on database!"); } foreach ($permissionsRecords as $permissionsRecord) { $aclSetter->getAcl()->addResource($permissionsRecord['flag']); $aclSetter->getAcl()->allow($records['roleName'], $permissionsRecord['flag']); } } else { $wrapper = new UsersRolesPermissionsRelationsGetterWrapper(new UsersRolesPermissionsRelationsGetter($entityManager)); $wrapper->setInput(array('roleId' => $records['roleId'])); $wrapper->setupQueryBuilder(); $permissionsRecords = $wrapper->getRecords(); if (empty($permissionsRecords)) { throw new NullException("Error: no permissions stored on database!"); } foreach ($permissionsRecords as $permissionsRecord) { $aclSetter->getAcl()->addResource($permissionsRecord['flag']); $aclSetter->getAcl()->allow($records['roleName'], $permissionsRecord['flag']); } } $sitename = $configurations['sitename']; if (!$sitename) { throw new NullException('Site name is not set. Cannot complete the login'); } $ckFinderUploadDir = $helper->getAppDirRelativePath() . '/public/' . $configurations['media_dir'] . $configurations['media_project'] . 'ckfinder_files'; $userDetails = new \stdClass(); $userDetails->sitename = $sitename; $userDetails->id = $records['id']; $userDetails->name = $records['name']; $userDetails->surname = $records['surname']; $userDetails->email = $records['email']; $userDetails->acl = $aclSetter->getAcl(); $userDetails->salt = $records['salt']; $userDetails->passwordLastUpdate = $records['passwordLastUpdate']; $userDetails->role = $records['roleName']; /* Set user session values */ $sessionContainer = new SessionContainer(); $sessionContainer->offsetSet('userDetails', $userDetails); $sessionContainer->offsetSet('ckFinderUploadDir', $ckFinderUploadDir); /* Regenerate Session ID after login */ $manager = new \Zend\Session\SessionManager(); $manager->regenerateId(); /* Log entering admin area */ $logWriter = new LogWriter($entityManager->getConnection()); $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => ModulesContainer::contenuti_id, 'message' => "Ingresso nell'area riservata", 'description' => $records['name'] . ' ' . $records['surname'] . " ha effettuato un ingresso nell'area riservata", 'type' => 'info', 'reference_id' => 0, 'backend' => 1)); } else { $this->flashmessenger()->addMessage(print_r("Nome utente e \\ o password non validi", 1)); } } } else { $sessionContainer = new SessionContainer(); $loginFailures = $sessionContainer->offsetGet('loginFailures'); $sessionContainer->offsetSet('loginFailures', $loginFailures); foreach ($form->getMessages() as $message) { $this->flashmessenger()->addMessage(print_r($message, 1)); } } } return $this->redirect()->toRoute($redirect, array("lang" => 'it')); }
public function indexAction() { /** * @var \Doctrine\ORM\EntityManager $em */ $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); /** * @var \Doctrine\DBAL\Connection $connection */ $connection = $em->getConnection(); $request = $this->getRequest(); $post = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray()); if (!($request->isXmlHttpRequest() or $request->isPost())) { return $this->redirect()->toRoute('main'); } $inputFilter = new PostsFormInputFilter(); $form = new PostsForm(); $form->setBindOnValidate(false); $form->setInputFilter($inputFilter->getInputFilter()); $form->setData($post); $this->initializeAdminArea(); $configurations = $this->layout()->getVariable('configurations'); $userDetails = $this->recoverUserDetails(); $moduleId = ModulesContainer::photo; try { if (!$form->isValid()) { throw new NullException("The form is not valid"); } $inputFilter->exchangeArray($form->getData()); $helper = new PostsControllerHelper(); $helper->setConnection($connection); $helper->getConnection()->beginTransaction(); $helper->setLoggedUser($userDetails); $publicDirPath = $helper->recoverPublicDirPath($this->layout()->getVariable('isPublicDirOnRoot')); if ($inputFilter->image) { $records = $helper->recoverWrapperRecordsById(new PostsGetterWrapper(new PostsGetter($em)), array('id' => $inputFilter->id, 'limit' => 1, 'fields' => 'p.image'), $inputFilter->id); $helper->checkRecords('Dati foto corrente non trovati'); $currentImage = isset($records[0]['image']) ? $records[0]['image'] : null; $mediaDir = $helper->checkMediaDir($configurations); $mediaProject = $helper->checkMediaProject($configurations); /* Delete old image */ $oldImageThumbPath = $publicDirPath . $mediaDir . $mediaProject . 'photo/thumbs/' . $currentImage; $oldImageBigPath = $publicDirPath . $mediaDir . $mediaProject . 'photo/big/' . $currentImage; if (file_exists($oldImageThumbPath) and $currentImage != '') { unlink($oldImageThumbPath); } if (file_exists($oldImageBigPath) and $currentImage != '') { unlink($oldImageBigPath); } $imagePathInfo = pathinfo($inputFilter->image['name']); $newFilename = $inputFilter->id . '_' . uniqid() . '.' . $imagePathInfo['extension']; $thumbWitdth = isset($configurations['photo_image_width']) ? $configurations['photo_image_width'] : 160; $thumbHeight = isset($configurations['photo_image_height']) ? $configurations['photo_image_height'] : 130; $imagine = new \Imagine\Gd\Imagine(); $imagine->open($inputFilter->image['tmp_name'])->thumbnail(new \Imagine\Image\Box($thumbWitdth, $thumbHeight), \Imagine\Image\ImageInterface::THUMBNAIL_INSET)->save($publicDirPath . $mediaDir . $mediaProject . '/photo/thumbs/' . $newFilename); move_uploaded_file($inputFilter->image['tmp_name'], $publicDirPath . $mediaDir . $mediaProject . '/photo/big/' . $newFilename); $inputFilter->image = $newFilename; } $helper->update($inputFilter); /* Delete old relations */ $helper->deleteRelation($inputFilter->id, $moduleId); /* Insert Relations */ foreach ($inputFilter->categories as $category) { $inputFilter->moduleId = $moduleId; $helper->insertRelation($inputFilter, $inputFilter->id, $category); } $helper->getConnection()->commit(); $logWriter = new LogWriter($connection); $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => $moduleId, 'message' => "Aggiornata foto " . $inputFilter->title, 'type' => 'info', 'reference_id' => $inputFilter->id, 'backend' => 1)); $this->layout()->setVariables(array('messageType' => 'success', 'messageTitle' => 'Foto aggiornata correttamente', 'messageText' => 'I dati sono stati processati correttamente dal sistema', 'messageShowFormLink' => 1, 'messageShowForm' => "Torna ai dati della foto", 'backToSummaryLink' => $this->url()->fromRoute('admin/photo-summary', array('lang' => $this->params()->fromRoute('lang'), 'languageSelection' => $this->params()->fromRoute('languageSelection'))), 'backToSummaryText' => "Elenco foto")); $this->layout()->setTemplate($this->layout()->getVariable('templateDir') . 'message.phtml'); } catch (\Exception $e) { try { $helper->getConnection()->rollBack(); } catch (\Doctrine\DBAL\ConnectionException $exDb) { } $logWriter = new LogWriter($connection); $logWriter->writeLog(array('user_id' => $userDetails->id, 'module_id' => $moduleId, 'message' => "Errore aggiornamento foto", 'type' => 'error', 'description' => $e->getMessage(), 'reference_id' => $inputFilter->id, 'backend' => 1)); $this->layout()->setVariables(array('messageType' => 'danger', 'messageTitle' => 'Errore aggiornamento foto', 'messageText' => $e->getMessage(), 'form' => $form, 'formInputFilter' => $inputFilter->getInputFilter(), 'messageShowFormLink' => 1, 'messageShowForm' => "Torna all'elenco foto")); $this->layout()->setTemplate($this->layout()->getVariable('templateDir') . 'message.phtml'); } }