Esempio n. 1
0
                    $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)';
            }
            if (!empty($update_log_info)) {
                $update_log->set('info', implode(',', $update_log_info));
                $update_log->save();
            }
        }
        if (!$this->data->errors['file']) {
            if (headers_sent()) {
                $this->data->load();
                $this->data->errors['global_errors'] = '<p class="tfk_ok">' . __('Changes saved.', 'taskfreak') . '</p>';
            } else {
                wp_redirect(remove_query_arg(array('edit', 'noheader'), add_query_arg('view', $this->pid) . "#tfk_task_title"));
                exit;
            }
        }
    }
} elseif (preg_match('/noheader=1/', $_SERVER['REQUEST_URI'])) {
    echo '<p class="tfk_err">' . __('Upload failed. Check file size.', 'taskfreak') . '</p>';
    return;
Esempio n. 2
0
 $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');
                     $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 {