function get_events() { $projects = CPM_Project::getInstance()->get_projects(); unset($projects['total_projects']); if (cpm_get_option('task_start_field') == 'on') { $enable_start = true; } else { $enable_start = false; } $events = array(); if ($projects) { foreach ($projects as $project) { $project_id = $project->ID; if (absint($_POST['project_id']) && $project_id != absint($_POST['project_id'])) { continue; } //Get Milestones $milestones = CPM_Milestone::getInstance()->get_by_project($project_id); if ($milestones) { foreach ($milestones as $milestone) { //Milestone Event $events[] = array('id' => $milestone->ID, 'title' => $milestone->post_title, 'start' => $milestone->due_date, 'url' => cpm_url_milestone_index($project_id), 'color' => '#32b1c8', 'className' => $milestone->completed == 1 ? 'milestone competed' : 'milestone'); } } //Get Tasks if (cpm_user_can_access($project_id, 'tdolist_view_private')) { $task_lists = CPM_Task::getInstance()->get_task_lists($project_id, true); } else { $task_lists = CPM_Task::getInstance()->get_task_lists($project_id); } if ($task_lists) { foreach ($task_lists as $task_list) { $tasks = CPM_Task::getInstance()->get_tasks_by_access_role($task_list->ID, $project_id); foreach ($tasks as $task) { $image = ''; if (is_array($task->assigned_to)) { foreach ($task->assigned_to as $key => $user_id) { $image .= get_avatar($user_id, 16); } } else { $image .= get_avatar($task->assigned_to, 16); } //Tasks Event if ($enable_start) { if (isset($task->start_date) && !empty($task->start_date)) { $start_date = $task->start_date; } else { $start_date = $task->due_date; } $events[] = array('id' => $task->ID, 'img' => $task->assigned_to == -1 ? '' : $image, 'title' => $task->post_title, 'start' => $start_date, 'end' => $task->due_date, 'complete_status' => $task->completed == 1 ? 'yes' : 'no', 'url' => cpm_url_single_task($project_id, $task_list->ID, $task->ID), 'color' => 'transparent', 'textColor' => '#c86432', 'className' => date('Y-m-d', time()) < $task->due_date ? 'cpm-calender-todo cpm-task-running' : 'cpm-calender-todo cpm-expire-task'); } else { $events[] = array('id' => $task->ID, 'img' => $task->assigned_to == -1 ? '' : $image, 'title' => $task->post_title, 'start' => $task->due_date, 'complete_status' => $task->completed == 1 ? 'yes' : 'no', 'url' => cpm_url_single_task($project_id, $task_list->ID, $task->ID), 'color' => 'transparent', 'textColor' => '#c86432', 'className' => date('Y-m-d', time()) < $task->due_date ? 'cpm-calender-todo cpm-task-running' : 'cpm-calender-todo cpm-expire-task'); } } } } } } return $events; }
echo $next_name; ?> </div> <div style="font-family: arial; font-size: 14px; line-height: 24px;"> <span style="float: left; font-size: 21px; width: 20px; color: #bcbcbc;">☑</span> <span style="float: left; width: 459px;"><?php echo $data->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_task($project_id, $list_id, $task_id); ?> " style="font-family: lato; font-size: 16px; text-decoration: none; color: #fff;"> <?php _e('View Task', 'cpm'); ?> </a> </div> </center> </div> <?php cpm_get_email_footer();
$base_image_url = admin_url('admin-ajax.php?action=cpm_file_get'); if ($attachments) { echo '<ul class="cpm-files">'; 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']; }
function all_search() { $project_id = isset($_POST['project_id']) ? $_POST['project_id'] : false; $item = trim($_POST['item']); if (!$project_id) { $args = array('post_type' => array('project', 'task_list', 'task', 'message', 'milestone'), 'post_status' => 'publish', 'posts_per_page' => '-1', 's' => $item); $args = apply_filters('cpm_all_project_search_query_arg', $args, $item); $query = new WP_Query($args); $posts = $query->posts; } if ($project_id) { $args = array('post_type' => array('task_list', 'message', 'milestone'), 'post_status' => 'publish', 'post_parent' => $project_id, 'posts_per_page' => '-1', 's' => $item); $query = new WP_Query($args); global $wpdb; $sql = "SELECT * FROM {$wpdb->posts} AS p\n LEFT JOIN {$wpdb->posts} AS tl ON p.ID=tl.post_parent\n LEFT JOIN {$wpdb->posts} AS tk ON tl.ID=tk.post_parent\n WHERE\n p.post_type='project' AND p.post_status='publish' AND p.ID={$project_id}\n AND tl.post_type='task_list' AND tk.post_type='task'\n AND tl.post_status='publish' AND tk.post_status='publish'\n AND ( tk.post_title like '%{$item}%' OR tk.post_content like '%{$item}%' )"; $posts = $wpdb->get_results($sql); $posts = array_merge($query->posts, $posts); } $url = array(); $items = array(); foreach ($posts as $key => $post) { switch ($post->post_type) { case 'project': $url = cpm_url_project_details($post->ID); $category = __('Project: ', 'cpm'); $items[] = array('label' => '<div class="cpm-all-search-item"><a href="' . $url . '"><strong>' . $category . '</strong>' . $post->post_title . '</a></div>'); break; case 'task_list': $url = cpm_url_single_tasklist($post->post_parent, $post->ID); $category = __('Task List: ', 'cpm'); $items[] = array('label' => '<div class="cpm-all-search-item"><a href="' . $url . '"><strong>' . $category . '</strong>' . $post->post_title . '</a></div>'); break; case 'task': $task_list = get_post($post->post_parent); $url = cpm_url_single_task($task_list->post_parent, $post->post_parent, $post->ID); $category = __('Task: ', 'cpm'); $items[] = array('label' => '<div class="cpm-all-search-item"><a href="' . $url . '"><strong>' . $category . '</strong>' . $post->post_title . '</a></div>'); break; case 'message': $url = cpm_url_single_message($post->post_parent, $post->ID); $category = __('Message: ', 'cpm'); $items[] = array('label' => '<div class="cpm-all-search-item"><a href="' . $url . '"><strong>' . $category . '</strong>' . $post->post_title . '</a></div>'); break; case 'milestone': $url = cpm_url_milestone_index($post->post_parent); $category = __('Milestone: ', 'cpm'); $items[] = array('label' => '<div class="cpm-all-search-item"><a href="' . $url . '"><strong>' . $category . '</strong>' . $post->post_title . '</a></div>'); break; } } if (!count($items)) { $items[] = array('label' => '<div class="cpm-all-search-item"><strong>' . __('No item found !', 'cpm') . '</strong></div>'); } $search_details = json_encode($items); wp_send_json_success($search_details); }
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); }
/** * Displays a single task url * * @since 0.1 * @param array $atts * @return string */ function cpm_sc_task_url($atts) { $atts = extract(shortcode_atts(array('id' => 0, 'list' => 0, 'project' => 0, 'title' => ''), $atts)); $url = cpm_url_single_task($project, $list, $id); return sprintf('<a href="%s">%s</a>', $url, $title); }
/** * HTML generator for single task * * @param object $task * @param int $project_id * @param int $list_id * @return string */ function cpm_task_html($task, $project_id, $list_id, $single = false) { $wrap_class = $task->completed == '1' ? 'cpm-task-complete' : 'cpm-task-uncomplete'; $start_date = isset($task->start_date) ? $task->start_date : ''; $is_admin = is_admin() ? 'yes' : 'no'; $can_manage = cpm_user_can_delete_edit($project_id, $task); $disabled = ' disabled="disabled"'; $status_class = 'can-not'; $private_class = $task->task_privacy == 'yes' ? 'cpm-lock' : 'cpm-unlock'; $user_id = get_current_user_id(); if (is_array($task->assigned_to)) { $assing_user = in_array($user_id, $task->assigned_to) ? true : false; } else { $assing_user = $user_id == $task->assigned_to ? true : false; } if ($can_manage || $assing_user) { $status_class = $task->completed == '1' ? 'cpm-complete' : 'cpm-uncomplete'; $disabled = ''; } if (isset($_POST['is_admin']) && $_POST['is_admin'] == 'no' || isset($_REQUEST['cpmf_url'])) { $is_admin = 'no'; } $title_link_status = apply_filters('cpm_task_title_link', true, $task, $project_id, $list_id, $single); ob_start(); ?> <div class="cpm-todo-wrap <?php echo $wrap_class; ?> "> <?php if ($can_manage) { ?> <span class="cpm-todo-action"> <a href="#" class="cpm-todo-delete cpm-icon-delete" <?php cpm_data_attr(array('single' => $single, 'list_id' => $list_id, 'project_id' => $project_id, 'task_id' => $task->ID, 'confirm' => __('Are you sure to delete this to-do?', 'cpm'))); ?> > <span><?php _e('Delete', 'cpm'); ?> </span> </a> <?php if ($task->completed != '1') { ?> <a href="#" class="cpm-todo-edit cpm-icon-edit"><span><?php _e('Edit', 'cpm'); ?> </span></a> <?php } ?> </span> <?php } ?> <span class="cpm-spinner"></span> <input class="<?php echo $status_class; ?> " type="checkbox" <?php cpm_data_attr(array('single' => $single, 'list' => $list_id, 'project' => $project_id, 'is_admin' => $is_admin)); ?> value="<?php echo $task->ID; ?> " name="" <?php checked($task->completed, '1'); ?> <?php echo $disabled; ?> > <span class="move"></span> <span class="cpm-todo-content"> <?php if ($single) { ?> <span class="cpm-todo-text"><?php echo $task->post_content; ?> </span> <span class="<?php echo $private_class; ?> "></span> <?php } else { if ($title_link_status) { ?> <a href="<?php echo cpm_url_single_task($project_id, $list_id, $task->ID); ?> "> <span class="cpm-todo-text"><?php echo $task->post_content; ?> </span> <span class="<?php echo $private_class; ?> "></span> </a> <?php } else { ?> <span class="cpm-todo-text"><?php echo $task->post_content; ?> </span> <span class="<?php echo $private_class; ?> "></span> <?php } } ?> <?php if ((int) $task->comment_count > 0 && !$single) { ?> <span class="cpm-comment-count"> <a href="<?php echo cpm_url_single_task($project_id, $list_id, $task->ID); ?> "> <?php printf(_n(__('1 Comment', 'cpm'), __('%d Comments', 'cpm'), $task->comment_count, 'cpm'), $task->comment_count); ?> </a> </span> <?php } ?> <?php //if the task is completed, show completed by if ($task->completed == '1' && $task->completed_by) { $completion_time = cpm_get_date($task->completed_on, true); ?> <span class="cpm-completed-by"> <?php printf(__('(Completed by %s on %s)', 'cpm'), cpm_url_user($task->completed_by), $completion_time); ?> </span> <?php } ?> <?php if ($task->completed != '1') { if (reset($task->assigned_to) != '-1') { cpm_assigned_user($task->assigned_to); } if ($start_date != '' || $task->due_date != '') { $task_status_wrap = date('Y-m-d', time()) > date('Y-m-d', strtotime($task->due_date)) ? 'cpm-due-date' : 'cpm-current-date'; ?> <span class="<?php echo $task_status_wrap; ?> "> <?php if (cpm_get_option('task_start_field') == 'on' && $start_date != '') { echo cpm_get_date($start_date); } if ($start_date != '' & $task->due_date != '') { echo ' - '; } if ($task->due_date != '') { echo cpm_get_date($task->due_date); } ?> </span> <?php } } ?> </span> <?php if ($task->completed != 1) { ?> <div class="cpm-task-edit-form"> <?php echo cpm_task_new_form($list_id, $project_id, $task, $single); ?> </div> <?php } ?> <?php do_action('cpm_task_single_after', $task, $project_id, $list_id, $single, $task->completed); ?> </div> <?php return ob_get_clean(); }
$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'], // '%IP%' => get_ipaddress() // ); // $message = cpm_get_content( cpm_get_option( 'new_comment_body' ) ); // // message // foreach ($template_vars as $key => $value) {
/** * 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); }
/** * HTML generator for single task * * @param object $task * @param int $project_id * @param int $list_id * @return string */ function cpm_task_html($task, $project_id, $list_id, $single = false) { $wrap_class = $task->completed == '1' ? 'cpm-task-complete' : 'cpm-task-uncomplete'; ob_start(); ?> <div class="cpm-todo-wrap <?php echo $wrap_class; ?> "> <span class="cpm-todo-action"> <a href="#" class="cpm-todo-delete cpm-icon-delete" <?php cpm_data_attr(array('single' => $single, 'list_id' => $list_id, 'project_id' => $project_id, 'task_id' => $task->ID, 'confirm' => __('Are you sure to delete this to-do?', 'cpm'))); ?> > <span><?php _e('Delete', 'cpm'); ?> </span> </a> <?php if ($task->completed != '1') { ?> <a href="#" class="cpm-todo-edit cpm-icon-edit"><span><?php _e('Edit', 'cpm'); ?> </span></a> <?php } ?> </span> <input type="checkbox" <?php cpm_data_attr(array('single' => $single, 'list' => $list_id, 'project' => $project_id)); ?> value="<?php echo $task->ID; ?> " name="" <?php checked($task->completed, '1'); ?> > <span class="cpm-todo-content"> <?php if ($single) { ?> <span class="cpm-todo-text"><?php echo $task->post_content; ?> </span> <?php } else { ?> <a href="<?php echo cpm_url_single_task($project_id, $list_id, $task->ID); ?> "> <span class="cpm-todo-text"><?php echo $task->post_content; ?> </span> </a> <?php } ?> <?php if ((int) $task->comment_count > 0 && !$single) { ?> <span class="cpm-comment-count"> <a href="<?php echo cpm_url_single_task($project_id, $list_id, $task->ID); ?> "> <?php printf(_n(__('1 Comment', 'cpm'), __('%d Comments', 'cpm'), $task->comment_count, 'cpm'), $task->comment_count); ?> </a> </span> <?php } ?> <?php //if the task is completed, show completed by if ($task->completed == '1' && $task->completed_by) { $user = get_user_by('id', $task->completed_by); $completion_time = cpm_get_date($task->completed_on, true); ?> <span class="cpm-completed-by"> <?php printf(__('(Completed by %s on %s)', 'cpm'), $user->display_name, $completion_time); ?> </span> <?php } ?> <?php if ($task->completed != '1') { if ($task->assigned_to != '-1') { $user = get_user_by('id', $task->assigned_to); ?> <span class="cpm-assigned-user"><?php echo $user->display_name; ?> </span> <?php } ?> <?php if ($task->due_date != '') { ?> <span class="cpm-due-date"> <?php echo cpm_get_date($task->due_date); ?> </span> <?php } } ?> </span> <?php if ($task->completed == '0') { ?> <div class="cpm-task-edit-form"> <?php echo cpm_task_new_form($list_id, $project_id, $task, $single); ?> </div> <?php } ?> </div> <?php return ob_get_clean(); }
<?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