/
wikiadmin.php
176 lines (157 loc) · 7.05 KB
/
wikiadmin.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<?php // -*-php-*- $Id: wikiadmin.php 7669 2010-09-02 19:40:52Z vargenau $
/*
* Copyright (C) 2009 Alain Peyrat, Alcatel-Lucent
* Copyright (C) 2009-2010 Marc-Etienne Vargenau, Alcatel-Lucent
*
* This file is part of PhpWiki.
*
* PhpWiki is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* PhpWiki is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PhpWiki; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* Standard Alcatel-Lucent disclaimer for contributing to open source
*
* "The Wiki Configurator ("Contribution") has not been tested and/or
* validated for release as or in products, combinations with products or
* other commercial use. Any use of the Contribution is entirely made at
* the user's own responsibility and the user can not rely on any features,
* functionalities or performances Alcatel-Lucent has attributed to the
* Contribution.
*
* THE CONTRIBUTION BY ALCATEL-LUCENT IS PROVIDED AS IS, WITHOUT WARRANTY
* OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, COMPLIANCE,
* NON-INTERFERENCE AND/OR INTERWORKING WITH THE SOFTWARE TO WHICH THE
* CONTRIBUTION HAS BEEN MADE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* ALCATEL-LUCENT BE LIABLE FOR ANY DAMAGES OR OTHER LIABLITY, WHETHER IN
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* CONTRIBUTION OR THE USE OR OTHER DEALINGS IN THE CONTRIBUTION, WHETHER
* TOGETHER WITH THE SOFTWARE TO WHICH THE CONTRIBUTION RELATES OR ON A STAND
* ALONE BASIS."
*/
require_once dirname(__FILE__)."/../../env.inc.php";
require_once $gfcommon.'include/pre.php';
require_once forge_get_config('plugins_path').'wiki/common/WikiPlugin.class.php';
require_once forge_get_config('plugins_path').'wiki/common/wikiconfig.class.php';
// the header that displays for the user portion of the plugin
function wiki_Project_Header($params) {
global $id;
$params['toptab']='wiki';
$params['group']=$id;
/*
Show horizontal links
*/
site_project_header($params);
}
$user = session_get_user(); // get the session user
if (!$user || !is_object($user) || $user->isError() || !$user->isActive()) {
exit_error("Invalid User", "Cannot Process your request for this user.");
}
$type = getStringFromRequest('type');
$id = getIntFromRequest('id');
$pluginname = 'wiki';
$config = getArrayFromRequest('config');
if (!$type) {
exit_error("Cannot Process your request","No TYPE specified");
} elseif (!$id) {
exit_error("Cannot Process your request","No ID specified");
} else {
if ($type == 'admin_post') {
$group = group_get_object($id);
if ( !$group) {
exit_error(_('Invalid Project'), _('Inexistent Project'));
}
if (!($group->usesPlugin($pluginname))) { //check if the group has the wiki plugin active
exit_error("Error", "First activate the $pluginname plugin through the Project's Admin Interface");
}
$userperm = $group->getPermission($user); //we'll check if the user belongs to the group
if ( !$userperm->IsMember()) {
exit_error(_('Access Denied'), _('You are not a member of this project'));
}
//only project admin can access here
if ( $userperm->isAdmin() ) {
$wc = new WikiConfig($id);
foreach ($wc->getWikiConfigNames() as $c) {
if ( ! array_key_exists($c, $config)) {
$config[$c] = 0;
}
}
foreach ($config as $config_name => $config_value) {
$r = $wc->updateWikiConfig($config_name, $config_value);
if (!$r) exit_error("Error", $wc->getErrorMessage());
}
$type = 'admin';
$feedback = _('Configuration saved.');
} else {
exit_error(_('Access Denied'), _('You are not a project Admin'));
}
}
if ($type == 'admin') {
$group = group_get_object($id);
if ( !$group) {
exit_error(_('Invalid Project'), _('Inexistent Project'));
}
if ( ! ($group->usesPlugin ($pluginname)) ) {//check if the group has the plugin active
exit_error("Error", "First activate the $pluginname plugin through the Project's Admin Interface");
}
$userperm = $group->getPermission($user); //we'll check if the user belongs to the group
if ( !$userperm->IsMember()) {
exit_error(_('Access Denied'), _('You are not a member of this project'));
}
//only project admin can access here
if ( $userperm->isAdmin() ) {
wiki_Project_Header(array('title'=>"Configuration for your project's Wiki",'pagename'=>"$pluginname",'sectionvals'=>array(group_getname($id))));
$wc = new WikiConfig($id);
print "\n<h1>"._("Configuration for your project's Wiki")."</h1>\n";
print "<table>\n";
print "<tr>\n";
print "<td>\n";
print "<fieldset>\n";
print "<legend>"._('Wiki Configuration')."</legend>\n";
print "<form action=\"/plugins/wiki/wikiadmin.php\" method=\"post\">\n";
print "<input type=\"hidden\" name=\"id\" value=\"$id\" />\n";
print "<input type=\"hidden\" name=\"pluginname\" value=\"$pluginname\" />\n";
print "<input type=\"hidden\" name=\"type\" value=\"admin_post\" />\n";
print '<table class="listing">';
print "\n<thead>\n<tr>\n<th>".
_("Parameter").
"</th>" .
"<th>".
_("Value").
"</th>\n" .
"</tr>\n</thead>\n";
foreach ($wc->getWikiConfigNames() as $c) {
$checked = $wc->getWikiConfig($c) ? ' checked="checked"' : '';
$desc = $wc->getWikiConfigDescription($c);
print "<tr>\n<td>$desc</td>\n" .
"<td align=\"center\">" .
"<input type=\"checkbox\" name=\"config[$c]\" value=\"1\"$checked /></td>\n" .
"</tr>\n";
}
print "</table>\n";
print "<p align=\"right\"><input type=\"submit\" value=\"" .
_("Save Configuration").
"\" /></p>";
print "</form>\n";
print "</fieldset>\n";
print "</td>\n";
print "</tr>\n";
print "</table>\n";
} else {
exit_error(_('Access Denied'), _('You are not a project Admin'));
}
}
}
site_project_footer(array());
?>