egroupware/admin/inc/class.uilog.inc.php

259 lines
8.0 KiB
PHP
Raw Normal View History

2001-08-05 08:48:42 +02:00
<?php
/***************************************************************************\
* phpGroupWare - uilog *
* http://www.phpgroupware.org *
* Written by : jerry westrick [jerry@westrick.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. *
\***************************************************************************/
/* $Id$ */
class uilog
{
var $grants;
var $cat_id;
var $start;
var $search;
var $filter;
var $public_functions = array
(
'list_log' => True
);
function uilog()
{
global $phpgw, $_cols, $editable, $modifytable, $nocols, $_delcol, $phpgw_info;
$this->bolog = CreateObject('admin.bolog',True);
$this->html = createobject('admin.html');
$this->t = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('admin'));
$this->lastid = "";
$this->editmode = false;
2001-08-06 18:51:44 +02:00
// nextmatchs
$this->start = 0;
$this->nextmatchs = CreateObject('phpgwapi.nextmatchs');
2001-08-05 08:48:42 +02:00
// Handle the Edit Table Button
if (isset($editable))
{
$this->editmode = $editable;
};
// Handle return from Modify Table form...
if (isset($modifytable))
{
// the delete column must not be empty
if (!isset($_delcol))
{
$_delcol = array();
};
// Build New fields_inc array...
if (isset($_cols))
{
$c = array();
for ($i=0;$i<$nocols;$i++)
{
if (!in_array($i, $_delcol))
{
$c[] = $_cols[$i];
};
}
$this->fields_inc = $c;
};
// Reset Mode to display...
$this->editmode = false;
// Save the fields_inc values in Session and User Preferences...
$data = array('fields_inc'=>$this->fields_inc);
$phpgw->session->appsession('session_data','log',$data);
$phpgw->preferences->read_repository();
$phpgw->preferences->delete('log','fields_inc');
$phpgw->preferences->add('log','fields_inc',$this->fields_inc);
$phpgw->preferences->save_repository();
}
// Make sure that $this->fields_inc is filled
if ( !isset($this->field_inc))
{
// Need to fill from Session Data...
$data = $phpgw->session->appsession('session_data','log');
if (isset($data) && isset($data['fields_inc']))
{
$this->fields_inc = $data['fields_inc'];
}
else
{
$phpgw->preferences->read_repository();
// Get From User Profile...
if (@$phpgw_info['user']['preferences']['log']['fields_inc'])
{
$fields_inc = $phpgw_info['user']['preferences']['log']['fields_inc'];
$this->fields_inc = $fields_inc;
$phpgw->session->appsession('session_data','log',array('fields_inc',$fields_inc));
}
else
{
// Use defaults...
$this->fields_inc = array ('log_severity',
'log_id',
'log_date_e',
'log_app',
'log_full_name',
'log_msg_seq_no',
'log_msg_date_e',
'log_msg_severity',
'log_msg_code',
'log_msg_text'
);
// Store defaults in session data...
$phpgw->session->appsession ('session_data',
'log',
array ('fields_inc'
=>$this->fields_inc
)
);
}
}
} // Values already filled...
2001-08-06 18:51:44 +02:00
reset($this->fields_inc);
while(list($cno,$cname)=each($this->fields_inc))
{
$this->column[$cname]=$cno;
};
2001-08-05 08:48:42 +02:00
}
function list_log()
{
global $phpgw, $phpgw_info;
/*
2001-08-06 18:51:44 +02:00
$phpgw->log->write('I-TestWrite, write: %1','This message should appear in log');
2001-08-05 08:48:42 +02:00
$phpgw->log->message('I-TestMsg, msg: %1','This message should appear in log');
$phpgw->log->error('I-TestInfo, info: %1','This Informational should not be in log');
$phpgw->log->clearstack();
$phpgw->log->error('I-TestInfo, info: %1','This Informational should be in log');
$phpgw->log->error('W-TestWarn, warn: %1','This is a test Warning');
$phpgw->log->error('E-TestError, err: %1','This is a test Error');
2001-08-06 18:51:44 +02:00
//$phpgw->log->error('F-Abend, abort: %1','Force abnormal termination');
2001-08-05 08:48:42 +02:00
$phpgw->log->commit(); // commit error stack to log...
*/
$this->t->set_file(array('log_list_t' => 'log.tpl'));
2001-08-06 18:51:44 +02:00
/*
// --------------------------------- nextmatch ---------------------------
$left = $this->nextmatchs->left('/admin/log.php',$this->start,$this->this->total_records,'&menuaction=admin.uilog.list_log');
$right = $this->nextmatchs->right('/admin/log.php',$this->start,$this->this->total_records,'&menuaction=admin.uilog.list_log');
$this->t->set_var('left',$left);
$this->t->set_var('right',$right);
2001-08-05 08:48:42 +02:00
2001-08-06 18:51:44 +02:00
$this->t->set_var('search_log',$this->nextmatchs->show_hits($this->bolog->total_records,$this->start));
// -------------------------- end nextmatch ------------------------------------
*/
2001-08-05 08:48:42 +02:00
// Get list of Possible Columns
$header = $this->bolog->get_error_cols_e();
// Set Table formating parameters
2001-08-05 12:23:11 +02:00
$header['_table_parms']='width="98%", bgcolor="D3DCFF" border="0"';
2001-08-05 08:48:42 +02:00
// Set User Configured List of columns to show
$header['_cols']= $this->fields_inc;
// Column Log_ID
$header['log_id']['parms_hdr'] = 'align="center", width="2%"';
$header['log_id']['title'] = 'Id';
$header['log_id']['parms'] = 'align="center"';
// Column Log_Severity
$header['log_severity']['parms_hdr'] = 'align="center", width="2%"';
$header['log_severity']['title'] = 'S';
$header['log_severity']['parms'] = 'align="center"';
// Column Trans Date
$header['log_date_e']['title'] = 'Tans. Date';
$header['log_date_e']['parms'] = '';
// Column Application
$header['log_app']['title'] = 'Application';
$header['log_app']['parms'] = '';
// Column FullName
$header['log_full_name']['title'] = 'User';
$header['log_full_name']['parms'] = 'align="center"';
// Column log_msg_seq_no
$header['log_msg_seq_no']['parms_hdr'] = 'align="center"';
$header['log_msg_seq_no']['title'] = 'Sno';
$header['log_msg_seq_no']['parms'] = 'align="center"';
// Column log_msg_seq_no
$header['log_msg_date_e']['title'] = 'TimeStamp';
$header['log_msg_severity']['title'] = 'S';
$header['log_msg_code']['title'] = 'Code';
$header['log_msg_text']['title'] = 'Error Msg';
2001-08-06 18:51:44 +02:00
// Set up Grouping, Suppression...
$header['_groupby']=array('log_id'=>1);
$header['_supres']=array('log_id'=>1,'log_severity'=>1,'log_date_e'=>1,'log_app'=>1,'log_full_name'=>1);
2001-08-05 08:48:42 +02:00
// Hack Get All Rows
$rows = $this->bolog->get_error_e(array('orderby'=>array('log_id','log_msg_log_id')));
2001-08-06 18:51:44 +02:00
$norows = count($rows);
2001-08-05 08:48:42 +02:00
$header['_edittable']=$this->editmode;
$table = $this->html->hash_table($rows,$header,$this, 'format_row');
$this->t->set_var('event_list',$table);
$this->t->pfp('out','log_list_t');
$phpgw->common->phpgw_footer();
// $this->set_app_langs();
}
function format_row($rno, $row)
{
2001-08-06 18:51:44 +02:00
switch($row[$this->column['log_severity']]['value'])
2001-08-05 08:48:42 +02:00
{
2001-08-06 18:51:44 +02:00
case 'I': $row[$this->column['log_severity']]['bgcolor'] = 'C0FFC0'; break;
case 'W': $row[$this->column['log_severity']]['bgcolor'] = 'FFFFC0'; break;
case 'E': $row[$this->column['log_severity']]['bgcolor'] = 'FFC0C0'; break;
case 'F': $row[$this->column['log_severity']]['bgcolor'] = 'FF0909'; break;
2001-08-05 08:48:42 +02:00
}
2001-08-06 18:51:44 +02:00
switch($row[$this->column['log_msg_severity']]['value'])
2001-08-05 08:48:42 +02:00
{
case 'I': $color = 'C0FFC0'; break;
case 'W': $color = 'FFFFC0'; break;
case 'E': $color = 'FFC0C0'; break;
case 'F': $color = 'FF0909'; break;
}
reset($this->fields_inc);
2001-08-06 18:51:44 +02:00
while(list($cno,$fld) = each($this->fields_inc))
2001-08-05 08:48:42 +02:00
{
if (substr($fld,0,7) == 'log_msg')
{
2001-08-06 18:51:44 +02:00
$row[$cno]['bgcolor'] = $color;
2001-08-05 08:48:42 +02:00
}
else
{
2001-08-06 18:51:44 +02:00
// $row[$cno]['bgcolor'] = $lcolor;
}
2001-08-05 08:48:42 +02:00
}
return $row;
}
}
?>