@@ -22,12 +22,12 @@ discard block |
||
22 | 22 | protected $ad_locations_table; |
23 | 23 | |
24 | 24 | /** |
25 | - * Constructor |
|
26 | - * |
|
27 | - * @param \phpbb\db\driver\driver_interface $db DB driver interface |
|
28 | - * @param string $ads_table Ads table |
|
29 | - * @param string $ad_locations_table Ad locations table |
|
30 | - */ |
|
25 | + * Constructor |
|
26 | + * |
|
27 | + * @param \phpbb\db\driver\driver_interface $db DB driver interface |
|
28 | + * @param string $ads_table Ads table |
|
29 | + * @param string $ad_locations_table Ad locations table |
|
30 | + */ |
|
31 | 31 | public function __construct(\phpbb\db\driver\driver_interface $db, $ads_table, $ad_locations_table) |
32 | 32 | { |
33 | 33 | $this->db = $db; |
@@ -36,11 +36,11 @@ discard block |
||
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
39 | - * Get specific ad |
|
40 | - * |
|
41 | - * @param int $ad_id Advertisement ID |
|
42 | - * @return mixed Array with advertisement data, false if ad doesn't exist |
|
43 | - */ |
|
39 | + * Get specific ad |
|
40 | + * |
|
41 | + * @param int $ad_id Advertisement ID |
|
42 | + * @return mixed Array with advertisement data, false if ad doesn't exist |
|
43 | + */ |
|
44 | 44 | public function get_ad($ad_id) |
45 | 45 | { |
46 | 46 | $sql = 'SELECT * |
@@ -54,11 +54,11 @@ discard block |
||
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
57 | - * Get one ad per every location |
|
58 | - * |
|
59 | - * @param array $ad_locations List of ad locations to fetch ads for |
|
60 | - * @return array List of ad codes for each location |
|
61 | - */ |
|
57 | + * Get one ad per every location |
|
58 | + * |
|
59 | + * @param array $ad_locations List of ad locations to fetch ads for |
|
60 | + * @return array List of ad codes for each location |
|
61 | + */ |
|
62 | 62 | public function get_ads($ad_locations) |
63 | 63 | { |
64 | 64 | $sql = 'SELECT location_id, ad_id, ad_code |
@@ -86,10 +86,10 @@ discard block |
||
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
89 | - * Get all advertisements |
|
90 | - * |
|
91 | - * @return array List of all ads |
|
92 | - */ |
|
89 | + * Get all advertisements |
|
90 | + * |
|
91 | + * @return array List of all ads |
|
92 | + */ |
|
93 | 93 | public function get_all_ads() |
94 | 94 | { |
95 | 95 | $sql = 'SELECT ad_id, ad_name, ad_enabled, ad_end_date, ad_views, ad_clicks, ad_views_limit, ad_clicks_limit |
@@ -102,14 +102,14 @@ discard block |
||
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
105 | - * Increment views for specified ads |
|
106 | - * |
|
107 | - * Note, that views are incremented only by one even when |
|
108 | - * an ad is displayed multiple times on the same page. |
|
109 | - * |
|
110 | - * @param array $ad_ids IDs of ads to increment views |
|
111 | - * @return void |
|
112 | - */ |
|
105 | + * Increment views for specified ads |
|
106 | + * |
|
107 | + * Note, that views are incremented only by one even when |
|
108 | + * an ad is displayed multiple times on the same page. |
|
109 | + * |
|
110 | + * @param array $ad_ids IDs of ads to increment views |
|
111 | + * @return void |
|
112 | + */ |
|
113 | 113 | public function increment_ads_views($ad_ids) |
114 | 114 | { |
115 | 115 | if (!empty($ad_ids)) |
@@ -122,11 +122,11 @@ discard block |
||
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
125 | - * Increment clicks for specified ad |
|
126 | - * |
|
127 | - * @param array $ad_id ID of an ad to increment clicks |
|
128 | - * @return void |
|
129 | - */ |
|
125 | + * Increment clicks for specified ad |
|
126 | + * |
|
127 | + * @param array $ad_id ID of an ad to increment clicks |
|
128 | + * @return void |
|
129 | + */ |
|
130 | 130 | public function increment_ad_clicks($ad_id) |
131 | 131 | { |
132 | 132 | $sql = 'UPDATE ' . $this->ads_table . ' |
@@ -136,11 +136,11 @@ discard block |
||
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
139 | - * Insert new advertisement to the database |
|
140 | - * |
|
141 | - * @param array $data New ad data |
|
142 | - * @return int New advertisement ID |
|
143 | - */ |
|
139 | + * Insert new advertisement to the database |
|
140 | + * |
|
141 | + * @param array $data New ad data |
|
142 | + * @return int New advertisement ID |
|
143 | + */ |
|
144 | 144 | public function insert_ad($data) |
145 | 145 | { |
146 | 146 | $data = $this->intersect_ad_data($data); |
@@ -152,12 +152,12 @@ discard block |
||
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
155 | - * Update advertisement |
|
156 | - * |
|
157 | - * @param int $ad_id Advertisement ID |
|
158 | - * @param array $data List of data to update in the database |
|
159 | - * @return int Number of affected rows. Can be used to determine if any ad has been updated. |
|
160 | - */ |
|
155 | + * Update advertisement |
|
156 | + * |
|
157 | + * @param int $ad_id Advertisement ID |
|
158 | + * @param array $data List of data to update in the database |
|
159 | + * @return int Number of affected rows. Can be used to determine if any ad has been updated. |
|
160 | + */ |
|
161 | 161 | public function update_ad($ad_id, $data) |
162 | 162 | { |
163 | 163 | $data = $this->intersect_ad_data($data); |
@@ -171,11 +171,11 @@ discard block |
||
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
174 | - * Delete advertisement |
|
175 | - * |
|
176 | - * @param int $ad_id Advertisement ID |
|
177 | - * @return int Number of affected rows. Can be used to determine if any ad has been deleted. |
|
178 | - */ |
|
174 | + * Delete advertisement |
|
175 | + * |
|
176 | + * @param int $ad_id Advertisement ID |
|
177 | + * @return int Number of affected rows. Can be used to determine if any ad has been deleted. |
|
178 | + */ |
|
179 | 179 | public function delete_ad($ad_id) |
180 | 180 | { |
181 | 181 | $sql = 'DELETE FROM ' . $this->ads_table . ' |
@@ -186,11 +186,11 @@ discard block |
||
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
189 | - * Get all locations for specified advertisement |
|
190 | - * |
|
191 | - * @param int $ad_id Advertisement ID |
|
192 | - * @return array List of template locations for specified ad |
|
193 | - */ |
|
189 | + * Get all locations for specified advertisement |
|
190 | + * |
|
191 | + * @param int $ad_id Advertisement ID |
|
192 | + * @return array List of template locations for specified ad |
|
193 | + */ |
|
194 | 194 | public function get_ad_locations($ad_id) |
195 | 195 | { |
196 | 196 | $ad_locations = array(); |
@@ -209,12 +209,12 @@ discard block |
||
209 | 209 | } |
210 | 210 | |
211 | 211 | /** |
212 | - * Insert advertisement locations |
|
213 | - * |
|
214 | - * @param int $ad_id Advertisement ID |
|
215 | - * @param array $ad_locations List of template locations for this ad |
|
216 | - * @return void |
|
217 | - */ |
|
212 | + * Insert advertisement locations |
|
213 | + * |
|
214 | + * @param int $ad_id Advertisement ID |
|
215 | + * @param array $ad_locations List of template locations for this ad |
|
216 | + * @return void |
|
217 | + */ |
|
218 | 218 | public function insert_ad_locations($ad_id, $ad_locations) |
219 | 219 | { |
220 | 220 | $sql_ary = array(); |
@@ -229,11 +229,11 @@ discard block |
||
229 | 229 | } |
230 | 230 | |
231 | 231 | /** |
232 | - * Delete advertisement locations |
|
233 | - * |
|
234 | - * @param int $ad_id Advertisement ID |
|
235 | - * @return void |
|
236 | - */ |
|
232 | + * Delete advertisement locations |
|
233 | + * |
|
234 | + * @param int $ad_id Advertisement ID |
|
235 | + * @return void |
|
236 | + */ |
|
237 | 237 | public function delete_ad_locations($ad_id) |
238 | 238 | { |
239 | 239 | $sql = 'DELETE FROM ' . $this->ad_locations_table . ' |
@@ -242,11 +242,11 @@ discard block |
||
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
245 | - * Load memberships of the user |
|
246 | - * |
|
247 | - * @param int $user_id User ID to load memberships |
|
248 | - * @return array List of group IDs user is member of |
|
249 | - */ |
|
245 | + * Load memberships of the user |
|
246 | + * |
|
247 | + * @param int $user_id User ID to load memberships |
|
248 | + * @return array List of group IDs user is member of |
|
249 | + */ |
|
250 | 250 | public function load_memberships($user_id) |
251 | 251 | { |
252 | 252 | $memberships = array(); |
@@ -264,10 +264,10 @@ discard block |
||
264 | 264 | } |
265 | 265 | |
266 | 266 | /** |
267 | - * Load all board groups |
|
268 | - * |
|
269 | - * @return array List of groups |
|
270 | - */ |
|
267 | + * Load all board groups |
|
268 | + * |
|
269 | + * @return array List of groups |
|
270 | + */ |
|
271 | 271 | public function load_groups() |
272 | 272 | { |
273 | 273 | $sql = 'SELECT group_id, group_name, group_type |
@@ -281,11 +281,11 @@ discard block |
||
281 | 281 | } |
282 | 282 | |
283 | 283 | /** |
284 | - * Make sure only necessary data make their way to SQL query |
|
285 | - * |
|
286 | - * @param array $data List of data to query the database |
|
287 | - * @return array Cleaned data that contain only valid keys |
|
288 | - */ |
|
284 | + * Make sure only necessary data make their way to SQL query |
|
285 | + * |
|
286 | + * @param array $data List of data to query the database |
|
287 | + * @return array Cleaned data that contain only valid keys |
|
288 | + */ |
|
289 | 289 | protected function intersect_ad_data($data) |
290 | 290 | { |
291 | 291 | return array_intersect_key($data, array( |
@@ -301,11 +301,11 @@ discard block |
||
301 | 301 | } |
302 | 302 | |
303 | 303 | /** |
304 | - * Get the random statement for this database layer |
|
305 | - * Random function should generate a float value between 0 and 1 |
|
306 | - * |
|
307 | - * @return string Random statement for current database layer |
|
308 | - */ |
|
304 | + * Get the random statement for this database layer |
|
305 | + * Random function should generate a float value between 0 and 1 |
|
306 | + * |
|
307 | + * @return string Random statement for current database layer |
|
308 | + */ |
|
309 | 309 | protected function sql_random() |
310 | 310 | { |
311 | 311 | switch ($this->db->get_sql_layer()) |