- Timestamp:
- Nov 1, 2007, 6:06:15 PM (17 years ago)
- Location:
- branches/branch-1_7
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/branch-1_7
- Property svn:ignore
-
old new 3 3 feed.xml 4 4 testmail 5 fstats
-
- Property svn:ignore
-
branches/branch-1_7/admin/include/functions_history.inc.php
r1912 r2156 52 52 } 53 53 54 function history_compare($a, $b) 55 { 56 return strcmp($a['date'].$a['time'], $b['date'].$b['time']); 57 } 58 59 function get_history($data, $search, $types) 60 { 61 if (isset($search['fields']['filename'])) 62 { 63 $query = ' 64 SELECT 65 id 66 FROM '.IMAGES_TABLE.' 67 WHERE file LIKE \''.$search['fields']['filename'].'\' 68 ;'; 69 $search['image_ids'] = array_from_query($query, 'id'); 70 } 71 72 // echo '<pre>'; print_r($search); echo '</pre>'; 73 74 $clauses = array(); 75 76 if (isset($search['fields']['date-after'])) 77 { 78 array_push( 79 $clauses, 80 "date >= '".$search['fields']['date-after']."'" 81 ); 82 } 83 84 if (isset($search['fields']['date-before'])) 85 { 86 array_push( 87 $clauses, 88 "date <= '".$search['fields']['date-before']."'" 89 ); 90 } 91 92 if (isset($search['fields']['types'])) 93 { 94 $local_clauses = array(); 95 96 foreach ($types as $type) { 97 if (in_array($type, $search['fields']['types'])) { 98 $clause = 'image_type '; 99 if ($type == 'none') 100 { 101 $clause.= 'IS NULL'; 102 } 103 else 104 { 105 $clause.= "= '".$type."'"; 106 } 107 108 array_push($local_clauses, $clause); 109 } 110 } 111 112 if (count($local_clauses) > 0) 113 { 114 array_push( 115 $clauses, 116 implode(' OR ', $local_clauses) 117 ); 118 } 119 } 120 121 if (isset($search['fields']['user']) 122 and $search['fields']['user'] != -1) 123 { 124 array_push( 125 $clauses, 126 'user_id = '.$search['fields']['user'] 127 ); 128 } 129 130 if (isset($search['fields']['image_id'])) 131 { 132 array_push( 133 $clauses, 134 'image_id = '.$search['fields']['image_id'] 135 ); 136 } 137 138 if (isset($search['fields']['filename'])) 139 { 140 if (count($search['image_ids']) == 0) 141 { 142 // a clause that is always false 143 array_push($clauses, '1 = 2 '); 144 } 145 else 146 { 147 array_push( 148 $clauses, 149 'image_id IN ('.implode(', ', $search['image_ids']).')' 150 ); 151 } 152 } 153 154 $clauses = prepend_append_array_items($clauses, '(', ')'); 155 156 $where_separator = 157 implode( 158 "\n AND ", 159 $clauses 160 ); 161 162 $query = ' 163 SELECT 164 date, 165 time, 166 user_id, 167 IP, 168 section, 169 category_id, 170 tag_ids, 171 image_id, 172 image_type 173 FROM '.HISTORY_TABLE.' 174 WHERE '.$where_separator.' 175 ;'; 176 177 // LIMIT '.$page['start'].', '.$conf['nb_logs_page'].' 178 179 $result = pwg_query($query); 180 181 while ($row = mysql_fetch_assoc($result)) 182 { 183 array_push($data, $row); 184 } 185 186 return $data; 187 } 188 189 add_event_handler('get_history', 'get_history', EVENT_HANDLER_PRIORITY_NEUTRAL, 3); 190 trigger_action('functions_history_included'); 191 54 192 ?>
Note: See TracChangeset
for help on using the changeset viewer.