示例#1
0
/**
* Muestra las características existentes de una descarga
*/
function dt_show_features($edit = 0)
{
    global $xoopsOption, $db, $tpl, $xoopsTpl, $xoopsUser, $mc, $dtfunc, $page, $item, $xoopsConfig, $xoopsModuleConfig, $feature;
    include 'header.php';
    $dtfunc->cpHeader($item, sprintf(__('%s Features', 'dtransport'), $item->getVar('name')));
    if ($feature > 0 && $edit) {
        $feature = new DTFeature($feature);
        if ($feature->isNew() || $feature->software() != $item->id()) {
            redirect_header(DT_URL . ($mc['permalinks'] ? '/cp/features/' . $item->id() . '/' : '/?p=cpanel&action=features&id=' . $item->id()), 1, __('Specified feature does not exists!', 'dtransport'));
        }
    }
    $tc = TextCleaner::getInstance();
    $sql = "SELECT * FROM " . $db->prefix('dtrans_features') . " WHERE id_soft=" . $item->id();
    $result = $db->queryF($sql);
    while ($rows = $db->fetchArray($result)) {
        $feat = new DTFeature();
        $feat->assignVars($rows);
        $xoopsTpl->append('features', array('id' => $feat->id(), 'title' => $feat->title(), 'content' => $tc->truncate($tc->clean_disabled_tags($feat->content()), 80), 'software' => $item->getVar('name'), 'links' => array('permalink' => $feat->permalink(), 'edit' => DT_URL . ($mc['permalinks'] ? '/cp/features/' . $item->getVar('nameid') . '/edit/' . $feat->id() . '/' : '/?p=cpanel&id=' . $item->id() . '&action=features&feature=' . $feat->id()), 'delete' => DT_URL . ($mc['permalinks'] ? '/cp/features/' . $item->getVar('nameid') . '/delete/' . $feat->id() . '/' : '/?p=cpanel&id=' . $item->id() . '&action=delete&feature=' . $feat->id()))));
    }
    $formurl = DT_URL . ($mc['permalinks'] ? '/cp/features/' . $item->id() . '/save/' . ($edit ? $feature->id() : '0') . '/' : '/p=cpanel');
    // Features Form
    $form = new RMForm($edit ? sprintf(__('Editing feature of "%s"', 'dtransport'), $item->getVar('name')) : sprintf(__('New feature for "%s"', 'dtransport'), $item->getVar('name')), 'frmfeat', $formurl);
    $form->addElement(new RMFormLabel(__('Download item', 'dtransport'), $item->getVar('name')));
    $form->addElement(new RMFormText(__('Feature title', 'dtransport'), 'title', 50, 200, $edit ? $feature->title() : ''), true);
    $form->addElement(new RMFormText(__('Short name', 'dtransport'), 'nameid', 50, 200, $edit ? $feature->nameId() : ''));
    $form->addElement(new RMFormEditor(__('Feature content', 'dtransport'), 'content', 'auto', '350px', $edit ? $feature->content('e') : ''), true);
    $dtfunc->meta_form('feat', $edit ? $feature->id() : 0, $form);
    $form->addElement(new RMFormHidden('action', 'save'));
    $form->addElement(new RMFormHidden('id', $item->id()));
    $form->addElement(new RMFormHidden('feature', $edit ? $feature->id() : 0));
    $form->addElement(new RMFormHidden('op', 'save'));
    $buttons = new RMFormButtonGroup();
    $buttons->addButton('sbt', _SUBMIT, 'submit');
    $buttons->addButton('cancel', _CANCEL, 'button', 'onclick="window.location=\'' . (DT_URL . ($mc['permalinks'] ? '/cp/features/' . $item->id() . '/' : '/?p=cpanel&action=features&id=' . $item->id())) . '\';"');
    $form->addElement($buttons);
    $xoopsTpl->assign('feat_form', $form->render());
    $tpl->add_xoops_style('cpanel.css', 'dtransport');
    $tpl->add_head_script('$(document).ready(function(){
        
        $("a.delete").click(function(){
            if(!confirm("' . __('Do you really want to delete selected feature?', 'dtransport') . '")) return false;
        });
        
    });');
    $xoopsTpl->assign('lang_id', __('ID', 'dtransport'));
    $xoopsTpl->assign('lang_title', __('Title', 'dtransport'));
    $xoopsTpl->assign('lang_content', __('Content', 'dtransport'));
    $xoopsTpl->assign('lang_edit', __('Edit', 'dtransport'));
    $xoopsTpl->assign('lang_delete', __('Delete', 'dtransport'));
    $xoopsTpl->assign('lang_addfeat', __('Add Feature', 'dtransport'));
    $xoopsTpl->assign('edit', $edit);
    include 'footer.php';
}
示例#2
0
/**
* @desc Elimina la característica especificada de la base de datos
**/
function deleteFeatures()
{
    global $util, $xoopsModule;
    $ids = isset($_REQUEST['id']) ? $_REQUEST['id'] : 0;
    $item = isset($_REQUEST['item']) ? intval($_REQUEST['item']) : 0;
    $ok = isset($_POST['ok']) ? intval($_POST['ok']) : 0;
    //Verificamos que el software sea válido
    if ($item <= 0) {
        redirectMsg('./features.php', _AS_DT_ERR_ITEMVALID, 1);
        die;
    }
    //Verificamos que el software exista
    $sw = new DTSoftware($item);
    if ($sw->isNew()) {
        redirectMsg('./features.php', _AS_DT_ERR_ITEMEXIST, 1);
        die;
    }
    //Verificamos si nos proporcionaron alguna caracteristica
    if (!is_array($ids) && $ids <= 0) {
        redirectMsg('./features.php?item=' . $item, _AS_DT_ERRFEAT, 1);
        die;
    }
    $num = 0;
    if (!is_array($ids)) {
        $feat = new DTFeature($ids);
        $ids = array($ids);
        $num = 1;
    }
    if ($ok) {
        if (!$util->validateToken()) {
            redirectMsg('./features.php?item=' . $item, _AS_DT_SESSINVALID, 1);
            die;
        }
        foreach ($ids as $k) {
            //Verificamos si la característica es válida
            if ($k <= 0) {
                $errors .= sprintf(_AS_DT_ERRFEATVAL, $k);
                continue;
            }
            //Verificamos si la caracteristica existe
            $ft = new DTFeature($k);
            if ($ft->isNew()) {
                $errors .= sprintf(_AS_DT_ERRFEATEX, $k);
                continue;
            }
            if (!$ft->delete()) {
                $errors .= sprintf(_AS_DT_ERRFEATDEL, $k);
            }
        }
        if ($errors != '') {
            redirectMsg('./features.php?item=' . $item, _AS_DT_ERRORS . $errors, 1);
            die;
        } else {
            redirectMsg('./features.php?item=' . $item, _AS_DT_DBOK, 0);
            die;
        }
    } else {
        optionsBar();
        xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> &raquo; <a href='./items.php'>" . _AS_DT_SW . "</a> &raquo; " . _AS_DT_DELETEFEATURE);
        xoops_cp_header();
        $hiddens['ok'] = 1;
        $hiddens['id[]'] = $ids;
        $hiddens['item'] = $item;
        $hiddens['op'] = 'delete';
        $buttons['sbt']['type'] = 'submit';
        $buttons['sbt']['value'] = _DELETE;
        $buttons['cancel']['type'] = 'button';
        $buttons['cancel']['value'] = _CANCEL;
        $buttons['cancel']['extra'] = 'onclick="window.location=\'features.php?item=' . $item . '\';"';
        $util->msgBox($hiddens, 'features.php', ($num ? sprintf(_AS_DT_DELETECONF, $feat->title()) : _AS_DT_DELCONF) . '<br /><br />' . _AS_DT_ALLPERM, XOOPS_ALERT_ICON, $buttons, true, '400px');
        xoops_cp_footer();
    }
}