Subversion Repositories computer_asset_manager_v2

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
67 rodolico 1
<?php
2
 
3
 
4
class Admin {
5
 
6
   private $menu = array(
7
      'motd' => 'Edit MOTD',
8
      'devicetypes' => 'Edit Device Types',
9
      'dbconsistency' => 'Verify Database'
10
      );
11
 
12
   function run () {
13
      global $dbConnection;
14
      global $url;
15
 
16
      $action;
17
 
18
      if ( ! isset( $_REQUEST['action'] ) ) { // just show the menu
19
         return $this->menu( $url );
20
      } else {
21
         $action = $_REQUEST['action'];
22
      }
23
      if ( method_exists( $this, $action ) ) {
24
         return $this->$action($url, $dbConnection);
25
      } else {
26
         return "<p>Action '$action' is not implemented yet</p>";
27
      }
28
   }
29
 
30
   function menu ($url) {
31
      $return = array();
32
      foreach ( $this->menu as $action => $prompt ) {
33
         $return[] = "<a href='$url?module=admin&action=$action'>$prompt</a>\n";
34
      }
35
      return '<table><tr><td>' . join( "</tr></td>\n<tr><td>", $return ) . "</td>\n</tr></table>";
36
   }
37
 
38
   function motd( $url, $connection ) {
39
      $return = '';
40
      if ( isset( $_REQUEST['new_motd'] ) ) {
41
         $motd = $connection->real_escape_string( $_REQUEST['new_motd'] );
42
         $query = "update _system set key_value = '$motd' where group_name = 'program' and key_name = 'motd'";
43
         //print "<pre>$query</pre>"; die;
44
         $connection->doSQL( $query );
45
         $return = $this->menu($url);
46
      } else {
47
         $return = '<h3>Enter the Message of the Day</h3>';
48
         $return .= "<form action='$url' method='post'>\n";
49
         $return .= "<input type='hidden' name='module' value='admin'>\n";
50
         $return .= "<input type='hidden' name='action' value='motd'>\n";
51
         $return .= "<label MOTD><textarea name='new_motd'></textarea></label>\n";
52
         $return .= "<input type='submit' name='submit' value='Update'>\n";
53
         $return .= "</form>\n";
54
      }
55
      return $return;
56
   } // motd
57
} // class admin
58
 
59
?>