$res = self::query("UPDATE `notes` SET `title` = '{$title}', `message` = '{$message}' WHERE `notes`.`id` = {$id}"); } // Return query result return json_encode($res); } public static function delete($id) { $res = self::query("DELETE FROM notes WHERE `id` = {$id}"); return $res; } } // Our script requires JSON data format // Set Content-Type to JSON header('Content-Type: application/json'); // if GET request then return the list of all items // if POST request then add, edit or delete switch ($_SERVER['REQUEST_METHOD']) { case 'GET': echo Note::getAll(); break; case 'POST': if (isset($_POST['action'])) { echo Note::delete($_POST['id']); } else { print_r(Note::save($_POST)); } break; default: echo 'Unknown operation'; break; }
public function destroy_note() { if (!isset($_POST['note_id'])) { error(__("Error"), __("No note ID specified.", "extend")); } $note = new Note($_POST['note_id']); if ($note->no_results) { error(__("Error"), __("Invalid note ID specified.", "extend")); } if (!$note->deletable()) { show_403(__("Access Denied"), __("You do not have sufficient privileges to delete this note.", "extend")); } Note::delete($note->id); Flash::notice(__("Note deleted.", "extend"), $note->version->url()); }
public function rename() { $from = $this->params->from; $to = $this->params->to; if ($this->username && !$this->is_owner) { return $this->redirect($from); } $orig = new Note(array('url' => "/{$from}")); if ($orig->load()) { // Check that the destination is missing or empty of words $dest = new Note(array('url' => "/{$to}")); if ($dest->load()) { if (strlen($dest->words)) { return $this->redirect($from); } $dest->delete(); } $orig->url = "/{$to}"; $orig->status = STATUS_RENAMED; if ($orig->save()) { return $this->redirect($to); } } }
public function delete() { $hash_Str = $this->input->get('hash'); $noteid_Num = $this->input->get('noteid'); $noteid_Arr = $this->input->post('noteid_Arr[]'); if (empty($noteid_Arr) && empty($noteid_Num)) { $this->load->model('Message'); $this->Message->show(['message' => '未選擇要刪除的文章', 'url' => 'admin/base/note/note/tablelist']); } //CSRF過濾 if ($hash_Str == $this->security->get_csrf_hash()) { if (!empty($noteid_Num)) { $Note = new Note(['noteid_Num' => $noteid_Num]); $Note->delete(); } if (!empty($noteid_Arr)) { foreach ($noteid_Arr as $key => $value_note) { $Note = new Note(['noteid_Num' => $value_note]); $Note->delete(); } } $this->load->model('Message'); $this->Message->show(['message' => '刪除成功', 'url' => 'admin/base/note/note/tablelist']); } else { $this->load->model('Message'); $this->Message->show(['message' => 'hash驗證失敗,請使用標準瀏覽器進行刪除動作', 'url' => 'admin/base/note/note/tablelist']); } }
/** * Function: delete * Deletes the given version, including its notes. Calls the "delete_version" trigger and passes the <Version> as an argument. * * Parameters: * $id - The version to delete. */ static function delete($id) { $version = new self($id); foreach ($version->notes as $note) { Note::delete($note->id); } foreach ($version->attachments as $attachment) { Attachment::delete($attachment->id); } @unlink(uploaded($version->filename, false)); @unlink(uploaded($version->preview, false)); parent::destroy(get_class(), $id); if (module_enabled("cacher")) { Modules::$instances["cacher"]->regenerate(); } }