public function output_message_list($allow_reply = true) { $message_id = $this->get('shub_message_id'); $comments = $this->get_comments(); $x = 0; foreach ($comments as $comment) { $x++; $from_user = $this->get_user($comment['shub_user_id']); $time = isset($comment['time']) ? $comment['time'] : false; // is this a queued-to-send message? $extra_class = ''; $comment_status = ''; $message_error = false; if (!empty($comment['shub_outbox_id'])) { $shub_outbox = new SupportHubOutbox($comment['shub_outbox_id']); if ($shub_outbox->get('shub_outbox_id') != $comment['shub_outbox_id']) { // the outbox entry has been removed but this comment still references it // todo: update this comment entry to not contain an shub_outbox_id } else { switch ($shub_outbox->get('shub_status')) { case _SHUB_OUTBOX_STATUS_QUEUED: case _SHUB_OUTBOX_STATUS_SENDING: $extra_class .= ' outbox_queued'; $comment_status = 'Currently Sending....' . $shub_outbox->get('shub_status'); break; case _SHUB_OUTBOX_STATUS_FAILED: $extra_class .= ' outbox_failed'; $comment_status = 'Failed to send message! Please check logs.'; $message_error = true; break; } } } if (!empty($comment['private'])) { $extra_class .= ' shub_message_private'; } ?> <div class="shub_message shub_message_<?php echo $x == 1 ? 'primary' : 'reply'; echo $extra_class; ?> "> <div class="shub_message_picture"> <img src="<?php echo $from_user->get_image(); ?> " /> </div> <div class="shub_message_header"> <?php if ($comment_status) { ?> <div class="shub_comment_status"><?php echo $comment_status; ?> </div> <?php } ?> <?php echo $from_user->get_full_link(); ?> <span> <?php if ($time) { ?> <span class="time" data-time="<?php echo esc_attr($time); ?> " data-date="<?php echo esc_attr(shub_print_date($time, true)); ?> "><?php echo shub_pretty_date($time); ?> </span> <?php } ?> <span class="wp_user"> <?php // todo - better this! don't call on every message, load list in main loop and pass through all results. if (isset($envato_data['user_id']) && $envato_data['user_id']) { $user_info = get_userdata($envato_data['user_id']); echo ' (sent by ' . htmlspecialchars($user_info->display_name) . ')'; } ?> </span> <span class="buyer_status_badges"> <?php // work out of this buyer has bought something via the envato module. // first we have to find out what item this is: //echo "user:"******"<br>product:".$this->get_product_id()."<br>"; // todo: store these as a flag in the message database so we can run stats on them and display a graph on the dashboard. $buyer_status = $this->get_buyer_status($comment['shub_user_id']); if (!empty($buyer_status['purchased'])) { echo '<span class="buyer_badge purchased">Purchased</span> '; } if (!empty($buyer_status['supported'])) { echo '<span class="buyer_badge supported">Supported</span> '; } if (!empty($buyer_status['unsupported'])) { echo '<span class="buyer_badge unsupported">Unsupported</span> '; } if (!empty($buyer_status['presale'])) { //echo '<span class="buyer_badge presale">Pre-sale</span> '; } // todo - add a badge for staff reply. ?> </span> </span> </div> <div class="shub_message_body"> <div> <?php echo shub_forum_text($comment['message_text']); ?> </div> </div> <div class="shub_message_actions"> <?php if ($message_error && !empty($comment['shub_outbox_id'])) { ?> <button data-post="<?php echo esc_attr(json_encode(array('action' => "support_hub_resend_outbox_message", 'shub_outbox_id' => $comment['shub_outbox_id']))); ?> " class="btn button shub_message_action_button"><?php _e('Re-Send'); ?> </button> <button data-post="<?php echo esc_attr(json_encode(array('action' => "support_hub_delete_outbox_message", 'shub_outbox_id' => $comment['shub_outbox_id']))); ?> " class="btn button shub_message_action_button"><?php _e('Delete Message'); ?> </button> <?php } ?> </div> </div> <?php } if ($allow_reply) { ?> <div class="shub_message shub_message_reply shub_message_reply_box"> <?php $reply_shub_user = $this->get_reply_user(); ?> <div class="shub_message_picture"> <img src="<?php echo $reply_shub_user->get_image(); ?> " /> </div> <div class="shub_message_header"> <?php echo $reply_shub_user->get_full_link(); ?> </div> <div class="shub_message_body"> <textarea placeholder="Write a reply..."></textarea> <div class="shub_message_buttons"> <a href="#" class="shub_request_extra btn btn-default btn-xs button" data-modaltitle="<?php _e('Request Extra Details'); ?> " data-action="request_extra_details" data-network="<?php echo $this->network; ?> " data-<?php echo $this->network; ?> -message-id="<?php echo $message_id; ?> "><?php _e('Request Details'); ?> </a> <!-- <a href="#" class="shub_template_button btn btn-default btn-xs button" data-modaltitle="<?php _e('Send Template Message'); ?> " data-action="send_template_message" data-network="<?php echo $this->network; ?> " data-<?php echo $this->network; ?> -message-id="<?php echo $message_id; ?> "><?php _e('Template'); ?> </a> --> <button data-post="<?php echo esc_attr(json_encode(array('account-id' => $this->get('shub_account_id'), 'message-id' => $message_id, 'network' => $this->network, 'last_activity' => $this->get('last_active')))); ?> " class="btn button shub_send_message_reply_button shub_hide_when_no_message shub_button_loading"><?php _e('Send'); ?> </button> </div </div> <div class="shub_message_actions shub_hide_when_no_message"> <div> <label for="message_reply_archive_<?php echo $message_id; ?> "><?php _e('Archive After Reply', 'shub'); ?> </label> <input id="message_reply_archive_<?php echo $message_id; ?> " type="checkbox" name="archive" data-reply="yes" value="1" checked> </div> <div> <label for="message_reply_private_<?php echo $message_id; ?> "><?php _e('Mark As Private', 'shub'); ?> </label> <input id="message_reply_private_<?php echo $message_id; ?> " type="checkbox" name="private" data-reply="yes" value="1"> </div> <div> <label for="message_reply_notify_email_<?php echo $message_id; ?> "><?php _e('Notify Via Email', 'shub'); ?> </label> <input id="message_reply_notify_email_<?php echo $message_id; ?> " type="checkbox" name="notify_email" data-reply="yes" value="1"> </div> <div> <label for="message_reply_debug_<?php echo $message_id; ?> "><?php _e('Enable Debug Mode', 'shub'); ?> </label> <input id="message_reply_debug_<?php echo $message_id; ?> " type="checkbox" name="debug" data-reply="yes" value="1"> </div> <?php $this->reply_actions(); ?> </div> </div> <?php } }
$myListTable->set_columns(array('cb' => 'Select All', 'shub_column_account' => __('Account', 'support_hub'), 'shub_column_product' => __('Product', 'support_hub'), 'shub_column_time' => __('Time', 'support_hub'), 'shub_column_from' => __('From', 'support_hub'), 'shub_column_summary' => __('Summary', 'support_hub'), 'shub_column_action' => __('Action', 'support_hub'))); /*$myListTable->set_sortable_columns( array( 'shub_column_time' => array( 'shub_column_time', 1 ), ) );*/ $myListTable->process_bulk_action(); // before we do the search on messages. $this_search = $search; if (isset($this_search['shub_status']) && $this_search['shub_status'] == -1) { unset($this_search['shub_status']); } // SupportHub::getInstance()->load_all_messages($this_search, $order); // $all_messages = SupportHub::getInstance()->all_messages; $all_messages = array_merge(SupportHubOutbox::get_failed(), SupportHubOutbox::get_pending()); $limit_pages = 2; // get about 10 pages of data to display in WordPress. $has_more = false; if (count($all_messages) >= $myListTable->get_pagenum() * $myListTable->items_per_page + $limit_pages * $myListTable->items_per_page) { $has_more = true; // a flag so we can show "more" in the pagination listing. } // todo - hack in here some sort of cache so pagination works nicer ? //module_debug::log(array( 'title' => 'Finished social messages', 'data' => '', )); $myListTable->set_layout_type($layout_type); $myListTable->set_data($all_messages); $myListTable->prepare_items(); $myListTable->pagination_has_more = $has_more; ?> <form method="post" id="shub_search_form">
public function send_outbox_messages($debug = false) { // find any pending outbox messages and send them // return stats on the messages left for update in the UI $pending_messages = SupportHubOutbox::get_pending(); if (count($pending_messages)) { foreach ($pending_messages as $pending_message) { $pending = new SupportHubOutbox($pending_message['shub_outbox_id']); $pending->send_queued(); } } }