Beispiel #1
0
/**
* @desc Visualiza todos los trabajos existentes
**/
function showWorks()
{
    global $xoopsModule, $xoopsSecurity;
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $page = rmc_server_var($_REQUEST, 'page', 1);
    $limit = rmc_server_var($_REQUEST, 'limit', 15);
    $show = rmc_server_var($_REQUEST, 'show', '');
    //Barra de Navegación
    $sql = "SELECT COUNT(*) FROM " . $db->prefix('pw_works');
    if ($show == 'public') {
        $sql .= " WHERE public=1";
    } elseif ($show == 'hidden') {
        $sql .= " WHERE public=0";
    }
    list($num) = $db->fetchRow($db->query($sql));
    $tpages = ceil($num / $limit);
    $page = $page > $tpages ? $tpages : $page;
    $start = $num <= 0 ? 0 : ($page - 1) * $limit;
    $nav = new RMPageNav($num, $limit, $page, 5);
    $nav->target_url('works.php?page={PAGE_NUM}');
    $sql = "SELECT * FROM " . $db->prefix('pw_works');
    if ($show == 'public') {
        $sql .= " WHERE public=1";
    } elseif ($show == 'hidden') {
        $sql .= " WHERE public=0";
    }
    $sql .= " ORDER BY id_work DESC LIMIT {$start}, {$limit}";
    $result = $db->query($sql);
    $works = array();
    //Container
    while ($row = $db->fetchArray($result)) {
        $work = new PWWork();
        $work->assignVars($row);
        //Obtenemos la categoría
        $cat = new PWCategory($work->category());
        //Obtenemos el cliente
        $user = new PWClient($work->client());
        $works[] = array('id' => $work->id(), 'title' => $work->title(), 'catego' => $cat->name(), 'client' => $user->name(), 'start' => formatTimeStamp($work->start(), 's'), 'mark' => $work->mark(), 'public' => $work->isPublic(), 'description' => $work->descShort());
    }
    PWFunctions::toolbar();
    RMTemplate::get()->add_style('admin.css', 'works');
    RMTemplate::get()->add_script(RMCURL . '/include/js/jquery.checkboxes.js');
    RMTemplate::get()->add_script('../include/js/admin_works.js');
    RMTemplate::get()->add_head("<script type='text/javascript'>\nvar pw_message='" . __('Do you really want to delete selected works?', 'works') . "';\n\n        var pw_select_message = '" . __('You must select some work before to execute this action!', 'works') . "';</script>");
    xoops_cp_location('<a href="./">' . $xoopsModule->name() . "</a> &raquo; " . __('Works', 'works'));
    xoops_cp_header();
    include RMTemplate::get()->get_template("admin/pw_works.php", 'module', 'works');
    xoops_cp_footer();
}
Beispiel #2
0
/**
* @desc Elimina de la base de datos la información del cliente
**/
function deleteClients()
{
    global $xoopsSecurity, $xoopsModule;
    $ids = rmc_server_var($_POST, 'ids', array());
    $page = rmc_server_var($_POST, 'page', 1);
    $limit = rmc_server_var($_POST, 'limit', 15);
    $ruta = "page={$page}&limit={$limit}";
    //Verificamos que nos hayan proporcionado un cliente para eliminar
    if (!is_array($ids)) {
        redirectMsg('./clients.php?' . $ruta, __('You must specify a customer to delete!', 'works'), 1);
        die;
    }
    if (!$xoopsSecurity->check()) {
        redirectMsg('./clients.php?' . $ruta, __('Session token expired!', 'works'), 1);
        die;
    }
    $errors = '';
    foreach ($ids as $k) {
        //Verificamos si el cliente es válido
        if ($k <= 0) {
            $errors .= sprintf(__('Customer ID "%u" is not valid!', 'works'), $k);
            continue;
        }
        //Verificamos si el cliente existe
        $client = new PWClient($k);
        if ($client->isNew()) {
            $errors .= sprintf(__('Customer with ID "%u" does not exists!', 'works'), $k);
            continue;
        }
        // Event
        RMEvents::get()->run_event('works.deleting.customer', $client);
        if (!$client->delete()) {
            $errors .= sprintf(__('Customer with ID "%u" could not be deleted!', 'works'), $k);
        }
    }
    if ($errors != '') {
        redirectMsg('./clients.php?' . $ruta, __('Errors ocurred while trying to delete customers:', 'works') . '<br />' . $errors, 1);
        die;
    } else {
        redirectMsg('./clients.php?' . $ruta, __('Database updated successfully!', 'works'), 0);
        die;
    }
}
Beispiel #3
0
}
//Verificamos si el trabajo existe
$work = new PWWork($id);
if ($work->isNew()) {
    redirect_header(PW_URL . '/', 2, __('Specified id does not exists!', 'works'));
    die;
}
if (!$work->isPublic() && !($xoopsUser && $xoopsUser->isAdmin())) {
    redirect_header(PW_URL, 1, __('The requested content is not available!', 'works'));
    die;
}
if (!$work->isPublic()) {
    $xoopsTpl->assign('lang_preview', __('You are in preview mode! This work is hidden for all other users.', 'works'));
}
$cat = new PWCategory($work->category());
$client = new PWClient($work->client());
$work_data = array('id' => $work->id(), 'title' => $work->title(), 'desc' => $work->desc(), 'intro' => $work->descShort(), 'category' => array('name' => $cat->name(), 'description' => $cat->desc(), 'id' => $cat->id(), 'nameid' => $cat->nameId(), 'link' => $cat->link()), 'client' => $client->businessName(), 'site' => $work->nameSite(), 'url' => formatURL($work->url()), 'created' => formatTimeStamp($work->created(), 's'), 'start' => formatTimeStamp($work->start(), 's'), 'period' => $work->period(), 'cost' => $mc['cost'] ? sprintf($mc['format_currency'], number_format($work->cost(), 2)) : '', 'mark' => $work->mark(), 'image' => XOOPS_UPLOAD_URL . '/works/' . $work->image(), 'thumb' => XOOPS_UPLOAD_URL . '/works/ths/' . $work->image(), 'comment' => $work->comment(), 'rating' => PWFunctions::rating($work->rating()), 'views' => $work->views(), 'metas' => $work->get_metas(), 'public' => $work->isPublic(), 'link' => $work->link());
$work_data = RMEvents::get()->run_event('works.work.data<{$work.l}', $work_data, $work);
$xoopsTpl->assign('work', $work_data);
$work->addView();
//Obtenemos todas las imágenes del trabajo
$sql = "SELECT * FROM " . $db->prefix('pw_images') . " WHERE work=" . $work->id();
$result = $db->query($sql);
while ($row = $db->fetchArray($result)) {
    $img = new PWImage();
    $img->assignVars($row);
    $tpl->append('images', array('id' => $img->id(), 'image' => XOOPS_UPLOAD_URL . '/works/ths/' . $img->image(), 'title' => $img->title(), 'desc' => $img->desc(), 'link_image' => XOOPS_UPLOAD_URL . '/works/' . $img->image()));
}
RMEvents::get()->run_event('works.load.work.images', $work);
$tpl->assign('xoops_pagetitle', $work->title() . ' &raquo; ' . $mc['title']);
/**
Beispiel #4
0
function pw_works_edit($options)
{
    global $db;
    include_once XOOPS_ROOT_PATH . '/modules/works/class/pwclient.class.php';
    include_once XOOPS_ROOT_PATH . '/modules/works/class/pwcategory.class.php';
    //Tipo de Trabajo
    $form = new RMForm(__('Block Options', 'works'), 'form_options', '');
    $ele = new RMFormSelect(__('Works type', 'works'), 'options[0]');
    $ele->addOption(0, __('Reandom works', 'works'), $options[0] == 0 ? 1 : 0);
    $ele->addOption(1, __('Featured works', 'works'), $options[0] == 1 ? 1 : 0);
    $ele->addOption(2, __('Recent works', 'works'), $options[0] == 2 ? 1 : 0);
    $form->addElement($ele);
    //Obtenemos las categorías
    $ele = new RMFormSelect(__('Category', 'works'), 'options[1]');
    $ele->addOption(0, __('All categories', 'works'));
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $result = $db->query("SELECT * FROM " . $db->prefix('pw_categos') . " WHERE active=1");
    while ($row = $db->fetchArray($result)) {
        $cat = new PWCategory();
        $cat->assignVars($row);
        $ele->addOption($cat->id(), $cat->name(), $options[1] == $cat->id() ? 1 : 0);
    }
    $form->addElement($ele, true);
    //Obtenemos los clientes
    $ele = new RMFormSelect(__('Customer', 'works'), 'options[2]');
    $ele->addOption(0, __('All customers', 'works'));
    $result = $db->query("SELECT * FROM " . $db->prefix('pw_clients'));
    while ($row = $db->fetchArray($result)) {
        $client = new PWClient();
        $client->assignVars($row);
        $ele->addOption($client->id(), $client->name(), isset($ptions[2]) ? $options[2] == $client->id() ? 1 : 0 : 0);
    }
    $form->addElement($ele, true);
    //Número de trabajos
    $form->addElement(new RMFormText(__('Works number', 'works'), 'options[3]', 5, 5, isset($options[3]) ? $options[3] : ''), true);
    $form->addElement(new RMFormText(__('Columns', 'works'), 'options[4]', 5, 5, isset($options[4]) ? $options[4] : ''), true);
    $form->addElement(new RMFormYesno(__('Show work image', 'works'), 'options[5]', isset($options[5]) ? $options[5] ? 1 : 0 : 0), true);
    $form->addElement(new RMFormYesno(__('Show description', 'works'), 'options[6]', isset($options[6]) ? $options[6] ? 1 : 0 : 0), true);
    return $form->render(false);
}