Пример #1
0
     $rs = $db->Execute("select idUsuario from usuario where upper(email) = upper('" . $email . "')");
     if ($rs->EOF) {
         echo json_encode(array("band" => "false"));
     } elseif ($rs->fields['idUsuario'] == $id) {
         echo json_encode(array("band" => "false"));
     } else {
         echo json_encode(array("band" => "true"));
     }
     break;
 case 'add':
     $obj = new TUsuario($_POST['id']);
     $obj->setNick($_POST['nick']);
     $obj->setNombre($_POST['nombre']);
     $obj->setEmail($_POST['email']);
     $obj->setTipo($_POST['tipo']);
     if ($obj->guardar()) {
         echo json_encode(array("band" => "true", "idUsuario" => $obj->getId()));
     } else {
         echo json_encode(array("band" => "false", "mensaje" => "Error al registrar la cuenta"));
     }
     break;
 case 'setPass':
     $obj = new TUsuario($_POST['usuario']);
     if ($obj->setPass($_POST['pass'])) {
         echo json_encode(array("band" => "true"));
     } else {
         echo json_encode(array("band" => "false"));
     }
     break;
 case 'del':
     $obj = new TUsuario(hexdec($_POST['usuario']));
Пример #2
0
                }
                $obj = new TUsuario();
                $obj->setId($_POST['id']);
                $obj->setNombre($_POST['nombre']);
                $obj->setEmail($_POST['email']);
                $obj->setPass($_POST['pass']);
                $obj->setTipo($_POST['tipo']);
                $obj->setCelular($_POST['celular']);
                echo json_encode(array("band" => $obj->guardar()));
                break;
            case 'del':
                $obj = new TUsuario($_POST['usuario']);
                echo json_encode(array("band" => $obj->eliminar()));
                break;
            case 'saveDatosPersonales':
                global $sesion;
                $obj = new TUsuario();
                $obj->setId($sesion['usuario']);
                $obj->setNombre($_POST['nombre']);
                echo json_encode(array("band" => $obj->guardar()));
                break;
            case 'savePassword':
                global $sesion;
                $obj = new TUsuario();
                $obj->setId($sesion['usuario']);
                $obj->setPass($_POST['pass']);
                echo json_encode(array("band" => $obj->guardar()));
                break;
        }
        break;
}
 /**
  * Guarda los datos en la base de datos, si no existe un identificador entonces crea el objeto
  *
  * @autor Hugo
  * @access public
  * @return boolean True si se realizó sin problemas
  */
 public function guardar()
 {
     if (!parent::guardar()) {
         return false;
     }
     $db = TBase::conectaDB();
     $rs = $db->Execute("select idUsuario from doctor where idUsuario = " . $this->getId());
     if ($rs->EOF) {
         $rs = $db->Execute("INSERT INTO doctor(idUsuario)VALUES(" . $this->getId() . ");");
         if (!$rs) {
             return false;
         }
     }
     if ($this->getId() == '') {
         return false;
     }
     $rs = $db->Execute("UPDATE doctor\n\t\t\tSET\n\t\t\t\tcedula = '" . $this->getCedula() . "',\n\t\t\t\tuniversidad = '" . $this->getUniversidad() . "',\n\t\t\t\tespecialidad = '" . $this->getEspecialidad() . "'\n\t\t\tWHERE idUsuario = " . $this->getId());
     return $rs ? true : false;
 }