if ($_POST['status'] != $this->data->get_status()->get('action_code')) { $this->data->set_status($_POST['status']); } } else { $this->data->set('author_id', get_current_user_id()); $this->data->set('creation_date', 'NOW'); $this->pid = $this->data->insert(); $this->data->set_status($_POST['status'], null, 'creation'); } $this->data->errors['file'] = ''; $wp_upload_dir = wp_upload_dir(); $saved_files = 0; for ($i = 1; $i <= 5; $i++) { // up to 5 uploads per edit 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', 'task'); $file->save(); $saved_files++; } else { $this->data->errors['file'] .= '<p class="tfk_err">' . $file->error . '</p>'; } } // else no file, do nothing } if (isset($update_log)) { if ($saved_files) { $update_log_info[] = $saved_files . ' file(s)';
$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'); $file->save(); $this->comment->set('body', $this->comment->get('body') . '<p>' . __('Uploaded file: ', 'taskfreak') . '<a href="' . $wp_upload_dir['url'] . '/' . $file->get('file_name') . '" rel="external">' . $file->get('file_title') . '</a>' . '</p>'); $this->comment->update(); } else { $this->comment->errors['file'] .= '<p class="tfk_err">' . $file->error . '</p>'; } } // else no file, do nothing } } if (!$this->comment->errors['file']) {