本文整理汇总了PHP中Zend\Session\Container::offsetGet方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::offsetGet方法的具体用法?PHP Container::offsetGet怎么用?PHP Container::offsetGet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Session\Container
的用法示例。
在下文中一共展示了Container::offsetGet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onDispatch
public function onDispatch(MvcEvent $e)
{
/*
$admin_session = new Container('admin');
$username = $admin_session->username;
if(empty($username)) {
return $this->redirect()->toRoute('adminlogin');
}
*/
/* Set Default layout for all the actions */
$this->layout('layout/layout');
$em = $this->getEntityManager();
$cities = $em->getRepository('\\Admin\\Entity\\City')->findBy(array('countryId' => 2));
$categories = $em->getRepository('\\Admin\\Entity\\Categories')->findBy(array('status' => 1));
$signupForm = new Forms\SignupForm();
$loginForm = new Forms\LoginForm();
$forgotpassForm = new Forms\ForgotPasswordForm();
$this->layout()->signupForm = $signupForm;
$this->layout()->loginForm = $loginForm;
$this->layout()->forgotpassForm = $forgotpassForm;
$this->layout()->cities = $cities;
$this->layout()->categories = $categories;
$user_session = new Container('user');
$userid = $user_session->userId;
$city = "";
$searchSession = new Container("searchsess");
$searchType = "";
$searchTerm = "";
if ($searchSession->offsetExists("type")) {
$searchType = $searchSession->offsetGet("type");
$searchTerm = $searchSession->offsetGet("searchTerm");
}
if ($searchType == "category" && $searchTerm != "") {
$this->layout()->searchedCategory = $searchTerm;
}
if ($searchType == "city" && $searchTerm != "") {
$this->layout()->userCity = $searchTerm;
}
if (!empty($userid)) {
$msg = 'You are already logged in.';
$status = 1;
$this->layout()->setVariable('userId', $user_session->userId);
$this->layout()->setVariable('username', $user_session->userName);
$username = $user_session->userName;
$tmp_user = $em->getRepository('\\Admin\\Entity\\Users')->find($user_session->userId);
$city = $tmp_user->getCity();
if ($searchType == "city" && $searchTerm != "") {
$this->layout()->userCity = $searchTerm;
} else {
if (!empty($city)) {
$cityObj = $em->getRepository('\\Admin\\Entity\\City')->find($city);
$this->layout()->userCity = $cityObj->getCityName();
}
}
} else {
$this->layout()->setVariable('userId', '');
}
return parent::onDispatch($e);
}
示例2: validateChangePassword
/**
* 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());
}
}
示例3: getdptoAction
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;
}
示例4: setTitleAndTranslation
/**
* 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);
}
示例5: indexAction
public function indexAction()
{
//Cargamos Layout
$this->layout('layout/admin');
//Instancias
$this->dbAdapter = $this->getServiceLocator()->get('Zend\\Db\\Adapter');
$sid = new Container('base');
//Obtenemos Datos de sesion
$nombre = $sid->offsetGet('nombreComercial');
$dbNombre = $sid->offsetGet('dbNombre');
//Buscamos direccion del condominio para mostrar
$valores = array('agua' => "804369", 'luz' => "2854633", 'mantenciones' => "854666", 'remuneraciones' => "6456997", 'insumos' => "1269322");
return new ViewModel(array("nombre" => $nombre, "direccion" => $direccion, 'valores' => $valores));
}
示例6: registerAction
/**
* @return array
*/
public function registerAction()
{
$form = new Register($this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager'));
$form->get('primary')->setValue($this->getAuthenticationService()->getIdentity()->getId());
$status = null;
// Step 3: Returned from PayPal
if ($this->params()->fromRoute('payum_token')) {
$status = $this->getDogService()->completePayment($this);
$details = $status->getFirstModel();
if ($details instanceof DetailsAggregateInterface) {
$details = $details->getDetails();
if ($details instanceof \Traversable) {
$details = iterator_to_array($details);
}
}
$form->setData($details['dogData']);
if ($status->isCaptured()) {
$this->getDogService()->registerNewDog($details['dogData']);
return $this->redirect()->toRoute('home');
}
// Step 2: Confirm dog information and redirect to PayPal
} elseif ($dogData = $this->session->offsetGet('dogData')) {
$this->session->offsetUnset('dogData');
$request = $this->getRequest();
if ($request->isPost() && $request->getPost('confirm') !== null) {
$token = $this->getDogService()->preparePayment($dogData, $this->getAuthenticationService()->getIdentity());
return $this->redirect()->toUrl($token->getTargetUrl());
}
$form->setData($dogData);
// Step 1: Collect dog information
} else {
$request = $this->getRequest();
if ($request->isPost()) {
if ($request->getPost('cancel') !== null) {
return $this->redirect()->toRoute('home');
}
$form->setData($request->getPost());
if ($form->isValid()) {
$dogData = $form->getData();
$dogData['breedName'] = $this->getDogService()->getBreed($dogData['breed'])->getName();
$this->session->offsetSet('dogData', $dogData);
$form = new Confirm();
}
}
}
// Remove payum token from form action url if necessary
$form->setAttribute('action', $this->url()->fromRoute('dog/register'));
return array('form' => $form, 'status' => $status, 'dogData' => $this->session->offsetGet('dogData'));
}
示例7: dbparamAction
public function dbparamAction()
{
$this->dbAdapter = $this->getServiceLocator()->get('Zend\\Db\\Adapter');
$usuario = new UsuarioTable($this->dbAdapter);
$tsession = new SessionTable($this->dbAdapter);
$id_db = $this->params()->fromRoute('id', 0);
$sid = new Container('base');
$dbParam = $sid->offsetGet('dbParam');
for ($i = 0; $i < count($dbParam); $i++) {
if ($id_db == $dbParam[$i]['id']) {
$id_perfil = $dbParam[$i]['id_perfil'];
$nro_session = $dbParam[$i]['nro_session'];
$db_nombre = $dbParam[$i]['nombre_db'];
$nombreComercial = $dbParam[$i]['nombre'];
$perfil = $dbParam[$i]['perfil'];
break;
}
}
$id_usuario = $sid->offsetGet('id_usuario');
$nroSessionDB = count($tsession->obtenetSesion($id_usuario, $id_db));
if ($nro_session > 0 && $nroSessionDB >= $nro_session) {
$sid->getManager()->getStorage()->clear();
if (isset($_COOKIE['usuario'])) {
unset($_COOKIE['usuario']);
}
if (isset($_COOKIE['password'])) {
unset($_COOKIE['password']);
}
//return $this->forward()->dispatch('Application\Controller\Login',array('action'=>'index','id'=>4));
return $this->redirect()->toUrl($this->getRequest()->getBaseUrl() . '/application/login/index/4');
}
$sid->offsetSet('dbNombre', $db_nombre);
$sid->offsetSet('nombreComercial', $nombreComercial);
$sid->offsetSet('id_db', $id_db);
$sid->offsetSet('perfil', $perfil);
$valores = array('id_usuario' => $id_usuario, 'id_db' => $id_db, 'ip_cliente' => $_SERVER['REMOTE_ADDR'], 'port_cliente' => $_SERVER['REMOTE_PORT']);
$sid->offsetSet('idSession', $tsession->crearSesion($valores));
//Mapeamos la base de datos
$modulo = $usuario->getModulo($this->dbAdapter, $id_perfil);
$sid->offsetSet('modulo', $modulo);
if (count($modulo) > 1) {
$urlHome = 'application';
} else {
$urlHome = $modulo[0]['url'];
}
$sid->offsetSet('urlHome', $urlHome);
return $this->redirect()->toUrl($this->getRequest()->getBaseUrl() . '/' . $urlHome);
//return new ViewModel();
}
示例8: indexAction
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: indexAction
public function indexAction()
{
$view = new ViewModel();
$username = $this->params()->fromPost('username');
$password = $this->params()->fromPost('password');
if (empty($username) && empty($password)) {
$session = new Container('user_session');
$pattern = $session->offsetGet('session_status');
if (!empty($pattern)) {
$adminContent = new ViewModel(array('posts' => $this->formatTargetPosts($this->postService->findAllPosts('', 'php'), true)));
$adminContent->setTemplate('template/content/adminContent.phtml');
$view->addChild($adminContent, '_admin_content');
return $view;
} else {
echo "<h1>Forbidden No Session stored!</h1>\r\n <button id=\"retry_1\" type=\"button\" class=\"btn btn-success\">To login Site</button>";
}
} else {
$result = $this->postService->userMapping($username, $password);
if ($result) {
$this->sessionAction($username);
$adminContent = new ViewModel(array('posts' => $this->formatTargetPosts($this->postService->findAllPosts('', 'php'), true)));
//
$adminContent->setTemplate('template/content/adminContent.phtml');
$view->addChild($adminContent, '_admin_content');
// TODO: Implement Admin Content.
} else {
$error_message = new ViewModel(array());
$error_message->setTemplate('template/error/error_admin_login.phtml');
$view->addChild($error_message, '_error_message');
}
return $view;
}
}
示例10: boforeDispatch
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();
}
}
示例11: indexAction
public function indexAction()
{
$mainLayout = $this->initializeFrontendWebsite();
$page = $this->params()->fromRoute('page');
$em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
$templateDir = $this->layout()->getVariable('templateDir');
$basicLayout = $this->layout()->getVariable('atti_concessione_basiclayout');
$sessionContainer = new SessionContainer();
$sessionSearch = $sessionContainer->offsetGet(AttiConcessioneSearchController::sessionIdentifier);
try {
$helper = new AttiConcessioneControllerHelper();
$yearsRecords = $helper->recoverWrapperRecords(new AttiConcessioneGetterWrapper(new AttiConcessioneGetter($em)), array('fields' => 'DISTINCT(atti.anno) AS year', 'orderBy' => 'atti.id DESC'), $page, null);
$wrapperArticoli = $helper->recoverWrapperRecordsPaginator(new AttiConcessioneGetterWrapper(new AttiConcessioneGetter($em)), array('anno' => isset($sessionSearch['anno']) ? $sessionSearch['anno'] : null, 'codice' => isset($sessionSearch['codice']) ? $sessionSearch['codice'] : null, 'beneficiarioSearch' => isset($sessionSearch['beneficiario']) ? $sessionSearch['beneficiario'] : null, 'importo' => isset($sessionSearch['importo']) ? $sessionSearch['importo'] : null, 'settore' => isset($sessionSearch['settore']) ? $sessionSearch['settore'] : null, 'attivo' => 1, 'orderBy' => 'atti.id DESC'), $page, null);
$settoriRecords = $helper->recoverWrapperRecords(new UsersSettoriGetterWrapper(new UsersSettoriGetter($em)), array('orderBy' => 'settore.nome'));
$wrapperArticoli->setEntityManager($em);
$articoliRecords = $wrapperArticoli->addAttachmentsToPaginatorRecords($wrapperArticoli->setupRecords(), array('moduleId' => ModulesContainer::atti_concessione, 'noScaduti' => 1, 'orderBy' => 'a.position'));
$form = new AttiConcessioneFormSearch();
$form->addAnno($helper->formatYears($yearsRecords));
$form->addMainElements();
$form->addUfficio($helper->formatForDropwdown($settoriRecords, 'id', 'nome'));
$form->addSubmitSearchButton();
if (!empty($sessionSearch)) {
$form->setData(array('anno' => $sessionSearch['anno'], 'codice' => $sessionSearch['codice'], 'beneficiario' => $sessionSearch['beneficiario'], 'importo' => $sessionSearch['importo'], 'settore' => $sessionSearch['settore']));
}
$articoliPaginator = $wrapperArticoli->getPaginator();
$this->layout()->setVariables(array('records' => $articoliRecords, 'form' => $form, 'sessionSearch' => $sessionSearch, 'paginator' => $articoliPaginator, 'paginator_total_item_count' => $articoliPaginator->getTotalItemCount(), 'templatePartial' => 'atti-concessione/atti-concessione.phtml'));
} catch (NullException $e) {
$this->layout()->setVariables(array('messageType' => 'secondary', 'messageText' => "Si è verificato un problema o una mancanza di dati necessari per visualizzare la pagina richiesta", 'templatePartial' => 'atti-concessione/atti-concessione.phtml'));
}
$this->layout()->setTemplate(isset($basicLayout) ? $templateDir . $basicLayout : $mainLayout);
}
示例12: indexAction
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);
}
示例13: indexAction
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 è verificato un problema:', 'messageText' => $e->getMessage(), 'moduleLabel' => 'Albo pretorio', 'templatePartial' => 'message.phtml'));
}
$this->layout()->setTemplate($mainLayout);
}
示例14: loginAction
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;
}
示例15: getIdentityRoles
/**
* {@inheritDoc}
*/
public function getIdentityRoles()
{
$authService = $this->userService;
// $definedRoles = $this->config['role_providers']['BjyAuthorize\Provider\Role\Config']['user']['children'];
$roleKey = $this->config['ldap_role_key'];
// $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
// $definedRoles = $em->getRepository("ZfcUserLdap\Entity\Role")->findAll();
// var_dump($role);
// exit();
if (!$authService->getAuthService()->hasIdentity()) {
return array($this->getDefaultRole());
}
$session = new Container('ZfcUserLdap');
if (!$session->offsetExists('ldapObj')) {
return array($this->getDefaultRole());
}
// var_dump($roleKey);
$user = $session->offsetGet('ldapObj');
$roles = array();
// var_dump($user);
// var_dump($definedRoles);
// exit();
foreach ($user->getRoles() as $role) {
// if (isset($definedRoles[$role]))
$roles[] = $role->getRoleId();
}
return $roles;
// $session = new Container('ZfcUserLdap');
// $user = $session->offsetGet('ldapObj');
// $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
// // $Roles = $em->getRepository("ZfcUserLdap\Entity\User")->find();
// // var_dump($authService->getAuthService()->getIdentity());
// var_dump($user);
// exit();
}