Subversion Repositories computer_asset_manager_v2

Rev

Rev 19 | Rev 26 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

<?php

  global $DATABASE_DEFINITION; // make variable available to all scripts

  /*
   * This file is used to override entries in DatabaseDefinition.php
   * which is subject to modifications via the script sql2admin_hash.pl
   * 
   * While DatabaseDefinition.php is overwritten by that script, this file
   * will not be.
   * 
   * Local change should be of the form
   * $DATABASE_DEFINITION['users']['field info']['id']['display name'] = 'ID';
   * 
   * You can also write scripts so, for example, to change the display
   * name in all tables which have a column named id
   * 
   * foreach ( $DATABASE_DEFINITION as $table => $def) {
   *   if ( isset( $DATABASE_DEFINITION[$table]['field info']['id'] ) ) {
   *      $DATABASE_DEFINITION[$table]['field info']['id']['display name'] = 'ID';
   *   }
   * }
   * 
   * 
   * NOTE: you can not redefine  the constants in DatabaseDefinition.php. 
   * That is why they are called constants. You should comment them 
   * in database_def.php
   * and then redefine them here. That will throw an error if you then 
   * rerun sql2admin_hash.pl and forget to comment them out in database_def.php
   * (error shows up in the apache error log)
   * 
   */ 
   
   foreach ( $DATABASE_DEFINITION as $table => $def) {
      if ( isset( $DATABASE_DEFINITION[$table]['field info'][$DATABASE_DEFINITION[$table]['key field']] ) ) {
         $DATABASE_DEFINITION[$table]['field info'][$DATABASE_DEFINITION[$table]['key field']]['display name'] = 'ID';
      }
      // go through all display fields and change spaces to underscores
      // then, for the look up tables, change _id to nothing, so 'Site Id' will become ''Site_Id' and then 'Site'
      foreach ( $DATABASE_DEFINITION[$table]['field info'] as $fieldName => $definition ) {
         $DATABASE_DEFINITION[$table]['field info'][$fieldName]['display name'] = str_ireplace( '_id', '', $DATABASE_DEFINITION[$table]['field info'][$fieldName]['display name'] );
         $DATABASE_DEFINITION[$table]['field info'][$fieldName]['display name'] = str_replace( '_', ' ', $DATABASE_DEFINITION[$table]['field info'][$fieldName]['display name'] );
         if ( ! isset( $DATABASE_DEFINITION[$table]['field info'][$fieldName]['input filter'] ) )
            $DATABASE_DEFINITION[$table]['field info'][$fieldName]['input filter'] = 'alphanum';
      } // foreach
   }
   
   $DATABASE_DEFINITION['_user']['display query'] = 'select _user_id,username,name,email,notes from _user';
   $DATABASE_DEFINITION['_user']['field info']['pass']['type'] = 'password';

   $DATABASE_DEFINITION['client']['display query'] = 'select client_id,name from client';

?>