/** * The call for editing a package * @param string $package_name The name of the package to edit * @todo Permission validation is in place, but check that the user has permission to * edit in the first place */ public function edit($package_name) { $this->load->model('spark'); $this->load->model('contributor'); $this->load->library('form_validation'); $this->load->helper('form_helper'); $submit = $this->input->post('submit'); $spark_id = $this->input->post('spark_id'); $success = FALSE; if ($submit) { if ($this->form_validation->run('edit-package')) { $update = elements(array('name', 'summary', 'description', 'website', 'repository_type', 'base_location', 'fork_id', 'is_browse'), $_POST); Spark::update($spark_id, $update); UserHelper::setNotice("This spark has been updated. Thanks again, you're awesome."); $success = TRUE; } else { UserHelper::setNotice("Whoops, there were some errors...", FALSE); } } if ($success) { $spark = Spark::getInfo($update['name']); } else { $spark = Spark::getInfo($package_name); } if (!$spark) { show_404(); } $data = array(); $data['sparkslist'] = Spark::get_index_list(); $data['contribution'] = $spark; $this->load->view('packages/edit', $data); }