Ejemplo 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']);
 }
Ejemplo n.º 2
0
 /**
  * Load ColorizeIt handler.
  *
  * @return null
  */
 protected function load_colorizeit()
 {
     $this->colorizeit_sample->configure(TITANIA_CLR_SCREENSHOT, $this->contrib->contrib_id)->get_operator()->load();
     $this->colorizeit_sample->handle_form_action();
     if ($this->colorizeit_sample->uploaded) {
         $uploaded = $this->colorizeit_sample->get_operator()->get_all_ids();
         // If multiple files are uploaded, then one is being replaced.
         if (sizeof($uploaded) > 1) {
             $this->colorizeit_sample->get_operator()->delete(array_diff($uploaded, array($this->colorizeit_sample->uploaded)));
         }
     }
 }
Ejemplo n.º 3
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);
 }
Ejemplo n.º 4
0
 /**
  * Setup the attachments
  * Unfortunately there is not much of a good way of doing this besides
  * 	requiring extra calls to the message class (which I do not want to do)
  */
 protected function setup_attachments()
 {
     // We set it up already...
     if ($this->uploader->get_object_type() !== null) {
         return;
     }
     $for_edit = $this->post_object->generate_text_for_edit();
     if ($this->auth['attachments'] && isset($for_edit['object_type'])) {
         $this->posting_panels['attach-panel'] = 'ATTACHMENTS';
         $this->uploader->configure($for_edit['object_type'], $for_edit['object_id'], true)->get_operator()->load();
         $this->uploader->handle_form_action();
         $this->error = array_merge($this->error, $this->uploader->get_errors());
         $this->uploader->clear_errors();
         // Empty the error array to prevent showing duplicates
     }
 }