Quick Search:

View

Revision:

Diff

Diff from 1857 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: administrators_log.php 1857 2009-03-01 02:41:14Z hpdl $
4
5   osCommerce, Open Source E-Commerce Solutions
6   http://www.oscommerce.com
7
hpdl
1857
8   Copyright (c) 2009 osCommerce
hpdl
1290
9
hpdl
1497
10   This program is free software; you can redistribute it and/or modify
11   it under the terms of the GNU General Public License v2 (1991)
12   as published by the Free Software Foundation.
hpdl
1290
13 */
14
hpdl
1857
15   class osC_AdministratorsLog_Admin {
16     public static function getData($id) {
hpdl
1290
17       global $osC_Database;
18
19       $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');
20       $Qlog->bindTable(':table_administrators_log', TABLE_ADMINISTRATORS_LOG);
21       $Qlog->bindTable(':table_administrators', TABLE_ADMINISTRATORS);
22       $Qlog->bindInt(':id', $id);
23       $Qlog->execute();
24
25       $data = $Qlog->toArray();
26
27       $Qlog->freeResult();
28
29       return $data;
30     }
31
hpdl
1857
32     public static function insert($module, $module_action, $module_id, $action, $log, $transaction_id) {
hpdl
1290
33       global $osC_Database;
34
35       if ( is_numeric($transaction_id) ) {
36         $log_id = $transaction_id;
37       } else {
38         $Qlog = $osC_Database->query('select max(id) as id from :table_administrators_log');
39         $Qlog->bindTable(':table_administrators_log', TABLE_ADMINISTRATORS_LOG);
40         $Qlog->execute();
41
42         $log_id = $Qlog->valueInt('id') + 1;
43
44         if ( $transaction_id === true ) {
45           $osC_Database->logging_transaction = $log_id;
46         }
47       }
48
49       foreach ( $log as $entry ) {
50         $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())');
51         $Qlog->bindTable(':table_administrators_log', TABLE_ADMINISTRATORS_LOG);
52         $Qlog->bindInt(':id', $log_id);
53         $Qlog->bindValue(':module', $module);
54         $Qlog->bindValue(':module_action', $module_action);
55         $Qlog->bindInt(':module_id', $module_id);
56         $Qlog->bindValue(':field_key', $entry['key']);
57         $Qlog->bindValue(':old_value', $entry['old']);
58         $Qlog->bindValue(':new_value', $entry['new']);
59         $Qlog->bindValue(':action', $action);
60         $Qlog->bindInt(':administrators_id', $_SESSION['admin']['id']);
61         $Qlog->execute();
62       }
63     }
64
hpdl
1857
65     public static function delete($id) {
hpdl
1290
66       global $osC_Database;
67
68       $Qlog = $osC_Database->query('delete from :table_administrators_log where id = :id');
69       $Qlog->bindTable(':table_administrators_log', TABLE_ADMINISTRATORS_LOG);
70       $Qlog->bindInt(':id', $id);
71       $Qlog->execute();
72
73       if ( !$osC_Database->isError() ) {
74         return true;
75       }
76
77       return false;
78     }
79   }
80 ?>