Rev 18 | 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 database_def.php
* which is subject to modifications via the script sql2admin_hash.pl
*
* While database_def.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 database_def.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']['id'] ) ) {
$DATABASE_DEFINITION[$table]['field info']['id']['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_replace( ' ', '_', $DATABASE_DEFINITION[$table]['field info'][$fieldName]['display name'] );
$DATABASE_DEFINITION[$table]['field info'][$fieldName]['display name'] = str_ireplace( '_id', '', $DATABASE_DEFINITION[$table]['field info'][$fieldName]['display name'] );
} // foreach
}
$DATABASE_DEFINITION['device_types']['field info']['system']['type'] = 'bool';
$DATABASE_DEFINITION['devices']['field info']['parent_id']['table alias'] = 'parent_device';
/*
select
devices.id "ID",
devices.serial_number "Serial Number",
devices.name "Name",
parent.name "Parent",
device_types.name "Device Type",
sites.name "Site",
owners.name "Owner",
devices.notes "Notes",
devices.created "Created",
devices.removed "Removed"
from
devices
left join sites on (devices.site_id = sites.id)
left join owners on (devices.owner_id=owners.id)
left join device_types on (devices.device_type_id = device_types.id)
left join devices parent on (devices.parent_id = parent.id)
where
devices.removed is null
and device_types.system = 1
and owners.id = 1;
*/
/*
$DATABASE_DEFINITION['devices']['queries'] = array(
'list' = array(
'fieldnames' => array('id','serial_number','name','parent_id','device_type_id','site_id','owner_id','notes','created','removed'),
'tables' => 'devices',
'where clause' => array(),
'order by' => array('name'),
),
'record' = array(
'fieldnames' => array('id','serial_number','name','parent_id','device_type_id','site_id','owner_id','notes','created','removed'),
'tables' => 'devices',
'where clause' => array(),
'order by' => array('name'),
),
);
*/
?>