1<?php
2/**
3 * @package tikiwiki
4 * Update object categories
5 */
6// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project
7//
8// All Rights Reserved. See copyright.txt for details and a complete list of authors.
9// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
10// $Id$
11
12if (basename($_SERVER['SCRIPT_NAME']) === basename(__FILE__)) {
13	die('This script may only be included.');
14}
15
16require_once('tiki-setup.php');
17
18global $prefs;
19if ($prefs['feature_categories'] == 'y' && Perms::get([ 'type' => $cat_type, 'object' => $cat_objid ])->modify_object_categories) {
20	if (isset($_REQUEST['import']) and isset($_REQUEST['categories'])) {
21		$_REQUEST["cat_categories"] = explode(',', $_REQUEST['categories']);
22		$_REQUEST["cat_categorize"] = 'on';
23	} elseif (! isset($_REQUEST["cat_categorize"]) || $_REQUEST["cat_categorize"] != 'on') {
24		$_REQUEST['cat_categories'] = null;
25	}
26	$categlib = TikiLib::lib('categ');
27	$categlib->update_object_categories(isset($_REQUEST['cat_categories']) ? $_REQUEST['cat_categories'] : [], $cat_objid, $cat_type, $cat_desc, $cat_name, $cat_href, $_REQUEST['cat_managed']);
28}
29