<?php
/*
* HelpCORE source file
* ====================
*
* CVS:
* ----
* $header$
*
* Purpose:
* --------
* Mananages maintainance performed by the users
*
* Copyright:
* ----------
* Copyright (C) 2002-2003 Dennis Fleurbaaij <hide@address.com>
* Copyright (C) 2002-2005 IO Software <hide@address.com>
*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software Foundation;
* either version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this
* program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
* Cambridge, MA 02139, USA.
*
* Please note that this software is dual licensed. For the commercial use of this
* software you will need a Commercial License. Please see http://www.io-software.nl
* for the terms and conditions.
*
* For more information you can contact IO Software at http://www.io-software.nl
*/
if ( ! include( '../coreapm/coreapm.php' ) )
{
die( 'Cannot include CORE APM' );
}
include_once( 'uls_rights_functions.php' );
$GLOBALS['security']->secure();
$coreapm->start();
$db2 = new class_database();
//ULS
$uls_users_limiter = null;
$uls_organisations_limiter = null;
$uls_buildings_limiter = null;
$uls_rooms_limiter = null;
$uls_departments_limiter = null;
$uls_groups_limiter = null;
$uls_hardware_limiter = null;
$uls_hardware_access_ids = '';
$uls_manage_limiter = null;
if( O_RIGHTS_USERLEVELSECURITY && (! $GLOBALS['security']->is_admin) && (! $GLOBALS['security']->global_view) )
{
uls_secure_modify( 'hardware', 'read_ok', null, $uls_users_limiter, $uls_organisations_limiter, $uls_buildings_limiter, $uls_rooms_limiter, $uls_departments_limiter, $uls_groups_limiter, $uls_hardware_limiter );
$uls_sql = uls_secure_show( 'hardware', $uls_manage_limiter, '', true );
// Select hardware which can be shown
$GLOBALS['db']->query( 'SELECT id FROM hardware WHERE ' . $uls_sql );
while( ( $row = $GLOBALS['db']->fetch_array() ) )
{
$uls_hardware_access_ids .= $row['id'] . ',';
}
// Check if available
if( $uls_hardware_access_ids == '' ) {
$uls_hardware_access_ids = '0,';
}
// Create where
$uls_manage_limiter = OBLIGATORY_WHERE( array( 'hardware_id' , 'in', '(' . substr( $uls_hardware_access_ids, 0, -1 ) . ')' ) );
}
if( ! USE_MAINTAINANCE ) {
$GLOBALS['box']->add( text('warning'), text('administrator_disabled') );
$coreapm->finish();
die;
}
/**
* Show the location of the maintainance history element
*/
function maint_hist_show_location( $value, $row )
{
global $db2;
if( $row['hardware_id'] == '' ) {
return '';
}
$db2->query( 'SELECT organisation.id AS organisation_id,
organisation.name AS organisation_name,
buildings.id AS building_id,
buildings.name AS building_name,
rooms.id AS room_id,
rooms.name AS room_name
FROM hardware
LEFT JOIN organisation ON ( organisation.id = hardware.organisation_id )
LEFT JOIN buildings ON ( buildings.id = hardware.building_id )
LEFT JOIN rooms ON ( rooms.id = hardware.rooms_id )
WHERE hardware.id='. $row['hardware_id'] );
if( ( $row = $db2->fetch_array() ) == null ) {
return "";
}
$return = '';
if( $row['organisation_id'] != '' ) {
$name = htmlentities( $row['organisation_name'], ENT_COMPAT, CHARSET );
$return .= '<a href="'.BASE_THIS_DIR.'/organisation.php?organisationaction=show&organisationshowid='.$row['organisation_id'].'">'.
'<img src="'.BASE_URL.'images/organisation_tiny.gif" border="0" alt="'.$name.'" />'.$name.'</a><br />';
}
if( $row['building_id'] != '' ) {
$name = htmlentities( $row['building_name'], ENT_COMPAT, CHARSET );
$return .= '<a href="'.BASE_THIS_DIR.'/buildings.php?buildingsaction=show&buildingsshowid='.$row['building_id'].'">'.
'<img src="'.BASE_URL.'images/building_tiny.gif" border="0" alt="'.$name.'" />'.$name.'</a><br />';
}
if( $row['room_id'] != '' ) {
$name = htmlentities( $row['room_name'], ENT_COMPAT, CHARSET );
$return .= '<a href="'.BASE_THIS_DIR.'/rooms.php?roomsaction=show&roomsshowid='.$row['room_id'].'">'.
'<img src="'.BASE_URL.'images/room_tiny.gif" border="0" alt="'.$name.'" />'.$name.'</a><br />';
}
// Strip last <br />
return substr( $return, 0, -6 );
}
// $GLOBALS['relational']->auto_insert_array['maintainer_id'] = $GLOBALS['security']->userid;
$GLOBALS['relational']->add_table_column( 'date_maintained', text( 'date_maintained' ), TYPE_DATE | REL_OBLIGATORY | OTH_DEFAULT( array_to_db_time( array( date( 'd' ), date( 'm' ), date( 'Y' ), date( 'H' ), date( 'i' ), date( 's' ) ) ) ) );
$GLOBALS['relational']->add_table_column( 'hardware_id', text( 'hardware' ), TYPE_SEARCH_JOIN( 'hardware', 'name', $uls_hardware_limiter ) | REL_OBLIGATORY );
if( $uls_users_limiter != null ) {
$uls_users_limiter[2] .= ' AND may_log_in='.database_boolean( true );
}
else {
$uls_users_limiter = array( 'may_log_in', '=', database_boolean( true ) );
}
$GLOBALS['relational']->add_table_column( 'maintainer_id', text( 'maint_guy' ), TYPE_SEARCH_JOIN( 'users', 'surname,middlename,firstname', $uls_users_limiter ) | REL_OBLIGATORY | OTH_DEFAULT( $GLOBALS['security']->userid ) );
$GLOBALS['relational']->add_table_column( 'time_used', text( 'time_taken' ), TYPE_INTEGER() | REL_OBLIGATORY | OTH_DEFAULT( 0 ) | ADD_OPTION( text( 'minutes' ) ) );
if( O_MAINT_FINISHED_SHOW_LOCATION ) {
$GLOBALS['relational']->add_table_column( '', text( 'location' ), NOT_IN_TABLE | INLINE_FUNCTION( 'maint_hist_show_location' ) );
}
$GLOBALS['relational']->add_table_column( 'description', text( 'description' ), TYPE_TEXT( 2000 ) );
$GLOBALS['relational']->manage( 'maint_hist', text( 'maint_hist' ), $uls_manage_limiter );
$coreapm->finish();
?>