/** delete, allows users to delete their own moodboard. Same page used for security, the param can only be passed through a user submitting the original form @param id : id of the moodboard to delete. **/ function delete($id = null) { loggedInSection(); if ($id == null || !is_numeric($id)) { if ($this->input->post("delete_id") !== FALSE) { $mb = $this->moodboard_model->getMoodboard($this->input->post("delete_id")); if ($mb == false) { redirect('', 'location'); } else { $mb = $mb->row(); } if ($this->session->userdata("user_id") == $mb->m_user_id) { // delete database records and delete file if ($this->moodboard_model->deleteMoodboard($mb->moodboard_id)) { redirect("/user/u/" . $this->session->userdata("username") . "/?moodboard_deleted=1", "location"); } else { $data = array("errorTitle" => "Delete Failed", "content" => "An error has occurred when delete the moodboard. Please ensure this is your moodboard. If the problem persists, please get in touch"); $this->template->write_view("content", "general/error", $data, TRUE); //now render templates $this->template->render(); } } else { redirect('', 'location'); } } else { redirect('', 'location'); } } else { $mb = $this->moodboard_model->getMoodboard($id); if ($mb == false) { redirect('', 'location'); } else { $mb = $mb->row(); } if ($this->session->userdata("user_id") == $mb->m_user_id) { $base = base_url(); // now show delete screen $data = array("mb_title" => $mb->m_title, "mb_url" => $base . "moodboard/view/" . $mb->moodboard_id . '/' . slugify($mb->m_title) . '/', "delete_id" => $mb->moodboard_id); $this->template->write("title", "Delete a Moodboard"); $this->template->write_view("content", "moodboard/delete", $data, TRUE); $this->template->render(); } else { redirect('', 'location'); } } }
/** Deletes a noticed by notice id, as long as the notice belongs to the **/ function deleteUserNotice() { loggedInSection(); if (isAJAXRequest()) { $this->load->model("notice_model"); $notice = $this->notice_model->getNotice($_POST["notice_id"])->row(); // check if this notice belongs the user requesting it if ($notice->n_object_user_id == $this->session->userdata("user_id")) { // now delete $delete = $this->notice_model->deleteNotice($_POST["notice_id"]); if ($delete == true) { echo "true"; } else { echo "false"; } } else { echo "false"; } } else { $data = array("errorTitle" => "Request Denied", "content" => "An error has occurred: you cannot access this page from the browser."); $this->template->write_view("content", "general/error", $data, TRUE); //now render templates $this->template->render(); } }
function delete() { loggedInSection(); // urika_helper.php if (isAjaxRequest()) { if (isset($_POST["delete_id"]) && is_numeric($_POST["delete_id"])) { // check this post belongs to the user $comment = $this->comment_model->getComment($this->input->xss_clean($_POST["delete_id"])); if ($comment != false) { $comment = $comment->row(); if ($comment->c_poster_id == $this->session->userdata("user_id")) { // now delete the comment if ($this->comment_model->deleteComment($_POST["delete_id"]) == true) { echo "true"; } else { echo "false"; } } else { echo "false"; } } else { echo "false"; } } else { echo "false"; } } else { $data = array("errorTitle" => "Request Denied", "content" => "An error has occurred: you cannot access this page from the browser."); $this->template->write_view("content", "general/error", $data, TRUE); //now render templates $this->template->render(); } }
function delete($id = null) { loggedInSection(); // urika_helper.php if ($id == null || !is_numeric($id)) { $col = $this->collection_model->getCollection($this->input->post("delete_id")); if ($col == false) { redirect('', 'location'); } else { $col = $col->row(); } if ($this->session->userdata("user_id") == $col->col_user_id) { $mb_ids = $this->collection_model->getCollectionMoodboardIds($col->collection_id); // delete database records and delete file if ($this->collection_model->deleteCollection($col->collection_id)) { // atempt to delet collections if ($mb_ids != false) { $count = count($mb_ids); $this->load->model("moodboard_model"); for ($i = 0; $i < $count; $i++) { $this->moodboard_model->deleteMoodboard($mb_ids[$i]->moodboard_id); } } redirect("/user/u/" . $this->session->userdata("username") . "/?collection_deleted=1", "location"); } else { $data = array("errorTitle" => "Delete Failed", "content" => "An error has occurred when delete the collection. Please ensure this is your collection. If the problem persists, please get in touch"); $this->template->write_view("content", "general/error", $data, TRUE); //now render templates $this->template->render(); } } } else { $col = $this->collection_model->getCollection($id); if ($col == false) { redirect('', 'location'); } else { $col = $col->row(); } if ($this->session->userdata("user_id") == $col->col_user_id) { $base = base_url(); // now show delete screen $data = array("collection_title" => $col->col_name, "collection_url" => $base . "collection/view/" . $col->collection_id . '/' . slugify($col->col_name) . '/', "delete_id" => $col->collection_id); $this->template->write("title", "Delete your Collection"); $this->template->write_view("content", "collections/delete", $data, TRUE); $this->template->render(); } else { redirect('', 'location'); } } }
function flag() { loggedInSection(); // urika_helper.php if (isAjaxRequest()) { $image = $this->image_model->getImage($this->input->xss_clean($_POST["image_id"])); $image = $image->row(); $this->load->model("flag_model"); if ($this->flag_model->flagExists($this->session->userdata("user_id"), $image->image_id) == true) { echo "false"; } else { // need to add a new favourite $insert_data = array("fl_upload_id" => $image->image_id, "fl_flagger_id" => $this->session->userdata("user_id")); $insert = $this->flag_model->createNewFlag($insert_data); if ($insert !== false) { echo "true"; } else { echo "false"; } } } else { $data = array("errorTitle" => "Request Denied", "content" => "An error has occurred: you cannot access this page from the browser."); $this->template->write_view("content", "general/error", $data, TRUE); //now render templates $this->template->render(); } }
function add() { loggedInSection(); // urika_helper.php if (isAjaxRequest()) { $this->load->model("image_model"); $this->load->model("moodboard_model"); $this->load->model("user_model"); $base = base_url(); if ($this->favourite_model->favouriteExists($this->session->userdata("user_id"), $_POST["subject_id"], $_POST["object_type"]) == true) { $out_arr = array("msg" => "false"); } else { // need to add a new favourite $insert_data = array("f_subject_id" => $_POST["subject_id"], "f_user_id" => $this->session->userdata("user_id"), "f_type" => $this->input->xss_clean($_POST["object_type"])); $insert = $this->favourite_model->createNewFavourite($insert_data); // get the request object if ($_POST["object_type"] == "image") { $obj = $this->image_model->getImage($this->input->xss_clean($_POST["subject_id"]))->row(); $obj_user_id = $obj->i_user_id; $obj_name = $obj->i_title; } else { $obj = $this->moodboard_model->getMoodboard($this->input->xss_clean($_POST["subject_id"]))->row(); $obj_user_id = $obj->m_user_id; $obj_name = $obj->m_title; } // check for upload_comments in notice format string $createNotice = true; $subject_user = $this->user_model->getUser($obj_user_id)->row(); if ($_POST["object_type"] == "image") { if (strpos($subject_user->u_notice_format, "upload_comments") === FALSE) { $createNotice = false; } } else { if ($_POST["object_type"] == "moodboard") { if (strpos($subject_user->u_notice_format, "mb_comments") === FALSE) { $createNotice = false; } } } if ($insert !== false && $createNotice == true) { // success /* Begin notice insert */ $notice_insert = array("n_object_user_id" => $obj_user_id, "n_object_id" => $_POST["subject_id"], "n_object_type" => $_POST["object_type"], "n_action_user_id" => $this->session->userdata("user_id"), "n_type" => "favourite", "n_new" => 1, "n_html" => ""); // now html $notice_html = '<span class="notice_date">' . date("F j, Y, G:i") . '</span> - <a href="' . $base . 'user/u/' . $this->session->userdata("username") . '/" title="' . $this->session->userdata("username") . '\'s profile">' . $this->session->userdata("username") . '</a> added your '; if ($_POST["object_type"] == "image") { $this->load->model("image_model"); $image = $this->image_model->getImage($_POST["subject_id"])->row(); $n_url = $base . 'image/view/' . $_POST["subject_id"] . '/' . slugify($image->i_title) . '/'; $notice_html .= 'upload <a href="' . $n_url . '" title="View this image">' . $obj_name . '</a>'; } else { if ($_POST["object_type"] == "moodboard") { $this->load->model("moodboard_model"); $mb = $this->moodboard_model->getMoodboard($_POST["subject_id"])->row(); $n_url = $base . 'moodboard/view/' . $_POST["subject_id"] . '/' . slugify($mb->m_title) . '/'; $notice_html .= 'moodboard <a href="' . $n_url . '" title="View this moodboard">' . $obj_name . '</a>'; } } $notice_html .= ' to their favourites'; $notice_insert["n_html"] = $notice_html; $this->load->model("notice_model"); $this->notice_model->createNewNotice($notice_insert); /* End notice insert */ $out_arr = array("msg" => "true", "newfavli" => '<li class="sul_' . $this->session->userdata("user_id") . '"> <a href="' . $base . 'user/u/' . $this->session->userdata("username") . '/" title="View this users profile"> <img src="' . $this->session->userdata("image_url") . '" width="30" height="30" alt="User profile image" /> <span>' . $this->session->userdata("username") . '</span> </a>'); } else { if ($insert == false) { $out_arr = array("msg" => "false"); } else { $out_arr = array("msg" => "true", "newfavli" => '<li class="sul_' . $this->session->userdata("user_id") . '"> <a href="' . $base . 'user/u/' . $this->session->userdata("username") . '/" title="View this users profile"> <img src="' . $this->session->userdata("image_url") . '" width="30" height="30" alt="User profile image" /> <span>' . $this->session->userdata("username") . '</span> </a>'); } } echo json_encode($out_arr); } } else { $data = array("errorTitle" => "Request Denied", "content" => "An error has occurred: you cannot access this page from the browser."); $this->template->write_view("content", "general/error", $data, TRUE); //now render templates $this->template->render(); } }