function create($project_id, $milestone_id = 0) { $posted = $_POST; $is_update = $milestone_id ? true : false; $milestone_privacy = isset($posted['milestone_privacy']) ? $posted['milestone_privacy'] : 'no'; $data = array('post_parent' => $project_id, 'post_title' => $posted['milestone_name'], 'post_content' => $posted['milestone_detail'], 'post_type' => 'milestone', 'post_status' => 'publish'); if ($milestone_id) { $data['ID'] = $milestone_id; $milestone_id = wp_update_post($data); } else { $milestone_id = wp_insert_post($data); update_post_meta($milestone_id, '_completed', 0); //open initially } if ($milestone_id) { $posted['milestone_due'] = isset($posted['milestone_due']) && !empty($posted['milestone_due']) ? cpm_date2mysql($posted['milestone_due']) : current_time('mysql'); update_post_meta($milestone_id, '_due', $posted['milestone_due']); update_post_meta($milestone_id, '_milestone_privacy', $milestone_privacy); if ($is_update) { CPM_Project::getInstance()->new_project_item($project_id, $milestone_id, $milestone_privacy, 'milestone', true); do_action('cpm_milestone_update', $milestone_id, $project_id, $data); } else { CPM_Project::getInstance()->new_project_item($project_id, $milestone_id, $milestone_privacy, 'milestone', false); do_action('cpm_milestone_new', $milestone_id, $project_id, $data); } } return $milestone_id; }
/** * Add a single task * * @param int $list_id task list id * @return int $task_id task id for update purpose */ function add_task($list_id, $postdata, $task_id = 0) { $files = isset($postdata['cpm_attachment']) ? $postdata['cpm_attachment'] : array(); $task_privacy = isset($postdata['task_privacy']) ? $postdata['task_privacy'] : 'no'; $is_update = $task_id ? true : false; $content = trim($postdata['task_text']); $assigned = isset($postdata['task_assign']) ? $postdata['task_assign'] : array('-1'); $due = empty($postdata['task_due']) ? '' : cpm_date2mysql($postdata['task_due']); $start = empty($postdata['task_start']) ? '' : cpm_date2mysql($postdata['task_start']); $data = array('post_parent' => $list_id, 'post_title' => trim(substr($content, 0, 40)), 'post_content' => $content, 'post_type' => 'task', 'post_status' => 'publish'); $data = apply_filters('cpm_task_params', $data); if ($task_id) { $data['ID'] = $task_id; $task_id = wp_update_post($data); } else { $task_id = wp_insert_post($data); } if ($task_id) { $this->assign_user($task_id, $assigned); update_post_meta($task_id, '_due', $due); if (cpm_get_option('task_start_field') == 'on') { update_post_meta($task_id, '_start', $start); } else { update_post_meta($task_id, '_start', ''); } update_post_meta($task_id, '_task_privacy', $task_privacy); //initially mark as uncomplete if (!$is_update) { update_post_meta($task_id, '_completed', 0); } //if there is any file, update the object reference if (count($files) > 0) { $comment_obj = CPM_Comment::getInstance(); foreach ($files as $file_id) { $comment_obj->associate_file($file_id, $task_id); } } if ($is_update) { $this->new_task_project_item($list_id, $task_id, $assigned, $task_privacy, $is_update); do_action('cpm_task_update', $list_id, $task_id, $data); } else { $this->new_task_project_item($list_id, $task_id, $assigned, $task_privacy, $is_update); do_action('cpm_task_new', $list_id, $task_id, $data); } } return $task_id; }
function create($project_id, $milestone_id = 0) { $posted = $_POST; $is_update = $milestone_id ? true : false; $data = array('post_parent' => $project_id, 'post_title' => $posted['milestone_name'], 'post_content' => $posted['milestone_detail'], 'post_type' => 'milestone', 'post_status' => 'publish'); if ($milestone_id) { $data['ID'] = $milestone_id; $milestone_id = wp_update_post($data); } else { $milestone_id = wp_insert_post($data); update_post_meta($milestone_id, '_completed', 0); //open initially } if ($milestone_id) { update_post_meta($milestone_id, '_due', cpm_date2mysql($posted['milestone_due'])); if ($is_update) { do_action('cpm_milestone_update', $milestone_id, $project_id, $data); } else { do_action('cpm_milestone_new', $milestone_id, $project_id, $data); } } return $milestone_id; }
<?php $logo_path = cpm_get_option('logo'); $date = cpm_date2mysql(current_time('mysql')); $custom_date = date('l, d F Y', strtotime($date)); $calendar = CPM_URL . '/assets/images/calendar.png'; ?> <div style="background: #f5f5f5; padding-bottom: 30px;"> <div style="width:600px; margin: 0 auto; background: #fff;"> <table cellspacing="0" cellpadding="0"> <tr> <td> <div style="height:9px; width: 100%; background: #858585;"> </div> <div style="height: 83px; width: 100%; background: #ededed;"> <div style="float: left; margin-left: 50px; margin-top: 21px;"><a href="<?php echo home_url(); ?> "><img src="<?php echo $logo_path; ?> "></a></div> <div style="float: right; margin-right: 50px; margin-top: 33px;"> <img style="float: left;" src="<?php echo $calendar; ?> "> <div style="float: right; margin: 3px 10px; font-family: arial; font-size: 13px;"><?php echo $custom_date; ?>