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; }
_e('Project Info', 'cpm'); ?> </span> <?php echo cpm_project_summary($project->info); ?> <?php do_action('cpm_project_header', $project); ?> </div> </h2> <div class="detail"> <?php echo cpm_get_content($project->post_content); ?> <?php do_action('cpm_project_after_description', $project); ?> </div> </div> <div class="cpm-edit-project" style="display:none;"> <?php if (cpm_user_can_access($project_id)) { cpm_project_form($project); } ?> </div>
/** * 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 }
if (is_array($project_users) && count($project_users)) { foreach ($project_users as $user_id => $role_array) { if ($this->filter_email($user_id)) { $users[$user_id] = sprintf('%s', $role_array['email']); // $users[$user_id] = sprintf( '%s (%s)', $role_array['name'], $role_array['email'] ); } } } //if any users left, get their mail addresses and send mail if ($users) { cpm_get_email_header(); $new = CPM_URL . '/assets/images/new.png'; $triangle = CPM_URL . '/assets/images/triangle.png'; $template_vars = array('%SITE%' => wp_specialchars_decode(get_option('blogname'), ENT_QUOTES), '%PROJECT_NAME%' => $data['post_title'], '%PROJECT_DETAILS%' => $data['post_content'], '%PROJECT_URL%' => '<a style="text-decoration: none;" href="' . cpm_url_project_details($project_id) . '">' . get_post_field('post_title', $project_id) . '</a>'); $subject = cpm_get_option('new_project_sub'); $message = cpm_get_content(cpm_get_option('new_project_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 echo $new;
<?php cpm_get_email_header(); $new = CPM_URL . '/assets/images/new.png'; $triangle = CPM_URL . '/assets/images/triangle.png'; $template_vars = array('%SITE%' => wp_specialchars_decode(get_option('blogname'), ENT_QUOTES), '%PROJECT_NAME%' => get_post_field('post_title', $project_id), '%PROJECT_URL%' => '<a style="text-decoration: none;" href="' . cpm_url_project_details($project_id) . '">' . get_post_field('post_title', $project_id) . '</a>', '%AUTHOR%' => $user->display_name, '%AUTHOR_EMAIL%' => $user->user_email, '%TASKLIST_URL%' => '<a style="text-decoration: none;" href="' . cpm_url_single_tasklist($project_id, $list_id) . '">' . get_post_field('post_title', $list_id) . '</a>', '%TASK_URL%' => '<a style="text-decoration: none;" href="' . cpm_url_single_task($project_id, $list_id, $task_id) . '">' . get_post_field('post_title', $task_id) . '</a>', '%TASK%' => $data['post_content'], '%IP%' => get_ipaddress()); $subject = cpm_get_option('new_task_sub'); $message = cpm_get_content(cpm_get_option('new_task_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 echo $new; ?> "/></center> </td> </tr> <tr> <td> <center><div style="font-size: 45px; padding-top: 38px;"><?php
echo $message->ID; ?> " data-project_id="<?php echo $project_id; ?> " 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;
if (is_array($project_users) && count($project_users)) { foreach ($project_users as $user_id => $role_array) { if ($this->filter_email($user_id)) { $users[$user_id] = sprintf('%s', $role_array['email']); // $users[$user_id] = sprintf( '%s (%s)', $role_array['name'], $role_array['email'] ); } } } //if any users left, get their mail addresses and send mail if ($users) { cpm_get_email_header(); $new = CPM_URL . '/assets/images/new.png'; $triangle = CPM_URL . '/assets/images/triangle.png'; $template_vars = array('%SITE%' => wp_specialchars_decode(get_option('blogname'), ENT_QUOTES), '%PROJECT_NAME%' => $data['post_title'], '%PROJECT_DETAILS%' => $data['post_content'], '%PROJECT_URL%' => '<a style="text-decoration: none;" href="' . cpm_url_project_details($project_id) . '">' . get_post_field('post_title', $project_id) . '</a>'); $subject = cpm_get_option('update_project_sub'); $message = cpm_get_content(cpm_get_option('update_project_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 echo $new; ?>
$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%' => '<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, '%COMMENT_URL%' => '<a style="text-decoration: none;" href="' . $comment_url . '/#cpm-comment-' . $comment_id . '">' . __('comment link', 'cpm') . '</a>', '%COMMENT%' => $data['comment_content'], '%IP%' => get_ipaddress()); $subject = cpm_get_option('new_comment_sub'); $message = cpm_get_content(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); } ?> <table width="600" style="margin-top: 50px; background: #fff;"> <tr> <td> <center><img src="<?php echo $new;
$project_users = CPM_Project::getInstance()->get_users($project_id); $users = array(); if (is_array($project_users) && count($project_users)) { foreach ($project_users as $user_id => $role_array) { if ($role_array['role'] == 'manager') { if ($this->filter_email($user_id)) { // $users[$user_id] = sprintf( '%s (%s)', $role_array['name'], $role_array['email'] ); $users[$user_id] = sprintf('%s', $role_array['email']); } } } } if ($users) { $template_vars = array('%SITE%' => wp_specialchars_decode(get_option('blogname'), ENT_QUOTES), '%PROJECT_NAME%' => get_post_field('post_title', $project_id), '%PROJECT_URL%' => '<a style="text-decoration: none;" href="' . cpm_url_project_details($project_id) . '">' . get_post_field('post_title', $project_id) . '</a>', '%TASKLIST_URL%' => '<a style="text-decoration: none;" href="' . cpm_url_single_tasklist($project_id, $list_id) . '"">' . get_post_field('post_title', $list_id) . '</a>', '%TASK_URL%' => '<a style="text-decoration: none;" href="' . cpm_url_single_task($project_id, $list_id, $task_id) . '">' . $data->post_content . '</a>', '%TASK%' => $data->post_content, '%IP%' => get_ipaddress()); $subject = cpm_get_option('complete_task_sub'); $message = cpm_get_content(cpm_get_option('completed_task_body')); // subject foreach ($template_vars as $key => $value) { $subject = str_replace($key, $value, $subject); } foreach ($template_vars as $key => $value) { $message = str_replace($key, $value, $message); } } ?> <table cellspacing="0" width="600"> <!-- <tr> <td style="position: relative;"><img style="position: absolute; left: 48%; top: -8px;" src="<?php echo $triangle; ?> "/></td>