function bp_gtm_get_tasks($group_id = false, $filter = false, $project_id = false, $limit = false) { global $bp; if (!$group_id) { $group_id = $bp->groups->current_group->id; } if (($filter == 'done' || $filter == 'undone') && is_numeric($group_id) && $project_id == false) { $tasks = BP_GTM_Tasks::get_done($filter, $group_id, $limit); } elseif ($filter == 'done' && is_numeric($project_id)) { $tasks = BP_GTM_Tasks::get_tasks_in_project($project_id, $done = true, $limit); } elseif ($filter == 'alpha' && is_numeric($group_id)) { $tasks = BP_GTM_Tasks::get_alpha($group_id, $limit); } elseif ($filter == 'deadline' && is_numeric($group_id)) { $tasks = BP_GTM_Tasks::get_deadline($group_id, $limit); } elseif ($filter == 'ingroup' && is_numeric($group_id)) { $tasks = BP_GTM_Tasks::get_all($group_id, $limit); } elseif ($filter == 'inproject' && is_numeric($project_id)) { $tasks = BP_GTM_Tasks::get_tasks_in_project($project_id, $done = false, $limit); } elseif ($filter == 'without') { $tasks = BP_GTM_Tasks::get_task_whithout_project($group_id, $limit); } else { $tasks = BP_GTM_Tasks::get_all($group_id, $limit); } return $tasks; }
function bp_gtm_task_list_settings($bp_gtm_group_settings) { $limit['per_page'] = $option['per_page'] = $bp_gtm_group_settings['tasks_pp']; // how many to show $limit['miss'] = $option['miss'] = 0; // from the very first one - need to be on the 1st page $option['filter'] = !empty($_GET['filter']) ? $_GET['filter'] : ''; $option['action'] = !empty($_GET['action']) ? $_GET['action'] : 'task_view'; if (empty($_GET['project'])) { $option['project_id'] = false; if ($option['filter'] == 'done') { $option['page_h4'] = __('All Completed Tasks', 'bp_gtm'); $option['tasks'] = bp_gtm_get_tasks(bp_get_current_group_id(), $option['filter'] = 'done', false, $limit); $option['done_style'] = 'class="grey"'; } elseif ($option['filter'] == 'alpha') { $option['page_h4'] = __('Tasks by A/Z', 'bp_gtm'); $option['tasks'] = bp_gtm_get_tasks(bp_get_current_group_id(), $option['filter'] = 'alpha', false, $limit); $option['alpha_style'] = 'class="grey"'; } elseif ($option['filter'] == 'deadline') { $option['page_h4'] = __('Tasks by Deadline', 'bp_gtm'); $option['tasks'] = bp_gtm_get_tasks(bp_get_current_group_id(), $option['filter'] = 'deadline', false, $limit); $option['deadline_style'] = 'class="grey"'; } elseif ($option['filter'] == 'without') { $option['page_h4'] = __('Tasks whithout Project', 'bp_gtm'); $option['tasks'] = bp_gtm_get_tasks(bp_get_current_group_id(), $option['filter'], false, $limit); $option['by_proj_style'] = 'class="grey"'; } else { $option['page_h4'] = __('Tasks by Deadline', 'bp_gtm'); $option['tasks'] = bp_gtm_get_tasks(bp_get_current_group_id(), $option['filter'] = 'deadline', false, $limit); $option['deadline_style'] = 'class="grey"'; } } elseif (!empty($_GET['project']) && !empty($option['filter'])) { if ($option['filter'] == 'done') { $option['project_id'] = $_GET['project']; $option['page_h4'] = __('Completed Tasks in Project', 'bp_gtm') . ' "' . bp_gtm_get_el_name_by_id($_GET['project'], 'project') . '"'; $option['tasks'] = bp_gtm_get_tasks(bp_get_current_group_id(), $option['filter'] = 'done', $_GET['project'], $limit); $option['by_proj_style'] = 'class="grey"'; } } elseif (!empty($_GET['project']) && empty($option['filter'])) { if ($_GET['project'] == 'without') { $option['page_h4'] = __('Tasks whithout Project', 'bp_gtm'); $option['tasks'] = BP_GTM_Tasks::get_task_whithout_project(bp_get_current_group_id()); $option['by_proj_style'] = 'class="grey"'; } else { $option['page_h4'] = __('Tasks by Deadline', 'bp_gtm'); $option['tasks'] = bp_gtm_get_tasks(bp_get_current_group_id(), $option['filter'] = 'inproject', $_GET['project'], $limit); $option['deadline_style'] = 'class="grey"'; } } else { $option['project_id'] = false; $option['page_h4'] = __('Pending Tasks in Project', 'bp_gtm') . ' "' . bp_gtm_get_el_name_by_id($_GET['project'], 'project') . '"'; $option['tasks'] = bp_gtm_get_tasks(bp_get_current_group_id(), $option['filter'] = 'project', $_GET['project'], $limit); $option['view_project'] = '<a href="' . $gtm_link . 'projects/view/' . $_GET['project'] . '" class="button" title="' . __('Go to project\'s page', 'bp_gtm') . '">' . __('View Project', 'bp_gtm') . '</a>'; $option['filter'] = $_GET['project']; $option['by_proj_style'] = 'class="grey"'; } return $option; }