Ejemplo n.º 1
0
/**
* Sends the note data in json format
*/
function send_note_foredit()
{
    $id = rmc_server_var($_GET, 'id', 0);
    if ($id <= 0) {
        echo json_encode(array('message' => __('Note id not provided!', 'docs'), 'error' => 1));
        die;
    }
    $ref = new RDReference($id);
    if ($ref->isNew()) {
        echo json_encode(array('message' => __('Specified note does not exists!', 'docs'), 'error' => 1));
        die;
    }
    $ret = array('id' => $ref->id(), 'title' => $ref->getVar('title'), 'res' => $ref->getVar('id_res'), 'text' => $ref->getVar('text', 'e'), 'error' => 0);
    echo json_encode($ret);
    die;
}
Ejemplo n.º 2
0
/**
* Build a note or reference
* 
* @param int ID of note
*/
function rd_build_note($id)
{
    global $xoopsModuleConfig;
    static $note_number = 1;
    $ref = new RDReference($id);
    if ($ref->isNew()) {
        return;
    }
    $tpl = RMTemplate::get();
    $rep = array('<p>', '</p>');
    $tpl->append('references', array('id' => $ref->id(), 'text' => str_replace($rep, '', $ref->getVar('text'))));
    $ret = "<a name='top{$note_number}'></a><sup><a class='note-link' href='#note-{$note_number}' title='" . $ref->getVar('title') . "'>";
    $ret .= "{$note_number}</a></sup>";
    $note_number++;
    return $ret;
}
Ejemplo n.º 3
0
/**
* @desc Almacena toda la información referente a la referencia
**/
function saveReferences($edit = 0)
{
    global $xoopsSecurity;
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    foreach ($_POST as $k => $v) {
        ${$k} = $v;
    }
    $ruta = '?id=' . $id . '&page=' . $page . '&limit=' . $limit . '&search=' . $search;
    if (!$xoopsSecurity->check()) {
        redirectMsg('./references.php' . $ruta, __('Session token expired!', 'docs'), 1);
        die;
    }
    //Comprobar publicacion valida
    if ($id <= 0) {
        redirectMsg('./references.php' . $ruta, __('Document ID not provided!', 'docs'), 1);
        die;
    }
    //Comprobar publicación existente existente
    $res = new RDResource($id);
    if ($res->isNew()) {
        redirectMsg('./references.php' . $ruta, __('Specified Document does not exists!', 'docs'), 1);
        die;
    }
    if ($edit) {
        if ($id_ref <= 0) {
            redirectMsg('./references.php' . $ruta, __('Note id not provided!', 'docs'), 1);
            die;
        }
        $ref = new RDReference($id_ref);
        if ($ref->isNew()) {
            redirectMsg('./references.php' . $ruta, __('Specified note does not exists!', 'docs'), 1);
            die;
        }
        //Comprobar si el título de la referencia en esa publicación existe
        $sql = "SELECT COUNT(*) FROM " . $db->prefix('rd_references') . " WHERE title='{$title}' AND id_res='{$id}' AND id_ref<>'{$id_ref}'";
        list($num) = $db->fetchRow($db->queryF($sql));
        if ($num > 0) {
            redirectMsg('./references.php' . $ruta, __('Another note with same title already exists', 'docs'), 1);
            die;
        }
    } else {
        //Comprobar si el título de la referencia en esa publicación existe
        $sql = "SELECT COUNT(*) FROM " . $db->prefix('rd_references') . " WHERE title='{$title}' AND id_res='{$id}'";
        list($num) = $db->fetchRow($db->queryF($sql));
        if ($num > 0) {
            redirectMsg('./references.php' . $ruta, __('Another note with same title already exists', 'docs'), 1);
            die;
        }
        $ref = new RDReference();
    }
    $ref->setVar('id_res', $id);
    $ref->setVar('title', $title);
    $ref->setVar('text', $reference);
    if ($ref->save()) {
        redirectMsg('./references.php' . $ruta, __('Note saved successfully', 'docs'), 0);
    } else {
        redirectMsg('./references.php' . $ruta, __('Errors ocurred while trying to save note', 'docs'), 1);
    }
}
Ejemplo n.º 4
0
/**
* @desc Almacena información perteneciente a referencia
**/
function rd_save_note($edit = 0)
{
    global $xoopsSecurity;
    $id = 0;
    foreach ($_POST as $k => $v) {
        ${$k} = $v;
    }
    $ruta = "?res={$res}";
    if (!$xoopsSecurity->validateToken()) {
        redirectMsg('./notes.php' . $ruta, __('Session token expired!', 'docs'), 1);
        die;
    }
    if ($edit) {
        //Verifica que referencia sea válida
        if ($id <= 0) {
            redirectMsg('./notes.php' . $ruta, __('Note id not specified!', 'docs'), 1);
            die;
        }
        //Verifica que referencia exista
        $ref = new RDReference($id);
        if ($ref->isNew()) {
            redirectMsg('./notes.php' . $ruta, __('Specified note does not exists!', 'docs'), 1);
            die;
        }
    } else {
        $ref = new RDReference();
    }
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    //Comprobar si el título de la referencia en esa publicación existe
    $sql = "SELECT COUNT(*) FROM " . $db->prefix('rd_references') . " WHERE title='{$title}' AND id_res='{$res}' AND id_ref<>'{$id}'";
    list($num) = $db->fetchRow($db->queryF($sql));
    if ($num > 0) {
        redirectMsg('./notes.php' . $ruta, __('Already exists a note with same title', 'docs'), 1);
        die;
    }
    $ref->setVar('title', $title);
    $ref->setVar('text', $reference);
    $ref->setVar('id_res', $res);
    if ($ref->save()) {
        redirectMsg('./notes.php?action=locate&res=' . $res . '&id=' . $ref->id(), __('Note saved successfully!', 'docs'), 0);
        die;
    } else {
        redirectMsg('./notes.php?res=' . $res, __('Note could not be saved!', 'docs') . '<br />' . $ref->errors(), 1);
        die;
    }
}