コード例 #1
0
ファイル: topic.php プロジェクト: petitours/bxpress
    $topic->addView();
    $topic->save();
    $_SESSION['topics_viewed'] = array();
    $_SESSION['topics_viewed'][] = $topic->id();
} else {
    if (!in_array($topic->id(), $_SESSION['topics_viewed'])) {
        $topic->addView();
        $topic->save();
        $_SESSION['topics_viewed'][] = $topic->id();
    }
}
$xoopsOption['template_main'] = "bxpress-topic.tpl";
$xoopsOption['module_subpage'] = "topics";
include 'header.php';
bXFunctions::makeHeader();
$tpl->assign('forum', array('id' => $forum->id(), 'title' => $forum->name(), 'moderator' => $xoopsUser ? $forum->isModerator($xoopsUser->uid()) || $xoopsUser->isAdmin() : false));
$tpl->assign('topic', array('id' => $topic->id(), 'title' => $topic->title(), 'closed' => $topic->status(), 'sticky' => $topic->sticky(), 'approved' => $topic->approved()));
if ($forum->isAllowed($xoopsUser ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS, 'reply')) {
    if ($topic->status()) {
        $canreply = $xoopsUser ? $forum->isModerator($xoopsUser->uid()) || $xoopsUser->isAdmin() : 0;
    } else {
        $canreply = true;
    }
    if ($forum->isAllowed($xoopsUser ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS, 'topic')) {
        $tpl->assign('lang_newtopic', __('New Topic', 'bxpress'));
        $tpl->assign('can_topic', 1);
    }
    $tpl->assign('can_reply', $canreply);
    $tpl->assign('lang_reply', __('Reply', 'bxpress'));
    $tpl->assign('lang_approved', __('Approved', 'bxpress'));
    $tpl->assign('lang_noapproved', __('Not approved', 'bxpress'));
コード例 #2
0
ファイル: delete.php プロジェクト: petitours/bxpress
    die;
}
$post = new bXPost($id);
if ($post->isNew()) {
    redirect_header('./', 2, __('Specified post does not exists!', 'bxpress'));
    die;
}
$topic = new bXTopic($post->topic());
$forum = new bXForum($post->forum());
// Verificamos que el usuario tenga permiso
if (!$xoopsUser || !$forum->isAllowed($xoopsUser->getGroups(), 'delete')) {
    redirect_header('topic.php?pid=' . $id . '#p' . $id, 2, __('Sorry, you don\'t have permission to do this action!', 'bxpress'));
    die;
}
// Verificamos si el usuario tiene permiso de eliminación para el post
if ($xoopsUser->uid() != $post->user() && (!$xoopsUser->isAdmin() && !$forum->isModerator($xoopsUser->uid()))) {
    redirect_header('topic.php?pid=' . $id . '#p' . $id, 2, __('Sorry, you don\'t have permission to do this action!', 'bxpress'));
    die;
}
if ($ok) {
    if (!$xoopsSecurity->check()) {
        redirect_header('topic.php?pid=' . $id . '#p' . $id, 2, __('Session token expired!', 'bxpress'));
        die;
    }
    if ($post->id() == bXFunctions::getFirstId($topic->id())) {
        $ret = $topic->delete();
        $wtopic = true;
    } else {
        $ret = $post->delete();
        $wtopic = false;
    }
コード例 #3
0
ファイル: forum.php プロジェクト: petitours/bxpress
include 'header.php';
$myts =& MyTextSanitizer::getInstance();
$id = isset($_GET['id']) ? $myts->addSlashes($_GET['id']) : '';
if ($id == '') {
    redirect_header(BB_URL, 2, __('No forum ID has been specified', 'bxpress'));
    die;
}
$forum = new bXForum($id);
if ($forum->isNew()) {
    redirect_header(BB_URL, 2, __('Specified forum does not exists!', 'bxpress'));
    die;
}
/**
 * Check if module is inactive
 */
$isModerator = $xoopsUser && ($xoopsUser->isAdmin() || $forum->isModerator($xoopsUser->uid()));
if (!$forum->active && !$isModerator) {
    RMUris::redirect_with_message(__('This forum is closed and you don\'t have permissions to view it', 'bxpress'), BX_URL, RMMSG_WARN);
}
/**
* Comprobamos que el usuario actual tenga permisos
* de acceso al foro
*/
if (!$forum->isAllowed($xoopsUser ? $xoopsUser->getGroups() : array(0, XOOPS_GROUP_ANONYMOUS), BXPRESS_PERM_VIEW)) {
    RMUris::redirect_with_message(__('You are not allowed to view this forum!', 'bxpress'), BX_URL, RMMSG_WARN);
    die;
}
/**
* Cargamos los temas
*/
$tbl1 = $db->prefix("mod_bxpress_topics");
コード例 #4
0
ファイル: post.php プロジェクト: laiello/bitcero-modules
     redirect_header('./' . ($create ? 'forum.php?id=' . $forum->id() : 'topic.php?id=' . $topic->id()), 2, __('Session token expired!', 'bxpress'));
     die;
 }
 $myts =& MyTextSanitizer::getInstance();
 if ($create) {
     $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);
         }
     }
コード例 #5
0
ファイル: edit.php プロジェクト: laiello/bitcero-modules
    die;
}
$post = new bXPost($id);
if ($post->isNew()) {
    redirect_header('./', 2, __('Specified post does not exists!', 'bxpress'));
    die;
}
$topic = new bXTopic($post->topic());
$forum = new bXForum($topic->forum());
// Verificamos si el usuario tiene permisos de edición en el foro
if (!$xoopsUser || !$forum->isAllowed($xoopsUser->getGroups(), 'edit')) {
    redirect_header('topic.php?pid=' . $id . '#p' . $id, 2, __('You don\'t have permission to edit this post!', 'bxpress'));
    die;
}
// Verificamos si el usuario tiene permiso de edición para el post
if ($xoopsUser->uid() != $post->user() && (!$xoopsUser->isAdmin() && !$forum->isModerator($xoopsUser->uid()))) {
    redirect_header('topic.php?pid=' . $id . '#p' . $id, 2, __('You don\'t have permission to edit this post!', 'bxpress'));
    die;
}
switch ($op) {
    case 'post':
        foreach ($_POST as $k => $v) {
            ${$k} = $v;
        }
        if (!$xoopsSecurity->check()) {
            redirect_header('edit.php?id=' . $id, 2, __('Session token expired!', 'bxpress'));
            die;
        }
        $myts =& MyTextSanitizer::getInstance();
        if (bXFunctions::getFirstId($topic->id()) == $id) {
            $topic->setDate(time());
コード例 #6
0
ファイル: forum.php プロジェクト: laiello/bitcero-modules
        if ($xoopsUser) {
            $lastpost['new'] = $last->date() > $xoopsUser->getVar('last_login') && time() - $last->date() < $xoopsModuleConfig['time_new'];
        } else {
            $lastpost['new'] = time() - $last->date() <= $xoopsModuleConfig['time_new'];
        }
    }
    $tpages = ceil($topic->replies() / $xoopsModuleConfig['perpage']);
    if ($tpages > 1) {
        $pages = bXFunctions::paginateIndex($tpages);
    } else {
        $pages = null;
    }
    $tpl->append('topics', array('id' => $topic->id(), 'title' => $topic->title(), 'replies' => $topic->replies(), 'views' => $topic->views(), 'by' => sprintf(__('By: %s', 'bxpress'), $topic->posterName()), 'last' => $lastpost, 'popular' => $topic->replies() >= $forum->hotThreshold(), 'sticky' => $topic->sticky(), 'pages' => $pages, 'tpages' => $tpages, 'closed' => $topic->status()));
}
// Datos del Foro
$tpl->assign('forum', array('id' => $forum->id(), 'title' => $forum->name(), 'moderator' => $xoopsUser ? $forum->isModerator($xoopsUser->uid()) || $xoopsUser->isAdmin() : false));
$tpl->assign('lang_pages', __('Pages:', 'bxpress'));
$tpl->assign('lang_topic', __('Topics', 'bxpress'));
$tpl->assign('lang_replies', __('Replies', 'bxpress'));
$tpl->assign('lang_views', __('Views', 'bxpress'));
$tpl->assign('lang_lastpost', __('Last Post', 'bxpress'));
$tpl->assign('lang_nonew', __('No new posts', 'bxpress'));
$tpl->assign('lang_withnew', __('New posts', 'bxpress'));
$tpl->assign('lang_hotnonew', __('No hot topics', 'bxpress'));
$tpl->assign('lang_hotnew', __('New hot topics', 'bxpress'));
$tpl->assign('lang_sticky', __('Sticky', 'bxpress'));
$tpl->assign('lang_closed', __('Closed Topic', 'bxpress'));
if ($forum->isAllowed($xoopsUser ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS, 'topic')) {
    $tpl->assign('lang_newtopic', __('New Topic'));
    $tpl->assign('can_topic', 1);
}
コード例 #7
0
ファイル: moderate.php プロジェクト: laiello/bitcero-modules
/**
* @desc Aprueba o no un mensaje editado
**/
function approvedPosts($app = 0)
{
    global $xoopsUser, $xoopsSecurity;
    $posts = isset($_REQUEST['posts']) ? intval($_REQUEST['posts']) : 0;
    //Verifica que el mensaje sea válido
    if ($posts <= 0) {
        redirect_header('./topic.php?id=' . $posts, 1, __('Topic not valid!', 'bxpress'));
        die;
    }
    //Comprueba que el mensaje exista
    $post = new bXPost($posts);
    if ($post->isNew()) {
        redirect_header('./topic.php?id=' . $posts, 1, __('Post doesn\'t exists!', 'bxpress'));
        die;
    }
    //Comprueba si usuario es moderador del foro
    $forum = new bXForum($post->forum());
    if (!$forum->isModerator($xoopsUser->uid()) || !$xoopsUser->isAdmin()) {
        redirect_header('./topic.php?id=' . $posts, 1, __('You don\'t have permission to do this action!', 'bxpress'));
        die;
    }
    if (!$xoopsSecurity->check()) {
        redirect_header('./topic.php?id=' . $posts, 2, __('Session token expired!', 'bxpress'));
        die;
    }
    $post->setApproved($app);
    if ($post->editText()) {
        $post->setText($post->editText());
    }
    $post->setEditText('');
    $post->save();
    redirect_header('./topic.php?id=' . $post->topic(), 1, __('Operation completed!', 'bxpress'));
}