/** * Display new contribution page. * * @return \Symfony\Component\HttpFoundation\Response */ protected function create() { if (!$this->is_owner && !$this->auth->acl_get('u_titania_contrib_submit')) { return $this->helper->needs_auth(); } $this->user->add_lang_ext('phpbb/titania', 'contributions'); $contrib = new \titania_contribution(); $contrib->contrib_user_id = $this->user->data['user_id']; $contrib->author = $this->author; $contrib->get_options(); // Set some main vars up $message = $this->setup_message($contrib); $submit = $this->request->is_set_post('submit'); $preview = $this->request->is_set_post('preview'); $error = array(); $settings = array('type' => $this->request->variable('contrib_type', 0), 'permalink' => $this->request->variable('permalink', '', true), 'categories' => $this->request->variable('contrib_category', array(0)), 'coauthors' => array('active' => $this->request->variable('active_coauthors', '', true), 'nonactive' => $this->request->variable('nonactive_coauthors', '', true)), 'custom' => $this->request->variable('custom_fields', array('' => ''), true)); if ($preview || $submit) { $contrib->post_data($message); $contrib->__set_array(array('contrib_type' => $settings['type'], 'contrib_name_clean' => $settings['permalink'], 'contrib_visible' => 1)); } if ($preview) { $message->preview(); } else { if ($submit) { $authors = $contrib->get_authors_from_usernames(array('active_coauthors' => $settings['coauthors']['active'], 'nonactive_coauthors' => $settings['coauthors']['nonactive'])); $authors['author'] = array($this->user->data['username'] => $this->user->data['user_id']); $error = $contrib->validate($settings['categories'], $authors, $settings['custom']); if (($form_key_error = $message->validate_form_key()) !== false) { $error[] = $form_key_error; } if (empty($error)) { $contrib->set_type($contrib->contrib_type); $contrib->set_custom_fields($settings['custom']); $contrib->contrib_categories = implode(',', $settings['categories']); $contrib->contrib_creation_time = time(); $contrib->submit(); $contrib->set_coauthors($authors['active_coauthors'], $authors['nonactive_coauthors'], true); // Create relations $contrib->put_contrib_in_categories($settings['categories']); if ($this->ext_config->support_in_titania) { $active_authors = array_merge($authors['author'], $authors['active_coauthors']); foreach ($active_authors as $author) { $this->subscriptions->subscribe(TITANIA_SUPPORT, $contrib->contrib_id, $author); } } redirect($contrib->get_url('revision')); } } } // Generate some stuff $this->display->generate_type_select($contrib->contrib_type); $this->display->generate_category_select($settings['categories']); $contrib->assign_details(); $message->display(); foreach ($this->types->get_all() as $type) { $this->display->generate_custom_fields($type->contribution_fields, $settings['custom'], $type->id); } $this->template->assign_vars(array('S_POST_ACTION' => $this->author->get_url('create'), 'S_CREATE' => true, 'S_CAN_EDIT_CONTRIB' => $this->auth->acl_get('u_titania_contrib_submit'), 'CONTRIB_PERMALINK' => $settings['permalink'], 'ERROR_MSG' => !empty($error) ? implode('<br />', $error) : false, 'ACTIVE_COAUTHORS' => $settings['coauthors']['active'], 'NONACTIVE_COAUTHORS' => $settings['coauthors']['nonactive'])); return $this->helper->render('contributions/contribution_manage.html', 'NEW_CONTRIBUTION'); }
/** * Display search page for contributions. * * @return \Symfony\Component\HttpFoundation\Response */ public function contributions() { $this->setup(); $this->user->add_lang_ext('phpbb/titania', 'contributions'); $this->display->generate_category_select(false, false, false); // Display the list of phpBB versions available foreach ($this->cache->get_phpbb_versions() as $version => $name) { $this->template->assign_block_vars('phpbb_versions', array('VERSION' => $name)); } $this->template->assign_vars(array('S_SEARCH_ACTION' => $this->helper->route('phpbb.titania.search.contributions.results'))); $this->display->assign_global_vars(); return $this->helper->render('find_contribution.html', $this->user->lang['SEARCH']); }