Changeset 2566:9bf417837888 for inc/core/class.dc.log.php
- Timestamp:
- 11/17/13 20:25:53 (12 years ago)
- Branch:
- 2.6
- Children:
- 2567:6c11245cbf04, 2568:61c67a7d17fa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inc/core/class.dc.log.php
r1179 r2566 16 16 protected $core; 17 17 protected $prefix; 18 18 19 19 /** 20 20 Object constructor. 21 21 22 22 @param core <b>dcCore</b> dcCore instance 23 23 */ … … 27 27 $this->prefix = $core->prefix; 28 28 } 29 29 30 30 /** 31 31 Retrieves logs. <b>$params</b> is an array taking the following 32 32 optionnal parameters: 33 33 34 34 - blog_id: Get logs belonging to given blog ID 35 35 - user_id: Get logs belonging to given user ID … … 38 38 - order: Order of results (default "ORDER BY log_dt DESC") 39 39 - limit: Limit parameter 40 40 41 41 @param params <b>array</b> Parameters 42 42 @param count_only <b>boolean</b> Only counts results … … 54 54 'U.user_firstname, U.user_displayname, U.user_url'; 55 55 } 56 56 57 57 $strReq = 'SELECT '.$f.' FROM '.$this->prefix.'log L '; 58 58 59 59 if (!$count_only) { 60 60 $strReq .= … … 62 62 'ON U.user_id = L.user_id '; 63 63 } 64 64 65 65 if (!empty($params['blog_id'])) { 66 66 if ($params['blog_id'] === 'all') { … … 74 74 $strReq .= "WHERE L.blog_id = '".$this->core->blog->id."' "; 75 75 } 76 76 77 77 if (!empty($params['user_id'])) { 78 78 $strReq .= 'AND L.user_id'.$this->core->con->in($params['user_id']); … … 84 84 $strReq .= 'AND log_table'.$this->core->con->in($params['log_table']); 85 85 } 86 86 87 87 if (!$count_only) 88 88 { … … 93 93 } 94 94 } 95 95 96 96 if (!empty($params['limit'])) { 97 97 $strReq .= $this->core->con->limit($params['limit']); 98 98 } 99 99 100 100 $rs = $this->core->con->select($strReq); 101 101 $rs->extend('rsExtLog'); 102 102 103 103 return $rs; 104 104 } 105 105 106 106 /** 107 107 Creates a new log. Takes a cursor as input and returns the new log 108 108 ID. 109 109 110 110 @param cur <b>cursor</b> Log cursor 111 111 @return <b>integer</b> New log ID … … 114 114 { 115 115 $this->core->con->writeLock($this->prefix.'log'); 116 116 117 117 try 118 118 { … … 120 120 $rs = $this->core->con->select( 121 121 'SELECT MAX(log_id) '. 122 'FROM '.$this->prefix.'log ' 122 'FROM '.$this->prefix.'log ' 123 123 ); 124 124 125 125 $cur->log_id = (integer) $rs->f(0) + 1; 126 126 $cur->blog_id = (string) $this->core->blog->id; 127 127 $cur->log_dt = date('Y-m-d H:i:s'); 128 128 129 129 $this->getLogCursor($cur,$cur->log_id); 130 130 131 131 # --BEHAVIOR-- coreBeforeLogCreate 132 132 $this->core->callBehavior('coreBeforeLogCreate',$this,$cur); 133 133 134 134 $cur->insert(); 135 135 $this->core->con->unlock(); … … 140 140 throw $e; 141 141 } 142 142 143 143 # --BEHAVIOR-- coreAfterLogCreate 144 144 $this->core->callBehavior('coreAfterLogCreate',$this,$cur); 145 145 146 146 return $cur->log_id; 147 147 } 148 148 149 149 /** 150 150 Deletes a log. 151 151 152 152 @param id <b>integer</b> Log ID 153 153 */ … … 157 157 'TRUNCATE TABLE '.$this->prefix.'log' : 158 158 'DELETE FROM '.$this->prefix.'log WHERE log_id'.$this->core->con->in($id); 159 159 160 160 $this->core->con->execute($strReq); 161 161 } 162 162 163 163 private function getLogCursor($cur,$log_id = null) 164 164 { … … 166 166 throw new Exception(__('No log message')); 167 167 } 168 168 169 169 if ($cur->log_table === null) { 170 170 $cur->log_table = 'none'; 171 171 } 172 172 173 173 if ($cur->user_id === null) { 174 174 $cur->user_id = 'unknown'; 175 175 } 176 176 177 177 if ($cur->log_dt === '' || $cur->log_dt === null) { 178 178 $cur->log_dt = date('Y-m-d H:i:s'); 179 179 } 180 180 181 181 if ($cur->log_ip === null) { 182 182 $cur->log_ip = http::realIP(); 183 183 } 184 184 185 185 $log_id = is_int($log_id) ? $log_id : $cur->log_id; 186 186 } … … 193 193 $user = dcUtils::getUserCN($rs->user_id, $rs->user_name, 194 194 $rs->user_firstname, $rs->user_displayname); 195 195 196 196 if ($user === 'unknown') { 197 197 $user = __('unknown'); 198 198 } 199 199 200 200 return $user; 201 201 } 202 202 } 203 204 ?>
Note: See TracChangeset
for help on using the changeset viewer.