getDefaultAdapter() public static method

Gets the default Zend_Db_Adapter_Abstract for all Zend_Db_Table objects.
public static getDefaultAdapter ( ) : Zend_Db_Adapter_Abstract
return Zend_Db_Adapter_Abstract or null
示例#1
0
 public static function authenticate(array $values)
 {
     $email = isset($values['email']) ? $values['email'] : null;
     $senha = isset($values['senha']) ? $values['senha'] : null;
     if (!count($values)) {
         throw new Exception('Não foi passado valores para autenticar');
     }
     // Pegar os dados da autenticacao e checa
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);
     $authAdapter->setTableName('usuario')->setIdentityColumn('email')->setCredentialColumn('senha');
     $authAdapter->setIdentity($email)->setCredential($senha)->setCredentialTreatment('MD5(?)');
     $select = $authAdapter->getDbSelect();
     $select->join(array('g' => 'grupo'), 'g.id = usuario.grupo_id', array('grupo' => 'nome'));
     //Realiza autenticação
     $result = $authAdapter->authenticate();
     //Verifica se a autenticação foi válida
     if ($result->isValid()) {
         //Obtém dados do usuário
         $usuario = $authAdapter->getResultRowObject();
         //Armazena seus dados na sessão
         $storage = Zend_Auth::getInstance()->getStorage();
         $storage->write($usuario);
         //Redireciona para o Index
         return true;
     }
     return false;
 }
 public function init()
 {
     $this->getHelper('layout')->disableLayout();
     $this->_db = Zend_Db_Table_Abstract::getDefaultAdapter();
     $cfg = Zend_Registry::get('cfg');
     $this->_docsPath = $cfg['docs']['path'];
 }
示例#3
0
 /**
  * 
  * @return int|bool
  */
 public function save()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $row = $this->_checkNameDepartment($this->_data);
         if (!empty($row)) {
             $this->_message->addMessage('Departamentu iha tiha ona.', App_Message::ERROR);
             return false;
         }
         if (empty($this->_data['id_department'])) {
             $history = 'INSERE DEPARTAMENTU: %s DADUS PRINCIPAL - INSERE NOVO DEPARTAMENTU';
         } else {
             $history = 'ALTERA DEPARTAMENTU: %s DADUS PRINCIPAL - ALTERA DEPARTAMENTU';
         }
         $id = parent::_simpleSave();
         $history = sprintf($history, $this->_data['name']);
         $this->_sysAudit($history);
         $dbAdapter->commit();
         return $id;
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }
示例#4
0
 /**
  * 
  * @return int|bool
  */
 public function save()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $row = $this->_checkClassTimor($this->_data);
         if (!empty($row)) {
             $this->_message->addMessage('Klase Timor-Leste iha tiha ona.', App_Message::ERROR);
             return false;
         }
         if (empty($this->_data['id_isicclasstimor'])) {
             $history = 'REJISTRU CLASSE TIMOR: %s-%s';
         } else {
             $history = 'ALTERA CLASSE TIMOR: %s-%s';
         }
         $id = parent::_simpleSave();
         $history = sprintf($history, $this->_data['acronym'], $this->_data['name_classtimor']);
         $this->_sysAudit($history);
         $dbAdapter->commit();
         return $id;
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }
示例#5
0
 /**
  * 
  * @return int|bool
  */
 public function save()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $row = $this->_checkDistrict($this->_data);
         if (!empty($row)) {
             $this->_message->addMessage('Distritu iha tiha ona.', App_Message::ERROR);
             return false;
         }
         if (empty($this->_data['id_adddistrict'])) {
             $history = 'INSERE DISTRITU: %s - INSERIDO NOVO DISTRITU';
         } else {
             $history = 'ALTERA DISTRITU: %s - ALTUALIZADO DISTRITO COM SUCESSO';
         }
         $id = parent::_simpleSave();
         $history = sprintf($history, $this->_data['District']);
         $this->_sysAudit($history);
         $dbAdapter->commit();
         return $id;
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }
示例#6
0
文件: Dec.php 项目: fredcido/simuweb
 /**
  * 
  * @return int|bool
  */
 public function save()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $row = $this->_checkCeop($this->_data);
         if (!empty($row)) {
             $this->_message->addMessage('CEOP iha tiha ona.', App_Message::ERROR);
             return false;
         }
         if (empty($this->_data['id_dec'])) {
             $history = 'INSERE CEOP-DEC: %s- INSERIDO NOVO CEOP-DEC COM SUCESSO';
             $this->_data['fk_id_sysuser'] = Zend_Auth::getInstance()->getIdentity()->id_sysuser;
             $this->_data['registry_date'] = Zend_Date::now()->toString('yyyy-MM-dd');
         } else {
             $history = 'ALTERA CEOP-DEC: %s DADUS PRINCIPAL - ALTERA CEOP-DEC';
         }
         $id = parent::_simpleSave();
         $history = sprintf($history, $id);
         $this->_sysAudit($history);
         $dbAdapter->commit();
         return $id;
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }
示例#7
0
 /**
  * 
  * @return int|bool
  */
 public function save()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         //	    $row = $this->_checkOcupationTimor( $this->_data );
         //
         //	    if ( !empty( $row ) ) {
         //		$this->_message->addMessage( 'Okupasaun Timor-Leste iha tiha ona.', App_Message::ERROR );
         //		return false;
         //	    }
         if (empty($this->_data['id_profocupationtimor'])) {
             $history = 'INSERE OCUPASAUN TIMOR: %s DADUS PRINCIPAL - INSERE NOVO OCUPASAUN TIMOR';
         } else {
             $history = 'ALTERA Ocupasaun Timor: %s DADUS PRINCIPAL - ALTERA Ocupasaun Timor';
         }
         $id = parent::_simpleSave();
         $history = sprintf($history, $this->_data['ocupation_name_timor']);
         $this->_sysAudit($history);
         $dbAdapter->commit();
         return $id;
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }
 public function crearventa($total, $mesa, $fecha, $puntos_venta, $descuento, $observacion, $id_usuario)
 {
     $data = array('total' => $total, 'mesa' => $mesa, 'fecha' => $fecha, 'puntos_venta' => $puntos_venta, 'descuento' => $descuento, 'observacion' => $observacion, 'id_usuario' => $id_usuario);
     $this->insert($data, 0);
     $db = Zend_Db_Table_Abstract::getDefaultAdapter();
     return $db->lastInsertId();
 }
 public function browseAction()
 {
     $db = Zend_Db_Table_Abstract::getDefaultAdapter();
     $sql = "SELECT * FROM evaluation WHERE is_deleted = 0";
     $rowArray = $db->fetchAll($sql);
     $this->view->assign('evaluations', $rowArray);
 }
示例#10
0
 public function getAuthAdapter($values)
 {
     $authAdapter = new Zend_Auth_Adapter_DbTable(Zend_Db_Table_Abstract::getDefaultAdapter(), 'Utenti', 'Username', 'Password');
     $authAdapter->setIdentity($values['username']);
     $authAdapter->setCredential($values['password']);
     return $authAdapter;
 }
示例#11
0
 /**
  * 
  * @return int|bool
  */
 public function save()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $row = $this->_checkTypeBankAccount($this->_data);
         if (!empty($row)) {
             $this->_message->addMessage('Tipu Konta Banku iha tiha ona.', App_Message::ERROR);
             return false;
         }
         if (empty($this->_data['id_bank'])) {
             $history = 'INSERE TIPU KONTA BANKU: %s - INSERIDO NOVO TIPU KONTA BANKU';
         } else {
             $history = 'ALTERA TIPU KONTA BANKU: %s - ALTERADO TIPU KONTA BANKU';
         }
         $id = parent::_simpleSave();
         $history = sprintf($history, $this->_data['type_bankaccount']);
         $this->_sysAudit($history);
         $dbAdapter->commit();
         return $id;
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }
示例#12
0
 /**
  * 
  * @return int|bool
  */
 public function save()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $row = $this->_checkIsicGroup($this->_data);
         if (!empty($row)) {
             $this->_message->addMessage('Grupu Setor Industria iha tiha ona.', App_Message::ERROR);
             return false;
         }
         $mapperDivision = new Register_Model_Mapper_IsicDivision();
         $division = $mapperDivision->fetchRow($this->_data['fk_id_isicdivision']);
         $this->_data['acronym'] = $division->acronym . $this->_data['acronym'];
         if (empty($this->_data['id_isicgroup'])) {
             $history = 'REJISTRU GRUPU: %s';
         } else {
             $history = 'ALTERA GRUPU: %s';
         }
         $id = parent::_simpleSave();
         // Save the client history
         $history = sprintf($history, $this->_data['acronym']);
         $this->_sysAudit($history);
         $dbAdapter->commit();
         return $id;
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }
示例#13
0
 public function auth($usuario, $password)
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);
     $authAdapter->setTableName('cn_admin')->setIdentityColumn('email')->setCredentialColumn('password')->setIdentity($usuario)->setCredential(md5($password));
     $select = $authAdapter->getDbSelect();
     $select->where('flagactive = 1');
     $result = Zend_Auth::getInstance()->authenticate($authAdapter);
     if ($result->isValid()) {
         $storage = Zend_Auth::getInstance()->getStorage();
         $bddResultRow = $authAdapter->getResultRowObject();
         $storage->write($bddResultRow);
         $msj = 'Bienvenido Usuario ' . $result->getIdentity();
         $this->view->message = $this->_flashMessenger->success($msj);
         $this->_identity = Zend_Auth::getInstance()->getIdentity();
         $return = true;
     } else {
         switch ($result->getCode()) {
             case Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND:
                 $msj = 'El usuario no existe';
                 break;
             case Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID:
                 $msj = 'Password incorrecto';
                 break;
             default:
                 $msj = 'Datos incorrectos';
                 break;
         }
         $this->view->message = $this->_flashMessenger->warning($msj);
         $return = false;
     }
     return $return;
 }
示例#14
0
 /**
  * 
  * @return int|bool
  */
 public function save()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $row = $this->_checkSubGroup($this->_data);
         if (!empty($row)) {
             $this->_message->addMessage('Sub-Grupu Okupasaun iha tiha ona.', App_Message::ERROR);
             return false;
         }
         $mapperGroup = new Register_Model_Mapper_ProfGroup();
         $group = $mapperGroup->fetchRow($this->_data['fk_id_profgroup']);
         $this->_data['acronym'] = $group->acronym . $this->_data['acronym'];
         if (empty($this->_data['id_profsubgroup'])) {
             $history = 'INSERE SUB-GROUP: %s - INSERIDO NOVO SUB-GRUPO';
         } else {
             $history = 'ALTERA SUB-GROUP: %s - ALTERADO SUB-GROUP';
         }
         $id = parent::_simpleSave();
         $history = sprintf($history, $this->_data['sub_group']);
         $this->_sysAudit($history);
         $dbAdapter->commit();
         return $id;
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }
示例#15
0
 /**
  * 
  * @return int|bool
  */
 public function save()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $row = $this->_checkGroup($this->_data);
         if (!empty($row)) {
             $this->_message->addMessage('Sesaun Industria iha tiha ona.', App_Message::ERROR);
             return false;
         }
         if (empty($this->_data['id_isicsection'])) {
             $history = 'REJISTRU SESAUN: %s';
         } else {
             $history = 'ALTERA SESAUN: %s';
         }
         $id = parent::_simpleSave();
         $history = sprintf($history, $this->_data['name_section']);
         $this->_sysAudit($history);
         $dbAdapter->commit();
         return $id;
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }
示例#16
0
 public function EditCohort($cohortid)
 {
     $db = Zend_Db_Table_Abstract::getDefaultAdapter();
     $select = $db->query("select * from cohort where id = '{$cohortid}'");
     $row = $select->fetch();
     return $row;
 }
示例#17
0
文件: User.php 项目: nldfr219/zhi
 public static function login($email, $password)
 {
     $db = Zend_Db_Table_Abstract::getDefaultAdapter();
     $authAdapter = new Zend_Auth_Adapter_DbTable($db);
     $authAdapter->setTableName('users');
     $authAdapter->setIdentityColumn('email');
     $authAdapter->setCredentialColumn('password');
     $authAdapter->setCredentialTreatment('?');
     $authAdapter->setIdentity($email);
     $authAdapter->setCredential($password);
     $auth = Zend_Auth::getInstance();
     $result = $auth->authenticate($authAdapter);
     if ($result->isValid()) {
         $data = $authAdapter->getResultRowObject(null, 'password');
         $oUser = null;
         $tUserInfo = new Table_UsersInfo();
         $data = $tUserInfo->getUser($data->userID);
         $oUser->school_id = $data->school_id;
         $oUser->user_id = $data->user_id;
         $oUser->email = $email;
         if (is_null($oUser)) {
             return false;
         }
         $auth->getStorage()->write($oUser);
         return true;
     }
     return false;
 }
示例#18
0
 /**
  * 
  * @return int|bool
  */
 public function save()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $row = $this->_checkGroup($this->_data);
         if (!empty($row)) {
             $this->_message->addMessage('Grupu Okupasaun iha tiha ona.', App_Message::ERROR);
             return false;
         }
         if (empty($this->_data['id_profgroup'])) {
             $history = 'INSERE GRUPO: %s - INSERIDO NOVO GRUPO DE OCUPASAUN';
         } else {
             $history = 'ALTERA GROUP: %s - ALTERADO GRUPO';
         }
         $id = parent::_simpleSave();
         $history = sprintf($history, $this->_data['group_name']);
         $this->_sysAudit($history);
         $dbAdapter->commit();
         return $id;
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }
 public function loginAction()
 {
     //Desabilita renderização da view
     $this->_helper->viewRenderer->setNoRender();
     //Obter o objeto do adaptador para autenticar usando banco de dados
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);
     //Seta qual tabela e colunas procurar o usuário
     $authAdapter->setTableName('usuario')->setIdentityColumn('login')->setCredentialColumn('senha');
     //Seta as credenciais com dados vindos do formulário de login
     $authAdapter->setIdentity($this->_getParam('login'))->setCredential($this->_getParam('senha'))->setCredentialTreatment('MD5(?)');
     //Realiza autenticação
     $result = $authAdapter->authenticate();
     //Verifica se a autenticação foi válida
     if ($result->isValid()) {
         //Obtém dados do usuário
         $usuario = $authAdapter->getResultRowObject();
         //Armazena seus dados na sessão
         $storage = Zend_Auth::getInstance()->getStorage();
         $storage->write($usuario);
         //Redireciona para o Index
         $this->_redirect('index');
     } else {
         $this->_redirect('autenticacao/falha');
     }
 }
示例#20
0
 /**
  * 
  * @return int|bool
  */
 public function save()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $row = $this->_checkBarrierType($this->_data);
         if (!empty($row)) {
             $this->_message->addMessage('Tipu Barreira iha tiha ona.', App_Message::ERROR);
             return false;
         }
         if (empty($this->_data['id_barrier_type'])) {
             $history = 'REJISTRU Tipu Barreira %s - ID: %s';
         } else {
             $history = 'ALTERA Tipu Barreira %s - ID: %s';
         }
         $id = parent::_simpleSave();
         $history = sprintf($history, $this->_data['barrier_type_name'], $id);
         $this->_sysAudit($history);
         $dbAdapter->commit();
         return $id;
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }
示例#21
0
 /**
  * 
  * @return int|bool
  */
 public function save()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $this->setValidators(array('_checkScholarityName', '_checkScholarityExternalCode'));
         if (!parent::isValid()) {
             return false;
         }
         if (empty($this->_data['id_perscholarity'])) {
             $history = 'INSERE KURSU: %s DADUS PRINCIPAL - INSERE NOVO KURSU';
         } else {
             $history = 'ALTERA KURSU: %s DADUS PRINCIPAL - ALTERA KURSU';
         }
         $id = parent::_simpleSave();
         $history = sprintf($history, $this->_data['scholarity']);
         $this->_sysAudit($history);
         $dbAdapter->commit();
         return $id;
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }
示例#22
0
 /**
  * 
  * @return int|bool
  */
 public function save()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $row = $this->_checkDivision($this->_data);
         if (!empty($row)) {
             $this->_message->addMessage('Divizaun iha tiha ona.', App_Message::ERROR);
             return false;
         }
         $mapperSection = new Register_Model_Mapper_IsicSection();
         $section = $mapperSection->fetchRow($this->_data['fk_id_isicsection']);
         $this->_data['acronym'] = $section->acronym . $this->_data['acronym'];
         if (empty($this->_data['id_isicdivision'])) {
             $history = 'REJISTRU DIVISAUN: %s';
         } else {
             $history = 'ALTERA DIVISAUN: %s';
         }
         $id = parent::_simpleSave();
         $history = sprintf($history, $this->_data['name_disivion']);
         $this->_sysAudit($history);
         $dbAdapter->commit();
         return $id;
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }
示例#23
0
 /**
  * @return Zend_Db_Adapter_Abstract
  */
 public function getAdapter()
 {
     if (empty($this->adapter)) {
         $this->adapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     }
     return $this->adapter;
 }
示例#24
0
 /**
  * 
  * @return int|bool
  */
 public function save()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $row = $this->_checkBudgetCategory($this->_data);
         if (!empty($row)) {
             $this->_message->addMessage('Categoria Orsamentu iha tiha ona.', App_Message::ERROR);
             return false;
         }
         if (empty($this->_data['id_budget_category'])) {
             $history = 'REJISTRU CATEGORIA ORSAMENTU: %s';
         } else {
             $history = 'ALTERA CATEGORIA ORSAMENTU: %s';
         }
         $id = parent::_simpleSave();
         // Save the client history
         $history = sprintf($history, $id);
         $this->_sysAudit($history);
         $dbAdapter->commit();
         return $id;
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }
 public function editarAction()
 {
     if ($this->getRequest()->isPost()) {
         $data = $this->getRequest()->getPost();
         $ok = true;
         // disativa todos os precos do salao
         $modelEspecialidadePreco = new Model_DbTable_EspecialidadePreco();
         $modelEspecialidadePreco->update(array('especialidade_preco_ativo' => 0), "salao_id = {$this->_auth->salao_id}");
         Zend_Db_Table_Abstract::getDefaultAdapter()->beginTransaction();
         foreach ($data['especialidade_preco'] as $key => $value) {
             if (!empty($value)) {
                 try {
                     $value = str_replace('.', '', $value);
                     $value = str_replace(',', '.', $value);
                     $data_insert = array('especialidade_id' => $key, 'salao_id' => $this->_auth->salao_id, 'especialidade_preco_preco' => $value);
                     $modelEspecialidadePreco->insert($data_insert);
                 } catch (Exception $ex) {
                     $ok = false;
                     $this->_helper->flashMessenger->addMessage(array('danger' => 'Houve um problema ao editar os preços. ' . $ex->getMessage()));
                     Zend_Db_Table_Abstract::getDefaultAdapter()->rollBack();
                 }
             }
         }
         Zend_Db_Table_Abstract::getDefaultAdapter()->commit();
         if ($ok) {
             $this->_helper->flashMessenger->addMessage(array('success' => 'Preços alterados com sucesso'));
         }
         $this->_redirect("/salao/preco");
     }
 }
 public function fetchdetails($where = null)
 {
     $output = array();
     $helper = new Helper();
     $db = Zend_Db_Table_Abstract::getDefaultAdapter();
     $select = $db->select()->from($this->_name);
     if ($where) {
         // comma seperated string for sql
         $select = $select->where($where);
     }
     $result = $db->fetchAll($select);
     $employees = $this->fetchEmployeeCounts();
     foreach ($result as $row) {
         $output[] = array("col1" => $row['partner'], "col2" => $employees[$row['id']] ? $employees[$row['id']] : 0, "link" => Settings::$COUNTRY_BASE_URL . "/partner/edit/id/" . $row['id'], "type" => 1);
         // foreach ($cohorts as $cohort){
         // 	$output[] = array(
         // 		"col1" => $cohort['name'],
         // 		"col2" => $cohort['count'],
         // 		"link" => Settings::$COUNTRY_BASE_URL . "/employee/edit/id/" . $employee['id'],
         // 		"type" => 2
         // 	);
         // }
     }
     return $output;
 }
示例#27
0
文件: Contact.php 项目: knatorski/SMS
 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;
 }
示例#28
0
 public static function validate($username, $hash, $rememberme = false)
 {
     if (!$username) {
         return false;
     }
     // TODO: try to make only one sql request
     $adapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $authAdapter = new Zend_Auth_Adapter_DbTable($adapter, 'users', 'pseudo', 'password');
     $authAdapter->setIdentity($username)->setCredential($hash);
     $auth = Zend_Auth::getInstance();
     $result = $auth->authenticate($authAdapter);
     if (!$result->isValid()) {
         self::$_current = null;
         return false;
     }
     $userid = $authAdapter->getResultRowObject('id')->id;
     $userMapper = new Syj_Model_UserMapper();
     $user = new Syj_Model_User();
     if (!$userMapper->find($userid, $user)) {
         throw new Zend_Exception();
     }
     $request = Zend_Controller_Front::getInstance()->getRequest();
     if (!$request->getCookie('syj_user') or !$request->getCookie('syj_hashpass')) {
         if ($rememberme) {
             // cookie will be valid for 2 weeks
             $time = time() + 14 * 60 * 24 * 60;
         } else {
             $time = 0;
         }
         setcookie("syj_user", $username, $time, "", "", false, true);
         setcookie("syj_hashpass", $hash, $time, "", "", false, true);
     }
     self::$_current = $user;
     return true;
 }
示例#29
0
 public function indexAction()
 {
     $filter = new Zend_Filter_StripTags();
     $login = trim($filter->filter($this->_request->getPost('login')));
     $senha = trim($filter->filter($this->_request->getPost('senha')));
     $uri = str_replace('kahina/', '', base64_decode($this->_request->getParam('u', base64_encode('painel/index'))));
     if (empty($login) || empty($senha)) {
         $this->view->message = 'Por favor, informe seu Usuário e Senha.';
         return;
     } else {
         $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
         $authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);
         $authAdapter->setTableName('login')->setIdentityColumn('login')->setCredentialColumn('senha');
         $authAdapter->setIdentity($this->_getParam('login'))->setCredential($this->_getParam('senha'))->setCredentialTreatment('MD5(?)');
         $result = $authAdapter->authenticate();
         if ($result->isValid()) {
             $user = $authAdapter->getResultRowObject();
             $storage = My_Auth::getInstance('Painel')->getStorage();
             $storage->write($user);
             $this->_redirect($uri);
         } else {
             $this->view->error = 'Você deve informar Login e Senha.';
         }
     }
     $this->render();
 }
示例#30
0
 /**
  * 
  * @return int|bool
  */
 public function save()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $row = $this->_checkScholarityArea($this->_data);
         if (!empty($row)) {
             $this->_message->addMessage('Area Kursu iha tiha ona.', App_Message::ERROR);
             return false;
         }
         if (!empty($this->_data['acronym'])) {
             $row = $this->_checkScholarityAreaAcronym($this->_data);
             if (!empty($row)) {
                 $this->_message->addMessage('Area Kursu nia sigla iha tiha ona.', App_Message::ERROR);
                 return false;
             }
         }
         if (empty($this->_data['id_scholarity_area'])) {
             $history = 'INSERE AREA KURSU: %s DADUS PRINCIPAL - INSERE NOVA AREA KURSU';
         } else {
             $history = 'ALTERA AREA KURSU: %s DADUS PRINCIPAL - ALTERA AREA KURSU';
         }
         $id = parent::_simpleSave();
         $history = sprintf($history, $this->_data['scholarity_area']);
         $this->_sysAudit($history);
         $dbAdapter->commit();
         return $id;
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }