function delete_task() { check_ajax_referer('cpm_nonce'); $task_id = (int) $_POST['task_id']; $list_id = (int) $_POST['list_id']; $project_id = (int) $_POST['project_id']; $task_obj = CPM_Task::getInstance(); do_action('cpm_delete_task_prev', $task_id, $list_id, $project_id, $task_obj); $task_obj->delete_task($task_id, true); $complete = $task_obj->get_completeness($list_id, $project_id); do_action('cpm_delete_task_after', $task_id, $list_id, $project_id, $task_obj); echo json_encode(array('success' => true, 'list_url' => cpm_url_single_tasklist($project_id, $list_id), 'progress' => cpm_task_completeness($complete['total'], $complete['completed']))); exit; }
foreach ($attachments as $attachment) { $file = CPM_Comment::getInstance()->get_file($attachment->ID); $topic_url = '#'; 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">
/** * Displays a task list url * * @since 0.1 * @param array $atts * @return string */ function cpm_sc_tasklist_url($atts) { $atts = extract(shortcode_atts(array('id' => 0, 'project' => 0, 'title' => ''), $atts)); $url = cpm_url_single_tasklist($project, $id); return sprintf('<a href="%s">%s</a>', $url, $title); }
function new_task($list_id, $task_id, $data) { //notification is not selected or no one is assigned if ($_POST['task_assign'] == '-1') { return; } $project_id = 0; if (isset($_POST['project_id'])) { $project_id = intval($_POST['project_id']); } $user = get_user_by('id', intval($_POST['task_assign'])); $to = sprintf('%s <%s>', $user->display_name, $user->user_email); $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%' => $user->display_name, '%AUTHOR_EMAIL%' => $user->user_email, '%TASKLIST_URL%' => cpm_url_single_tasklist($project_id, $list_id), '%TASK_URL%' => cpm_url_single_task($project_id, $list_id, $task_id), '%TASK%' => $data['post_content'], '%IP%' => get_ipaddress()); $subject = cpm_get_option('new_task_sub'); $message = 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); } $this->send($to, $subject, $message); }
/** * 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 }
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 ), // '%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'],
/** * 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 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
<?php cpm_get_header(__('To-do List', 'cpm'), $project_id); $task_obj = CPM_Task::getInstance(); $list = $task_obj->get_task_list($tasklist_id); $task = $task_obj->get_task($task_id); ?> <h3 class="cpm-nav-title"> <?php _e('Task List', 'cpm'); ?> : <a href="<?php echo cpm_url_single_tasklist($project_id, $list->ID); ?> "><?php echo get_the_title($list->ID); ?> </a> </h3> <div class="cpm-single-task"> <?php echo cpm_task_html($task, $project_id, $list->ID, true); ?> </div> <h3 class="cpm-comment-title"><?php _e('Discuss this to-do', 'cpm'); ?> </h3>