コード例 #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
ファイル: 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'));
コード例 #4
0
ファイル: rss.php プロジェクト: petitours/bxpress
        $rss_channel['title'] = $xoopsModule->name();
        $rss_channel['link'] = XOOPS_URL . ($config->urlmode ? $config->htbase : '/modules/bxpress');
        $rss_channel['description'] = __('All recent messages posted on forum', 'bxpress');
        $rss_channel['lastbuild'] = formatTimestamp(time(), 'rss');
        $rss_channel['webmaster'] = checkEmail($xoopsConfig['adminmail'], true);
        $rss_channel['editor'] = checkEmail($xoopsConfig['adminmail'], true);
        $rss_channel['category'] = 'Forum';
        $rss_channel['generator'] = 'Common Utilities';
        $rss_channel['language'] = RMCLANG;
        $sql = "SELECT * FROM {$tbl1} WHERE approved=1 ORDER BY post_time DESC LIMIT 0,50";
        $result = $db->queryF($sql);
        $topics = array();
        $block = array();
        $post = new bXPost();
        $forum = new bXForum();
        $tf = new RMTimeFormatter(0, '%T%-%d%-%Y% at %h%:%i%');
        while ($row = $db->fetchArray($result)) {
            $post = new bXPost();
            $post->assignVars($row);
            $topic = new bXTopic($post->topic());
            $forum = new bXForum($post->forum());
            $item = array();
            $item['title'] = sprintf(__('Posted on: %s :: %s'), $topic->title(), $forum->name());
            $item['link'] = $post->permalink();
            $item['description'] = XoopsLocal::convert_encoding(htmlspecialchars($post->text(), ENT_QUOTES));
            $item['pubdate'] = formatTimestamp($post->date(), 'rss');
            $item['guid'] = $post->permalink();
            $rss_items[] = $item;
        }
        break;
}
コード例 #5
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;
    }
コード例 #6
0
ファイル: search.php プロジェクト: petitours/bxpress
            $sql1 .= " (a.title LIKE '%{$search}%' OR b.post_text LIKE '%{$search}%') ";
        }
    }
    $sql2 .= ($sql1 ? " AND " : '') . " c.approved=1 AND a.id_topic=c.id_topic AND b.post_id=c.id_post AND d.id_forum=c.id_forum ";
    $sql2 .= $themes ? $themes == 1 ? " AND a.date>" . (time() - $xoopsModuleConfig['time_topics'] * 3600) : ($themes == 2 ? " AND a.replies=0" : '') : '';
    $sql2 .= "  ORDER BY a.sticky DESC, a.date DESC LIMIT {$start},{$limit}";
}
$result = $db->queryF($sql . $sql1 . $sql2);
while ($rows = $db->fetchArray($result)) {
    $date = bXFunctions::formatDate($rows['date']);
    $lastpost = array();
    $firstpost = array();
    if (!$search && $themes == 0) {
        $firstpost = bXFunctions::getFirstId($rows['id_topic']);
        $last = new bXPost($rows['last_post']);
        $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'];
        }
    }
    $tpl->append('posts', array('id' => $rows['id_topic'], 'title' => $rows['title'], 'sticky' => $rows['sticky'], 'user' => $rows['poster_name'], 'replies' => $rows['replies'], 'views' => $rows['views'], 'closed' => $rows['status'], 'date' => $date, 'by' => sprintf(__('By: %s', 'bxpress'), $rows['poster_name']), 'forum' => $rows['name'], 'id_post' => $rows['id_post'], 'post_text' => TextCleaner::getInstance()->truncate($rows['post_text'], 100), 'last' => $lastpost, 'firstpost' => $firstpost));
}
$tpl->assign('lang_search', __('Search:', 'bxpress'));
$tpl->assign('lang_recenttopics', __('Recent topics', 'bxpress'));
$tpl->assign('lang_alltopics', __('All topics', 'bxpress'));
$tpl->assign('lang_anunswered', __('Unanswered topics', 'bxpress'));
$tpl->assign('themes', $themes);
コード例 #7
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;
}
コード例 #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
ファイル: 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");