예제 #1
0
 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;
 }
예제 #2
0
 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);
 }
예제 #3
0
 /**
  * Generates navigational menu for a project
  *
  * @param int $project_id
  * @return array
  */
 function nav_links($project_id)
 {
     $links = array(__('Activity', 'cpm') => cpm_url_project_details($project_id), __('Messages', 'cpm') => cpm_url_message_index($project_id), __('To-do Lists', 'cpm') => cpm_url_tasklist_index($project_id), __('Milestones', 'cpm') => cpm_url_milestone_index($project_id), __('Files', 'cpm') => cpm_url_file_index($project_id));
     $links = apply_filters('cpm_project_nav_links', $links, $project_id);
     if (cpm_user_can_access($project_id)) {
         $links[__('Settings', 'cpm')] = cpm_url_settings_index($project_id);
     }
     return $links;
 }
 /**
  * Generates navigational menu for a project
  *
  * @param int $project_id
  * @return array
  */
 function nav_links($project_id)
 {
     $links = array(__('Activity', 'cpm') => cpm_url_project_details($project_id), __('Messages', 'cpm') => cpm_url_message_index($project_id), __('To-do List', 'cpm') => cpm_url_tasklist_index($project_id), __('Milestones', 'cpm') => cpm_url_milestone_index($project_id), __('Files', 'cpm') => cpm_url_file_index($project_id));
     return apply_filters('cpm_project_nav_links', $links, $project_id);
 }