Quick Search:

View

Revision:

Diff

Diff from 1290 to:

Annotations

Annotate by Age | Author | Mixed | None
/fisheye/browse/osCommerce/branches/hpdl/oscommerce/admin/includes/applications/administrators_log/classes/administrators_log.php

Annotated File View

hpdl
1290
1 <?php
2 /*
3   $Id: $
4
5   osCommerce, Open Source E-Commerce Solutions
6   http://www.oscommerce.com
7
8   Copyright (c) 2007 osCommerce
9
10   Released under the GNU General Public License
11 */
12
13   class osC_AdministratorsLog {
14     function getData($id) {
15       global $osC_Database;
16
17       $Qlog = $osC_Database->query('select al.id, al.module, al.module_action, al.module_id, al.action, a.user_name, unix_timestamp(al.datestamp) as datestamp from :table_administrators_log al, :table_administrators a where al.id = :id and al.administrators_id = a.id limit 1');
18       $Qlog->bindTable(':table_administrators_log', TABLE_ADMINISTRATORS_LOG);
19       $Qlog->bindTable(':table_administrators', TABLE_ADMINISTRATORS);
20       $Qlog->bindInt(':id', $id);
21       $Qlog->execute();
22
23       $data = $Qlog->toArray();
24
25       $Qlog->freeResult();
26
27       return $data;
28     }
29
30     function insert($module, $module_action, $module_id, $action, $log, $transaction_id) {
31       global $osC_Database;
32
33       if ( is_numeric($transaction_id) ) {
34         $log_id = $transaction_id;
35       } else {
36         $Qlog = $osC_Database->query('select max(id) as id from :table_administrators_log');
37         $Qlog->bindTable(':table_administrators_log', TABLE_ADMINISTRATORS_LOG);
38         $Qlog->execute();
39
40         $log_id = $Qlog->valueInt('id') + 1;
41
42         if ( $transaction_id === true ) {
43           $osC_Database->logging_transaction = $log_id;
44         }
45       }
46
47       foreach ( $log as $entry ) {
48         $Qlog = $osC_Database->query('insert into :table_administrators_log (id, module, module_action, module_id, field_key, old_value, new_value, action, administrators_id, datestamp) values (:id, :module, :module_action, :module_id, :field_key, :old_value, :new_value, :action, :administrators_id, now())');
49         $Qlog->bindTable(':table_administrators_log', TABLE_ADMINISTRATORS_LOG);
50         $Qlog->bindInt(':id', $log_id);
51         $Qlog->bindValue(':module', $module);
52         $Qlog->bindValue(':module_action', $module_action);
53         $Qlog->bindInt(':module_id', $module_id);
54         $Qlog->bindValue(':field_key', $entry['key']);
55         $Qlog->bindValue(':old_value', $entry['old']);
56         $Qlog->bindValue(':new_value', $entry['new']);
57         $Qlog->bindValue(':action', $action);
58         $Qlog->bindInt(':administrators_id', $_SESSION['admin']['id']);
59         $Qlog->execute();
60       }
61     }
62
63     function delete($id) {
64       global $osC_Database;
65
66       $Qlog = $osC_Database->query('delete from :table_administrators_log where id = :id');
67       $Qlog->bindTable(':table_administrators_log', TABLE_ADMINISTRATORS_LOG);
68       $Qlog->bindInt(':id', $id);
69       $Qlog->execute();
70
71       if ( !$osC_Database->isError() ) {
72         return true;
73       }
74
75       return false;
76     }
77   }
78 ?>