| @@ 183-195 (lines=13) @@ | ||
| 180 | { |
|
| 181 | $data = $this->get_form_data('phpbb/ads/add'); |
|
| 182 | ||
| 183 | if ($preview) |
|
| 184 | { |
|
| 185 | $this->ad_preview($data['ad_code']); |
|
| 186 | } |
|
| 187 | else if (empty($this->errors)) |
|
| 188 | { |
|
| 189 | $ad_id = $this->manager->insert_ad($data); |
|
| 190 | $this->manager->insert_ad_locations($ad_id, $data['ad_locations']); |
|
| 191 | ||
| 192 | $this->log('ADD', $data['ad_name']); |
|
| 193 | ||
| 194 | $this->success('ACP_AD_ADD_SUCCESS'); |
|
| 195 | } |
|
| 196 | ||
| 197 | $this->assign_locations($data); |
|
| 198 | $this->assign_form_data($data); |
|
| @@ 234-249 (lines=16) @@ | ||
| 231 | { |
|
| 232 | $this->ad_preview($data['ad_code']); |
|
| 233 | } |
|
| 234 | else if (empty($this->errors)) |
|
| 235 | { |
|
| 236 | $success = $this->manager->update_ad($ad_id, $data); |
|
| 237 | ||
| 238 | if ($success) |
|
| 239 | { |
|
| 240 | // Only insert new ad locations to DB when ad exists |
|
| 241 | $this->manager->delete_ad_locations($ad_id); |
|
| 242 | $this->manager->insert_ad_locations($ad_id, $data['ad_locations']); |
|
| 243 | ||
| 244 | $this->log('EDIT', $data['ad_name']); |
|
| 245 | ||
| 246 | $this->success('ACP_AD_EDIT_SUCCESS'); |
|
| 247 | } |
|
| 248 | $this->error('ACP_AD_DOES_NOT_EXIST'); |
|
| 249 | } |
|
| 250 | } |
|
| 251 | else |
|
| 252 | { |
|