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',
68 rodolico 9
      'dbconsistency' => 'Verify Database',
10
      'activitylog' => 'View Activity Log'
67 rodolico 11
      );
12
 
13
   function run () {
14
      global $dbConnection;
15
      global $url;
16
 
17
      $action;
18
 
19
      if ( ! isset( $_REQUEST['action'] ) ) { // just show the menu
20
         return $this->menu( $url );
21
      } else {
22
         $action = $_REQUEST['action'];
23
      }
24
      if ( method_exists( $this, $action ) ) {
25
         return $this->$action($url, $dbConnection);
26
      } else {
27
         return "<p>Action '$action' is not implemented yet</p>";
28
      }
29
   }
30
 
31
   function menu ($url) {
32
      $return = array();
33
      foreach ( $this->menu as $action => $prompt ) {
34
         $return[] = "<a href='$url?module=admin&action=$action'>$prompt</a>\n";
35
      }
36
      return '<table><tr><td>' . join( "</tr></td>\n<tr><td>", $return ) . "</td>\n</tr></table>";
37
   }
38
 
39
   function motd( $url, $connection ) {
40
      $return = '';
41
      if ( isset( $_REQUEST['new_motd'] ) ) {
42
         $motd = $connection->real_escape_string( $_REQUEST['new_motd'] );
43
         $query = "update _system set key_value = '$motd' where group_name = 'program' and key_name = 'motd'";
44
         //print "<pre>$query</pre>"; die;
45
         $connection->doSQL( $query );
46
         $return = $this->menu($url);
47
      } else {
48
         $return = '<h3>Enter the Message of the Day</h3>';
49
         $return .= "<form action='$url' method='post'>\n";
50
         $return .= "<input type='hidden' name='module' value='admin'>\n";
51
         $return .= "<input type='hidden' name='action' value='motd'>\n";
52
         $return .= "<label MOTD><textarea name='new_motd'></textarea></label>\n";
53
         $return .= "<input type='submit' name='submit' value='Update'>\n";
54
         $return .= "</form>\n";
55
      }
56
      return $return;
57
   } // motd
68 rodolico 58
 
59
   public function devicetypes( $url, $connection, $deviceType = null ) {
60
      require_once( 'devicetype.class.php' );
61
 
62
      if ( isset( $_REQUEST['id'] ) ) {
63
         $_SESSION['data']['DeviceType'] = new DeviceType( $_REQUEST['id']  );
64
         $_SESSION['data']['DeviceType']->edit( array( 'module' => 'admin', 'action' => 'devicetypes' ) );
65
      } else {
70 rodolico 66
         return DeviceType::ShowSelectionList();
68 rodolico 67
      }
68
      return '';
69
   }
70
 
67 rodolico 71
} // class admin
72
 
73
?>