PluginProbe
WP Directory Kit / 1.1.0
WP Directory Kit v1.1.0
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_messages.php

Wdk_messages.php in WP Directory Kit 1.1.0, at application/controllers/Wdk_messages.php

112 lines 3.1 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_messages extends Winter_MVC_Controller {
5
6 public function __construct(){
7 parent::__construct();
8 }
9
10 public function index()
11 {
12 $this->load->model('messages_m');
13
14 $total_items = $this->messages_m->total();
15
16 $current_page = 1;
17 if(isset($_GET['paged']))
18 $current_page = intval($_GET['paged']);
19
20 $this->data['paged'] = $current_page;
21
22 $per_page = 20;
23 $offset = $per_page*($current_page-1);
24
25 $this->data['pagination_output'] = '';
26
27 if(function_exists('wmvc_wp_paginate'))
28 $this->data['pagination_output'] = wmvc_wp_paginate($total_items, $per_page);
29
30 $this->data['messages'] = $this->messages_m->get_pagination($per_page, $offset);
31
32 // Load view
33 $this->load->view('wdk_messages/index', $this->data);
34 }
35
36 public function delete()
37 {
38 $id = (int) $this->input->post_get('id');
39 $paged = (int) $this->input->post_get('paged');
40
41 $this->load->model('messages_m');
42
43 $this->messages_m->delete($id);
44
45 wp_redirect(admin_url("admin.php?page=wdk_messages&paged=$paged"));
46 }
47
48 public function edit()
49 {
50 $this->load->model('messages_m');
51
52 $id = $this->input->post_get('id');
53 wdk_access_check('messages_m', $id);
54 $this->data['db_data'] = NULL;
55
56 $this->data['form'] = &$this->form;
57
58 //exit($this->db->last_query());
59
60 $rules = array(
61 array(
62 'field' => 'post_id',
63 'label' => __('Listing Id', 'wpdirectorykit'),
64 'rules' => 'required'
65 ),
66 array(
67 'field' => 'date',
68 'label' => __('Date', 'wpdirectorykit'),
69 'rules' => ''
70 ),
71 array(
72 'field' => 'message',
73 'label' => __('Message', 'wpdirectorykit'),
74 'rules' => ''
75 ),
76 array(
77 'field' => 'is_readed',
78 'label' => __('Readed', 'wpdirectorykit'),
79 'rules' => ''
80 ),
81 );
82
83 if($this->form->run($rules))
84 {
85 // Save procedure for basic data
86 $data = $this->messages_m->prepare_data($this->input->post(), $rules);
87
88 // Save standard wp post
89
90 $insert_id = $this->messages_m->insert($data, $id);
91
92 //exit($this->db->last_error());
93
94 // redirect
95 if(!empty($insert_id) && empty($id))
96 {
97 wp_redirect(admin_url("admin.php?page=wdk_messages&id=$insert_id&is_updated=true"));
98 exit;
99 }
100
101 }
102
103 if(!empty($id))
104 {
105 $this->data['db_data'] = $this->messages_m->get($id, TRUE);
106 }
107
108 $this->load->view('wdk_messages/edit', $this->data);
109 }
110
111 }
112