decir/admincp/admin_base.php
changeset 6 3f66ec435f08
child 7 37387f84fe25
equal deleted inserted replaced
5:6eea55374f5b 6:3f66ec435f08
       
     1 <?php
       
     2 /*
       
     3  * Decir
       
     4  * Version 0.1
       
     5  * Copyright (C) 2007 Dan Fuhry
       
     6  * admin_base.php - lowlevel loader for the Decir admin panel
       
     7  *
       
     8  * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
       
     9  * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
       
    10  *
       
    11  * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
       
    12  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
       
    13  */
       
    14  
       
    15 $decir_menu = array();
       
    16 
       
    17 // Only load the actual admin modules if they're needed
       
    18 function page_Special_DecirAdmin_preloader()
       
    19 {
       
    20   global $db, $session, $paths, $template, $plugins; // Common objects
       
    21   global $decir_menu;
       
    22   require( DECIR_ROOT . '/admincp/admin_index.php' );
       
    23   require( DECIR_ROOT . '/admincp/admin_forums.php' );
       
    24   
       
    25   $decir_menu['Special|Administration'] = 'Main administration panel';
       
    26 }
       
    27 
       
    28 $plugins->attachHook('base_classes_initted', '
       
    29     $paths->add_page(Array(
       
    30       \'name\'=>\'Decir Administration Panel\',
       
    31       \'urlname\'=>\'DecirAdmin\',
       
    32       \'namespace\'=>\'Special\',
       
    33       \'special\'=>0,\'visible\'=>0,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
       
    34       ));
       
    35   ');
       
    36 
       
    37 function page_Special_DecirAdmin()
       
    38 {
       
    39   global $db, $session, $paths, $template, $plugins; // Common objects
       
    40   
       
    41   if ( $session->user_level < USER_LEVEL_ADMIN )
       
    42     die_friendly('Access denied', '<p>This page is restricted access.</p>');
       
    43   
       
    44   if ( $session->auth_level < USER_LEVEL_ADMIN )
       
    45     redirect(makeUrlNS('Special', 'Login/' . $paths->page, 'level=' . USER_LEVEL_ADMIN, true), '', '', 0);
       
    46   
       
    47   $session->theme = 'admin';
       
    48   $session->style = 'default';
       
    49   $template = false;
       
    50   unset($GLOBALS['template']);
       
    51   unset($template);
       
    52   $GLOBALS['template'] = new template();
       
    53   $template =& $GLOBALS['template'];
       
    54   
       
    55   $template->header();
       
    56   ?>
       
    57   Add or remove forums, control user permissions, and check forum statistics.
       
    58   <table border="0" cellspacing="0" cellpadding="0" width="100%" style="margin-top: 10px;">
       
    59     <tr>
       
    60       <td style="padding-right: 20px; width: 200px;" valign="top">
       
    61         <h4 style="margin: 0 0 10px 0;">Decir configuration</h4>
       
    62         <ul>
       
    63           <?php
       
    64             global $decir_menu;
       
    65             foreach ( $decir_menu as $page_id => $link_text )
       
    66             {
       
    67               if ( strpos($page_id, '|') )
       
    68               {
       
    69                 $namesp  = substr($page_id, 0, strpos($page_id, '|'));
       
    70                 $page_id = substr($page_id, strpos($page_id, '|') + 1);                
       
    71               }
       
    72               else
       
    73               {
       
    74                 $namesp = 'Admin';
       
    75               }
       
    76               $link_text = htmlspecialchars($link_text);
       
    77               if ( $namesp == 'Admin' )
       
    78               {
       
    79                 $url = makeUrlNS('Special', 'DecirAdmin', 'module=' . $paths->nslist[$namesp] . $page_id, true);
       
    80               }
       
    81               else
       
    82               {
       
    83                 $url = makeUrlNS($namesp, $page_id);
       
    84               }
       
    85               echo '<li><a href="' . $url . "\">$link_text</a></li>";
       
    86             }
       
    87           ?>
       
    88         </ul>
       
    89       </td>
       
    90       <td valign="top">
       
    91         <?php
       
    92           $module = ( isset($_GET['module']) ) ? $_GET['module'] : $paths->nslist['Admin'] . 'DecirIndex';
       
    93           list($page_id, $namespace) = RenderMan::strToPageID($module);
       
    94           $page = new PageProcessor($page_id, $namespace);
       
    95           $page->send();
       
    96         ?>
       
    97       </td>
       
    98     </tr>
       
    99   </table>
       
   100   <?php
       
   101   
       
   102   $template->footer();
       
   103 }
       
   104 
       
   105 ?>