コード例 #1
0
 /**
  * Function for validating and changing the Password
  *
  * @param unknown $password            
  * @return boolean
  */
 public function validateChangePassword($password)
 {
     $userPassword = new UserEncryption();
     $session = new Container('User');
     $passMsg = array('passChange' => 0, 'passSame' => 0, 'passNotSame' => 0);
     try {
         // ////Checking the Old Password is valid or not//////
         $old_password = $userPassword->create($password['old_password']);
         $sql = new Sql($this->getAdapter());
         $select = $sql->select()->from($this->table)->columns(array('password'))->where(array('id' => $session->offsetGet('userId'), 'password' => $old_password));
         $statement = $sql->prepareStatementForSqlObject($select);
         $data = $this->resultSetPrototype->initialize($statement->execute())->toArray();
         if (count($data)) {
             // ///////Password is Valid now change the Password/////
             $userPasswordData['userId'] = $session->offsetGet('userId');
             $userPasswordData['password'] = $password['new_password'];
             if ($this->changeUserPassword($userPasswordData)) {
                 $passMsg['passChange'] = 1;
             } else {
                 $passMsg['passSame'] = 1;
             }
             return $passMsg;
         } else {
             // ///// Password is not valid ///////////
             $passMsg['passNotSame'] = 1;
             return $passMsg;
         }
     } catch (\Exception $e) {
         throw new \Exception($e->getPrevious()->getMessage());
     }
 }
コード例 #2
0
ファイル: Module.php プロジェクト: schoolMsoftware/schoolm
 function boforeDispatch(MvcEvent $event)
 {
     include 'config/constant.php';
     $response = $event->getResponse();
     $controller = $event->getRouteMatch()->getParam('controller');
     $module_array = explode("\\", $controller);
     if ($module_array[0] == 'Admin') {
         $action = $event->getRouteMatch()->getParam('action');
         $requestedResourse = $controller . "\\" . $action;
         $session = new Container('User');
         if ($session->offsetExists('user')) {
             if (in_array($requestedResourse, $GLOBALS['PAGE_BEFORE_LOGIN'])) {
                 $url = $GLOBALS['SITE_ADMIN_URL'] . 'dashboard/add';
                 $response->setHeaders($response->getHeaders()->addHeaderLine('Location', $url));
                 $response->setStatusCode(302);
             }
         } else {
             if ($requestedResourse != 'Admin\\Controller\\Index\\index' && !in_array($requestedResourse, $GLOBALS['PAGE_BEFORE_LOGIN'])) {
                 $url = $GLOBALS['SITE_ADMIN_URL'] . 'index/login';
                 $response->setHeaders($response->getHeaders()->addHeaderLine('Location', $url));
                 $response->setStatusCode(302);
             }
             $response->sendHeaders();
         }
     }
 }
コード例 #3
0
ファイル: Module.php プロジェクト: samsonasik/unnamed
 /**
  * Handle layout titles onDispatch.
  *
  * @param MvcEvent $event
  */
 public function setTitleAndTranslation(MvcEvent $event)
 {
     $route = $event->getRouteMatch();
     $title = $this->service->get('ControllerPluginManager')->get('systemsettings');
     $viewHelper = $this->service->get('ViewHelperManager');
     $lang = new Container('translations');
     $translator = $this->service->get('translator');
     /*
      * Load translations.
      */
     $renderer = $this->service->get('ViewManager')->getRenderer();
     $renderer->plugin('formRow')->setTranslator($translator, 'SD_Translations');
     $renderer->plugin('formCollection')->setTranslator($translator, 'SD_Translations');
     $renderer->plugin('formLabel')->setTranslator($translator, 'SD_Translations');
     $renderer->plugin('formSelect')->setTranslator($translator, 'SD_Translations');
     $renderer->plugin('formSubmit')->setTranslator($translator, 'SD_Translations');
     AbstractValidator::setDefaultTranslator($translator, 'formandtitle');
     $translator->setLocale($lang->offsetGet('languageName'))->setFallbackLocale('en');
     $viewModel = $event->getViewModel();
     $viewModel->setVariable('lang', $translator->getLocale());
     /*
      * Custom flash messenger.
      */
     $msg = $lang->offsetGet('flashMessages');
     $viewModel->setVariable('flashMessages', $msg);
     /*
      * Load page title
      */
     $action = $route->getParam('post') ? ' - ' . $route->getParam('post') : ucfirst($route->getParam('__CONTROLLER__'));
     $headTitleHelper = $viewHelper->get('headTitle');
     $headTitleHelper->append($title->__invoke('general', 'site_name') . ' ' . $action);
 }
コード例 #4
0
ファイル: PostRedirectGet.php プロジェクト: ninahuanca/zf2
 public function __invoke($redirect, $redirectToUrl = false)
 {
     $controller = $this->getController();
     $request = $controller->getRequest();
     $container = new Container('prg_post1');
     if ($request->isPost()) {
         $container->setExpirationHops(1, 'post');
         $container->post = $request->getPost()->toArray();
         if (method_exists($controller, 'getPluginManager')) {
             // get the redirect plugin from the plugin manager
             $redirector = $controller->getPluginManager()->get('Redirect');
         } else {
             /*
              * if the user wants to redirect to a route, the redirector has to come
              * from the plugin manager -- otherwise no router will be injected
              */
             if ($redirectToUrl === false) {
                 throw new RuntimeException('Could not redirect to a route without a router');
             }
             $redirector = new Redirect();
         }
         if ($redirectToUrl === false) {
             return $redirector->toRoute($redirect);
         }
         return $redirector->toUrl($redirect);
     } else {
         if ($container->post !== null) {
             $post = $container->post;
             unset($container->post);
             return $post;
         }
         return false;
     }
 }
コード例 #5
0
 /**
  * @param MvcEvent $e
  * @return mixed|void
  */
 public function onDispatch(MvcEvent $e)
 {
     $this->sessionContainer->getDefaultManager()->forgetMe();
     $this->sessionContainer->getDefaultManager()->expireSessionCookie();
     $this->sessionContainer->getDefaultManager()->destroy();
     $this->redirect()->toRoute('frontend');
 }
コード例 #6
0
ファイル: Module.php プロジェクト: tineo/webapoyopublicitario
 public function onBootstrap($e)
 {
     $e->getApplication()->getEventManager()->getSharedManager()->attach('Zend\\Mvc\\Controller\\AbstractActionController', 'dispatch', function ($e) {
         $controller = $e->getTarget();
         $controllerClass = get_class($controller);
         $moduleNamespace = substr($controllerClass, 0, strpos($controllerClass, '\\'));
         $config = $e->getApplication()->getServiceManager()->get('config');
         if (isset($config['module_layouts'][$moduleNamespace])) {
             $controller->layout($config['module_layouts'][$moduleNamespace]);
         }
     }, 100);
     $session = new Container('base');
     if (!$session->offsetExists('language')) {
         if (substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) == "es") {
             $session->offsetSet('language', "es_ES");
         } elseif (substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) == "en") {
             $session->offsetSet('language', "en_US");
         }
     }
     $e->getApplication()->getServiceManager()->get('translator')->setLocale($session->offsetGet('language'));
     $e->getApplication()->getServiceManager()->get('translator');
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
 }
コード例 #7
0
ファイル: Module.php プロジェクト: tsens/UsersACL
 /**
  * Before Dispatch Function
  *
  * @param MvcEvent $event            
  */
 function boforeDispatch(MvcEvent $event)
 {
     $sm = $event->getApplication()->getServiceManager();
     $config = $sm->get('Config');
     $list = $config['whitelist'];
     $name = $sm->get('request')->getUri()->getPath();
     $controller = $event->getRouteMatch()->getParam('controller');
     $action = $event->getRouteMatch()->getParam('action');
     $session = new Container('User');
     $controller = $event->getRouteMatch()->getParam('controller');
     $action = $event->getRouteMatch()->getParam('action');
     if (!(strpos($name, 'reset-password') || in_array($name, $list)) && $session->offsetExists('userId')) {
         $serviceManager = $event->getApplication()->getServiceManager();
         $roleTable = $serviceManager->get('RoleTable');
         $userRoleTable = $serviceManager->get('UserRoleTable');
         $roleID = $userRoleTable->getUserRoles('user_id = ' . $session->offsetGet('userId'), array('role_id'));
         $roleName = $roleTable->getUserRoles('rid = ' . $roleID[0]['role_id'], array('role_name'));
         $userRole = $roleName[0]['role_name'];
         $acl = $serviceManager->get('Acl');
         $acl->initAcl();
         $status = $acl->isAccessAllowed($userRole, $controller, $action);
         if (!$status) {
             die('Permission denied');
         }
     }
 }
コード例 #8
0
 public function indexAction()
 {
     $mainLayout = $this->initializeFrontendWebsite();
     $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     $page = $this->params()->fromRoute('page');
     $perPage = $this->params()->fromRoute('perpage');
     $sessionContainer = new SessionContainer();
     $sessionSearch = $sessionContainer->offsetGet(StatoCivileSearchController::sessionIdentifier);
     try {
         $helper = new StatoCivileControllerHelper();
         $sezioniRecords = $helper->recoverWrapperRecords(new StatoCivileSezioniGetterWrapper(new StatoCivileSezioniGetter($em)), array());
         $helper->checkRecords($sezioniRecords, 'Nessuna sezione stato civile in archivio');
         $sezioniRecordsForDropdown = $helper->formatForDropwdown($sezioniRecords, 'id', 'nome');
         $wrapper = $helper->recoverWrapperRecordsPaginator(new StatoCivileGetterWrapper(new StatoCivileGetter($em)), array_merge(array('textSearch' => isset($sessionSearch['testo']) ? $sessionSearch['testo'] : null, 'mese' => isset($sessionSearch['mese']) ? $sessionSearch['mese'] : null, 'anno' => isset($sessionSearch['anno']) ? $sessionSearch['anno'] : null, 'sezione' => isset($sessionSearch['sezine']) ? $sessionSearch['sezine'] : null), array('attivo' => 1, 'noScaduti' => 1, 'orderBy' => 'sca.data DESC')), $page, $perPage);
         $wrapper->setEntityManager($em);
         $wrapper->addAttachmentsToPaginatorRecords($wrapper->setupRecords(), array('moduleId' => ModulesContainer::stato_civile_id, 'noScaduti' => 1, 'orderBy' => 'a.position'));
         $paginator = $wrapper->getPaginator();
         $form = new StatoCivileFormSearch();
         $form->addTesto();
         $form->addSezioni($sezioniRecordsForDropdown);
         $form->addMese();
         $form->addAnni();
         $form->addCheckExpired();
         $form->addSubmitButton();
         $form->setData(array('testo' => isset($sessionSearch['testo']) ? $sessionSearch['testo'] : null, 'mese' => isset($sessionSearch['mese']) ? $sessionSearch['mese'] : null, 'anno' => isset($sessionSearch['anno']) ? $sessionSearch['anno'] : null, 'sezione' => isset($sessionSearch['sezione']) ? $sessionSearch['sezione'] : null));
     } catch (\Exception $e) {
         $paginator = null;
     }
     $this->layout()->setVariables(array('sessionSearch' => $sessionSearch, 'paginator' => !empty($paginator) ? $paginator : null, 'emptyRecords' => count($paginator), 'records' => !empty($paginator) ? $paginator : null, 'form' => !empty($form) ? $form : null, 'templatePartial' => 'stato-civile/stato-civile.phtml'));
     $this->layout()->setTemplate($mainLayout);
 }
コード例 #9
0
 public function indexAction()
 {
     $mainLayout = $this->initializeAdminArea();
     $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     $configurations = $this->layout()->getVariable('configurations');
     $page = $this->params()->fromRoute('page');
     $languageSelection = $this->params()->fromRoute('languageSelection');
     $modulename = $this->params()->fromRoute('modulename');
     $sessionContainer = new SessionContainer();
     $sessionSearch = $sessionContainer->offsetGet(SottoSezioniSearchController::sessionIdentifier);
     $helper = new SezioniControllerHelper();
     try {
         $wrapper = $helper->recoverWrapperRecordsPaginator(new SottoSezioniGetterWrapper(new SottoSezioniGetter($em)), array('isAmmTrasparente' => $modulename == 'amministrazione-trasparente' ? 1 : 0, 'languageAbbreviation' => $languageSelection, 'freeSearch' => isset($sessionSearch['testo']) ? $sessionSearch['testo'] : null), $page, null);
         $sezioniRecords = $helper->recoverWrapperRecords(new SezioniGetterWrapper(new SezioniGetter($em)), array('languageAbbreviation' => $languageSelection, 'fields' => 'sezioni.id, sezioni.nome', 'orderBy' => 'sezioni.posizione ASC'));
         $helper->checkRecordset($sezioniRecords, 'Nessuna sezione presente');
         if (!empty($configurations['isMultiLanguage']) == 1) {
             $helper->setLanguagesGetterWrapper(new LanguagesGetterWrapper(new LanguagesGetter($em)));
             $formLanguage = $helper->setupLanguageFormSearch(new LanguagesFormSearch(), array('status' => 1), $languageSelection);
         }
         $formSearch = new SottoSezioniFormSearch();
         $formSearch->addSezioni($helper->formatForDropwdown($sezioniRecords, 'id', 'nome'));
         $formSearch->addSubmitButton();
         $formSearch->setData(!empty($sessionSearch) ? $sessionSearch : array());
         $this->layout()->setVariables(array('tableTitle' => 'Sottosezioni ' . ucfirst(str_replace('-', ' ', $modulename)), 'tableDescription' => $wrapper->getPaginator()->getTotalItemCount() . ' sottosezioni in archivio', 'columns' => array("Nome", "Sezione", " ", " ", " "), 'sessionSearch' => $sessionSearch, 'formLanguage' => isset($formLanguage) ? $formLanguage : null, 'paginator' => $wrapper->getPaginator(), 'records' => $this->formatRecordsToShowOnTable($wrapper->setupRecords()), 'formSearch' => $formSearch, 'templatePartial' => 'datatable/datatable_sottosezioni.phtml'));
     } catch (\Exception $e) {
         $this->layout()->setVariables(array('messageText' => $e->getMessage(), 'templatePartial' => 'message-exception.phtml'));
     }
     $this->layout()->setTemplate($mainLayout);
 }
コード例 #10
0
ファイル: IndexController.php プロジェクト: sonny-one/zero
 public function getdptoAction()
 {
     /*$sid = new Container('base');
          $db_name = $sid->offsetGet('dbNombre');
          $id_db = $sid->offsetGet('id_db');
          $this->dbAdapter=$this->getServiceLocator()->get($db_name);
      
          //Obtenemos datos POST
          $lista = $this->request->getPost();
          $dpto = new UnidadTable($this->dbAdapter);
          $unidad = $dpto->getIdUnidad($lista['dpto']);
          
            
          $result = new ViewModel(array('unidad'=>$unidad));
          $result->setTerminal(true);
          return $result*/
     $status = "nok";
     $error = "";
     $msj = "";
     $sid = new Container('base');
     $db_name = $sid->offsetGet('dbNombre');
     //$id_db = $sid->offsetGet('id_db');
     $this->dbAdapter = $this->getServiceLocator()->get($db_name);
     $id_usuario = $sid->offsetGet('id_usuario');
     $parametro = $this->request->getPost();
     if (isset($id_usuario) && !empty($parametro['dpto'])) {
         $dpto = new UnidadTable($this->dbAdapter);
         $lista = $dpto->getListarDptoByNombre($this->dbAdapter, $parametro['dpto']);
         $nombre = "";
         $titular = "";
         $contacto = "";
         $condicion = "";
         $tabla = "";
         if (count($lista) > 0) {
             $status = "ok";
             $tabla = "<table class='table table-hover'><thead><tr><th>Nombres</th><th>Contacto</th><th></th></tr></thead><tbody>";
             $nombre = $lista[0]['dpto'];
             for ($i = 0; $i < count($lista); $i++) {
                 if ($lista[$i]['titular'] == "1") {
                     $titular = isset($lista[$i]['nombre']) ? $lista[$i]['nombre'] : "";
                     if (isset($lista[$i]['condicion'])) {
                         $condicion = $lista[$i]['condicion'] == "A" ? "Arrendatario" : "Copropetario";
                     }
                     $contacto = isset($lista[$i]['contacto']) ? $lista[$i]['contacto'] : "";
                 } else {
                     $tabla = $tabla . "<tr><td>" . $lista[$i]['nombre'] . "</td><td>" . $lista[$i]['contacto'] . "</td><td>" . $lista[$i]['condicion'] . "</td></tr>";
                 }
             }
             $tabla = $tabla . "</tbody></table>";
         } else {
             $status = "nok";
             $error = "No hay informacion para el departamento: " . $parametro['dpto'];
         }
     } else {
         $error = "La sesion ha finalizado, vuelve a conectarse al sistema";
     }
     $datos = array('status' => $status, 'error' => $error, 'message' => $msj, 'nombre' => $nombre, 'titular' => $titular, 'contacto' => $contacto, 'condicion' => $condicion, 'tabla' => $tabla);
     $result = new JsonModel($datos);
     return $result;
 }
コード例 #11
0
 /**
  * CSV export
  *
  * @return \Zend\Http\Response|\Zend\Stdlib\ResponseInterface
  * @throws \ModelModule\Model\NullException
  */
 public function csvAction()
 {
     if ($this->getRequest()->isPost()) {
         $request = $this->getRequest();
         $post = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray());
         $form = new StatoCivileFormSearch();
         $form->setBindOnValidate(false);
         $form->setData($post);
         if ($form->isValid()) {
             $sessionContainer = new SessionContainer();
             $sessionContainer->offsetSet('statoCivileFormSearch', $post);
             $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
             $wrapper = new StatoCivileGetterWrapper(new StatoCivileGetter($em));
             $wrapper->setInput(array('numero' => isset($post['numero']) ? $post['numero'] : null, 'anno' => isset($post['anno']) ? $post['anno'] : null, 'sezioneId' => isset($post['sezione']) ? $post['sezione'] : null, 'noScaduti' => isset($post['expired']) ? $post['expired'] : null, 'textSearch' => isset($post['testo']) ? $post['testo'] : null, 'orderBy' => 'sca.id DESC', 'limit' => 1500));
             $wrapper->setupQueryBuilder();
             $records = $wrapper->getRecords();
             if (!empty($records)) {
                 $arrayContent = array();
                 $arrayContent[] = array('Titolo', 'Numero \\ Anno', 'Inserito il', 'Scadenza');
                 foreach ($records as $record) {
                     $arrayContent[] = array($record['titolo'], $record['progressivo'] . ' / ' . $record['anno'], $record['data']->format("d-m-Y"), $record['scadenza']->format("d-m-Y"));
                 }
                 $csvExportHelper = new CsvExportHelper();
                 $content = $csvExportHelper->makeCsvLine($arrayContent);
                 $response = $this->getResponse();
                 $response->getHeaders()->addHeaderLine('Content-Type', 'text/csv')->addHeaderLine('Content-Disposition', 'attachment; filename="stato_civile_' . date("dmYHis") . '.csv"')->addHeaderLine('Accept-Ranges', 'bytes')->addHeaderLine('Content-Length', strlen($content));
                 $response->setContent($content);
                 return $response;
             }
         }
     }
     return $this->redirectForUnvalidAccess();
 }
コード例 #12
0
 function boforeDispatch(MvcEvent $event)
 {
     $request = $event->getRequest();
     $response = $event->getResponse();
     $target = $event->getTarget();
     $whiteList = array('Auth\\Controller\\Index-index', 'Auth\\Controller\\Index-logout');
     $requestUri = $request->getRequestUri();
     $controller = $event->getRouteMatch()->getParam('controller');
     $action = $event->getRouteMatch()->getParam('action');
     $requestedResourse = $controller . "-" . $action;
     $session = new Container('User');
     if ($session->offsetExists('email')) {
         if ($requestedResourse == 'Auth\\Controller\\Index-index' || in_array($requestedResourse, $whiteList)) {
             $url = '/';
             $response->setHeaders($response->getHeaders()->addHeaderLine('Location', $url));
             $response->setStatusCode(302);
         } else {
             $serviceManager = $event->getApplication()->getServiceManager();
             $userRole = $session->offsetGet('roleName');
             $acl = $serviceManager->get('Acl');
             $acl->initAcl();
             $status = $acl->isAccessAllowed($userRole, $controller, $action);
             if (!$status) {
                 die('Permission denied');
             }
         }
     } else {
         if ($requestedResourse != 'Auth\\Controller\\Index-index' && !in_array($requestedResourse, $whiteList)) {
             $url = '/login';
             $response->setHeaders($response->getHeaders()->addHeaderLine('Location', $url));
             $response->setStatusCode(302);
         }
         $response->sendHeaders();
     }
 }
コード例 #13
0
 /**
  * @throws BadAuthenticationException
  */
 public function authorize()
 {
     if (!$this->sessionContainer->offsetExists('data')) {
         throw new BadAuthenticationException('You must be first authenticated');
     }
     $this->instagramWrapper->setAccessToken($this->sessionContainer->data);
 }
コード例 #14
0
 public function csvAction()
 {
     if ($this->getRequest()->isPost()) {
         $request = $this->getRequest();
         $post = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray());
         $form = new ContenutiFormSearch();
         $form->addSubmitButton();
         $form->setBindOnValidate(false);
         $form->setData($post);
         if ($form->isValid()) {
             $sessionContainer = new SessionContainer();
             $sessionContainer->offsetSet('contenutiFormSearch', $post);
             $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
             $wrapper = new ContenutiGetterWrapper(new ContenutiGetter($em));
             $wrapper->setInput(array('limit' => 1500));
             $wrapper->setupQueryBuilder();
             $records = $wrapper->getRecords();
             $csvExportHelper = new CsvExportHelper();
             if (!empty($records)) {
                 $arrayContent = array();
                 $arrayContent[] = array('Titolo', 'Sottotitolo', 'Testo');
                 foreach ($records as $record) {
                     $arrayContent[] = array($record['titolo'], $record['sommario'], $record['testo']);
                 }
                 $content = $csvExportHelper->makeCsvLine($arrayContent);
                 $response = $this->getResponse();
                 $response->getHeaders()->addHeaderLine('Content-Type', 'text/csv')->addHeaderLine('Content-Disposition', 'attachment; filename="contenuti_' . date("dmYHis") . '.csv"')->addHeaderLine('Accept-Ranges', 'bytes')->addHeaderLine('Content-Length', strlen($content));
                 $response->setContent($content);
                 return $response;
             }
         }
     }
     return $this->redirectForUnvalidAccess();
 }
コード例 #15
0
 /**
  * @return mixed
  */
 public function indexAction()
 {
     if ($this->getRequest()->isPost()) {
         $request = $this->getRequest();
         $post = $request->getPost()->toArray();
         $inputFilter = new SottoSezioniFormSearchInputFilter();
         $formSearch = new SottoSezioniFormSearch();
         $formSearch->setData($post);
         if ($formSearch->isValid()) {
             $inputFilter->exchangeArray($formSearch->getData());
             $sessioContainer = new SessionContainer();
             $sessioContainer->offsetSet(self::sessionIdentifier, array('testo' => $inputFilter->testo, 'sottosezioni' => $inputFilter->sezioni));
             $referer = $this->getRequest()->getHeader('Referer');
             if (is_object($referer)) {
                 return $this->redirect()->toUrl($referer->getUri());
             }
         }
         $mainLayout = $this->initializeFrontendWebsite();
         $moduleUrl = $this->url()->fromRoute('main', array('lang' => 'it'));
         $referer = $this->getRequest()->getHeader('Referer');
         $refererUrl = is_object($referer) ? $referer->getUri() : $moduleUrl;
         $this->layout()->setVariables(array('formMessages' => $formSearch->getMessages(), 'refererUrl' => $refererUrl, 'moduleUrl' => $moduleUrl, 'moduleLabel' => "Contenuti", 'templatePartial' => 'form-message.phtml'));
         $this->layout()->setTemplate($mainLayout);
     } else {
         $referer = $this->getRequest()->getHeader('Referer');
         if (is_object($referer)) {
             return $this->redirect()->toUrl($referer->getUri());
         }
         return $this->redirect()->toRoute('main');
     }
 }
コード例 #16
0
 /**
  * Set search session
  *
  * @return \Zend\Http\Response
  */
 public function indexAction()
 {
     if ($this->getRequest()->isPost()) {
         $request = $this->getRequest();
         $post = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray());
         $inputFilter = new PostsFormSearchInputFilter();
         $formSearch = new PostsFormSearch();
         $formSearch->setInputFilter($inputFilter->getInputFilter());
         $formSearch->setData($post);
         $currentClass = get_class($this);
         $sessionIdentifier = $currentClass::sessionIdentifier;
         if ($formSearch->isValid()) {
             $inputFilter->exchangeArray($formSearch->getData());
             $formSearch->setData($post);
             $sessioContainer = new SessionContainer();
             $sessioContainer->offsetSet($sessionIdentifier, array('testo' => $inputFilter->testo, 'categories' => $inputFilter->category));
             $referer = $this->getRequest()->getHeader('Referer');
             if (is_object($referer)) {
                 return $this->redirect()->toUrl($referer->getUri());
             }
         }
         $mainLayout = $this->initializeFrontendWebsite();
         $referer = $this->getRequest()->getHeader('Referer');
         $this->layout()->setVariables(array('formMessages' => $formSearch->getMessages(), 'refererUrl' => is_object($referer) ? $referer->getUri() : null, 'moduleLabel' => "Posts", 'templatePartial' => 'form-message.phtml'));
         $this->layout()->setTemplate($mainLayout);
     } else {
         $referer = $this->getRequest()->getHeader('Referer');
         if (is_object($referer)) {
             return $this->redirect()->toUrl($referer->getUri());
         }
         return $this->redirect()->toRoute('main');
     }
 }
コード例 #17
0
 public function loginAction()
 {
     // 		$crypt	= new Cryptography\Service();
     $form = new Login();
     $request = $this->getRequest();
     if ($request->isPost()) {
         //Validate the form
         $formValidator = new LoginValidator();
         $form->setInputFilter($formValidator->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $formData = $form->getData();
             //                 $dbAdapter = $this->authService->getAdapter();
             $authAdapter = $this->authService->getAdapter();
             $authAdapter->setIdentity($formData['email_address']);
             $authAdapter->setCredential($formData['password']);
             // Perform the authentication query, saving the result
             $result = $this->authService->authenticate($authAdapter);
             if ($result->isValid()) {
                 $data = $authAdapter->getResultRowObject(null, 'password');
                 $this->authService->getStorage()->write($data);
                 $sessionContainer = new Container('base');
                 $redirectUrl = $sessionContainer->offsetExists('lastRequest') ? $sessionContainer->offsetGet('lastRequest') : 'home';
                 return $this->redirect()->toRoute($redirectUrl);
             }
         }
         $this->flashMessenger()->addErrorMessage('Validation failed');
     }
     $viewModel = new ViewModel(array('form' => $form, 'errorMessages' => $this->flashMessenger()->getErrorMessages(), 'successMessages' => $this->flashMessenger()->getCurrentSuccessMessages()));
     //         $viewModel->setTerminal(true-); //Remove this if you want your layout to be shown
     return $viewModel;
 }
コード例 #18
0
 public function loginAction()
 {
     $sessao = new Container();
     $id = $this->params()->fromRoute("id") ? $this->params()->fromRoute("id") : null;
     $request = $this->getRequest();
     if (empty($sessao->usuario)) {
         if ($request->isPost()) {
             $senha = $request->getPost('senha');
             $usuario = $request->getPost('usuario');
             if (!empty($senha) && !empty($usuario)) {
                 $user = new Login();
                 $user = $this->getLoginTable()->getLogin($usuario, $senha);
                 if (!$user) {
                     $this->redirect()->toRoute('errologin');
                 } else {
                     $sessao->usuario = $usuario;
                     $sessao->registro = time();
                     $this->redirect()->toRoute('dashboard');
                 }
             }
         }
     } else {
         if (!isset($id)) {
             $this->redirect()->toRoute('dashboard');
         } else {
             $sessao->getManager()->getStorage()->clear();
             $this->redirect()->toRoute('login');
         }
     }
 }
コード例 #19
0
ファイル: BreadcrumbFactory.php プロジェクト: odegroot/ers
 public function reset()
 {
     $clearance = new Container('forrest');
     $clearance->getManager()->getStorage()->clear('forrest');
     $this->forrest = new Container('forrest');
     $this->forrest->trace = new \ArrayObject();
 }
コード例 #20
0
 public function logoutAction()
 {
     $this->getAuthService()->getStorage()->clear();
     $user_session = new Container('webshop');
     $user_session->getManager()->destroy();
     return $this->redirect()->toRoute('webshop/product');
 }
コード例 #21
0
ファイル: UsoFnc.php プロジェクト: sonny-one/zero
     <table class="table ' . $clase . '">
            <thead>
               <tr>
               <th><i class="fa fa-cutlery"> - ' . $alias . '</i></th>
            </tr>                                                
           </thead>
           <tbody>
           <tr>
           <td>' . $titulo . '<br/>
           <span>Cap. nejo
           </span>' . $cupo . '<br/>
           <strong>' . $estado . '</strong><br/>
           G: $ ' . $garantia . '<br/>
           R: $ ' . $reserva . '<br/>
           ' . $flag . '
           </td>
           </tr>
     </tbody>
     </table>       
     </div>
     </div></a>';
 }
 public static function detalleRsvQuincho($fecha, $titulo, $alias, $cap, $rsv, $gar, $horario)
 {
     $sid = new Container('base');
     $dpto = $sid->offsetGet('dpto');
     $botones = '';
     $cnt = 0;
     for ($j = 0; $j < count($horario); $j++) {
         $marcar = "class='A1 btn btn-outline btn-success'";
         $unidad = $horario[$j]['unidad'] == "" ? "" : $horario[$j]['unidad'];
         $status = $horario[$j]['valor'] == "" ? "Disponible" : $horario[$j]['valor'];
         $resta = "-";
         if ($status == "Reserva") {
コード例 #22
0
 /**
  * @return object | null
  */
 public function getAuthData()
 {
     if (!$this->sessionContainer->offsetExists('data')) {
         return null;
     }
     return $this->sessionContainer->data;
 }
コード例 #23
0
ファイル: UserController.php プロジェクト: n3vrax/dotkernel
 public function loginAction()
 {
     $redirect = $this->getRequest()->getQuery('redirect', false);
     $errors = [];
     if ($this->authentication->hasIdentity()) {
         return $this->redirect()->toRoute('dotuser');
     }
     if ($this->getRequest()->isPost()) {
         $this->loginForm->setData($this->getRequest()->getPost());
         $redirect = $this->getRequest()->getPost()->get('redirect', false);
         if ($this->loginForm->isValid()) {
             $authAdapter = $this->authentication->getAdapter();
             $this->authentication->clearIdentity();
             $params = $this->getRequest()->getPost();
             $identity = $params->get('identity');
             $credential = $params->get('credential');
             $authAdapter->setIdentity($identity);
             $authAdapter->setCredential($credential);
             $result = $this->authentication->authenticate();
             if ($result->isValid()) {
                 $identity = $result->getIdentity();
                 $session = new Container($this->authentication->getStorage()->getNameSpace());
                 $session->getDefaultManager()->regenerateId();
                 if ($redirect) {
                     return $this->redirect()->toUrl($redirect);
                 }
                 return $this->redirect()->toRoute('dotuser');
             } else {
                 $errors = array_merge($errors, $result->getMessages());
             }
         }
     }
     //show login form
     return array('loginForm' => $this->loginForm, 'redirect' => $redirect, 'errors' => $errors);
 }
コード例 #24
0
 public function logoutAction()
 {
     $session = new Container('User');
     $session->getManager()->destroy();
     $this->getAuthService()->clearIdentity();
     return $this->redirect()->toRoute('login');
 }
コード例 #25
0
ファイル: IndexControllerTest.php プロジェクト: zfury/cmf
 public function tearDown()
 {
     $this->sessionProgress->getManager()->getStorage()->clear('progress_tracker');
     $forms = new Container('forms');
     $forms->getManager()->getStorage()->clear('forms');
     parent::tearDown();
 }
コード例 #26
0
 public function indexAction()
 {
     $mainLayout = $this->initializeFrontendWebsite();
     $page = $this->params()->fromRoute('page');
     $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     $sessionContainer = new SessionContainer();
     $sessionSearch = $sessionContainer->offsetGet(AlboPretorioSearchController::sessionIdentifier);
     try {
         $helper = new AlboPretorioControllerHelper();
         $sezioniRecords = $helper->recoverWrapperRecords(new AlboPretorioSezioniGetterWrapper(new AlboPretorioSezioniGetter($em)), array());
         $articoliWrapper = $helper->recoverWrapperRecordsPaginator(new AlboPretorioArticoliGetterWrapper(new AlboPretorioArticoliGetter($em)), array('freeSearch' => isset($sessionSearch['testo']) ? $sessionSearch['testo'] : null, 'sezioneId' => isset($sessionSearch['sezine']) ? $sessionSearch['sezine'] : null, 'numeroProgressivo' => isset($sessionSearch['numero_progressivo']) ? $sessionSearch['numero_progressivo'] : null, 'numeroAtto' => isset($sessionSearch['numero_atto']) ? $sessionSearch['numero_atto'] : null, 'mese' => isset($sessionSearch['mese']) ? $sessionSearch['mese'] : null, 'anno' => isset($sessionSearch['anno']) ? $sessionSearch['anno'] : null, 'noScaduti' => 1, 'orderBy' => 'alboArticoli.id DESC', 'pubblicare' => 1), $page, null);
         $articoliWrapper->setEntityManager($em);
         $mainRecords = $articoliWrapper->addAttachmentsToPaginatorRecords($articoliWrapper->setupRecords(), array('moduleId' => ModulesContainer::albo_pretorio_id, 'noScaduti' => 1, 'orderBy' => 'a.position'));
         $formSearch = new AlboPretorioFormSearch();
         $formSearch->addYears();
         $formSearch->addSezioni($helper->formatForDropwdown($sezioniRecords, 'id', 'nome'));
         $formSearch->addCheckExpired();
         $formSearch->addSubmitButton();
         if (!empty($sessionSearch)) {
             $formSearch->setData(array('numero_progressivo' => $sessionSearch['numero_progressivo'], 'numero_atto' => $sessionSearch['numero_atto'], 'mese' => $sessionSearch['mese'], 'anno' => $sessionSearch['anno'], 'sezione' => $sessionSearch['sezione'], 'testo' => $sessionSearch['testo'], 'expired' => $sessionSearch['expired']));
         }
         $this->layout()->setVariables(array('sessionSearch' => $sessionSearch, 'form' => $formSearch, 'paginator' => $articoliWrapper->getPaginator(), 'emptyRecords' => count($mainRecords), 'records' => $mainRecords, 'templatePartial' => 'albo-pretorio/albo-pretorio.phtml'));
     } catch (\Exception $e) {
         $this->layout()->setVariables(array('messageTitle' => 'Si &egrave; verificato un problema:', 'messageText' => $e->getMessage(), 'moduleLabel' => 'Albo pretorio', 'templatePartial' => 'message.phtml'));
     }
     $this->layout()->setTemplate($mainLayout);
 }
コード例 #27
0
ファイル: MyAuthStorage.php プロジェクト: hopealive/ds
 public function setReferer($referer = "")
 {
     $sessionReferer = new Container('referer');
     if (strlen($referer) > 0) {
         $sessionReferer->offsetSet('referer', $referer);
     }
 }
コード例 #28
0
 public function membreAction()
 {
     $return = null;
     $identifiantMembre = (int) $this->params()->fromRoute('id', 0);
     $auth = new AuthenticationService();
     $logged = null;
     if ($auth->hasIdentity()) {
         $session = new Container('user');
         $logged = $session->offsetGet('id');
     }
     $like = array();
     $images = $this->getImageTable()->fetchAllById($identifiantMembre);
     if ($logged != null) {
         foreach ($images as $image) {
             $isLike = $this->getLikeTable()->fetchCorrespondance($logged, $image->id);
             foreach ($isLike as $isLikeTest) {
                 if ($isLikeTest->id != null) {
                     array_push($like, 'FALSE');
                 } else {
                     array_push($like, 'TRUE');
                 }
             }
         }
     }
     return new ViewModel(array('images' => $this->getImageTable()->fetchAllById($identifiantMembre), 'user' => $this->getUserTable()->getUser($identifiantMembre), 'like' => $like));
 }
コード例 #29
0
 public function toCartAction()
 {
     $item_id = $this->getRequest()->getPost()->item_id;
     $item_quantity = $this->getRequest()->getPost()->item_quantity;
     $item_price = $this->getRequest()->getPost()->item_price;
     //die($item_id.'_'.$item_quantity.'_'.$item_price);
     //$item_id = $this->params()->fromRoute('id'); // need if non-ajax request
     $guest_session = new Container();
     $guest_session->sessid = $guest_session->getDefaultManager()->getId();
     $toExchange = $this->getCollectionTable()->fetchById($item_id)->toArray();
     //$toExchange = $this->toArray($details);
     $toExchange[0]['cart_id'] = $guest_session->sessid;
     $toExchange[0]['item_quantity'] = $item_quantity;
     $toExchange[0]['item_price'] = $item_price;
     $cart_item = new Cart();
     $cart_item->exchangeArray($toExchange[0]);
     $this->getCartTable()->insertCart($cart_item);
     /*
             return $this->redirect()->toRoute(NULL , array(
                 'controller' => 'collection',
                 'action' => 'index',
             ));
     */
     /*                                              // just check for workability
             $viewModel = new ViewModel(array(
                 'details' => $details,
                 'guest_session' => $guest_session
             ));
             return $viewModel;
     */
 }
コード例 #30
0
ファイル: Module.php プロジェクト: GemiWagner/my_panel
 function boforeDispatch(MvcEvent $event)
 {
     $request = $event->getRequest();
     $response = $event->getResponse();
     $target = $event->getTarget();
     /* Offline pages not needed authentication */
     $whiteList = array('Auth\\Controller\\Auth-login', 'Auth\\Controller\\Auth-logout', 'Auth\\Controller\\Auth-signup');
     $requestUri = $request->getRequestUri();
     $controller = $event->getRouteMatch()->getParam('controller');
     $action = $event->getRouteMatch()->getParam('action');
     $requestedResourse = $controller . "-" . $action;
     $session = new Container('User');
     if ($session->offsetExists('email')) {
         if (in_array($requestedResourse, $whiteList)) {
             $url = '/TPWeb/public/produit';
             $response->setHeaders($response->getHeaders()->addHeaderLine('Location', $url));
             $response->setStatusCode(302);
         }
     } else {
         if (!in_array($requestedResourse, $whiteList)) {
             $url = '/TPWeb/public/auth';
             $response->setHeaders($response->getHeaders()->addHeaderLine('Location', $url));
             $response->setStatusCode(302);
         }
         $response->sendHeaders();
     }
     //print "Called before any controller action called. Do any operation.";
 }