tiki-directory_admin_related.php 2.93 KB
Newer Older
lrargerich's avatar
lrargerich committed
1
<?php
2
// (c) Copyright 2002-2011 by authors of the Tiki Wiki CMS Groupware Project
3
// 
4 5
// 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.
6
// $Id$
changi67's avatar
changi67 committed
7

8 9
require_once ('tiki-setup.php');
include_once ('lib/directory/dirlib.php');
10 11
$access->check_feature('feature_directory');
$access->check_permission('tiki_p_admin_directory_cats');
12
// If no parent category then the parent category is 0
13
if (!isset($_REQUEST["parent"])) $_REQUEST["parent"] = 0;
14 15 16
$smarty->assign('parent', $_REQUEST["parent"]);
if ($_REQUEST["parent"] == 0) {
	$parent_name = 'Top';
17
} else {
18 19
	$parent_info = $dirlib->dir_get_category($_REQUEST['parent']);
	$parent_name = $parent_info['name'];
20
}
21
$smarty->assign('parent_name', $parent_name);
22 23
// Now get the path to the parent category
$path = $dirlib->dir_get_category_path_admin($_REQUEST["parent"]);
24
$smarty->assign_by_ref('path', $path);
25
// Remove a relationship
26
if (isset($_REQUEST["remove"])) {
27 28
	$access->check_authenticity();
	$dirlib->dir_remove_related($_REQUEST["parent"], $_REQUEST["categId"]);
29 30
}
// Update a relationship
31
if (isset($_REQUEST["update"])) {
32
	check_ticket('dir-admin-related');
33 34
	$dirlib->dir_remove_related($_REQUEST["parent"], $_REQUEST["oldcategId"]);
	$dirlib->dir_add_categ_rel($_REQUEST["parent"], $_REQUEST["categId"]);
35 36
}
// Add a relationship
37
if (isset($_REQUEST["add"])) {
38
	check_ticket('dir-admin-related');
39 40 41 42 43
	$dirlib->dir_add_categ_rel($_REQUEST["parent"], $_REQUEST["categId"]);
	if (isset($_REQUEST["mutual"]) && $_REQUEST["mutual"] == 'on') {
		$dirlib->dir_add_categ_rel($_REQUEST["categId"], $_REQUEST["parent"]);
	}
}
44 45
// Listing: categories in the parent category
// Pagination resolution
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
if (!isset($_REQUEST["sort_mode"])) {
	$sort_mode = 'created_desc';
} else {
	$sort_mode = $_REQUEST["sort_mode"];
}
if (!isset($_REQUEST["offset"])) {
	$offset = 0;
} else {
	$offset = $_REQUEST["offset"];
}
if (isset($_REQUEST["find"])) {
	$find = $_REQUEST["find"];
} else {
	$find = '';
}
$smarty->assign_by_ref('offset', $offset);
$smarty->assign_by_ref('sort_mode', $sort_mode);
$smarty->assign('find', $find);
64
$items = $dirlib->dir_list_related_categories($_REQUEST["parent"], $offset, $maxRecords, $sort_mode, $find);
65
$smarty->assign_by_ref('cant_pages', $items["cant"]);
66
$smarty->assign_by_ref('items', $items["data"]);
redflo's avatar
fix  
redflo committed
67
$categs = $dirlib->dir_get_all_categories_np(0, -1, 'name_asc', $find, $_REQUEST["parent"]);
68
$smarty->assign('categs', $categs);
redflo's avatar
fix  
redflo committed
69
$all_categs = $dirlib->dir_get_all_categories(0, -1, 'name_asc', $find);
70
$smarty->assign('all_categs', $all_categs);
71
// This page should be displayed with Directory section options
72 73
$section = 'directory';
include_once ('tiki-section_options.php');
74
ask_ticket('dir-admin-related');
75 76
// disallow robots to index page:
$smarty->assign('metatag_robots', 'NOINDEX, NOFOLLOW');
lrargerich's avatar
lrargerich committed
77
// Display the template
78
$smarty->assign('mid', 'tiki-directory_admin_related.tpl');
79
$smarty->display("tiki.tpl");