[ Index ]

PHP Cross Reference of MyBB

title

Body

[close]

/admin/modules/home/ -> module_meta.php (source)

   1  <?php
   2  /**
   3   * MyBB 1.6
   4   * Copyright 2010 MyBB Group, All Rights Reserved
   5   *
   6   * Website: http://mybb.com
   7   * License: http://mybb.com/about/license
   8   *
   9   * $Id$
  10   */
  11  
  12  // Disallow direct access to this file for security reasons
  13  if(!defined("IN_MYBB"))
  14  {
  15      die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
  16  }
  17  
  18  function home_meta()
  19  {
  20      global $page, $lang, $plugins;
  21  
  22      $sub_menu = array();
  23      $sub_menu['10'] = array("id" => "dashboard", "title" => $lang->dashboard, "link" => "index.php?module=home-dashboard");
  24      $sub_menu['20'] = array("id" => "preferences", "title" => $lang->preferences, "link" => "index.php?module=home-preferences");
  25      $sub_menu['30'] = array("id" => "version_check", "title" => $lang->version_check, "link" => "index.php?module=home-version_check");
  26      $sub_menu['40'] = array("id" => "credits", "title" => $lang->mybb_credits, "link" => "index.php?module=home-credits");
  27      $sub_menu = $plugins->run_hooks("admin_home_menu", $sub_menu);
  28      
  29      $page->add_menu_item($lang->home, "home", "index.php", 1, $sub_menu);
  30      
  31      return true;
  32  }
  33  
  34  function home_action_handler($action)
  35  {
  36      global $page, $db, $lang, $plugins;
  37      
  38      $page->active_module = "home";
  39      
  40      $actions = array(
  41          'preferences' => array('active' => 'preferences', 'file' => 'preferences.php'),
  42          'credits' => array('active' => 'credits', 'file' => 'credits.php'),
  43          'version_check' => array('active' => 'version_check', 'file' => 'version_check.php'),
  44          'dashboard' => array('active' => 'dashboard', 'file' => 'index.php')
  45      );
  46      
  47      if(!isset($actions[$action]))
  48      {
  49          $page->active_action = "dashboard";
  50      }
  51      else
  52      {
  53          $page->active_action = $actions[$action]['active'];
  54      }
  55      
  56      $actions = $plugins->run_hooks("admin_home_action_handler", $actions);
  57      
  58      if($page->active_action == "dashboard")
  59      {
  60          // Quick Access
  61          $sub_menu = array();
  62          $sub_menu['10'] = array("id" => "add_forum", "title" => $lang->add_new_forum, "link" => "index.php?module=forum-management&action=add");
  63          $sub_menu['20'] = array("id" => "search", "title" => $lang->search_for_users, "link" => "index.php?module=user-users&action=search");
  64          $sub_menu['30'] = array("id" => "themes", "title" => $lang->themes, "link" => "index.php?module=style-themes");
  65          $sub_menu['40'] = array("id" => "templates", "title" => $lang->templates, "link" => "index.php?module=style-templates");
  66          $sub_menu['50'] = array("id" => "plugins", "title" => $lang->plugins, "link" => "index.php?module=config-plugins");
  67          $sub_menu['60'] = array("id" => "backupdb", "title" => $lang->database_backups, "link" => "index.php?module=tools-backupdb");
  68          
  69          $sub_menu = $plugins->run_hooks("admin_home_menu_quick_access", $sub_menu);
  70          
  71          $sidebar = new SidebarItem($lang->quick_access);
  72          $sidebar->add_menu_items($sub_menu, $page->active_action);
  73          
  74          $page->sidebar .= $sidebar->get_markup();
  75  
  76          // Online Administrators in the last 30 minutes
  77          $timecut = TIME_NOW-60*30;
  78          $query = $db->simple_select("adminsessions", "uid, ip", "lastactive > {$timecut}");
  79          $online_users = "<ul class=\"menu online_admins\">";
  80          $online_admins = array();
  81          
  82          // If there's only 1 user online, it has to be us.
  83          if($db->num_rows($query) == 1)
  84          {
  85              global $mybb;
  86              
  87              $online_admins[$mybb->user['username']] = array(
  88                  "uid" => $mybb->user['uid'],
  89                  "username" => $mybb->user['username'],
  90                  "ip" => $db->fetch_field($query, "ip")
  91              );
  92          }
  93          else
  94          {
  95              $uid_in = array();
  96              while($user = $db->fetch_array($query))
  97              {
  98                  $uid_in[] = $user['uid'];
  99                  $online_admins[$user['uid']] = array(
 100                      "uid" => $user['uid'],
 101                      "username" => "",
 102                      "ip" => $user['ip']
 103                  );
 104              }
 105              
 106              $query = $db->simple_select("users", "uid, username", "uid IN(".implode(',', $uid_in).")", array('order_by' => 'username'));
 107              while($user = $db->fetch_array($query))
 108              {
 109                  $online_admins[$user['username']] = array(
 110                      "uid" => $user['uid'],
 111                      "username" => $user['username'],
 112                      "ip" => $online_admins[$user['uid']]['ip']
 113                  );
 114                  unset($online_admins[$user['uid']]);
 115              }
 116          }
 117          
 118          $done_users = array();
 119          
 120          asort($online_admins);
 121          
 122          foreach($online_admins as $user)
 123          {
 124              if(!isset($done_users["{$user['uid']}.{$user['ip']}"]))
 125              {
 126                  if(isset($user['type']) == "mobile")
 127                  {
 128                      $class = " class=\"mobile_user\"";
 129                  }
 130                  else
 131                  {
 132                      $class = "";
 133                  }
 134                  $online_users .= "<li{$class}>".build_profile_link($user['username'], $user['uid'], "_blank")."</li>";
 135                  $done_users["{$user['uid']}.{$user['ip']}"] = 1;
 136              }
 137          }
 138          $online_users .= "</ul>";
 139          $sidebar = new SidebarItem($lang->online_admins);
 140          $sidebar->set_contents($online_users);
 141  
 142          $page->sidebar .= $sidebar->get_markup();
 143      }
 144  
 145      if(isset($actions[$action]))
 146      {
 147          $page->active_action = $actions[$action]['active'];
 148          return $actions[$action]['file'];
 149      }
 150      else
 151      {
 152          $page->active_action = "dashboard";
 153          return "index.php";
 154      }
 155  }
 156  
 157  ?>


Generated: Tue Oct 8 19:19:50 2013 Cross-referenced by PHPXref 0.7.1