if ($this->user_can_post) { ?> <a id="tfk_new_task" href="<?php echo esc_url(add_query_arg('edit', '')); ?> "><?php _e('New Task', 'taskfreak'); ?> </a> <?php } ?> <ul id="tfk_subfilters"> <?php echo tfk_item_status::list_links($this->baselink, 'filter_task', $this->filters['filter_task'], $this->data->count() ? $this->data->total() : null); ?> </ul> <?php if ($this->data->count()) { ?> <div id="tfk_task_count"> <?php echo $this->data->total() . ' ' . _n('task', 'tasks', $this->data->total(), 'taskfreak'); ?> </div> <div id="tfk_sort_criteria"> <label for="tfk_sort_criteria"><?php _e('Sort by:', 'taskfreak'); ?> </label>
/** * (non-PHPdoc) * @see tzn_model::load_list() */ public function load_list($args = null) { $sql = array('sql' => 'SELECT log.*, user.display_name, IF (log.item_id = 0, "project", "task") AS type, IFNULL(title, project.name) AS title_or_name, IFNULL(item.creation_date, project.creation_date) AS creation_date, IFNULL(who_read, (SELECT who_read FROM ' . $this->db_table('project') . ' WHERE project_id = item.project_id LIMIT 1) ) AS who_read, IF( log.project_id = 0, (SELECT action_code FROM ' . $this->db_table() . ' WHERE item_id = item.item_id AND action_code <> "" AND comment_id = 0 ORDER BY log_date DESC LIMIT 1), (SELECT action_code FROM ' . $this->db_table() . ' WHERE project_id = project.project_id AND action_code <> "" AND comment_id = 0 ORDER BY log_date DESC limit 1) ) AS status FROM ' . $this->db_table() . ' AS log LEFT JOIN ' . $this->db_table('item') . ' AS item ON item.item_id = log.item_id LEFT JOIN ' . $this->db_table('project') . ' AS project ON project.project_id = log.project_id LEFT JOIN ' . $this->db->base_prefix . 'users AS user ON user.ID = log.user_id', 'where' => '(log.item_id <> 0 OR project.trashed = 0)', 'having' => tfk_user::get_roles_sql('who_read') . ' AND status > 0', 'order' => 'log_date DESC'); if (isset($args['where'])) { $sql['where'] .= ' AND ' . $args['where']; } return parent::load_list($sql); }
} else { $this->current_project = ''; } if ($this->pid != 0 && get_current_user_id() != $this->data->get('author_id') && !$this->data->get('project')->check_access('manage')) { // or must be a manager of the project echo '<p class="tfk_err">' . __("Sorry, you can't edit this task. Please contact an admin.", 'taskfreak') . '</p>'; return; } // --- SUBMIT --------------------------- if (isset($_POST['edit'])) { // Submit data, check and save // we have to do this because of http://codex.wordpress.org/Function_Reference/stripslashes_deep#Notes $_POST = stripslashes_deep($_POST); if ($this->pid) { // prepare log info (if data check fails, it won't be saved) $update_log = new tfk_item_status(); $update_log->set('log_date', 'NOW'); $update_log->set('item_id', $this->pid); $update_log->set_object('user', get_current_user_id()); $update_log_info = array(); foreach (array('title', 'priority', 'user_id', 'description') as $prop) { if (!empty($_POST[$prop]) && $_POST[$prop] != $this->data->get($prop)) { $update_log_info[] = $prop; } } if (!empty($_POST['project_id']) && $_POST['project_id'] != $this->data->get('project')->get_uid()) { $update_log_info[] = 'project'; } if (!empty($_POST['deadline_date']) && $_POST['deadline_date'] != $this->data->html('deadline_date')) { $update_log_info[] = 'deadline'; }
$this->comment = new tfk_item_comment(); if (isset($_POST['edit'])) { // Submit data, check and save // we have to do this because of http://codex.wordpress.org/Function_Reference/stripslashes_deep#Notes $_POST = stripslashes_deep($_POST); $this->comment->set_auto($_POST); if (!$this->user_can_comment_project) { echo '<p class="tfk_err">' . __("Sorry, you can't comment tasks in this project. Please contact an admin.", 'taskfreak') . '</p>'; return; } elseif ($this->comment->check()) { $this->comment->set('body', $_POST['body'], 'HTM'); $this->comment->set('item_id', $this->pid); $this->comment->set('post_date', 'NOW'); $this->comment->set('user_id', get_current_user_id()); $this->comment->insert(); $log = new tfk_item_status(); $log->set('log_date', 'NOW'); $log->set('item_id', $this->pid); $log->set_object('user', get_current_user_id()); $log->set('comment_id', $this->comment->get_uid()); $log->save(); $this->comment->errors['file'] = ''; if ($this->options['comment_upload']) { $wp_upload_dir = wp_upload_dir(); for ($i = 1; $i <= 3; $i++) { // up to 3 uploads per comment if (!empty($_FILES["tfk_file_{$i}"]['name'])) { $file = new tfk_item_file(); if ($file->upload("tfk_file_{$i}")) { $file->set('item_id', $this->pid); $file->set('user_id', get_current_user_id());