|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @package Redcore.Backend |
|
4
|
|
|
* @subpackage Models |
|
5
|
|
|
* |
|
6
|
|
|
* @copyright Copyright (C) 2008 - 2016 redCOMPONENT.com. All rights reserved. |
|
7
|
|
|
* @license GNU General Public License version 2 or later, see LICENSE. |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
defined('_JEXEC') or die; |
|
11
|
|
|
|
|
12
|
|
|
jimport('joomla.filesystem.folder'); |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Webservices Model |
|
16
|
|
|
* |
|
17
|
|
|
* @package Redcore.Backend |
|
18
|
|
|
* @subpackage Models |
|
19
|
|
|
* @since 1.2 |
|
20
|
|
|
*/ |
|
21
|
|
|
class RedcoreModelWebservice_History_Logs extends RModelList |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* Name of the filter form to load |
|
25
|
|
|
* |
|
26
|
|
|
* @var string |
|
27
|
|
|
*/ |
|
28
|
|
|
protected $filterFormName = 'filter_webservice_history_logs'; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Limitstart field used by the pagination |
|
32
|
|
|
* |
|
33
|
|
|
* @var string |
|
34
|
|
|
*/ |
|
35
|
|
|
protected $limitField = 'webservice_history_logs_limit'; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Constructor |
|
39
|
|
|
* |
|
40
|
|
|
* @param array $config Configuration array |
|
41
|
|
|
*/ |
|
42
|
|
|
public function __construct($config = array()) |
|
43
|
|
|
{ |
|
44
|
|
|
if (empty($config['filter_fields'])) |
|
45
|
|
|
{ |
|
46
|
|
|
$config['filter_fields'] = array( |
|
47
|
|
|
'webservice_name', 'whl.webservice_name', |
|
48
|
|
|
'webservice_version', 'whl.webservice_version', |
|
49
|
|
|
'webservice_client', 'whl.webservice_client', |
|
50
|
|
|
'operation', 'whl.operation', |
|
51
|
|
|
'using_soap', 'whl.using_soap', |
|
52
|
|
|
'authentication_user', 'whl.authentication_user', |
|
53
|
|
|
'created_date', 'whl.created_date', |
|
54
|
|
|
'created_by_start_date', 'created_by_end_date' |
|
55
|
|
|
); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
parent::__construct($config); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Build an SQL query to load the list data. |
|
63
|
|
|
* |
|
64
|
|
|
* @return JDatabaseQuery |
|
65
|
|
|
*/ |
|
66
|
|
|
protected function getListQuery() |
|
67
|
|
|
{ |
|
68
|
|
|
$db = $this->getDbo(); |
|
69
|
|
|
|
|
70
|
|
|
$query = $db->getQuery(true) |
|
71
|
|
|
->select('whl.*') |
|
72
|
|
|
->from($db->qn('#__redcore_webservice_history_log', 'whl')); |
|
73
|
|
|
|
|
74
|
|
|
$client = $this->getState('filter.webservice_client'); |
|
75
|
|
|
|
|
76
|
|
|
// Filter by webservice client. |
|
77
|
|
|
if ($client) |
|
78
|
|
|
{ |
|
79
|
|
|
$query->where('whl.webservice_client = ' . $db->quote($db->escape($client, true))); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
$version = $this->getState('filter.webservice_version'); |
|
83
|
|
|
|
|
84
|
|
|
// Filter by webservice version |
|
85
|
|
|
if ($version) |
|
86
|
|
|
{ |
|
87
|
|
|
$query->where('whl.webservice_version = ' . $db->quote($db->escape($version, true))); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
// Filter by operation. |
|
91
|
|
|
$operation = $this->getState('filter.operation'); |
|
92
|
|
|
|
|
93
|
|
|
if ($operation) |
|
94
|
|
|
{ |
|
95
|
|
|
$query->where('whl.operation like ' . $db->quote('%' . $db->escape($operation, true) . '%')); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
// Filter by using soap. |
|
99
|
|
|
$usingSoap = $this->getState('filter.using_soap'); |
|
100
|
|
|
|
|
101
|
|
|
if ($usingSoap) |
|
102
|
|
|
{ |
|
103
|
|
|
$query->where('whl.using_soap = ' . $db->quote($db->escape($usingSoap, true))); |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
// Filter by authentication user |
|
107
|
|
|
$user = $this->getState('filter.authentication_user'); |
|
108
|
|
|
|
|
109
|
|
|
if ($user) |
|
110
|
|
|
{ |
|
111
|
|
|
$query->where('whl.authentication_user = ' . $db->quote($db->escape($user, true))); |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
// Filter by start date |
|
115
|
|
|
$startDate = $this->getState('filter.created_by_start_date'); |
|
116
|
|
|
|
|
117
|
|
|
if ($startDate) |
|
118
|
|
|
{ |
|
119
|
|
|
$startDate = date('Y-m-d H:i:s', strtotime($startDate)); |
|
120
|
|
|
$query->where('whl.created_date >= ' . $db->quote($db->escape($startDate, true))); |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
// Filter by start date |
|
124
|
|
|
$endDate = $this->getState('filter.created_by_end_date'); |
|
125
|
|
|
|
|
126
|
|
|
if ($endDate) |
|
127
|
|
|
{ |
|
128
|
|
|
$endDate = date('Y-m-d H:i:s', strtotime($endDate)); |
|
129
|
|
|
$query->where('whl.created_date <= ' . $db->quote($db->escape($endDate, true))); |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
// Filter search |
|
133
|
|
|
$search = $this->getState('filter.search_webservice_history_logs'); |
|
134
|
|
|
|
|
135
|
|
|
if (!empty($search)) |
|
136
|
|
|
{ |
|
137
|
|
|
$search = $db->quote('%' . $db->escape($search, true) . '%'); |
|
138
|
|
|
$query->where('(whl.webservice_name LIKE ' . $search . ') OR (whl.url LIKE ' . $search . ')'); |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
// Ordering |
|
142
|
|
|
$orderList = $this->getState('list.ordering'); |
|
143
|
|
|
$directionList = $this->getState('list.direction'); |
|
144
|
|
|
|
|
145
|
|
|
$order = !empty($orderList) ? $orderList : 'whl.created_date'; |
|
146
|
|
|
$direction = !empty($directionList) ? $directionList : 'DESC'; |
|
147
|
|
|
$query->order($db->escape($order) . ' ' . $db->escape($direction)); |
|
148
|
|
|
|
|
149
|
|
|
return $query; |
|
150
|
|
|
} |
|
151
|
|
|
} |
|
152
|
|
|
|