From 6166a9fbe707f353f7a9ceebb4d97c12f13a051a Mon Sep 17 00:00:00 2001 From: Juan Leyva Date: Mon, 13 Jul 2015 15:05:16 +0200 Subject: [PATCH] MDL-50816 notes: Delete never met condition code --- lang/en/deprecated.txt | 1 + lang/en/notes.php | 4 +++- notes/delete.php | 4 +--- notes/externallib.php | 7 +------ notes/lib.php | 2 +- 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/lang/en/deprecated.txt b/lang/en/deprecated.txt index 83a6cb4feb9ad..93f82df4da43f 100644 --- a/lang/en/deprecated.txt +++ b/lang/en/deprecated.txt @@ -10,3 +10,4 @@ myfilesmanage,core mypreferences,core_grades myprofile,core viewallmyentries,core_blog +cannotdeletepost,core_notes \ No newline at end of file diff --git a/lang/en/notes.php b/lang/en/notes.php index 16f7097cec3f6..4491e67c7f4fa 100644 --- a/lang/en/notes.php +++ b/lang/en/notes.php @@ -26,7 +26,6 @@ $string['addnewnote'] = 'Add a new note'; $string['addnewnoteselect'] = 'Select users to write notes about'; $string['bynameondate'] = 'by {$a->name} - {$a->date}'; -$string['cannotdeletepost'] = 'Error occurred while deleting post'; $string['configenablenotes'] = 'Enable storing of notes about individual users.'; $string['content'] = 'Content'; $string['course'] = 'course'; @@ -66,3 +65,6 @@ $string['site'] = 'site'; $string['sitenotes'] = 'Site notes'; $string['unknown'] = 'unknown'; + +// Deprecated since Moodle 3.0. +$string['cannotdeletepost'] = 'Error occurred while deleting post'; diff --git a/notes/delete.php b/notes/delete.php index ccd2b16f045e4..3e0efc41413ae 100644 --- a/notes/delete.php +++ b/notes/delete.php @@ -48,9 +48,7 @@ if (data_submitted() && confirm_sesskey()) { // If data was submitted and is valid, then delete note. $returnurl = $CFG->wwwroot . '/notes/index.php?course=' . $course->id . '&user=' . $note->userid; - if (!note_delete($note)) { - print_error('cannotdeletepost', 'notes', $returnurl); - } + note_delete($note); redirect($returnurl); } else { diff --git a/notes/externallib.php b/notes/externallib.php index 22d8cbfc8fd57..13ca62df77f33 100644 --- a/notes/externallib.php +++ b/notes/externallib.php @@ -239,12 +239,7 @@ public static function delete_notes($notes = array()) { $context = context_course::instance($note->courseid); self::validate_context($context); require_capability('moodle/notes:manage', $context); - if (!note_delete($note)) { - $warnings[] = array(array('item' => 'note', - 'itemid' => $noteid, - 'warningcode' => 'savedfailed', - 'message' => 'Note could not be modified')); - } + note_delete($note); } else { $warnings[] = array('item'=>'note', 'itemid'=>$noteid, 'warningcode'=>'badid', 'message'=>'Note does not exist'); } diff --git a/notes/lib.php b/notes/lib.php index ea05994e0c2ed..a443a4b4c7797 100644 --- a/notes/lib.php +++ b/notes/lib.php @@ -154,7 +154,7 @@ function note_save(&$note) { * Deletes a note object based on its id. * * @param int|object $note id of the note to delete, or a note object which is to be deleted. - * @return boolean true if the object was deleted; false otherwise + * @return boolean true always */ function note_delete($note) { global $DB;