function update_message() { check_ajax_referer('cpm_message'); $posted = $_POST; $files = array(); $project_id = isset($posted['project_id']) ? intval($posted['project_id']) : 0; $message_id = isset($posted['message_id']) ? intval($posted['message_id']) : 0; if (isset($posted['cpm_attachment'])) { $files = $posted['cpm_attachment']; } $message_obj = CPM_Message::getInstance(); $message_id = $message_obj->update($project_id, $posted, $files, $message_id); $message = $message_obj->get($message_id); if ($message_id && !empty($message)) { echo json_encode(array('success' => true, 'id' => $message_id, 'content' => cpm_get_content($message->post_content) . cpm_show_attachments($message, $project_id))); exit; } echo json_encode(array('success' => false)); exit; }
?> " class="cpm-msg-edit"> <?php _e('Edit', 'cpm'); ?> </a> </span> </div> <div class="cpm-entry-detail"> <?php echo cpm_get_content($message->post_content); ?> <?php echo cpm_show_attachments($message); ?> </div> <span class="cpm-msg-edit-form"></span> </div> <?php $comments = $msg_obj->get_comments($message_id); if ($comments) { $count = 0; ?> <h3><?php printf(_n('One Comment', '%s Comments', count($comments), 'cpm'), number_format_i18n(count($comments)));
/** * Generates markup for displaying a single comment * * @since 0.1 * @param object $comment * @param int $project_id * @param string $class * @return string */ function cpm_show_comment($comment, $project_id, $class = '') { $class = empty($class) ? '' : ' ' . $class; ob_start(); ?> <li class="cpm-comment<?php echo $class; ?> " id="cpm-comment-<?php echo $comment->comment_ID; ?> "> <div class="cpm-avatar"><?php echo cpm_url_user($comment->user_id, true); ?> </div> <div class="cpm-comment-container"> <div class="cpm-comment-meta"> <span class="cpm-author"><?php echo cpm_url_user($comment->user_id); ?> </span> <span class="cpm-separator">|</span> <span class="cpm-date"><?php echo cpm_get_date($comment->comment_date, true); ?> </span> <?php if ($comment->user_id == get_current_user_id() && $comment->comment_type == '') { ?> <span class="cpm-separator">|</span> <span class="cpm-edit-link"> <a href="#" class="cpm-edit-comment-link" <?php cpm_data_attr(array('comment_id' => $comment->comment_ID, 'project_id' => $project_id, 'object_id' => $comment->comment_post_ID)); ?> > <span><?php _e('Edit', 'cpm'); ?> </span> </a> </span> <span class="cpm-separator">|</span> <span class="cpm-delete-link"> <a href="#" class="cpm-delete-comment-link" <?php cpm_data_attr(array('project_id' => $project_id, 'id' => $comment->comment_ID, 'confirm' => 'Are you sure to delete this comment?')); ?> > <span><?php _e('Delete', 'cpm'); ?> </span> </a> </span> <?php } ?> </div> <div class="cpm-comment-content"> <?php echo comment_text($comment->comment_ID); ?> <?php echo cpm_show_attachments($comment, $project_id); ?> </div> <div class="cpm-comment-edit-form"></div> </div> </li> <?php return ob_get_clean(); }
_e('Edit', 'cpm'); ?> </a> </span> <?php } ?> </div> <div class="cpm-entry-detail"> <?php echo cpm_get_content($message->post_content); ?> <?php echo cpm_show_attachments($message, $project_id); ?> </div> <span class="cpm-msg-edit-form"></span> </div> <?php $comments = $msg_obj->get_comments($message_id); if ($comments) { $count = 0; ?> <h3><?php printf(_n('One Comment', '%s Comments', count($comments), 'cpm'), number_format_i18n(count($comments)));