/** * Search report * * @return void */ function report() { //check_ajax_referer( 'cpm_nonce' ); parse_str($_POST['data'], $data); $table = cpm()->report->report_generate($data); wp_send_json_success(array('table' => $table)); }
/** * Delete todo list * * @param int $project_id * @param int $list_id * @param boolen $force * * - Method: DELETE * - URL: http://example.com/cpm-json/projects/project_id/lists/list_id/?force=1 * * @since 1.2 * @return array */ public function delete_list($project_id, $list_id, $force = false) { $list_id = (int) $list_id; $project_id = (int) $project_id; if (!$project_id) { return new WP_Error('project_id', __('Invalid project id.', 'cpm')); } if (!$list_id) { return new WP_Error('list_id', __('Invalid list id', 'cpm')); } $project_id = intval($project_id); $list_id = intval($list_id); $post = get_post($list_id); if (empty($list_id) || empty($post->ID)) { return new WP_Error('json_post_invalid_id', __('Invalid post ID.'), array('status' => 404)); } $post = cpm()->task->get_task_list($list_id); if (!cpm_user_can_delete_edit($project_id, $post)) { return new WP_Error('premission', __('Permission deny'), array('status' => 404)); } $force = $force ? true : false; cpm()->task->delete_list($list_id, $force); if ($force) { return array('message' => __('Permanently deleted post')); } else { // TODO: return a HTTP 202 here instead return array('message' => __('Deleted post')); } }
<?php $project_users = CPM_Project::getInstance()->get_users($project_id); $users = array(); $task_data = cpm()->task->get_task($task_id); $due_date = cpm_get_date(current_time('mysql')); if (!empty($due_date)) { $next_name = sprintf('<em style="font-family: lato; color: #B3B3B3; ">%s</em> <strong style="font-family: lato; color: #7e7e7e;"> <span style="padding-right: 5px;">%s</span>', __('Date ', 'cpm'), $due_date); } else { $next_name = ''; } 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) { return; } cpm_get_email_header(); $tpbk = CPM_URL . '/assets/images/tpbk.png'; $completed_user = get_user_by('id', $data->completed_by); // $template_vars = array( // '%SITE%' => wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ),
* related markup. * * @since 0.1 */ function admin_page_handler() { $this->router->output(); } /** * Shows the add-ons page on admin * * @return void */ function admin_page_addons() { $this->router->admin_page_addons(); } } /** * Returns the main instance. * * @since 1.1 * @return WeDevs_CPM */ function cpm() { return WeDevs_CPM::instance(); } //cpm instance. cpm();
/** * Delete a milestone * * @param int $project_id * @param int $milestone_id * @param boolen $force * * - URL: http://example.com/cpm-json/projects/project_id/milestones/milestone_id/?force=1 * - METHOD: DELETE * * @since 1.2 * @return array */ public function delete_milestone($project_id, $milestone_id, $force = false) { $project_id = intval($project_id); $milestone_id = intval($milestone_id); if (!$project_id) { return new WP_Error('milestone_id', __('Invalid project id', 'cpm')); } if (!$milestone_id) { return new WP_Error('milestone_id', __('Invalid milestoe id', 'cpm')); } $milestone = get_post($milestone_id); if (!cpm_user_can_delete_edit($project_id, $milestone)) { return new WP_Error('permission', __('Sorry! you do not have permission to delete this milestone', 'cpm'), array('status' => 404)); } $force = $force ? true : false; cpm()->milestone->delete($milestone_id, $force); if ($force) { return array('message' => __('Permanently deleted post')); } else { // TODO: return a HTTP 202 here instead return array('message' => __('Deleted post')); } }
/** * Get all comments for individual message, todo list, task * * @param int $project_id * @param int $post_id * * @since 1.2 * @return array $response */ public function get_comments($project_id, $post_id) { $premission = $this->check_get_comment_permission($project_id, $post_id); if ($premission !== true) { return new WP_Error($premission['key'], $premission['message'], array('status' => 404)); } remove_filter('comments_clauses', 'cpm_hide_comments', 99); $comments = cpm()->comment->get_comments($post_id); $response = new WP_JSON_Response(); $response->set_data($comments); return $response; }
* related markup. * * @since 0.1 */ function admin_page_handler() { $this->router->output(); } /** * Shows the add-ons page on admin * * @return void */ function admin_page_addons() { $this->router->admin_page_addons(); } } /** * Returns the main instance. * * @since 1.1 * @return WeDevs_CPM */ function cpm() { return WeDevs_CPM::instance(); } //cpm instance. $cpm = cpm();
/** * Delete project * * @param int $project_id * @param boolen $force * * - URL: http://example.com/cpm-json/projects/project_id/?force=1 * - Method: DELETE * * @since 1.2 * @return array */ public function delete_project($project_id, $force = false) { $id = intval($project_id); if (!$id) { return new WP_Error('json_post_invalid_id', __('Invalid project ID.'), array('status' => 404)); } $manage_capability = cpm_manage_capability(); if (!$manage_capability && !cpm_project_user_role_pre_chache($id)) { return new WP_Error('permission', __('Sorry! you are not assigned in this project', 'cpm'), array('status' => 404)); } if (!cpm_user_can_access($id)) { return new WP_Error('project_edit_capability', __('You do not have permission to delete this project', 'cpm')); } $post = get_post($id, ARRAY_A); if (empty($post['ID'])) { return new WP_Error('json_post_invalid_id', __('Invalid post ID.'), array('status' => 404)); } cpm()->project->delete($id, $force); if ($force) { return array('message' => __('Permanently deleted post')); } else { return array('message' => __('Deleted post')); } }
/** * Delete a task * * @param int $project_id * @param int $list_id * @param int $task_id * @param boolen $force * * - URL: http://example.com/cpm-json/projects/project_id/lists/list_id/tasks/task_id/?force=1 * - METHOD: DELETE * * @since 1.2 * @return array */ public function delete_task($project_id, $list_id, $task_id, $force = false) { $task_id = (int) $task_id; $project_id = (int) $project_id; if (!$project_id) { return new WP_Error('json_post_invalid_id', __('Invalid project ID.'), array('status' => 404)); } if (!$task_id) { return new WP_Error('task_id', __('Invalid task id', 'cpm')); } $task = get_post($task_id); if (!cpm_user_can_delete_edit($project_id, $task)) { return new WP_Error('permission', __('Sorry! you do not have permission to edit this task', 'cpm'), array('status' => 404)); } $force = $force ? true : false; $result = cpm()->task->delete_task($task_id, $force); if ($force) { return array('message' => __('Permanently deleted post')); } else { // TODO: return a HTTP 202 here instead return array('message' => __('Deleted post')); } }