1<?php
2/**
3 * @package tikiwiki
4 */
5// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project
6//
7// All Rights Reserved. See copyright.txt for details and a complete list of authors.
8// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
9// $Id$
10
11require_once('tiki-setup.php');
12$adminlib = TikiLib::lib('admin');
13
14$access->check_permission('tiki_p_admin');
15
16if (! isset($_REQUEST["dsnId"])) {
17	$_REQUEST["dsnId"] = 0;
18}
19$smarty->assign('dsnId', $_REQUEST["dsnId"]);
20if ($_REQUEST["dsnId"]) {
21	$info = $adminlib->get_dsn($_REQUEST["dsnId"]);
22} else {
23	$info = [];
24	$info["dsn"] = '';
25	$info['name'] = '';
26}
27$smarty->assign('info', $info);
28if (isset($_REQUEST["remove"]) && $access->checkCsrfForm(tr('Remove DSN?'))) {
29	$result = $adminlib->remove_dsn($_REQUEST["remove"]);
30	if ($result && $result->numRows()) {
31		Feedback::success(tr('DSN removed'));
32	} else {
33		Feedback::error(tr('DSN not removed'));
34	}
35}
36if (isset($_REQUEST["save"]) && $access->checkCsrf()) {
37	$result = $adminlib->replace_dsn($_REQUEST["dsnId"], $_REQUEST["dsn"], $_REQUEST['name']);
38	if ($result && $result->numRows()) {
39		Feedback::success(tr('DSN created or modified'));
40	} else {
41		Feedback::error(tr('DSN not created or modified'));
42	}
43	$info = [];
44	$info["dsn"] = '';
45	$info['name'] = '';
46	$smarty->assign('info', $info);
47	$smarty->assign('name', '');
48	$smarty->assign('dsnId', '');
49}
50if (! isset($_REQUEST["sort_mode"])) {
51	$sort_mode = 'dsnId_desc';
52} else {
53	$sort_mode = $_REQUEST["sort_mode"];
54}
55if (! isset($_REQUEST["offset"])) {
56	$offset = 0;
57} else {
58	$offset = $_REQUEST["offset"];
59}
60$smarty->assign_by_ref('offset', $offset);
61if (isset($_REQUEST["find"])) {
62	$find = $_REQUEST["find"];
63} else {
64	$find = '';
65}
66$smarty->assign('find', $find);
67$smarty->assign_by_ref('sort_mode', $sort_mode);
68$channels = $adminlib->list_dsn($offset, $maxRecords, $sort_mode, $find);
69$smarty->assign_by_ref('cant_pages', $channels["cant"]);
70$smarty->assign_by_ref('channels', $channels["data"]);
71// disallow robots to index page:
72$smarty->assign('metatag_robots', 'NOINDEX, NOFOLLOW');
73// Display the template
74$smarty->assign('mid', 'tiki-admin_dsn.tpl');
75$smarty->display("tiki.tpl");
76