Beispiel #1
0
 /**
  * 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;
 }