PluginProbe
WP Directory Kit / 1.5.9
WP Directory Kit v1.5.9
1.5.9 1.5.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 All 37 releases
← All changes | application/controllers/Wdk.php +63 -7 1.1.6 → 1.5.9 View file →
@@ -51,8 +51,21 @@
51 51 foreach($dbusers as $dbuser) {
52 52 $this->data['users'][wmvc_show_data('ID', $dbuser)] = '#'.wmvc_show_data('ID', $dbuser).', '.wmvc_show_data('display_name', $dbuser);
53 53 }
54 54
55 + $this->data['fields_list'] = $this->field_m->get();
56 +
57 + $fields_data = $this->field_m->get();
58 + $this->data['fields_list'] = array();
59 +
60 + foreach($fields_data as $field)
61 + {
62 + if(wmvc_show_data('field_type', $field) == 'SECTION') {
63 + } else {
64 + $this->data['fields_list']['field_'.wmvc_show_data('idfield', $field)] = '#'.wmvc_show_data('idfield', $field).' '.wmvc_show_data('field_label', $field).'['.wmvc_show_data('field_type', $field).']';
65 + }
66 + }
67 +
55 68 $controller = 'listing';
56 69 $columns = array('ID', 'location_id', 'category_id', 'post_title', 'post_date', 'search', 'order_by', 'address','user_id_editor', 'is_featured','is_activated','is_approved');
57 70 $external_columns = array('location_id', 'category_id', 'post_title', 'user_id_editor',);
58 71
@@ -65,8 +78,10 @@
65 78 'post_date ASC' => __('Post Date', 'wpdirectorykit').' ASC',
66 79 'post_date DESC' => __('Post Date', 'wpdirectorykit').' DESC',
67 80 'date_modified ASC' => __('Last Modified Date', 'wpdirectorykit').' ASC',
68 81 'date_modified DESC' => __('Last Modified Date', 'wpdirectorykit').' DESC',
82 + $this->listing_m->_table_name.'.rank ASC, ID ASC' => __('Rank', 'wpdirectorykit').' ASC',
83 + $this->listing_m->_table_name.'.rank DESC, ID DESC' => __('Rank', 'wpdirectorykit').' DESC',
69 84 );
70 85
71 86 $rules = array(
72 87 array(
@@ -105,10 +120,28 @@
105 120 'rules' => ''
106 121 ),
107 122 );
108 123
124 + $custom_parameters = array();
125 + foreach ($this->input->get() as $key => $value) {
126 + if(stripos($key, 'c_field_') !== FALSE && stripos($key, '_field',8) !== FALSE) {
127 + $field_id = substr($key, 8, (stripos($key, '_',8) - 8) );
128 + if(!empty($_GET['c_field_'.$field_id.'_field'])
129 + && !empty($_GET['c_field_'.$field_id.'_like'])
130 + && !empty($_GET['c_field_'.$field_id.'_value'])) {
131 + switch ($_GET['c_field_'.$field_id.'_like']) {
132 + case '>': $custom_parameters[sanitize_key($_GET['c_field_'.$field_id.'_field']).'_min'] = sanitize_text_field($_GET['c_field_'.$field_id.'_value']);
133 + break;
134 + case '<': $custom_parameters[sanitize_key($_GET['c_field_'.$field_id.'_field']).'_max'] = sanitize_text_field($_GET['c_field_'.$field_id.'_value']);
135 + break;
136 + case '==': $custom_parameters[sanitize_key($_GET['c_field_'.$field_id.'_field'])] = sanitize_text_field($_GET['c_field_'.$field_id.'_value']);
137 + break;
138 + }
139 + }
140 + }
141 + };
142 +
109 143 $this->data['db_data'] = $this->listing_m->prepare_data($this->input->get(), $rules);
110 -
111 144 /* [/Search Form] */
112 145
113 146 $where = array();
114 147 if(isset($_GET['inactive']) && $_GET['inactive'] == 'on') {
@@ -114,9 +147,9 @@
114 147 if(isset($_GET['inactive']) && $_GET['inactive'] == 'on') {
115 148 $where['(is_activated IS NULL OR is_approved IS NULL)'] = NULL;
116 149 }
117 150
118 - wdk_prepare_search_query_GET($columns, $controller.'_m', $external_columns);
151 + wdk_prepare_search_query_GET($columns, $controller.'_m', $external_columns, $custom_parameters);
119 152 $total_items = $this->listing_m->total($where);
120 153
121 154 $current_page = 1;
122 155
@@ -133,9 +166,9 @@
133 166
134 167 if(function_exists('wmvc_wp_paginate'))
135 168 $this->data['pagination_output'] = wmvc_wp_paginate($total_items, $per_page);
136 169
137 - wdk_prepare_search_query_GET($columns, $controller.'_m', $external_columns);
170 + wdk_prepare_search_query_GET($columns, $controller.'_m', $external_columns, $custom_parameters);
138 171 $this->data['listings'] = $this->listing_m->get_pagination($per_page, $offset, $where);
139 172
140 173 // Load view
141 174 $this->load->view('wdk/index', $this->data);
@@ -147,10 +180,15 @@
147 180
148 181 $post_id = (int) $this->input->post_get('id');
149 182 $paged = (int) $this->input->post_get('paged');
150 183
184 + // Check _wpnonce
185 + check_admin_referer( 'wdk-listing-delete_'.$post_id, '_wpnonce' );
186 +
151 187 $this->listing_m->delete($post_id);
152 188
189 + do_action('wpdirectorykit/listing/removed');
190 +
153 191 wp_redirect(admin_url("admin.php?page=wdk&paged=$paged"));
154 192 }
155 193
156 194 public function bulk_delete($posts_selected)
@@ -155,18 +193,26 @@
155 193
156 194 public function bulk_delete($posts_selected)
157 195 {
158 196 $this->load->model('listing_m');
197 +
198 + // Check _wpnonce
199 + check_admin_referer( 'wdk-listing-bulk', '_wpnonce');
200 +
159 201 foreach($posts_selected as $key=>$post_id)
160 202 {
161 203 $this->listing_m->delete($post_id);
162 204 }
163 205
206 + do_action('wpdirectorykit/listing/bulk_removed');
164 207 wp_redirect(admin_url("admin.php?page=wdk"));
165 208 }
166 209
167 210 public function bulk_deactivate($posts_selected)
168 211 {
212 + // Check _wpnonce
213 + check_admin_referer( 'wdk-listing-bulk', '_wpnonce');
214 +
169 215 $this->load->model('listing_m');
170 216 foreach($posts_selected as $key=>$post_id)
171 217 {
172 218 if($this->listing_m->check_deletable($post_id))
@@ -171,14 +217,17 @@
171 217 {
172 218 if($this->listing_m->check_deletable($post_id))
173 219 $this->listing_m->insert(array('is_activated'=>NULL), $post_id);
174 220 }
175 -
221 + do_action('wpdirectorykit/listing/updated');
176 222 wp_redirect(admin_url("admin.php?page=wdk"));
177 223 }
178 224
179 225 public function bulk_activate($posts_selected)
180 226 {
227 + // Check _wpnonce
228 + check_admin_referer( 'wdk-listing-bulk', '_wpnonce');
229 +
181 230 $this->load->model('listing_m');
182 231 foreach($posts_selected as $key=>$post_id)
183 232 {
184 233 if($this->listing_m->check_deletable($post_id))
@@ -183,13 +232,17 @@
183 232 {
184 233 if($this->listing_m->check_deletable($post_id))
185 234 $this->listing_m->insert(array('is_activated'=>1), $post_id);
186 235 }
187 -
236 + do_action('wpdirectorykit/listing/updated');
188 237 wp_redirect(admin_url("admin.php?page=wdk"));
189 238 }
190 239 public function bulk_deapprove($posts_selected)
191 240 {
241 +
242 + // Check _wpnonce
243 + check_admin_referer( 'wdk-listing-bulk', '_wpnonce');
244 +
192 245 $this->load->model('listing_m');
193 246 foreach($posts_selected as $key=>$post_id)
194 247 {
195 248 if($this->listing_m->check_deletable($post_id))
@@ -194,14 +247,17 @@
194 247 {
195 248 if($this->listing_m->check_deletable($post_id))
196 249 $this->listing_m->insert(array('is_approved'=>NULL), $post_id);
197 250 }
198 -
251 + do_action('wpdirectorykit/listing/updated');
199 252 wp_redirect(admin_url("admin.php?page=wdk"));
200 253 }
201 254
202 255 public function bulk_approve($posts_selected)
203 256 {
257 + // Check _wpnonce
258 + check_admin_referer( 'wdk-listing-bulk', '_wpnonce');
259 +
204 260 $this->load->model('listing_m');
205 261 foreach($posts_selected as $key=>$post_id)
206 262 {
207 263 if($this->listing_m->check_deletable($post_id))
@@ -206,8 +262,8 @@
206 262 {
207 263 if($this->listing_m->check_deletable($post_id))
208 264 $this->listing_m->insert(array('is_approved'=>1), $post_id);
209 265 }
210 -
266 + do_action('wpdirectorykit/listing/updated');
211 267 wp_redirect(admin_url("admin.php?page=wdk"));
212 268 }
213 269 }