public function salvar(\Usuario $u)
 {
     $nome = $u->getNome();
     $login = $u->getLogin();
     $senha = $u->getSenha();
     $status = $u->getStatus();
     if ($u->getId()) {
         $id = $u->getId();
         $sql = "update usuario set nome=:nome, login=:login, senha=:senha, status=:status where id=:id";
     } else {
         $id = $this->generateID();
         $u->setId($id);
         $sql = "insert into usuario (id, nome, login, senha, status) values (:id, :nome, :login, :senha, :status)";
     }
     $cnx = Conexao::getConexao();
     $sth = $cnx->prepare($sql);
     $sth->bindParam("id", $id);
     $sth->bindParam("nome", $nome);
     $sth->bindParam("login", $login);
     $sth->bindParam("senha", $senha);
     $sth->bindParam("status", $status);
     try {
         $sth->execute();
         return $u;
     } catch (Exception $exc) {
         echo $exc->getMessage();
     }
 }
 public function inserir(Usuario $usuario)
 {
     //Objetivo deste metodo é inserir um objeto no banco, fazendo-o ter persistencia.
     //utilizaremos a abstracao do SQL da classe TsqlInstruction
     //1. Foreach dos atributos . PRa cada existencia de atributo é um valor a ser adicionado.
     $instrucao = new TSqlInsert();
     $instrucao->setEntity("usuario");
     if ($usuario->getId() != null) {
         $instrucao->setRowData("id", $usuario->getId());
     }
     if ($usuario->getNome() != null) {
         $instrucao->setRowData("nome", $usuario->getNome());
     }
     if ($usuario->getLogin() != null) {
         $instrucao->setRowData("login", $usuario->getLogin());
     }
     if ($usuario->getSenha() != null) {
         $instrucao->setRowData("senha", $usuario->getSenha());
     }
     echo $instrucao->getInstruction();
     if ($this->Conexao->query($instrucao->getInstruction())) {
         return true;
     } else {
         return false;
     }
 }
Exemple #3
0
 public function apagar(Usuario $objUsuario)
 {
     $v = $this->_getValidacao();
     $v->setRules($objUsuario->getId(), 'required', 'ID');
     $v->validar();
     return $this->_getRepositorio()->apagar($objUsuario);
 }
 function dadosUsuario(Usuario $usuario)
 {
     $rs = $this->con->prepare("select * from usuarios where id = ?");
     $rs->bindValue(1, $usuario->getId());
     $rs->execute();
     $rs->setFetchMode(PDO::FETCH_CLASS, "Usuario");
     $usuario = $rs->fetch();
     return $usuario;
 }
Exemple #5
0
 public function visualizar(Usuario $objUsuario)
 {
     try {
         $this->_stat = $this->_getConn()->prepare('SELECT * FROM tblusuario WHERE usu_id = :usu_id AND usu_excluido = 0 AND usu_status = 1');
         $this->_stat->bindValue(':usu_id', $objUsuario->getId(), \PDO::PARAM_INT);
         $this->_stat->execute();
         return $this->_getUsuario($this->_stat->fetch(\PDO::FETCH_ASSOC));
     } catch (\PDOException $e) {
         throw new \model\conexao\Excecao($e->getMessage());
     }
 }
 public function save()
 {
     try {
         $model = new Usuario($this->data->id);
         $model->setData($this->data);
         $model->save();
         $go = '>auth/usuario/formObject/' . $model->getId();
         $this->renderPrompt('information', 'OK', $go);
     } catch (EControllerException $e) {
         $this->renderPrompt('error', $e->getMessage());
     }
 }
Exemple #7
0
 public function insert(Usuario $u)
 {
     if ($this->getUsuario($u->getLogin(), $u->getSenha()) == 0) {
         $i = $u->getId();
         $n = $u->getNome();
         $l = $u->getLogin();
         $s = $u->getSenha();
         $e = $u->getEmail();
         if ($stmt = $this->connection->prepare("Insert into `TB_Usuario` (`id_usuario`, `nm_usuario`, `ds_login`, `ds_senha`, `ds_email`) VALUES (?,?,?,?,?)")) {
             //  "sss" retpresenta 3 strings, se fosse  2 string e um interio  seria "ssd"
             $stmt->bind_param("issss", $i, $n, $l, $s, $e);
             $stmt->execute();
             $stmt->close();
             redirect("/painel/usuarios");
         } else {
             echo "<hr>";
             die($this->connection->error);
             echo "<hr>";
         }
     } else {
         echo "Usuario Ja Cadastrado";
     }
 }
 /**
  * Valida que se este autorizado para ejecutar el modulo
  * @param string $metodo
  */
 protected function _seguridad($metodo)
 {
     $tipo_seguridad = $this->_metodos[$metodo];
     switch ($tipo_seguridad) {
         case "session":
             $id_usuario = Usuario::getId();
             $DAOUsuario = new DAOUsuarios();
             $usuario = $DAOUsuario->getById($id_usuario);
             if (is_null($usuario)) {
                 $this->_autorizado = false;
             }
             break;
         case "llave":
             $this->_chequearKey();
             break;
         default:
             break;
     }
 }
Exemple #9
0
 /**
  * Exclude object from result
  *
  * @param   Usuario $usuario Object to remove from the list of results
  *
  * @return UsuarioQuery The current query, for fluid interface
  */
 public function prune($usuario = null)
 {
     if ($usuario) {
         $this->addUsingAlias(UsuarioPeer::ID, $usuario->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
 function toRecordSet(Usuario $usuario)
 {
     return array($usuario->getId(), $usuario->getUsuario(), $usuario->getSenha(), $usuario->getNome(), $usuario->getEmail(), $usuario->getNivel(), $usuario->getEmpresa()->getId());
 }
 /**
  * Filter the query by a related Usuario object
  *
  * @param     Usuario|PropelCollection $usuario The related object(s) to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return    NotificacionQuery The current query, for fluid interface
  */
 public function filterByUsuarioRelatedById_receptor($usuario, $comparison = null)
 {
     if ($usuario instanceof Usuario) {
         return $this->addUsingAlias(NotificacionPeer::ID_RECEPTOR, $usuario->getId(), $comparison);
     } elseif ($usuario instanceof PropelCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(NotificacionPeer::ID_RECEPTOR, $usuario->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByUsuarioRelatedById_receptor() only accepts arguments of type Usuario or PropelCollection');
     }
 }
 public function deletar(Usuario $u)
 {
     $where = "WHERE " . self::ID . " = '" . $u->getId() . "'";
     Arquivos::__DeleteArquivo(Sistema::$caminhoDiretorio . Sistema::$caminhoDataUsuarios . $u->getImagem()->nome . "." . $u->getImagem()->extensao);
     $this->con->deletar(Sistema::$BDPrefixo . $this->tabela, $where);
 }
        if ($_SESSION['session'][3] == "SI") {
            ?>
			<form id="form_borrador" name="form_borrador" method="post" action="javascript:validar_historial_atencion(<?php 
            echo $_REQUEST["id"];
            ?>
)" enctype="multipart/form-data">			
				<input type="hidden" id="area" name="area" value="<?php 
            echo $_SESSION['session'][5];
            ?>
" />
				<input type="hidden" id="user" name="user" value="<?php 
            echo $_SESSION['session'][0];
            ?>
" />			
				<input type="hidden" id="usuario" name="usuario" value="<?php 
            echo $usuario->getId();
            ?>
" readonly="readonly"/>
				<input type="hidden" id="categoria" name="categoria" size="30" value="<?php 
            echo $_REQUEST["cat"];
            ?>
"/>
				<input type="hidden" id="accion" name="accion" value="<?php 
            echo $accion->getId();
            ?>
"/>			
				<textarea id="comentario" name="comentario" style="display:none"></textarea>			

		<table width="100%" border="0">
		<tr>
			<td width="11%" class="Estilo22">Pase a </td>
 function updateSenha(Usuario $usuario)
 {
     $stmt = $this->pdo->prepare('
         UPDATE
             ' . self::$TABELA_USUARIO . '
         SET
             senha = ?
         WHERE
             id=?
     ');
     $queryParams = array($usuario->getSenha(), $usuario->getId());
     $stmt->execute($queryParams);
 }
Exemple #15
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      Usuario $obj A Usuario object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool($obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         UsuarioPeer::$instances[$key] = $obj;
     }
 }
Exemple #16
0
 /**
  * Declares an association between this object and a Usuario object.
  *
  * @param      Usuario $v
  * @return     Lista The current object (for fluent API support)
  * @throws     PropelException
  */
 public function setUsuario(Usuario $v = null)
 {
     if ($v === null) {
         $this->setId_usuario(NULL);
     } else {
         $this->setId_usuario($v->getId());
     }
     $this->aUsuario = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the Usuario object, it will not be re-added.
     if ($v !== null) {
         $v->addLista($this);
     }
     return $this;
 }
Exemple #17
0
 public function getCliente()
 {
     global $config;
     $servidor = $config['db']['servidor'];
     $usuario = $config['db']['usuario'];
     $pwd = $config['db']['pwd'];
     $bd = $config['db']['DBGlobal'];
     dataIO::conectar($servidor, $usuario, $pwd, $bd);
     //no pregunto por pass porq todavia no lo uso
     if (isset($_GET['nick'])) {
         $nick = (string) $_GET['nick'];
         $pass = (string) $_GET['pass'];
     } else {
         if (isset($_POST['nick'])) {
             $nick = (string) $_POST['nick'];
             $pass = (string) $_POST['pass'];
         }
     }
     //escapamos el nick y pass para prevenir inyeccion sql ya que son strings
     $nick = mysqli_real_escape_string(dataIO::isConnected(), $nick);
     $pass = mysqli_real_escape_string(dataIO::isConnected(), $pass);
     //fin escape
     $usuario = new Usuario();
     $cliente = new Cliente();
     $query = $usuario->getUserByName($nick);
     try {
         $result = dataIO::executeQuery($query);
         $fila = mysqli_fetch_assoc($result);
         $usuario = new Usuario($fila);
         $query2 = $cliente->getClientByid($usuario->getId());
         $result2 = dataIO::executeQuery($query2);
         $fila2 = mysqli_fetch_assoc($result2);
         $cliente = new Cliente($fila2);
         echo json_encode($cliente->getJSon());
     } catch (Exception $e) {
         echo json_encode(null);
     }
 }
 /**
  * Filter the query by a related Usuario object
  *
  * @param     Usuario|PropelCollection $usuario The related object(s) to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return    Solicitud_amistadQuery The current query, for fluid interface
  */
 public function filterByUsuarioRelatedById_usuario_solicitante($usuario, $comparison = null)
 {
     if ($usuario instanceof Usuario) {
         return $this->addUsingAlias(Solicitud_amistadPeer::ID_USUARIO_SOLICITANTE, $usuario->getId(), $comparison);
     } elseif ($usuario instanceof PropelCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(Solicitud_amistadPeer::ID_USUARIO_SOLICITANTE, $usuario->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByUsuarioRelatedById_usuario_solicitante() only accepts arguments of type Usuario or PropelCollection');
     }
 }
Exemple #19
0
 public static function obtMultiples($smtm, $params, BDCon $BD)
 {
     $rs = $BD->stmt($smtm, $params);
     $usuarios = array();
     while ($res = $BD->fetch($rs)) {
         $usuario = new Usuario($res);
         $usuarios[$usuario->getId()] = $usuario;
     }
     return $usuarios;
 }
 /**
  * Filter the query by a related Usuario object
  *
  * @param     Usuario|PropelCollection $usuario The related object(s) to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return    Libro_colaboradorQuery The current query, for fluid interface
  */
 public function filterByUsuario($usuario, $comparison = null)
 {
     if ($usuario instanceof Usuario) {
         return $this->addUsingAlias(Libro_colaboradorPeer::IDUSUARIO, $usuario->getId(), $comparison);
     } elseif ($usuario instanceof PropelCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(Libro_colaboradorPeer::IDUSUARIO, $usuario->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByUsuario() only accepts arguments of type Usuario or PropelCollection');
     }
 }
Exemple #21
0
 public function setUsuario(Usuario $v = null)
 {
     if ($v === null) {
         $this->setFkUsuarioId(NULL);
     } else {
         $this->setFkUsuarioId($v->getId());
     }
     $this->aUsuario = $v;
     if ($v !== null) {
         $v->addLegajosalud($this);
     }
     return $this;
 }
Exemple #22
0
 public static function obtenerOfertasParaUsuario(Usuario $usuario, $intervalo = 2, $tipo = "DAY")
 {
     $ofertasTable = new \apf\db\mysql5\Table("ofertas");
     $empresasTable = new \apf\db\mysql5\Table("empresas");
     $empresasDatosTable = new \apf\db\mysql5\Table("empresas_datos");
     $ofertasUbicacionTable = new \apf\db\mysql5\Table("ofertas_ubicacion");
     $localidadesTable = new \apf\db\mysql5\Table("localidades");
     $ofertasCategoriaTable = new \apf\db\mysql5\Table("ofertas_categoria");
     $categoriasTable = new \apf\db\mysql5\Table("categorias");
     $select = new \apf\db\mysql5\Select($ofertasTable);
     $fields = array("ofertas.id AS idOferta", "ofertas.email", "ofertas.titulo", "GROUP_CONCAT(categorias.id) AS categorias", "GROUP_CONCAT(localidades.id) AS localidades");
     $select->fields($fields);
     //INNER JOIN ofertas_ubicacion
     /////////////////////////////////////////////////////////
     $joinOfertasUbicacion = new \apf\db\mysql5\Join($ofertasUbicacionTable);
     $joinOfertasUbicacion->type("INNER");
     $on = array(array("field" => "ofertas.id", "value" => "ofertas_ubicacion.id_oferta", "quote" => FALSE));
     $joinOfertasUbicacion->on($on);
     $select->join($joinOfertasUbicacion);
     //INNER JOIN localidades
     /////////////////////////////////////////////////////////
     $joinLocalidades = new \apf\db\mysql5\Join($localidadesTable);
     $joinLocalidades->type("INNER");
     $on = array(array("field" => "localidades.id", "value" => "ofertas_ubicacion.id_localidad", "quote" => FALSE));
     $joinLocalidades->on($on);
     $select->join($joinLocalidades);
     //INNER JOIN ofertas_categoria
     /////////////////////////////////////////////////////////
     $joinOfertasCategoria = new \apf\db\mysql5\Join($ofertasCategoriaTable);
     $joinOfertasCategoria->type("INNER");
     $on = array(array("field" => "ofertas_categoria.id_oferta", "value" => "ofertas.id", "quote" => FALSE));
     $joinOfertasCategoria->on($on);
     $select->join($joinOfertasCategoria);
     //INNER JOIN categorias
     /////////////////////////////////////////////////////////
     $joinCategorias = new \apf\db\mysql5\Join($categoriasTable);
     $joinCategorias->type("INNER");
     $on = array(array("field" => "ofertas_categoria.id_categoria", "value" => "categorias.id", "quote" => FALSE));
     $joinCategorias->on($on);
     $select->join($joinCategorias);
     //WHERE
     /////////////////////////////////////////////////////////
     $where = array();
     $tmpWhere = array();
     $usuariosCategoria = new \apf\db\mysql5\Table("usuarios_categorias");
     $selectCategorias = new \apf\db\mysql5\Select($usuariosCategoria);
     $selectCategorias->fields(array("id_categoria"));
     $selectCategorias->where(array(array("field" => "id_usuario", "value" => $usuario->getId())));
     $tmpWhere[] = array("field" => "ofertas_categoria.id_categoria", "operator" => "IN", "value" => $selectCategorias);
     $prefUbicaciones = new \apf\db\mysql5\Table("usuarios_ubicaciones");
     $selectLocalidades = new \apf\db\mysql5\Select($prefUbicaciones);
     $selectLocalidades->fields(array("id_localidad"));
     $selectLocalidades->where(array(array("field" => "id_usuario", "value" => $usuario->getId())));
     $tmpWhere[] = array("field" => "ofertas_ubicacion.id_localidad", "operator" => "IN", "value" => $selectLocalidades);
     $postulacionesTable = new \apf\db\mysql5\Table("usuarios_postulaciones");
     $selectPostulaciones = new \apf\db\mysql5\Select($postulacionesTable);
     $selectPostulaciones->fields(array("id_oferta"));
     $selectPostulaciones->where(array(array("field" => "id_usuario", "value" => $usuario->getId())));
     $tmpWhere[] = array("field" => "ofertas.id", "operator" => "NOT IN", "value" => $selectPostulaciones);
     $prefCriterios = $usuario->getPreferencia("criterios");
     if ($prefCriterios) {
         $cantCriterios = sizeof($prefCriterios);
         foreach ($prefCriterios as $key => $criterio) {
             if ($key == 0) {
                 $tmpWhere[] = array("field" => "ofertas.titulo", "operator" => "LIKE", "value" => "%{$criterio}%", "begin_enclose" => TRUE);
             } else {
                 if ($key == $cantCriterios - 1) {
                     $tmpWhere[] = array("field" => "ofertas.titulo", "operator" => "LIKE", "value" => "%{$criterio}%", "end_enclose" => TRUE);
                 } else {
                     $tmpWhere[] = array("field" => "ofertas.titulo", "operator" => "LIKE", "value" => "%{$criterio}%");
                 }
             }
         }
     }
     foreach ($tmpWhere as $key => $value) {
         $where[] = $value;
         $op = $value["operator"] == "LIKE" ? "OR" : "AND";
         $where[] = array("operator" => $op);
     }
     unset($where[sizeof($where) - 1]);
     if ($intervalo) {
         $where[] = array("operator" => "AND");
         $where[] = array("field" => "ofertas.fecha_publicacion", "operator" => "BETWEEN", "value" => array("min" => "DATE_SUB(NOW(), INTERVAL {$intervalo} {$tipo})", "max" => "NOW()"));
     }
     $select->where($where);
     $select->group(array("ofertas.id"));
     $select->orderBy(array("fecha_publicacion"), "DESC");
     $res = $select->execute($smartMode = FALSE);
     $ofertas = array();
     $class = __CLASS__;
     foreach ($res as $r) {
         $oferta = new Oferta();
         $oferta->setId($r["idOferta"]);
         $oferta->setEmail($r["email"]);
         $oferta->setTitulo($r["titulo"]);
         $ofertas[] = $oferta;
     }
     return $ofertas;
 }
 /**
  * Declares an association between this object and a Usuario object.
  *
  * @param      Usuario $v
  * @return     Notificacion The current object (for fluent API support)
  * @throws     PropelException
  */
 public function setUsuarioRelatedById_receptor(Usuario $v = null)
 {
     if ($v === null) {
         $this->setId_receptor(NULL);
     } else {
         $this->setId_receptor($v->getId());
     }
     $this->aUsuarioRelatedById_receptor = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the Usuario object, it will not be re-added.
     if ($v !== null) {
         $v->addNotificacionRelatedById_receptor($this);
     }
     return $this;
 }
Exemple #24
0
 public function atualizar(Usuario $usuario)
 {
     try {
         $sql = "UPDATE usuario SET " . "nome = :nome," . "cpf = :cpf," . "email = :email," . "telefone = :telefone," . "senha = :senha," . "liberado = :liberado," . "tipo = :tipo," . "qtdResponde = :qtdResponde," . "status = :status," . "idCurso = :idCurso " . "WHERE id = :id";
         $p_sql = $this->pdo->prepare($sql);
         $p_sql->bindValue(":id", $usuario->getId());
         $p_sql->bindValue(":nome", $usuario->getNome());
         $p_sql->bindValue(":cpf", $usuario->getCpf());
         $p_sql->bindValue(":email", $usuario->getEmail());
         $p_sql->bindValue(":telefone", $usuario->getTelefone());
         $p_sql->bindValue(":senha", $usuario->getSenha());
         $p_sql->bindValue(":liberado", $usuario->getLiberado());
         $p_sql->bindValue(":tipo", $usuario->getTipo());
         $p_sql->bindValue(":qtdResponde", $usuario->getQtdResponde());
         $p_sql->bindValue(":status", $usuario->getStatus());
         $p_sql->bindValue(":idCurso", $usuario->getIdCurso());
         return $p_sql->execute();
     } catch (Exception $e) {
         print "Ocorreu um erro ao tentar executar esta ação, foi gerado um LOG do mesmo, tente novamente mais tarde.";
     }
 }
Exemple #25
0
 public function save(Usuario $usuario)
 {
     $sql = "insert into biblioteca values(?,?,?,?)";
     $stm = ConexaoMysql::getInstance()->prepare($sql);
     $stm->execute(array($usuario->getId(), $usuario->getCpf(), $usuario->getNome()));
 }
Exemple #26
0
 public function setUsuario(Usuario $v = null)
 {
     if ($v === null) {
         $this->setFkUsuarioId(0);
     } else {
         $this->setFkUsuarioId($v->getId());
     }
     $this->aUsuario = $v;
     if ($v !== null) {
         $v->addUsuarioPermiso($this);
     }
     return $this;
 }
 /**
  * Funcion: eliminarUsuario   
  * Descripcion: Elimina un Usuario
  * @param Usuario $usuario 
  * @return List<Unidad>
  * @throws Exception
  * @author Rodrigo Contreras B. <*****@*****.**>
  * @version 2015-12-07
  * @since 2015-12-07
  */
 public function eliminarUsuario(Usuario $usuario)
 {
     // Conexion
     $conexion = new Conn();
     $link = $conexion->Conexion();
     // Consulta
     $strsql = 'DELETE FROM usuario WHERE id_usuario=' . $usuario->getId();
     // Ejecucion Consulta
     $retval = $conexion->query($link, $strsql);
     if (!$retval) {
         die('Could not delete data: ' . $conexion->error());
     }
     echo "Deleted data successfully\n";
     // Cerra Conexion
     $conexion->close($link);
     // Retorno
     return $usuario;
 }