public function add() { $user = User_Model::current(); if ($post = $this->input->post('project')) { if (!$user->loaded) { return $this->template->content = 'You need to be logged in'; } $project = ORM::factory('project'); $validation = Projects_utils::projects_add_validation($post); if (!$project->validate($validation, true)) { return $this->template->content = Kohana::debug($validation->errors()); } $post_user_data = $this->input->post('user'); if (empty($post_user_data['role'])) { return $this->template->content = 'What was your role?!'; } $project->add_user_roles(array($user->id => $post_user_data['role'])); if (!empty($_FILES)) { $image_file = $_FILES['screenshot']; if (!$image_file['error']) { $image = new Image($image_file['tmp_name']); if ($image->width > 547) { $image->resize(547, null); } $image->save(DOCROOT . '/media/project-images/' . $project->id . '.jpg'); } $image_file = $_FILES['logo']; if (!$image_file['error']) { $image = new Image($image_file['tmp_name']); if ($image->width > 60) { $image->resize(90, 90, Image::AUTO); } $image->crop(60, 60, 'center')->save(DOCROOT . '/media/project-images/' . $project->id . '-tiny.jpg'); } } return url::redirect($project->local_url); } else { HTMLPage::add_style('forms'); $this->template->content = new View('projects/add'); $this->template->content->project_types = Projects_utils::get_project_types_dropdown_array(); $this->template->content->user = $user; } }