Exemplo n.º 1
0
 public function deletePregunta($pid)
 {
     $r = new Respuestas();
     $r->deleteRespuestas($pid);
     $db = new DB();
     $sql = "DELETE FROM preguntas WHERE id='{$pid}'";
     $db->execute($sql);
 }
Exemplo n.º 2
0
 public function executeBd(sfWebRequest $request)
 {
     for ($x = 855; $x <= 886; $x++) {
         $respuesta = new Respuestas();
         $respuesta->setPreguntasId($x);
         $respuesta->setOpcionesId(55);
         $respuesta->setEstadosId(1);
         $respuesta->save();
     }
 }
Exemplo n.º 3
0
 public function register($usuario, $password, $iduser = "")
 {
     $r = new Respuestas();
     $con = new mysqli("localhost", "root", "", "videoclub");
     //conectamos con la base de datos
     if ($con->connect_error) {
         //si la conexion da error :
         die("error en la conexion" . $con->connect_error);
     } else {
         $r->respuestaBuena();
     }
     $passcifrada = password_hash($password, PASSWORD_DEFAULT);
     $sql = "INSERT INTO usuarios values('{$iduser}','{$usuario}','{$passcifrada}')";
     //guardamos la consulta en resultado
     if ($con->query($sql) === TRUE) {
         $r->exitoInsert();
     } else {
         $cadena = "Error: " . $sql . "<br>" . $con->error;
         $r->respuestaMala($cadena);
     }
 }
 public function postElimPub()
 {
     if (Request::ajax()) {
         $id = Input::get('id');
         $pub = Publicaciones::find($id);
         $titulo = $pub->titulo;
         $comment = Comentarios::where('pub_id', '=', $id)->get();
         $resp = Respuestas::where('pub_id', '=', $id)->get();
         if (count($comment) > 0) {
             foreach ($comment as $c) {
                 $c->deleted = 1;
                 $c->save();
             }
         }
         if (count($resp) > 0) {
             foreach ($resp as $r) {
                 $r->deleted = 1;
                 $r->save();
             }
         }
         $userid = $pub->user_id;
         $user = User::find($userid);
         $subject = "Correo de Aviso";
         $pub->deleted = 1;
         $pub->save();
         $data = array('subject' => $subject, 'publicacion' => $titulo, 'motivo' => 'Eliminado por el usuario');
         $to_Email = $user->email;
         Mail::send('emails.elimPubUser', $data, function ($message) use($titulo, $to_Email, $subject) {
             $message->to($to_Email)->from('*****@*****.**')->subject($subject);
         });
         return Response::json(array('type' => 'success', 'msg' => 'Publicación eliminada satisfactoriamente. Hemos enviado un email al correo.'));
     }
 }
Exemplo n.º 5
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      Respuestas $value A Respuestas object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(Respuestas $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
Exemplo n.º 6
0
 public function postResponse()
 {
     $id = Input::get('id');
     $input = Input::all();
     $rules = array('comment_id' => 'required|numeric', 'respuesta' => 'required', 'pub_id' => 'required|numeric');
     $validator = Validator::make($input, $rules);
     if ($validator->fails()) {
         return Response::json(array('type' => 'danger', 'msg' => 'Error al validar los datos.', 'data' => $validator->getMessageBag()->toArray()));
     }
     $com = Comentarios::find($input['comment_id']);
     if ($com->respondido == 1) {
         return Response::json(array('type' => 'danger', 'msg' => 'El comantario ya fue respondido.'));
     }
     if ($com->deleted == 1) {
         $com->deleted = 0;
     }
     $resp = new Respuestas();
     $resp->comentario_id = $input['comment_id'];
     $resp->respuesta = $input['respuesta'];
     $resp->pub_id = $input['pub_id'];
     $resp->user_id = $com->user_id;
     $resp->created_at = date('Y-m-d', time());
     $resp->updated_at = date('Y-m-d', time());
     $user = User::find($resp->user_id);
     $to_Email = $user->email;
     $subject = "han respondido tu comentario";
     $data = array('email' => $to_Email);
     Mail::send('emails.respuesta', $data, function ($message) use($to_Email, $subject) {
         $message->to($to_Email)->from('*****@*****.**')->subject($subject);
     });
     if ($resp->save()) {
         $com->respondido = 1;
         $com->save();
         return Response::json(array('type' => 'success', 'msg' => 'Respuesta guardada satisfactoriamente'));
     } else {
         return Response::json(array('type' => 'danger', 'msg' => 'Error al guardar la respuesta'));
     }
     return Response::json($input);
 }
Exemplo n.º 7
0
<!DOCTYPE html>

<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    <link rel="stylesheet" type="text/css" href="estilo.css" media="screen" />
    </head>
    <body>
        <?php 
include_once 'Usuario.php';
$u = new Usuario();
$r = new Respuestas();
if (isset($_POST['registrar'])) {
    $u->register($_POST['nombre'], $_POST['password']);
    $r->exitoRegistro();
}
if ($u->login($_POST['nombre'], $_POST['password'])) {
    $r->loginCorrecto();
} else {
    $r->loginIncorrecto();
}
?>
    </body>
</html>
Exemplo n.º 8
0
 public function modifica($cod_pelicula, $titulo, $genero, $pais, $year)
 {
     $r = new Respuestas();
     $con = new mysqli("localhost", "root", "", "videoclub");
     //conectamos con la base de datos
     if ($con->connect_error) {
         //si la conexion da error :
         die("error en la conexion" . $con->connect_error);
     } else {
         $r->respuestaBuena();
     }
     $sql = "UPDATE peliculas SET titulo='{$titulo}',genero ='{$genero}',pais = '{$pais}',year = '{$year}'  WHERE cod_pelicula = '{$cod_pelicula}'";
     if ($con->query($sql) === TRUE) {
         $r->exitoUpdate();
     } else {
         $cadena = "Error: " . $sql . "<br>" . $con->error;
         $r->respuestaMala($cadena);
     }
     mysqli_close($con);
 }
Exemplo n.º 9
0
 public function borrarPelicula($cod_pelicula)
 {
     $r = new Respuestas();
     $con = new mysqli("localhost", "root", "", "videoclub");
     if ($con->connect_error) {
         //si la conexion da error :
         die("error en la conexion" . $con->connect_error);
     } else {
         $r->respuestaBuena();
     }
     $sql = "DELETE FROM peliculas WHERE cod_pelicula = " . $cod_pelicula;
     //guardamos la consulta en resultado
     if ($con->query($sql) === TRUE) {
         $r->exitoDelete();
     } else {
         $cadena = "Error: " . $sql . "<br>" . $con->error;
         $r->respuestaMala($cadena);
     }
     mysqli_close($con);
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Respuestas::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, Yii::t('The requested page does not exist.'));
     }
     return $model;
 }
Exemplo n.º 11
0
 /**
  * Declares an association between this object and a Respuestas object.
  *
  * @param      Respuestas $v
  * @return     Respuestasescalas The current object (for fluent API support)
  * @throws     PropelException
  */
 public function setRespuestas(Respuestas $v = null)
 {
     if ($v === null) {
         $this->setRespuestasId(NULL);
     } else {
         $this->setRespuestasId($v->getId());
     }
     $this->aRespuestas = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the Respuestas object, it will not be re-added.
     if ($v !== null) {
         $v->addRespuestasescalas($this);
     }
     return $this;
 }
Exemplo n.º 12
0
         if (isset($_do_save) && $_do_save == "do") {
             $e = new Encuestas();
             $e->setUpdateEncuesta($_eid);
         } else {
             $e = new Encuestas();
             $e->editEncuesta($_eid);
         }
     }
     break;
 case 'addpregunta':
     if (!$uperms['encuestas_w']) {
         Elfic::cosRedirect('index2.php', MSG_NOPERM_COM);
     } else {
         $p = new Preguntas();
         $pid = $p->setPregunta($_eid);
         $r = new Respuestas();
         $r->setRespuestas($pid);
         Elfic::cosRedirect('index2.php?com=encuestas&do=edit&eid=' . $_eid);
     }
     break;
 case 'deletepregunta':
     if (!$uperms['encuestas_w']) {
         Elfic::cosRedirect('index2.php', MSG_NOPERM_COM);
     } else {
         if ($_pid) {
             $p = new Preguntas();
             $p->deletePregunta($_pid);
         }
         Elfic::cosRedirect('index2.php?com=encuestas&do=edit&eid=' . $_eid);
     }
     break;
Exemplo n.º 13
0
 public function getVerifyComment()
 {
     if (Request::ajax()) {
         $comment = Comentarios::leftJoin('publicaciones', 'publicaciones.id', '=', 'comentario.pub_id')->where('publicaciones.user_id', '=', Auth::user()->id)->where('comentario.is_read', '=', 0)->where('publicaciones.deleted', '=', 0)->where('comentario.deleted', '=', 0)->count();
         $responses = Respuestas::where('user_id', '=', Auth::user()->id)->where('is_read', '=', 0)->where('deleted', '=', 0)->count();
         return $comment + $responses;
     }
 }