<commit_before><?php
// (c) Copyright 2002-2012 by authors of the Tiki Wiki CMS Groupware Project
// 
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$

require_once ('tiki-setup.php');
include_once ('lib/categories/categlib.php');

$access->check_feature('feature_categories');
// Check for parent category or set to 0 if not present
if (!empty($_REQUEST['parentId']) && !($info = $categlib->get_category($_REQUEST['parentId']))) {
	$smarty->assign('msg', 'Incorrect param'.' parentId');
	$smarty->display('error.tpl');
	die;
}	

if (!isset($_REQUEST['parentId'])) {
	$_REQUEST['parentId'] = 0;
}
$smarty->assign('parentId', $_REQUEST['parentId']);


if (!empty($_REQUEST['parentId'])) {
	$access->check_permission('tiki_p_admin_categories', '', 'category', $_REQUEST['parentId']);
}

if (!empty($_REQUEST['unassign'])) {
	$access->check_authenticity(tra('Are you sure you want to unassign the objects of this category: ') . $info['name']);
	$categlib->unassign_all_objects($_REQUEST['parentId']);
}
if (!empty($_REQUEST['move_to']) && !empty($_REQUEST['toId'])) {
	check_ticket('admin-categories');
	if (!$categlib->get_category($_REQUEST['toId'])) {
		$smarty->assign('msg', 'Incorrect param'.' toId');
		$smarty->display('error.tpl');
		die;
	}
	$access->check_permission('tiki_p_admin_categories', '', 'category', $_REQUEST['toId']);
	$categlib->move_all_objects($_REQUEST['parentId'], $_REQUEST['toId']);
}
if (!empty($_REQUEST['copy_from']) && !empty($_REQUEST['to'])) {
	check_ticket('admin-categories');
	if (!$categlib->get_category($_REQUEST['to'])) {
		$smarty->assign('msg', 'Incorrect param'.' fromId');
		$smarty->display('error.tpl');
		die;
	}
	$access->check_permission('tiki_p_admin_categories', '', 'category', $_REQUEST['to']);
	$categlib->assign_all_objects($_REQUEST['parentId'], $_REQUEST['to']);<commit_msg>[FIX] categ admin: check for admin permission even when parentId=0<commit_after><?php
// (c) Copyright 2002-2012 by authors of the Tiki Wiki CMS Groupware Project
// 
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$

require_once ('tiki-setup.php');
include_once ('lib/categories/categlib.php');

$access->check_feature('feature_categories');
// Check for parent category or set to 0 if not present
if (!empty($_REQUEST['parentId']) && !($info = $categlib->get_category($_REQUEST['parentId']))) {
	$smarty->assign('msg', 'Incorrect param'.' parentId');
	$smarty->display('error.tpl');
	die;
}	

if (!isset($_REQUEST['parentId'])) {
	$_REQUEST['parentId'] = 0;
}
$smarty->assign('parentId', $_REQUEST['parentId']);


$access->check_permission('tiki_p_admin_categories', '', 'category', $_REQUEST['parentId']);

if (!empty($_REQUEST['unassign'])) {
	$access->check_authenticity(tra('Are you sure you want to unassign the objects of this category: ') . $info['name']);
	$categlib->unassign_all_objects($_REQUEST['parentId']);
}
if (!empty($_REQUEST['move_to']) && !empty($_REQUEST['toId'])) {
	check_ticket('admin-categories');
	if (!$categlib->get_category($_REQUEST['toId'])) {
		$smarty->assign('msg', 'Incorrect param'.' toId');
		$smarty->display('error.tpl');
		die;
	}
	$access->check_permission('tiki_p_admin_categories', '', 'category', $_REQUEST['toId']);
	$categlib->move_all_objects($_REQUEST['parentId'], $_REQUEST['toId']);
}
if (!empty($_REQUEST['copy_from']) && !empty($_REQUEST['to'])) {
	check_ticket('admin-categories');
	if (!$categlib->get_category($_REQUEST['to'])) {
		$smarty->assign('msg', 'Incorrect param'.' fromId');
		$smarty->display('error.tpl');
		die;
	}
	$access->check_permission('tiki_p_admin_categories', '', 'category', $_REQUEST['to']);
	$categlib->assign_all_objects($_REQUEST['parentId'], $_REQUEST['to']);
{'fraction_non_alphanumeric': 0.20929641859283718, 'fraction_numerical': 0.005334010668021336, 'mean_word_length': 6.987829614604462, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5417630', 'n_tokens_mistral': 1314, 'n_tokens_neox': 1262, 'n_words': 258}