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 / models / Messages_m.php

Messages_m.php in WP Directory Kit 1.1.0, at application/models/Messages_m.php

89 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // If this file is called directly, abort.
4 if ( ! defined( 'WPINC' ) ) {
5 die;
6 }
7
8 class Messages_m extends Winter_MVC_Model {
9
10 public $_table_name = 'wdk_messages';
11 public $_order_by = 'idmessage';
12 public $_primary_key = 'idmessage';
13 public $_own_columns = array();
14 public $_timestamps = TRUE;
15 protected $_primary_filter = 'intval';
16 public $form_admin = array();
17 public $fields_list = NULL;
18
19 public function __construct(){
20 parent::__construct();
21 }
22
23 /* [START] For dynamic data table */
24
25 public function get_available_fields()
26 {
27 $fields = $this->db->list_fields($this->_table_name);
28
29 return $fields;
30 }
31
32 public function total($where = array())
33 {
34 $this->db->select('COUNT(*) as total_count');
35 $this->db->from($this->_table_name);
36 $this->db->where($where);
37 $this->db->order_by($this->_order_by);
38
39 $query = $this->db->get();
40
41 $res = $this->db->results();
42
43 if(isset($res[0]->total_count))
44 return $res[0]->total_count;
45
46 return 0;
47 }
48
49 public function get_pagination($limit, $offset, $where = array(), $order_by = NULL)
50 {
51 $this->db->select('*');
52 $this->db->from($this->_table_name);
53 $this->db->where($where);
54 $this->db->limit($limit);
55 $this->db->offset($offset);
56
57 if(!empty($order_by)){
58 $this->db->order_by($order_by);
59 } else {
60 $this->db->order_by($this->_order_by);
61 }
62
63 $query = $this->db->get();
64
65 if ($this->db->num_rows() > 0)
66 return $this->db->results();
67
68 return array();
69 }
70
71 public function check_deletable($id)
72 {
73 return true;
74 }
75
76
77 /* [END] For dynamic data table */
78
79 public function is_related($item_id, $user_id, $method = 'edit')
80 {
81 $row = $this->get($item_id, TRUE);
82 if(wmvc_show_data('user_id_receiver', $row) == $user_id)
83 return true;
84
85 return false;
86 }
87
88 }
89 ?>