/** * Retorna a lista de Profile para o Formulário * * @param string $formName * @return array */ public function getListProfile($formName) { $listProfile = array(); $_profile = new Profile_DataView_ObjectView_MapperView(); $session = Zend_Auth::getInstance()->getStorage()->read(); $login = ''; if ($session !== null) { $login = $session->getLogin(); $_where = new ZendT_Db_Where(); $_where->addFilter('login', $login); $_where->addFilter('objeto', $formName); $_where->addFilter('tipo', 'F'); $_where->addFilter('publico', 'N'); $_profile->findAll($_where, array('id', 'nome'), array('2')); while ($_profile->fetch()) { $key = $_profile->getId()->get(); $value = $_profile->getNome()->get(); $listProfile[$key] = $value; } } $_where = new ZendT_Db_Where(); $_where->addFilter('objeto', $formName); $_where->addFilter('tipo', 'F'); $_where->addFilter('publico', 'S'); $_profile->findAll($_where, array('id', 'nome'), array('2')); while ($_profile->fetch()) { $key = $_profile->getId()->get(); $value = $_profile->getNome()->get(); $listProfile[$key] = $value; } return $listProfile; }
/** * Lista os Profile do usuário, para preencher o Combobox * * @param string $objectName * @param string $type * @param array $user * @return array */ public static function listProfile($objectName, $type = '', $user = array()) { $_priv = new Profile_Model_ObjectViewPriv_Mapper(); $sqlPriv = $_priv->getSqlPriv(); $listProfile = array(); $_profile = new Profile_DataView_ObjectView_MapperView(); $_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); } } $profileKey = Zend_Controller_Front::getInstance()->getRequest()->getParam('profile_key'); if ($profileKey) { $_where->addFilter('profile_object_view.chave', $profileKey); } $_whereSec = new ZendT_Db_Where('OR'); $_whereSec->addFilter('profile_object_view.id_usuario', Auth_Session_User::getInstance()->getId()); $_whereSec->addFilter('acesso_liberado', new Zend_Db_Expr($sqlPriv), 'EXISTS'); $_whereGroup = new ZendT_Db_Where_Group(); $_whereGroup->addWhere($_whereSec); $_whereGroup->addWhere($_where); $_profile->findAll($_whereGroup, array('id', 'tipo', 'nome', 'observacao', 'config'), array('2', '3')); while ($_profile->fetch()) { $key = $_profile->getId()->get(); $listProfile[$key] = array('tipo' => $_profile->getTipo()->toPhp(), 'tipoDescricao' => $_profile->getTipo()->get(), 'nome' => $_profile->getNome()->get(), 'observacao' => $_profile->getObservacao()->get(), 'config' => $_profile->getConfig()->get()); } return $listProfile; }