<?php if (!empty($_POST)) { $file = FileData::getById($_POST["id"]); $p = new CommentData(); $p->user_id = $_SESSION["user_id"]; $p->file_id = $_POST["id"]; $p->comment = $_POST["comment"]; $p->add(); Core::alert("Agregado exitosamente!"); Core::redir("./?view=file&code=" . $file->code); }
<?php /** * @author evilnapsis * @brief Agregar likes apartir del id y tipo de referencia con el usuario logeado. **/ if (Session::exists("user_id") && !empty($_POST)) { if ($_POST["content"] != "") { $h = new CommentData(); $h->ref_id = $_POST["r"]; $h->user_id = $_SESSION["user_id"]; $h->type_id = $_POST["t"]; $h->content = $_POST["content"]; $h->add(); $user_id = null; $author_id = null; if ($_POST["t"] == 1) { $post = PostData::getReceptorId($_POST["r"]); $user_id = $post->receptor_ref_id; $author_id = $post->author_ref_id; } else { if ($_POST["t"] == 2) { $post = ImageData::getUserId($_POST["r"]); $user_id = $post->user_id; $author_id = $post->user_id; } } if ($author_id != $_SESSION["user_id"] && $user_id != $_SESSION["user_id"]) { // si es el mismo autor del post, entonces no le notificamos $notification = new NotificationData(); $notification->not_type_id = 2;
<?php $comment = new CommentData(); $comment->content = $_POST['content']; $comment->image_id = $_POST['image_id']; $comment->user_id = Session::getUID(); $comment->add(); $not_type = NotificationTypeData::getByName("Nuevo Comentario"); $u = UserData::getById(Session::getUID()); $image = ImageData::getById($_POST['image_id']); $n = new NotificationData(); $n->brief = "<b>{$u->name} {$u->lastname}</b> Te ha agregado un nuevo comentario."; $n->content = ""; $n->channel_id = $image->channel_id; $n->image_id = $_POST['image_id']; $n->comment_id = "NULL"; $n->album_id = "NULL"; $n->notification_type_id = $not_type->id; $n->user_id = Session::getUID(); $n->add(); print "<script>window.location='index.php?view=image&id={$_POST['image_id']}';</script>";