예제 #1
0
function bxpress_block_topics_show($options)
{
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $mc = RMSettings::module_settings('bxpress');
    $tbl1 = $db->prefix('mod_bxpress_posts');
    $tbl2 = $db->prefix('mod_bxpress_topics');
    $tbl3 = $db->prefix('mod_bxpress_likes');
    $tbl4 = $db->prefix('mod_bxpress_forums');
    // Calculate period of time
    if (0 < $options['days']) {
        $period = time() - $options['days'] * 86400;
    }
    $order = 'DESC' == $options['order'] ? 'DESC' : 'ASC';
    $sql = "SELECT topics.*, forums.name,\n                (SELECT SUM(likes) FROM {$tbl1} WHERE id_topic=topics.id_topic) as likes,\n                (SELECT post_time FROm {$tbl1} WHERE id_topic=topics.id_topic ORDER BY post_time DESC LIMIT 0, 1) as updated\n                FROM {$tbl2} as topics, {$tbl4} as forums WHERE ";
    if (0 < $options['days']) {
        $sql .= " topics.date > {$period} AND ";
    }
    $sql .= "forums.id_forum=topics.id_forum";
    if ('recent' == $options['type']) {
        $sql .= " ORDER BY topics.id_topic {$order} LIMIT 0, {$options['limit']}";
    } elseif ('hot' == $options['type']) {
        $sql .= " ORDER BY topics.replies {$order} LIMIT 0, {$options['limit']}";
    } elseif ('hits' == $options['type']) {
        $sql .= " ORDER BY topics.views {$order} LIMIT 0, {$options['limit']}";
    }
    $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';
    $topic = new bXTopic();
    $forum = new bXForum();
    $tf = new RMTimeFormatter(0, '%T% %d%, %Y%');
    while ($row = $db->fetchArray($result)) {
        $topic->assignVars($row);
        $forum->assignVars(array('id_forum' => $topic->forum()));
        $ret = array('id' => $topic->id(), 'title' => $topic->title, 'link' => $topic->permalink(), 'likes' => $topic->likes, 'replies' => $topic->replies, 'hits' => $topic->views, 'forum' => array('name' => $row['name'], 'id' => $row['id_forum'], 'link' => $forum->permalink()), 'time' => $topic->date, 'date' => $tf->ago($topic->date), 'likes' => $row['likes'], 'updated' => 'full' == $options['format'] ? sprintf(__('Updated on %s', 'bxpress'), $tf->format($row['updated'])) : $tf->ago($row['updated']));
        $topics[] = $ret;
    }
    $block['topics'] = $topics;
    $block['format'] = $options['format'];
    // Add css styles
    RMTemplate::get()->add_style('bxpress-blocks.min.css', 'bxpress');
    return $block;
}
예제 #2
0
 /**
  * @desc Elimina un foro junto con sus temas y mensajes
  */
 public function delete()
 {
     $sql = "SELECT * FROM " . $this->db->prefix("mod_bxpress_topics") . " WHERE id_forum='" . $this->id() . "'";
     $result = $this->db->query($sql);
     while ($row = $this->db->fetchArray($result)) {
         $topic = new bXTopic();
         $topic->assignVars($row);
         $topic->delete();
     }
     return $this->deleteFromTable();
 }
예제 #3
0
파일: forum.php 프로젝트: petitours/bxpress
    $nav = new RMPageNav($num, $limit, $pactual);
    $nav->target_url($forum->permalink() . '&amp;pag={PAGE_NUM}');
    $tpl->assign('itemsNavPage', $nav->render(false));
}
$sql = str_replace("COUNT(*)", '*', $sql);
$sql .= " ORDER BY sticky DESC,";
$sql .= $xoopsModuleConfig['order_post'] ? " last_post " : " date ";
$sql .= " DESC LIMIT {$start},{$limit}";
$result = $db->query($sql);
/**
 * Posters cache
 */
$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);
예제 #4
0
/**
* @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';
}