コード例 #1
0
ファイル: index.php プロジェクト: petitours/bxpress
function forums_data($data)
{
    global $xoopsUser;
    if (empty($data)) {
        return;
    }
    $forums = array();
    foreach ($data as $forum) {
        $isModerator = $xoopsUser && ($xoopsUser->isAdmin() || $forum->isModerator($xoopsUser->uid()));
        if (!$forum->active && !$isModerator) {
            continue;
        }
        $last = new bXPost($forum->lastPostId());
        $lastpost = array();
        if (!$last->isNew()) {
            if (!isset($posters[$last->uid])) {
                $posters[$last->uid] = new RMUser($last->uid);
            }
            $user = $posters[$last->uid];
            $lastpost['date'] = bXFunctions::formatDate($last->date());
            $lastpost['by'] = sprintf(__('by %s', 'bxpress'), $last->uname());
            $lastpost['id'] = $last->id();
            $lastpost['topic'] = $last->topic();
            $lastpost['user'] = array('uname' => $user->uname, 'name' => $user->name != '' ? $user->name : $user->uname, 'avatar' => $user ? RMEvents::get()->run_event('rmcommon.get.avatar', $user->getVar('email'), 50) : '');
            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'];
            }
        }
        $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;
}
コード例 #2
0
ファイル: delete.php プロジェクト: petitours/bxpress
// bXpress Forums
// An simple forums module for XOOPS and Common Utilities
// Author: Eduardo Cortés <*****@*****.**>
// Email: i.bitcero@gmail.com
// License: GPL 2.0
// --------------------------------------------------------------
include '../../mainfile.php';
$ok = isset($_POST['ok']) ? $_POST['ok'] : 0;
// Id del Post
$id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
if ($id <= 0) {
    redirect_header('./', 2, __('Please specify a post id to delete!', '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;
}
コード例 #3
0
ファイル: forum.php プロジェクト: petitours/bxpress
 */
$posters = array();
while ($row = $db->fetchArray($result)) {
    $topic = new bXTopic();
    $topic->assignVars($row);
    $last = new bXPost($topic->lastPost());
    if (!isset($posters[$topic->poster])) {
        $posters[$topic->poster] = new RMUser($topic->poster);
    }
    if (!isset($posters[$last->uid])) {
        $posters[$last->uid] = new RMUser($last->uid);
    }
    $poster = $posters[$topic->poster];
    $last_poster = $posters[$last->uid];
    $lastpost = array();
    if (!$last->isNew()) {
        $lastpost['date'] = formatTimeStamp($last->date(), __('M d, Y'));
        $lastpost['time'] = $last->date();
        $lastpost['id'] = $last->id();
        $lastpost['poster'] = array('uid' => $last->uid, 'uname' => $last->poster_name, 'name' => $last_poster->name != '' ? $last_poster->name : $last_poster->uname, 'email' => $last_poster->email, 'avatar' => RMEvents::get()->run_event('rmcommon.get.avatar', $last_poster->getVar('email'), 50), 'link' => XOOPS_URL . '/userinfo.php?uid=' . $last_poster->uid);
        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;
コード例 #4
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'));
}
コード例 #5
0
ファイル: post.php プロジェクト: petitours/bxpress
    $forum = new bXForum($topic->forum());
    $retlink = './topic.php?id=' . $topic->id();
    $create = false;
}
if ($forum->isNew()) {
    redirect_header('./', 2, __('Specified forum does not exists!', 'bxpress'));
    die;
}
if (!$forum->isAllowed($xoopsUser ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS, $fid > 0 ? 'topic' : 'reply')) {
    redirect_header($retlink, 2, __('You do not have permission to do this!', 'bxpress'));
    die;
}
// Load specified post
if ($pid > 0) {
    $parent = new bXPost($pid);
    if ($parent->isNew()) {
        $pid = 0;
    }
}
switch ($op) {
    case 'post':
        foreach ($_POST as $k => $v) {
            ${$k} = $v;
        }
        if (!$xoopsSecurity->check()) {
            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();