<?php /* @package TaskFreak @since 0.1 @version 1.0 Update task status in Ajax */ $pid = intval($_REQUEST['proj']); $selected = intval($_REQUEST['user']); $users = get_users(); $project = new tfk_project(); $project->set_uid($pid); if ($pid && $project->load()) { if (!$project->check_access('post')) { echo '<p class="tfk_err">' . __("Sorry, you can't post in this project. Please contact an admin.", 'taskfreak') . '</p>'; } else { echo '<div id="tfk_corresponding_users">'; echo '<option value="">—</option>'; foreach ($users as $user) { if ($project->check_access('read', $user->ID)) { echo '<option value="' . $user->ID . '"' . ($user->ID == $selected ? ' selected' : '') . '>' . $user->display_name . '</option>'; } } echo '</div>'; } }
public function load_list($args = null) { $sql = array('sql' => 'SELECT project.project_id, project.name, project.description, project.who_read, project.who_comment, project.who_post, project.who_manage, project.trashed, project_status.log_date AS project_status_log_date, project_status.action_code AS project_status_action_code, project_status.project_id AS project_status_project_id, project_status.user_id AS project_status_user_id FROM ' . $this->db_table() . ' AS ' . $this->db_alias() . ' INNER JOIN ' . $this->db_table('log') . ' AS project_status ON project.project_id = project_status.project_id AND project_status.item_id = 0 ', 'count' => true, 'group' => 'project_status.project_id'); $where = 'project_status.log_date = ( SELECT MAX(log_date) FROM ' . $this->db_table('log') . ' WHERE project.project_id = project_id AND item_id = 0 )'; if ($args) { if (isset($args['where'])) { $where = $where .= ' AND ' . $args['where']; unset($args['where']); } $args['where'] = $where; $args = array_merge($args, $sql); } else { $sql['where'] = $where; $args = $sql; } return parent::load_list($args); }
$sort_params = array('priority', 'deadline_date', 'proximity', 'title', 'name', 'display_name', 'log_date', 'item_status_action_code', 'comment_count', 'file_count'); $sort = isset($_REQUEST['sort']) && in_array($_REQUEST['sort'], $sort_params) ? $_REQUEST['sort'] : 'proximity'; $order = isset($_REQUEST['ord']) && in_array($_REQUEST['ord'], array('asc', 'desc')) ? $_REQUEST['ord'] : 'ASC'; $this->page = isset($_REQUEST['pg']) && preg_match('/^\\d+$/', $_REQUEST['pg']) ? $_REQUEST['pg'] : 1; if (isset($_REQUEST['npg']) && preg_match('/^\\d+$/', $_REQUEST['npg'])) { // useful if JS is disabled if (!headers_sent()) { setcookie('tfk_page_size', $_REQUEST['npg']); } $this->page_size = $_REQUEST['npg']; } elseif (isset($_COOKIE['tfk_page_size']) && preg_match('/^\\d+$/', $_COOKIE['tfk_page_size'])) { $this->page_size = $_COOKIE['tfk_page_size']; } elseif ($this->options['tasks_per_page']) { $this->page_size = $this->options['tasks_per_page']; } else { $this->page_size = 5; } // show "new task" or not $project = new tfk_project(); $this->user_can_post = $project->load_count(array('where' => tfk_user::get_roles_sql('who_post') . ' AND trashed = 0')); // show only drafts to their author and to users who have the right to manage the project if (is_user_logged_in()) { $current_user = wp_get_current_user(); $can_see_drafts = '( item_status_action_code <> 0 OR item.author_id = ' . $current_user->ID . ' )'; } else { $can_see_drafts = 'item_status_action_code <> 0'; } $this->data->load_list(array('where' => tfk_user::get_roles_sql('who_read') . ' AND trashed = 0', 'having' => $can_see_drafts . ($this->filters['filter_task'] == 'all' ? '' : ' AND item_status_action_code = ' . $this->filters['filter_task']), 'order' => $sort . ' ' . $order . ', priority ASC', 'page_size' => $this->page_size, 'page' => $this->page, 'count' => true)); $this->npages = ceil($this->data->total() / $this->page_size); $this->prio_size = !empty($this->options['prio_size']); $this->view('front/task_list.php');