/** * Delete category. * * @return null */ protected function delete() { $parent_id = $this->category->parent_id == $this->category->category_id ? self::ROOT_CATEGORY : $this->category->parent_id; $error = array(); if ($this->request->is_set_post('submit')) { if (check_form_key('category_move')) { $action_contribs = $this->request->variable('action_contribs', ''); $contribs_to_id = $this->request->variable('contribs_to_id', 0); // Check for errors $sql = 'SELECT category_id FROM ' . TITANIA_CATEGORIES_TABLE . "\n\t\t\t\t\tWHERE parent_id = {$this->category->category_id}"; $result = $this->db->sql_query($sql); $children_row = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); // Check if category contains subcategories. If yes, then return an error. if ($children_row) { $error[] = $this->user->lang['CATEGORY_HAS_CHILDREN']; } else { if ($action_contribs == 'move' && !empty($contribs_to_id)) { $error = array_merge($error, $this->category->move_category_content($contribs_to_id, $this->sync)); } } } else { $error[] = $this->user->lang['FORM_INVALID']; } if (empty($error)) { // Delete category $this->category->delete($this->sync); // Redirect back to the parent category redirect($this->helper->route('phpbb.titania.manage.categories', array('id' => $parent_id))); } } add_form_key('category_move'); $this->template->assign_vars(array('S_DELETE_CATEGORY' => true, 'U_ACTION' => $this->category->get_manage_url('delete'), 'U_BACK' => $this->helper->route('phpbb.titania.manage.categories', array('id' => $parent_id)), 'CATEGORY' => $this->category->category_id, 'CATEGORY_NAME' => $this->category->get_name(), 'SECTION_NAME' => $this->user->lang['DELETE_CATEGORY'] . ' - ' . $this->category->get_name(), 'S_HAS_SUBCATS' => $this->category->right_id - $this->category->left_id > 1, 'S_MOVE_CATEGORY_OPTIONS' => generate_category_select($this->category->parent_id, true), 'ERROR_MSG' => !empty($error) ? implode('<br />', $error) : '')); }
$result = phpbb::$db->sql_query($sql); while ($row = phpbb::$db->sql_fetchrow($result)) { $contrib_categories[] = $row['category_id']; } phpbb::$db->sql_freeresult($result); $active_coauthors = $nonactive_coauthors = array(); foreach (titania::$contrib->coauthors as $row) { // User does not exist anymore... if (users_overlord::get_user($row['user_id'], 'user_id') != $row['user_id']) { continue; } if ($row['active']) { $active_coauthors[] = users_overlord::get_user($row['user_id'], 'username'); } else { $nonactive_coauthors[] = users_overlord::get_user($row['user_id'], 'username'); } } $active_coauthors = implode("\n", $active_coauthors); $nonactive_coauthors = implode("\n", $nonactive_coauthors); } } // Generate some stuff generate_category_select($contrib_categories); titania::$contrib->assign_details(); $message->display(); foreach ($status_list as $status => $row) { phpbb::$template->assign_block_vars('status_select', array('S_SELECTED' => $status == titania::$contrib->contrib_status ? true : false, 'VALUE' => $status, 'NAME' => phpbb::$user->lang[$row])); } phpbb::$template->assign_vars(array('S_POST_ACTION' => titania::$contrib->get_url('manage'), 'S_EDIT_SUBJECT' => titania_types::$types[titania::$contrib->contrib_type]->acl_get('moderate') ? true : false, 'S_DELETE_CONTRIBUTION' => phpbb::$auth->acl_get('u_titania_admin') ? true : false, 'S_IS_OWNER' => titania::$contrib->is_author ? true : false, 'S_IS_MODERATOR' => titania_types::$types[titania::$contrib->contrib_type]->acl_get('moderate') ? true : false, 'S_CAN_EDIT_STYLE_DEMO' => titania::$config->can_modify_style_demo_url || titania_types::$types[TITANIA_TYPE_STYLE]->acl_get('moderate') || titania::$contrib->contrib_type != TITANIA_TYPE_STYLE ? true : false, 'CONTRIB_PERMALINK' => $permalink, 'SCREENSHOT_UPLOADER' => $screenshot->parse_uploader('posting/attachments/simple.html'), 'ERROR_MSG' => sizeof($error) ? implode('<br />', $error) : false, 'ACTIVE_COAUTHORS' => $active_coauthors, 'NONACTIVE_COAUTHORS' => $nonactive_coauthors, 'S_TRANSLATION_TYPE_ID' => defined('TITANIA_TYPE_TRANSLATION') ? TITANIA_TYPE_TRANSLATION : 0)); titania::page_header(titania::$contrib->contrib_name . ' - ' . phpbb::$user->lang['MANAGE_CONTRIBUTION']); titania::page_footer(true, 'contributions/contribution_manage.html');
function pva_generate_category_select() { titania::_include('functions_posting', 'generate_category_select'); phpbb::$template->destroy_block_vars('category_select'); generate_category_select(); phpbb::$template->set_filenames(array('generate_category_select' => 'manage/generate_category_select.html')); $select = phpbb::$template->assign_display('generate_category_select'); return $select; }
$search_fields = request_var('sf', ''); $search_type = request_var('type', 0); $categories = request_var('c', array(0)); $search_subcategories = request_var('sc', 0); $phpbb_versions = request_var('versions', array('')); // Display the advanced search page if (!$keywords && !$user_id && !$contrib_id && !isset($_POST['submit'])) { if ($mode == 'find-contribution') { titania::_include('functions_posting', 'generate_category_select'); titania::add_lang('contributions'); phpbb::$template->assign_vars(array('S_SEARCH_ACTION' => titania_url::build_url('find-contribution'))); // Display the list of phpBB versions available foreach (titania::$cache->get_phpbb_versions() as $version => $name) { $template->assign_block_vars('phpbb_versions', array('VERSION' => $name)); } generate_category_select($categories, false, false); titania::page_header('SEARCH'); titania::page_footer(true, 'find_contribution.html'); } // Output search types foreach ($search_types as $value => $name) { phpbb::$template->assign_block_vars('types', array('NAME' => isset(phpbb::$user->lang[$name]) ? phpbb::$user->lang[$name] : $name, 'VALUE' => $value)); } phpbb::$template->assign_vars(array('S_SEARCH_ACTION' => titania_url::build_url('search'))); titania::page_header('SEARCH'); titania::page_footer(true, 'search_body.html'); } // Add some POST stuff to the url if (isset($_POST['submit'])) { $author = utf8_normalize_nfc(request_var('author', '', true)); if ($author) {
// Check if category contains subcategories. If yes, then return an error. if ($children_row) { $error[] = phpbb::$user->lang['CATEGORY_HAS_CHILDREN']; } else { if ($action_contribs == 'move' && !empty($contribs_to_id)) { $error = array_merge($error, $category_object->move_category_content($contribs_to_id)); } } if (!sizeof($error)) { // Delete category $category_object->delete(); // Redirect back to the previous category redirect(titania_url::build_url('manage/categories', array('c' => $parent_id))); } } phpbb::$template->assign_vars(array('S_DELETE_CATEGORY' => true, 'U_ACTION' => titania_url::build_url('manage/categories', array('c' => $category_id, 'action' => 'delete')), 'U_BACK' => 'c_' . $category_object->parent_id, 'CATEGORY' => $category_id, 'CATEGORY_NAME' => isset(phpbb::$user->lang[$category_object->category_name]) ? phpbb::$user->lang[$category_object->category_name] : $category_object->category_name, 'SECTION_NAME' => phpbb::$user->lang['DELETE_CATEGORY'] . ' - ' . (isset(phpbb::$user->lang[$category_object->category_name]) ? phpbb::$user->lang[$category_object->category_name] : $category_object->category_name), 'S_HAS_SUBCATS' => $category_object->right_id - $category_object->left_id > 1 ? true : false, 'S_MOVE_CATEGORY_OPTIONS' => generate_category_select($category_object->parent_id, true), 'ERROR_MSG' => sizeof($error) ? implode('<br />', $error) : '')); break; default: titania::_include('functions_display', 'titania_display_categories'); titania_display_categories($category_id, 'categories', true); if ($category_id != 0) { // Breadcrumbs $category_object = new titania_category(); $categories_ary = titania::$cache->get_categories(); // Parents foreach (array_reverse(titania::$cache->get_category_parents($category_id)) as $row) { $category_object->__set_array($categories_ary[$row['category_id']]); titania::generate_breadcrumbs(array(isset(phpbb::$user->lang[$categories_ary[$row['category_id']]['category_name']]) ? phpbb::$user->lang[$categories_ary[$row['category_id']]['category_name']] : $categories_ary[$row['category_id']]['category_name'] => titania_url::build_url('manage/categories', array('c' => $row['category_id'])))); } // Self $category_object->__set_array($categories_ary[$category_id]);