/** * New revision submission action. * * @param string $contrib_type Contrib type URL identifier. * @param string $contrib Contrib name clean. * * @return \Symfony\Component\HttpFoundation\Response */ public function add($contrib_type, $contrib) { $this->setup($contrib_type, $contrib); if (!$this->check_auth()) { return $this->helper->needs_auth(); } $this->revisions_in_queue = $this->contrib->in_queue(); $allowed_branches = $this->get_allowed_branches(); if (empty($allowed_branches)) { return $this->helper->error('REVISION_IN_QUEUE'); } if ($this->use_queue) { $this->queue = new \titania_queue(); $message = $this->get_message(); $message->display(); } $error = array(); if ($this->request->is_set_post('new_revision')) { $result = $this->process_steps(); if ($result['complete']) { $this->submit(); if ($this->use_queue) { // Subscriptions $this->queue = $this->revision->get_queue(); $email_vars = array('NAME' => $this->user->lang['VALIDATION'] . ' - ' . $this->contrib->contrib_name . ' - ' . $this->revision->revision_version, 'U_VIEW' => $this->queue->get_url()); $this->subscriptions->send_notifications(TITANIA_QUEUE, $this->contrib->contrib_type, 'subscribe_notify_forum', $email_vars, $this->user->data['user_id']); } redirect($this->contrib->get_url()); } else { if (isset($result['response'])) { return $result['response']; } } $error = $result['error']; } else { if ($this->request->is_set_post('cancel')) { $this->cancel(); } } $this->assign_common_vars($error, !empty($this->id)); $this->template->assign_vars(array('S_CAN_SUBSCRIBE' => !$this->is_author_subscribed() && $this->use_queue, 'SUBSCRIBE_AUTHOR' => $this->request->variable('subscribe_author', false), 'S_POST_ACTION' => $this->contrib->get_url('revision'))); add_form_key('postform'); return $this->helper->render('contributions/contribution_revision.html', $this->contrib->contrib_name . ' - ' . $this->user->lang['NEW_REVISION']); }
/** * Common approval/denial message handler. * * @param string $action Action: approve|deny * @return bool Returns true if message was submmited properly. */ protected function validate($action) { $this->queue->message_fields_prefix = 'message_validation'; $message = $this->get_message($this->queue); $error = array(); if ($message->submit_check()) { // Check form key if (($form_key_error = $message->validate_form_key()) !== false) { $error[] = $form_key_error; } if (empty($error)) { return true; } } $message->display(); $this->contrib->type->display_validation_options($action, $this->request, $this->template); $this->display_topic_review(); $this->template->assign_vars(array('ERROR' => implode('<br />', $error), 'L_TOPIC_REVIEW' => $this->user->lang['QUEUE_REVIEW'], 'TOPIC_TITLE' => $this->contrib->contrib_name, 'PAGE_TITLE_EXPLAIN' => $this->user->lang[strtoupper($action) . '_QUEUE_CONFIRM'], 'S_CONFIRM_ACTION' => $this->queue->get_url($action))); return false; }