Esempio n. 1
0
<?php

require_once '..\\class\\Notes.php';
$o = new Notes();
$r = $o->update_note($_POST['id'], $_POST['isChecked']);
echo json_encode($r);
return;
Esempio n. 2
0
}

/* submit form: new or updated note */
if (isset($_POST['submitNote'])) {
    $v = new Valitron\Validator($_POST);
    $v->rule('required', array('newTitle'));
    $v->labels(array(
        'newTitle' => "$langTheField $langTitle"
    ));    
    if($v->validate()) {
        $newTitle = $_POST['newTitle'];
        $newContent = $_POST['newContent'];
        $refobjid = ($_POST['refobjid'] == "0") ? $_POST['refcourse'] : $_POST['refobjid'];
        if (!empty($_POST['id'])) { //existing note
            $id = intval(getDirectReference($_POST['id']));
            Notes::update_note($id, $newTitle, $newContent, $refobjid);
            Session::Messages($langNoteModify, 'alert-success');
            redirect_to_home_page('main/notes/index.php');        
        } else { // new note
            $id = Notes::add_note($newTitle, $newContent, $refobjid);
            if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
                echo $langNoteAdd;
                exit;
            }
            Session::Messages($langNoteAdd, 'alert-success');
            redirect_to_home_page('main/notes/index.php');
        }
    } else {
        $new_or_modify = empty($_POST['id']) ? "addNote=1" : "modify=$_POST[id]";
        Session::flashPost()->Messages($langFormErrors)->Errors($v->errors());
        redirect_to_home_page("main/notes/index.php?$new_or_modify");