예제 #1
0
/**
* @desc Muestra el formulario para creación de Foros
* @param int $edit Determina si se esta editando un foro existente
*/
function bx_show_form($edit = 0)
{
    global $xoopsModule, $xoopsConfig;
    if ($edit) {
        $id = rmc_server_var($_REQUEST, 'id', 0);
        if ($id <= 0) {
            redirectMsg('forums.php', __('Provided ID is not valid!', 'bxpress'), 1);
            die;
        }
        $forum = new bXForum($id);
        if ($forum->isNew()) {
            redirectMsg('forums.php', __('Specified forum does not exists!', 'bxpress'), 1);
            die;
        }
    }
    bXFunctions::menu_bar();
    RMTemplate::get()->set_help('http://www.redmexico.com.mx/docs/bxpress-forums/foros/standalone/1/#crear-foro');
    RMTemplate::get()->add_style('admin.css', 'bxpress');
    xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> &raquo; " . ($edit ? __('Edit Forum', 'bxpress') : __('New Forum', 'bxpress')));
    xoops_cp_header();
    $bcHand = new bXCategoryHandler();
    $bfHand = new bXForumHandler();
    $form = new RMForm($edit ? __('Edit Forum', 'bxpress') : __('New Forum', 'bxpress'), 'frmForum', 'forums.php');
    // Categorias
    $ele = new RMFormSelect(__('Category', 'bxpress'), 'cat', 0, $edit ? array($forum->category()) : null);
    $ele->addOption(0, __('Select category...', 'bxpress'), $edit ? 0 : 1);
    $ele->addOptionsArray($bcHand->getForSelect());
    $form->addElement($ele, true, 'noselect:0');
    // NOmbre
    $form->addElement(new RMFormText(__('Forum name', 'bxpress'), 'name', 50, 150, $edit ? $forum->name() : ''), true);
    // Descripcion
    $form->addElement(new RMFormEditor(__('Forum description', 'bxpress'), 'desc', '90%', '300px', $edit ? $forum->description() : ''));
    // Activo
    $form->addElement(new RMFormYesNo(__('Activate forum', 'bxpress'), 'active', $edit ? $forum->active() : 1));
    // Firmas
    $form->addElement(new RMFormYesNo(__('Allow signatures in the posts', 'bxpress'), 'sig', $edit ? $forum->signature() : 1));
    // Temas Populares
    $form->addElement(new RMFormText(__('Answers to match a topic as popular', 'bxpress'), 'hot_threshold', 10, 5, $edit ? $forum->hotThreshold() : 10), true, 'bigger:1');
    // Orden en la lista
    $form->addElement(new RMFormText(__('Order in the list', 'bxpress'), 'order', 10, 5, $edit ? $forum->order() : 0), false, 'bigger:-1');
    // Adjuntos
    $form->addElement(new RMFormYesNo(__('Allow attachments', 'bxpress'), 'attachments', $edit ? $forum->attachments() : 1));
    $ele = new RMFormText(__('Maximum attachments file size', 'bxpress'), 'attach_maxkb', 10, 20, $edit ? $forum->maxSize() : 50);
    $ele->setDescription(__('Specify this value in Kilobytes', 'bxpress'));
    $form->addElement($ele, false, 'bigger:0');
    $ele = new RMFormText(__('Allowed file types', 'bxpress'), 'attach_ext', 50, 0, $edit ? implode("|", $forum->extensions()) : 'zip|tar|jpg|gif|png|gz');
    $ele->setDescription(__('Specified the extensions of allowed file types separating each one with "|" and without the dot.', 'bxpress'));
    $form->addElement($ele);
    // Grupos con permiso
    if ($edit) {
        $grupos = $forum->permissions();
    }
    $form->addElement(new RMFormGroups(__('Can view the forum', 'bxpress'), 'perm_view', 1, 1, 5, $edit ? $grupos['view'] : array(0)));
    $form->addElement(new RMFormGroups(__('Can start new topics', 'bxpress'), 'perm_topic', 1, 1, 5, $edit ? $grupos['topic'] : array(1, 2)));
    $form->addElement(new RMFormGroups(__('Can answer', 'bxpress'), 'perm_reply', 1, 1, 5, $edit ? $grupos['reply'] : array(1, 2)));
    $form->addElement(new RMFormGroups(__('Can edit their posts', 'bxpress'), 'perm_edit', 1, 1, 5, $edit ? $grupos['edit'] : array(1, 2)));
    $form->addElement(new RMFormGroups(__('Can delete', 'bxpress'), 'perm_delete', 1, 1, 5, $edit ? $grupos['delete'] : array(1)));
    $form->addElement(new RMFormGroups(__('Can vote', 'bxpress'), 'perm_vote', 1, 1, 5, $edit ? $grupos['vote'] : array(1, 2)));
    $form->addElement(new RMFormGroups(__('Can attach', 'bxpress'), 'perm_attach', 1, 1, 5, $edit ? $grupos['attach'] : array(1, 2)));
    $form->addElement(new RMFormGroups(__('Can send without approval', 'bxpress'), 'perm_approve', 1, 1, 5, $edit ? $grupos['approve'] : array(1, 2)));
    $ele = new RMFormButtonGroup();
    $ele->addButton('sbt', $edit ? __('Save Changes', 'bxpress') : __('Create Forum', 'bxpress'), 'submit', '', 1);
    $ele->addButton('cancel', __('Cancel', 'bxpress'), 'button', 'onclick="window.location=\'forums.php\';"');
    $form->addElement($ele);
    $form->addElement(new RMFormHidden('action', $edit ? 'saveedit' : 'save'));
    if ($edit) {
        $form->addElement(new RMFormHidden('id', $forum->id()));
    }
    $form->display();
    xoops_cp_footer();
}
예제 #2
0
/**
* @desc Muestra el formulario para creación de Foros
* @param int $edit Determina si se esta editando un foro existente
*/
function bx_show_form($edit = 0)
{
    global $xoopsModule, $xoopsConfig;
    if (!RMfunctions::plugin_installed('advform')) {
        RMUris::redirect_with_message(sprintf(__('<a href="%s">AdvancedForms</a> must be installed before to create any forum. Please download and install it.', 'bxpress'), 'https://github.com/bitcero/advform'), 'forums.php', RMMSG_ERROR);
    }
    if ($edit) {
        $id = RMHttpRequest::request('id', 'integer', 0);
        if ($id <= 0) {
            RMUris::redirect_with_message(__('Provided ID is not valid!', 'bxpress'), 'forums.php', RMMSG_WARN);
            die;
        }
        $forum = new bXForum($id);
        if ($forum->isNew()) {
            RMUris::redirect_with_message(__('Specified forum does not exists!', 'bxpress'), 'forums.php', RMMSG_ERROR);
            die;
        }
    }
    RMTemplate::get()->add_style('admin.css', 'bxpress');
    xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> &raquo; " . ($edit ? __('Edit Forum', 'bxpress') : __('New Forum', 'bxpress')));
    xoops_cp_header();
    $bcHand = new bXCategoryHandler();
    $bfHand = new bXForumHandler();
    $form = new RMForm($edit ? __('Edit Forum', 'bxpress') : __('New Forum', 'bxpress'), 'frmForum', 'forums.php');
    // Categorias
    $ele = new RMFormSelect(__('Category', 'bxpress'), 'cat', 0, $edit ? array($forum->category()) : null);
    $ele->addOption(0, __('Select category...', 'bxpress'), $edit ? 0 : 1);
    $ele->addOptionsArray($bcHand->getForSelect());
    $form->addElement($ele, true, 'noselect:0');
    // NOmbre
    $form->addElement(new RMFormText(__('Forum name', 'bxpress'), 'name', 50, 150, $edit ? $forum->name() : ''), true);
    // Descripcion
    $form->addElement(new RMFormEditor(__('Forum description', 'bxpress'), 'desc', '90%', '300px', $edit ? $forum->getVar('desc', 'e') : ''));
    $form->addElement(new RMFormImageUrl(__('Forum image', 'bxpress'), 'image', $edit ? $forum->image : ''));
    // Activo
    $form->addElement(new RMFormYesNo(__('Activate forum', 'bxpress'), 'active', $edit ? $forum->active() : 1));
    // Firmas
    $form->addElement(new RMFormYesNo(__('Allow signatures in the posts', 'bxpress'), 'sig', $edit ? $forum->signature() : 1));
    // Temas Populares
    $form->addElement(new RMFormText(__('Answers to match a topic as popular', 'bxpress'), 'hot_threshold', 10, 5, $edit ? $forum->hotThreshold() : 10), true, 'bigger:1');
    // Orden en la lista
    $form->addElement(new RMFormText(__('Order in the list', 'bxpress'), 'order', 10, 5, $edit ? $forum->order() : 0), false, 'bigger:-1');
    // Adjuntos
    $form->addElement(new RMFormYesNo(__('Allow attachments', 'bxpress'), 'attachments', $edit ? $forum->attachments() : 1));
    $ele = new RMFormText(__('Maximum attachments file size', 'bxpress'), 'attach_maxkb', 10, 20, $edit ? $forum->maxSize() : 50);
    $ele->setDescription(__('Specify this value in Kilobytes', 'bxpress'));
    $form->addElement($ele, false, 'bigger:0');
    $ele = new RMFormText(__('Allowed file types', 'bxpress'), 'attach_ext', 50, 0, $edit ? implode("|", $forum->extensions()) : 'zip|tar|jpg|gif|png|gz');
    $ele->setDescription(__('Specified the extensions of allowed file types separating each one with "|" and without the dot.', 'bxpress'));
    $form->addElement($ele);
    // Grupos con permiso
    if ($edit) {
        $grupos = $forum->permissions();
    }
    $form->addElement(new RMFormGroups(__('Can view the forum', 'bxpress'), 'perm_view', 1, 1, 5, $edit ? $grupos['view'] : array(0)));
    $form->addElement(new RMFormGroups(__('Can start new topics', 'bxpress'), 'perm_topic', 1, 1, 5, $edit ? $grupos['topic'] : array(1, 2)));
    $form->addElement(new RMFormGroups(__('Can answer', 'bxpress'), 'perm_reply', 1, 1, 5, $edit ? $grupos['reply'] : array(1, 2)));
    $form->addElement(new RMFormGroups(__('Can edit their posts', 'bxpress'), 'perm_edit', 1, 1, 5, $edit ? $grupos['edit'] : array(1, 2)));
    $form->addElement(new RMFormGroups(__('Can delete', 'bxpress'), 'perm_delete', 1, 1, 5, $edit ? $grupos['delete'] : array(1)));
    $form->addElement(new RMFormGroups(__('Can vote', 'bxpress'), 'perm_vote', 1, 1, 5, $edit ? $grupos['vote'] : array(1, 2)));
    $form->addElement(new RMFormGroups(__('Can attach', 'bxpress'), 'perm_attach', 1, 1, 5, $edit ? $grupos['attach'] : array(1, 2)));
    $form->addElement(new RMFormGroups(__('Can send without approval', 'bxpress'), 'perm_approve', 1, 1, 5, $edit ? $grupos['approve'] : array(1, 2)));
    $ele = new RMFormButtonGroup();
    $ele->addButton('sbt', $edit ? __('Save Changes', 'bxpress') : __('Create Forum', 'bxpress'), 'submit', '', 1);
    $ele->addButton('cancel', __('Cancel', 'bxpress'), 'button', 'onclick="window.location=\'forums.php\';"');
    $form->addElement($ele);
    $form->addElement(new RMFormHidden('action', $edit ? 'saveedit' : 'save'));
    if ($edit) {
        $form->addElement(new RMFormHidden('id', $forum->id()));
    }
    $form->display();
    xoops_cp_footer();
}
예제 #3
0
파일: index.php 프로젝트: petitours/bxpress
                $lastpost['new'] = time() - $last->date() <= $xoopsModuleConfig['time_new'];
            }
        }
        $category = new bXCategory($forum->cat);
        $forums[] = array('id' => $forum->id(), 'name' => $forum->name(), 'desc' => $forum->description(), 'topics' => $forum->topics(), 'posts' => $forum->posts(), 'link' => $forum->makeLink(), 'last' => $lastpost, 'image' => $forum->image, 'active' => $forum->active, 'category' => array('title' => $category->title));
    }
    return $forums;
}
if ($xoopsModuleConfig['showcats']) {
    /**
     * Cargamos las categorías y los foros ordenados por categorías   
     */
    $xoopsOption['template_main'] = 'bxpress-index-categories.tpl';
    $xoopsOption['module_subpage'] = "index";
    include 'header.php';
    $categos = bXCategoryHandler::getObjects(1);
    foreach ($categos as $catego) {
        if (!$catego->groupAllowed($xoopsUser ? $xoopsUser->getGroups() : array(0, XOOPS_GROUP_ANONYMOUS))) {
            continue;
        }
        $forums = bXForumHandler::getForums($catego->id(), $xoopsModuleConfig['show_inactive'] ? -1 : 1, true);
        $tpl->append('categos', array('id' => $catego->id(), 'title' => $catego->title(), 'forums' => forums_data($forums)));
    }
} else {
    /**
     * Cargamos solo los foros
     */
    $xoopsOption['template_main'] = 'bxpress-index-forums.tpl';
    $xoopsOption['module_subpage'] = "index";
    include 'header.php';
    $fHand = new bXForumHandler();