ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilTermsOfServiceAcceptanceHistoryProvider.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceTableDatabaseDataProvider.php';
5 
11 {
17  protected function getSelectPart(array $params, array $filter)
18  {
19  $fields = array(
20  'tos_acceptance_track.tosv_id',
21  'ud.usr_id',
22  'ud.login',
23  'ud.firstname',
24  'ud.lastname',
25  'tos_acceptance_track.ts',
26  'tos_versions.src',
27  'tos_versions.text',
28  'tos_versions.lng'
29  );
30 
31  return implode(', ', $fields);
32  }
33 
39  protected function getFromPart(array $params, array $filter)
40  {
41  $joins = array(
42  'INNER JOIN tos_acceptance_track ON tos_acceptance_track.usr_id = ud.usr_id',
43  'INNER JOIN tos_versions ON tos_versions.id = tos_acceptance_track.tosv_id',
44  );
45 
46  return 'usr_data ud ' . implode(' ', $joins);
47  }
48 
54  protected function getWherePart(array $params, array $filter)
55  {
56  $where = array();
57 
58  if (isset($filter['query']) && strlen($filter['query'])) {
59  $where[] = '(' . implode(' OR ', array(
60  $this->db->like('ud.login', 'text', '%' . $filter['query'] . '%'),
61  $this->db->like('ud.firstname', 'text', '%' . $filter['query'] . '%'),
62  $this->db->like('ud.lastname', 'text', '%' . $filter['query'] . '%'),
63  $this->db->like('ud.email', 'text', '%' . $filter['query'] . '%')
64  )) . ')';
65  }
66 
67  if (isset($filter['lng']) && strlen($filter['lng'])) {
68  $where[] = 'tos_versions.lng = ' . $this->db->quote($filter['lng'], 'text');
69  }
70 
71  if (isset($filter['period']) && is_array($filter['period'])) {
72  $where[] = '(' . implode(' AND ', array(
73  'tos_acceptance_track.ts >= ' . $this->db->quote($filter['period']['start'], 'integer'),
74  'tos_acceptance_track.ts <= ' . $this->db->quote($filter['period']['end'], 'integer')
75  )) . ')';
76  }
77 
78  return implode(' AND ', $where);
79  }
80 
86  protected function getGroupByPart(array $params, array $filter)
87  {
88  return '';
89  }
90 
96  protected function getHavingPart(array $params, array $filter)
97  {
98  return '';
99  }
100 
107  protected function getOrderByPart(array $params, array $filter)
108  {
109  if (isset($params['order_field'])) {
110  if (!is_string($params['order_field'])) {
111  throw new InvalidArgumentException('Please provide a valid order field.');
112  }
113 
114  if (!in_array($params['order_field'], array('lng', 'login', 'firstname', 'lastname', 'src', 'ts'))) {
115  throw new InvalidArgumentException('Please provide a valid order field.');
116  }
117 
118  if ($params['order_field'] == 'ts') {
119  $params['order_field'] = 'tos_acceptance_track.ts';
120  }
121 
122  if (!isset($params['order_direction'])) {
123  $params['order_direction'] = 'ASC';
124  } elseif (!in_array(strtolower($params['order_direction']), array('asc', 'desc'))) {
125  throw new InvalidArgumentException('Please provide a valid order direction.');
126  }
127 
128  return $params['order_field'] . ' ' . $params['order_direction'];
129  }
130 
131  return '';
132  }
133 }
$params
Definition: disable.php:11
Create styles array
The data for the language used.