MDL-50816 notes: Delete never met condition code

This commit is contained in:
Juan Leyva 2015-07-13 15:05:16 +02:00
parent 9325cd963f
commit 6166a9fbe7
5 changed files with 7 additions and 11 deletions

View File

@ -10,3 +10,4 @@ myfilesmanage,core
mypreferences,core_grades
myprofile,core
viewallmyentries,core_blog
cannotdeletepost,core_notes

View File

@ -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['selectnotestate'] = "Select note state";
$string['site'] = 'site';
$string['sitenotes'] = 'Site notes';
$string['unknown'] = 'unknown';
// Deprecated since Moodle 3.0.
$string['cannotdeletepost'] = 'Error occurred while deleting post';

View File

@ -48,9 +48,7 @@ if (!has_capability('moodle/notes:manage', $context)) {
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 {

View File

@ -239,12 +239,7 @@ class core_notes_external extends external_api {
$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');
}

View File

@ -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;