/** * set task status * @param number $status status code * @param number $uid (optional) id of the user setting the status * @param string $info (optional) may contain "creation" for example * @return boolean */ public function set_status($status, $uid = null, $info = null) { if (is_null($uid)) { $uid = get_current_user_id(); } $obj = new tfk_item_status(); $obj->set('item_id', $this->get_uid()); $obj->set('log_date', 'NOW'); $obj->set('action_code', $status); $obj->set_object('user', $uid); if (!is_null($info)) { $obj->set('info', $info); } return $obj->insert('ignore'); }
$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'; } }
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()); $file->set('file_tags', 'comment');