<?php
/*
* HelpCORE source file
* ====================
*
* CVS:
* ----
* $header$
*
* Purpose:
* --------
* Main file of helpcore, "home"
*
* 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');
}
$GLOBALS['security']->secure();
include_once( 'uls_rights_functions.php' );
$coreapm->start();
$db2 = new class_database;
$incidents_limiter = '';
$users_uls_limiter = $organisations_uls_limiter = $buildings_uls_limiter = $rooms_uls_limiter = $departments_uls_limiter = $groups_uls_limiter = $hardware_uls_limiter = null;
if( ! uls_secure_modify( 'incidents', 'read_ok', null, $users_uls_limiter, $organisations_uls_limiter, $buildings_uls_limiter, $rooms_uls_limiter, $departments_uls_limiter, $groups_uls_limiter, $hardware_uls_limiter ) )
$incidents_limiter = ' AND ( incidents.rooms_id ' . $rooms_uls_limiter[1] . ' ' . $rooms_uls_limiter[2] . ' OR incidents.building_id ' . $buildings_uls_limiter[1] . ' ' . $buildings_uls_limiter[2] . ' OR incidents.organisation_id ' . $organisations_uls_limiter[1] . ' ' . $organisations_uls_limiter[2] . ' OR incidents.group_id ' . $groups_uls_limiter[1] . ' ' . $groups_uls_limiter[2] . ' OR incidents.department_id ' . $departments_uls_limiter[1] . ' ' . $departments_uls_limiter[2] .' ) ';
echo "<table border=\"0\" width=\"94%\">\n";
echo '<tr><td valign="top" width="50%">';
$GLOBALS['box']->add( '', text( 'helpcore_welcome' ) );
// Global system messages
$table = new class_table;
$table->table_columns = 4;
$GLOBALS['db']->query('SELECT name,
text,
expected_finish_date,
start_date
FROM known_problems
WHERE finish_date = 0
AND level >= '.$GLOBALS['security']->userlevel.'
ORDER BY finish_date DESC ' );
if( $GLOBALS['db']->num_rows() == 0 ) {
$table->add_header_line( text('none_found') );
}
else {
$table->add_header_row( array( text('name'), text('started'), text('expected_finish') ) );
while( $row = $GLOBALS['db']->fetch_array( ) )
{
$table->add_row( array( $row['name'], db_to_human_time($row['start_date']), db_to_human_time($row['expected_finish_date']) ) );
$table->add_line( nl2br( $row['text'] ) );
}
}
$table->add_header_line( '<a href="known_problems.php?known_problemsaction=add">'.text('add').'</a>');
$GLOBALS['box']->add( text('announcements'), $table->finish() );
echo '</td><td width="100" nowrap> </td><td valign="top" rowspan="2" width="50%">';
if( O_INC_INCIDENTSONMAINPAGE ) {
// Show incidents that are new or altered
$table = new class_table;
$table->table_columns = 4;
$GLOBALS['db']->query('SELECT incidents.id AS id,
incidents.desc_small AS desc_small,
incidents.date_laststatuschange AS altered,
incidents.date_reported AS reported,
incidents.status_id as status,
incidents.priorities_id as priority,
incidents.incidentcategories_id as category,
seen_incidents.date_seen AS lastseen
FROM incidents
LEFT JOIN seen_incidents ON ( incidents.id = seen_incidents.incident_id AND seen_incidents.user_id='.$GLOBALS['security']->userid.' )
WHERE ( incidents.date_laststatuschange >= seen_incidents.date_seen
OR seen_incidents.date_seen IS NULL )
'.$incidents_limiter.'
ORDER BY incidents.id DESC
LIMIT 20' );
if( $GLOBALS['db']->num_rows() == 0 ) {
$table->add_header_line( text('none_found') );
}
else {
$table->add_header_row( array( '', '#', text('desc_small'), text('date_status_change') ) );
while( $row = $GLOBALS['db']->fetch_array( ) )
{
$image = '';
if( $row['lastseen'] == '' ) {
$image = '<img alt="'.text('new').'" src="'.BASE_URL.'images/new_small.gif" width="16" height="16" />';
}
// If not yet altered, show started
if( $row['altered'] == '0000-00-00 00:00:00' ) $row['altered'] = $row['reported'];
// Determine if this incident is public or not
if( ($row['status']=='') || ($row['priority']=='') ) {
$table->add_row( array( $image, '<a href="incidents_public.php?incidentsaction=show&incidentsshowid='.$row['id'].'">' . $row['id'] . '</a>', $row['desc_small'], $row['altered'] ) );
}
else {
$table->add_row( array( $image, '<a href="incidents.php?incidentsaction=show&incidentsshowid='.$row['id'].'">' . $row['id'] . '</a>', $row['desc_small'], $row['altered'] ) );
}
}
}
$table->add_header_line( '<a href="incidents.php?incidentsaction=add">'.text('add').'</a>');
$GLOBALS['box']->add( text( 'altered_incidents' ), $table->finish() );
}
echo '<br /> </td></tr><tr><td valign="top">';
// Show all subscriptions to information
if( isset( $_GET['informtable_name'] ) && isset( $_GET['informtable_id'] ) ) {
$GLOBALS['db']->query( 'DELETE FROM inform WHERE table_name=\''.$_GET['informtable_name'].'\' AND table_id='.$_GET['informtable_id'].' AND user_id='.$GLOBALS['security']->userid );
}
$table = new class_table;
$table->table_columns = 4;
$GLOBALS['db']->query('SELECT inform.table_name AS table_name,
inform.table_id AS table_id,
incidents.desc_small AS incidentdesc
FROM inform
LEFT JOIN incidents ON ( incidents.id = inform.table_id )
WHERE inform.user_id='.$GLOBALS['security']->userid );
if( $GLOBALS['db']->num_rows() == 0 ) {
$table->add_header_line( text('none_found') );
}
else {
$table->add_header_row( array( text('type'), '#', text('name'), text('action') ) );
while( $row = $GLOBALS['db']->fetch_array( ) )
{
switch( $row['table_name'] ) {
case 'incidents':
$name = '<a href="incidents.php?incidentsaction=show&incidentsshowid='.$row['table_id'].'">'.$row['incidentdesc'].'</a>';
$type = '<a href="incidents.php">'.text('incidents').'</a>';
break;
default:
__FATAL__( __FILE__, __LINE__, __CLASS__, __FUNCTION__, 'Unknown table name: "'.$table_name.'"' );
break;
}
$table->add_row( array( $type, $row['table_id'], $name, '<a href="main.php?informtable_name='.$row['table_name'].'&informtable_id='.$row['table_id'].'"><img src="' . BASE_URL . 'images/inform_off_small.gif" border="0" alt="'.text('inform_off').'" /></a>' ) );
}
}
$GLOBALS['box']->add( text( 'inform' ), $table->finish() );
echo '</td><td width="100" nowrap> </td><td valign="top" rowspan="2" width="50%">';
echo "</td></tr></table>\n";
$coreapm->finish();
?>