/** * Helper para pegar as imagens do webservice * */ public function GetDadosUsuario() { $auth = Zend_Auth::getInstance(); $db = Zend_Db_Table::getDefaultAdapter(); $chAction = strtolower(Zend_Controller_Front::getInstance()->getRequest()->getActionName()); $chController = Zend_Controller_Front::getInstance()->getRequest()->getControllerName(); $sql = 'select '; $sql .= ' u.*, '; $sql .= ' a.nm_avatar, '; $sql .= ' a.tp_avatar, '; $sql .= ' a.sz_avatar, '; $sql .= ' a.arquivo '; $sql .= 'from '; $sql .= ' sca_usuario u '; $sql .= ' left join sgg_avatar a on a.id_avatar = u.id_avatar '; $sql .= 'where u.st_usuario = 1 '; $sql .= 'and u.id_usuario = ' . $auth->getIdentity()->id_usuario; $result = $db->fetchRow($sql); if ($result) { if ($result['arquivo']) { $result['arquivo'] = "data:" . $result['tp_avatar'] . ";base64," . base64_encode($result['arquivo']); } } return $result; }
public function indexAction() { // display the profile form and populate if profile exists $request = $this->getRequest(); $form = new Application_Form_Profile(); $auth = Zend_Auth::getInstance(); $identity = $auth->getIdentity(); $profileMapper = new Application_Model_ProfileMapper(); $profile = new Application_Model_Profile(); $exists = $profileMapper->exists($identity->id); if ($request->isPost()) { if ($form->isValid($request->getPost())) { $profile->setOptions($form->getValues()); $profile->setUserId($identity->id); $profileMapper->save($profile, $exists); // display success message $this->view->msg = "<p class='msg'>Profile saved</p>"; } } else { $profileMapper->find($identity->id, $profile); $data = array('first_name' => $profile->getFirstName(), 'last_name' => $profile->getLastName(), 'birthdate' => date_format(new DateTime($profile->getBirthdate()), 'Y-m-d'), 'gender' => $profile->getGender()); $form->populate($data); } $this->view->form = $form; }
public function preDispatch(Zend_Controller_Request_Abstract $request) { $auth = Zend_Auth::getInstance(); $isAllowed = false; $controller = $request->getControllerName(); $action = $request->getActionName(); // Generate the resource name $resourceName = $controller . '/' . $action; // Don't block errors if ($resourceName == 'error/error') { return; } $resources = $this->acl->getResources(); if (!in_array($resourceName, $resources)) { $request->setControllerName('error')->setActionName('error')->setDispatched(true); throw new Zend_Controller_Action_Exception('This page does not exist', 404); return; } // Check if user can access this resource or not $isAllowed = $this->acl->isAllowed(Zend_Registry::get('role'), $resourceName); // Forward user to access denied or login page if this is guest if (!$isAllowed) { if (!Zend_Auth::getInstance()->hasIdentity()) { $forwardAction = 'login'; } else { $forwardAction = 'deny'; } $request->setControllerName('index')->setActionName($forwardAction)->setDispatched(true); } }
function preDispatch() { $auth = Zend_Auth::getInstance(); if (!$auth->hasIdentity()) { $this->_redirect('auth/login'); } }
public function preRender() { if (Zend_Auth::getInstance()->hasIdentity()) { $controller = sgContext::getInstance()->getController(); if ($controller instanceof FlatCMSPluginController) { $session = new Zend_Session_Namespace(Zend_Auth::getInstance()->getStorage()->getNamespace()); $session->FlatCMSEditorPluginFileMTime = filemtime(FlatCMSPluginPageModel::getPagePath(sgContext::getInstance()->getCurrentPath())); //figure out better way to handle this so libraries aren't double loaded $controller->scripts[] = sgToolkit::url('/js/FlatCMSEditorPlugin/jquery.min.js'); $controller->scripts[] = sgToolkit::url('/js/FlatCMSEditorPlugin/jquery.jeditable.mini.js'); $controller->scripts[] = sgToolkit::url('/js/FlatCMSEditorPlugin/jquery.jeditable.autogrow.js'); $controller->scripts[] = sgToolkit::url('/js/FlatCMSEditorPlugin/tinymce/jscripts/tiny_mce/jquery.tinymce.js'); $controller->scripts[] = sgToolkit::url('/js/FlatCMSEditorPlugin/jquery.jeditable.tinymce.js'); $controller->scripts[] = sgToolkit::url('/js/FlatCMSEditorPlugin/init.js'); $controller->js_settings['FlatCMSEditorPlugin'] = array('saveURL' => sgToolkit::url(sgConfiguration::get('routing.FlatCMSEditorPlugin_save.path')), 'currentPath' => sgContext::getInstance()->getCurrentPath()); if (isset($controller->content) && is_array($controller->content)) { $textarea_fields = sgConfiguration::get('settings.FlatCMSEditorPlugin.textarea_fields', array()); foreach ($controller->content as $key => &$field) { if (in_array($key, $textarea_fields)) { $field = '<div class="editable-area" id="' . $key . '">' . $field . '</div>'; } else { $field = '<div class="editable" id="' . $key . '">' . $field . '</div>'; } } } } } }
public function __construct($tthis, $context, $data) { $this->tthis = $tthis; $this->context = $context; $this->data = $data; $year = 0; if (isset($tthis->_attributes['year'])) { $year = (int) $tthis->_attributes['year']; } if (!$year > 0) { $year = date('Y') - 1; } // default year to previous $this->dateStart = date('Y-m-d', strtotime($year . '-01-01')); $this->dateEnd = date('Y-m-d', strtotime($year . '-12-31')); $this->providerId = (int) Zend_Auth::getInstance()->getIdentity()->personId; $providerId = (int) $this->context; if ($providerId > 0) { $this->providerId = $providerId; } $info = array(); $info['dateStart'] = $this->dateStart; $info['dateEnd'] = $this->dateEnd; $provider = new Provider(); $provider->personId = $this->providerId; $provider->populate(); $info['provider'] = $provider; self::$info = $info; }
public function loggedInAs() { $Auth = Zend_Auth::getInstance(); $Ret = ''; if ($Auth->hasIdentity()) { $Username = $Auth->getIdentity()->Nome . ' ' . $Auth->getIdentity()->Cognome; $Module = Zend_Controller_Front::getInstance()->getRequest()->getModuleName(); $LogoutURL = $this->view->url(array('controller' => 'login', 'action' => 'logout', 'module' => 'default'), 'default', true); $MessaggiURL = $this->view->url(array('controller' => 'messages', 'action' => 'index', 'module' => 'default'), 'default'); $AdminURL = $this->view->url(array('controller' => 'index', 'action' => 'index', 'module' => $Module == 'admin' ? 'default' : 'admin'), 'default'); #$Ret .= 'Welcome ' . $Username . ' '; $Ret .= '<a href="' . $MessaggiURL . '">' . $this->view->img('images/icons/mail_24x24.png', array('title' => 'Messages', 'alt' => 'Messages')) . '</a> '; $Ret .= '<a href="' . $AdminURL . '">' . $this->view->img('images/icons/' . ($Module == 'admin' ? 'magic_wand' : 'wrench') . '_24x24.png', array('title' => $Module == 'admin' ? 'Public' : 'Admin', 'alt' => $Module == 'admin' ? 'Public' : 'Admin')) . '</a> '; $Ret .= '<a href="' . $LogoutURL . '">' . $this->view->img('images/icons/lock_24x24.png', array('title' => 'Logout', 'alt' => 'Logout')) . '</a>'; return $Ret; } $Request = Zend_Controller_Front::getInstance()->getRequest(); $Controller = $Request->getControllerName(); $Action = $Request->getActionName(); if ($Controller == 'login' && $Action == 'index') { return ''; } $LoginURL = $this->view->url(array('controller' => 'login', 'action' => 'index'), 'default'); $Ret .= '<a href="' . $LoginURL . '">' . $this->view->img('images/icons/unlock_24x24.png', array('title' => 'Login', 'alt' => 'Login')) . '</a>'; return $Ret; }
public function authAction() { $request = $this->getRequest(); // Check if we have a POST request if (!$request->isPost()) { die('not posted'); //return $this->_helper->redirector('index'); } // Get our form and validate it $form = $this->_loginForm; if (!$form->isValid($request->getPost())) { // Invalid entries $this->view->loginForm = $form; return $this->render('index'); // re-render the login form } // Get our authentication adapter and check credentials $adapter = $this->getAuthAdapter($form->getValues()); $auth = Zend_Auth::getInstance(); $result = $auth->authenticate($adapter); if (!$result->isValid()) { // Invalid credentials $form->setDescription('Invalid credentials provided'); $this->view->loginForm = $form; return $this->render('index'); // re-render the login form } die("We're authenticated! Redirect to the home page"); //$this->_helper->redirector('poll', 'index'); }
function init() { $auth = Zend_Auth::getInstance(); $this->_userInfo = $auth->getIdentity(); $this->_dirApp = Zend_Registry::get('dirApp')->toArray(); $this->view = Myapp_View_Smarty::getInstance(); $this->view->setView($this->_dirApp['template_front'] . $this->_dirApp['style'] . '/'); $smarty = $this->view->getEngine(); $smarty->compile_dir = $this->_dirApp['template_front_cache']; $viewRenderer = $this->_helper->getHelper('viewRenderer'); $viewRenderer->setView($this->view)->setViewBasePathSpec($smarty->template_dir)->setViewScriptPathSpec(':controller/:action.:suffix')->setViewScriptPathNoControllerSpec(':action.:suffix')->setViewSuffix($this->_dirApp['template_extension']); $this->_base_url = $this->_dirApp['base_url']; $this->view->assign('base_url', $this->_base_url); $this->view->assign('base_tpl', $this->_dirApp['base_tpl']); $this->_model = Front_Model_Lang::getInstance(); $this->_module = $this->_getParam('module'); $this->_control = $this->_getParam('controller'); $action = $this->_getParam('action'); $this->view->assign('form', array('module' => $this->_module, 'control' => $this->_control, 'action' => $action, 'lang' => $_SESSION['lang'])); $this->_lable = Zend_Registry::get('lable'); $this->view->assign('lable', $this->_lable); if (empty($this->_userInfo->adminId)) { $this->_redirect($this->_base_url . 'login/'); } if ($this->_userInfo->adminId != '') { $file_name = $this->_dirApp['dir_auth'] . $this->_userInfo->adminLogin . '.ini'; $sessionAuth = Myapp_File_Createauth::getInstance()->compareSession($file_name); if ($sessionAuth == true) { $this->_redirect($this->_base_url . 'logout/'); } } $this->view->assign('userInfo', $this->_userInfo); }
public function preDispatch(Zend_Controller_Request_Abstract $request) { $loginController = 'authentication'; $loginAction = 'login'; $auth = Zend_Auth::getInstance(); // If user is not logged in and is not requesting login page // - redirect to login page. if (!$auth->hasIdentity() && $request->getControllerName() != $loginController && $request->getActionName() != $loginAction) { $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('Redirector'); $redirector->gotoSimpleAndExit($loginAction, $loginController); } // User is logged in or on login page. if ($auth->hasIdentity()) { // Is logged in // Let's check the credential $acl = new Tynex_Models_TynexAcl(); $identity = $auth->getIdentity(); // role is a column in the user table (database) $isAllowed = $acl->isAllowed($identity->role, $request->getControllerName(), $request->getActionName()); if (!$isAllowed) { $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('Redirector'); $redirector->gotoUrlAndExit('/'); } } }
/** * Check authorization */ protected function _checkAuthorization() { $routeName = Zend_Controller_Front::getInstance()->getRouter()->hasRoute('admin') ? 'admin' : 'default'; $lang = $this->_request->getParam('lang'); if (!Zend_Auth::getInstance()->hasIdentity()) { //if ajax request if ($this->getRequest()->isXmlHttpRequest()) { /*return $this->getHelper('json')->direct(array( 'success' => false, 'message' => $this->view->translate("Please login first") ));*/ throw new Zend_Controller_Action_Exception("Please login first", 403); } //store to return $this->returnHere(); //redirect to login page $this->_redirect($this->view->url(array('controller' => 'index', 'action' => 'login', 'module' => 'admin', 'lang' => $lang), $routeName, true)); } $aclLoader = HCMS_Acl_Loader::getInstance(); //check permission if (!$aclLoader->getAcl()->isAllowed($aclLoader->getCurrentRoleCode(), $this->_authResourse, $this->_authPrivilege)) { //redirect to login page $this->_redirect($this->view->url(array('module' => 'admin', 'controller' => 'index', 'action' => 'login', 'lang' => $lang), $routeName, true)); throw new Zend_Controller_Action_Exception("You are not allowed to access this page", 403); } }
/** * Returns true if and only if the assertion conditions are met * * This method is passed the ACL, Role, Resource, and privilege to which * the authorization query applies. If the $role, $resource, or $privilege * parameters are null, it means that the query applies to all Roles, * Resources, or privileges, respectively. * * @param Zend_Acl $acl * @param Zend_Acl_Role_Interface $role * @param Zend_Acl_Resource_Interface $resource * @param string $privilege * @return boolean */ public function assert(Zend_Acl $acl, Zend_Acl_Role_Interface $role = null, Zend_Acl_Resource_Interface $resource = null, $privilege = null) { // We need specific objects to check against each other if (NULL === $role || NULL === $resource) { return false; } // Ensure we're handled User models if (!$role instanceof UserModel) { throw new Exception('Role must be an instance of UserModel'); } if (!$resource instanceof WatcherModel) { throw new Exception('Resource must be an instance of WatcherModel'); } switch ($resource->scope) { case 'user': return $role->id == $resource->scopeId; case 'apiId': if (!$role instanceof \Application\Model\CurrentUserModel || !$role->isApiAuthUser()) { return FALSE; } return $role->apiId == $resource->scopeId; case 'token': if (Zend_Auth::getInstance()->hasIdentity() && ($ident = Zend_Auth::getInstance()->getIdentity()) && isset($ident['token'])) { return $ident['token'] === $resource->scopeId; } return false; case 'organization': return $role->organizationId === $resource->scopeId; } return false; }
/** * Get the auth object * * @return Zend_Auth */ public function getAuth() { if (null === $this->_auth) { $this->_auth = Zend_Auth::getInstance(); } return $this->_auth; }
public function confirmTrialAction() { $subscription_id = $this->_getParam('id'); $subscription = Engine_Api::_()->getItem('payment_subscription', $subscription_id); if ($subscription) { //save tracking $trialPlanTable = Engine_Api::_()->getDbTable('trialplans', 'user'); $trialRow = $trialPlanTable->getRow($subscription->user_id, $subscription->package_id); if (isset($trialRow)) { return $this->_helper->requireSubject()->forward(); } else { $trialRow = $trialPlanTable->createRow(); $trialRow->package_id = $subscription->package_id; $trialRow->user_id = $subscription->user_id; $trialRow->active = true; $package = $subscription->getPackage(); if (isset($package)) { $trialRow->level_id = $package->level_id; } $trialRow->save(); } $this->view->verified = true; $this->view->approved = true; $subscription->status = 'pending'; $subscription->active = true; $subscription->save(); $subscription->onTrialPaymentSuccess(); //set login for viewer Zend_Auth::getInstance()->getStorage()->write($subscription->user_id); Engine_Api::_()->user()->setViewer(); $this->view->viewer_id = $subscription->user_id; } }
public function assert(Core_Acl $acl, Zend_Acl_Role_Interface $role = null, Zend_Acl_Resource_Interface $resource = null, $privilege = null) { $auth = Zend_Auth::getInstance(); if (!$auth->hasIdentity()) { return false; } $controller = Controlador::getInstance(); $usuario = $controller->usuario; if (!$controller->cache->test('privilegio_' . $usuario->ID . '_' . $resource->id)) { // não existe o cache, pegar o valor do banco $privilegio = DaoRecurso::getPrivilegioByUsuario($usuario, $resource); $controller->cache->save($privilegio, 'privilegio_' . $usuario->ID . '_' . $resource->id, array('acl_usuario_' . $usuario->ID, 'acl_unidade_' . $usuario->ID_UNIDADE)); } else { $privilegio = $controller->cache->load('privilegio_' . $usuario->ID . '_' . $resource->id); } // Checa se o usuario tem permissao de acessar o recurso incondicionalmente if ($acl->has($resource) && $privilegio) { return true; } else { $contexto = $resource->getContexto(); if (!is_null($contexto) && count($contexto) > 0) { // Existe um contexto, avaliar se o id_unid_area_trabalho do objeto contexto == ID_UNIDADE do usuario logado return $contexto['id_unid_area_trabalho'] == $usuario->ID_UNIDADE; } else { // Não existe objeto de contexto, retorna true se recurso original da requisicao for AREA DE TRABALHO return Controlador::getInstance()->recurso->id == 3; } } return false; }
/** * * @return array * @todo right exception handling */ public function getImages($ceId = null) { $table = new Image(); $namespace = new Zend_Session_Namespace('default'); $auth = Zend_Auth::getInstance(); $storage = $auth->getStorage()->read(); if ($ceId == null) { $constCeId = CalibrationExercise::COL_ID; $ceId = $namespace->{$constCeId}; } $dbAdapter = Zend_Registry::get('DB_CONNECTION1'); $select = $dbAdapter->select(); $select->from(array("im" => Image::TABLE_NAME)); $select->join(array("ceHim" => CeHasImage::TABLE_NAME), "im." . Image::COL_ID . " = " . " ceHim." . CeHasImage::COL_IMAGE_ID, array(CeHasImage::COL_IMAGE_ID, CeHasImage::COL_ID)); // if($state == null || $state == "groupState"){ $select->where(CeHasImage::COL_CALIBRATION_EXERCISE_ID . " = ?", $ceId); // }else{ // $select->join( array( "ce" => CalibrationExercise::TABLE_NAME), // "ce." . CalibrationExercise::COL_ID . " = " . " ceHim." . CeHasImage::COL_CALIBRATION_EXERCISE_ID); // $select->join(array('exp'=>Expertise::TABLE_NAME), // 'ce.'.CalibrationExercise::COL_EXPERTISE_ID . "=" . 'exp.' . Expertise::COL_ID); // if($state == 'ws-refState'){ // $select->where("ce." . CalibrationExercise::COL_WORKSHOP_ID . "=?",$namespace->ceArray[0][CalibrationExercise::COL_WORKSHOP_ID],"int"); // }elseif($state == 'webgr-refState'){ // $select->join(array('ws'=>Workshop::TABLE_NAME), // 'ce.'.CalibrationExercise::COL_WORKSHOP_ID . "=" . 'ws.' . Workshop::COL_ID); // } // $select->where("exp." . Expertise::COL_ID . "=?",$namespace->ceArray[0][Expertise::COL_ID],"int"); // } $select->group("im." . Image::COL_ID); $dataArray = $dbAdapter->fetchAll($select); return $dataArray; }
public function init() { ## Envia o usuário que não logou para o controller auth ## if (!Zend_Auth::getInstance()->hasIdentity()) { return $this->_helper->redirector->goToRoute(array('module' => 'default', 'controller' => 'index'), null, true); } ## Enviando informações para Carregar o Javascript ## $parametros = $this->_request->getParams(); $modulo = $parametros['module']; $controle = $parametros['controller']; $this->view->modulo_cadastros = $modulo; $this->view->controle_cadastros = $controle; $auth = Zend_Auth::getInstance(); $dataSession = $auth->getStorage()->read(); $nomeUsuarioSessao = $dataSession->_fullName; $this->view->nome = $nomeUsuarioSessao; $this->view->login_usuario = $dataSession->_userName; $this->view->nome_perfil = $dataSession->_nomePerfil; ## Rotina para fazer a paginação de resultados ## $session = new Zend_Session_Namespace('busca_obreiro'); ## Grava dados da busca na sessão ## if (!isset($session->dadosBusca) || $this->_request->isPost()) { $this->_dadosBusca['filtros']['filtra_cim'] = $this->_request->getPost('filtra_cim'); $this->_dadosBusca['filtros']['filtra_loja'] = $this->_request->getPost('filtra_loja'); $this->_dadosBusca['filtros']['filtra_status'] = $this->_request->getPost('filtra_status'); $this->_dadosBusca['filtros']['filtra_nome'] = $this->_request->getPost('filtra_nome'); $this->_dadosBusca['filtros']['filtra_caminhada'] = $this->_request->getPost('filtra_caminhada'); $this->_dadosBusca['filtros']['filtra_dt_entrada'] = $this->_request->getPost('filtra_dt_entrada'); $session->dadosBusca = $this->_dadosBusca; } else { $this->_dadosBusca = $session->dadosBusca; } }
public function xmlAction() { $this->getHelper('layout')->disableLayout(); $this->getHelper('viewRenderer')->setNoRender(); $model = new Stat_Model_Requests(); $auth = Zend_Auth::getInstance(); $ident = $auth->getIdentity(); $requests = $model->getResponsesReports(0, $ident->STRUCTURE_CODE == 0 ? 0 : $ident->STRUCTUREID); $dom = new DOMDocument('1.0', 'utf-8'); $root = $dom->createElement('requestlist'); foreach ($requests as $request) { if ($request['UPLOADDATE']) { continue; } // Пропустить, если отчёт уже подан $publicDate = strtotime($request['PUBLICDATE']); if ($publicDate < strtotime('-30 day')) { continue; } // Пропустить, если от даты публикации прошло больше 30 дней $req = $dom->createElement('request'); $req->setAttribute("id", $request['PERIODID']); $req->setAttribute("title", $request['REPORT'] . ' (' . $request['PERIOD'] . ')'); $req->setAttribute("publicdate", $request['PUBLICDATE']); $root->appendChild($req); } $dom->appendChild($root); // $dom->formatOutput = TRUE; header("Content-type: text/xml"); echo $dom->saveXML(); }
public function loggedInAs() { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $user = $auth->getIdentity(); if (!isset($user->username)) { $auth->clearIdentity(); $info = 'logout'; return $info; } $logoutUrl = $this->view->url(array('controller' => 'auth', 'action' => 'logout'), null, true); $url = $this->view->url(array('controller' => 'user', 'action' => 'edit', 'id' => $user->id)); $info = '<div class ="menuButton"><span class="menu">' . $user->username . '</span>'; $info .= '<ul> <li><a href="' . $url . '">Mon profil</a></li> <li class="separator"></li> <li><a href="' . $logoutUrl . '" class="logout">se déconnecter</a></li> </ul></div>'; return $info; } $request = Zend_Controller_Front::getInstance()->getRequest(); $controller = $request->getControllerName(); $action = $request->getActionName(); if ($controller == 'auth' && $action == 'index') { return ''; } $form = new Application_Form_Login(); $loginUrl = $this->view->url(array('controller' => 'auth', 'action' => 'index'), null, true); $info = '<div class ="menuButton"><span class="menu"> Se connecter </span><ul><li class="form">' . $form->setAction($loginUrl) . '</li></ul></div>'; return $info; //$loginUrl = $this->view->url(array('controller'=>'auth', 'action'=>'index')); //return '<a href="'.$loginUrl.'">Login</a>'; }
/** * @param Zend_Controller_Request_Abstract $oHttpRequest */ public function preDispatch(Zend_Controller_Request_Abstract $oHttpRequest) { $sControllerName = $oHttpRequest->getControllerName(); $sActionName = $oHttpRequest->getActionName(); $aRequestedParams = $oHttpRequest->getUserParams(); $sQuery = ''; unset($aRequestedParams['controller']); unset($aRequestedParams['action']); // Define user role if (Zend_Auth::getInstance()->hasIdentity()) { $aData = Zend_Auth::getInstance()->getStorage()->read(); $sRole = $aData['role']; } else { // Default role $sRole = 'guest'; } // Check access if (!$this->_oAcl->isAllowed($sRole, $sControllerName, $sActionName)) { $oHttpRequest->setParam('referer_controller', $sControllerName); $oHttpRequest->setParam('referer_action', $sActionName); $aParams = array(); if (count($aRequestedParams)) { foreach ($aRequestedParams as $sKey => $sValue) { $aParams[] = $sKey; $aParams[] = $sValue; } $sQuery = implode('/', $aParams) . '/'; } $oHttpRequest->setParam('query', $sQuery); $oHttpRequest->setControllerName('auth')->setActionName('login'); $this->_response->setHttpResponseCode(401); } }
/** * Get all accepted submissions belonging to a conference * * @param integer $conferenceId conference_id * @param string $empty String containing the empty value to display */ public function getSubmissionsForSelect($conferenceId = null, $empty = null) { $return = array(); if ($empty) { $return[0] = $empty; } $identity = Zend_Auth::getInstance()->getIdentity(); $query = 'select st.submission_id, s.title from submission_status st left join submissions s ON s.submission_id = st.submission_id where st.status = :status AND s.conference_id = :conference_id'; if (!$identity->isAdmin()) { // if user is not admin, only show their own submissions $mySubmissions = implode(",", array_keys($identity->getMySubmissions())); if (!empty($mySubmissions)) { $query .= ' and st.submission_id IN (' . $mySubmissions . ')'; } else { return array(); } } $submissions = $this->getAdapter()->query($query, array('status' => $this->_getAcceptedValue(), 'conference_id' => $this->getConferenceId())); foreach ($submissions as $submission) { $return[$submission['submission_id']] = $submission['title']; } return $return; }
public function init() { parent::init(); $this->breadcrumbs->addStep('Account', $this->getUrl(null, 'account')); $this->breadcrumbs->addStep('Blog Manager', $this->getUrl(null, 'blogmanager')); $this->identity = Zend_Auth::getInstance()->getIdentity(); }
/** * Show sidebar * * @var int $pcategory Selected category * * @throws Exception 404, Category not found * */ public function sidebarAction() { $categoriesModel = new Model_DbTable_Categories(); $select = $categoriesModel->select(); $select->order(new Zend_Db_Expr('`order`<=-100'))->order("order"); if (!Zend_Auth::getInstance()->hasIdentity()) { $select->where("`order` != -100 OR `order` IS NULL"); } if (NULL != ($category_id = $this->getRequest()->getParam("category"))) { if (!($category = $categoriesModel->find($category_id)->current())) { throw new Exception("Category not found", 404); } $select->where("parent_id = ?", $category->id); $categories = $categoriesModel->fetchAll($select); if (count($categories) == 0) { $category = $categoriesModel->find($category->parent_id)->current(); $categories = $category->findDependentRowset("Model_DbTable_Categories"); } } else { $category = NULL; $categories = $categoriesModel->fetchAll($select->where("parent_id = ?", 0)); } $this->view->categories = $categories; $this->view->category = $category; $this->view->current = $category_id; $this->view->catalogs = new Zend_Config_Xml(APPLICATION_PATH . "/config/catalogs.xml"); }
public function logoutAction() { // уничтожаем информацию об авторизации пользователя Zend_Auth::getInstance()->clearIdentity(); // и отправляем его на главную $this->_helper->redirector('index', 'index'); }
public function init($styles = array()) { // Init messages $this->view->message = array(); $this->view->infoMessage = array(); $this->view->errorMessage = array(); $this->messenger = new Zend_Controller_Action_Helper_FlashMessenger(); $this->messenger->setNamespace('messages'); $this->_helper->addHelper($this->messenger); $this->errorMessenger = new Zend_Controller_Action_Helper_FlashMessenger(); $this->errorMessenger->setNamespace('errorMessages'); $this->_helper->addHelper($this->errorMessenger); $this->infoMessenger = new Zend_Controller_Action_Helper_FlashMessenger(); $this->infoMessenger->setNamespace('infoMessages'); $this->_helper->addHelper($this->infoMessenger); // Setup breadcrumbs $this->view->breadcrumbs = $this->buildBreadcrumbs($this->getRequest()->getRequestUri()); $this->view->user = Zend_Auth::getInstance()->getIdentity(); // Set the menu active element $uri = $this->getRequest()->getPathInfo(); if (strrpos($uri, '/') === strlen($uri) - 1) { $uri = substr($uri, 0, -1); } if (!is_null($this->view->navigation()->findByUri($uri))) { $this->view->navigation()->findByUri($uri)->active = true; } $this->view->styleSheets = array_merge(array('css/styles.css'), $styles); $translate = Zend_Registry::get('tr'); $this->view->tr = $translate; $this->view->setEscape(array('Lupin_Security', 'escape')); }
public function init() { $auth = Zend_Auth::getInstance(); $this->data_user = $auth->getIdentity(); if (!$auth->hasIdentity()) { $this->redirect('/login'); } else { $this->_acl_model = new Application_Model_Acl_Acl(); if (!$this->_acl_model->isAllowed()) { $this->redirect('/error/forbidden'); } } $this->view->user = $this->data_user; $this->view->model_user = new Application_Model_Usuarios(); $this->view->model = new Application_Model_Clientes(); $this->_modelUsers = new Application_Model_Usuarios(); $config = Zend_Controller_Front::getInstance()->getParam('bootstrap'); $this->_custom = $config->getOption('custom'); // Acessando permissões $this->_acl = $config->getOption('acl'); // Pegando array de configurações para a criação do menu $this->view->menu = $config->getOption('menu'); $this->_FlashMessenger = $this->_helper->getHelper('FlashMessenger'); $this->view->headTitle(strtoupper($this->getRequest()->getControllerName()) . ' | ' . $this->_custom['company_name']); $this->view->controllerName = $this->_controllerName = $this->getRequest()->getControllerName(); $this->view->actionName = $this->_actionName = $this->getRequest()->getActionName(); $this->view->user = $this->data_user; if ($this->data_user->childrens_ids) { $this->_ids = $this->data_user->childrens_ids; $this->_ids[] = CURRENT_USER_ID; } else { $this->_ids = array(CURRENT_USER_ID); } $this->view->date = new Zend_Date(); }
protected function _initView() { // Start initail view $this->bootstrap('layout'); $config = $this->getOption('views'); $resources = $this->getOption('resources'); $view = new Zend_View(); if (isset($resources['layout']['layoutPath'])) { $view->assign('layoutRootPath', $resources['layout']['layoutPath']); } $this->bootstrap('db'); Zend_Loader::loadClass('Ht_Utils_SystemSetting'); $sysSetting = Ht_Utils_SystemSetting::getSettings(); $view->assign('sysSetting', $sysSetting); $view->assign('profile', Zend_Auth::getInstance()->getIdentity()); Zend_Loader::loadClass("Ht_Model_SystemSetting"); $this->setSystemLogConfiguration($sysSetting); // use the viewrenderer to keep the code DRY // instantiate and add the helper in one go $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer'); $viewRenderer->setView($view); $viewRenderer->setViewSuffix('phtml'); // add it to the action helper broker Zend_Controller_Action_HelperBroker::addHelper($viewRenderer); /** * Set inflector for Zend_Layout */ $inflector = new Zend_Filter_Inflector(':script.:suffix'); $inflector->addRules(array(':script' => array('Word_CamelCaseToDash', 'StringToLower'), 'suffix' => 'phtml')); // Initialise Zend_Layout's MVC helpers $this->getResource('layout')->setLayoutPath(realpath($resources['layout']['layoutPath']))->setView($view)->setContentKey('content')->setInflector($inflector); return $this->getResource('layout')->getView(); }
/** * clears the user session and signs him out * @param $sessionName (string)session identifier * @return User */ public function clear($sessionName = 'userSessionName') { $auth = Zend_Auth::getInstance(); $auth->setStorage(new Zend_Auth_Storage_Session($sessionName)); $auth->clearIdentity(); $this->getTable()->recreateUserSession($sessionName); }
public function buildSQl() { $user_id = Zend_Auth::getInstance()->getIdentity()->id; $db = Zend_Db_Table_Abstract::getDefaultAdapter(); $sql = 'select c.id, c.ip, c.message, c.priority, c.id_user, c.logic, c.method, c.id_row, c.created_at from log.contact c '; $where = ' where c.ip != \'\' '; $join = ''; if (isset($this->filterdata['ip']) and $this->filterdata['ip']) { $where .= $db->quoteInto("\n and c.ip = ?\n ", $this->filterdata['ip']); } if (isset($this->filterdata['message']) and $this->filterdata['message']) { $where .= $db->quoteInto("\n and c.message ~* ?\n ", $this->filterdata['message']); } if (isset($this->filterdata['id_user']) and $this->filterdata['id_user']) { $where .= $db->quoteInto("\n and c.id_user = ?\n ", $this->filterdata['id_user']); } $sql .= $join; $sql .= $where; return $sql; }
public function processAction() { $authAdapter = new Zend_Auth_Adapter_DbTable(Zend_Registry::get('dbAdapter')); $authAdapter->setTableName('user')->setIdentityColumn('username')->setCredentialColumn('password')->setIdentity($_POST['username'])->setCredential($_POST['password']); $auth = Zend_Auth::getInstance(); $result = $auth->authenticate($authAdapter); $data = array(); if ($result->isValid()) { unset($this->_session->messages); $identity = $auth->getIdentity(); $user = new User(); $user->username = $identity; $user->populateWithUsername(); Zend_Auth::getInstance()->getStorage()->write($user); //$this->_redirect('login/complete'); //$this->_forward('index','main'); $data['msg'] = __("Login successful."); $data['code'] = 200; } else { $auth->clearIdentity(); $this->_session->messages = $result->getMessages(); //$this->_redirect('login'); $data['err'] = __("Invalid username/password."); $data['code'] = 404; } header('Content-Type: application/xml;'); $this->view->data = $data; $this->completeAction(); //$this->render(); }