コード例 #1
0
 /** retrieve data for sidebar 
  *
  * this retrieves the content of the various sidebar blocks (if any)
  * currently only the htmlpage module is supported.
  * 
  * @param array $sidebar_nodes contains node-module pairs to show
  * @param string $m add to human readability
  * @return string ready-to-use HTML-code
  */
 function cornelia_get_sidebar($sidebar_nodes, $m = '')
 {
     $s = '';
     $modules = get_module_records();
     if (!empty($sidebar_nodes)) {
         $index = 0;
         foreach ($sidebar_nodes as $node_id => $module_id) {
             ++$index;
             switch ($modules[$module_id]['name']) {
                 case 'htmlpage':
                     $s .= $this->cornelia_get_sidebar_htmlpage($index, $node_id, $m);
                     break;
             }
         }
     }
     return $s;
 }
コード例 #2
0
 /** load the admin interface of a module in core
  *
  * this includes the 'admin'-part of a module via 'require_once()'. This routine
  * first figures out if the admin-script file actually exists before the
  * file is included. Also, we look at a very specific location, namely:
  * /program/modules/<modulename>/<module_admin_script> where <modulename> is retrieved
  * from the modules table in the database.
  *
  * Note that if modulename would somehow be something like "../../../../../../etc/passwd\x00",
  * we could be in trouble...
  *
  * @param int $module_id indicates which module to load
  * @return bool|array FALSE on error or an array with the module record from the modules table
  * @todo should we sanitise the modulename here? It is not user input, but it comes from the modules
  *       table in the database. However, if a module name would contain sequences of "../" we might
  *       be in trouble
  */
 function module_load_admin($module_id)
 {
     global $CFG;
     $modules = get_module_records();
     if (!isset($modules[$module_id])) {
         logger(__FUNCTION__ . "(): weird: module '{$module_id}' is not there. Is it de-activated?");
         return FALSE;
     }
     $module = $modules[$module_id];
     unset($modules);
     $module_admin_script = $CFG->progdir . '/modules/' . $module['name'] . '/' . $module['admin_script'];
     if (!file_exists($module_admin_script)) {
         logger(__FUNCTION__ . "(): weird: file '{$module_admin_script}' does not exist. Huh?");
         return FALSE;
     }
     require_once $module_admin_script;
     return $module;
 }