예제 #1
0
/**
* @desc Visualiza todas las licencias existentes
**/
function showLicences()
{
    global $xoopsModule, $xoopsSecurity;
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $sql = "SELECT * FROM " . $db->prefix('dtrans_licences');
    $result = $db->queryF($sql);
    $licences = array();
    while ($rows = $db->fetchArray($result)) {
        $lc = new DTLicense();
        $lc->assignVars($rows);
        $licences[] = array('id' => $lc->id(), 'name' => $lc->name(), 'url' => $lc->link(), 'type' => $lc->type());
    }
    RMTemplate::get()->add_xoops_style('admin.css', 'dtransport');
    RMTemplate::get()->add_local_script('jquery.validate.min.js', 'rmcommon', 'include');
    RMTemplate::get()->add_local_script('jquery.checkboxes.js', 'rmcommon', 'include');
    RMTemplate::get()->add_local_script('admin.js', 'dtransport');
    RMTemplate::get()->add_head('<script type="text/javascript">
            var dt_message = "' . __('Do you really want to delete selected licenses', 'dtransport') . '";
            var dt_select_message = "' . __('Select at least one licence to delete!', 'dtransport') . '";
        </script>');
    DTFunctions::toolbar();
    xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> &raquo; " . __('Licences Management', 'dtransport'));
    xoops_cp_header();
    include RMTemplate::get()->get_template('admin/dtrans_licenses.php', 'module', 'dtransport');
    xoops_cp_footer();
}
 /**
  * @desc Obtiene las licencias del elemento
  * @param bool True devuelve objetos {@link DTLicense()}
  * @return array
  */
 public function licences($asobj = false)
 {
     $tbl1 = $this->db->prefix("dtrans_licsoft");
     $tbl2 = $this->db->prefix("dtrans_licences");
     if (empty($this->_licences) || $asobj && !is_a($this->_licences[0], 'DTLicense')) {
         $this->_licences = array();
         $sql = "SELECT b.* FROM {$tbl1} a, {$tbl2} b  WHERE a.id_soft='" . $this->id() . "' AND b.id_lic=a.id_lic";
         $result = $this->db->queryF($sql);
         while ($rows = $this->db->fetchArray($result)) {
             if ($asobj) {
                 $tmp = new DTLicense();
                 $tmp->assignVars($rows);
             } else {
                 $tmp = $rows['id_lic'];
             }
             $this->_licences[] = $tmp;
         }
     }
     return $this->_licences;
 }
예제 #3
0
/**
* @desc Formulario de Elementos
**/
function formItems($edit = 0)
{
    global $xoopsModule, $xoopsConfig, $xoopsModuleConfig, $rmc_config, $xoopsSecurity, $functions;
    define('RMCSUBLOCATION', 'newitem');
    // Get layout data
    $id = intval(rmc_server_var($_REQUEST, 'id', 0));
    $page = intval(rmc_server_var($_REQUEST, 'page', 0));
    $search = rmc_server_var($_REQUEST, 'search', '');
    $sort = rmc_server_var($_REQUEST, 'sort', 'id_soft');
    $mode = intval(rmc_server_var($_REQUEST, 'mode', 0));
    $catid = intval(rmc_server_var($_REQUEST, 'car', 0));
    $type = rmc_server_var($_REQUEST, 'type', '');
    $ev = RMEvents::get();
    $params = '?page=' . $page . '&search=' . $search . '&sort=' . $sort . '&mode=' . $mode . '&cat=' . $catid . '&type=' . $type;
    if ($edit) {
        //Verificamos que el software sea válido
        if ($id <= 0) {
            redirectMsg('items.php' . $params, __('Download item has not been specified!', 'dtransport'), 1);
            die;
        }
        //Verificamos que el software exista
        if ($type == 'edit') {
            $sw = new DTSoftwareEdited($id);
            $location = __('Verifying edited item!', 'dtransport');
        } else {
            $sw = new DTSoftware($id);
            $location = __('Editing download item', 'dtransport');
        }
        if ($sw->isNew()) {
            redirectMsg('./items.php' . $params, __('Specified download item does not exists!', 'dtransport'), 1);
            die;
        }
    } else {
        $sw = new DTSoftware();
        $location = __('New Download Item', 'dtransport');
    }
    $form = new RMForm('', '', '');
    $ed = new RMFormEditor('', 'desc', '99%', '300px', $edit ? $sw->getVar('desc', $rmc_config['editor_type'] != 'tiny' ? 'e' : 's') : '', $rmc_config['editor_type']);
    $ed->addClass('required');
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    //Lista de categorías
    $categos = array();
    $swcats = $sw->categories();
    DTFunctions::getCategos($categos, 0, 0, array(), false);
    foreach ($categos as $row) {
        $cat = new DTCategory();
        $cat->assignVars($row);
        $categories[] = array('id' => $cat->id(), 'name' => $cat->name(), 'parent' => $cat->parent(), 'active' => $cat->active(), 'description' => $cat->desc(), 'indent' => $row['jumps'], 'selected' => $edit ? in_array($cat->id(), $swcats) : '');
    }
    unset($categos);
    // Licencias
    $sql = "SELECT * FROM " . $db->prefix('dtrans_licences');
    $result = $db->queryF($sql);
    $lics = array();
    $lics[] = array('id' => 0, 'name' => __('Other license', 'dtransport'), 'selected' => !$edit || in_array(0, $sw->licences()) ? 1 : 0);
    while ($row = $db->fetchArray($result)) {
        $lic = new DTLicense();
        $lic->assignVars($row);
        $lics[] = array('id' => $lic->id(), 'name' => $lic->name(), 'selected' => $edit ? in_array($lic->id(), $sw->licences()) : '');
    }
    unset($lic);
    // Plataformas
    $sql = "SELECT * FROM " . $db->prefix('dtrans_platforms');
    $result = $db->queryF($sql);
    $oss = array();
    $oss[] = array('id' => 0, 'name' => __('Other platform', 'dtransport'), 'selected' => !$edit || in_array(0, $sw->platforms()) ? 1 : 0);
    while ($row = $db->fetchArray($result)) {
        $os = new DTPlatform();
        $os->assignVars($row);
        $oss[] = array('id' => $os->id(), 'name' => $os->name(), 'selected' => $edit ? in_array($os->id(), $sw->platforms()) : '');
    }
    unset($os);
    // Allowed groups
    $field = new RMFormGroups('', 'groups', 1, 1, 1, $edit ? $sw->getVar('groups') : array(1, 2));
    $groups = $field->render();
    // Tags
    $ftags = $sw->tags(true);
    $tags = array();
    foreach ($ftags as $tag) {
        $tags[] = $tag->getVar('tag');
    }
    unset($ftags);
    RMTemplate::get()->add_style('admin.css', 'dtransport');
    RMTemplate::get()->add_style('items.css', 'dtransport');
    RMTemplate::get()->add_local_script('itemsform.js', 'dtransport');
    RMTemplate::get()->add_local_script('jquery.validate.min.js', 'rmcommon', 'include');
    include DT_PATH . '/include/js_strings.php';
    DTFunctions::toolbar();
    xoops_cp_location($location);
    xoops_cp_header();
    include RMTemplate::get()->get_template('admin/dtrans_formitems.php', 'module', 'dtransport');
    xoops_cp_footer();
}