if (!$attachment->post_parent) { $parent_id = get_post_meta($attachment->ID, '_parent', true); $parent = get_post($parent_id); } else { $parent = get_post($attachment->post_parent); } $post_type_object = get_post_type_object($parent->post_type); if ($parent->post_type == 'task') { $task_list = get_post($parent->post_parent); $topic_url = cpm_url_single_task($project_id, $task_list->ID, $parent->ID); } else { if ($parent->post_type == 'task_list') { $topic_url = cpm_url_single_tasklist($project_id, $parent->ID); } else { if ($parent->post_type == 'message') { $topic_url = cpm_url_single_message($project_id, $parent->ID); } } } $file_url = sprintf('%s&file_id=%d&project_id=%d', $base_image_url, $file['id'], $project_id); if ($file['type'] == 'image') { $thumb_url = sprintf('%s&file_id=%d&project_id=%d&type=thumb', $base_image_url, $file['id'], $project_id); } else { $thumb_url = $file['thumb']; } ?> <li> <div class="cpm-thumb"> <a href="<?php echo $file_url; ?>
/** * Send email to all about a new comment * * @param int $comment_id * @param array $comment_info the post data */ function new_comment($comment_id, $project_id, $data) { $users = $this->prepare_contacts(); if (!$users) { return; } $msg_obj = CPM_Message::getInstance(); $parent_post = get_post($data['comment_post_ID']); $author = wp_get_current_user(); $comment_url = ''; switch ($parent_post->post_type) { case 'message': $comment_url = cpm_url_single_message($project_id, $data['comment_post_ID']); break; case 'task_list': $comment_url = cpm_url_single_tasklist($project_id, $parent_post->ID); break; case 'task': $comment_url = cpm_url_single_task($project_id, $parent_post->post_parent, $parent_post->ID); break; } $template_vars = array('%SITE%' => wp_specialchars_decode(get_option('blogname'), ENT_QUOTES), '%PROJECT_NAME%' => get_post_field('post_title', $project_id), '%PROJECT_URL%' => cpm_url_project_details($project_id), '%AUTHOR%' => $author->display_name, '%AUTHOR_EMAIL%' => $author->user_email, '%COMMENT_URL%' => $comment_url, '%COMMENT%' => $data['comment_content'], '%IP%' => get_ipaddress()); $subject = cpm_get_option('new_comment_sub'); $message = cpm_get_option('new_comment_body'); // subject foreach ($template_vars as $key => $value) { $subject = str_replace($key, $value, $subject); } // message foreach ($template_vars as $key => $value) { $message = str_replace($key, $value, $message); } $this->send(implode(', ', $users), $subject, $message); }
function new_message() { check_ajax_referer('cpm_message'); $posted = $_POST; $files = array(); $project_id = isset($posted['project_id']) ? intval($posted['project_id']) : 0; if (isset($posted['cpm_attachment'])) { $files = $posted['cpm_attachment']; } $message_obj = CPM_Message::getInstance(); $message_id = $message_obj->create($project_id, $posted, $files); if ($message_id) { echo json_encode(array('success' => true, 'id' => $message_id, 'url' => cpm_url_single_message($project_id, $message_id))); exit; } echo json_encode(array('success' => false)); exit; }
</span> <div style="clear: both;"></div> <span style="float: left; width: 70px;"><em style="font-family: lato; color: #B3B3B3; "><?php _e('Message ', 'cpm'); ?> </em></span> <span style="float: left; width: 430px;"><?php echo $msg->post_content; ?> </span> <div style="clear: both;"></div> </div> </div> <center> <div style="padding: 18px; margin: 30px 0 45px; border-radius: 30px; background: #00b1e7; width: 171px;"> <a href="<?php echo cpm_url_single_message($project_id, $message_id); ?> " style="font-family: lato; font-size: 16px; text-decoration: none; color: #fff;"> <?php _e('View Message', 'cpm'); ?> </a> </div> </center> </div> <?php cpm_get_email_footer();
/** * Displays a single message url * * @since 0.1 * @param array $atts * @return string */ function cpm_sc_message_url($atts) { $atts = extract(shortcode_atts(array('id' => 0, 'project' => 0, 'title' => ''), $atts)); $url = cpm_url_single_message($project, $id); return sprintf('<a href="%s">%s</a>', $url, $title); }
/** * Generates markup for a single milestone * * @since 0.1 * @param object $milestone * @param int $project_id */ function cpm_show_milestone($milestone, $project_id) { $milestone_obj = CPM_Milestone::getInstance(); $task_obj = CPM_Task::getInstance(); $due = strtotime($milestone->due_date); $is_left = cpm_is_left(time(), $due); $milestone_completed = (int) $milestone->completed; if ($milestone_completed) { $class = 'complete'; } else { $class = $is_left == true ? 'left' : 'late'; } $string = $is_left == true ? __('left', 'cpm') : __('late', 'cpm'); $milestone_private = $milestone->private == 'yes' ? 'cpm-lock' : 'cpm-unlock'; ?> <div class="cpm-milestone <?php echo $class; ?> "> <div class="milestone-detail"> <h3> <?php echo $milestone->post_title; ?> <?php if (!$milestone_completed) { ?> <span class="time-left">(<?php printf('%s %s - %s', human_time_diff(time(), $due), $string, cpm_get_date($milestone->due_date)); ?> )</span> <?php } ?> <?php if (cpm_user_can_delete_edit($project_id, $milestone)) { ?> <ul class="cpm-links cpm-right"> <li> <a class="cpm-icon-edit" <?php cpm_data_attr(array('id' => $milestone->ID, 'project_id' => $project_id)); ?> href="#" title="<?php esc_attr_e('Edit milestone', 'cpm'); ?> "><span><?php _e('Edit', 'cpm'); ?> </span></a> </li> <li> <a class="cpm-icon-delete cpm-milestone-delete" <?php cpm_data_attr(array('project' => $project_id, 'id' => $milestone->ID, 'confirm' => __('Are you sure?', 'cpm'))); ?> title="<?php esc_attr_e('Delete milestone', 'cpm'); ?> " href="#"><span><?php _e('Delete', 'cpm'); ?> </span></a> </li> <?php if ($milestone->completed == '0') { ?> <li><a class="cpm-icon-tick grey cpm-milestone-complete" data-project="<?php echo $project_id; ?> " data-id="<?php echo esc_attr($milestone->ID); ?> " title="<?php esc_attr_e('Mark as complete', 'cpm'); ?> " href="#"><span><?php _e('Mark as complete', 'cpm'); ?> </span></a></li> <?php } else { ?> <li><a class="cpm-icon-tick green cpm-milestone-open" data-project="<?php echo $project_id; ?> " data-id="<?php echo esc_attr($milestone->ID); ?> " title="<?php esc_attr_e('Mark un-complete', 'cpm'); ?> " href="#"><span><?php _e('Reopen', 'cpm'); ?> </span></a></li> <?php } ?> <li> <span class="<?php echo $milestone_private; ?> "></span> </li> </ul> <?php } ?> </h3> <div class="detail"> <?php echo cpm_get_content($milestone->post_content); ?> </p> </div> </div> <div class="cpm-milestone-edit-form"></div> <?php if (cpm_user_can_access($project_id, 'tdolist_view_private')) { $tasklists = $milestone_obj->get_tasklists($milestone->ID, true); } else { $tasklists = $milestone_obj->get_tasklists($milestone->ID); } if (cpm_user_can_access($project_id, 'msg_view_private')) { $messages = $milestone_obj->get_messages($milestone->ID, true); } else { $messages = $milestone_obj->get_messages($milestone->ID); } if ($tasklists) { ?> <h3><?php _e('To-do List', 'cpm'); ?> </h3> <ul class="dash"> <?php foreach ($tasklists as $tasklist) { ?> <li> <a href="<?php echo cpm_url_single_tasklist($project_id, $tasklist->ID); ?> "><?php echo stripslashes($tasklist->post_title); ?> </a> <div class="cpm-right"> <?php $complete = $task_obj->get_completeness($tasklist->ID, $project_id); echo cpm_task_completeness($complete['total'], $complete['completed']); ?> </div> <div class="cpm-clear"></div> </li> <?php } ?> </ul> <?php } ?> <?php if ($messages) { ?> <h3><?php _e('Messages', 'cpm'); ?> </h3> <ul class="dash"> <?php foreach ($messages as $message) { ?> <li> <a href="<?php echo cpm_url_single_message($project_id, $message->ID); ?> "><?php echo stripslashes($message->post_title); ?> </a> (<?php echo cpm_get_date($message->post_date, true); ?> | <?php echo get_the_author_meta('display_name', $message->post_author); ?> ) </li> <?php } ?> </ul> <?php } ?> <?php if ($milestone_completed) { ?> <span class="cpm-milestone-completed"> <?php _e('Completed on:', 'cpm'); ?> <?php echo cpm_get_date($milestone->completed_on, true); ?> </span> <?php } ?> </div> <?php }
$users = $this->prepare_contacts(); if (!$users) { return; } cpm_get_email_header(); $tpbk = CPM_URL . '/assets/images/tpbk.png'; $msg_obj = CPM_Message::getInstance(); $parent_post = get_post($data['comment_post_ID']); $author = wp_get_current_user(); $comment_url = ''; switch ($parent_post->post_type) { case 'message': $type = __('Message', 'cpm'); $title = $parent_post->post_title; $comment_url = cpm_url_single_message($project_id, $data['comment_post_ID']); break; case 'task_list': $title = $parent_post->post_title; $type = __('Task List', 'cpm'); $comment_url = cpm_url_single_tasklist($project_id, $parent_post->ID); break; case 'task': $type = __('Task', 'cpm'); $title = $parent_post->post_title; $comment_url = cpm_url_single_task($project_id, $parent_post->post_parent, $parent_post->ID); break; } // $template_vars = array( // '%SITE%' => wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ), // '%PROJECT_NAME%' => get_post_field( 'post_title', $project_id ),
/** * Single comment URL * * @param int $comment_id * @param int $project_id * @return string */ function cpm_url_comment($comment_id, $project_id) { $comment = get_comment($comment_id); if (!$comment) { return false; } $post = get_post($comment->comment_post_ID); $url = ''; if (!$post) { return false; } if ($post->post_type == 'message') { $url = cpm_url_single_message($project_id, $post->ID); } else { if ($post->post_type == 'task_list') { $url = cpm_url_single_tasklist($project_id, $post->ID); } else { if ($post->post_type == 'task') { $list = get_post($post->post_parent); $url = cpm_url_single_task($project_id, $list->ID, $post->ID); } } } $url = "{$url}#cpm-comment-{$comment_id}"; return apply_filters('cpm_url_comment', $url, $comment_id, $project_id, $post->ID); }
<?php $users = $this->prepare_contacts(); if (!$users) { return; } cpm_get_email_header(); $new = CPM_URL . '/assets/images/new.png'; $triangle = CPM_URL . '/assets/images/triangle.png'; $pro_obj = CPM_Project::getInstance(); $msg_obj = CPM_Message::getInstance(); $project = $pro_obj->get($project_id); $msg = $msg_obj->get($message_id); $author = wp_get_current_user(); $template_vars = array('%SITE%' => wp_specialchars_decode(get_option('blogname'), ENT_QUOTES), '%PROJECT_NAME%' => $project->post_title, '%PROJECT_URL%' => '<a style="text-decoration: none;" href="' . cpm_url_project_details($project_id) . '">' . get_post_field('post_title', $project_id) . '</a>', '%AUTHOR%' => $author->display_name, '%AUTHOR_EMAIL%' => $author->user_email, '%MESSAGE_URL%' => '<a style="text-decoration: none;" href="' . cpm_url_single_message($project_id, $message_id) . '">' . get_post_field('post_title', $message_id) . '</a>', '%MESSAGE%' => $msg->post_content, '%IP%' => get_ipaddress()); $subject = cpm_get_option('new_message_sub'); $message = cpm_get_content(cpm_get_option('new_message_body')); // subject foreach ($template_vars as $key => $value) { $subject = str_replace($key, $value, $subject); } // message foreach ($template_vars as $key => $value) { $message = str_replace($key, $value, $message); } ?> <table width="600" style="margin-top: 50px; background: #fff;"> <tr> <td> <center><img src="<?php
/** * Send email to all about a new comment * * @param int $comment_id * @param array $comment_info the post data */ function new_comment($comment_id, $project_id, $data) { $users = $this->prepare_contacts(); if (!$users) { return; } $msg_obj = CPM_Message::getInstance(); $parent_post = get_post($data['comment_post_ID']); $post_type = get_post_type_object($parent_post->post_type); $author = wp_get_current_user(); $subject = sprintf(__('[%s] New comment on %s: %s', 'cpm'), __('Project Manager', 'cpm'), $post_type->labels->singular_name, $parent_post->post_title); $message = sprintf('New comment on %s', $parent_post->post_title) . "\r\n\n"; $message .= sprintf('Author : %s', $author->display_name) . "\r\n"; $message .= sprintf(__('Permalink : %s'), cpm_url_single_message($project_id, $data['comment_post_ID'])) . "\r\n"; $message .= sprintf("Comment : \r\n%s", $data['comment_content']) . "\r\n"; $users = apply_filters('cpm_new_comment_to', $users); $subject = apply_filters('cpm_new_comment_subject', $subject); $message = apply_filters('cpm_new_comment_message', $message); $this->send(implode(', ', $users), $subject, $message); }