source: branches/2.2/expressoAdmin1_2/inc/class.uilogs.inc.php @ 414

Revision 414, 5.5 KB checked in by niltonneto, 16 years ago (diff)

Alterações feitas por João Alfredo.
Email: jakjr@…

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2        /************************************************************************************\
3        * Expresso Administração                                                                                                     *
4        * by Joao Alfredo Knopik Junior (joao.alfredo@gmail.com, jakjr@celepar.pr.gov.br)        *
5        * -----------------------------------------------------------------------------------*
6        *  This program is free software; you can redistribute it and/or modify it                       *
7        *  under the terms of the GNU General Public License as published by the                         *
8        *  Free Software Foundation; either version 2 of the License, or (at your                        *
9        *  option) any later version.                                                                                                            *
10        \************************************************************************************/
11
12        class uilogs
13        {
14                var $public_functions = array
15                (
16                        'list_logs'     => True,
17                        'view_log'      => True
18                );
19
20                var $functions;
21                var $nextmatchs;
22
23                function uilogs()
24                {
25                        $this->functions = createobject('expressoAdmin1_2.functions');
26                        $this->nextmatchs = createobject('phpgwapi.nextmatchs');
27                }
28
29                function list_logs()
30                {
31                        $account_lid = $GLOBALS['phpgw']->accounts->data['account_lid'];
32                        $tmp = $this->functions->read_acl($account_lid);
33                        $manager_context = $tmp[0]['context'];
34                       
35                        // Verifica se o administrador tem acesso.
36                        if (!$this->functions->check_acl($account_lid,'view_logs'))
37                        {
38                                $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/expressoAdmin1_2/inc/access_denied.php'));
39                        }
40                                               
41                        unset($GLOBALS['phpgw_info']['flags']['noheader']);
42                        unset($GLOBALS['phpgw_info']['flags']['nonavbar']);
43                        $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['expressoAdmin1_2']['title'].' - '.lang('Logs');
44                        $GLOBALS['phpgw']->common->phpgw_header();
45
46                        $p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
47                        $p->set_file(Array('logs' => 'logs.tpl'));
48                        $p->set_block('logs','list','list');
49                        $p->set_block('logs','row','row');
50                        $p->set_block('logs','row_empty','row_empty');
51
52                        //Administrador realizou uma pesquisa no log
53                        if (($_POST['query_manager_lid'] != '') || ($_POST['query_action'] != '') || ($_POST['query_date'] != '') || ($_POST['query_hour'] != '') || ($_POST['query_other'] != ''))
54                        {
55                                $query = "SELECT manager,date,userinfo,action FROM phpgw_expressoadmin_log WHERE";
56                               
57                                if ($_POST['query_manager_lid'] != '')
58                                {
59                                        $query .= " manager LIKE '%".$_POST['query_manager_lid']."%'";
60                                }
61                               
62                                if ($_POST['query_date'] != '')
63                                {
64                                        if ($_POST['query_manager_lid'] != '')
65                                                $query .= " AND";
66                                       
67                                        if ($_POST['query_hour'] != '')
68                                                $query .= " date > TO_TIMESTAMP('".$_POST['query_date'].$_POST['query_hour']."','DD/MM/YYYYHH24:MI') AND date < TO_TIMESTAMP('".$_POST['query_date'].$_POST['query_hour']."','DD/MM/YYYYHH24:MI') + INTERVAL '1 minute'";
69                                        else
70                                                $query .= " date > TO_TIMESTAMP('".$_POST['query_date']."','DD/MM/YYYY') AND date < TO_TIMESTAMP('".$_POST['query_date']."','DD/MM/YYYY') + INTERVAL '1 day'";
71                                }
72                               
73                                if ($_POST['query_action'])
74                                {
75                                        if (($_POST['query_manager_lid'] != '') || ($_POST['query_date'] != ''))
76                                                $query .= " AND";
77                                       
78                                        $query .= " action LIKE '%".$_POST['query_action']."%'";
79                                }
80
81                                if ($_POST['query_other'])
82                                {
83                                        if (($_POST['query_manager_lid'] != '') || ($_POST['query_date'] != '') || ($_POST['query_action'] != ''))
84                                                $query .= " AND";
85                                       
86                                        $query .= " userinfo LIKE '%" . $_POST['query_other'] . "%'";
87                                        $query .= "OR action LIKE '%" . $_POST['query_other'] . "%'";
88                                        $query .= "OR manager LIKE '%" . $_POST['query_other'] . "%'";
89                                }
90                               
91                                $query .= " ORDER by date DESC";
92                               
93                                $GLOBALS['phpgw']->db->query($query);
94                                while($GLOBALS['phpgw']->db->next_record())
95                                {
96                                        $logs[] = $GLOBALS['phpgw']->db->row();
97                                }
98                        }
99                       
100                        $var = Array(
101                                'bg_color'                      => $GLOBALS['phpgw_info']['theme']['bg_color'],
102                                'th_bg'                         => $GLOBALS['phpgw_info']['theme']['th_bg'],
103                                'back_url'                      => $GLOBALS['phpgw']->link('/expressoAdmin1_2/index.php'),
104                                'search_action'         => $GLOBALS['phpgw']->link('/index.php','menuaction=expressoAdmin1_2.uilogs.list_logs'),
105                               
106                                'query_manager_lid'     => $_POST['query_manager_lid'],
107                                'query_action'          => $_POST['query_action'],
108                                'query_date'            => $_POST['query_date'],
109                                'query_hour'            => $_POST['query_hour'],
110                                'query_other'           => $_POST['query_other'],
111                        );
112                        $p->set_var($var);
113                        $p->set_var($this->functions->make_dinamic_lang($p, 'list'));
114
115                        if ((!count($logs)) && (($_POST['query_manager_lid'] != '') || ($_POST['query_date'] != '') || ($_POST['query_hour'] != '')))
116                        {
117                                $p->set_var('message',lang('No matches found'));
118                        }
119                        else if (count($logs))
120                        {
121                                foreach ($logs as $log)
122                                {
123                                        //_debug_array($log);
124                                        $this->nextmatchs->template_alternate_row_color($p);
125                                       
126                                        //Date treatment
127                                        $a_date = split(" ", $log['date']);
128                                        $a_day = split("-", $a_date[0]);
129                                        $a_day_tmp = array_reverse($a_day);
130                                        $a_day = join($a_day_tmp, "/");
131                                        $a_hour = split("\.", $a_date[1]);
132                                       
133                                        $var = array(
134                                                'row_date'                      => $a_day . '  ' . $a_hour[0],                                         
135                                                'row_manager_lid'       => $log['manager'],
136                                                'row_action'            => lang($log['action']),
137                                                'row_about'                     => $log['userinfo']
138                                        );
139                                        $p->set_var($var);
140                                        $p->set_var('row_view',$this->row_action('view','log',$log['date']));
141                                        $p->parse('rows','row',True);
142                                }
143                        }
144                        $p->parse('rows','row_empty',True);
145                        $p->pfp('out','list');
146                }
147                               
148                function row_action($action,$type,$date)
149                {
150                        return '<a href="'.$GLOBALS['phpgw']->link('/index.php',Array(
151                                'menuaction' => 'expressoAdmin1_2.uilogs.'.$action.'_'.$type,
152                                'date' => $date
153                        )).'"> '.lang($action).' </a>';
154                }               
155        }               
156?>
Note: See TracBrowser for help on using the repository browser.