$PAGE->set_pagelayout(get_layout());
$PAGE->set_title(get_string('deletenote', 'local_note'));
$PAGE->set_heading(get_string('deletenote', 'local_note'));
$PAGE->set_url($CFG->wwwroot . '/local/note/my_notes.php');
if (!($id = required_param('id', PARAM_INT))) {
    new moodle_exception('invalidparam');
}
$form = new delete_note();
$form->set_data((object) array('id' => $id));
$message = false;
if ($form->is_cancelled()) {
    redirect(new moodle_url($CFG->wwwroot . '/local/note/my_notes.php'));
} else {
    if ($data = $form->get_data()) {
        $note = new \moi\note($DB, $USER->id);
        if ($note->author_authenticate($data->id)) {
            if ($note->delete($data->id)) {
                $message = html_writer::div(get_string('notedeleted', 'local_note'), 'alert alert-success');
                $form = null;
            }
        } else {
            $message = \html_writer::div(get_string('permisssiondenieddelete', 'local_note'), 'alert alert-danger');
            $form = null;
        }
    }
}
echo $OUTPUT->header();
echo html_writer::start_div('row');
echo html_writer::start_div('span12');
if ($message) {
    echo $message;
 * @copyright  2015 MoodleOfIndia
 * @author     shambhu kumar
 * @license    MoodleOfIndia {@web http://www.moodleofindia.com}
 */
require_once dirname(dirname(dirname(__FILE__))) . '/config.php';
require_login(0, false);
require_once 'locallib.php';
require_once 'classes/note.php';
$noteid = required_param('id', PARAM_INT);
$PAGE->set_context(context_system::instance());
$PAGE->set_pagelayout(get_layout());
$PAGE->set_title(get_string('editnote', 'local_note'));
$PAGE->set_heading(get_string('editnote', 'local_note'));
$PAGE->set_url($CFG->wwwroot . '/local/note/add_note.php');
$note = new \moi\note($DB, $USER->id);
if (!$note->author_authenticate($noteid, false)) {
    throw new moodle_exception('nopermissiontoshow');
}
$noteform = new \note_form($noteid);
$data = $DB->get_record('cli_note', array('id' => $noteid));
$noteform->set_data($data);
$message = false;
if ($noteform->is_cancelled()) {
    redirect(new moodle_url($CFG->wwwroot . '/local/note/my_notes.php'));
} else {
    if ($data = $noteform->get_data()) {
        $data->modifiedtime = time();
        $data->publisherid = $USER->id;
        if ($DB->update_record('cli_note', $data)) {
            $context = \context_system::instance();
            file_save_draft_area_files($data->attachment, $context->id, 'local_note', 'content', $data->attachment, array('subdirs' => 0, 'maxbytes' => 5000000, 'maxfiles' => 1));