本文整理汇总了PHP中cache_forums函数的典型用法代码示例。如果您正苦于以下问题:PHP cache_forums函数的具体用法?PHP cache_forums怎么用?PHP cache_forums使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cache_forums函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetch_forum_announcements
function fetch_forum_announcements($pid = 0, $depth = 1)
{
global $mybb, $db, $lang, $announcements, $templates, $announcements_forum, $moderated_forums;
static $forums_by_parent, $forum_cache, $parent_forums;
if (!is_array($forum_cache)) {
$forum_cache = cache_forums();
}
if (!is_array($parent_forums) && $mybb->user['issupermod'] != 1) {
// Get a list of parentforums to show for normal moderators
$parent_forums = array();
foreach ($moderated_forums as $mfid) {
$parent_forums = array_merge($parent_forums, explode(',', $forum_cache[$mfid]['parentlist']));
}
}
if (!is_array($forums_by_parent)) {
foreach ($forum_cache as $forum) {
$forums_by_parent[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum;
}
}
if (!is_array($forums_by_parent[$pid])) {
return;
}
foreach ($forums_by_parent[$pid] as $children) {
foreach ($children as $forum) {
if ($forum['active'] == 0 || !is_moderator($forum['fid'])) {
// Check if this forum is a parent of a moderated forum
if (in_array($forum['fid'], $parent_forums)) {
// A child is moderated, so print out this forum's title. RECURSE!
$trow = alt_trow();
eval("\$announcements_forum .= \"" . $templates->get("modcp_announcements_forum_nomod") . "\";");
} else {
// No subforum is moderated by this mod, so safely continue
continue;
}
} else {
// This forum is moderated by the user, so print out the forum's title, and its announcements
$trow = alt_trow();
$padding = 40 * ($depth - 1);
eval("\$announcements_forum .= \"" . $templates->get("modcp_announcements_forum") . "\";");
if ($announcements[$forum['fid']]) {
foreach ($announcements[$forum['fid']] as $aid => $announcement) {
$trow = alt_trow();
if ($announcement['enddate'] < TIME_NOW && $announcement['enddate'] != 0) {
$icon = "<img src=\"images/minioff.gif\" alt=\"({$lang->expired})\" title=\"{$lang->expired_announcement}\" style=\"vertical-align: middle;\" /> ";
} else {
$icon = "<img src=\"images/minion.gif\" alt=\"({$lang->active})\" title=\"{$lang->active_announcement}\" style=\"vertical-align: middle;\" /> ";
}
$subject = htmlspecialchars_uni($announcement['subject']);
eval("\$announcements_forum .= \"" . $templates->get("modcp_announcements_announcement") . "\";");
}
}
}
// Build the list for any sub forums of this forum
if ($forums_by_parent[$forum['fid']]) {
fetch_forum_announcements($forum['fid'], $depth + 1);
}
}
}
}
示例2: checkForumPassword
/**
* Let's see if the correct password is given for a forum!
* Possible Todo: Pass passowrds in an array for defining passwords for parent categories (so far this only works when parent foums have same pass)
*
* @param integer $forum_id ID of Forum
* @param string $password Wow, what might this be??
* @return boolean
*/
function checkForumPassword($forum_id, $password = '', $pid = 0)
{
global $forum_cache;
if (!is_array($forum_cache)) {
$forum_cache = cache_forums();
if (!$forum_cache) {
return false;
}
}
// Loop through each of parent forums to ensure we have a password for them too
$parents = explode(',', $forum_cache[$fid]['parentlist']);
rsort($parents);
if (!empty($parents)) {
foreach ($parents as $parent_id) {
if ($parent_id == $forum_id || $parent_id == $pid) {
continue;
}
if ($forum_cache[$parent_id]['password'] != "") {
if (!$this->checkForumPassword($parent_id, $password)) {
return false;
}
}
}
}
$forum_password = $forum_cache[$forum_id]['password'];
// A password is required
if ($forum_password) {
if (empty($password)) {
if (!$this->mybb->cookies['forumpass'][$forum_id] || $this->mybb->cookies['forumpass'][$forum_id] && md5($this->mybb->user['uid'] . $forum_password) != $this->mybb->cookies['forumpass'][$forum_id]) {
return false;
} else {
return true;
}
} else {
if ($forum_password == $password) {
$this->setCookie('forumpass[' . $forum_id . ']', md5($this->mybb->user['uid'] . $password), NULL, true);
return true;
} else {
return false;
}
}
} else {
return true;
}
}
示例3: action
/**
This is where you perform the action when the API is called, the parameter given is an instance of stdClass, this method should return an instance of stdClass.
*/
public function action()
{
global $mybb, $db;
$api = APISystem::get_instance();
if (isset($api->paths[1]) && is_string($api->paths[1])) {
$forums = cache_forums();
switch (strtolower($api->paths[1])) {
case "list":
if (isset($api->paths[2]) && is_string($api->paths[2]) && isset($forums[$api->paths[2]])) {
return (object) $forums[$api->paths[2]];
} else {
return (object) $forums;
}
break;
case "threads":
if (isset($api->paths[2]) && is_string($api->paths[2]) && isset($forums[$api->paths[2]])) {
$threads = array();
$fid = $db->escape_string($api->paths[2]);
$query = $db->write_query("SELECT * FROM " . TABLE_PREFIX . "threads t WHERE t.`fid` = '{$fid}'");
while ($thread = $db->fetch_array($query)) {
$threads[$thread["tid"]] = $thread;
}
return (object) $threads;
} else {
// what forum?
}
break;
case "permissions":
if (isset($api->paths[2]) && is_string($api->paths[2]) && isset($forums[$api->paths[2]]) && $this->is_authenticated()) {
return (object) forum_permissions($api->paths[2], $this->get_user()->id, $this->get_user()->usergroup);
} else {
//what forum?
}
default:
break;
}
}
throw new BadRequestException("No valid option given in the URL.");
}
示例4: intval
$plugins->run_hooks("admin_tools_modlog_prune");
if ($mybb->request_method == 'post') {
$where = 'dateline < ' . (TIME_NOW - intval($mybb->input['older_than']) * 86400);
// Searching for entries by a particular user
if ($mybb->input['uid']) {
$where .= " AND uid='" . intval($mybb->input['uid']) . "'";
}
// Searching for entries in a specific module
if ($mybb->input['fid'] > 0) {
$where .= " AND fid='" . $db->escape_string($mybb->input['fid']) . "'";
}
$db->delete_query("moderatorlog", $where);
$num_deleted = $db->affected_rows();
$plugins->run_hooks("admin_tools_modlog_prune_commit");
if (!is_array($forum_cache)) {
$forum_cache = cache_forums();
}
// Log admin action
log_admin_action($mybb->input['older_than'], $mybb->input['uid'], $mybb->input['fid'], $num_deleted, $forum_cache[$mybb->input['fid']]['name']);
flash_message($lang->success_pruned_mod_logs, 'success');
admin_redirect("index.php?module=tools/modlog");
}
$page->add_breadcrumb_item($lang->prune_mod_logs, "index.php?module=tools/modlog&action=prune");
$page->output_header($lang->prune_mod_logs);
$page->output_nav_tabs($sub_tabs, 'prune_mod_logs');
// Fetch filter options
$sortbysel[$mybb->input['sortby']] = 'selected="selected"';
$ordersel[$mybb->input['order']] = 'selected="selected"';
$user_options[''] = $lang->all_moderators;
$user_options['0'] = '----------';
$query = $db->query("\n\t\tSELECT DISTINCT l.uid, u.username\n\t\tFROM " . TABLE_PREFIX . "moderatorlog l\n\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (l.uid=u.uid)\n\t\tORDER BY u.username ASC\n\t");
示例5: define
}
$taptalk_from = '';
if (strpos($_SERVER['HTTP_USER_AGENT'], 'BYO') !== false) {
$taptalk_from = 'BYO';
}
$_SERVER['QUERY_STRING'] = 'method=' . $request_method . '¶ms=' . $request_params[0] . '&from=' . $taptalk_from;
define("IN_MYBB", 1);
require_once './global.php';
if (!isset($cache->cache['plugins']['active']['tapatalk']) && $request_method != 'get_config') {
get_error('Tapatalk will not work on this forum before forum admin Install & Activate tapatalk plugin on forum side!');
}
// hide forum option
if ($mybb->settings['tapatalk_hide_forum']) {
$t_hfids = array_map('intval', explode(',', $mybb->settings['tapatalk_hide_forum']));
if (empty($forum_cache)) {
cache_forums();
}
foreach ($t_hfids as $t_hfid) {
$forum_cache[$t_hfid]['active'] = 0;
}
}
if ($request_method && isset($server_param[$request_method])) {
if ($function_file_name == 'thankyoulike' && file_exists('thankyoulike.php')) {
include 'thankyoulike.php';
} else {
if (substr($request_method, 0, 2) == 'm_') {
include TT_ROOT . 'include/moderation.php';
} else {
if (file_exists(TT_ROOT . 'include/' . $function_file_name . '.php')) {
include TT_ROOT . 'include/' . $function_file_name . '.php';
}
示例6: check_forum_password_archive
/**
* Check the password given on a certain forum for validity
*
* @param int The forum ID
* @param boolean The Parent ID
*/
function check_forum_password_archive($fid, $pid = 0)
{
global $forum_cache;
if (!is_array($forum_cache)) {
$forum_cache = cache_forums();
if (!$forum_cache) {
return false;
}
}
// Loop through each of parent forums to ensure we have a password for them too
$parents = explode(',', $forum_cache[$fid]['parentlist']);
rsort($parents);
if (!empty($parents)) {
foreach ($parents as $parent_id) {
if ($parent_id == $fid || $parent_id == $pid) {
continue;
}
if ($forum_cache[$parent_id]['password'] != "") {
check_forum_password_archive($parent_id, $fid);
}
}
}
$password = $forum_cache[$fid]['password'];
if ($password) {
if (!$mybb->cookies['forumpass'][$fid] || $mybb->cookies['forumpass'][$fid] && md5($mybb->user['uid'] . $password) != $mybb->cookies['forumpass'][$fid]) {
archive_error_no_permission();
}
}
}
示例7: ougc_showinportal_cutoff
function ougc_showinportal_cutoff(&$message, $fid, $tid)
{
global $settings;
if (!$message || !$settings['ougc_showinportal_tag']) {
return;
}
if (!preg_match('#' . ($tag = preg_quote($settings['ougc_showinportal_tag'])) . '#', $message)) {
return;
}
$msg = preg_split('#' . $tag . '#', $message);
if (!(isset($msg[0]) && my_strlen($msg[0]) >= (int) $settings['minmessagelength'])) {
return;
}
global $lang, $forum_cache, $showinportal;
$showinportal->lang_load();
$forum_cache or cache_forums();
// Find out what langguage variable to use
$lang_var = 'ougc_showinportal_readmore';
if ((bool) $forum_cache[$fid]['allowmycode']) {
$lang_var .= '_mycode';
} elseif ((bool) $forum_cache[$fid]['allowhtml']) {
$lang_var .= '_html';
}
$message = $msg[0] . $lang->sprintf($lang->{$lang_var}, $settings['bburl'], get_thread_link($tid));
}
示例8: tt_check_forum_password
function tt_check_forum_password($fid, $pid = 0, $pass = '')
{
global $mybb, $header, $footer, $headerinclude, $theme, $templates, $lang, $forum_cache;
$mybb->input['pwverify'] = $pass;
$showform = true;
if (!is_array($forum_cache)) {
$forum_cache = cache_forums();
if (!$forum_cache) {
return false;
}
}
// Loop through each of parent forums to ensure we have a password for them too
$parents = explode(',', $forum_cache[$fid]['parentlist']);
rsort($parents);
if (!empty($parents)) {
foreach ($parents as $parent_id) {
if ($parent_id == $fid || $parent_id == $pid) {
continue;
}
if ($forum_cache[$parent_id]['password'] != "") {
tt_check_forum_password($parent_id, $fid);
}
}
}
$password = $forum_cache[$fid]['password'];
if ($password) {
if ($mybb->input['pwverify'] && $pid == 0) {
if ($password == $mybb->input['pwverify']) {
my_setcookie("forumpass[{$fid}]", md5($mybb->user['uid'] . $mybb->input['pwverify']), null, true);
$showform = false;
} else {
eval("\$pwnote = \"" . $templates->get("forumdisplay_password_wrongpass") . "\";");
$showform = true;
}
} else {
if (!$mybb->cookies['forumpass'][$fid] || $mybb->cookies['forumpass'][$fid] && md5($mybb->user['uid'] . $password) != $mybb->cookies['forumpass'][$fid]) {
$showform = true;
} else {
$showform = false;
}
}
} else {
$showform = false;
}
if ($showform) {
if (empty($pwnote)) {
global $lang;
$pwnote = $lang->forum_password_note;
}
error($pwnote);
}
}
示例9: get_password_protected_forums
/**
* Build a array list of the forums this user cannot search due to password protection
*
* @param int the fids to check (leave null to check all forums)
* @return return a array list of password protected forums the user cannot search
*/
function get_password_protected_forums($fids = array())
{
global $forum_cache, $mybb;
if (!is_array($fids)) {
return false;
}
if (!is_array($forum_cache)) {
$forum_cache = cache_forums();
if (!$forum_cache) {
return false;
}
}
if (empty($fids)) {
$fids = array_keys($forum_cache);
}
$pass_fids = array();
foreach ($fids as $fid) {
if (empty($forum_cache[$fid]['password'])) {
continue;
}
if (md5($mybb->user['uid'] . $forum_cache[$fid]['password']) != $mybb->cookies['forumpass'][$fid]) {
$pass_fids[] = $fid;
$child_list = get_child_list($fid);
}
if (is_array($child_list)) {
$pass_fids = array_merge($pass_fids, $child_list);
}
}
return array_unique($pass_fids);
}
示例10: build_tt_breadcrumb
function build_tt_breadcrumb($fid, $multipage = array())
{
global $pforumcache, $currentitem, $forum_cache, $navbits, $lang, $base_url, $archiveurl;
if (!$pforumcache) {
if (!is_array($forum_cache)) {
cache_forums();
}
foreach ($forum_cache as $key => $val) {
$pforumcache[$val['fid']][$val['pid']] = $val;
}
}
if (is_array($pforumcache[$fid])) {
foreach ($pforumcache[$fid] as $key => $forumnav) {
if ($fid == $forumnav['fid']) {
if ($pforumcache[$forumnav['pid']]) {
build_tt_breadcrumb($forumnav['pid']);
}
$navsize = count($navbits);
// Convert & to &
$navbits[$navsize]['name'] = $forumnav['name'];
$navbits[$navsize]['type'] = $pforumcache[$fid][$forumnav['pid']]['type'];
if (IN_ARCHIVE == 1) {
// Set up link to forum in breadcrumb.
if ($pforumcache[$fid][$forumnav['pid']]['type'] == 'f' || $pforumcache[$fid][$forumnav['pid']]['type'] == 'c') {
$navbits[$navsize]['fid'] = $forumnav['fid'];
} else {
$navbits[$navsize]['fid'] = "";
}
} else {
$navbits[$navsize]['fid'] = $forumnav['fid'];
}
}
}
}
return 1;
}
示例11: cache_forums
function cache_forums($forumid = -1, $depth = 0)
{
// returns an array of forums with correct parenting and depth information
// see makeforumchooser for an example of usage
die('
<p>The function <strong>cache_forums()</strong> is now redundant.</p>
<p>The standard <em>$vbulletin->forumcache</em> variable now has a \'depth\' key for each forum,
which can be used for producing the depthmark etc.</p>
<p>Additionally, the <em>$vbulletin->forumcache</em> is now stored in the correct order</p>
');
global $vbulletin, $count;
static $fcache, $i;
if (!is_array($fcache))
{
// check to see if we have already got the results from the database
$fcache = array();
$vbulletin->forumcache = array();
$forums = $vbulletin->db->query_read_slave("SELECT * FROM " . TABLE_PREFIX . "forum ORDER BY displayorder");
while ($forum = $vbulletin->db->fetch_array($forums))
{
$fcache["$forum[parentid]"]["$forum[forumid]"] = $forum;
}
}
// database has already been queried
if (is_array($fcache["$forumid"]))
{
foreach ($fcache["$forumid"] AS $forum)
{
$vbulletin->forumcache["$forum[forumid]"] = $forum;
$vbulletin->forumcache["$forum[forumid]"]['depth'] = $depth;
unset($fcache["$forumid"]);
cache_forums($forum['forumid'], $depth + 1);
} // end foreach ($fcache["$forumid"] AS $key1 => $val1)
} // end if (found $fcache["$forumid"])
}
示例12: build_admincp_forums_list
/**
* @param DefaultFormContainer $form_container
* @param int $pid
* @param int $depth
*/
function build_admincp_forums_list(&$form_container, $pid = 0, $depth = 1)
{
global $mybb, $lang, $db, $sub_forums;
static $forums_by_parent;
if (!is_array($forums_by_parent)) {
$forum_cache = cache_forums();
foreach ($forum_cache as $forum) {
$forums_by_parent[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum;
}
}
if (!is_array($forums_by_parent[$pid])) {
return;
}
foreach ($forums_by_parent[$pid] as $children) {
foreach ($children as $forum) {
$forum['name'] = preg_replace("#&(?!\\#[0-9]+;)#si", "&", $forum['name']);
// Fix & but allow unicode
if ($forum['active'] == 0) {
$forum['name'] = "<em>" . $forum['name'] . "</em>";
}
if ($forum['type'] == "c" && ($depth == 1 || $depth == 2)) {
$sub_forums = '';
if (isset($forums_by_parent[$forum['fid']]) && $depth == 2) {
build_admincp_forums_list($form_container, $forum['fid'], $depth + 1);
}
if ($sub_forums) {
$sub_forums = "<br /><small>{$lang->sub_forums}: {$sub_forums}</small>";
}
$form_container->output_cell("<div style=\"padding-left: " . 40 * ($depth - 1) . "px;\"><a href=\"index.php?module=forum-management&fid={$forum['fid']}\"><strong>{$forum['name']}</strong></a>{$sub_forums}</div>");
$form_container->output_cell("<input type=\"text\" name=\"disporder[" . $forum['fid'] . "]\" value=\"" . $forum['disporder'] . "\" class=\"text_input align_center\" style=\"width: 80%; font-weight: bold;\" />", array("class" => "align_center"));
$popup = new PopupMenu("forum_{$forum['fid']}", $lang->options);
$popup->add_item($lang->edit_forum, "index.php?module=forum-management&action=edit&fid={$forum['fid']}");
$popup->add_item($lang->subforums, "index.php?module=forum-management&fid={$forum['fid']}");
$popup->add_item($lang->moderators, "index.php?module=forum-management&fid={$forum['fid']}#tab_moderators");
$popup->add_item($lang->permissions, "index.php?module=forum-management&fid={$forum['fid']}#tab_permissions");
$popup->add_item($lang->add_child_forum, "index.php?module=forum-management&action=add&pid={$forum['fid']}");
$popup->add_item($lang->copy_forum, "index.php?module=forum-management&action=copy&fid={$forum['fid']}");
$popup->add_item($lang->delete_forum, "index.php?module=forum-management&action=delete&fid={$forum['fid']}&my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_forum_deletion}')");
$form_container->output_cell($popup->fetch(), array("class" => "align_center"));
$form_container->construct_row();
// Does this category have any sub forums?
if ($forums_by_parent[$forum['fid']]) {
build_admincp_forums_list($form_container, $forum['fid'], $depth + 1);
}
} elseif ($forum['type'] == "f" && ($depth == 1 || $depth == 2)) {
if ($forum['description']) {
$forum['description'] = preg_replace("#&(?!\\#[0-9]+;)#si", "&", $forum['description']);
$forum['description'] = "<br /><small>" . $forum['description'] . "</small>";
}
$sub_forums = '';
if (isset($forums_by_parent[$forum['fid']]) && $depth == 2) {
build_admincp_forums_list($form_container, $forum['fid'], $depth + 1);
}
if ($sub_forums) {
$sub_forums = "<br /><small>{$lang->sub_forums}: {$sub_forums}</small>";
}
$form_container->output_cell("<div style=\"padding-left: " . 40 * ($depth - 1) . "px;\"><a href=\"index.php?module=forum-management&fid={$forum['fid']}\">{$forum['name']}</a>{$forum['description']}{$sub_forums}</div>");
$form_container->output_cell("<input type=\"text\" name=\"disporder[" . $forum['fid'] . "]\" value=\"" . $forum['disporder'] . "\" class=\"text_input align_center\" style=\"width: 80%;\" />", array("class" => "align_center"));
$popup = new PopupMenu("forum_{$forum['fid']}", $lang->options);
$popup->add_item($lang->edit_forum, "index.php?module=forum-management&action=edit&fid={$forum['fid']}");
$popup->add_item($lang->subforums, "index.php?module=forum-management&fid={$forum['fid']}");
$popup->add_item($lang->moderators, "index.php?module=forum-management&fid={$forum['fid']}#tab_moderators");
$popup->add_item($lang->permissions, "index.php?module=forum-management&fid={$forum['fid']}#tab_permissions");
$popup->add_item($lang->add_child_forum, "index.php?module=forum-management&action=add&pid={$forum['fid']}");
$popup->add_item($lang->copy_forum, "index.php?module=forum-management&action=copy&fid={$forum['fid']}");
$popup->add_item($lang->delete_forum, "index.php?module=forum-management&action=delete&fid={$forum['fid']}&my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_forum_deletion}')");
$form_container->output_cell($popup->fetch(), array("class" => "align_center"));
$form_container->construct_row();
if (isset($forums_by_parent[$forum['fid']]) && $depth == 1) {
build_admincp_forums_list($form_container, $forum['fid'], $depth + 1);
}
} else {
if ($depth == 3) {
if ($donecount < $mybb->settings['subforumsindex']) {
$sub_forums .= "{$comma} <a href=\"index.php?module=forum-management&fid={$forum['fid']}\">{$forum['name']}</a>";
$comma = $lang->comma;
}
// Have we reached our max visible subforums? put a nice message and break out of the loop
++$donecount;
if ($donecount == $mybb->settings['subforumsindex']) {
if (subforums_count($forums_by_parent[$pid]) > $donecount) {
$sub_forums .= $comma . $lang->sprintf($lang->more_subforums, subforums_count($forums_by_parent[$pid]) - $donecount);
return;
}
}
}
}
}
}
}
示例13: ps_GetUnviewable
function ps_GetUnviewable($name = "")
{
global $mybb, $forum_cache;
$unviewwhere = $comma = '';
$name ? $name .= '.' : NULL;
$unviewable = get_unviewable_forums();
if ($mybb->settings['ps_ignoreforums']) {
!is_array($forum_cache) ? cache_forums() : NULL;
if (in_array($mybb->settings['ps_ignoreforums'], array(-1, 'all'))) {
foreach ($forum_cache as $fid => $forum) {
$ignoreforums[] = $forum['fid'];
}
} else {
$ignoreforums = explode(',', $mybb->settings['ps_ignoreforums']);
}
if (count($ignoreforums)) {
$unviewable ? $unviewable .= ',' : NULL;
foreach ($ignoreforums as $fid) {
$unviewable .= $comma . "'" . intval($fid) . "'";
$comma = ',';
}
}
}
if ($unviewable) {
$unviewwhere = "AND " . $name . "fid NOT IN (" . $unviewable . ")";
}
return array($unviewwhere, explode(',', $unviewable));
}
示例14: xthreads_breadcrumb_hack
function xthreads_breadcrumb_hack($fid)
{
global $pforumcache, $forum_cache;
if (!$pforumcache) {
if (!is_array($forum_cache)) {
cache_forums();
}
foreach ($forum_cache as &$val) {
// MyBB does this very weirdly... I mean, like
// ...the second dimension of the array is useless, since fid
// is pulling a unique $val already...
$pforumcache[$val['fid']][$val['pid']] = $val;
}
}
if (!is_array($pforumcache[$fid])) {
return;
}
// our strategy works by rewriting parents of forums below hidden forums
foreach ($pforumcache[$fid] as &$pforum) {
// will only ever loop once
if ($pforum['fid'] != $fid) {
continue;
}
// paranoia
// we can't really hide the active breadcrumb, so ignore current forum...
// (actually, it might be possible if we rewrite forum ids)
if ($pforum['pid'] && !empty($pforumcache[$pforum['pid']])) {
$prevforum =& $pforum;
$forum =& xthreads_get_array_first($pforumcache[$pforum['pid']]);
while ($forum) {
if (!$forum['xthreads_hidebreadcrumb']) {
// rewrite parent fid (won't actually change if there's no hidden breadcrumbs in-between)
$prevforum['pid'] = $forum['fid'];
$prevforum =& $forum;
}
if (!$forum['pid'] || empty($pforumcache[$forum['pid']])) {
break;
}
$forum =& xthreads_get_array_first($pforumcache[$forum['pid']]);
}
$prevforum['pid'] = 0;
}
}
}
示例15: fetch_forum_announcements
/**
* @param DefaultTable $table
* @param int $pid
* @param int $depth
*/
function fetch_forum_announcements(&$table, $pid = 0, $depth = 1)
{
global $mybb, $db, $lang, $announcements, $page;
static $forums_by_parent;
if (!is_array($forums_by_parent)) {
$forum_cache = cache_forums();
foreach ($forum_cache as $forum) {
$forums_by_parent[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum;
}
}
if (!is_array($forums_by_parent[$pid])) {
return;
}
foreach ($forums_by_parent[$pid] as $children) {
foreach ($children as $forum) {
$forum['name'] = htmlspecialchars_uni($forum['name']);
if ($forum['active'] == 0) {
$forum['name'] = "<em>" . $forum['name'] . "</em>";
}
if ($forum['type'] == "c") {
$forum['name'] = "<strong>" . $forum['name'] . "</strong>";
}
$table->construct_cell("<div style=\"padding-left: " . 40 * ($depth - 1) . "px;\">{$forum['name']}</div>");
$table->construct_cell("<a href=\"index.php?module=forum-announcements&action=add&fid={$forum['fid']}\">{$lang->add_announcement}</a>", array("class" => "align_center", "colspan" => 2));
$table->construct_row();
if (isset($announcements[$forum['fid']])) {
foreach ($announcements[$forum['fid']] as $aid => $announcement) {
if ($announcement['enddate'] < TIME_NOW && $announcement['enddate'] != 0) {
$icon = "<img src=\"styles/{$page->style}/images/icons/bullet_off.png\" alt=\"(Expired)\" title=\"Expired Announcement\" style=\"vertical-align: middle;\" /> ";
} else {
$icon = "<img src=\"styles/{$page->style}/images/icons/bullet_on.png\" alt=\"(Active)\" title=\"Active Announcement\" style=\"vertical-align: middle;\" /> ";
}
$table->construct_cell("<div style=\"padding-left: " . 40 * $depth . "px;\">{$icon}<a href=\"index.php?module=forum-announcements&action=edit&aid={$aid}\">" . htmlspecialchars_uni($announcement['subject']) . "</a></div>");
$table->construct_cell("<a href=\"index.php?module=forum-announcements&action=edit&aid={$aid}\">{$lang->edit}</a>", array("class" => "align_center"));
$table->construct_cell("<a href=\"index.php?module=forum-announcements&action=delete&aid={$aid}&my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_announcement_deletion}')\">{$lang->delete}</a>", array("class" => "align_center"));
$table->construct_row();
}
}
// Build the list for any sub forums of this forum
if (isset($forums_by_parent[$forum['fid']])) {
fetch_forum_announcements($table, $forum['fid'], $depth + 1);
}
}
}
}