/** * Handle initial revision, queue, and attachment creation. * * @return array Returns array in form for array('error' => array()) * where error contains any errors found. */ protected function create() { if ($this->request->variable('disagree', false)) { // Did not agree to the agreement. redirect($this->contrib->get_url()); } // Handle upload $this->uploader->handle_form_action(); if ($this->uploader->uploaded) { $uploaded = $this->uploader->get_operator()->get_all_ids(); // If multiple files are uploaded, then one is being replaced. if (sizeof($uploaded) > 1) { $this->uploader->get_operator()->delete(array_diff($uploaded, array($this->uploader->uploaded))); } $this->attachment = $this->uploader->get_uploaded_attachment(); } if ($this->uploader->plupload_active()) { return array('response' => new JsonResponse($this->uploader->get_plupload_response_data())); } else { if ($this->request->is_set('attachment_data')) { $data = $this->uploader->get_filtered_request_data(); if (!empty($data)) { $attachment = array_shift($data); $this->load_attachment($attachment['attach_id']); } } } $settings = array('version' => $this->request->variable('revision_version', '', true), 'name' => $this->request->variable('revision_name', '', true), 'allow_repack' => $this->request->variable('queue_allow_repack', 0), 'license' => $this->request->variable('revision_license', '', true), 'custom' => $this->request->variable('custom_fields', array('' => ''), true), 'vendor_versions' => $this->get_selected_branches(), 'test_account' => $this->request->variable('revision_test_account', '', true)); if ($this->has_custom_license($settings['license'])) { $settings['license'] = $this->request->variable('revision_custom_license', '', true); } // Check for errors $error = array_merge($this->uploader->get_errors(), $this->validate_settings($settings)); if (empty($error)) { $this->create_revision($settings); // Add queue values to the queue table if ($this->use_queue) { $this->create_queue_item($settings['allow_repack'], $settings['test_account']); // Subscribe author to queue discussion topic if ($this->request->variable('subscribe_author', false)) { $this->subscriptions->subscribe(TITANIA_TOPIC, $this->queue->queue_discussion_topic_id); } } if ($this->attachment) { $this->set_package_paths(); } $error = $this->clean_package(); } return array('error' => $error); }