PluginProbe
WP Directory Kit / 1.2.7
WP Directory Kit v1.2.7
1.5.6 1.5.5 1.5.4 1.5.3 trunk 1.1.0 1.1.6 1.1.8 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.8 1.4.0 1.4.1 All 35 releases
wpdirectorykit / application / controllers / Wdk_listing.php

Wdk_listing.php in WP Directory Kit 1.2.7, at application/controllers/Wdk_listing.php

624 lines 28.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly;
3
4 class Wdk_listing extends Winter_MVC_Controller {
5
6 public function __construct(){
7 parent::__construct();
8 }
9
10 // Edit listing method
11 public function index()
12 {
13 $this->load->model('field_m');
14 $this->load->model('listing_m');
15 $this->load->model('listingfield_m');
16 $this->load->model('listingusers_m');
17 $this->load->model('category_m');
18 $this->load->model('location_m');
19 $this->load->model('user_m');
20 $this->load->model('categorieslistings_m');
21 $this->load->model('locationslistings_m');
22 $this->load->load_helper('listing');
23
24 $listing_post_id = (int) $this->input->post_get('id');
25
26 wdk_access_check('listing_m', $listing_post_id, NULL, 'edit');
27
28 $this->data['db_data'] = NULL;
29 $this->data['db_data']['listing_agents'] = array();
30 $this->data['db_data']['listing_sub_locations'] = array();
31 $this->data['db_data']['listing_sub_categories'] = array();
32 $this->data['form'] = &$this->form;
33 $this->data['edit_log'] = NULL;
34
35 $this->data['categories'] = $this->category_m->get_parents();
36 $this->data['locations'] = $this->location_m->get_parents();
37
38 $or_like = "(meta_value LIKE '%administrator%'
39 OR meta_value LIKE '%wdk_agency%'
40 OR meta_value LIKE '%wdk_agent%'
41 OR meta_value LIKE '%wdk_owner%')";
42
43 $this->data['agents'] = $this->user_m->get_agents_names(array(), $or_like);
44
45 if(!empty($listing_post_id))
46 {
47 $listing_post = get_post( $listing_post_id );
48
49 $listing_db_data = $this->listing_m->get($listing_post_id, TRUE);
50
51 $listingfield_db_data = $this->listingfield_m->get($listing_post_id, TRUE);
52 $listingusers_db_data = $this->listingusers_m->get($listing_post_id);
53
54 $this->data['db_data'] = array_merge((array) $listing_post,
55 (array) $listing_db_data,
56 (array) $listingfield_db_data);
57
58 $this->data['db_data']['listing_agents'] = array();
59 $this->data['db_data']['listing_sub_locations'] = array();
60 $this->data['db_data']['listing_sub_categories'] = array();
61
62 foreach ($listingusers_db_data as $key => $listinguser) {
63 if(isset($this->data['agents'][$listinguser->user_id]))
64 $this->data['db_data']['listing_agents'] [$listinguser->user_id]= $this->data['agents'][$listinguser->user_id];
65 }
66
67 $this->data['db_data']['listing_sub_locations'] = wdk_generate_other_locations_keys($listing_post_id);
68 $this->data['db_data']['listing_sub_categories'] = wdk_generate_other_categories_keys($listing_post_id);
69 if(function_exists('run_wdk_payments')) {
70 $this->data['packages'] = array();
71
72 global $Winter_MVC_wdk_payments;
73 $Winter_MVC_wdk_payments->model('package_m');
74
75 $packages = $Winter_MVC_wdk_payments->package_m->get_by(array('(date_from IS NULL OR date_from < \''.current_time( 'mysql' ).'\')'=>NULL,
76 '(date_to IS NULL OR date_to > \''.current_time( 'mysql' ).'\')'=>NULL,
77 '(location_id IS NULL OR location_id = '.wdk_show_data('location_id', $listing_db_data, '0', TRUE, TRUE).')'=>NULL,
78 '(category_id IS NULL OR category_id = '.wdk_show_data('category_id', $listing_db_data, '0', TRUE, TRUE).')'=>NULL));
79 if (count($packages) > 0) {
80 foreach($packages as $package) {
81 $this->data['packages'][wdk_show_data('idpackage', $package, TRUE, TRUE)] = wdk_show_data('idpackage', $package,'', TRUE, TRUE)
82 .', '.wdk_show_data('package_name', $package,'', TRUE, TRUE)
83 .'('.wdk_get_date(wdk_show_data('date_to', $package,'', TRUE, TRUE)).')';
84 }
85 }
86 }
87
88 $this->load->model('editlog_m');
89 $this->data['edit_log'] = $this->editlog_m->get_pagination_listing($listing_post_id, 10, NULL);
90 }
91
92 if(isset($_POST['listing_agents'])) {
93 $this->data['db_data']['listing_agents'] = array();
94 foreach ($_POST['listing_agents'] as $user_id) {
95 if(isset($this->data['agents'][intval($user_id)]))
96 $this->data['db_data']['listing_agents'] [intval($user_id)]= $this->data['agents'][intval($user_id)];
97 }
98 }
99
100 if(isset($_POST['listing_sub_locations'])) {
101 $this->data['db_data']['listing_sub_locations'] = $_POST['listing_sub_locations'];
102 }
103 if(isset($_POST['listing_sub_categories'])) {
104 $this->data['db_data']['listing_sub_categories'] = $_POST['listing_sub_categories'];
105 }
106
107 $this->data['subscriptions'] = array();
108 $this->data['subscriptions_data'] = array();
109
110 if(wdk_get_option('wdk_membership_is_enable_subscriptions') && function_exists('run_wdk_membership')){
111 global $Winter_MVC_wdk_membership;
112 $Winter_MVC_wdk_membership->model('subscription_user_m');
113 $Winter_MVC_wdk_membership->model('subscription_m');
114
115 $this->db->select('*');
116 $this->db->join($Winter_MVC_wdk_membership->subscription_m->_table_name.' ON '.$Winter_MVC_wdk_membership->subscription_m->_table_name.'.idsubscription = '.$Winter_MVC_wdk_membership->subscription_user_m->_table_name.'.subscription_id');
117 $this->db->join($this->db->prefix.'wdk_categories ON '.$this->db->prefix.'wdk_categories.idcategory = '.$Winter_MVC_wdk_membership->subscription_m->_table_name.'.category_id', TRUE, 'LEFT');
118 $this->db->join($this->db->prefix.'wdk_locations ON '.$this->db->prefix.'wdk_locations.idlocation = '.$Winter_MVC_wdk_membership->subscription_m->_table_name.'.location_id', TRUE, 'LEFT');
119 $this->db->where(array(
120 '(date_expire > \''.current_time( 'mysql' ).'\')'=>NULL,
121 '(user_id = \''.wmvc_show_data('user_id_editor', $this->data['db_data'], false).'\')'=>NULL,
122 '(status = \'ACTIVE\')'=>NULL,
123 )
124 );
125
126 $subscriptions = $Winter_MVC_wdk_membership->subscription_user_m->get();
127 if (count($subscriptions) > 0) {
128 foreach($subscriptions as $subscription) {
129 $this->data['subscriptions'][wdk_show_data('subscription_id',$subscription,'', TRUE, TRUE)] = wdk_show_data('subscription_id', $subscription,'', TRUE, TRUE)
130 .', '.wdk_show_data('subscription_name', $subscription,'', TRUE, TRUE)
131 .', '.wdk_show_data('location_title',$subscription, esc_html__('Any', 'wpdirectorykit'), TRUE, TRUE).' '. esc_html__('Location', 'wpdirectorykit')
132 .', '.wdk_show_data('category_title',$subscription, esc_html__('Any', 'wpdirectorykit'), TRUE, TRUE).' '. esc_html__('Category', 'wpdirectorykit')
133 .'('.wdk_get_date(wdk_show_data('date_expire', $subscription,'', TRUE, TRUE)).')';
134 }
135 }
136 }
137
138
139 $this->db->where(array('field_type !='=> 'SECTION'));
140 $this->data['listing_fields'] = $this->field_m->get();
141
142 $this->data['fields'] = $this->field_m->get();
143
144 $rules = array(
145 array(
146 'field' => 'post_title',
147 'label' => __('Title', 'wpdirectorykit'),
148 'rules' => 'required'
149 ),
150 array(
151 'field' => 'post_content',
152 'label' => __('Content', 'wpdirectorykit'),
153 'rules' => 'required'
154 ),
155 array(
156 'field' => 'category_id',
157 'label' => __('Category', 'wpdirectorykit'),
158 'rules' => (wdk_get_option('wdk_listing_category_required')) ? 'required':''
159 ),
160 array(
161 'field' => 'location_id',
162 'label' => __('Location', 'wpdirectorykit'),
163 'rules' => (wdk_get_option('wdk_listing_location_required')) ? 'required':''
164 ),
165 array(
166 'field' => 'address',
167 'label' => __('Address', 'wpdirectorykit'),
168 'rules' => ''
169 ),
170 array(
171 'field' => 'lat',
172 'label' => __('lat', 'wpdirectorykit'),
173 'rules' => (wdk_get_option('wdk_is_address_enabled')) ? 'wdk_gps_single':''
174 ),
175 array(
176 'field' => 'lng',
177 'label' => __('lng', 'wpdirectorykit'),
178 'rules' => (wdk_get_option('wdk_is_address_enabled')) ? 'wdk_gps_single':''
179 ),
180 array(
181 'field' => 'listing_images',
182 'label' => __('Listing images', 'wpdirectorykit'),
183 'rules' => (wdk_get_option('wdk_listings_images_required_enable')) ? 'required' : ''
184 ),
185 array(
186 'field' => 'listing_plans_documents',
187 'label' => __('Listing plans and documents', 'wpdirectorykit'),
188 'rules' => ''
189 ),
190 array(
191 'field' => 'is_featured',
192 'label' => __('Is Featured', 'wpdirectorykit'),
193 'rules' => ''
194 ),
195 array(
196 'field' => 'is_activated',
197 'label' => __('Is Activated', 'wpdirectorykit'),
198 'rules' => ''
199 ),
200 array(
201 'field' => 'is_approved',
202 'label' => __('Is Approved', 'wpdirectorykit'),
203 'rules' => ''
204 ),
205 array(
206 'field' => 'user_id_editor',
207 'label' => __('Agents', 'wpdirectorykit'),
208 'rules' => ''
209 ),
210 array(
211 'field' => 'listing_agents',
212 'label' => __('Agents', 'wpdirectorykit'),
213 'rules' => ''
214 ),
215 array(
216 'field' => 'listing_sub_locations',
217 'label' => __('Locations', 'wpdirectorykit'),
218 'rules' => ''
219 ),
220 array(
221 'field' => 'listing_sub_categories',
222 'label' => __('Categories', 'wpdirectorykit'),
223 'rules' => ''
224 ),
225 array(
226 'field' => 'package_id',
227 'label' => __('Package', 'wpdirectorykit'),
228 'rules' => ''
229 ),
230 array(
231 'field' => 'subscription_id',
232 'label' => __('Subscription id', 'wpdirectorykit'),
233 'rules' => ''
234 ),
235 array(
236 'field' => 'listing_parent_post_id',
237 'label' => __('Listing parent id', 'wpdirectorykit'),
238 'rules' => ''
239 ),
240 array(
241 'field' => 'listing_related_ids',
242 'label' => __('Listing childs', 'wpdirectorykit'),
243 'rules' => ''
244 ),
245 );
246
247 $rules[] = array(
248 'field' => 'rank',
249 'label' => __('Rank', 'wpdirectorykit'),
250 'rules' => 'numeric'
251 );
252
253
254 foreach($this->data['fields'] as $key => $field)
255 {
256 if($field->field_type == 'SECTION'){
257 $this->data['fields'][$key]->is_required = '';
258 continue;
259 }
260
261 $rule_required = (wmvc_show_data('is_required', $field) == 1) ? 'required' : '';
262
263 if(wmvc_show_data('validation', $field)) {
264 if(!empty($rule_required)) {
265 $rule_required .= '|';
266 }
267 $rule_required .= wmvc_show_data('validation', $field);
268 }
269
270 if(!empty(wmvc_show_data('min_length', $field))) {
271 if(!empty($rule_required)) {
272 $rule_required .= '|';
273 }
274
275 if(wmvc_show_data('field_type', $field) == "NUMBER") {
276 $rule_required .= "min_number";
277 } else {
278 $rule_required .= "min_length";
279 }
280 $rule_required .= "[".wmvc_show_data('min_length', $field)."]";
281
282 }
283
284 if(!empty(wmvc_show_data('max_length', $field))) {
285 if(!empty($rule_required)) {
286 $rule_required .= '|';
287 }
288 if(wmvc_show_data('field_type', $field) == "NUMBER") {
289 $rule_required .= "max_number";
290 } else {
291 $rule_required .= "max_length";
292 }
293 $rule_required .= "[".wmvc_show_data('max_length', $field)."]";
294 }
295
296 /* clear rules, because hidden field */
297 if(isset($_POST['category_id']) && !empty($_POST['category_id'])) {
298 if(wdk_depend_is_hidden_field($field->idfield, intval($_POST['category_id']))) {
299 $rule_required = '';
300 }
301 }
302
303 $rules[] =
304 array(
305 'field' => 'field_'.$field->idfield,
306 'label' => $field->field_label,
307 'rules' => $rule_required
308 );
309
310 if(isset($this->data['db_data']['field_'.$field->idfield.'_'.$field->field_type]))
311 $this->data['db_data']['field_'.$field->idfield] =
312 $this->data['db_data']['field_'.$field->idfield.'_'.$field->field_type];
313 }
314
315 $this->form->add_error_message('wdk_gps_single', __('Gps field is not valid, should be like xx.xxxxxx (between -180 and 180)', 'wpdirectorykit'));
316 if($this->form->run($rules))
317 {
318 // Check _wpnonce
319 check_admin_referer( 'wdk-listing-edit_'.$listing_post_id, '_wpnonce' );
320
321 $data = $this->listing_m->prepare_data(wdk_get_post(), $rules, FALSE);
322 // Save standard wp post
323
324 // Create post object
325 $listing_post = array(
326 'ID' => $listing_post_id,
327 'post_type' => 'wdk-listing',
328 'post_title' => wp_strip_all_tags( $data['post_title'] ),
329 'post_content' => $data['post_content'],
330 'post_status' => 'publish',
331 'post_author' => get_current_user_id()
332 );
333
334 // Insert the post into the database
335 $id = wp_insert_post( $listing_post );
336
337 // Save our main listing data
338
339 $listing_data = array('post_id' => $id);
340
341 $listing_data_fields = array('category_id', 'location_id', 'address', 'lat', 'lng', 'listing_images','listing_plans_documents', 'is_featured', 'is_activated','is_approved', 'package_id','rank','subscription_id',
342 'user_id_editor', 'listing_parent_post_id','listing_related_ids');
343 foreach($listing_data_fields as $field_name)
344 {
345 $listing_data[$field_name] = $data[$field_name];
346 }
347
348 $image_ids = explode(',', $data['listing_images']);
349
350 $listing_data['listing_images_path'] = '';
351 $listing_data['listing_images_path_medium'] = '';
352
353 if(is_array($image_ids)) {
354 foreach ($image_ids as $image_id) {
355 if(is_numeric($image_id))
356 {
357 $image_path = wp_get_original_image_path( $image_id);
358 if($image_path) {
359 /* path of image */
360 $next_path = str_replace(WP_CONTENT_DIR . '/uploads/','', $image_path);
361
362 if(!empty($listing_data['listing_images_path']))
363 $listing_data['listing_images_path'] .= ',';
364
365 $listing_data['listing_images_path'] .= $next_path;
366 }
367
368 $image_url = wp_get_attachment_image_url($image_id, 'large');
369 if($image_url) {
370 $parsed = parse_url($image_url);
371 $next_path = substr($parsed['path'], strpos($parsed['path'], 'uploads/')+8);
372
373 if(!empty($listing_data['listing_images_path_medium']))
374 $listing_data['listing_images_path_medium'] .= ',';
375
376 $listing_data['listing_images_path_medium'] .= $next_path;
377 }
378 }
379 }
380 }
381
382 if(wmvc_user_in_role('administrator') && $this->input->post('slug')) {
383 // update the post slug
384 wp_update_post( array(
385 'ID' => $id,
386 'post_name' => sanitize_text_field($this->input->post('slug'))
387 ));
388
389 }
390
391 if(!function_exists('run_wdk_membership')) {
392 if($listing_data['is_activated'] == 1) {
393 $listing_data['is_approved'] = 1;
394 } else {
395 $listing_data['is_approved'] = 0;
396 }
397 }
398
399 if(!wmvc_user_in_role('administrator')) {
400 unset($listing_data['rank']);
401 }
402
403 if(function_exists('run_wdk_payments') && wmvc_show_data('package_id', $listing_data_field, false)) {
404
405 global $Winter_MVC_wdk_payments;
406 $Winter_MVC_wdk_payments->model('package_m');
407 $package = $Winter_MVC_wdk_payments->package_m->get(wmvc_show_data('package_id', $listing_data_field, false), TRUE);
408 if ($packages) {
409 if(!isset($listing_data['rank']) || empty($listing_data['rank']))
410 $listing_data['rank'] = wdk_show_data('featured_rank',$package, 0, TRUE, TRUE);
411 $listing_data['date_package_expire'] = date('Y-m-d H:i:s', strtotime('+'.wdk_show_data('days_limit',$package, 0, TRUE, TRUE).'days'));
412 }
413 }
414
415 /* dates set */
416 if(isset($this->data['db_data']['date']))
417 $listing_data['date'] = $this->data['db_data']['date'];
418
419 $listing_data['date_modified'] = date('Y-m-d H:i:s');
420
421 if(empty($listing_db_data))
422 {
423 $this->listing_m->insert($listing_data, NULL);
424 }
425 else
426 {
427 $this->listing_m->insert($listing_data, $id);
428 }
429
430 // insert users/agents
431
432 if(function_exists('run_wdk_membership')){
433 $this->listingusers_m->delete_where(array('post_id' => $id));
434 if(is_array($data['listing_agents']))
435 foreach($data['listing_agents'] as $val)
436 {
437 $this->listingusers_m->insert(array('post_id' => $id, 'user_id' => $val), NULL);
438 }
439 }
440
441 $data_other_categories = array();
442 if(isset($data['listing_sub_categories']) || is_null($data['listing_sub_categories'])) {
443 $this->categorieslistings_m->delete_where(array('post_id' => $id));
444 if(is_array($data['listing_sub_categories']))
445 foreach($data['listing_sub_categories'] as $val)
446 {
447 $this->categorieslistings_m->insert(array('post_id' => $id, 'category_id' => $val), NULL);
448
449 $data_other_categories []= $val;
450 }
451 }
452
453 $data_other_locations = array();
454 if(isset($data['listing_sub_locations']) || is_null($data['listing_sub_locations'])) {
455 $this->locationslistings_m->delete_where(array('post_id' => $id));
456 if(is_array($data['listing_sub_locations']))
457 foreach($data['listing_sub_locations'] as $val)
458 {
459 $this->locationslistings_m->insert(array('post_id' => $id, 'location_id' => $val), NULL);
460 $data_other_locations []= $val;
461 }
462 }
463
464 $data_update = array(
465 'categories_list'=> '',
466 'locations_list'=>''
467 );
468
469 if(!empty($data_other_categories)) {
470 $data_update['categories_list'] = ','.join(',',$data_other_categories).',';
471 }
472
473 if(!empty($data_other_locations)) {
474 $data_update['locations_list'] = ','.join(',',$data_other_locations).',';
475 }
476
477
478 if(!empty($data_update))
479 $this->listing_m->insert($data_update, $id);
480
481 //exit($this->db->last_query());
482
483 // Save dynamic fields data
484
485 $data['post_id'] = $id;
486
487 if(empty($listingfield_db_data))
488 {
489 $this->listingfield_m->insert_custom_fields($this->data['listing_fields'], $data, NULL);
490 }
491 else
492 {
493 $this->listingfield_m->insert_custom_fields($this->data['listing_fields'], $data, $id);
494 }
495
496 $this->load->model('editlog_m');
497 $this->editlog_m->insert(array(
498 'user_id' => get_current_user_id(),
499 'post_id' => $id,
500 'date' => date('Y-m-d H:i:s'),
501 'ip' => $_SERVER['REMOTE_ADDR']
502 ));
503
504
505 do_action('wpdirectorykit/listing/saved', $id, $this->data['db_data']);
506
507 if(wdk_get_option('wdk_sub_listings_enable')) {
508 /* generate fast childs ids for parents */
509
510 if(isset($listing_data['listing_parent_post_id']) && !empty($listing_data['listing_parent_post_id'])) {
511
512 $this->db->select('post_id');
513 $this->db->order_by('sublisting_order,idlisting');
514 $this->db->from($this->listing_m->_table_name);
515 $this->db->where(array('listing_parent_post_id' => intval($listing_data['listing_parent_post_id'])));
516 $query = $this->db->get();
517
518 $listings_childs = '';
519 if ($this->db->num_rows() > 0)
520 foreach ($this->db->results() as $listing) {
521 $listings_childs .= $listing->post_id.',';
522 }
523
524 if(!empty($listings_childs))
525 $listings_childs = substr($listings_childs,0, -1);
526
527 $this->listing_m->insert(array('listing_related_ids' => $listings_childs), intval($listing_data['listing_parent_post_id']));
528 }
529
530 if(isset($listing_data['listing_related_ids']) && !empty($listing_data['listing_related_ids'])) {
531
532 $old_childs_ids = wmvc_show_data('listing_related_ids', $this->data['db_data'],'',TRUE, TRUE);
533 $order_index = 0;
534 $listings_childs = '';
535
536 $old_childs_ids = explode(',', $old_childs_ids);
537 $old_childs_ids = array_flip($old_childs_ids);
538 foreach (explode(',', $listing_data['listing_related_ids']) as $idlisting) {
539 $this->listing_m->insert(array('listing_parent_post_id' => $listing_post_id, 'sublisting_order'=>$order_index++), intval($idlisting));
540
541 if(isset($old_childs_ids[$idlisting])) {
542 unset($old_childs_ids[$idlisting]);
543 }
544 }
545
546 /* clear old related listings */
547 if(!empty($old_childs_ids)) {
548 foreach ($old_childs_ids as $idlisting => $v) {
549 $this->listing_m->insert(array('listing_parent_post_id' => NULL), intval($idlisting));
550 }
551 }
552 }
553 }
554
555 // redirect
556 if(empty($listing_post_id) && !empty($id))
557 {
558 wp_redirect(admin_url("admin.php?page=wdk_listing&id=$id&is_updated=true"));
559 exit;
560 }
561
562 /* fix checkbox after submit */
563 if(!empty($id))
564 {
565 $is_approved_before_save = (isset($this->data['db_data']['is_approved'])) ? $this->data['db_data']['is_approved'] : 0;
566
567 $listing_post = get_post( $id );
568 $listing_db_data = $this->listing_m->get($id, TRUE);
569 $listingfield_db_data = $this->listingfield_m->get($id, TRUE);
570 $listingusers_db_data = $this->listingusers_m->get($id);
571 $this->data['db_data'] = array_merge((array) $listing_post,
572 (array) $listing_db_data,
573 (array) $listingfield_db_data);
574
575 $this->data['db_data']['listing_agents'] = array();
576 $this->data['db_data']['listing_sub_locations'] = array();
577 $this->data['db_data']['listing_sub_categories'] = array();
578
579 foreach ($listingusers_db_data as $key => $listinguser) {
580 if(isset($this->data['agents'][$listinguser->user_id]))
581 $this->data['db_data']['listing_agents'] [$listinguser->user_id]= $this->data['agents'][$listinguser->user_id];
582 }
583
584 if(isset($_POST['listing_sub_locations'])) {
585 $this->data['db_data']['listing_sub_locations'] = $_POST['listing_sub_locations'];
586 unset($_POST['listing_sub_locations']);
587 }
588 if(isset($_POST['listing_sub_categories'])) {
589 $this->data['db_data']['listing_sub_categories'] = $_POST['listing_sub_categories'];
590 unset($_POST['listing_sub_categories']);
591 }
592
593 /* if approved message */
594 if (!empty($listing_post_id) && wmvc_show_data('user_id', $data, false)) {
595 if( $is_approved_before_save != 1 && wmvc_show_data('is_approved', $data) == 1 && wmvc_show_data('is_activated', $data) == 1) {
596
597 $user = get_userdata( wmvc_show_data('user_id', $data) );
598
599 $data_message = array();
600 $data_message['user'] = $user;
601 $data_message['post_id'] = $id;
602 $data_message['post'] = $this->data['db_data'];
603 $ret = wdk_mail($user->user_email, __('Your Listing Approved', 'wpdirectorykit'), $data_message, 'new_listing_approved');
604 }
605 }
606 }
607
608 }
609
610 $this->data['calendar_id'] = NULL;
611 if(!empty($listing_post_id) && function_exists('run_wdk_bookings')) {
612 global $Winter_MVC_wdk_bookings;
613 $Winter_MVC_wdk_bookings->model('calendar_m');
614 $calendar = $Winter_MVC_wdk_bookings->calendar_m->get_by(array('post_id'=>$listing_post_id), TRUE);
615 if($calendar) {
616 $this->data['calendar_id'] = $calendar->idcalendar;
617 }
618 }
619
620 $this->load->view('wdk_listing/index', $this->data);
621 }
622
623 }
624