/
tiki-edit_perspective.php
113 lines (88 loc) · 3.35 KB
/
tiki-edit_perspective.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?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: tiki-edit_perspective.php 40070 2012-03-07 21:09:42Z changi67 $
$inputConfiguration = array( array(
'staticKeyFilters' => array(
'offset' => 'int',
'id' => 'int',
'name' => 'striptags',
'create' => 'alpha',
'action' => 'alpha',
'criteria' => 'striptags',
),
'staticKeyFiltersForArrays' => array(
'lm_preference' => 'word',
),
'catchAllUnset' => null,
) );
$auto_query_args = array( 'offset', 'id', 'cookietab' );
$section='admin';
require_once('tiki-setup.php');
require_once('lib/perspectivelib.php');
$access->check_feature(array('feature_perspective', 'feature_jquery_ui'));
$selectedId = 0;
if ( isset( $_REQUEST['id'] ) ) {
$selectedId = $_REQUEST['id'];
$objectperms = Perms::get(array( 'type' => 'perspective', 'object' => $_REQUEST['id'] ));
$cookietab = 3;
}
if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'remove' && $selectedId && $objectperms->perspective_admin ) {
check_ticket('remove_perspective');
$perspectivelib->remove_perspective($selectedId);
$selectedId = 0;
$cookietab = '1';
}
// Edit perspective
if ( isset( $_REQUEST['name'] ) && $selectedId && $objectperms->perspective_edit ) {
global $prefslib; require_once 'lib/prefslib.php';
$perspectivelib->replace_perspective($selectedId, $_REQUEST['name']);
$preferences = $_REQUEST['lm_preference'];
$input = $prefslib->getInput($jitRequest, $preferences, 'perspective');
$perspectivelib->replace_preferences($selectedId, $input);
$cookietab = '1';
}
// Create perspective
if ( isset( $_REQUEST['create'], $_REQUEST['name'] ) && $globalperms->create_perspective ) {
$name = trim($_REQUEST['name']);
if ( ! empty( $name ) ) {
$selectedId = $perspectivelib->replace_perspective(null, $name);
$cookietab = 3;
}
}
$maxRecords = $prefs['maxRecords'];
$offset = isset( $_REQUEST['offset'] ) ? $_REQUEST['offset'] : 0;
$smarty->assign('offset', $offset);
$smarty->assign('count', $tikilib->getOne('SELECT COUNT(*) FROM tiki_perspectives'));
$perspectives = $perspectivelib->list_perspectives($offset, $maxRecords);
if ( $selectedId ) {
$info = $perspectivelib->get_perspective($selectedId);
$smarty->assign('perspective_info', $info);
if ( isset( $_REQUEST['criteria'] ) ) {
global $prefslib; require_once 'lib/prefslib.php';
require_once 'lib/smarty_tiki/function.preference.php';
$criteria = $_REQUEST['criteria'];
$results = $prefslib->getMatchingPreferences($criteria);
$results = array_diff($results, array_keys($info['preferences']));
foreach ( $results as $name ) {
echo smarty_function_preference(array('name' => $name), $smarty);
}
exit;
}
}
$headerlib->add_cssfile('css/admin.css'); // to display the prefs properly
$headtitle = tra('Perspectives');
$description = tra('Edit Perspectives');
$crumbs[] = new Breadcrumb($headtitle, $description, '', '', '');
$headtitle = breadcrumb_buildHeadTitle($crumbs);
$smarty->assign('headtitle', $headtitle);
$smarty->assign('trail', $crumbs);
if (!isset($cookietab)) {
$cookietab = '1';
}
setcookie('tab', $cookietab);
$smarty->assign('perspectives', $perspectives);
$smarty->assign('mid', 'tiki-edit_perspective.tpl');
$smarty->display('tiki.tpl');