public function object_data($event)
 {
     include_once XOOPS_ROOT_PATH . '/modules/bxpress/class/bxforum.class.php';
     include_once XOOPS_ROOT_PATH . '/modules/bxpress/class/bxtopic.class.php';
     switch ($event->event) {
         case 'reply':
             // Get topic
             $topic = new bXTopic($event->params);
             if ($topic->isNew()) {
                 return null;
             }
             $ret = array('name' => $topic->title(), 'link' => $topic->permalink());
             break;
         case 'newtopic':
         case 'forum-newpost':
             // Get forum
             $forum = new bXForum($event->params);
             if ($forum->isNew()) {
                 return null;
             }
             $ret = array('name' => $forum->name(), 'link' => $forum->permalink());
             break;
     }
     return $ret;
 }
示例#2
0
/**
* @desc Almacena los usuarios moderadores
**/
function bx_save_moderators()
{
    global $xoopsSecurity;
    if (!$xoopsSecurity->check()) {
        redirectMsg('forums.php', __('Session token expired!', 'bxpress'), 1);
        die;
    }
    foreach ($_POST as $k => $v) {
        ${$k} = $v;
    }
    //Verificamos si el foro es válido
    if ($id <= 0) {
        redirectMsg('forums.php', __('A forum ID has not been provided!', 'bxpress'), 1);
        die;
    }
    //Comprobamos que el foro exista
    $forum = new bXForum($id);
    if ($forum->isNew()) {
        redirectMsg('forums.php', __('Sepecified forum does not exists!', 'bxpress'), 1);
        die;
    }
    $forum->setModerators($users);
    if ($forum->save()) {
        redirectMsg('forums.php', __('Moderator saved successfully!', 'bxpress'), 0);
    } else {
        redirectMsg('forums.php', __('Moderators could not be saved!', 'bxpress') . '<br />' . $forum->errors(), 1);
    }
}
示例#3
0
文件: rss.php 项目: petitours/bxpress
$bxFunc = new bXFunctions();
$db = XoopsDatabaseFactory::getDatabaseConnection();
$tc = TextCleaner::getInstance();
$tbl1 = $db->prefix('mod_bxpress_posts');
$tbl2 = $db->prefix('mod_bxpress_topics');
$tbl3 = $db->prefix('mod_bxpress_posts_text');
$tbl4 = $db->prefix('mod_bxpress_forums');
switch ($show) {
    case 'forum':
        $id = rmc_server_var($_GET, 'forum', 0);
        if ($id <= 0) {
            redirect_header('backend.php', 1, __('Sorry, specified forum was not foud!', 'bxpress'));
            die;
        }
        $forum = new bXForum($id);
        if ($forum->isNew()) {
            redirect_header('backend.php', 1, __('Sorry, specified forum was not foud!', 'bxpress'));
            die;
        }
        $rss_channel['title'] = sprintf(__('%s :: Posts on forum %s'), $xoopsModule->name(), $forum->name());
        $rss_channel['link'] = $forum->permalink();
        $rss_channel['description'] = sprintf(__('All recent messages posted on %s', 'dtransport'), $forum->name());
        $rss_channel['lastbuild'] = formatTimestamp(time(), 'rss');
        $rss_channel['webmaster'] = checkEmail($xoopsConfig['adminmail'], true);
        $rss_channel['editor'] = checkEmail($xoopsConfig['adminmail'], true);
        $rss_channel['category'] = $forum->name();
        $rss_channel['generator'] = 'Common Utilities';
        $rss_channel['language'] = RMCLANG;
        $sql = "SELECT * FROM {$tbl1} WHERE id_forum={$id} AND approved=1 ORDER BY post_time DESC LIMIT 0,50";
        $result = $db->queryF($sql);
        $topics = array();
示例#4
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';
    }
}