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 +100 -13 1.1.0 → 1.5.9 View file →
@@ -14,10 +14,10 @@
14 14 $this->load->model('listingfield_m');
15 15 $this->load->model('location_m');
16 16 $this->load->model('category_m');
17 17 $this->load->load_helper('listing');
18 +
18 19 /* [Table Actions Bulk Form] */
19 -
20 20 $table_action = $this->input->post_get('table_action');
21 21 $action = $this->input->post_get('action');
22 22 $posts_selected = $this->input->post_get('post');
23 23
@@ -44,11 +44,31 @@
44 44 }
45 45
46 46 /* [Search Form] */
47 47
48 + $dbusers = get_users( array( 'search' => '',
49 + 'orderby' => 'display_name', 'order' => 'ASC'));
50 +
51 + foreach($dbusers as $dbuser) {
52 + $this->data['users'][wmvc_show_data('ID', $dbuser)] = '#'.wmvc_show_data('ID', $dbuser).', '.wmvc_show_data('display_name', $dbuser);
53 + }
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 +
48 68 $controller = 'listing';
49 - $columns = array('ID', 'location_id', 'category_id', 'post_title', 'post_date', 'search', 'order_by', 'address');
50 - $external_columns = array('location_id', 'category_id', 'post_title');
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');
70 + $external_columns = array('location_id', 'category_id', 'post_title', 'user_id_editor',);
51 71
52 72 $this->data['categories'] = $this->category_m->get_parents();
53 73 $this->data['locations'] = $this->location_m->get_parents();
54 74 $this->data['order_by'] = array('ID DESC' => __('ID', 'wpdirectorykit').' DESC',
@@ -55,9 +75,14 @@
55 75 'ID ASC' => __('ID', 'wpdirectorykit').' ASC',
56 76 'post_title ASC' => __('Post Title', 'wpdirectorykit').' ASC',
57 77 'post_title DESC' => __('Post Title', 'wpdirectorykit').' DESC',
58 78 'post_date ASC' => __('Post Date', 'wpdirectorykit').' ASC',
59 - 'post_date DESC' => __('Post Date', 'wpdirectorykit').' DESC',);
79 + 'post_date DESC' => __('Post Date', 'wpdirectorykit').' DESC',
80 + 'date_modified ASC' => __('Last Modified Date', 'wpdirectorykit').' ASC',
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',
84 + );
60 85
61 86 $rules = array(
62 87 array(
63 88 'field' => 'location_id',
@@ -78,16 +103,54 @@
78 103 'field' => 'order_by',
79 104 'label' => __('Order By', 'wpdirectorykit'),
80 105 'rules' => ''
81 106 ),
107 + array(
108 + 'field' => 'user_id_editor',
109 + 'label' => __('User', 'wpdirectorykit'),
110 + 'rules' => ''
111 + ),
112 + array(
113 + 'field' => 'is_activated',
114 + 'label' => __('Is Activated', 'wpdirectorykit'),
115 + 'rules' => ''
116 + ),
117 + array(
118 + 'field' => 'is_featured',
119 + 'label' => __('Is Featured', 'wpdirectorykit'),
120 + 'rules' => ''
121 + ),
82 122 );
83 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 +
84 143 $this->data['db_data'] = $this->listing_m->prepare_data($this->input->get(), $rules);
144 + /* [/Search Form] */
85 145
86 - /* [/Search Form] */
146 + $where = array();
147 + if(isset($_GET['inactive']) && $_GET['inactive'] == 'on') {
148 + $where['(is_activated IS NULL OR is_approved IS NULL)'] = NULL;
149 + }
87 150
88 - wdk_prepare_search_query_GET($columns, $controller.'_m', $external_columns);
89 - $total_items = $this->listing_m->total();
151 + wdk_prepare_search_query_GET($columns, $controller.'_m', $external_columns, $custom_parameters);
152 + $total_items = $this->listing_m->total($where);
90 153
91 154 $current_page = 1;
92 155
93 156 if(isset($_GET['paged']))
@@ -94,8 +157,9 @@
94 157 $current_page = intval($_GET['paged']);
95 158
96 159 $this->data['paged'] = $current_page;
97 160
161 +
98 162 $per_page = 20;
99 163 $offset = $per_page*($current_page-1);
100 164
101 165 $this->data['pagination_output'] = '';
@@ -102,10 +166,10 @@
102 166
103 167 if(function_exists('wmvc_wp_paginate'))
104 168 $this->data['pagination_output'] = wmvc_wp_paginate($total_items, $per_page);
105 169
106 - wdk_prepare_search_query_GET($columns, $controller.'_m', $external_columns);
107 - $this->data['listings'] = $this->listing_m->get_pagination($per_page, $offset);
170 + wdk_prepare_search_query_GET($columns, $controller.'_m', $external_columns, $custom_parameters);
171 + $this->data['listings'] = $this->listing_m->get_pagination($per_page, $offset, $where);
108 172
109 173 // Load view
110 174 $this->load->view('wdk/index', $this->data);
111 175 }
@@ -116,10 +180,15 @@
116 180
117 181 $post_id = (int) $this->input->post_get('id');
118 182 $paged = (int) $this->input->post_get('paged');
119 183
184 + // Check _wpnonce
185 + check_admin_referer( 'wdk-listing-delete_'.$post_id, '_wpnonce' );
186 +
120 187 $this->listing_m->delete($post_id);
121 188
189 + do_action('wpdirectorykit/listing/removed');
190 +
122 191 wp_redirect(admin_url("admin.php?page=wdk&paged=$paged"));
123 192 }
124 193
125 194 public function bulk_delete($posts_selected)
@@ -124,18 +193,26 @@
124 193
125 194 public function bulk_delete($posts_selected)
126 195 {
127 196 $this->load->model('listing_m');
197 +
198 + // Check _wpnonce
199 + check_admin_referer( 'wdk-listing-bulk', '_wpnonce');
200 +
128 201 foreach($posts_selected as $key=>$post_id)
129 202 {
130 203 $this->listing_m->delete($post_id);
131 204 }
132 205
206 + do_action('wpdirectorykit/listing/bulk_removed');
133 207 wp_redirect(admin_url("admin.php?page=wdk"));
134 208 }
135 209
136 210 public function bulk_deactivate($posts_selected)
137 211 {
212 + // Check _wpnonce
213 + check_admin_referer( 'wdk-listing-bulk', '_wpnonce');
214 +
138 215 $this->load->model('listing_m');
139 216 foreach($posts_selected as $key=>$post_id)
140 217 {
141 218 if($this->listing_m->check_deletable($post_id))
@@ -140,14 +217,17 @@
140 217 {
141 218 if($this->listing_m->check_deletable($post_id))
142 219 $this->listing_m->insert(array('is_activated'=>NULL), $post_id);
143 220 }
144 -
221 + do_action('wpdirectorykit/listing/updated');
145 222 wp_redirect(admin_url("admin.php?page=wdk"));
146 223 }
147 224
148 225 public function bulk_activate($posts_selected)
149 226 {
227 + // Check _wpnonce
228 + check_admin_referer( 'wdk-listing-bulk', '_wpnonce');
229 +
150 230 $this->load->model('listing_m');
151 231 foreach($posts_selected as $key=>$post_id)
152 232 {
153 233 if($this->listing_m->check_deletable($post_id))
@@ -152,13 +232,17 @@
152 232 {
153 233 if($this->listing_m->check_deletable($post_id))
154 234 $this->listing_m->insert(array('is_activated'=>1), $post_id);
155 235 }
156 -
236 + do_action('wpdirectorykit/listing/updated');
157 237 wp_redirect(admin_url("admin.php?page=wdk"));
158 238 }
159 239 public function bulk_deapprove($posts_selected)
160 240 {
241 +
242 + // Check _wpnonce
243 + check_admin_referer( 'wdk-listing-bulk', '_wpnonce');
244 +
161 245 $this->load->model('listing_m');
162 246 foreach($posts_selected as $key=>$post_id)
163 247 {
164 248 if($this->listing_m->check_deletable($post_id))
@@ -163,14 +247,17 @@
163 247 {
164 248 if($this->listing_m->check_deletable($post_id))
165 249 $this->listing_m->insert(array('is_approved'=>NULL), $post_id);
166 250 }
167 -
251 + do_action('wpdirectorykit/listing/updated');
168 252 wp_redirect(admin_url("admin.php?page=wdk"));
169 253 }
170 254
171 255 public function bulk_approve($posts_selected)
172 256 {
257 + // Check _wpnonce
258 + check_admin_referer( 'wdk-listing-bulk', '_wpnonce');
259 +
173 260 $this->load->model('listing_m');
174 261 foreach($posts_selected as $key=>$post_id)
175 262 {
176 263 if($this->listing_m->check_deletable($post_id))
@@ -175,8 +262,8 @@
175 262 {
176 263 if($this->listing_m->check_deletable($post_id))
177 264 $this->listing_m->insert(array('is_approved'=>1), $post_id);
178 265 }
179 -
266 + do_action('wpdirectorykit/listing/updated');
180 267 wp_redirect(admin_url("admin.php?page=wdk"));
181 268 }
182 269 }