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/models/Messages_m.php +36 -3 1.2.7 → 1.5.9 View file →
@@ -33,9 +33,9 @@
33 33 ),
34 34 array(
35 35 'field' => 'date',
36 36 'field_label' => __('Date', 'wpdirectorykit'),
37 - 'field_type' => 'DATE_READONLY',
37 + 'field_type' => 'DATETIME_READONLY',
38 38 'rules' => ''
39 39 ),
40 40 array(
41 41 'field' => 'message',
@@ -400,9 +400,9 @@
400 400
401 401 if(wmvc_show_data('user_id_receiver', $row) == $user_id || wmvc_show_data('user_id_editor', $row) == $user_id )
402 402 return true;
403 403
404 - if(wmvc_user_in_role('administrator')) return true;
404 + if(wmvc_user_in_role('administrator') || current_user_can('wdk_listings_manage')) return true;
405 405
406 406 return false;
407 407 }
408 408
@@ -423,9 +423,9 @@
423 423 if(wmvc_show_data('user_id_receiver', $row) == $user_id || wmvc_show_data('user_id_editor', $row) == $user_id )
424 424 return true;
425 425 }
426 426
427 - if(wmvc_user_in_role('administrator')) return true;
427 + if(wmvc_user_in_role('administrator') || current_user_can('wdk_listings_manage')) return true;
428 428
429 429 return false;
430 430 }
431 431
@@ -459,9 +459,42 @@
459 459 /* remove */
460 460 parent::delete($id);
461 461
462 462 return true;
463 + }
464 +
465 +
466 + public function total_unread($user_id=NULL)
467 + {
468 + $post_table = $this->db->prefix.'posts';
469 +
470 + $this->db->select('COUNT(*) as total_count');
471 +
472 + if(empty($user_id))
473 + {
474 + $user_id = $this->current_user_id;
475 + }
476 +
477 + $this->db->join($this->db->prefix.'wdk_messages_chat ON ('.$this->_table_name.'.idmessage = '.$this->db->prefix.'wdk_messages_chat.related_key AND chat_is_readed IS NULL AND `outgoing_msg_user_id`!= '.$user_id.')', NULL, 'LEFT');
478 +
479 + $this->db->from($this->_table_name);
480 +
481 + $this->db->join($this->db->prefix.'wdk_listings ON '.$this->db->prefix.'wdk_listings.post_id = '.$this->_table_name.'.post_id', NULL, 'LEFT');
482 + $this->db->join($post_table.' ON '.$this->_table_name.'.post_id = '.$post_table.'.ID', NULL, 'LEFT');
483 +
484 + $this->db->where('(`'.$this->db->prefix.'wdk_listings`.`user_id_editor` = '.$user_id.' OR user_id_sender = '.$user_id.' OR user_id_receiver = '.$user_id.' )');
485 +
486 + $this->db->where('(('.$this->_table_name.'.is_readed IS NULL AND related_key IS NULL AND user_id_editor = '.$user_id.') OR ('.$this->_table_name.'.is_readed IS NOT NULL AND related_key IS NOT NULL))');
487 +
488 + $query = $this->db->get();
489 +
490 + $res = $this->db->results();
491 +
492 + if(isset($res[0]->total_count))
493 + return $res[0]->total_count;
494 +
495 + return 0;
463 496 }
464 497
465 498 }
466 499
467 500 ?>