Ejemplo n.º 1
0
function edit_note($conn)
{
    $validate = array('note_id' => array('validation' => 'OSS_DIGIT', 'e_message' => 'illegal:' . _('Note ID')), 'txt' => array('validation' => 'OSS_TEXT, OSS_PUNC_EXT', 'e_message' => 'illegal:' . _('Note text')));
    $validation_errors = validate_form_fields('POST', $validate);
    if (is_array($validation_errors) && !empty($validation_errors)) {
        Av_exception::throw_error(Av_exception::USER_ERROR, _('Error! Note could not be saved'));
    }
    $note_id = POST('note_id');
    $txt = POST('txt');
    $result = Notes::update($conn, $note_id, gmdate('Y-m-d H:i:s'), $txt);
    if ($result == TRUE) {
        $data['msg'] = _('Note saved successfully');
    } else {
        Av_exception::throw_error(Av_exception::USER_ERROR, _('Error! Note could not be saved'));
    }
    return $data;
}
Ejemplo n.º 2
0
        echo ossim_error();
    } else {
        if (Notes::insert($conn, $type, gmdate('Y-m-d H:i:s'), Session::get_session_user(), $id, $txt)) {
            $msg = 'created';
        } else {
            $msg = 'error';
        }
    }
} elseif (POST('action') == 'update') {
    $txt = POST('txt');
    $id_note = intval(POST('id_note'));
    ossim_valid($txt, OSS_TEXT, OSS_PUNC_EXT, 'illegal:' . _('Note text'));
    if (ossim_error()) {
        die(ossim_error());
    }
    if (Notes::update($conn, $id_note, gmdate('Y-m-d H:i:s'), $txt)) {
        echo json_encode(array('state' => 'OK'));
    } else {
        echo json_encode(array('state' => 'ERR'));
    }
    exit;
} elseif (POST('action') == 'new_ajax') {
    $txt = POST('txt');
    ossim_valid($txt, OSS_TEXT, OSS_PUNC_EXT, 'illegal:' . _('Note text'));
    if (ossim_error()) {
        die(ossim_error());
    }
    if (Notes::insert($conn, $type, gmdate('Y-m-d H:i:s'), Session::get_session_user(), $id, $txt)) {
        echo json_encode(array('state' => 'OK'));
    } else {
        echo json_encode(array('state' => 'ERR'));