1<?php 2/** 3 * Cuts out a category. 4 * 5 * This Source Code Form is subject to the terms of the Mozilla Public License, 6 * v. 2.0. If a copy of the MPL was not distributed with this file, You can 7 * obtain one at http://mozilla.org/MPL/2.0/. 8 * 9 * @package phpMyFAQ 10 * @author Thorsten Rinne <thorsten@phpmyfaq.de> 11 * @copyright 2003-2020 phpMyFAQ Team 12 * @license http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0 13 * @link https://www.phpmyfaq.de 14 * @since 2003-12-25 15 */ 16 17use phpMyFAQ\Category; 18use phpMyFAQ\Filter; 19 20if (!defined('IS_VALID_PHPMYFAQ')) { 21 http_response_code(400); 22 exit(); 23} 24 25if ($user->perm->checkRight($user->getUserId(), 'editcateg')) { 26 $category = new Category($faqConfig, [], false); 27 $category->setUser($currentAdminUser); 28 $category->setGroups($currentAdminGroups); 29 $category->buildTree(); 30 31 $id = Filter::filterInput(INPUT_GET, 'cat', FILTER_VALIDATE_INT, 0); 32 $parent_id = $category->categoryName[$id]['parent_id']; 33 $header = sprintf('%s: <em>%s</em>', $PMF_LANG['ad_categ_move'], $category->categoryName[$id]['name']); 34 ?> 35 <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom"> 36 <h1 class="h2"> 37 <i aria-hidden="true" class="fa fa-cut"></i> <?= $header ?> 38 </h1> 39 </div> 40 41 <div class="row"> 42 <div class="col-lg-12"> 43 <form action="?action=pastecategory" method="post" accept-charset="utf-8"> 44 <input type="hidden" name="cat" value="<?= $id ?>"> 45 <input type="hidden" name="csrf" value="<?= $user->getCsrfTokenFromSession() ?>"> 46 <div class="form-group row"> 47 <label class="col-lg-2 col-form-label"><?= $PMF_LANG['ad_categ_paste2'] ?></label> 48 <div class="col-lg-4"> 49 <select name="after" class="form-control"> 50<?php 51 foreach ($category->getCategoryTree() as $cat) { 52 $indent = ''; 53 for ($j = 0; $j < $cat['indent']; ++$j) { 54 $indent .= '...'; 55 } 56 if ($id != $cat['id']) { 57 printf("<option value=\"%s\">%s%s</option>\n", $cat['id'], $indent, $cat['name']); 58 } 59 } 60 61 if ($parent_id != 0) { 62 printf('<option value="0">%s</option>', $PMF_LANG['ad_categ_new_main_cat']); 63 } 64 ?> 65 </select> 66 </div> 67 </div> 68 <div class="form-group row"> 69 <div class="offset-lg-2 col-lg-4"> 70 <button class="btn btn-primary" type="submit" name="submit"> 71 <?= $PMF_LANG['ad_categ_updatecateg'] ?> 72 </button> 73 </div> 74 </div> 75 </form> 76 </div> 77 </div> 78<?php 79 80} else { 81 echo $PMF_LANG['err_NotAuth']; 82} 83