private static function upgrade() { if (!get_option('mm_upgrade_message_status')) { $models = MM_Conversation_Model::model()->find_all(); foreach ($models as $model) { $model->status = MM_Message_Status_Model::STATUS_READ; $model->save(); } update_option('mm_upgrade_message_status', 1); } }
<div id='lean_overlay'></div> <?php $this->render_partial('shortcode/_reply_form', array('message' => $message)); ?> <div class="ig-container"> <section class="message-content"> <div class="message-content-actions pull-right"> <?php if (mmg()->get('box') != 'sent' && $render_reply == true) { ?> <?php $from_data = get_userdata($message->send_from); ?> <div class="btn-group btn-group-sm"> <?php $conversation = MM_Conversation_Model::model()->find($message->conversation_id); ?> <?php if ($conversation->is_archive()) { ?> <a href="#" title="<?php echo esc_attr(__("Unarchive", mmg()->domain)); ?> " data-id="<?php echo esc_attr(mmg()->encrypt($message->conversation_id)); ?> " data-type="<?php echo MM_Message_Status_Model::STATUS_READ; ?>
function prepare_items() { global $wpdb; $totals = $wpdb->get_var($wpdb->prepare('SELECT COUNT(id) from ' . $wpdb->prefix . 'mm_conversation WHERE site_id=%d', get_current_blog_id())); //How many to display per page? $perpage = 10; //Which page is this? $paged = !empty($_GET["paged"]) ? mysql_real_escape_string($_GET["paged"]) : ''; //Page Number if (empty($paged) || !is_numeric($paged) || $paged <= 0) { $paged = 1; } $offset = ($this->get_pagenum() - 1) * $perpage; //How many pages do we have in total? $totalpages = ceil($totals / $perpage); //adjust the query to take pagination into account /* -- Register the pagination -- */ $this->set_pagination_args(array("total_items" => $totals, "total_pages" => $totalpages, "per_page" => $perpage)); //The pagination links are automatically built according to those parameters /* — Register the Columns — */ $columns = $this->get_columns(); $hidden = array(); $sortable = $this->get_sortable_columns(); $this->_column_headers = array($columns, $hidden, $sortable); if (isset($_GET['s']) && !empty($_GET['s'])) { if (isset($_GET['s'])) { $this->items = MM_Conversation_Model::search($_GET['s'], $perpage); $totals = mmg()->global['conversation_total_pages']; $totalpages = ceil($totals / $perpage); $this->set_pagination_args(array("total_items" => $totals, "total_pages" => $totalpages, "per_page" => $perpage)); } } else { $this->items = MM_Conversation_Model::model()->find_all('site_id=%d', array(get_current_blog_id()), $perpage, $offset); } }
function _reply_message($conv_id, $message_id, $user_id, $model) { //load conversation $conversation = MM_Conversation_Model::model()->find($conv_id); $conversation->status = MM_Message_Status_Model::STATUS_UNREAD; //we will add new message to this conversation $conversation->save(); //update users from this conversation, now save the message $m = new MM_Message_Model(); $m->import($model->export()); $m->send_to = $user_id; $m->conversation_id = $conversation->id; $m->status = MM_Message_Model::UNREAD; $mess = MM_Message_Model::model()->find($message_id); if (!empty($m->reply_to)) { if (!is_numeric($m->reply_to)) { wp_send_json(array('status' => 'fail', 'errors' => $model->get_errors())); exit; } $title = $m->subject; $description = $m->content; $price = $m->reply_to; $product_html = get_custom_order_button($title, $description, $price); } if (empty($m->subject)) { $m->subject = __("Re:", mmg()->domain) . ' ' . $mess->subject; } if (isset($product_html)) { $m->subject = __('You have new estimates!', 'artgorae'); $m->content = __('You have new estimates!', 'artgorae') . '<br/><br/>' . $product_html; } $m->save(); //update status for send to $status = MM_Message_Status_Model::model()->find_one_with_attributes(array('conversation_id' => $conversation->id, 'user_id' => $user_id)); if (is_object($status)) { $status->status = MM_Message_Status_Model::STATUS_UNREAD; $status->save(); } //update index $conversation->update_index($m->id); do_action('mm_message_sent', $m); }
function view() { $id = mmg()->get('id', 0); $model = MM_Conversation_Model::model()->find($id); if (is_object($model)) { $this->render('backend/view', array('model' => $model)); } else { echo __("Conversation not found!", mmg()->domain); } }