Exemple #1
0
/**
* @desc Muestra la lista de foros existentes
*/
function bx_show_forums()
{
    global $xoopsModule, $xoopsSecurity;
    $catid = rmc_server_var($_REQUEST, 'catid', 0);
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $sql = "SELECT * FROM " . $db->prefix("bxpress_forums");
    if ($catid > 0) {
        $sql .= " WHERE cat='{$catid}'";
    }
    $sql .= " ORDER BY cat,`order`";
    $result = $db->query($sql);
    $categos = array();
    $forums = array();
    while ($row = $db->fetchArray($result)) {
        $forum = new bXForum();
        $forum->assignVars($row);
        // Cargamos la categoría
        if (isset($categos[$forum->category()])) {
            $catego = $categos[$forum->category()];
        } else {
            $categos[$forum->category()] = new bXCategory($forum->category());
            $catego = $categos[$forum->category()];
        }
        // Asignamos los valores
        $forums[] = array('id' => $forum->id(), 'title' => $forum->name(), 'topics' => $forum->topics(), 'posts' => $forum->posts(), 'catego' => $catego->title(), 'active' => $forum->active(), 'attach' => $forum->attachments(), 'order' => $forum->order());
    }
    bXFunctions::menu_bar();
    xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> &raquo; " . __('Forums Management', 'bxpress'));
    xoops_cp_header();
    RMTemplate::get()->set_help('http://www.redmexico.com.mx/docs/bxpress-forums/foros/standalone/1/');
    RMTemplate::get()->add_local_script('jquery.checkboxes.js', 'rmcommon', 'include');
    RMTemplate::get()->add_local_script('admin.js', 'bxpress');
    RMTemplate::get()->add_head('<script type="text/javascript">
        var bx_select_message = "' . __('You must select one forum at least in order to run this action!', 'bxpress') . '";
        var bx_message = "' . __('Do you really want to delete selected forums?\\n\\nAll posts sent in this forum will be deleted also!', 'bxpress') . '";
    </script>');
    include RMTemplate::get()->get_template('admin/forums_forums.php', 'module', 'bxpress');
    xoops_cp_footer();
}
Exemple #2
0
/**
* @desc Muestra la lista de foros existentes
*/
function bx_show_forums()
{
    global $xoopsModule, $xoopsSecurity;
    $catid = RMHttpRequest::request('catid', 'integer', 0);
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $sql = "SELECT * FROM " . $db->prefix("mod_bxpress_forums");
    if ($catid > 0) {
        $sql .= " WHERE cat='{$catid}'";
    }
    $sql .= " ORDER BY cat,`order`";
    $result = $db->query($sql);
    $categos = array();
    $forums = array();
    while ($row = $db->fetchArray($result)) {
        $forum = new bXForum();
        $forum->assignVars($row);
        // Cargamos la categoría
        if (isset($categos[$forum->category()])) {
            $catego = $categos[$forum->category()];
        } else {
            $categos[$forum->category()] = new bXCategory($forum->category());
            $catego = $categos[$forum->category()];
        }
        // Asignamos los valores
        $forums[] = array('id' => $forum->id(), 'title' => $forum->name(), 'topics' => $forum->topics(), 'posts' => $forum->posts(), 'catego' => $catego->title(), 'active' => $forum->active(), 'attach' => $forum->attachments(), 'order' => $forum->order());
    }
    $bc = RMBreadCrumb::get();
    $bc->add_crumb(__('Forums', 'bxpress'));
    xoops_cp_header();
    RMTemplate::get()->add_help(__('Forums Help', 'bxpress'), 'http://www.redmexico.com.mx/docs/bxpress-forums/foros/standalone/1/');
    RMTemplate::get()->add_script('admin.js', 'bxpress');
    RMTemplate::get()->add_head_script('var bx_select_message = "' . __('You must select one forum at least in order to run this action!', 'bxpress') . '";
        var bx_message = "' . __('Do you really want to delete selected forums?\\n\\nAll posts sent in this forum will be deleted also!', 'bxpress') . '";');
    include RMTemplate::get()->get_template('admin/forums-forums.php', 'module', 'bxpress');
    xoops_cp_footer();
}
Exemple #3
0
/**
* @desc Mover temas de un foro a otro
*/
function moveTopics()
{
    global $db, $xoopsModuleConfig, $xoopsSecurity, $forum, $xoopsUser, $xoopsOption, $xoopsConfig;
    $topics = isset($_REQUEST['topics']) ? $_REQUEST['topics'] : null;
    $ok = isset($_POST['ok']) ? $_POST['ok'] : 0;
    $moveforum = rmc_server_var($_POST, 'moveforum', 0);
    if (empty($topics) || is_array($topics) && empty($topics)) {
        redirect_header('moderate.php?id=' . $moveforum, 2, __('Select at least a topic to moderate!', 'bxpress'));
        die;
    }
    $topics = !is_array($topics) ? array($topics) : $topics;
    if ($ok) {
        if (!$xoopsSecurity->check()) {
            redirect_header('moderate.php?id=' . $moveforum, 2, __('Session token expired!', 'bxpress'));
            die;
        }
        if ($moveforum <= 0) {
            redirect_header('moderate.php?id=' . $forum->id(), 2, __('Please select the target forum', 'bxpress'));
            die;
        }
        $mf = new bXForum($moveforum);
        if ($mf->isNew()) {
            redirect_header('moderate.php?id=' . $forum->id(), 2, __('Specified forum does not exists!', 'bxpress'));
            die;
        }
        $lastpost = false;
        foreach ($topics as $k) {
            $topic = new bXTopic($k);
            if ($topic->forum() != $forum->id()) {
                continue;
            }
            //Verificamos si el tema contiene el último mensaje del foro
            if (!$lastpost && array_key_exists($forum->lastPostId(), $topic->getPosts(0))) {
                $lastpost = true;
            }
            $topic->setForum($moveforum);
            if ($topic->save()) {
                //Decrementa el número de temas
                $forum->setTopics($forum->topics() - 1 > 0 ? $forum->topics() - 1 : 0);
                $forum->setPosts($forum->posts() - ($topic->replies() + 1) > 0 ? $forum->posts() - ($topic->replies() + 1) : 0);
                $forum->save();
                $mf->setPosts($mf->posts() + ($topic->replies() + 1));
                $mf->addTopic();
                $mf->save();
                //Cambiamos el foro de los mensajes del tema
                if ($topic->getPosts()) {
                    foreach ($topic->getPosts() as $k => $v) {
                        $v->setForum($moveforum);
                        $v->save();
                    }
                }
            }
        }
        //Actualizamos el último mensaje del foro
        if ($lastpost) {
            $post = $forum->getLastPost();
            $forum->setPostId($post);
            $forum->save();
        }
        //Actualizamos el último mensaje del foro al que fue movido el tema
        $post = $mf->getLastPost();
        $post ? $mf->setPostId($post) : '';
        $mf->save();
        redirect_header('moderate.php?id=' . $forum->id(), 1, __('Topics has been relocated!', 'bxpress'));
        die;
    } else {
        global $xoopsTpl;
        $tpl = $xoopsTpl;
        $xoopsOption['template_main'] = "bxpress_moderateforms.html";
        $xoopsOption['module_subpage'] = "moderate";
        include 'header.php';
        bXFunctions::makeHeader();
        $form = new RMForm(__('Move Topics', 'bxpress'), 'frmMove', 'moderate.php');
        $form->addElement(new RMFormHidden('id', $forum->id()));
        $form->addElement(new RMFormHidden('op', 'move'));
        $form->addElement(new RMFormHidden('ok', '1'));
        $i = 0;
        foreach ($topics as $k) {
            $form->addElement(new RMFormHidden('topics[' . $i . ']', $k));
            ++$i;
        }
        $form->addElement(new RMFormSubTitle('&nbsp', 1, ''));
        $form->addElement(new RMFormSubTitle(__('Select the forum where you wish to move selected topics', 'bxpress'), 1, 'even'));
        $ele = new RMFormSelect(__('Forum', 'bxpress'), 'moveforum');
        $ele->addOption(0, '', 1);
        $tbl1 = $db->prefix("bxpress_categories");
        $tbl2 = $db->prefix("bxpress_forums");
        $sql = "SELECT b.*, a.title FROM {$tbl1} a, {$tbl2} b WHERE b.cat=a.id_cat AND b.active='1' AND id_forum<>" . $forum->id() . " ORDER BY a.order, b.order";
        $result = $db->query($sql);
        $categories = array();
        while ($row = $db->fetchArray($result)) {
            $cforum = array('id' => $row['id_forum'], 'name' => $row['name']);
            if (isset($categores[$row['cat']])) {
                $categories[$row['cat']]['forums'][] = $cforum;
            } else {
                $categories[$row['cat']]['title'] = $row['title'];
                $categories[$row['cat']]['forums'][] = $cforum;
            }
        }
        foreach ($categories as $cat) {
            $ele->addOption(0, $cat['title'], 0, true, 'color: #000; font-weight: bold; font-style: italic; border-bottom: 1px solid #c8c8c8;');
            foreach ($cat['forums'] as $cforum) {
                $ele->addOption($cforum['id'], $cforum['name'], 0, false, 'padding-left: 10px;');
            }
        }
        $form->addElement($ele, true, "noselect:0");
        $ele = new RMFormButtonGroup();
        $ele->addButton('sbt', __('Move Topics Now!', 'bxpress'), 'submit');
        $ele->addButton('cancel', __('Cancel', 'bxpress'), 'button', 'onclick="history.go(-1);"');
        $form->addElement($ele);
        $tpl->assign('moderate_form', $form->render());
        include 'footer.php';
    }
}