Skip to content

Commit

Permalink
MDL-50816 notes: Delete never met condition code
Browse files Browse the repository at this point in the history
  • Loading branch information
jleyva committed Jul 15, 2015
1 parent 9325cd9 commit 6166a9f
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 11 deletions.
1 change: 1 addition & 0 deletions lang/en/deprecated.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ myfilesmanage,core
mypreferences,core_grades
myprofile,core
viewallmyentries,core_blog
cannotdeletepost,core_notes
4 changes: 3 additions & 1 deletion lang/en/notes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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';
4 changes: 1 addition & 3 deletions notes/delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 1 addition & 6 deletions notes/externallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
2 changes: 1 addition & 1 deletion notes/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 6166a9f

Please sign in to comment.