phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] admin/inc/class.uilog.inc.php, 1.11


From: nomail
Subject: [Phpgroupware-cvs] admin/inc/class.uilog.inc.php, 1.11
Date: Thu, 30 Dec 2004 08:38:14 +0100

Update of /admin/inc
Modified Files:
        Branch: 
          class.uilog.inc.php

date: 2004/12/30 07:38:14;  author: skwashd;  state: Exp;  lines: +132 -261

Log Message:
new HEAD admin - sans GIFs
=====================================================================
Index: admin/inc/class.uilog.inc.php
diff -u admin/inc/class.uilog.inc.php:1.10 admin/inc/class.uilog.inc.php:1.11
--- admin/inc/class.uilog.inc.php:1.10  Sun May 18 19:18:39 2003
+++ admin/inc/class.uilog.inc.php       Thu Dec 30 07:38:14 2004
@@ -1,298 +1,169 @@
 <?php
-       
/***************************************************************************\
-       * phpGroupWare - uilog                                                  
    *
-       * http://www.phpgroupware.org                                           
    *
-       * Written by : jerry westrick address@hidden                          *
-       * -------------------------------------------------                     
    *
-       * 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.                                            
    *
-       
\***************************************************************************/
+       
/**************************************************************************\
+       * phpGroupWare - Administration                                         
   *
+       * http://www.phpgroupware.org                                           
   *
+       * --------------------------------------------                          
   *
+       *  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 $template;
                var $public_functions = array(
-                       'list_log' => True
+                       'list_log' => True,
+                       'purge_log' => True
                );
 
                function uilog()
                {
-                       $_cols    = $GLOBALS['HTTP_POST_VARS']['_cols'];
-                       $nocols   = $GLOBALS['HTTP_POST_VARS']['nocols'];
-                       $_delcol  = $GLOBALS['HTTP_POST_VARS']['_delcol'];
-                       $layout   = $GLOBALS['HTTP_POST_VARS']['layout'];
-                       $editable = $GLOBALS['HTTP_GET_VARS']['editable'];
-                       $modifytable = $GLOBALS['HTTP_GET_VARS']['modifytable'] 
? $GLOBALS['HTTP_GET_VARS']['modifytable'] : 
$GLOBALS['HTTP_POST_VARS']['modifytable'];
-
-                       $this->bolog    = CreateObject('admin.bolog',True);
-                       $this->html     = createobject('admin.html');
-                       $this->t        = 
CreateObject('phpgwapi.Template',$GLOBALS['phpgw']->common->get_tpl_dir('admin'));
-                       $this->lastid   = '';
-                       $this->editmode = False;
+                       if 
($GLOBALS['phpgw']->acl->check('error_log_access',1,'admin'))
+                       {
+                               $GLOBALS['phpgw']->redirect_link('/index.php');
+                       }
+                       
+                       $this->bo         = createobject('admin.bolog');
+                       $this->nextmatchs = createobject('phpgwapi.nextmatchs');
+                       $this->template   = $GLOBALS['phpgw']->template;
+                       $this->template->set_file(
+                               Array(
+                                       'errorlog' => 'errorlog_view.tpl',
+                                       'form_button' => 
'form_button_script.tpl'
+                               )
+                       );
+                       $this->template->set_block('errorlog','list');
+                       $this->template->set_block('errorlog','row');
+                       $this->template->set_block('errorlog','row_empty');
+               }
 
-                       // Handle the Edit Table Button
-                       if (isset($editable))
+               function list_log()
+               {
+                       if 
($GLOBALS['phpgw']->acl->check('error_log_access',1,'admin'))
+                       {
+                               $GLOBALS['phpgw']->redirect_link('/index.php');
+                       }
+                       
+                       $account_id = get_var('account_id',array('GET','POST'));
+                       $start = get_var('start',array('POST'),0);
+                       $sort = get_var('sort',array('POST'),0);
+                       $order = get_var('order',array('POST'),0);
+                       
+                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('Admin').' - '.lang('View error log');
+                       if ( $account_id )
                        {
-                               $this->editmode = $editable;
+                               $GLOBALS['phpgw_info']['flags']['app_header'] 
.= ' ' . lang('for') . ' ' . 
$GLOBALS['phpgw']->common->grab_owner_name($account_id);
                        }
+                       
+                       $GLOBALS['phpgw']->common->phpgw_header();
+                       echo parse_navbar();
 
-                       // Handle return from Modify Table form...
-                       if ($modifytable)
+                       $total_records = $this->bo->total($account_id);
+
+                       $var = Array(
+                               'th_bg'       => 
$GLOBALS['phpgw_info']['theme']['th_bg'],
+                               'nextmatchs_left'  => 
$this->nextmatchs->left('/index.php',$start,$total_records,'&menuaction=admin.uilog.list_log&account_id='
 . $account_id),
+                               'nextmatchs_right' => 
$this->nextmatchs->right('/index.php',$start,$total_records,'&menuaction=admin.uilog.list_log&account_id='
 . $account_id),
+                               'showing'          => 
$this->nextmatchs->show_hits($total_records,$start),
+                               'lang_loginid'     => lang('LoginID'),
+                               'lang_date'        => lang('time'),
+                               'lang_app'         => lang('module'),
+                               'lang_severity'    => lang('severity'),
+                               'lang_line'        => lang('line'),
+                               'lang_file'        => lang('file'),
+                               'lang_message'     => lang('log message'),
+                               'lang_total'       => lang('Total')
+                       );
+
+                       $this->template->set_var($var);
+
+                       $records = 
$this->bo->list_log($account_id,$start,$order,$sort);
+                       while (is_array($records) && list(,$record) = 
each($records))
                        {
-                               // the delete column must not be empty
-                               if (!isset($_delcol))
-                               {
-                                       $_delcol = array();
-                               }
+                               
$this->nextmatchs->template_alternate_row_color($this->template);
 
-                               // Build New fields_inc array...
-                               if (isset($_cols))
-                               {
-                                       $c = array();
-                                       for ($i=0;$i<count($_cols);$i++)
-                                       {
-                                               if (!in_array($i, $_delcol))
-                                               {
-                                                       $c[] = $_cols[$i];
-                                               }
-                                       }
-                                       $this->fields_inc = $c;
-                               }
+                               $var = array(
+                                       'row_date'              => 
$record['log_date'],
+                                       'row_loginid'   => 
$record['log_account_lid'],
+                                       'row_app'       => $record['log_app'],
+                                       'row_severity'  => 
$record['log_severity'],
+                                       'row_file'      => $record['log_file'],
+                                       'row_line'      => $record['log_line'],
+                                       'row_message'   => $record['log_msg'],
+                               );
+                               $this->template->set_var($var);
+                               $this->template->fp('rows_access','row',True);
+                       }
 
-                               // Reset Mode to display...
-                               $this->editmode = False;
-                               $this->layout = $layout;
-
-                               // Save the fields_inc values in Session and 
User Preferences...
-                               $data = 
array('fields_inc'=>$this->fields_inc,'layout'=>$layout);
-                               
$GLOBALS['phpgw']->session->appsession('session_data','log',$data);
-                               
$GLOBALS['phpgw']->preferences->read_repository();
-                               
$GLOBALS['phpgw']->preferences->delete('log','fields_inc');
-                               
$GLOBALS['phpgw']->preferences->add('log','fields_inc',$this->fields_inc);
-                               
$GLOBALS['phpgw']->preferences->delete('log','layout');
-                               
$GLOBALS['phpgw']->preferences->add('log','layout',$this->layout);
-                               
$GLOBALS['phpgw']->preferences->save_repository();
+                       if (! $total_records && $account_id)
+                       {
+                               
$this->nextmatchs->template_alternate_row_color($this->template);
+                               $this->template->set_var('row_message',lang('No 
error log records exist for this user'));
+                               
$this->template->fp('rows_access','row_empty',True);
                        }
 
-                       // Make sure that $this->fields_inc is filled
-                       if ( !isset($this->field_inc))
+                       if ( $total_records ) 
                        {
-                               // Need to fill from Session Data...
-                               $data = 
$GLOBALS['phpgw']->session->appsession('session_data','log');
-                               if (isset($data) && isset($data['fields_inc']))
+                               if ( $account_id ) 
                                {
-                                       $this->fields_inc = $data['fields_inc'];
-                                       $this->layout = $data['layout'];
+                                       $var = Array(
+                                               'submit_button' => 
lang('Submit'),
+                                               'action_url_button'     => 
$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uilog.purge_log&account_id='
 . $account_id),
+                                               'action_text_button'    => ' 
'.lang('Delete all log records for 
').$GLOBALS['phpgw']->common->grab_owner_name($account_id),
+                                               'action_confirm_button' => '',
+                                               'action_extra_field'    => ''
+                                       );
                                }
-                               else
+                               else 
                                {
-                                       
$GLOBALS['phpgw']->preferences->read_repository();
-                                       // Get From User Profile...
-                                       if 
(@$GLOBALS['phpgw_info']['user']['preferences']['log']['fields_inc'])
-                                       {
-                                               $fields_inc = 
$GLOBALS['phpgw_info']['user']['preferences']['log']['fields_inc'];
-                                               $this->fields_inc = $fields_inc;
-                                               $layout = 
$GLOBALS['phpgw_info']['user']['preferences']['log']['layout'];
-                                               $this->layout = $layout;
-                                               
$GLOBALS['phpgw']->session->appsession('session_data','log',array('fields_inc'=>$fields_inc,'layout'=>$layout));
-                                       }
-                                       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',
-                                                       'log_msg_file',
-                                                       'log_msg_line'
-                                               );
-                                               $this->layout[]= 
array(0,1,2,3,4,5,6,7,8,9);
-                                               $this->layout[]= 
array(0,1,2,3,4,5,6,7,10,11);
-
-                                               // Store defaults in session 
data...
-                                               
$GLOBALS['phpgw']->session->appsession(
-                                                       'session_data',
-                                                       'log',
-                                                       array(
-                                                               
'fields_inc'=>$this->fields_inc,
-                                                               
'layout'=>$this->layout
-                                                       )
-                                               );
-                                       }
+                                       $var = Array(
+                                               'submit_button' => 
lang('Submit'),
+                                               'action_url_button'     => 
$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uilog.purge_log'),
+                                               'action_text_button'    => ' 
'.lang('Delete all log records'),
+                                               'action_confirm_button' => '',
+                                               'action_extra_field'    => ''
+                                       );
                                }
+                               $this->template->set_var($var);
+                               $var['purge_log_button'] = 
$this->template->fp('button', 'form_button', True);
+                               $this->template->set_var($var);
+                       }
 
-                       } // Values already filled...
-                       reset($this->fields_inc);
-                       while(list($cno,$cname)=each($this->fields_inc))
+                       if ( $account_id ) 
                        {
-                               $this->column[$cname]=$cno;
+                               $var = Array(
+                                       'bg_color'     => 
$GLOBALS['phpgw_info']['themes']['bg_color'],
+                                       'footer_total' => lang('Total records') 
. ' ' . lang('for') . ' ' . 
$GLOBALS['phpgw']->common->grab_owner_name($account_id) . ': ' . $total_records 
+                               );
                        }
-               }
-
-               function list_log()
-               {
-                       if (False) // add some errors to the log...
+                       else
                        {
-                               // Test 1: single Error line immedeately to 
errorlog 
-                               // (could be type Debug, Info, Warning, or 
Error)
-                               
$GLOBALS['phpgw']->log->write(array('text'=>'I-TestWrite, write: 
%1','p1'=>'This message should appear in 
log','file'=>__FILE__,'line'=>__LINE__));
-
-                               // Test 2: A message should appear in log even 
if clearstack is called
-                               
$GLOBALS['phpgw']->log->message(array('text'=>'I-TestMsg, msg: %1','p1'=>'This 
message should appear in log','file'=>__FILE__,'line'=>__LINE__));
-                               
$GLOBALS['phpgw']->log->error(array('text'=>'I-TestInfo, info: %1','p1'=>'This 
Informational should not be in log','file'=>__FILE__,'line'=>__LINE__));
-                               $GLOBALS['phpgw']->log->clearstack();
-                               $GLOBALS['phpgw']->log->commit();  // commit 
error stack to log...
-
-                               // Test 3: one debug message
-                               
$GLOBALS['phpgw']->log->error(array('text'=>'D-Debug, dbg: %1','p1'=>'This 
debug statment should be in log','file'=>__FILE__,'line'=>__LINE__));
-                               $GLOBALS['phpgw']->log->commit();  // commit 
error stack to log...
-
-                               // Test 3: debug and one informational
-                               
$GLOBALS['phpgw']->log->error(array('text'=>'D-Debug, dbg: %1','p1'=>'This 
debug statment should be in log','file'=>__FILE__,'line'=>__LINE__));
-                               
$GLOBALS['phpgw']->log->error(array('text'=>'I-TestInfo, info: %1','p1'=>'This 
Informational should be in log','file'=>__FILE__,'line'=>__LINE__));
-                               $GLOBALS['phpgw']->log->commit();  // commit 
error stack to log...
-
-                               // Test 4: an informational and a Warning
-                               
$GLOBALS['phpgw']->log->error(array('text'=>'D-Debug, dbg: %1','p1'=>'This 
debug statment should be in log','file'=>__FILE__,'line'=>__LINE__));
-                               
$GLOBALS['phpgw']->log->error(array('text'=>'I-TestInfo, info: %1','p1'=>'This 
Informational should be in log','file'=>__FILE__,'line'=>__LINE__));
-                               
$GLOBALS['phpgw']->log->error(array('text'=>'W-TestWarn, warn: %1','p1'=>'This 
is a test Warning','file'=>__FILE__,'line'=>__LINE__));
-                               $GLOBALS['phpgw']->log->commit();  // commit 
error stack to log...
-
-                               // Test 5: and an error
-                               
$GLOBALS['phpgw']->log->error(array('text'=>'D-Debug, dbg: %1','p1'=>'This 
debug statment should be in log','file'=>__FILE__,'line'=>__LINE__));
-                               
$GLOBALS['phpgw']->log->error(array('text'=>'I-TestInfo, info: %1','p1'=>'This 
Informational should be in log','file'=>__FILE__,'line'=>__LINE__));
-                               
$GLOBALS['phpgw']->log->error(array('text'=>'W-TestWarn, warn: %1','p1'=>'This 
is a test Warning','file'=>__FILE__,'line'=>__LINE__));
-                               
$GLOBALS['phpgw']->log->error(array('text'=>'E-TestError, err: %1','p1'=>'This 
is a test Error','file'=>__FILE__,'line'=>__LINE__));
-                               $GLOBALS['phpgw']->log->commit();  // commit 
error stack to log...
-
-                               // Test 6: and finally a fatal...
-                               
$GLOBALS['phpgw']->log->error(array('text'=>'D-Debug, dbg: %1','p1'=>'This 
debug statment should be in log','file'=>__FILE__,'line'=>__LINE__));
-                               
$GLOBALS['phpgw']->log->error(array('text'=>'I-TestInfo, info: %1','p1'=>'This 
Informational should be in log','file'=>__FILE__,'line'=>__LINE__));
-                               
$GLOBALS['phpgw']->log->error(array('text'=>'W-TestWarn, warn: %1','p1'=>'This 
is a test Warning','file'=>__FILE__,'line'=>__LINE__));
-                               
$GLOBALS['phpgw']->log->error(array('text'=>'E-TestError, err: %1','p1'=>'This 
is a test Error','file'=>__FILE__,'line'=>__LINE__));
-                               
$GLOBALS['phpgw']->log->error(array('text'=>'F-Abend, abort: %1','p1'=>'Force 
abnormal termination','file'=>__FILE__,'line'=>__LINE__));
+                               $var = Array(
+                                       'bg_color'     => 
$GLOBALS['phpgw_info']['themes']['bg_color'],
+                                       'footer_total' => lang('Total records') 
. ': ' . $total_records
+                               );
                        }
-                       $this->t->set_file(array('log_list_t' => 'log.tpl'));
 
-                       // -------------------------- Layout Description 
-------------------------------
-                       $phycols = array('2%', '2%', '15%', '10%', '15%', '2%', 
'20%', '2%', '7%', '25%');
-                       // -------------------------- end Layout Description 
---------------------------
-
-                       // Get list of Possible Columns
-                       $header = $this->bolog->get_error_cols_e();
-
-                       // Describe table layout...
-                       $header['#phycols'] = $phycols;
-                       $header['#layout'] = $this->layout;
-
-                       // Set User Configured List of columns to show
-                       $header['_cols']= $this->fields_inc;
-
-                       // Set Table formating parameters
-                       $header['#table_parms']=array('width'=>"98%", 
'bgcolor'=>"000000", 'border'=>"0");
-
-                       // Set Header formating parameters
-                       $header['#head_parms']=array('bgcolor'=>"D3DCFF");
-
-                       // Column Log_ID
-                       $header['log_id']['#parms_hdr'] = 
array('align'=>"center");
-                       $header['log_id']['#title'] = 'Id';
-                       $header['log_id']['align'] = 'center';
-
-                       // Column Log_Severity
-                       $header['log_severity']['#parms_hdr'] = 
array('align'=>"center");
-                       $header['log_severity']['#title'] = 'S';
-                       $header['log_severity']['align'] = 'center';
-
-                       // Column Trans Date
-                       $header['log_date_e']['#title'] = 'Tans. Date';
-
-                       // Column Application
-                       $header['log_app']['#title'] = 'App.';
-
-                       // Column FullName
-                       $header['log_full_name']['#title'] = 'User';
-                       $header['log_full_name']['align'] = 'center';
-
-                       // Column log_msg_seq_no
-                       $header['log_msg_seq_no']['#parms_hdr'] = 
array('align'=>"center");
-                       $header['log_msg_seq_no']['#title'] = 'Sno';
-                       $header['log_msg_seq_no']['align'] = 'center';
-
-                       // Column log_msg_seq_no
-                       $header['log_msg_date_e']['#title'] = 'TimeStamp';
-                       $header['log_msg_severity']['#title'] = 'S';
-                       $header['log_msg_severity']['align'] = 'center';
-                       $header['log_msg_code']['#title'] = 'Code';
-                       $header['log_msg_text']['#title'] = 'Error Msg';
-                       $header['log_msg_file']['#title'] = 'File';
-                       $header['log_msg_line']['#title'] = 'Line';
-
-                       // 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);
-
-                       // Hack Get All Rows
-                       $rows = 
$this->bolog->get_error_e(array('orderby'=>array('log_id','log_msg_log_id')));
-                       $norows = count($rows);
-                       $header['_edittable']=$this->editmode;
-                       $table = $this->html->hash_table($rows,$header,$this, 
'format_row');
-                       $this->t->set_var('event_list',$table);
+                       // create the menu on the left, if needed
+                       $menuClass = CreateObject('admin.uimenuclass');
+                       $var['rows'] = 
$menuClass->createHTMLCode('view_account');
 
-                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('Admin').' - '.($this->editmode?lang('Edit Table format') : lang('View 
error log'));
-                       $GLOBALS['phpgw']->common->phpgw_header();
-                       $this->t->pfp('out','log_list_t');
-//                     $this->set_app_langs();
+                       $this->template->set_var($var);
+                       $this->template->pfp('out','list');
                }
-
-               function format_row($rno, $row)
+               
+               function purge_log()
                {
-                       switch($row['log_severity']['value'])
+                       if 
($GLOBALS['phpgw']->acl->check('error_log_access',1,'admin'))
                        {
-                               case 'D': $row['log_severity']['bgcolor'] = 
'D3DCFF'; break;
-                               case 'I': $row['log_severity']['bgcolor'] = 
'C0FFC0'; break;
-                               case 'W': $row['log_severity']['bgcolor'] = 
'FFFFC0'; break;
-                               case 'E': $row['log_severity']['bgcolor'] = 
'FFC0C0'; break;
-                               case 'F': $row['log_severity']['bgcolor'] = 
'FF0909'; break;
-                       }
-
-                       switch($row['log_msg_severity']['value'])
-                       {
-                               case 'D': $color = 'D3DCFF'; break;
-                               case 'I': $color = 'C0FFC0'; break;
-                               case 'W': $color = 'FFFFC0'; break;
-                               case 'E': $color = 'FFC0C0'; break;
-                               case 'F': $color = 'FF0909'; break;
-                       }
-                       reset($this->fields_inc);
-                       while(list($cno,$fld) = each($this->fields_inc))
-                       {
-                               if (substr($fld,0,7) == 'log_msg')
-                               {
-                                       $row[$fld]['bgcolor'] = $color;
-                               }
-                               else
-                               {
-//                                     $row[$cno]['bgcolor'] = $lcolor;
-                               }
+                               $GLOBALS['phpgw']->redirect_link('/index.php');
                        }
-                       return $row;
+                       $account_id = get_var('account_id',array('GET','POST'));
+                       $this->bo->purge_log($account_id);
+                       $this->list_log();
                }
+               
        }
-?>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]