Subversion Repositories computer_asset_manager_v2

Rev

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

Rev Author Line No. Line
1 rodolico 1
<?php
2
 
3
  global $DATABASE_DEFINITION; // make variable available to all scripts
4
 
5
  /*
6
   * This file is used to override entries in database_def.php
7
   * which is subject to modifications via the script sql2admin_hash.pl
8
   * 
9
   * While database_def.php is overwritten by that script, this file
10
   * will not be.
11
   * 
12
   * Local change should be of the form
13
   * $DATABASE_DEFINITION['users']['field info']['id']['display name'] = 'ID';
14
   * 
15
   * You can also write scripts so, for example, to change the display
16
   * name in all tables which have a column named id
17
   * 
18
   * foreach ( $DATABASE_DEFINITION as $table => $def) {
19
   *   if ( isset( $DATABASE_DEFINITION[$table]['field info']['id'] ) ) {
20
   *      $DATABASE_DEFINITION[$table]['field info']['id']['display name'] = 'ID';
21
   *   }
22
   * }
23
   * 
24
   * 
25
   * NOTE: you can not redefine  the constants in database_def.php. That is why 
26
   * they are called constants. You should comment them in database_def.php
27
   * and then redefine them here. That will throw an error if you then 
28
   * rerun sql2admin_hash.pl and forget to comment them out in database_def.php
29
   * (error shows up in the apache error log)
30
   * 
31
   */ 
32
 
33
   foreach ( $DATABASE_DEFINITION as $table => $def) {
34
      if ( isset( $DATABASE_DEFINITION[$table]['field info']['id'] ) ) {
35
         $DATABASE_DEFINITION[$table]['field info']['id']['display name'] = 'ID';
36
      }
37
      // go through all display fields and change spaces to underscores
38
      // then, for the look up tables, change _id to nothing, so 'Site Id' will become ''Site_Id' and then 'Site'
39
      foreach ( $DATABASE_DEFINITION[$table]['field info'] as $fieldName => $definition ) {
40
         $DATABASE_DEFINITION[$table]['field info'][$fieldName]['display name'] = str_replace( ' ', '_', $DATABASE_DEFINITION[$table]['field info'][$fieldName]['display name'] );
41
         $DATABASE_DEFINITION[$table]['field info'][$fieldName]['display name'] = str_ireplace( '_id', '', $DATABASE_DEFINITION[$table]['field info'][$fieldName]['display name'] );
42
      } // foreach
43
   }
44
 
45
   $DATABASE_DEFINITION['device_types']['field info']['system']['type'] = 'bool';
46
   $DATABASE_DEFINITION['devices']['field info']['parent_id']['table alias'] = 'parent_device';
47
 
48
   /*
49
   select 
50
     devices.id "ID",
51
     devices.serial_number "Serial Number",
52
     devices.name "Name",
53
     parent.name "Parent",
54
     device_types.name "Device Type",
55
     sites.name "Site",
56
     owners.name "Owner",
57
     devices.notes "Notes",
58
     devices.created "Created",
59
     devices.removed "Removed"
60
   from
61
      devices 
62
      left join sites on (devices.site_id = sites.id) 
63
      left join owners on (devices.owner_id=owners.id) 
64
      left join device_types on (devices.device_type_id = device_types.id)
65
      left join devices parent on (devices.parent_id = parent.id)
66
   where
67
      devices.removed is null
68
      and device_types.system = 1
69
      and owners.id = 1;
70
   */
71
   /*
72
   $DATABASE_DEFINITION['devices']['queries'] = array(
73
                    'list' = array(
74
                          'fieldnames' => array('id','serial_number','name','parent_id','device_type_id','site_id','owner_id','notes','created','removed'),
75
                          'tables'     => 'devices',
76
                          'where clause' => array(),
77
                          'order by'     => array('name'),
78
                          ),
79
                    'record' = array(
80
                          'fieldnames' => array('id','serial_number','name','parent_id','device_type_id','site_id','owner_id','notes','created','removed'),
81
                          'tables'     => 'devices',
82
                          'where clause' => array(),
83
                          'order by'     => array('name'),
84
                          ),
85
      );
86
*/
87
 
88
?>