Changeset 177

Show
Ignore:
Timestamp:
01/12/07 23:39:27 (14 years ago)
Author:
exi
Message:

Removed unneeded admin_rental.php and maintenance.php.
Converted the first admin page to a new format, see class.options.php for details.

Location:
dev
Files:
12 added
3 removed
4 modified

Legend:

Unmodified
Added
Removed
  • dev/common/admin.php

    r165 r177  
    44require_once('class.page.php'); 
    55require_once('class.tabbedform.php'); 
     6 
     7// admin menu now loads all admin pages with options 
    68require_once('admin_menu.php'); 
    79require_once('autoupgrade.php'); 
     
    2628check_tblstrct6(); 
    2729 
    28 if ($_POST['submit']) 
     30if (!$_REQUEST['field'] && !$_REQUEST['sub']) 
    2931{ 
    30     $config->setStyleBanner($_POST['style_banner']); 
    31     $config->setStyleName($_POST['style_name']); 
    32  
    33     // new function checkCheckbox, checks $_POST[arg] and inserts 0 if != 'on' 
    34     $config->checkCheckbox('kill_points'); 
    35     $config->checkCheckbox('loss_points'); 
    36     $config->checkCheckbox('total_points'); 
    37     $config->checkCheckbox('ship_values'); 
    38     $config->checkCheckbox('least_active'); 
    39     $config->checkCheckbox('adapt_items'); 
    40     $config->checkCheckbox('show_standing'); 
    41     $config->checkCheckbox('bs_podlink'); 
    42     $config->checkCheckbox('post_forbid'); 
    43  
    44     if ($config->checkCheckbox('comments')) 
     32    $_REQUEST['field'] = 'Appearance'; 
     33    $_REQUEST['sub'] = 'Generic'; 
     34} 
     35if ($_REQUEST['field'] && $_REQUEST['sub']) 
     36{ 
     37    if ($_POST) 
    4538    { 
    46         check_commenttable(); 
     39        options::handlePost(); 
    4740    } 
    48     $config->checkCheckbox('comments_pw'); 
    49     $config->checkCheckbox('comments_count'); 
    50         $config->checkCheckbox('item_values'); 
    51         $config->checkCheckbox('readd_dupes'); 
    52     $config->setPostPassword($_POST['post_password']); 
    53     $config->setPostMailto($_POST['post_mailto']); 
    54     $config->setConfig('mail_host', $_POST['post_mailhost']); 
    55  
    56     if ($_POST['filter_apply'] == "on") 
    57     { 
    58         $config->setConfig('filter_apply', '1'); 
    59         $config->setConfig('filter_date', mktime(0, 0, 0, $_POST['filter_month'], ($_POST['filter_day'] > 31 ? 31 : $_POST['filter_day']), $_POST['filter_year'])); 
    60     } 
    61     else 
    62     { 
    63         $config->setConfig('filter_apply', '0'); 
    64         $config->setConfig('filter_date', 0); 
    65     } 
    66  
    67     $html .= "Changes saved."; 
    68 } 
    69  
    70 $html .= "<form id=options name=options method=post action=?a=admin>"; 
    71 $html .= "<div class=block-header2>Look and feel</div>"; 
    72 $html .= "<table class=kb-subtable>"; 
    73 $html .= "<tr><td width=120><b>Banner:</b></td><td><select id=style_banner name=style_banner>"; 
    74  
    75 $dir = "img/logo/"; 
    76 if (is_dir($dir)) 
    77 { 
    78     if ($dh = opendir($dir)) 
    79     { 
    80         while (($file = readdir($dh)) !== false) 
    81         { 
    82             $file = substr($file, 0, strpos($file, ".")); 
    83             if (!is_dir($dir.$file)) 
    84             { 
    85                 $html .= "<option value=\"".$file."\""; 
    86                 if ($file == $config->getConfig('style_banner')) 
    87                 { 
    88                     $html .= " selected=\"selected\""; 
    89                 } 
    90                 $html .= ">".$file."</option>"; 
    91             } 
    92         } 
    93         closedir($dh); 
    94     } 
    95 } 
    96 $html .= "</td></tr>"; 
    97 $html .= "<tr><td width=120><b>Style:</b></td><td><select id=style_name name=style_name>"; 
    98  
    99 $dir = "style/"; 
    100 if (is_dir($dir)) 
    101 { 
    102     if ($dh = opendir($dir)) 
    103     { 
    104         while (($file = readdir($dh)) !== false) 
    105         { 
    106             if (is_dir($dir.$file)) 
    107             { 
    108                 if ($file == "." || $file == ".." || $file == ".svn") 
    109                 { 
    110                     continue; 
    111                 } 
    112                 $html .= "<option value=\"".$file."\""; 
    113                 if ($file == $config->getConfig('style_name')) 
    114                 { 
    115                     $html .= " selected=\"selected\""; 
    116                 } 
    117                 $html .= ">".$file."</option>"; 
    118             } 
    119         } 
    120         closedir($dh); 
    121     } 
    122 } 
    123 $html .= "</select></td></tr>"; 
    124 $html .= "<tr><td></td></tr></table>"; 
    125  
    126 $html .= "<div class=block-header2>Global options</div>"; 
    127 $html .= "<table class=kb-subtable>"; 
    128 $html .= "<tr><td width=120><b>Display killpoints:</b></td><td><input type=checkbox name=kill_points id=kill_points"; 
    129 if ($config->getConfig('kill_points')) 
    130 { 
    131     $html .= " checked=\"checked\""; 
    132 } 
    133 $html .= "></td></tr>"; 
    134 $html .= "<tr><td width=120><b>Display losspoints:</b></td><td><input type=checkbox name=loss_points id=loss_points"; 
    135 if ($config->getConfig('loss_points')) 
    136 { 
    137     $html .= " checked=\"checked\""; 
    138 } 
    139 $html .= "></td></tr>"; 
    140 $html .= "<tr><td width=120><b>Display totalpoints:</b></td><td><input type=checkbox name=total_points id=total_points"; 
    141 if ($config->getConfig('total_points')) 
    142 { 
    143     $html .= " checked=\"checked\""; 
    144 } 
    145 $html .= "></td></tr>"; 
    146  
    147 $html .= "<tr><td width=120><b>Enable Comments:</b></td><td><input type=checkbox name=comments id=comments"; 
    148 if ($config->getConfig('comments')) 
    149 { 
    150     $html .= " checked=\"checked\""; 
    151 } 
    152 $html .= "></td></tr>"; 
    153 $html .= "<tr><td width=120><b>Require password for Comments:</b></td><td><input type=checkbox name=comments_pw id=comments_pw"; 
    154 if ($config->getConfig('comments_pw')) 
    155 { 
    156         $html .= " checked=\"checked\""; 
    157 } 
    158 $html .= "></td></tr>"; 
    159 $html .= "<tr><td width=120><b>Display Comment Count on Killlists:</b></td><td><input type=checkbox name=comments_count id=comments_count"; 
    160 if ($config->getConfig('comments_count')) 
    161 { 
    162     $html .= " checked=\"checked\""; 
    163 } 
    164 $html .= "></td></tr>"; 
    165 $html .= "<tr><td width=120><b>Display Standings:</b></td><td><input type=checkbox name=show_standing id=show_standing"; 
    166 if ($config->getConfig('show_standing')) 
    167 { 
    168     $html .= " checked=\"checked\""; 
    169 } 
    170 $html .= "></td></tr>"; 
    171  
    172 $html .= "<tr><td width=120><b>Enable Lost Item Values</b></td><td><input type=checkbox name=item_values id=item_values"; 
    173 if ($config->getConfig('item_values')) 
    174 { 
    175     $html .= " checked=\"checked\""; 
    176 } 
    177 $html .= "></td></tr>"; 
    178 $html .= "<tr><td width=120><b>Use custom shipvalues:</b></td><td><input type=checkbox name=ship_values id=ship_values"; 
    179 if ($config->getConfig('ship_values')) 
    180 { 
    181     $html .= " checked=\"checked\""; 
    182 } 
    183 $html .= "></td></tr>"; 
    184 $html .= "<tr><td width=120><b>Display a link instead of POD on Battlesummary:</b></td><td><input type=checkbox name=bs_podlink id=bs_podlink"; 
    185 if ($config->getConfig('bs_podlink')) 
    186 { 
    187     $html .= " checked=\"checked\""; 
    188 } 
    189 $html .= "></td></tr>"; 
    190 // $html .= "<tr><td width=120><b>Display least active:</b></td><td><input type=checkbox name=least_active id=least_active"; 
    191 // if ( $config->getLeastActive() ) 
    192 // $html .= " checked=\"checked\""; 
    193 // $html .= "></td></tr>"; 
    194 $html .= "<tr><td></td></tr></table>"; 
    195  
    196 $html .= "<div class=block-header2>Posting</div>"; 
    197 $html .= "<table class=kb-subtable>"; 
    198  
    199 $html .= "<tr><td width=120><b>Post password:</b></td><td><input type=text name=post_password id=post_password size=20 maxlength=20 value=\"".$config->getPostPassword()."\"></td></tr>"; 
    200 $html .= "<tr><td width=120><b>Killmail CC:</b></td><td><input type=text name=post_mailto id=post_mailto size=20 maxlength=80 value=\"".$config->getPostMailto()."\"> (e-mail address)</td></tr>"; 
    201 $html .= "<tr><td width=120><b>Mailhost:</b></td><td><input type=text name=post_mailhost id=post_mailhost size=20 maxlength=80 value=\"".$config->getConfig('mail_host')."\"></td></tr>"; 
    202 $html .= "<tr><td width=120><b>Disallow any killmails before:</b></td><td>".dateSelector($config->getConfig('filter_apply'), $config->getConfig('filter_date'))."</td></tr>"; 
    203 $html .= "<tr><td width=120><b>Forbid posting</b></td><td><input type=checkbox name=post_forbid id=post_forbid"; 
    204 if ($config->getConfig('post_forbid')) 
    205 { 
    206     $html .= " checked=\"checked\""; 
    207 } 
    208 $html .= "> (Checking this option disables mailposting)</td></tr>"; 
    209 $html .= "<tr><td width=120><b>Enable auto-addition of unknown Items:</b></td><td><input type=checkbox name=adapt_items id=adapt_items"; 
    210 if ($config->getConfig('adapt_items')) 
    211 { 
    212     $html .= " checked=\"checked\""; 
    213 } 
    214 $html .= "> (This is in case we can't supply a dump with the new items when Kali goes live)</td></tr>"; 
    215 $html .= "<tr><td width=120><b>ReAdd known killmails</b></td><td><input type=checkbox name=readd_dupes id=readd_dupes"; 
    216 if ($config->getConfig('readd_dupes')) 
    217 { 
    218     $html .= " checked=\"checked\""; 
    219 } 
    220 $html .= "> (This internally reparses a dupe on submit)</td></tr>"; 
    221 $html .= "</table>"; 
    222  
    223 $html .= "<div class=block-header2>Save changes</div>"; 
    224 $html .= "<table class=kb-subtable>"; 
    225  
    226 $html .= "<tr><td width=120></td><td><input type=submit name=submit value=\"Save\"></td></tr>"; 
    227 $html .= "</table>"; 
    228  
    229 $html .= "</form>"; 
    230  
    231 $page->setContent($html); 
    232 $page->addContext($menubox->generate()); 
    233 $page->generate(); 
    234  
    235 function dateSelector($apply, $date) 
    236 { 
    237         if ($date > 0) 
    238     { 
    239                 $date = getdate($date); 
    240         } 
    241     else 
    242     { 
    243                 $date = getdate(); 
    244         } 
    245         $html = "<input type=\"text\" name=\"filter_day\" id=\"filter_day\" style=\"width:20px\" value=\"{$date['mday']}\"/>&nbsp;"; 
    246         $html .= "<select name=\"filter_month\" id=\"filter_month\">"; 
    247         for ($i = 1; $i <= 12; $i++) 
    248     { 
    249                 $t = mktime(0, 0, 0, $i, 1, 1980); 
    250                 $month = date("M", $t); 
    251                 if($date['mon'] == $i) 
    252         { 
    253             $selected = " selected=\"selected\""; 
    254         } 
    255         else 
    256         { 
    257             $selected = ""; 
    258         } 
    259  
    260                 $html .= "<option value=\"$i\"$selected>$month</option>"; 
    261         } 
    262         $html .= "</select>&nbsp;"; 
    263  
    264         $html .= "<select name=\"filter_year\" id=\"filter_year\">"; 
    265         for ($i = date("Y")-7; $i <= date("Y"); $i++) 
    266     { 
    267                 if ($date['year'] == $i) 
    268         { 
    269             $selected = " selected=\"selected\""; 
    270         } 
    271         else 
    272         { 
    273             $selected = ""; 
    274         } 
    275                 $html .= "<option value=\"$i\"$selected>$i</option>"; 
    276         } 
    277         $html .= "</select>&nbsp;"; 
    278         $html .= "<input type=checkbox name=filter_apply id=filter_apply"; 
    279         if ($apply) 
    280     { 
    281         $html .= " checked=\"checked\""; 
    282     } 
    283         $html .= "/>Apply&nbsp;"; 
    284         return $html; 
     41    $page->setContent(options::genOptionsPage()); 
     42    $page->addContext(options::genAdminMenu()); 
     43    $page->generate(); 
    28544} 
    28645?> 
  • dev/common/admin_menu.php

    r148 r177  
    11<?php 
    22require_once("class.box.php"); 
     3require_once('class.options.php'); 
    34 
    4 $menubox = new Box(); 
    5 $menubox->setIcon("menu-item.gif"); 
    6 $menubox->addOption("link","Generic", "?a=admin"); 
    7 $menubox->addOption("link","Contracts", "?a=admin_cc&op=view&type=contract"); 
    8 $menubox->addOption("link","Campaigns", "?a=admin_cc&op=view&type=campaign"); 
    9 $menubox->addOption("link","Standings", "?a=admin_standings"); 
    10 $menubox->addOption("link","Ship Values", "?a=admin_shp_val"); 
    11 $menubox->addOption("link","Synchronization", "?a=admin_sync"); 
    12 $menubox->addOption("link","Map Options", "?a=admin_mapoptions"); 
    13 $menubox->addOption("link","Post Permissions", "?a=admin_postperm"); 
    14 $menubox->addOption("link","Mods", "?a=admin_mods"); 
    15 if (file_exists('common/admin_feed.php')) 
     5// include all admin modules 
     6$dir = 'common/admin/'; 
     7if (is_dir($dir)) 
    168{ 
    17     $menubox->addOption("link","Feeds", "?a=admin_feed"); 
     9    if ($dh = opendir($dir)) 
     10    { 
     11        while (($file = readdir($dh)) !== false) 
     12        { 
     13            if (strstr($file, 'admin_') && substr($file, -4) == '.php') 
     14            { 
     15                require_once($dir.$file); 
     16            } 
     17        } 
     18        closedir($dh); 
     19    } 
    1820} 
    19 $menubox->addOption("link","Auditing", "?a=admin_audit"); 
    20 $menubox->addOption("link","Kill Import - files", "?a=kill_import"); 
    21 $menubox->addOption("link","Kill Import - csv", "?a=kill_import_csv"); 
    22 $menubox->addOption("link","Kill Export - files", "?a=kill_export"); 
    23 $menubox->addOption("link","Kill Export - csv", "?a=kill_export_search"); 
    24 $menubox->addOption("link","Logout", "?a=logout"); 
     21 
     22// overload the box object to force every admin page to use the new options menu 
     23class Box2 extends Box 
     24{ 
     25    function generate() 
     26    { 
     27        return options::genAdminMenu(); 
     28    } 
     29} 
     30 
     31$menubox = new Box2(); 
     32 
     33options::oldMenu('Appearance', "Contracts", "?a=admin_cc&op=view&type=contract"); 
     34options::oldMenu('Appearance', "Campaigns", "?a=admin_cc&op=view&type=campaign"); 
     35options::oldMenu('Appearance', "Standings", "?a=admin_standings"); 
     36options::oldMenu('Appearance', "Map Options", "?a=admin_mapoptions"); 
     37options::oldMenu('Advanced', "Ship Values", "?a=admin_shp_val"); 
     38options::oldMenu('Advanced', "Synchronization", "?a=admin_sync"); 
     39options::oldMenu('Advanced', "Post Permissions", "?a=admin_postperm"); 
     40options::oldMenu('Modules'," Mods", "?a=admin_mods"); 
     41options::oldMenu('Maintenance', "Auditing", "?a=admin_audit"); 
     42options::oldMenu('Maintenance', "Kill Import - files", "?a=kill_import"); 
     43options::oldMenu('Maintenance', "Kill Import - csv", "?a=kill_import_csv"); 
     44options::oldMenu('Maintenance', "Kill Export - files", "?a=kill_export"); 
     45options::oldMenu('Maintenance', "Kill Export - csv", "?a=kill_export_search"); 
     46options::oldMenu('Maintenance', "Logout", "?a=logout"); 
    2547?> 
  • dev/common/class.box.php

    r165 r177  
    1111    } 
    1212 
    13     //its called setIcon... and it sets the Icon.//its called setIcon... and it sets the Icon. 
     13    // its called setIcon... and it sets the Icon. 
    1414    function setIcon($icon) 
    1515    { 
     
    1717    } 
    1818 
    19     //add something to the array that we send to smarty later... types can be caption, img, link, points. Only link needs all 3 attribues 
     19    // add something to the array that we send to smarty later... 
     20    // types can be caption, img, link, points. Only link needs all 3 attribues 
    2021    function addOption($type, $name, $url = '') 
    2122    { 
     
    2829 
    2930        $smarty->assign('count', count($this->box_array)); 
    30         if($this->icon_) 
     31        if ($this->icon_) 
    3132        { 
    3233            $smarty->assign('icon', IMG_URL."/".$this->icon_); 
  • dev/common/globals.php

    r162 r177  
    66// current version: major.minor.sub 
    77// unpair numbers for minor = development version 
    8 define('KB_VERSION', '1.2.2'); 
     8define('KB_VERSION', '1.3.0'); 
    99 
    1010// set the running-server for id-syncs here