From 775e55fc86e2c2d642ec10780466d8479f70aa93 Mon Sep 17 00:00:00 2001 From: jengo Date: Sun, 5 Aug 2001 06:48:42 +0000 Subject: [PATCH] Added patch for eventlog --- admin/inc/class.bolog.inc.php | 80 ++++++++ admin/inc/class.html.inc.php | 194 +++++++++++++++++++ admin/inc/class.solog.inc.php | 164 ++++++++++++++++ admin/inc/class.uilog.inc.php | 257 ++++++++++++++++++++++++++ admin/inc/hook_admin.inc.php | 3 +- admin/log.php | 21 +++ admin/templates/default/log.tpl | 8 + phpgwapi/inc/class.error.inc.php | 74 ++++++++ phpgwapi/inc/class.log.inc.php | 175 ++++++++++++++++++ phpgwapi/setup/setup.inc.php | 4 +- phpgwapi/setup/tables_current.inc.php | 32 ++++ phpgwapi/setup/tables_update.inc.php | 51 ++++- 12 files changed, 1060 insertions(+), 3 deletions(-) create mode 100755 admin/inc/class.bolog.inc.php create mode 100755 admin/inc/class.html.inc.php create mode 100755 admin/inc/class.solog.inc.php create mode 100644 admin/inc/class.uilog.inc.php create mode 100755 admin/log.php create mode 100755 admin/templates/default/log.tpl create mode 100755 phpgwapi/inc/class.error.inc.php create mode 100644 phpgwapi/inc/class.log.inc.php diff --git a/admin/inc/class.bolog.inc.php b/admin/inc/class.bolog.inc.php new file mode 100755 index 0000000000..4a8f645f62 --- /dev/null +++ b/admin/inc/class.bolog.inc.php @@ -0,0 +1,80 @@ + True + ); + + function bolog($session=False) + { + global $phpgw; + $this->so = CreateObject('admin.solog'); + } + + function get_error_cols() + { + $fields = $this->so->get_error_cols(); + // boAccounts + $fields['account_pwd']['include'] = false; + return $fields; + } + + function get_error_cols_e() + { + $fields = $this->so->get_error_cols_e(); + $fields['log_date_e'] = array(); + $fields['log_msg_date_e'] = array(); + $fields['log_full_name'] = array(); + // boAccounts + $fields['account_pwd']['include'] = false; + $fields['account_lastlogin_e'] = array(); + $fields['account_lastloginfrom_e'] = array(); + $fields['account_lastpwd_change_e'] = array(); + return $fields; + } + + function get_error($values='') + { + $rows = $this->so->get_error($values); + // should remove the accounts_pwd + return $rows; + } + + function get_error_e($values='') + { + $rows = $this->so->get_error_e($values); + + // Enhance the fields + reset($rows); + while(list($rno,$r)=each($rows)) + { + unset($r['acount_pwd']); // remove the accounts_pwd + $r['log_date_e'] = date('Y.n.d:H.i.s',$r['log_date']); + $r['log_msg_date_e'] = date('Y.n.d:H.i.s',$r['log_msg_date']); + $r['log_full_name'] = $r['account_lastname'] . ', ' .$r['account_firstname']; + $r['account_lastlogin_e'] = date('Y.n.d:H.i.s',$r['account_lastlogin']); + $r['account_lastpwd_change_e'] = date('Y.n.d:H.i.s',$r['account_lastpwd_change']); + $r['account_lastloginfrom_e'] = 'www.nowhere.com'; + + $r['log_msg_text'] = lang($r['log_msg_msg'],explode('|',$r['log_msg_parms'])); + + $rows[$rno]=$r; + } + return $rows; + } + } +?> diff --git a/admin/inc/class.html.inc.php b/admin/inc/class.html.inc.php new file mode 100755 index 0000000000..05aa447fa0 --- /dev/null +++ b/admin/inc/class.html.inc.php @@ -0,0 +1,194 @@ + * + * -------------------------------------------- * + * 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 html +{ + function hash_table($rows,$head='',$obj, $frtn) + { + global $phpgw; + $html = ''; + $edittable =$head['_edittable']; + if (isset($edittable)) + { + if ($edittable) + { + // Generate the customization table... + return $this->edit_table($rows,$head,$obj,$frtn); + } + else + { + $html .= "
link() + . "&editable=true\">\n"; + $html .= ""; + } + + } + $params = $head['_table_parms']; + if ($head == '') + { + $frow = $rows[0]; + $cnam = array_keys($frow); + while(list(,$fn)=each($cnam)) + { + $head[$fn] = array(); + } + }; + + if ( gettype($head['_cols'])=="NULL") + { + $cols = array_keys($rows[0]); + } + else + { + $cols = $head['_cols']; + }; + $html .= "\n"; + // Build Header Row... + $html .= "\t "; + reset($cols); + while (list(,$name) = each($cols)) + { + $values = $head[$name]; + $title = $values['title']; + if ($title == '') + { + $title = $name; + } + $html .= "\t\t\n"; + } + + $html .= "\t\n"; + + + + reset($rows); + while(list($rno,$r)=each($rows)) + { + $row = $obj->$frtn($rno,$r); + $rparms = $row['_rparms']; + $html .= "\t "; + reset($cols); + while (list(,$name) = each($cols)) + { + $values = $head[$name]; + $parms = $values['parms']; + $fparms = $row['_'.$name]; + $html .= "\t\t\n"; + } + $html .= "\t\n"; + } + $html .= "
".$title."
".$row[$name]."
\n"; + $html .= "
"; + return $html; + } + + + function edit_table($rows,$head='',$obj, $frtn) + { + global $phpgw, $nocols; + $html = ''; + $html .= "
link() + . "&editable=true" + . "\">\n"; + + $params = $head['_table_parms']; + $frow = $rows[0]; + $cnam = array_keys($frow); + if ($head == '') + { + while(list(,$fn)=each($cnam)) + { + $head[$fn] = array(); + } + }; + + if ( gettype($head['_cols'])=="NULL") + { + $cols = array_keys($rows[0]); + } + else + { + $cols = $head['_cols']; + }; + if (!isset($nocols)) + { + $nocols = count($cols); + } + // Build Header Row... + $html .= "

Number of Columns: "; + $html .= ""; + $html .= ""; + $html .= "

\n"; + $html .= "\t "; + $html .= "\n"; + $html .= "\t\t\n"; + $html .= "\t\t\n"; + $html .= "\t\t\n"; + $html .= "\t\n"; + + + // Add Table Rows... + reset($cols); +// while (list($cno,$name) = each($cols)) + for ($cno=0;$cno<$nocols;$cno++) + { + $name = $cols[$cno]; + $values = $head[$name]; + $title = $values['title']; + if ($title == '') + { + $title = $name; + } + $html .= "\t\n"; + $html .= "\t\t\n"; + $html .= "\t\t\n"; + $value = $rows[0][$name]; + $html .= "\t\t\n"; + $html .= "\t\n"; + } + $html .= "
DelColumnValue
".$this->dropdown($cnam,'_cols[]',$name)."$value
\n"; + $html .= ""; + $html .= "
"; + return $html; + } + + + function dropdown($opts,$name='',$sel='') + { + $items = $opts; + $html = '\n"; + return $html; + } + +} + + diff --git a/admin/inc/class.solog.inc.php b/admin/inc/class.solog.inc.php new file mode 100755 index 0000000000..42062ba4dd --- /dev/null +++ b/admin/inc/class.solog.inc.php @@ -0,0 +1,164 @@ + * + * -------------------------------------------- * + * Funding for this program was provided by http://www.checkwithmom.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 solog + { + var $db; + var $owner; + var $error_cols = ''; + var $error_cols_e = ''; + var $public_functions = array + ('get_error_cols' => True + ,'get_error_cols_e'=> True + ,'get_error' => True + ,'get_error_e' => True + ); + + function solog() + { + global $phpgw; + $this->db = $phpgw->db; + } + + function get_error_cols() + { + if ($this->error_cols == '') + { + $this->error_cols = array(); + + // fields from phpgw_log table + $clist = $this->db->metadata('phpgw_log'); + for ($i=0; $ierror_cols[$name] = array(); + } + + // fields from phpgw_log_msg table + $clist = $this->db->metadata('phpgw_log_msg'); + for ($i=0; $ierror_cols[$name] = array(); + } + } + return $this->error_cols; + } + + function get_error_cols_e() + { + if ($this->task_cols_e == '') + { + // Get Columns for Errors + $this->error_cols_e = $this->get_error_cols(); + + // Enhance with Columns for phpgw_accounts + $clist = $this->db->metadata('phpgw_accounts'); + for ($i=0; $ierror_cols_e[$name] = array(); + } + } + return $this->error_cols_e; + } + + function get_error_e($parms) + { + // Fixed From + if ($parms['from'] == '') + { + $parms['from'] = array('phpgw_accounts'); + } + else + { + $parms['from'][] = 'phpgw_accounts'; + } + + // Fix Where + if ($parms['where'] == '') + { + $parms['where'] = array('phpgw_log.log_user = phpgw_accounts.account_id'); + } + else + { + $parms['where'][] = 'phpgw_log.log_id = phpgw_accounts.account_id'; + } + + // Fix Default Fields + if ($parms['fields'] == '') + { + $parms['fields'] = $this->get_error_cols_e(); + } + + return $this->get_error($parms); + } + + function get_error($parms) + { // Get paramenter values + $from = $parms['from']; + $where = $parms['where']; + $orderby = $parms['orderby']; + $fields = $parms['fields']; + + // Build From_Clause + $from_clause = 'FROM phpgw_log, phpgw_log_msg '; + if ($from != '') + { + $from[] = 'phpgw_log'; + $from[] = 'phpgw_log_msg'; + $from_clause = 'FROM '.implode(', ' , $from).' '; + } + + // Build Where_Clause + $where_clause = 'WHERE phpgw_log.log_id = phpgw_log_msg.log_msg_log_id '; + if ($where != '') + { + $where[] = 'phpgw_log.log_id = phpgw_log_msg.log_msg_log_id'; + $where_clause = 'WHERE ' . implode(' AND ',$where) . ' '; + } + + // Build Order_By_Clause + $orderby_clause = 'Order By phpgw_log.log_id, phpgw_log_msg.log_msg_seq_no '; + if ($orderby != '') + { + $orderby_clause = 'Order By ' . implode(', ',$orderby); + } + + // If no Fields specified default to * + if ($fields == '') + { + $fields = $this->error_cols; + } + + $rows = array(); + $rowno = 0; + + // Do Select + $this->db->query("select ". implode(', ',array_keys($fields)).' '.$from_clause.$where_clause.$orderby_clause,__LINE__,__FILE__); + while($this->db->next_record()) + { + reset($fields); + while(list($fname,$fopt) = each($fields)) + { + $this_row[$fname] = $this->db->f($fname); + }; + $rows[$rowno] = $this_row; + $rowno++; + }; + return $rows; + } + } diff --git a/admin/inc/class.uilog.inc.php b/admin/inc/class.uilog.inc.php new file mode 100644 index 0000000000..2e9747985c --- /dev/null +++ b/admin/inc/class.uilog.inc.php @@ -0,0 +1,257 @@ + 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; + + + // 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... + } + + function list_log() + { + global $phpgw, $phpgw_info; +/* +$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'); +$phpgw->log->error('F-Abend, abort: %1','Force abnormal termination'); +$phpgw->log->commit(); // commit error stack to log... +*/ + + $this->t->set_file(array('log_list_t' => 'log.tpl')); + + + // Get list of Possible Columns + $header = $this->bolog->get_error_cols_e(); + + // Set Table formating parameters + $header['_table_parms']='width="98%", bgcolor="D3DCFF"'; + + // 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'; + + // Hack Get All Rows + $rows = $this->bolog->get_error_e(array('orderby'=>array('log_id','log_msg_log_id'))); + + $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) + { + if ($rno == 0) + { + $this->lastid = ''; + } + + if ($this->lastid != $row['log_id']) + { + $this->lastid = $row['log_id']; + } + else + { + $row['log_id'] = '  '; + $row['log_severity'] = '  '; + $row['log_date_e'] = '  '; + $row['log_app'] = '  '; + $row['log_full_name'] = '  '; + } + switch($row['log_severity']) + { + case 'I': $lcolor = 'C0FFC0'; break; + case 'W': $lcolor = 'FFFFC0'; break; + case 'E': $lcolor = 'FFC0C0'; break; + case 'F': $lcolor = 'FF0909'; break; + } + + switch($row['log_msg_severity']) + { + 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(,$fld) = each($this->fields_inc)) + { + if (substr($fld,0,7) == 'log_msg') + { + $c = $color; + } + else + { + if ($fld == 'log_severity' && $row['log_severity'] != '  ') + { + $c = $lcolor; + } + else + { + $c = "FFFFFF"; + } + }; + $parms = 'bgcolor="' . $c . '"'; + $row['_'.$fld] = $parms; + } + return $row; + } + } +?> diff --git a/admin/inc/hook_admin.inc.php b/admin/inc/hook_admin.inc.php index f9a4fbb12f..f81651d677 100644 --- a/admin/inc/hook_admin.inc.php +++ b/admin/inc/hook_admin.inc.php @@ -23,9 +23,10 @@ 'Change Main Screen Message' => $phpgw->link('/admin/mainscreen_message.php'), 'View Sessions' => $phpgw->link('/admin/currentusers.php'), 'View Access Log' => $phpgw->link('/index.php','menuaction=admin.uiaccess_history.list_history'), + 'View Error Log' => $phpgw->link('/admin/log.php'), //j3rry 'phpInfo' => $phpgw->link('/admin/phpinfo.php') ); //Do not modify below this line display_section($appname,$title,$file); } -?> \ No newline at end of file +?> diff --git a/admin/log.php b/admin/log.php new file mode 100755 index 0000000000..f298850d80 --- /dev/null +++ b/admin/log.php @@ -0,0 +1,21 @@ + 'admin' + ); + include('../header.inc.php'); + $obj = CreateObject('admin.uilog'); + $obj->list_log(); +?> diff --git a/admin/templates/default/log.tpl b/admin/templates/default/log.tpl new file mode 100755 index 0000000000..2f3d97cd48 --- /dev/null +++ b/admin/templates/default/log.tpl @@ -0,0 +1,8 @@ + + +{app_header} +
+{event_list} +
+{save_preferences} + diff --git a/phpgwapi/inc/class.error.inc.php b/phpgwapi/inc/class.error.inc.php new file mode 100755 index 0000000000..2bb46df6f1 --- /dev/null +++ b/phpgwapi/inc/class.error.inc.php @@ -0,0 +1,74 @@ + * + * -------------------------------------------- * + * 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 error + { + /***************************\ + * Instance Variables... * + \***************************/ + var $severity = 'E'; + var $code = 'Unknown'; + var $msg = 'Unknown error'; + var $parms = array(); + var $ismsg = 0; + var $timestamp; + + var $public_functions = array(); + + /*******************************************\ + * Constructor * + * to be accessed as new error() * + \*******************************************/ + // Translate Message into Language + function langmsg() + { + return lang($this->msg,$this->parms); + } + + + function error($etext, $parms, $ismsg) + { + global $phpgw; + if (eregi('([IWEF])-(.*)[\,](.*)',$etext,$match)) + { + $this->severity = strtoupper($match[1]); + $this->code = $match[2]; + $this->msg = trim($match[3]); + } + else + { + $this->msg = trim($etext); + } + $this->timestamp = time(); + $this->parms = $parms; + $this->ismsg = $ismsg; + + $phpgw->log->errorstack[] = $this; + if ($this->severity == 'F') + { + // This is it... Don't return + // do rollback... + // Hmmm this only works if UI!!!! + // What Do we do if it's a SOAP/XML? + echo "
"; + echo "

Fatal Error

"; + echo "

Error Stack

"; + echo $phpgw->log->astable(); + echo "
"; + // Commit stack to log + $phpgw->log->commit(); + exit(); + } + } + } diff --git a/phpgwapi/inc/class.log.inc.php b/phpgwapi/inc/class.log.inc.php new file mode 100644 index 0000000000..11ba425922 --- /dev/null +++ b/phpgwapi/inc/class.log.inc.php @@ -0,0 +1,175 @@ + * + * -------------------------------------------- * + * 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 log + { + /***************************\ + * Instance Variables... * + \***************************/ + var $errorstack = array(); + var $public_functions = array('message', + 'error', + 'iserror', + 'severity', + 'commit', + 'clearstack', + 'astable', + ); + + + function message($etext,$p0='',$p1='',$p2='',$p3='',$p4='',$p5='',$p6='',$p7='',$p8='',$p9='') + { + $parms = array($p0,$p1,$p2,$p3,$p4,$p5,$p6,$p7,$p8,$p9); + CreateObject('phpgwapi.error',$etext,$parms,1); + } + + + function error($etext,$p0='',$p1='',$p2='',$p3='',$p4='',$p5='',$p6='',$p7='',$p8='',$p9='') + { + $parms = array($p0,$p1,$p2,$p3,$p4,$p5,$p6,$p7,$p8,$p9); + CreateObject('phpgwapi.error',$etext,$parms,false); + } + + function iserror($ecode) + { + $errorstack = $this->errorstack; + reset($errorstack); + while(list(,$err)=each($errorstack)) + { + if ($ecode == $err->code) + { + return true; + } + } + return false; + } + + + function severity() + { + $max = 'I'; + $errorstack = $this->errorstack; + reset($errorstack); + while(list(,$err)=each($errorstack)) + { + switch($err->severity) + { + case 'F': return 'F'; break; + case 'E': $max = 'E'; break; + case 'W': if ($max == 'I') + { + $max = 'W'; + } + break; + } + } + return $max; + } + + function commit() + { + + global $phpgw, $phpgw_info; + $db = $phpgw->db; + $db->query ('insert into phpgw_log (log_date, log_user, log_app, log_severity) values ' + .'('.time() + .','.$phpgw->session->account_id + .',"'.$phpgw_info['flags']['currentapp'].'"' + .',"'.$this->severity().'"' + .')' + ,__LINE__,__FILE__); + + $db->query ('select max(log_id) log_id from phpgw_log',__LINE__,__FILE__); + $db->next_record(); + $log_id = $db->f('log_id'); + $errorstack = $this->errorstack; + for ($i = 0; $i < count($errorstack); $i++) + { + $err = $errorstack[$i]; + $db->query ("insert into phpgw_log_msg " + ."(log_msg_log_id, log_msg_seq_no, log_msg_date, " + ."log_msg_severity, log_msg_code, log_msg_msg, log_msg_parms) values " + ."( " . $log_id + .", " . $i + .", " . $err->timestamp + .", '". $err->severity . "'" + .", '". $err->code . "'" + .", '". $err->msg . "'" + .", '". addslashes(implode('|',$err->parms)). "'" + .")" + ,__LINE__,__FILE__); + }; + unset ($errorstack); + unset ($this->errorstack); + $this->errorstack = array(); + + } + function clearstack() + { + $new = array(); + reset($this->errorstack); + for ($i = 0; $i < count($this->errorstack); $i++) + { + $err = $this->errorstack[$i]; + if ($err->ismsg) + { + $new[] = $err; + }; + } + unset ($this->errorstack); + $this->errorstack = $new; + } + + function astable() + { + global $phpgw; + + $html = "
\n"; + $html .= "\n"; + $html .= "\t\n"; + $html .= "\t\t\n"; + $html .= "\t\t\n"; + $html .= "\t\t\n"; + $html .= "\t\t\n"; + $html .= "\t\t\n"; + $html .= "\t\t\n"; + $html .= "\t\n"; + + $errorstack = $this->errorstack; + for ($i = 0; $i < count($errorstack); $i++) + { + $err = $errorstack[$i]; + switch ($err->severity) + { + case 'I': $color = 'C0FFC0'; break; + case 'W': $color = 'FFFFC0'; break; + case 'E': $color = 'FFC0C0'; break; + case 'F': $color = 'FF0909'; break; + } + + $html .= "\t\n"; + $html .= "\t\t\n"; + $html .= "\t\t\n"; + $html .= "\t\t\n"; + $html .= "\t\t\n"; + $html .= "\t\t\n"; + $html .= "\t\t\n"; + $html .= "\t\n"; + }; + $html .= "
NoDateAppSError CodeMsg
".$i."".date('Y.n.d:H.i.s',$err->timestamp)."".$phpgw_info['flags']['currentapp']."  ".$err->severity."".$err->code."".$err->langmsg()."
\n"; + $html .= "
\n"; + + return $html; + } + } diff --git a/phpgwapi/setup/setup.inc.php b/phpgwapi/setup/setup.inc.php index ab89a2d824..b02fdfc2d5 100755 --- a/phpgwapi/setup/setup.inc.php +++ b/phpgwapi/setup/setup.inc.php @@ -14,7 +14,7 @@ /* Basic information about this app */ $setup_info['phpgwapi']['name'] = 'phpgwapi'; $setup_info['phpgwapi']['title'] = 'phpgwapi'; - $setup_info['phpgwapi']['version'] = '0.9.13.006'; + $setup_info['phpgwapi']['version'] = '0.9.13.007'; $setup_info['phpgwapi']['versions']['current_header'] = '1.16'; $setup_info['phpgwapi']['enable'] = 3; $setup_info['phpgwapi']['app_order'] = 1; @@ -35,6 +35,8 @@ $setup_info['phpgwapi']['tables'][] = 'phpgw_nextid'; $setup_info['phpgwapi']['tables'][] = 'phpgw_addressbook'; $setup_info['phpgwapi']['tables'][] = 'phpgw_addressbook_extra'; + $setup_info['phpgwapi']['tables'][] = 'phpgw_log'; + $setup_info['phpgwapi']['tables'][] = 'phpgw_log_msg'; /* Basic information about this app */ $setup_info['notifywindow']['name'] = 'notifywindow'; diff --git a/phpgwapi/setup/tables_current.inc.php b/phpgwapi/setup/tables_current.inc.php index 4116e07c05..8a8773e227 100644 --- a/phpgwapi/setup/tables_current.inc.php +++ b/phpgwapi/setup/tables_current.inc.php @@ -257,6 +257,38 @@ 'fk' => array(), 'ix' => array(), 'uc' => array() + ), +// Begin j3rry + 'phpgw_log' => array( + 'fd' => array( + 'log_id' => array('type' => 'auto', 'precision' => 4, 'nullable' => False), + 'log_date' => array('type' => 'int', 'precision' => 4, 'nullable' => False), + 'log_user' => array('type' => 'int', 'precision' => 4, 'nullable' => False), + 'log_app' => array('type' => 'varchar', 'precision' => 50, 'nullable' => False), + 'log_severity' => array('type' => 'char', 'precision' => 1, 'nullable' => False) + ), + 'pk' => array('log_id'), + 'fk' => array(), + 'ix' => array(), + 'uc' => array() + ), + 'phpgw_log_msg' => array( + 'fd' => array( + 'log_msg_log_id' => array('type' => 'int', 'precision' => 4, 'nullable' => False), + 'log_msg_seq_no' => array('type' => 'int', 'precision' => 4, 'nullable' => False), + 'log_msg_date' => array('type' => 'int', 'precision' => 4, 'nullable' => False), + 'log_msg_tx_fid' => array('type' => 'varchar', 'precision' => 4, 'nullable' => True), + 'log_msg_tx_id' => array('type' => 'varchar', 'precision' => 4, 'nullable' => True), + 'log_msg_severity' => array('type' => 'char', 'precision' => 1, 'nullable' => False), + 'log_msg_code' => array('type' => 'varchar', 'precision' => 30, 'nullable' => False), + 'log_msg_msg' => array('type' => 'text', 'nullable' => False), + 'log_msg_parms' => array('type' => 'text', 'nullable' => False) + ), + 'pk' => array('log_msg_log_id', 'log_msg_seq_no'), + 'fk' => array(), + 'ix' => array(), + 'uc' => array() ) +// End j3rry ); ?> diff --git a/phpgwapi/setup/tables_update.inc.php b/phpgwapi/setup/tables_update.inc.php index b722428f9f..1fdc5c9c78 100644 --- a/phpgwapi/setup/tables_update.inc.php +++ b/phpgwapi/setup/tables_update.inc.php @@ -1632,7 +1632,7 @@ 'phpgw_nextid', array( 'fd' => array( 'appname' => array('type' => 'varchar', 'precision' => 25, 'nullable' => False), - 'id' => array('type' => 'int', 'precision' => 4) + 'id' => array('type' => 'int', 'precision' => 4), ), 'pk' => array(), 'fk' => array(), @@ -1905,6 +1905,7 @@ $phpgw_setup->oProc->AddColumn('phpgw_access_log','account_id',array('type' => 'int', 'precision' => 4, 'default' => 0, 'nullable' => False)); + global $phpgw; class phpgw { var $common; @@ -1977,4 +1978,52 @@ $setup_info['phpgwapi']['currentver'] = '0.9.13.006'; return $setup_info['phpgwapi']['currentver']; } +// begin j3rry + $test[] = '0.9.13.006'; // version number? + function phpgwapi_upgrade0_9_13_006() + { + global $setup_info, $phpgw_setup; + + $phpgw_setup->oProc->CreateTable( + 'phpgw_log', array( + 'fd' => array( + 'log_id' => array('type' => 'auto', 'precision' => 4, 'nullable' => False), + 'log_date' => array('type' => 'int', 'precision' => 4, 'nullable' => False), + 'log_user' => array('type' => 'int', 'precision' => 4, 'nullable' => False), + 'log_app' => array('type' => 'varchar', 'precision' => 50, 'nullable' => False), + 'log_severity' => array('type' => 'char', 'precision' => 1, 'nullable' => False) + ), + 'pk' => array('log_id'), + 'fk' => array(), + 'ix' => array(), + 'uc' => array() + ) + ); + + $phpgw_setup->oProc->CreateTable( + 'phpgw_log_msg', array( + 'fd' => array( + 'log_msg_log_id' => array('type' => 'int', 'precision' => 4, 'nullable' => False), + 'log_msg_seq_no' => array('type' => 'int', 'precision' => 4, 'nullable' => False), + 'log_msg_date' => array('type' => 'int', 'precision' => 4, 'nullable' => False), + 'log_msg_tx_fid' => array('type' => 'varchar', 'precision' => 4, 'nullable' => True), + 'log_msg_tx_id' => array('type' => 'varchar', 'precision' => 4, 'nullable' => True), + 'log_msg_severity' => array('type' => 'char', 'precision' => 1, 'nullable' => False), + 'log_msg_code' => array('type' => 'varchar', 'precision' => 30, 'nullable' => False), + 'log_msg_msg' => array('type' => 'text', 'nullable' => False), + 'log_msg_parms' => array('type' => 'text', 'nullable' => False) + ), + 'pk' => array('log_msg_log_id', 'log_msg_seq_no'), + 'fk' => array(), + 'ix' => array(), + 'uc' => array() + ) + ); + + $setup_info['phpgwapi']['currentver'] = '0.9.13.007'; + return $setup_info['phpgwapi']['currentver']; + } + + + ?>