Exemplo n.º 1
0
 /**
  * Edit revision action.
  *
  * @param string $contrib_type		Contrib type URL identifier
  * @param string $contrib			Contrib name clean
  * @param int $id					Revision id
  *
  * @return \Symfony\Component\HttpFoundation\Response|JsonResponse
  */
 public function edit($contrib_type, $contrib, $id)
 {
     $this->setup($contrib_type, $contrib);
     if (!$this->check_auth()) {
         return $this->helper->needs_auth();
     }
     $this->load_revision($id);
     $this->vendor_versions = $this->cache->get_phpbb_versions();
     $this->handle_revision_delete();
     // Translations
     $this->translations->configure(TITANIA_TRANSLATION, $this->id, true);
     if ($this->contrib->type->extra_upload) {
         $this->translations->get_operator()->load();
         $this->translations->handle_form_action();
         $this->handle_translation_delete();
         if ($this->translations->plupload_active()) {
             return new JsonResponse($this->translations->get_plupload_response_data());
         }
     }
     $settings = $this->get_settings();
     $error = array();
     // Submit the revision
     if ($this->request->is_set_post('submit')) {
         $error = array_merge($this->validate_settings($settings), $this->translations->get_errors());
         // If no errors, submit
         if (empty($error)) {
             $this->submit_settings($settings);
             redirect($this->contrib->get_url());
         }
     }
     $this->assign_vars($settings, $error);
     add_form_key('postform');
     return $this->helper->render('contributions/contribution_revision_edit.html', $this->contrib->contrib_name . ' - ' . $this->user->lang['EDIT_REVISION']);
 }
Exemplo n.º 2
0
 /**
  * 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);
 }
Exemplo n.º 3
0
 /**
  * Manage contribution.
  *
  * @param string $contrib_type		Contrib type URL identifier.
  * @param string $contrib			Contrib name clean.
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function manage($contrib_type, $contrib)
 {
     $this->setup($contrib_type, $contrib);
     if (!$this->check_auth()) {
         return $this->helper->needs_auth();
     }
     $this->load_screenshot();
     if ($this->screenshots->plupload_active()) {
         return new JsonResponse($this->screenshots->get_plupload_response_data());
     }
     if (confirm_box(true) && $this->check_auth('change_author')) {
         $this->change_author();
     }
     $old_settings = $this->contrib->__get_array();
     $old_settings['categories'] = array_keys($this->contrib->category_data);
     $this->settings = array('permalink' => $this->request->variable('permalink', $this->contrib->contrib_name_clean, true), 'status' => $this->request->variable('contrib_status', (int) $this->contrib->contrib_status), 'categories' => $old_settings['categories'], 'demo' => array(), 'coauthors' => array('active' => $this->request->variable('active_coauthors', '', true), 'nonactive' => $this->request->variable('nonactive_coauthors', '', true)), 'new_author' => $this->request->variable('change_owner', '', true), 'limited_support' => $this->contrib->contrib_limited_support);
     $this->settings['custom'] = $this->contrib->get_custom_fields();
     foreach ($this->contrib->type->get_allowed_branches(true) as $branch => $name) {
         $this->settings['demo'][$branch] = $this->contrib->get_demo_url($branch);
     }
     $this->load_message();
     $submit = $this->request->is_set_post('submit');
     $preview = $this->request->is_set_post('preview');
     $error = $this->screenshots->get_errors();
     if ($preview || $submit || $this->screenshots->uploaded) {
         $this->settings = array_merge($this->settings, array('categories' => $this->request->variable('contrib_category', array(0 => 0)), 'custom' => $this->request->variable('custom_fields', array('' => ''), true), 'limited_support' => $this->request->is_set('limited_support')));
         $demos = $this->request->variable('demo', array(0 => ''));
         foreach ($this->contrib->type->get_allowed_branches(true) as $branch => $name) {
             if (isset($demos[$branch])) {
                 $this->settings['demo'][$branch] = $demos[$branch];
             }
         }
         $this->contrib->post_data($this->message);
         $this->contrib->__set_array(array('contrib_demo' => $this->can_edit_demo ? json_encode($this->settings['demo']) : $this->contrib->contrib_demo, 'contrib_limited_support' => $this->settings['limited_support']));
     }
     // ColorizeIt sample
     if ($this->use_colorizeit) {
         $this->load_colorizeit();
         $error = array_merge($error, $this->colorizeit_sample->get_errors());
         if ($this->colorizeit_sample->uploaded) {
             $this->contrib->post_data($this->message);
         }
     }
     $this->handle_screenshot_action();
     if ($preview) {
         $this->preview();
     } else {
         if ($submit) {
             if (($form_key_error = $this->message->validate_form_key()) !== false) {
                 $error[] = $form_key_error;
             } else {
                 if ($this->request->is_set_post('delete') && $this->check_auth('delete')) {
                     // Handle the deletion routine
                     $this->contrib->delete();
                     redirect($this->helper->route('phpbb.titania.index'));
                 }
             }
             $this->contrib->post_data($this->message);
             $authors = $this->contrib->get_authors_from_usernames(array('active_coauthors' => $this->settings['coauthors']['active'], 'nonactive_coauthors' => $this->settings['coauthors']['nonactive'], 'new_author' => $this->settings['new_author']));
             $author_username = \users_overlord::get_user($this->contrib->contrib_user_id, 'username', true);
             $authors['author'] = array($author_username => $this->contrib->contrib_user_id);
             $error = array_merge($error, $this->contrib->validate($this->settings['categories'], $authors, $this->settings['custom'], $this->contrib->contrib_name_clean));
             // Did we succeed or have an error?
             if (empty($error)) {
                 $this->submit($authors, $old_settings);
             }
         }
     }
     $this->assign_vars($error);
     return $this->helper->render('contributions/contribution_manage.html', $this->contrib->contrib_name . ' - ' . $this->user->lang['MANAGE_CONTRIBUTION']);
 }
Exemplo n.º 4
0
 /**
  * Get response data to return to Plupload.
  *
  * @return array
  */
 public function get_plupload_response_data()
 {
     return $this->uploader->get_plupload_response_data();
 }