| @@ -9,8 +9,9 @@ | ||
| 9 | 9 | |
| 10 | 10 | public function index() |
| 11 | 11 | { |
| 12 | 12 | $this->load->model('messages_m'); |
| 13 | + $this->load->model('listing_m'); | |
| 13 | 14 | $this->data['form'] = &$this->form; |
| 14 | 15 | |
| 15 | 16 | $dbusers = get_users( array( 'search' => '', |
| 16 | 17 | 'orderby' => 'display_name', 'order' => 'ASC')); |
| @@ -41,12 +42,15 @@ | ||
| 41 | 42 | } |
| 42 | 43 | } |
| 43 | 44 | |
| 44 | 45 | /* [Search Form] */ |
| 45 | - | |
| 46 | + | |
| 47 | + global $wpdb; | |
| 48 | + $wp_usermeta_table = $wpdb->users; | |
| 49 | + | |
| 46 | 50 | $controller = 'messages'; |
| 47 | - $columns = array('idmessage','user_id_editor','display_name','user_login', 'user_email', 'search', 'order_by'); | |
| 48 | - $external_columns = array('user_id_editor','display_name','user_login', 'user_email'); | |
| 51 | + $columns = array($this->messages_m->_table_name.'.idmessage',$this->listing_m->_table_name.'.user_id_editor',$wp_usermeta_table.'.display_name',$wp_usermeta_table.'.user_login', $wp_usermeta_table.'.user_email', 'search',$this->messages_m->_table_name.'.email_sender', $this->messages_m->_table_name.'.message'); | |
| 52 | + $external_columns = array($this->listing_m->_table_name.'.user_id_editor',$wp_usermeta_table.'.display_name',$wp_usermeta_table.'.user_login', $wp_usermeta_table.'.user_email',$this->messages_m->_table_name.'.email_sender', $this->messages_m->_table_name.'.message'); | |
| 49 | 53 | |
| 50 | 54 | $this->data['order_by'] = array('idmessage DESC' => __('ID DESC', 'wpdirectorykit'), |
| 51 | 55 | 'idmessage ASC' => __('ID ASC', 'wpdirectorykit'), |
| 52 | 56 | 'display_name DESC' => __('User DESC', 'wpdirectorykit'), |
| @@ -71,12 +75,10 @@ | ||
| 71 | 75 | ), |
| 72 | 76 | ); |
| 73 | 77 | |
| 74 | 78 | $this->data['db_data'] = $this->messages_m->prepare_data($this->input->get(), $rules); |
| 75 | - | |
| 76 | - global $wpdb; | |
| 77 | - $wp_usermeta_table = $wpdb->users; | |
| 78 | 79 | |
| 80 | + | |
| 79 | 81 | $this->db->join($this->db->prefix.'wdk_listings ON '.$this->db->prefix.'wdk_listings.post_id = '.$this->messages_m->_table_name.'.post_id', NULL, 'LEFT'); |
| 80 | 82 | $this->db->join($wp_usermeta_table.' ON '.$this->db->prefix.'wdk_listings.user_id_editor = '.$wp_usermeta_table.'.ID', NULL, 'LEFT'); |
| 81 | 83 | wdk_messages_prepare_search_query_GET($columns, $controller.'_m', $external_columns); |
| 82 | 84 | $total_items = $this->messages_m->total(); |
| @@ -102,9 +104,9 @@ | ||
| 102 | 104 | .$wp_usermeta_table.'.user_email'); |
| 103 | 105 | $this->db->join($this->db->prefix.'wdk_listings ON '.$this->db->prefix.'wdk_listings.post_id = '.$this->messages_m->_table_name.'.post_id', NULL, 'LEFT'); |
| 104 | 106 | $this->db->join($wp_usermeta_table.' ON '.$this->db->prefix.'wdk_listings.user_id_editor = '.$wp_usermeta_table.'.ID', NULL, 'LEFT'); |
| 105 | 107 | $this->data['messages'] = $this->messages_m->get_pagination($per_page, $offset); |
| 106 | - | |
| 108 | + | |
| 107 | 109 | // Load view |
| 108 | 110 | $this->load->view('wdk_messages/index', $this->data); |
| 109 | 111 | } |
| 110 | 112 | |