[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 /**************************************************************************\ 3 * eGroupWare - solog * 4 * http://www.egroupware.org * 5 * This application written by Jerry Westrick <jerry@westrick.com> * 6 * -------------------------------------------- * 7 * Funding for this program was provided by http://www.checkwithmom.com * 8 * -------------------------------------------- * 9 * This program is free software; you can redistribute it and/or modify it * 10 * under the terms of the GNU General Public License as published by the * 11 * Free Software Foundation; either version 2 of the License, or (at your * 12 * option) any later version. * 13 \**************************************************************************/ 14 15 /* $Id: class.solog.inc.php 20295 2006-02-15 12:31:25Z $ */ 16 17 class solog 18 { 19 var $db; 20 var $accounts_table = 'egw_accounts'; 21 var $log_table = 'egw_log'; 22 var $msg_table = 'egw_log_msg'; 23 var $owner; 24 var $error_cols = ''; 25 var $error_cols_e = ''; 26 var $public_functions = array( 27 'get_error_cols' => True, 28 'get_error_cols_e' => True, 29 'get_error' => True, 30 'get_error_e' => True 31 ); 32 33 function solog() 34 { 35 $this->db = clone($GLOBALS['egw']->db); 36 } 37 38 function get_error_cols() 39 { 40 if ($this->error_cols == '') 41 { 42 $this->error_cols = array(); 43 44 /* fields from log table */ 45 $clist = $this->db->metadata($this->log_table); 46 for ($i=0; $i<count($clist); $i++) 47 { 48 $name = $clist[$i]['name']; 49 $this->error_cols[$name] = array(); 50 } 51 52 /* fields from msg table */ 53 $clist = $this->db->metadata($this->msg_table); 54 for ($i=0; $i<count($clist); $i++) 55 { 56 $name = $clist[$i]['name']; 57 $this->error_cols[$name] = array(); 58 } 59 } 60 return $this->error_cols; 61 } 62 63 function get_error_cols_e() 64 { 65 if ($this->task_cols_e == '') 66 { 67 /* Get Columns for Errors */ 68 $this->error_cols_e = $this->get_error_cols(); 69 70 /* Enhance with Columns from accounts-table */ 71 $clist = $this->db->metadata($this->accounts_table); 72 for ($i=0; $i<count($clist); $i++) 73 { 74 $name = $clist[$i]['name']; 75 $this->error_cols_e[$name] = array(); 76 } 77 } 78 return $this->error_cols_e; 79 } 80 81 function get_error_e($parms) 82 { 83 84 /* Fixed From */ 85 if (!isset($parms['from'])) 86 { 87 $parms['from'] = array($this->accounts_table); 88 } 89 else 90 { 91 $parms['from'][] = $this->accounts_table; 92 } 93 94 /* Fix Where */ 95 if (!isset($parms['where'])) 96 { 97 $parms['where'] = array("$this->log_table.log_user = $this->accounts_table.account_id"); 98 } 99 else 100 { 101 $parms['where'][] = "$this->log_table.log_user = $this->accounts_table.account_id"; 102 } 103 104 /* Fix Default Fields */ 105 if (!isset($parms['fields'])) 106 { 107 $parms['fields'] = $this->get_error_cols_e(); 108 } 109 110 return $this->get_error($parms); 111 } 112 113 function get_no_errors() 114 { 115 /* Get max ErrorId */ 116 $this->db->query("select count(*) as max_id from $this->log_table, $this->msg_table WHERE $this->log_table.log_id = $this->msg_table.log_msg_log_id",__LINE__,__FILE__); 117 118 return $this->db->next_record() ? $this->db->f('max_id') : 0; 119 } 120 121 function get_error($parms) 122 { 123 /* Get parameter values */ 124 $from = $parms['from']; 125 $where = $parms['where']; 126 $orderby = $parms['orderby']; 127 $fields = $parms['fields']; 128 129 /* Build From_Clause */ 130 $from_clause = "FROM $this->log_table , $this->msg_table "; 131 if (isset($from)) 132 { 133 $from[] = $this->log_table; 134 $from[] = $this->msg_table; 135 $from_clause = 'FROM '.implode(', ' , $from).' '; 136 } 137 138 /* Build Where_Clause */ 139 $where_clause = "WHERE $this->log_table.log_id = $this->msg_table.log_msg_log_id "; 140 if (isset($where)) 141 { 142 $where[] = "$this->log_table.log_id = $this->msg_table.log_msg_log_id"; 143 $where_clause = 'WHERE ' . implode(' AND ',$where) . ' '; 144 } 145 146 /* Build Order_By_Clause */ 147 $orderby_clause = "ORDER BY $this->log_table.log_id, $this->msg_table.log_msg_seq_no "; 148 if (isset($orderby)) 149 { 150 $orderby_clause = 'ORDER BY ' . implode(', ',$orderby); 151 } 152 153 /* If no Fields specified default to * */ 154 if (!isset($fields)) 155 { 156 $fields = $this->get_error_cols(); 157 } 158 159 $rows = array(); 160 161 $select = 'SELECT ' . implode(',',array_keys($fields)) . ' ' . $from_clause . $where_clause . $orderby_clause; 162 $this->db->query($select,__LINE__,__FILE__); 163 while($this->db->next_record()) 164 { 165 foreach($fields as $fname => $fopt) 166 { 167 $this_row[$fname]['value'] = $this->db->f($fname); 168 } 169 $rows[] = $this_row; 170 } 171 return $rows; 172 } 173 }
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 |