| [ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 /***************************************************************************\ 3 * eGroupWare - uilog * 4 * http://www.egroupware.org * 5 * Written by : jerry westrick [jerry@westrick.com] * 6 * ------------------------------------------------- * 7 * This program is free software; you can redistribute it and/or modify it * 8 * under the terms of the GNU General Public License as published by the * 9 * Free Software Foundation; either version 2 of the License, or (at your * 10 * option) any later version. * 11 \***************************************************************************/ 12 13 /* $Id: class.uilog.inc.php 20295 2006-02-15 12:31:25Z $ */ 14 15 class uilog 16 { 17 var $grants; 18 var $cat_id; 19 var $start; 20 var $search; 21 var $filter; 22 23 var $public_functions = array( 24 'list_log' => True 25 ); 26 27 function uilog() 28 { 29 if ($GLOBALS['egw']->acl->check('error_log_access',1,'admin')) 30 { 31 $GLOBALS['egw']->redirect_link('/index.php'); 32 } 33 34 $_cols = $_POST['_cols']; 35 $nocols = $_POST['nocols']; 36 $_delcol = $_POST['_delcol']; 37 $layout = $_POST['layout']; 38 $editable = $_GET['editable']; 39 $modifytable = $_GET['modifytable'] ? $_GET['modifytable'] : $_POST['modifytable']; 40 41 $this->bolog =& CreateObject('admin.bolog',True); 42 $this->html =& CreateObject('admin.html_tables'); 43 $this->t =& CreateObject('phpgwapi.Template',$GLOBALS['egw']->common->get_tpl_dir('admin')); 44 $this->lastid = ''; 45 $this->editmode = False; 46 47 // Handle the Edit Table Button 48 if (isset($editable)) 49 { 50 $this->editmode = $editable; 51 } 52 53 // Handle return from Modify Table form... 54 if ($modifytable) 55 { 56 // the delete column must not be empty 57 if (!isset($_delcol)) 58 { 59 $_delcol = array(); 60 } 61 62 // Build New fields_inc array... 63 if (isset($_cols)) 64 { 65 $c = array(); 66 for ($i=0;$i<count($_cols);$i++) 67 { 68 if (!in_array($i, $_delcol)) 69 { 70 $c[] = $_cols[$i]; 71 } 72 } 73 $this->fields_inc = $c; 74 } 75 76 // Reset Mode to display... 77 $this->editmode = False; 78 $this->layout = $layout; 79 80 // Save the fields_inc values in Session and User Preferences... 81 $data = array('fields_inc'=>$this->fields_inc,'layout'=>$layout); 82 $GLOBALS['egw']->session->appsession('session_data','log',$data); 83 $GLOBALS['egw']->preferences->read_repository(); 84 $GLOBALS['egw']->preferences->delete('log','fields_inc'); 85 $GLOBALS['egw']->preferences->add('log','fields_inc',$this->fields_inc); 86 $GLOBALS['egw']->preferences->delete('log','layout'); 87 $GLOBALS['egw']->preferences->add('log','layout',$this->layout); 88 $GLOBALS['egw']->preferences->save_repository(); 89 } 90 91 // Make sure that $this->fields_inc is filled 92 if ( !isset($this->field_inc)) 93 { 94 // Need to fill from Session Data... 95 $data = $GLOBALS['egw']->session->appsession('session_data','log'); 96 if (isset($data) && isset($data['fields_inc'])) 97 { 98 $this->fields_inc = $data['fields_inc']; 99 $this->layout = $data['layout']; 100 } 101 else 102 { 103 $GLOBALS['egw']->preferences->read_repository(); 104 // Get From User Profile... 105 if (@$GLOBALS['egw_info']['user']['preferences']['log']['fields_inc']) 106 { 107 $fields_inc = $GLOBALS['egw_info']['user']['preferences']['log']['fields_inc']; 108 $this->fields_inc = $fields_inc; 109 $layout = $GLOBALS['egw_info']['user']['preferences']['log']['layout']; 110 $this->layout = $layout; 111 $GLOBALS['egw']->session->appsession('session_data','log',array('fields_inc'=>$fields_inc,'layout'=>$layout)); 112 } 113 else 114 { 115 // Use defaults... 116 $this->fields_inc = array( 117 'log_severity', 118 'log_id', 119 'log_date_e', 120 'log_app', 121 'log_full_name', 122 'log_msg_seq_no', 123 'log_msg_date_e', 124 'log_msg_severity', 125 'log_msg_code', 126 'log_msg_text', 127 'log_msg_file', 128 'log_msg_line' 129 ); 130 $this->layout[]= array(0,1,2,3,4,5,6,7,8,9); 131 $this->layout[]= array(0,1,2,3,4,5,6,7,10,11); 132 133 // Store defaults in session data... 134 $GLOBALS['egw']->session->appsession( 135 'session_data', 136 'log', 137 array( 138 'fields_inc'=>$this->fields_inc, 139 'layout'=>$this->layout 140 ) 141 ); 142 } 143 } 144 145 } // Values already filled... 146 reset($this->fields_inc); 147 while(list($cno,$cname)=each($this->fields_inc)) 148 { 149 $this->column[$cname]=$cno; 150 } 151 } 152 153 function list_log() 154 { 155 if (False) // add some errors to the log... 156 { 157 // Test 1: single Error line immedeately to errorlog 158 // (could be type Debug, Info, Warning, or Error) 159 $GLOBALS['egw']->log->write(array('text'=>'I-TestWrite, write: %1','p1'=>'This message should appear in log','file'=>__FILE__,'line'=>__LINE__)); 160 161 // Test 2: A message should appear in log even if clearstack is called 162 $GLOBALS['egw']->log->message(array('text'=>'I-TestMsg, msg: %1','p1'=>'This message should appear in log','file'=>__FILE__,'line'=>__LINE__)); 163 $GLOBALS['egw']->log->error(array('text'=>'I-TestInfo, info: %1','p1'=>'This Informational should not be in log','file'=>__FILE__,'line'=>__LINE__)); 164 $GLOBALS['egw']->log->clearstack(); 165 $GLOBALS['egw']->log->commit(); // commit error stack to log... 166 167 // Test 3: one debug message 168 $GLOBALS['egw']->log->error(array('text'=>'D-Debug, dbg: %1','p1'=>'This debug statment should be in log','file'=>__FILE__,'line'=>__LINE__)); 169 $GLOBALS['egw']->log->commit(); // commit error stack to log... 170 171 // Test 3: debug and one informational 172 $GLOBALS['egw']->log->error(array('text'=>'D-Debug, dbg: %1','p1'=>'This debug statment should be in log','file'=>__FILE__,'line'=>__LINE__)); 173 $GLOBALS['egw']->log->error(array('text'=>'I-TestInfo, info: %1','p1'=>'This Informational should be in log','file'=>__FILE__,'line'=>__LINE__)); 174 $GLOBALS['egw']->log->commit(); // commit error stack to log... 175 176 // Test 4: an informational and a Warning 177 $GLOBALS['egw']->log->error(array('text'=>'D-Debug, dbg: %1','p1'=>'This debug statment should be in log','file'=>__FILE__,'line'=>__LINE__)); 178 $GLOBALS['egw']->log->error(array('text'=>'I-TestInfo, info: %1','p1'=>'This Informational should be in log','file'=>__FILE__,'line'=>__LINE__)); 179 $GLOBALS['egw']->log->error(array('text'=>'W-TestWarn, warn: %1','p1'=>'This is a test Warning','file'=>__FILE__,'line'=>__LINE__)); 180 $GLOBALS['egw']->log->commit(); // commit error stack to log... 181 182 // Test 5: and an error 183 $GLOBALS['egw']->log->error(array('text'=>'D-Debug, dbg: %1','p1'=>'This debug statment should be in log','file'=>__FILE__,'line'=>__LINE__)); 184 $GLOBALS['egw']->log->error(array('text'=>'I-TestInfo, info: %1','p1'=>'This Informational should be in log','file'=>__FILE__,'line'=>__LINE__)); 185 $GLOBALS['egw']->log->error(array('text'=>'W-TestWarn, warn: %1','p1'=>'This is a test Warning','file'=>__FILE__,'line'=>__LINE__)); 186 $GLOBALS['egw']->log->error(array('text'=>'E-TestError, err: %1','p1'=>'This is a test Error','file'=>__FILE__,'line'=>__LINE__)); 187 $GLOBALS['egw']->log->commit(); // commit error stack to log... 188 189 // Test 6: and finally a fatal... 190 $GLOBALS['egw']->log->error(array('text'=>'D-Debug, dbg: %1','p1'=>'This debug statment should be in log','file'=>__FILE__,'line'=>__LINE__)); 191 $GLOBALS['egw']->log->error(array('text'=>'I-TestInfo, info: %1','p1'=>'This Informational should be in log','file'=>__FILE__,'line'=>__LINE__)); 192 $GLOBALS['egw']->log->error(array('text'=>'W-TestWarn, warn: %1','p1'=>'This is a test Warning','file'=>__FILE__,'line'=>__LINE__)); 193 $GLOBALS['egw']->log->error(array('text'=>'E-TestError, err: %1','p1'=>'This is a test Error','file'=>__FILE__,'line'=>__LINE__)); 194 $GLOBALS['egw']->log->error(array('text'=>'F-Abend, abort: %1','p1'=>'Force abnormal termination','file'=>__FILE__,'line'=>__LINE__)); 195 } 196 $this->t->set_file(array('log_list_t' => 'log.tpl')); 197 198 // -------------------------- Layout Description ------------------------------- 199 $phycols = array('2%', '2%', '15%', '10%', '15%', '2%', '20%', '2%', '7%', '25%'); 200 // -------------------------- end Layout Description --------------------------- 201 202 // Get list of Possible Columns 203 $header = $this->bolog->get_error_cols_e(); 204 205 // Describe table layout... 206 $header['#phycols'] = $phycols; 207 $header['#layout'] = $this->layout; 208 209 // Set User Configured List of columns to show 210 $header['_cols']= $this->fields_inc; 211 212 // Set Table formating parameters 213 $header['#table_parms']=array('width'=>"98%", 'bgcolor'=>"#000000", 'border'=>"0"); 214 215 // Set Header formating parameters 216 $header['#head_parms']=array('bgcolor'=>"#D3DCFF"); 217 218 // Column Log_ID 219 $header['log_id']['#parms_hdr'] = array('align'=>"center"); 220 $header['log_id']['#title'] = 'Id'; 221 $header['log_id']['align'] = 'center'; 222 223 // Column Log_Severity 224 $header['log_severity']['#parms_hdr'] = array('align'=>"center"); 225 $header['log_severity']['#title'] = 'S'; 226 $header['log_severity']['align'] = 'center'; 227 228 // Column Trans Date 229 $header['log_date_e']['#title'] = 'Tans. Date'; 230 231 // Column Application 232 $header['log_app']['#title'] = 'App.'; 233 234 // Column FullName 235 $header['log_full_name']['#title'] = 'User'; 236 $header['log_full_name']['align'] = 'center'; 237 238 // Column log_msg_seq_no 239 $header['log_msg_seq_no']['#parms_hdr'] = array('align'=>"center"); 240 $header['log_msg_seq_no']['#title'] = 'Sno'; 241 $header['log_msg_seq_no']['align'] = 'center'; 242 243 // Column log_msg_seq_no 244 $header['log_msg_date_e']['#title'] = 'TimeStamp'; 245 $header['log_msg_severity']['#title'] = 'S'; 246 $header['log_msg_severity']['align'] = 'center'; 247 $header['log_msg_code']['#title'] = 'Code'; 248 $header['log_msg_text']['#title'] = 'Error Msg'; 249 $header['log_msg_file']['#title'] = 'File'; 250 $header['log_msg_line']['#title'] = 'Line'; 251 252 // Set up Grouping, Suppression... 253 $header['_groupby']=array('log_id'=>1); 254 $header['_supres']=array('log_id'=>1,'log_severity'=>1,'log_date_e'=>1,'log_app'=>1,'log_full_name'=>1); 255 256 // Hack Get All Rows 257 $rows = $this->bolog->get_error_e(array('orderby'=>array('log_id','log_msg_log_id'))); 258 $norows = count($rows); 259 $header['_edittable']=$this->editmode; 260 $table = $this->html->hash_table($rows,$header,$this, 'format_row'); 261 $this->t->set_var('event_list',$table); 262 263 $GLOBALS['egw_info']['flags']['app_header'] = lang('Admin').' - '.($this->editmode?lang('Edit Table format') : lang('View error log')); 264 if(!@is_object($GLOBALS['egw']->js)) 265 { 266 $GLOBALS['egw']->js =& CreateObject('phpgwapi.javascript'); 267 } 268 $GLOBALS['egw']->js->validate_file('jscode','openwindow','admin'); 269 $GLOBALS['egw']->common->egw_header(); 270 echo parse_navbar(); 271 $this->t->pfp('out','log_list_t'); 272 // $this->set_app_langs(); 273 } 274 275 function format_row($rno, $row) 276 { 277 switch($row['log_severity']['value']) 278 { 279 case 'D': $row['log_severity']['bgcolor'] = '#D3DCFF'; break; 280 case 'I': $row['log_severity']['bgcolor'] = '#C0FFC0'; break; 281 case 'W': $row['log_severity']['bgcolor'] = '#FFFFC0'; break; 282 case 'E': $row['log_severity']['bgcolor'] = '#FFC0C0'; break; 283 case 'F': $row['log_severity']['bgcolor'] = '#FF0909'; break; 284 } 285 286 switch($row['log_msg_severity']['value']) 287 { 288 case 'D': $color = '#D3DCFF'; break; 289 case 'I': $color = '#C0FFC0'; break; 290 case 'W': $color = '#FFFFC0'; break; 291 case 'E': $color = '#FFC0C0'; break; 292 case 'F': $color = '#FF0909'; break; 293 } 294 reset($this->fields_inc); 295 while(list($cno,$fld) = each($this->fields_inc)) 296 { 297 if (substr($fld,0,7) == 'log_msg') 298 { 299 $row[$fld]['bgcolor'] = $color; 300 } 301 else 302 { 303 // $row[$cno]['bgcolor'] = $lcolor; 304 } 305 } 306 return $row; 307 } 308 } 309 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |