<?php
/*
* HelpCORE source file
* ====================
*
* CVS:
* ----
* $header$
*
* Purpose:
* --------
* Brands callbacks
*
* 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
*/
// Only load if CoreAPM is loaded
if( ! isset( $GLOBALS['coreapm'] ) ) {
die( __FILE__ . '('.__LINE__.'): CoreAPM not set' );
}
/**
* Callback function for CoreAPM to remove all links with this brand after it has been deleted
*/
function brands_post_delete( $table_name, $id, &$message )
{
$db2 = new class_database;
$GLOBALS['db']->query( 'UPDATE hardware SET nc_brand_id=NULL WHERE nc_brand_id='.$id );
// Config files
include_once( 'configuration_functions.php' );
$GLOBALS['db']->query( 'SELECT name FROM hardware_types' );
while ( $row = $GLOBALS['db']->fetch_array() )
{
$name = $row['name'];
$work_name = secure_name( $row['name'] );
// check if the config exists, and link to the correct page
if ( file_exists( 'config_' . $work_name . '.php' ) )
{
$db2->query( 'UPDATE config_'.$work_name.' SET brands_id=NULL WHERE brands_id='.$id );
}
}
return true;
}
$GLOBALS['coreapm']->plugin_register_relational_callback( 'brands', 'post_delete', 'brands_post_delete' );
/**
* Here due to weird errorreport ( occurred only once ever )
*/
function brands_post_update( $table_name, $id, &$message ) { return true; }
$GLOBALS['coreapm']->plugin_register_relational_callback( 'brands', 'post_update', 'brands_post_update' );
?>