コード例 #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
function bxpress_recents_show($options)
{
    $util = RMUtilities::get();
    $tc = TextCleaner::getInstance();
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $xoopsModuleConfig = $util->module_config('exmbb');
    $mc = RMUtilities::module_config('bxpress');
    $tbl1 = $db->prefix('bxpress_posts');
    $tbl2 = $db->prefix('bxpress_topics');
    $tbl3 = $db->prefix('bxpress_posts_text');
    $tbl4 = $db->prefix('bxpress_forums');
    $sql = "SELECT MAX(id_post) AS id FROM {$tbl1} WHERE approved=1 GROUP BY id_topic ORDER BY MAX(id_post) DESC LIMIT 0,{$options['0']}";
    $result = $db->queryF($sql);
    $topics = array();
    $block = array();
    include_once XOOPS_ROOT_PATH . '/modules/bxpress/class/bxforum.class.php';
    include_once XOOPS_ROOT_PATH . '/modules/bxpress/class/bxpost.class.php';
    include_once XOOPS_ROOT_PATH . '/modules/bxpress/class/bxtopic.class.php';
    include_once XOOPS_ROOT_PATH . '/modules/bxpress/class/bxfunctions.class.php';
    $post = new bXPost();
    $forum = new bXForum();
    $tf = new RMTimeFormatter(0, '%T%-%d%-%Y% at %h%:%i%');
    while ($row = $db->fetchArray($result)) {
        $post = new bXPost($row['id']);
        $topic = new bXTopic($post->topic());
        $forum = new bXForum($post->forum());
        $ret = array();
        $ret['id'] = $topic->id();
        $ret['post'] = $post->id();
        $ret['link'] = $post->permalink();
        if ($options[2]) {
            $ret['date'] = $tf->format($post->date());
        }
        if ($options[3]) {
            $ret['poster'] = sprintf(__('Posted by: %s', 'bxpress'), "<a href='" . $post->permalink() . "'>" . $post->uname() . "</a>");
        }
        $ret['title'] = $topic->title();
        if ($options[4]) {
            $ret['text'] = $tc->clean_disabled_tags($post->text());
        }
        $ret['forum'] = array('id' => $forum->id(), 'name' => $forum->name(), 'link' => $forum->permalink());
        $topics[] = $ret;
    }
    // Opciones
    $block['showdates'] = $options[2];
    $block['showuname'] = $options[3];
    $block['showtext'] = $options[4];
    $block['topics'] = $topics;
    $block['lang_topic'] = __('Topic', 'bxpress');
    $block['lang_date'] = __('Date', 'bxpress');
    $block['lang_poster'] = __('Poster', 'bxpress');
    return $block;
}
コード例 #3
0
ファイル: delete.php プロジェクト: petitours/bxpress
// 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;
    }
    if ($ret) {
        redirect_header($wtopic ? 'forum.php?id=' . $forum->id() : 'topic.php?id=' . $topic->id(), 1, $wtopic ? __('Topic deleted successfully!', 'bxpress') : __('Post deleted successfully!', 'bxpress'));
    } else {
        redirect_header('topic.php?pid=' . $id, 1, ($wtopic ? __('The topic could not be deleted!', 'bxpress') : __('The post could not be deleted!', 'bxpress')) . '<br />' . ($wtopic ? $topic->errors() : $post->errors()));
    }
} else {
    include 'header.php';
    //include '../../header.php';
    $myts =& MyTextSanitizer::getInstance();
コード例 #4
0
ファイル: topic.php プロジェクト: petitours/bxpress
    $tf = new RMTimeFormatter(0, __('%T% %d%, %Y%', 'bxpress'));
    // Likes parsing
    if (!is_null($row['liked'])) {
        $likes_ids = explode(",", $row['liked'], 3);
    } else {
        $likes_ids = array();
    }
    $likes = array();
    foreach ($likes_ids as $like) {
        if (!isset($users[$like])) {
            $users[$like] = new XoopsUser($like);
        }
        $like_user = $users[$like];
        $likes[] = array('uid' => $like, 'uname' => $like_user->getVar('uname'), 'name' => $like_user->getVar('name') != '' ? $like_user->getVar('name') : $like_user->getVar('uname'), 'avatar' => RMEvents::get()->run_event("rmcommon.get.avatar", $like_user->getVar('email'), 40));
    }
    $posts[$post->id()] = array('id' => $post->id(), 'text' => $post->text(), 'edit' => $post->editText(), 'approved' => $post->approved(), 'date' => $tf->ago($post->date()), 'canedit' => $canedit, 'candelete' => $candelete, 'canshow' => $canshow, 'canreport' => $report, 'poster' => $userData, 'attachs' => $attachs, 'attachscount' => count($attachs), 'parent' => $post->parent, 'replies' => $row['replies'], 'likes_count' => $row['likes'], 'likes' => $likes);
    $posts_ids[] = $post->id();
}
$tpl->assign('posts', $posts);
unset($userData, $bbUser, $users);
// Common Utilities Notifications
$notifications = RMNotifications::get();
$events = Bxpress_Notifications::get();
$permissions = $forum->permissions();
// New topics notifications
$event = $events->event('reply')->parameters($topic->id())->permissions(array('groups' => in_array(0, $permissions['view']) ? array() : $permissions['view']));
$notifications->add_item($event);
unset($event, $permissions);
$tpl->assign('notifications', $notifications->render());
$tpl->assign('lang_edit', __('Edit', 'bxpress'));
$tpl->assign('lang_delete', __('Delete', 'bxpress'));
コード例 #5
0
ファイル: forum.php プロジェクト: petitours/bxpress
    $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;
    }
    $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(), 'poster' => array('uid' => $topic->poster, 'uname' => $poster->uname, 'name' => $poster->name, 'email' => $poster->email, 'avatar' => RMEvents::get()->run_event('rmcommon.get.avatar', $poster->getVar('email'), 100), 'type' => $poster->isAdmin() ? 'admin' : ($forum->isModerator($topic->poster) ? 'moderator' : 'user'))));
}
コード例 #6
0
ファイル: post.php プロジェクト: laiello/bitcero-modules
        $form->addElement(new RMFormEditor(__('Post', 'bxpress'), 'msg', 'auto', '400px', isset($quote) ? $quote : ''), true);
        // Adjuntar Archivos
        if ($forum->attachments() && $forum->isAllowed($xoopsUser ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS, 'attach')) {
            $ele = new RMFormFile(__('Attach file', 'bxpress'), 'attach', 45, $xoopsModuleConfig['maxfilesize'] * 1024);
            $ele->setDescription(sprintf(__('Allowed file types: %s', 'bxpress'), implode(',', $forum->extensions())));
            $form->addElement($ele);
            $form->setExtra('enctype="multipart/form-data"');
        }
        $form->addElement(new RMFormHidden('op', 'post'));
        $form->addElement(new RMFormHidden($fid > 0 ? 'fid' : 'tid', $fid > 0 ? $fid : $tid));
        $ele = new RMFormButtonGroup();
        $ele->addButton('sbt', __('Send', 'bxpress'), 'submit');
        $ele->addButton('cancel', __('Cancel', 'bxpress'), 'button', 'onclick="history.go(-1)";');
        $form->addElement($ele);
        $tpl->assign('topic_form', $form->render());
        /**
         * @desc Cargamos los mensajes realizados en este tema
         */
        if ($mc['numpost'] > 0 && !$create) {
            $sql = "SELECT * FROM " . $db->prefix("bxpress_posts") . " WHERE id_topic='" . $topic->id() . "' ORDER BY post_time DESC LIMIT 0, {$mc['numpost']}";
            $result = $db->query($sql);
            while ($row = $db->fetchArray($result)) {
                $post = new bXPost();
                $post->assignVars($row);
                $tpl->append('posts', array('id' => $post->id(), 'text' => $post->text(), 'time' => date($xoopsConfig['datestring'], $post->date()), 'uname' => $post->uname()));
            }
        }
        $tpl->assign('lang_topicreview', __('Topic review (newest first)', 'bxpress'));
        include 'footer.php';
        break;
}
コード例 #7
0
ファイル: edit.php プロジェクト: laiello/bitcero-modules
 }
 // Si se especifico una acotación entonces la cargamos
 $idq = isset($_GET['quote']) ? intval($_GET['quote']) : 0;
 if ($idq > 0) {
     $post = new bXPost($idq);
     if ($post->isNew()) {
         break;
     }
     $quote = "[quote=" . $post->uname() . "]" . $post->getVar('post_text', 'e') . "[/quote]\n\n";
 }
 $form->addElement(new RMFormEditor(__('Post', 'bxpress'), 'msg', '90%', '300px', $rmc_config['editor_type'] == 'tiny' ? $post->getVar('post_text') : $post->getVar('post_text', 'e')), true);
 $form->addElement(new RMFormHidden('op', 'post'));
 $form->addElement(new RMFormHidden('id', $id));
 $ele = new RMFormButtonGroup();
 $ele->addButton('sbt', __('Save Changes', 'bxpress'), 'submit');
 $ele->addButton('cancel', _CANCEL, 'button', 'onclick="window.location = \'topic.php?pid=' . $post->id() . '#p' . $post->id() . '\'";');
 $form->addElement($ele);
 // Adjuntar Archivos
 if ($forum->attachments() && $forum->isAllowed($xoopsUser ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS, 'attach')) {
     $forma = new RMForm('<a name="attachments"></a>' . __('Attached Files', 'bxpress'), 'frmAttach', 'edit.php');
     $forma->addElement(new RMFormSubTitle(sprintf(__('You can upload new files to this post. You have a limit of <strong>%s</strong> attachment per post.', 'bxpress'), $xoopsModuleConfig['attachlimit']), 1, 'even'));
     if ($post->totalAttachments() < $xoopsModuleConfig['attachlimit']) {
         $ele = new RMFormFile(__('Attach File:', 'bxpress'), 'attach', 45, $xoopsModuleConfig['maxfilesize'] * 1024);
         $ele->setDescription(sprintf(__('Allowed File Types: %s', 'bxpress'), implode(',', $forum->extensions())));
         $forma->addElement($ele, true);
         $forma->setExtra('enctype="multipart/form-data"');
     }
     // Lista de Archivos Adjuntos
     $list = new RMFormCheck(__('Cuerrent Attachments', 'bxpress'));
     $list->asTable(1);
     foreach ($post->attachments() as $file) {
コード例 #8
0
ファイル: moderate.php プロジェクト: laiello/bitcero-modules
/**
* @desc Muestra todas las opciones configurables
*/
function showItemsAndOptions()
{
    global $xoopsUser, $db, $xoopsOption, $tpl, $xoopsModule, $xoopsConfig, $xoopsSecurity;
    global $xoopsModuleConfig, $forum;
    $xoopsOption['template_main'] = "bxpress_moderate.html";
    $xoopsOption['module_subpage'] = "moderate";
    include 'header.php';
    /**
     * Cargamos los temas
     */
    $tbl1 = $db->prefix("bxpress_topics");
    $tbl2 = $db->prefix("bxpress_forumtopics");
    $sql = "SELECT COUNT(*) FROM {$tbl1} WHERE id_forum='" . $forum->id() . "' ";
    list($num) = $db->fetchRow($db->queryF($sql));
    $page = isset($_REQUEST['pag']) ? $_REQUEST['pag'] : '';
    $limit = $xoopsModuleConfig['topicperpage'] > 0 ? $xoopsModuleConfig['topicperpage'] : 15;
    if ($page > 0) {
        $page -= 1;
    }
    $start = $page * $limit;
    $tpages = (int) ($num / $limit);
    if ($num % $limit > 0) {
        $tpages++;
    }
    $pactual = $page + 1;
    if ($pactual > $tpages) {
        $rest = $pactual - $tpages;
        $pactual = $pactual - $rest + 1;
        $start = ($pactual - 1) * $limit;
    }
    if ($tpages > 0) {
        $nav = new RMPageNav($num, $limit, $pactual);
        $nav->target_url('moderate.php?id=' . $forum->id() . '&amp;pag={PAGE_NUM}');
        $tpl->assign('itemsNavPage', $nav->render(false));
    }
    $sql = str_replace("COUNT(*)", '*', $sql);
    $sql .= " ORDER BY sticky DESC, date DESC LIMIT {$start},{$limit}";
    $result = $db->query($sql);
    while ($row = $db->fetchArray($result)) {
        $topic = new bXTopic();
        $topic->assignVars($row);
        $last = new bXPost($topic->lastPost());
        $lastpost = array();
        if (!$last->isNew()) {
            $lastpost['date'] = bXFunctions::formatDate($last->date());
            $lastpost['by'] = sprintf(__('By: %s', 'bxpress'), $last->uname());
            $lastpost['id'] = $last->id();
            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, 'approved' => $topic->approved(), 'closed' => $topic->status()));
    }
    $tpl->assign('forum', array('id' => $forum->id(), 'title' => $forum->name()));
    $tpl->assign('lang_topic', __('Topic', 'bxpress'));
    $tpl->assign('lang_replies', __('Replies', 'bxpress'));
    $tpl->assign('lang_views', __('Views', 'bxpress'));
    $tpl->assign('lang_lastpost', __('Last Post', 'bxpress'));
    $tpl->assign('lang_sticky', __('Sticky', 'bxpress'));
    $tpl->assign('lang_moderating', __('Moderating Forum', 'bxpress'));
    $tpl->assign('lang_pages', __('Pages', 'bxpress'));
    $tpl->assign('lang_move', __('Move', 'bxpress'));
    $tpl->assign('lang_open', __('Unlock', 'bxpress'));
    $tpl->assign('lang_close', __('Lock', 'bxpress'));
    $tpl->assign('lang_dosticky', __('Sticky', 'bxpress'));
    $tpl->assign('lang_dounsticky', __('Unsticky', 'bxpress'));
    $tpl->assign('lang_approved', __('Approved', 'bxpress'));
    $tpl->assign('lang_app', __('Approve', 'bxpress'));
    $tpl->assign('lang_noapp', __('Unapprove', 'bxpress'));
    $tpl->assign('lang_delete', __('Delete', 'bxpress'));
    $tpl->assign('lang_confirm', __('Do you really want to delete selected topics?', 'bxpress'));
    $tpl->assign('token_input', $xoopsSecurity->getTokenHTML());
    bXFunctions::makeHeader();
    RMTemplate::get()->add_xoops_style('style.css', 'bxpress');
    include 'footer.php';
}
コード例 #9
0
ファイル: likes.php プロジェクト: petitours/bxpress
}
if (!$xoopsUser) {
    exit;
}
/*
 * Get parameters
 */
$id = RMHttpRequest::post('id', 'integer', 0);
if (!$xoopsSecurity->check(true, false, 'BXTOKEN')) {
    response_json(1, __('Please refresh the page in order to register your likes.', 'bxpress'), array(), false);
}
$post = new bXPost($id);
if ($post->isNew()) {
    response_json(1, __('The specified post does not exists! Verify it!', 'bxpress'), array(), true);
}
$sql = "SELECT COUNT(*) FROM " . $xoopsDB->prefix("mod_bxpress_likes") . " WHERE uid=" . $xoopsUser->uid() . " AND post=" . $post->id();
list($exists) = $xoopsDB->fetchRow($xoopsDB->query($sql));
if ($exists > 0) {
    $action = 'unlike';
} else {
    $action = 'like';
}
if ('like' == $action) {
    // Add to likes table
    $sql = "INSERT INTO " . $xoopsDB->prefix("mod_bxpress_likes") . " (post,uid,time) VALUES (" . $post->id() . "," . $xoopsUser->uid() . "," . time() . ")";
    if (!$xoopsDB->queryF($sql)) {
        response_json(1, __('We could not register your like for this post. Please try again.', 'bxpress'), array(), true);
    }
    $sql = "UPDATE " . $xoopsDB->prefix("mod_bxpress_posts") . " SET likes=likes+1 WHERE id_post = " . $post->id();
    $xoopsDB->queryF($sql);
    $data = array('likes' => $post->likes + 1, 'uname' => $xoopsUser->uname(), 'uid' => $xoopsUser->uid(), 'name' => $xoopsUser->getVar('name') != '' ? $xoopsUser->getVar('name') : $xoopsUser->getVar('uname'), 'avatar' => RMEvents::get()->run_event("rmcommon.get.avatar", $xoopsUser->getVar('email'), 40), 'post' => $post->id(), 'action' => 'add');
コード例 #10
0
ファイル: topic.php プロジェクト: laiello/bitcero-modules
        $userData = array();
        $userData['id'] = 0;
        $userData['uname'] = $xoopsModuleConfig['anonymous_prefix'] . $post->uname();
        $userData['rank'] = $xoopsConfig['anonymous'];
        $userData['rank_image'] = '';
        $userData['registered'] = '';
        $userData['avatar'] = RMEvents::get()->run_event("rmcommon.get.avatar", '', 0);
        $userData['posts'] = sprintf(__('Posts: %u', 'bxpress'), 0);
        $userData['online'] = false;
    }
    // Adjuntos
    $attachs = array();
    foreach ($post->attachments() as $k) {
        $attachs[] = array('title' => $k->name(), 'downs' => $k->downloads(), 'id' => $k->id(), 'ext' => $k->extension(), 'size' => RMUtilities::formatBytesSize($k->size()), 'icon' => $k->getIcon());
    }
    $tpl->append('posts', array('id' => $post->id(), 'text' => $post->text(), 'edit' => $post->editText(), 'approved' => $post->approved(), 'date' => bXFunctions::formatDate($post->date()), 'canedit' => $canedit, 'candelete' => $candelete, 'canshow' => $canshow, 'canreport' => $report, 'poster' => $userData, 'attachs' => $attachs, 'attachscount' => count($attachs)));
}
unset($userData, $bbUser, $users);
$tpl->assign('lang_edit', __('Edit', 'bxpress'));
$tpl->assign('lang_delete', __('Delete', 'bxpress'));
$tpl->assign('lang_report', __('Report', 'bxpress'));
$tpl->assign('lang_quote', __('Quote', 'bxpress'));
$tpl->assign('lang_online', __('Online!', 'bxpress'));
$tpl->assign('lang_offline', __('Disconnected', 'bxpress'));
$tpl->assign('lang_attachments', __('Attachments', 'bxpress'));
$tpl->assign('xoops_pagetitle', $topic->title() . " &raquo; " . $xoopsModuleConfig['forum_title']);
$tpl->assign('token', $xoopsSecurity->createToken());
$tpl->assign('lang_edittext', __('Edit Text', 'bxpress'));
$tpl->assign('lang_goto', __('Change Forum:', 'bxpress'));
$tpl->assign('lang_go', __('Go!', 'bxpress'));
//$tpl->assign('url',XOOPS_URL."/modules/bxpress/report.php");