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; }
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; }
} } else { include 'header.php'; //include '../../header.php'; $myts =& MyTextSanitizer::getInstance(); $hiddens['ok'] = 1; $hiddens['id'] = $id; $buttons['sbt']['value'] = __('Delete', 'bxpress'); $buttons['sbt']['type'] = 'submit'; $buttons['cancel']['value'] = __('Cancel', 'bxpress'); $buttons['cancel']['type'] = 'button'; $buttons['cancel']['extra'] = 'onclick="window.location=\'topic.php?pid=' . $id . '#p' . $id . '\';"'; $text = __('Dou you really wish to delete specified post?', 'bxpress'); if ($id == bXFunctions::getFirstId($topic->id())) { $text .= "<br /><br /><span class='bbwarning'>" . __('<strong>Warning:</strong> This is the first post in the topic. By deleting this all posts will be deleted also.', 'bxpress') . "</span>"; } $text .= "<br /><br /><strong>" . $post->uname() . ":</strong><br />"; $text .= substr($post->getVar('post_text', 'e'), 0, 100) . '...'; $form = new RMForm(__('Delete post?', 'bxpress'), 'frmDelete', 'delete.php'); $form->addElement(new RMFormHidden('ok', 1)); $form->addElement(new RMFormHidden('id', $id)); $form->addElement(new RMFormLabel('', $text)); $but = new RMFormButtonGroup(); $but->addButton('sbt', __('Delete!', 'bxpress'), 'submit'); $but->addButton('cancel', __('Cancel', 'bxpress'), 'button', 'onclick="history.go(-1);"'); $form->addElement($but); echo $form->render(); $tpl->assign('xoops_pagetitle', __('Delete Post?', 'bxpress') . ' » ' . $xoopsModuleConfig['forum_title']); include 'footer.php'; //include '../../footer.php'; }
$userData['uname'] = $bbUser->uname(); $userData['name'] = $bbUser->getVar('name') != '' ? $bbUser->getVar('name') : $bbUser->uname(); //$userData['rank'] = $ranks[$bbUser->getVar('rank')]['title']; //$userData['rank_image'] = $ranks[$bbUser->getVar('rank')]['image']; $userData['registered'] = sprintf(__('Registered: %s', 'bxpress'), date($mc['dates'], $bbUser->getVar('user_regdate'))); $userData['avatar'] = RMEvents::get()->run_event("rmcommon.get.avatar", $bbUser->getVar('email'), 0); $userData['posts'] = sprintf(__('Posts: %u', 'bxpress'), $bbUser->getVar('posts')); if ($xoopsUser && ($moderator || $admin)) { $userData['ip'] = sprintf(__('IP: %s', 'bxpress'), $post->ip()); } $userData['online'] = $bbUser->isOnline(); $userData['type'] = $bbUser->isAdmin() ? 'admin' : ($forum->isModerator($bbUser->uid()) ? 'moderator' : 'user'); } else { $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; $userData['type'] = 'anon'; } // 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()); } $tf = new RMTimeFormatter(0, __('%T% %d%, %Y%', 'bxpress')); // Likes parsing
} } $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); $tpl->assign('search', $search);
$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; }
// Sticky if ($xoopsUser && $xoopsModuleConfig['sticky']) { $sticky = $xoopsUser->isAdmin() || $forum->isModerator($xoopsUser->uid()) || $xoopsUser->posts() > $xoopsModuleConfig['sticky_posts'] && $topic->poster() == $xoopsUser->uid(); if ($sticky) { $form->addElement(new RMFormYesNo(__('Sticky Topic', 'bxpress'), 'sticky', $topic->sticky())); } } } // 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())));
/** * @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() . '&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'; }