@@ -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 array Advertisement data |
|
43 | - */ |
|
39 | + * Get specific ad |
|
40 | + * |
|
41 | + * @param int $ad_id Advertisement ID |
|
42 | + * @return array Advertisement data |
|
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_code |
@@ -82,10 +82,10 @@ discard block |
||
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
85 | - * Get all advertisements |
|
86 | - * |
|
87 | - * @return array List of all ads |
|
88 | - */ |
|
85 | + * Get all advertisements |
|
86 | + * |
|
87 | + * @return array List of all ads |
|
88 | + */ |
|
89 | 89 | public function get_all_ads() |
90 | 90 | { |
91 | 91 | $sql = 'SELECT ad_id, ad_name, ad_enabled, ad_end_date |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
101 | - * Insert new advertisement to the database |
|
102 | - * |
|
103 | - * @param array $data New ad data |
|
104 | - * @return int New advertisement ID |
|
105 | - */ |
|
101 | + * Insert new advertisement to the database |
|
102 | + * |
|
103 | + * @param array $data New ad data |
|
104 | + * @return int New advertisement ID |
|
105 | + */ |
|
106 | 106 | public function insert_ad($data) |
107 | 107 | { |
108 | 108 | $data = $this->intersect_ad_data($data); |
@@ -114,12 +114,12 @@ discard block |
||
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
117 | - * Update advertisement |
|
118 | - * |
|
119 | - * @param int $ad_id Advertisement ID |
|
120 | - * @param array $data List of data to update in the database |
|
121 | - * @return int Number of affected rows. Can be used to determine if any ad has been updated. |
|
122 | - */ |
|
117 | + * Update advertisement |
|
118 | + * |
|
119 | + * @param int $ad_id Advertisement ID |
|
120 | + * @param array $data List of data to update in the database |
|
121 | + * @return int Number of affected rows. Can be used to determine if any ad has been updated. |
|
122 | + */ |
|
123 | 123 | public function update_ad($ad_id, $data) |
124 | 124 | { |
125 | 125 | $data = $this->intersect_ad_data($data); |
@@ -133,11 +133,11 @@ discard block |
||
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
136 | - * Delete advertisement |
|
137 | - * |
|
138 | - * @param int $ad_id Advertisement ID |
|
139 | - * @return int Number of affected rows. Can be used to determine if any ad has been deleted. |
|
140 | - */ |
|
136 | + * Delete advertisement |
|
137 | + * |
|
138 | + * @param int $ad_id Advertisement ID |
|
139 | + * @return int Number of affected rows. Can be used to determine if any ad has been deleted. |
|
140 | + */ |
|
141 | 141 | public function delete_ad($ad_id) |
142 | 142 | { |
143 | 143 | $sql = 'DELETE FROM ' . $this->ads_table . ' |
@@ -148,10 +148,10 @@ discard block |
||
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
151 | - * Disable expired advertisements |
|
152 | - * |
|
153 | - * @return void |
|
154 | - */ |
|
151 | + * Disable expired advertisements |
|
152 | + * |
|
153 | + * @return void |
|
154 | + */ |
|
155 | 155 | public function disable_expired_ads() |
156 | 156 | { |
157 | 157 | $sql = 'UPDATE ' . $this->ads_table . ' |
@@ -161,11 +161,11 @@ discard block |
||
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
164 | - * Get all locations for specified advertisement |
|
165 | - * |
|
166 | - * @param int $ad_id Advertisement ID |
|
167 | - * @return array List of template locations for specified ad |
|
168 | - */ |
|
164 | + * Get all locations for specified advertisement |
|
165 | + * |
|
166 | + * @param int $ad_id Advertisement ID |
|
167 | + * @return array List of template locations for specified ad |
|
168 | + */ |
|
169 | 169 | public function get_ad_locations($ad_id) |
170 | 170 | { |
171 | 171 | $ad_locations = array(); |
@@ -184,12 +184,12 @@ discard block |
||
184 | 184 | } |
185 | 185 | |
186 | 186 | /** |
187 | - * Insert advertisement locations |
|
188 | - * |
|
189 | - * @param int $ad_id Advertisement ID |
|
190 | - * @param array $ad_locations List of template locations for this ad |
|
191 | - * @return void |
|
192 | - */ |
|
187 | + * Insert advertisement locations |
|
188 | + * |
|
189 | + * @param int $ad_id Advertisement ID |
|
190 | + * @param array $ad_locations List of template locations for this ad |
|
191 | + * @return void |
|
192 | + */ |
|
193 | 193 | public function insert_ad_locations($ad_id, $ad_locations) |
194 | 194 | { |
195 | 195 | $sql_ary = array(); |
@@ -204,11 +204,11 @@ discard block |
||
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
207 | - * Delete advertisement locations |
|
208 | - * |
|
209 | - * @param int $ad_id Advertisement ID |
|
210 | - * @return void |
|
211 | - */ |
|
207 | + * Delete advertisement locations |
|
208 | + * |
|
209 | + * @param int $ad_id Advertisement ID |
|
210 | + * @return void |
|
211 | + */ |
|
212 | 212 | public function delete_ad_locations($ad_id) |
213 | 213 | { |
214 | 214 | $sql = 'DELETE FROM ' . $this->ad_locations_table . ' |
@@ -217,11 +217,11 @@ discard block |
||
217 | 217 | } |
218 | 218 | |
219 | 219 | /** |
220 | - * Make sure only necessary data make their way to SQL query |
|
221 | - * |
|
222 | - * @param array $data List of data to query the database |
|
223 | - * @return array Cleaned data that contain only valid keys |
|
224 | - */ |
|
220 | + * Make sure only necessary data make their way to SQL query |
|
221 | + * |
|
222 | + * @param array $data List of data to query the database |
|
223 | + * @return array Cleaned data that contain only valid keys |
|
224 | + */ |
|
225 | 225 | protected function intersect_ad_data($data) |
226 | 226 | { |
227 | 227 | return array_intersect_key($data, array( |
@@ -234,10 +234,10 @@ discard block |
||
234 | 234 | } |
235 | 235 | |
236 | 236 | /** |
237 | - * Get the random statement for this database layer |
|
238 | - * |
|
239 | - * @return string Random statement for current database layer |
|
240 | - */ |
|
237 | + * Get the random statement for this database layer |
|
238 | + * |
|
239 | + * @return string Random statement for current database layer |
|
240 | + */ |
|
241 | 241 | protected function sql_random() |
242 | 242 | { |
243 | 243 | switch ($this->db->get_sql_layer()) |