예제 #1
0
     $topic = new bXTopic();
     $topic->setApproved($forum->isAllowed($xoopsUser ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS, 'approve'));
     $topic->setDate(time());
     $topic->setForum($forum->id());
     $topic->setPoster($xoopsUser ? $xoopsUser->uid() : 0);
     $topic->setPosterName($xoopsUser ? $xoopsUser->uname() : $name);
     $topic->setRating(0);
     $topic->setReplies(0);
     $topic->setStatus(0);
     if ($xoopsUser && $xoopsModuleConfig['sticky']) {
         $csticky = $xoopsUser->isAdmin() || $forum->isModerator($xoopsUser->uid()) || $xoopsUser->posts() > $xoopsModuleConfig['sticky_posts'];
         if ($sticky) {
             $topic->sticky(isset($sticky) ? $sticky : 0);
         }
     } else {
         $topic->setSticky(0);
     }
     $topic->setTitle($myts->addSlashes($subject));
     $topic->setViews(0);
     $topic->setVotes(0);
     $topic->setFriendName(TextCleaner::getInstance()->sweetstring($subject));
     if ($xoopsUser && isset($sticky) && $xoopsModuleConfig['sticky']) {
         if ($xoopsUser->isAdmin() || $forum->isModerator($xoopsUser->uid()) || $xoopsUser->posts() > $xoopsModuleConfig['sticky_posts']) {
             $topic->setSticky($sticky);
         }
     }
     if (!$topic->save()) {
         redirect_header('./forum.php?id=' . $forum->id(), 2, __('Message could not be posted! Please try again', 'bxpress'));
         die;
     }
 }
예제 #2
0
/**
* @desc Cerrar o abrir un tema
*/
function stickyTopic($sticky)
{
    global $forum, $xoopsSecurity;
    if (!$xoopsSecurity->check()) {
        redirect_header('moderate.php?id=' . $forum->id(), 2, __('Session token expired!', 'bxpress'));
        die;
    }
    $topics = isset($_REQUEST['topics']) ? $_REQUEST['topics'] : null;
    if (empty($topics) || is_array($topics) && empty($topics)) {
        redirect_header('moderate.php?id=' . $forum->id(), 2, __('Select at least one topic to set as sticky!', 'bxpress'));
        die;
    }
    $topics = !is_array($topics) ? array($topics) : $topics;
    foreach ($topics as $k) {
        $topic = new bXTopic($k);
        if ($topic->isNew()) {
            continue;
        }
        $topic->setSticky($sticky);
        $topic->save();
    }
    redirect_header('moderate.php?id=' . $forum->id(), 1, __('Action completed!', 'bxpress'));
}