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); } } } }
/** * 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; } }
/** 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."); }
$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");
} $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'; }
/** * 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(); } } }
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)); }
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); } }
/** * 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); }
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; }
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"]) }
/** * @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; } } } } } } }
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)); }
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; } } }
/** * @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); } } } }
/** * Generate a forum selection box. * * @param string The name of the selection box. * @param mixed Array/string of the selected items. * @param array Array of options (pid, main_option, multiple) * @param boolean Is this our first interation of this funciton? * @return string The built select box. */ function generate_forum_select($name, $selected, $options = array(), $is_first = 1) { global $fselectcache, $forum_cache, $selectoptions; if (!$selectoptions) { $selectoptions = ''; } if (!$options['depth']) { $options['depth'] = 0; } $options['depth'] = intval($options['depth']); if (!$options['pid']) { $pid = 0; } $pid = intval($options['pid']); if (!is_array($fselectcache)) { if (!is_array($forum_cache)) { $forum_cache = cache_forums(); } foreach ($forum_cache as $fid => $forum) { $fselectcache[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum; } } if ($options['main_option'] && $is_first) { $select_add = ''; if ($selected == -1) { $select_add = " selected=\"selected\""; } $selectoptions .= "<option value=\"-1\"{$select_add}>{$options['main_option']}</option>\n"; } if (is_array($fselectcache[$pid])) { foreach ($fselectcache[$pid] as $main) { foreach ($main as $forum) { if ($forum['fid'] != "0" && $forum['linkto'] == '') { $select_add = ''; if (!empty($selected) && ($forum['fid'] == $selected || is_array($selected) && in_array($forum['fid'], $selected))) { $select_add = " selected=\"selected\""; } $sep = ''; if (isset($options['depth'])) { $sep = str_repeat(" ", $options['depth']); } $style = ""; if ($forum['active'] == 0) { $style = " style=\"font-style: italic;\""; } $selectoptions .= "<option value=\"{$forum['fid']}\"{$style}{$select_add}>" . $sep . htmlspecialchars_uni(strip_tags($forum['name'])) . "</option>\n"; if ($forum_cache[$forum['fid']]) { $options['depth'] += 5; $options['pid'] = $forum['fid']; $this->generate_forum_select($forum['fid'], $selected, $options, 0); $options['depth'] -= 5; } } } } } if ($is_first == 1) { if (!isset($options['multiple'])) { $select = "<select name=\"{$name}\""; } else { $select = "<select name=\"{$name}\" multiple=\"multiple\""; } if (isset($options['class'])) { $select .= " class=\"{$options['class']}\""; } if (isset($options['id'])) { $select .= " id=\"{$options['id']}\""; } if (isset($options['size'])) { $select .= " size=\"{$options['size']}\""; } $select .= ">\n" . $selectoptions . "</select>\n"; $selectoptions = ''; return $select; } }
/** * Update the moderators cache. * */ function update_moderators() { global $forum_cache, $db; $this->built_moderators = array(0); // Get our forum list cache_forums(true); if (!is_array($forum_cache)) { return false; } reset($forum_cache); $fcache = array(); // Resort in to the structure we require foreach ($forum_cache as $fid => $forum) { $this->moderators_forum_cache[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum; } // Sort children foreach ($fcache as $pid => $value) { ksort($fcache[$pid]); } ksort($fcache); // Fetch moderators from the database $query = $db->query("\n\t\t\tSELECT m.*, u.username, u.usergroup, u.displaygroup\n\t\t\tFROM " . TABLE_PREFIX . "moderators m\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (m.id=u.uid)\n\t\t\tWHERE m.isgroup = '0'\n\t\t\tORDER BY u.username\n\t\t"); while ($moderator = $db->fetch_array($query)) { $this->moderators[$moderator['fid']]['users'][$moderator['id']] = $moderator; } if (!function_exists("sort_moderators_by_usernames")) { function sort_moderators_by_usernames($a, $b) { return strcasecmp($a['username'], $b['username']); } } //Fetch moderating usergroups from the database $query = $db->query("\n\t\t\tSELECT m.*, u.title\n\t\t\tFROM " . TABLE_PREFIX . "moderators m\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "usergroups u ON (m.id=u.gid)\n\t\t\tWHERE m.isgroup = '1'\n\t\t\tORDER BY u.title\n\t\t"); while ($moderator = $db->fetch_array($query)) { $this->moderators[$moderator['fid']]['usergroups'][$moderator['id']] = $moderator; } if (is_array($this->moderators)) { foreach (array_keys($this->moderators) as $fid) { uasort($this->moderators[$fid], 'sort_moderators_by_usernames'); } } $this->build_moderators(); $this->update("moderators", $this->built_moderators); }
/** * Get inactivate forums. * * @return string The comma separated values of the inactivate forum. */ function get_inactive_forums() { global $forum_cache, $cache, $inactiveforums; if (!$forum_cache) { cache_forums(); } $inactive = array(); foreach ($forum_cache as $fid => $forum) { if ($forum['active'] == 0) { $inactive[] = $fid; foreach ($forum_cache as $fid1 => $forum1) { if (my_strpos("," . $forum1['parentlist'] . ",", "," . $fid . ",") !== false && !in_array($fid1, $inactive)) { $inactive[] = $fid1; } } } } $inactiveforums = implode(",", $inactive); return $inactiveforums; }