/// locate context information $context = get_context_instance(CONTEXT_COURSE, $course->id); require_capability('moodle/notes:manage', $context); if (empty($CFG->enablenotes)) { print_error('notesdisabled', 'notes'); } /// create form $noteform = new note_edit_form(); /// set defaults $noteform->set_data($note); /// if form was cancelled then return to the notes list of the note if ($noteform->is_cancelled()) { redirect($CFG->wwwroot . '/notes/index.php?course=' . $note->courseid . '&user='******'notes', 'update', 'index.php?course=' . $note->courseid . '&user='******'#note-' . $note->id, 'update note'); } // redirect to notes list that contains this note redirect($CFG->wwwroot . '/notes/index.php?course=' . $note->courseid . '&user='******'editnote', 'notes'); } else { $strnotes = get_string('addnewnote', 'notes'); } /// output HTML $nav = array(); if (has_capability('moodle/course:viewparticipants', $context) || has_capability('moodle/site:viewparticipants', get_context_instance(CONTEXT_SYSTEM))) { $nav[] = array('name' => get_string('participants'), 'link' => $CFG->wwwroot . '/user/index.php?id=' . $course->id, 'type' => 'misc');
/// check capability require_capability('moodle/notes:manage', $context); /// locate user information if (!($user = get_record('user', 'id', $userid))) { error('Incorrect user id found'); } /// build-up form require_once 'edit_form.php'; /// create form $noteform = new note_edit_form(null, $extradata); /// if form was cancelled then return to the previous notes list if ($noteform->is_cancelled()) { redirect($CFG->wwwroot . '/notes/index.php?course=' . $courseid . '&user='******'notes', 'add', 'index.php?course=' . $note->courseid . '&user='******'#note-' . $note->id, 'add note'); } // redirect to notes list that contains this note redirect($CFG->wwwroot . '/notes/index.php?course=' . $note->courseid . '&user=' . $note->userid); } if ($noteform->is_submitted()) { // if data was submitted with errors, then use it as default for new form $note = $noteform->get_submitted_data(false);