public static function form($idConteudoPai) { $xhtml = ''; if (Auth_Session_User::getInstance()->authenticated()) { $_comentarForm = new Cms_Form_Conteudo_Edit(); $_comentarForm->loadElements("", "comment"); $_profile = ZendT_Profile::get('Cms_Form_Conteudo_Edit', '', 'comentario'); $_comentarForm->loadProfile($_profile); $_comentarForm->getElement('corpo')->editorHtml('comment')->setLabel(''); $_comentarForm->populate(array('id_conteudo_pai' => $idConteudoPai)); $_comentarForm->loadButtons(); $nomeUsuario = Auth_Session_User::getInstance()->getName(); $avatarUsuario = Auth_Session_User::getInstance()->getAvatar(); $xhtml = ' <li class="ui-helper-clearfix" id="comment-text"> <div class="header ui-helper-clearfix"> <span class="name">' . $nomeUsuario . '</span> </div> <div class="content ui-helper-clearfix"> <span class="avatar"> <img src="' . $avatarUsuario . '"> </span> <span class="message comment" calc-width-parent="" calc-width="-100"> ' . $_comentarForm . ' </span> </div> </li>'; } return $xhtml; }
public function getWhereSeekerSearch($value, $field = '') { $where = new ZendT_Db_Where('AND'); $result = array(); $result['column'] = ''; $result['operation'] = ''; $result['mapper'] = $this->getMapperName(); if (count($this->_primary) == 1) { if (is_numeric($value)) { $result['column'] = $this->_name . "." . $this->_primary[0]; $result['operation'] = '='; } } if ($result['column'] == '') { $result['column'] = $this->_name . "." . $this->_search; $result['operation'] = '='; $idEmpresa = Auth_Session_User::getInstance()->getIdEmpresa(); $_veiculo = new Frota_Model_Veiculo_Mapper(); $_veiculo->setPlaca($value)->setIdEmpresa($idEmpresa); if (!$_veiculo->exists()) { $_veiculo->setPlaca($value)->setDescricao($_veiculo->getPlaca())->setIdEmpresa($idEmpresa)->insert(); } } if ($value) { $where->addFilter($result['column'], $value, $result['operation'], $result['mapper']); } return $where; }
public function _beforeSave() { parent::_beforeSave(); if ($this->getIdEmpresa(true)->toPhp() == '') { $this->setIdEmpresa(Auth_Session_User::getInstance()->getIdEmpresa()); } }
public function deleteAction() { $this->_disableRender(); if ($this->getRequest()->getParam('all')) { $json = new ZendT_Json_Result(); try { if (!$this->getRequest()->getParam('confirmacao')) { $form = new ZendT_Form(); $form->setAction(ZendT_Url::getUri()); $params = $this->getRequest()->getParams(); $params['confirmacao'] = '1'; foreach ($params as $key => $val) { $element = new ZendT_Form_Element_Hidden($key); $element->setValue($val); $form->addElement($element); } $msg = "Deseja remover todas as notificações?"; throw new ZendT_Exception_Confirm($msg . $form->render()); } else { if (Auth_Session_User::getInstance()->authenticated()) { $this->getMapper()->setIdUsuario(Zend_Auth::getInstance()->getStorage()->read()->getId())->delete(); } $json->setResult(true); } } catch (Exception $ex) { $json->setException($ex); } echo $json->render(); } else { parent::deleteAction(); } }
protected function _getWhere($postData) { $where = false; if (ZendT_Acl::getInstance()->restriction('restringe-empresa', 'auth')) { $where = new ZendT_Db_Where('AND'); $where->addFilter('empresa.hierarquia', Auth_Session_User::getInstance()->getHierarquiaEmpresa(), '?%'); } return $where; }
public function _beforeSave() { parent::_beforeSave(); if ($this->_action != 'delete') { if ($this->getIdEmpresa(true)->toPhp() == '') { $this->setIdEmpresa(Auth_Session_User::getInstance()->getIdEmpresa()); } if ($this->getIdCliente(true)->toPhp() == '') { $_pessoa = new Ca_DataView_Pessoa_MapperView(); $_pessoa->setNome(_i18n('CONSUMIDOR')); $_pessoa->retrieve(); $this->setIdCliente($_pessoa->getId()); } if ($this->getIdClienteCon(true)->toPhp() == '') { $this->setIdClienteCon($this->getIdCliente()); } if ($this->getIdUsuInc(true)->toPhp() == '') { $this->setIdUsuInc(Auth_Session_User::getInstance()->getId()); } if ($this->getTipo(true)->toPhp() == '') { $this->setTipo('V'); } if ($this->getStatus(true)->toPhp() == '') { $this->setStatus('A'); } if ($this->getStatusEdi(true)->toPhp() == '') { $this->setStatusEdi('N'); } if ($this->getDtEmis(true)->toPhp() == '') { $this->setDtEmis(ZendT_Type_Date::nowDate()); } if ($this->getDhInc(true)->toPhp() == '') { $this->setDhInc(ZendT_Type_Date::nowDateTime()); } $this->setIdUsuAlt(Auth_Session_User::getInstance()->getId()); if ($this->getIdFuncionario(true)->toPhp() == '') { $_pessoa = new Ca_DataView_Pessoa_MapperView(); $_pessoa->setEmail(Auth_Session_User::getInstance()->getLogin()); $_pessoa->retrieve(); $this->setIdFuncionario($_pessoa->getId()); } if ($this->_action == 'update') { /*if ($this->getStatus()->toPhp() == 'A') { $this->_pagamento = new Vendas_DataView_Pagamento_MapperView(); $this->_saldoPagto = $this->_pagamento->getSaldoPagar($this->getId()); if ($this->_saldoPagto == 0) { $this->setStatus('P'); // pago } }*/ } } if ($this->_action == 'insert' && !$this->getNumero(true)->toPhp()) { $_numeracao = new Ca_Model_Numeracao_Mapper(); $numero = $_numeracao->proximo(self::$table . '.numero', $this->getIdEmpresa()->toPhp()); $this->setNumero($numero); } }
public function getSqlPriv($user = false, $column = 'profile_object_view.id') { if ($user) { $idUsuario = $user['id']; } else { $idUsuario = Auth_Session_User::getInstance()->getId(); } $sqlPriv = "(SELECT 1\n FROM " . Profile_Model_ObjectViewPriv_Mapper::$table . " object_view_sec\n JOIN " . Auth_Model_Conta_Mapper::$table . " conta_sec ON (object_view_sec.id_papel = conta_sec.id)\n JOIN " . Auth_Model_ContaRel_Mapper::$table . " conta_rel_sec ON (conta_rel_sec.id_papel = " . $idUsuario . ")\n JOIN " . Auth_Model_Conta_Mapper::$table . " conta_usu_sec ON (conta_rel_sec.id_papel_rel = conta_usu_sec.id)\n WHERE object_view_sec.id_profile_object_view = " . $column . "\n AND conta_usu_sec.hierarquia LIKE " . $this->getModel()->getAdapter()->concat(array("conta_sec.hierarquia", "'%'")) . ")"; return $sqlPriv; }
public function processLanc() { $_lancamentos = new Financeiro_DataView_Lancamento_MapperView(); $_where = new ZendT_Db_Where(); $_where->addFilter('fc_lancamento.dt_lanc', ZendT_Type_Date::nowDate(), '<='); if (Auth_Session_User::getInstance()->getIdEmpresa()) { $_where->addFilter('fc_lancamento.id_empresa', Auth_Session_User::getInstance()->getIdEmpresa()); } $_where->addFilter('fc_lancamento.vlr_saldo', '', '=', '', true); $_lancamentos->findAll($_where); while ($_lancamentos->fetch()) { $_lancamentos->update(); } }
public function proximo($nome, $idEmpresa = false) { if (!$idEmpresa) { $idEmpresa = Auth_Session_User::getInstance()->getIdEmpresa(); } $this->newRow()->setIdEmpresa($idEmpresa)->setNome($nome)->retrieve(); if (!$this->getId(true)->toPhp()) { $this->setIdEmpresa($idEmpresa)->setNome($nome)->setTamanho(10)->setNumero(0)->insert(); } $numero = $this->getNumero()->toPhp(); $numero = $numero + 1; $this->setNumero($numero)->update(); $numero = str_pad($numero, $this->getTamanho(true)->toPhp(), '0', STR_PAD_LEFT); return $numero; }
public function indexAction() { $debug = $this->getRequest()->getParam('debug'); $this->view->topApps = Auth_Session_User::getInstance()->getApps(false); $this->view->allApps = Auth_Session_User::getInstance()->getApps(); if ($debug) { $this->view->banners = array(); $this->view->noticias = array(); $this->view->paraVoce = array(); $this->view->qualidade = array(); } else { $this->view->banner = $this->_getContent('banner'); $this->view->noticia = $this->_getContent('noticias'); $this->view->paraVoce = $this->_getContent('com-voce'); $this->view->qualidade = $this->_getContent('com-qualidade'); } $this->setLayout(ZendT_Controller_Action::LAYOUT_INTRANET); }
public function _beforeSave() { parent::_beforeSave(); if ($this->_action == 'insert' && !$this->getNumero(true)->toPhp()) { $_numeracao = new Ca_Model_Numeracao_Mapper(); $numero = $_numeracao->proximo(self::$table . '.numero', $this->getIdEmpresa(true)->toPhp()); $this->setNumero($numero); } if ($this->getIdEmpresa(true)->toPhp() == '') { $this->setIdEmpresa(Auth_Session_User::getInstance()->getIdEmpresa()); } if ($this->getIdCliente(true)->toPhp() == '') { $_pessoa = new Ca_DataView_Pessoa_MapperView(); $_pessoa->setNome(_i18n('CONSUMIDOR')); $_pessoa->retrieve(); $this->setIdCliente($_pessoa->getId()); } }
public function _beforeSave() { if ($this->_action != 'delete') { if ($this->getIdUsuInc(true)->toPhp() == '') { $this->setIdUsuInc(Auth_Session_User::getInstance()->getId()); } $this->setIdUsuAlt(Auth_Session_User::getInstance()->getId()); if ($this->getQtdItem(true)->toPhp() == '') { $this->setQtdItem(1); } if ($this->getPerAcre(true)->toPhp() == '') { $this->setPerAcre(0); } if ($this->getPerDesc(true)->toPhp() == '') { $this->setPerDesc(0); } if ($this->getVlrItem(true)->toPhp() == '') { $_pedido = new Vendas_DataView_Pedido_MapperView(); $_pedido->setId($this->getIdPedido())->retrieve(); $_produto = new Vendas_DataView_ProdutoContrato_MapperView(); $_produto->setIdClienteCon($_pedido->getIdClienteCon())->setId($this->getIdProduto()); $row = $_produto->retrieveRow($_where); if (!$row) { throw new ZendT_Exception_Alert(_i18n('Não foi possível determinar o valor do produto!')); } else { $this->setVlrItem($row['vlr_final']); } } if ($this->getVlrFinal(true)->toPhp() == '') { $vlrFinal = $this->getVlrItem()->toPhp() * $this->getQtdItem()->toPhp(); $vlrOrig = $vlrFinal; if ($this->getPerAcre()->toPhp() > 0) { $vlrAcre = $vlrOrig * $this->getPerAcre()->toPhp() / 100; $vlrFinal += $vlrAcre; } if ($this->getPerDesc()->toPhp() > 0) { $vlrDesc = $vlrOrig * $this->getPerDesc()->toPhp() / 100; $vlrFinal += $vlrDesc; } $this->setVlrFinal($vlrFinal); } } }
public static function get($objectName, $type, $profile = '') { $_priv = new Profile_Model_ObjectViewPriv_Mapper(); $sqlPriv = $_priv->getSqlPriv(); $config = array(); $row = false; $idUsuario = Auth_Session_User::getInstance()->getId(); $idProfile = ''; $_profile = new Profile_DataView_ObjectView_MapperView(); $request = Zend_Controller_Front::getInstance()->getRequest(); if (is_object($request)) { if (!$profile) { $profile = $request->getParam('profile'); } $parentId = $request->getParam('profile_parent_id'); $profileKey = $request->getParam('profile_key'); } if ($parentId && is_numeric($parentId)) { $_profile->newRow()->setId($parentId)->retrieve(); $chave = $_profile->getChave()->get(); /** * */ $_where = new ZendT_Db_Where('AND'); $_where->addFilter('profile_object_view.objeto', $objectName); $_where->addFilter('profile_object_view.chave', $chave); if (is_array($type)) { $_where->addFilter('profile_object_view.tipo', $type, 'in'); } else { if ($type) { $_where->addFilter('profile_object_view.tipo', $type); } } $_whereSec = new ZendT_Db_Where('OR'); $_whereSec->addFilter('profile_object_view.id_usuario', $idUsuario); $_whereSec->addFilter('acesso_liberado', new Zend_Db_Expr($sqlPriv), 'EXISTS'); $_whereGroup = new ZendT_Db_Where_Group(); $_whereGroup->addWhere($_whereSec); $_whereGroup->addWhere($_where); $row = $_profile->retriveRow($_whereGroup); if ($row) { $profile = $row['id']->get(); } } if (!$profile) { if ($profileKey) { $_where = new ZendT_Db_Where('AND'); $_where->addFilter('profile_object_view.objeto', $objectName); $_where->addFilter('profile_object_view.chave', $profileKey); if (is_array($type)) { $_where->addFilter('profile_object_view.tipo', $type, 'in'); } else { if ($type) { $_where->addFilter('profile_object_view.tipo', $type); } } $row = $_profile->retriveRow($_where); if ($row) { $profile = $row['id']->get(); } } } if ($profile) { if (!is_numeric($profile)) { $_where = new ZendT_Db_Where('AND'); $_where->addFilter('profile_object_view.objeto', $objectName); $_where->addFilter('profile_object_view.chave', $profile, '='); $row = $_profile->retriveRow($_where); if ($row) { $profile = $row['id']->get(); } } $idProfile = $profile; } if (isset($_COOKIE['profile-' . $objectName . '-' . $type]) && $idProfile == '') { $idProfile = $_COOKIE['profile-' . $objectName . '-' . $type]; } if (isset($_COOKIE['profile-' . $objectName]) && $idProfile == '') { $idProfile = $_COOKIE['profile-' . $objectName]; } if (isset($_SESSION['profile-' . $objectName]) && $idProfile == '') { $idProfile = $_SESSION['profile-' . $objectName]; } if ($idProfile) { $_where = new ZendT_Db_Where(); $_where->addFilter('profile_object_view.id', $idProfile); $_whereSec = new ZendT_Db_Where('OR'); $_whereSec->addFilter('profile_object_view.id_usuario', $idUsuario); $_whereSec->addFilter('acesso_liberado', new Zend_Db_Expr($sqlPriv), 'EXISTS'); $_whereGroup = new ZendT_Db_Where_Group(); $_whereGroup->addWhere($_whereSec); $_whereGroup->addWhere($_where); $row = $_profile->retriveRow($_whereGroup); } if ($idUsuario && !$row) { $_where = new ZendT_Db_Where('AND'); $_where->addFilter('profile_object_view.objeto', $objectName); $_where->addFilter('profile_object_view.padrao', 'S'); if (is_array($type)) { $_where->addFilter('profile_object_view.tipo', $type, 'in'); } else { if ($type) { $_where->addFilter('profile_object_view.tipo', $type); } } $_whereSec = new ZendT_Db_Where('OR'); $_whereSec->addFilter('profile_object_view.id_usuario', $idUsuario); $_whereSec->addFilter('acesso_liberado', new Zend_Db_Expr($sqlPriv), 'EXISTS'); $_whereGroup = new ZendT_Db_Where_Group(); $_whereGroup->addWhere($_whereSec); $_whereGroup->addWhere($_where); $row = $_profile->retriveRow($_whereGroup); } if ($idUsuario && !$row) { $_where = new ZendT_Db_Where('AND'); $_where->addFilter('profile_object_view.objeto', $objectName); if (is_array($type)) { $_where->addFilter('profile_object_view.tipo', $type, 'in'); } else { if ($type) { $_where->addFilter('profile_object_view.tipo', $type); } } $_whereSec = new ZendT_Db_Where('OR'); $_whereSec->addFilter('profile_object_view.id_usuario', $idUsuario); $_whereSec->addFilter('acesso_liberado', new Zend_Db_Expr($sqlPriv), 'EXISTS'); $_whereGroup = new ZendT_Db_Where_Group(); $_whereGroup->addWhere($_whereSec); $_whereGroup->addWhere($_where); $row = $_profile->retrieveRow($_whereGroup); } if ($row) { $config = unserialize(html_entity_decode($row['config']->get())); $config['id'] = $row['id']->get(); $config['tipo'] = $row['tipo']->toPhp(); $config['title'] = $row['nome']->get(); } return $config; }
public function run($where = '') { $this->_log('Iniciado: ' . date('d/m/Y H:s:i')); Auth_Session_User::refresh('JOB_VSP'); $_pedido = new Vendas_DataView_Pedido_MapperView(); $_vistoria = new Vendas_DataView_Vistoria_MapperView(); $_where = new ZendT_Db_Where(); $_where->addFilter('pedido.id_empresa', Auth_Session_User::getInstance()->getIdEmpresa()); $_where->addFilter('cliente.codigo', '33164021000100'); if (isset($where['placa'])) { $_where->addFilter('veiculo.placa', $where['placa']); } else { $_where->addFilter('pedido.status_edi', 'N'); } if (isset($where['dt_emis']) && $where['dt_emis']) { if (!is_array($where['dt_emis'])) { $where['dt_emis'] = array($where['dt_emis']); } $where['dt_emis'][0] = new ZendT_Type_Date($where['dt_emis'][0], 'Date'); if (!isset($where['dt_emis'][1])) { $where['dt_emis'][1] = $where['dt_emis'][0]; } else { $where['dt_emis'][1] = new ZendT_Type_Date($where['dt_emis'][1], 'Date'); } $_where->addFilter('pedido.dt_emis', $where['dt_emis'], 'BETWEEN'); } $sql = "(SELECT 1" . " FROM " . Vendas_DataView_Vistoria_MapperView::$table . " as vistoria " . " WHERE vistoria.id_pedido = pedido.id" . " AND vistoria.laudo IS NOT NULL)"; $_where->addFilterExists($sql); $_pedido->findAll($_where, '*'); $total = $_pedido->getCountRows(); $seq = 1; while ($row = $_pedido->fetch()) { try { $this->_log("Processando " . $seq . " de " . $total . ", Placa: " . $row['placa_veiculo']); $_vistoria->newRow()->setIdPedido($_pedido->getId())->retrieve(); $pdf = $_vistoria->getLaudo()->getFile(); $fileName = $pdf->getFilename(); $dtConclusao = date("d/m/Y", $_vistoria->getDtEmis()->toPhp()); /* var_dump($fileName); exit; */ $this->postPdf($row['placa_veiculo'], $row['sinistro'], $fileName, $dtConclusao); $_pedido->setStatusEdi('T'); } catch (Exception $ex) { $message = 'Mensagem: ' . $ex->getMessage() . "\n"; //$message.= 'Erro: ' . $ex->getTraceAsString() . "\n"; $_pedido->setStatusEdi('E'); Vendas_Model_LogPedido_Mapper::log($_pedido->getId(), $ex->getMessage()); Tools_Model_LogErro_Mapper::log('Vendas_Interface_Vsp_Tokio', $message); $this->_log('Placa: ' . $row['placa_veiculo'] . ', Erro: ' . $message); } $_pedido->update(); $seq++; } echo "OK"; $this->_log('Finalizado: ' . date('d/m/Y H:s:i')); }
/** * Levando os dados do ACL * * @return bool */ public function startup($options = array('validSession' => true)) { $this->_started = true; $token = Zend_Controller_Front::getInstance()->getRequest()->getParam('token'); $__idUserToken__ = Zend_Controller_Front::getInstance()->getRequest()->getParam('__idUserToken__'); $__codeToken__ = Zend_Controller_Front::getInstance()->getRequest()->getParam('__codeToken__'); $noLocation = Zend_Controller_Front::getInstance()->getRequest()->getParam('no_location'); /** * Resgate os parâmetros usados no roteamento do FrontController * para carregarmos no Zend_Acl * * Carregue o Acl de acordo com o módulo que o usuário querer * acessar */ if (isset($options['module'])) { $moduleName = $options['module']; } else { $moduleName = Zend_Controller_Front::getInstance()->getRequest()->getModuleName(); } if (isset($options['controller'])) { $controllerName = $options['controller']; } else { $controllerName = Zend_Controller_Front::getInstance()->getRequest()->getControllerName(); } $actionName = Zend_Controller_Front::getInstance()->getRequest()->getActionName(); /** processo usado para os sistemas que estão dentro do VB, não usar para os sistemas em PHP */ if ($__idUserToken__ != '') { Zend_Auth::getInstance()->getStorage()->clear(); $idUser = $__idUserToken__ * 1; $codeToken = $__codeToken__ * 1; if ($idUser == 0) { $idUser = 1; } if ($codeToken == 0) { $codeToken = -1; } $idUser = $idUser / 70; # algorítmo com a criptografia $idUser = $idUser / $codeToken; /** * Levanto o objeto para o usuário * Resgato os dados do usuário da sessão */ $user = $this->_getUser(); $rowSession = $user->getRowSession($idUser); /** * Verifico se existe id do usuário na sessão * se não escreva nela os dados do usuário */ if ($rowSession->getId() != '') { if (!$noLocation) { if ($_SESSION["logon"]["usuario"] != $rowSession->getLogin()) { header('location:/Application/index.php?email=' . $rowSession->getLogin() . '&urlLocation=' . $_SERVER['PHP_SELF'] . '&module=' . $moduleName); exit; } } else { $storage = Zend_Auth::getInstance()->getStorage(); $storage->write($rowSession); Zend_Auth::getInstance()->setStorage($storage); /** * Usado para sistema legado */ $_SESSION["logon"]["active"] = 1; $_SESSION["logon"]["id_usuario"] = $rowSession->getId(); $_SESSION["logon"]["usuario"] = $rowSession->getLogin(); $_SESSION["logon"]["nome"] = $rowSession->getName(); $_SESSION["logon"]["papel"] = $rowSession->getRole(); $_SESSION["logon"]["empresa"] = $rowSession->getEmpresa(); $_SESSION["logon"]["filial"] = $rowSession->getFilial(); } } else { $rowSession = new stdClass(); } unset($user); } else { if ($token) { $rowSession = new ZendT_Acl_User_Row(); $rowSession->fromToken($token); /** * Usado para sistema legado */ $_SESSION["logon"]["active"] = 1; $_SESSION["logon"]["id_usuario"] = $rowSession->getId(); $_SESSION["logon"]["usuario"] = $rowSession->getLogin(); $_SESSION["logon"]["nome"] = $rowSession->getName(); $_SESSION["logon"]["papel"] = $rowSession->getRole(); } else { #$rowSession = Zend_Auth::getInstance()->getStorage()->read(); $rowSession = Auth_Session_User::getInstance()->getRowSession(); } } if (!$rowSession instanceof ZendT_Acl_User_Row) { /** * Usado para sistema legado */ $rowSession = new ZendT_Acl_User_Row(); $rowSession->setId($_SESSION["logon"]["id_usuario"]); $rowSession->setLogin($_SESSION["logon"]["usuario"]); $rowSession->setName($_SESSION["logon"]["nome"]); $rowSession->setRole($_SESSION["logon"]["papel"]); } /** * Se não existir o id do usuário na sessão * e se o validar sessão estiver habilitado * * Retorne para o usuário a mensagem de sessão expirada */ if ($rowSession->getRole() == '' && $options['validSession']) { $this->_valid = false; $this->_message = "Sessão expirada, favor logar novamente!"; /** * Caso a sessão estiver de pé execute as regras relacionadas * a disposição dos elementos da intranet de acordo com seu papel * */ } else { /** * Implemente o papel default para o usuário caso não haja na sessão * um papel definido. */ if ($rowSession->getRole() == '') { $rowSession->setRole('DEFAULT'); } $this->loadAcl($moduleName); /** * Registro o recurso acessado montando uma string * com o module/controller/action */ $resource = strtolower($moduleName) . '.' . strtolower($controllerName) . '.' . strtolower($actionName); //action $roles = $rowSession->getRoles(); if ($actionName == 'filter-valid') { $this->_valid = true; } else { $this->_valid = $this->_isAllowed($rowSession->getRole(), $resource); //$this->_valid = $this->_acl->isAllowed($rowSession->getRole(), $resource); if (strpos($resource, 'cms.') !== false) { $this->_valid = true; } if (!$this->_valid && is_array($roles)) { foreach ($roles as $role) { $this->_valid = $this->_isAllowed($role, $resource); //$this->_valid = $this->_acl->isAllowed($role, $resource); if ($this->_valid) { break; } } } } #$rowSession->dataMenu = array(); if (!isset($rowSession->dataMenu[$moduleName])) { $dataMenu = $this->_getResource()->getMenu($moduleName); $roles = $rowSession->getRoles(); foreach ($dataMenu as $parentName => &$itens) { foreach ($itens as $menu) { //$isAllow = $this->_acl->isAllowed($rowSession->getRole(), $menu->getUrl()); $isAllow = $this->_isAllowed($rowSession->getRole(), $menu->getUrl()); if ($isAllow) { $rowSession->dataMenu[$moduleName][$parentName][] = $menu->toArray(); } if (!$isAllow && is_array($roles)) { foreach ($roles as $role) { //$isAllow = $this->_acl->isAllowed($role, $menu->getUrl()); $isAllow = $this->_isAllowed($role, $menu->getUrl()); if ($isAllow) { $rowSession->dataMenu[$moduleName][$parentName][] = $menu->toArray(); break; } } } } } $rowSession->dataMenuEncode[$moduleName] = 'UTF8'; /** * @todo */ /* if ($rowSession->dataMenu[$moduleName]){ $rowSession->dataMenu[$moduleName] = 'loaded'; } */ $storage = Zend_Auth::getInstance()->getStorage(); $storage->write($rowSession); Zend_Auth::getInstance()->setStorage($storage); } $this->_message = "Acesso não autorizado!"; } }
protected function _restritionSql() { $idUsuario = Auth_Session_User::getInstance()->getId(); return "(\n /**\n * privilégio por usuário na categoria\n */\n SELECT 1\n FROM cms_categoria ct\n JOIN cms_categoria ct_pai\n ON (ct.chave LIKE ct_pai.chave || '%')\n JOIN cms_priv_categ pc\n ON (pc.id_categoria = ct_pai.id)\n WHERE ct.id = cms_categoria.id\n AND pc.id_usuario = {$idUsuario}\n\n UNION ALL\n\n /**\n * privilégio por papel na categoria\n */\n SELECT 1\n FROM cms_categoria ct\n JOIN cms_categoria ct_pai\n ON (ct.chave LIKE ct_pai.chave || '%')\n JOIN cms_priv_categ pc\n ON (pc.id_categoria = ct_pai.id)\n JOIN prouser.papel pa\n ON (pc.id_papel = pa.id)\n WHERE ct.id = cms_categoria.id\n AND EXISTS (SELECT 1\n FROM prouser.usuario_papel up\n JOIN prouser.papel pu\n ON (up.id_papel = pu.id)\n WHERE up.id_usuario = {$idUsuario}\n AND pu.nome LIKE pa.nome || '%'\n UNION ALL\n SELECT 1\n FROM prouser.usuario us\n JOIN prouser.papel pu\n ON (us.id_papel = pu.id)\n WHERE us.id = {$idUsuario}\n AND pu.nome LIKE pa.nome || '%') \n )"; }
public function copyAction() { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $json = new ZendT_Json_Result(); try { $idUsuario = Auth_Session_User::getInstance()->getId(); $id = $this->getRequest()->getParam('id'); $nome = $this->getRequest()->getParam('nome'); $privileges = $this->getRequest()->getParam('privileges'); $this->getMapper()->setId($id); $this->getMapper()->retrive(); $this->getMapper()->setId(null); $this->getMapper()->setNome($nome); $this->getMapper()->setIdUsuario($idUsuario); $this->getMapper()->insert(); $idCopyFrom = ''; if ($privileges) { $idCopyFrom = $id; } $this->getMapper()->setDefaultPrivilege($this->getMapper()->getId(), $idCopyFrom); $json->setResult($this->getMapper()->getId()->get()); } catch (Exception $ex) { $json->setException($ex); } echo $json->render(); }
/** * * @param string|int $categoria * @param string $orderBy * @return array */ protected function _list($categoria, $idConteudoPai = '', $orderBy = '') { $this->_removeLob = false; $_fileSystem = new Ged_Model_Arquivo_FileSystem(); $idUsuario = Auth_Session_User::getInstance()->getId(); $_auth = new Auth_Model_Usuario_Mapper(); $_auth->setLogin('GUEST')->retrieve(); $avatarGuest = $_auth->getAvatar(true)->toPhp(); /** * caso seja uma string retorna o id */ $idCategoria = $this->_getIdCategoria($categoria); if (!$orderBy) { $orderBy = 'cms_conteudo.dh_ini_pub'; } $_whereGroup = new ZendT_Db_Where_Group('AND'); $_where = new ZendT_Db_Where(); $_where->addFilter("cms_conteudo.id_categoria", $idCategoria); if ($idConteudoPai) { $_where->addFilter("cms_conteudo.id_conteudo_pai", $idConteudoPai); } $_where->addFilter("cms_conteudo.dh_ini_pub", ZendT_Type_Date::nowDateTime(), "<="); $_where->addFilter("status.acao", "A"); $_whereGroup->addWhere($_where); $_where = new ZendT_Db_Where('OR'); $_where->addFilter("cms_conteudo.dh_fim_pub", ZendT_Type_Date::nowDateTime(), ">="); $_where->addFilter("cms_conteudo.dh_fim_pub", "", "NULL"); $_whereGroup->addWhere($_where); //($where, $retrieve = false, $found = false, $orderBy='1') $_recordset = $this->recordset($_whereGroup, false, false, $orderBy); $data = array(); $result = array(); while ($data = $_recordset->getRow()) { $data['url'] = ZendT_Url::getBaseUrl() . '/cms/conteudo/view/id/' . $data['id']->toPhp(); $thumbnail = $data['thumbnail']->toPhp(); if (!$thumbnail) { $_conteudo = new Cms_Model_Conteudo_Mapper(); $_conteudo->setChave('generic')->retrieve(); $thumbnail = $_conteudo->getThumbnail(true)->toPhp(); } $data['thumbnail'] = $_fileSystem->getDirectoryAdress($thumbnail); $data['banner'] = $_fileSystem->getDirectoryAdress($data['banner']->toPhp()); $avatar = $data['avatar_usuario_inc']->toPhp(); if (!$avatar) { $avatar = $avatarGuest; //avatar genérico } $data['avatar_usuario_inc'] = $_fileSystem->getDirectoryAdress($avatar); $data['html_like'] = Cms_Helper_Likes::button($data['id']); $data['html_comment'] = Cms_Helper_Feeds::button($data['id']); if ($data['id_usuario_inc']->toPhp() == $idUsuario) { $data['nome_usuario_inc'] = 'Você'; } $result[] = $data; } return $result; }
public function comment($idConteudo, $corpo, $onlyLoad = false) { if (!$onlyLoad) { if (Auth_Session_User::getInstance()->authenticated()) { $corpo = strip_tags(trim($corpo)); if ($corpo) { $idUsuario = Auth_Session_User::getInstance()->getId(); $this->populateConteudo($this->_getIdCategoria('comment'), $idConteudo, $idUsuario); $this->setIdStatus($this->_getIdStatus('comment')); $this->setTitulo(md5($corpo)); if (!$this->exists()) { $this->setCorpo($corpo); $this->insert(); } } else { throw new ZendT_Exception("Favor preencher o comentário!"); } } else { throw new ZendT_Exception("Apenas usuários autenticados podem comentar os conteúdos!"); } } return true; }
public static function get($idUsuario = '', $format = true) { if (!$idUsuario) { $idUsuario = Auth_Session_User::getInstance()->getId(); } $_notificacao = new Cms_DataView_Notificacao_MapperView(); $_notificacao->setIdUsuario($idUsuario)->findAll(null, '*'); if ($format) { $notificacoes = array(); $_conteudo = new Cms_Model_Conteudo_Mapper(); $_categoria = new Cms_Model_Categoria_Mapper(); $_categoriaPai = new Cms_Model_Categoria_Mapper(); while ($_notificacao->fetch()) { $_conteudo->setId($_notificacao->getIdConteudo())->retrieve(); $_categoria->setId($_conteudo->getIdCategoria())->retrieve(); $conteudo = $_conteudo->getTitulo()->get(); if (strlen($conteudo) > 10) { $conteudo = substr($conteudo, 1, 10) . "..."; } $titulo = $_categoria->getDescricao()->get() . " (" . $conteudo . ")"; if ($_categoria->getIdCategoriaPai()->get()) { $_categoriaPai->setId($_categoria->getIdCategoriaPai())->retrieve(); $titulo = $_categoriaPai->getDescricao()->get() . " - " . $titulo; } $url = Cms_Model_Conteudo_Mapper::getUrlView($_conteudo->getId()->get(), $_categoria->getIdByDescricao("Para você")); $notificacoes[] = array('id' => $_conteudo->getId()->get(), 'titulo' => $titulo, 'url' => $url); } return $_notificacao->_getLayout($notificacoes); } return $_notificacao; }
public function runLaudos($where = array()) { $this->_log('Iniciado: ' . date('d/m/Y H:s:i')); Auth_Session_User::refresh('JOB_VSP'); $this->_token = $this->_doLogin(); $_pedido = new Vendas_DataView_Pedido_MapperView(); $_vistoria = new Vendas_DataView_Vistoria_MapperView(); $_where = new ZendT_Db_Where(); $_where->addFilter('pedido.id_empresa', Auth_Session_User::getInstance()->getIdEmpresa()); if (isset($where['placa'])) { $_where->addFilter('veiculo.placa', $where['placa']); } else { $_where->addFilter('pedido.status_edi', 'N'); } if (isset($where['cnpj_cliente']) && $where['cnpj_cliente']) { $_where->addFilter('cliente.codigo', $where['cnpj_cliente']); //33164021000100 } if (isset($where['dt_emis']) && $where['dt_emis']) { if (!is_array($where['dt_emis'])) { $where['dt_emis'] = array($where['dt_emis']); } $where['dt_emis'][0] = new ZendT_Type_Date($where['dt_emis'][0], 'Date'); if (!isset($where['dt_emis'][1])) { $where['dt_emis'][1] = $where['dt_emis'][0]; } else { $where['dt_emis'][1] = new ZendT_Type_Date($where['dt_emis'][1], 'Date'); } $_where->addFilter('pedido.dt_emis', $where['dt_emis'], 'BETWEEN'); } $sql = "(SELECT 1" . " FROM " . Vendas_DataView_Vistoria_MapperView::$table . " as vistoria " . " WHERE vistoria.id_pedido = pedido.id" . " AND vistoria.laudo IS NULL)"; $_where->addFilterExists($sql); $_pedido->findAll($_where, '*'); $total = $_pedido->getCountRows(); $seq = 1; while ($row = $_pedido->fetch()) { try { $this->_log("Processando " . $seq . " de " . $total . ", Placa: " . $row['placa_veiculo']); $_vistoria->newRow(); $_vistoria->setIdPedido($row['id'])->retrieve(); if ($_vistoria->getLaudo(true)->toPhp() == '' && $_vistoria->getNumero(true)->toPhp() != '') { $laudo = $this->_laudo($_vistoria->getNumero()->get()); if ($laudo) { $_laudo = new ZendT_File(str_replace(array('-', '/'), '_', $_vistoria->getNumero()->get()) . '.pdf', $laudo, 'application/pdf'); $dataLaudo = array(); $dataLaudo['file'] = $_laudo; $_vistoria->setLaudo($dataLaudo); $_vistoria->update(); } } } catch (Exception $ex) { $message = 'Mensagem: ' . $ex->getMessage() . "\n"; $message .= 'Erro: ' . $ex->getTraceAsString() . "\n"; Vendas_Model_LogPedido_Mapper::log($_pedido->getId(), $ex->getMessage()); Tools_Model_LogErro_Mapper::log('Vendas_Interface_Vsp_Tokio', $message); $this->_log('Placa: ' . $row['placa_veiculo'] . ', Erro: ' . $message); } $seq++; } $this->_log('Finalizado: ' . date('d/m/Y H:s:i')); echo "OK"; }