]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - wikiadmin.php
Allow bold, italics or underlined for numbers
[SourceForge/phpwiki.git] / wikiadmin.php
1 <?php
2 /*
3  * Copyright (C) 2009 Alain Peyrat, Alcatel-Lucent
4  * Copyright (C) 2009-2010 Marc-Etienne Vargenau, Alcatel-Lucent
5  *
6  * This file is part of PhpWiki.
7  *
8  * PhpWiki is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * PhpWiki is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with PhpWiki; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 */
22
23 /*
24  * Standard Alcatel-Lucent disclaimer for contributing to open source
25  *
26  * "The Wiki Configurator ("Contribution") has not been tested and/or
27  * validated for release as or in products, combinations with products or
28  * other commercial use. Any use of the Contribution is entirely made at
29  * the user's own responsibility and the user can not rely on any features,
30  * functionalities or performances Alcatel-Lucent has attributed to the
31  * Contribution.
32  *
33  * THE CONTRIBUTION BY ALCATEL-LUCENT IS PROVIDED AS IS, WITHOUT WARRANTY
34  * OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
35  * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, COMPLIANCE,
36  * NON-INTERFERENCE AND/OR INTERWORKING WITH THE SOFTWARE TO WHICH THE
37  * CONTRIBUTION HAS BEEN MADE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL
38  * ALCATEL-LUCENT BE LIABLE FOR ANY DAMAGES OR OTHER LIABLITY, WHETHER IN
39  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
40  * CONTRIBUTION OR THE USE OR OTHER DEALINGS IN THE CONTRIBUTION, WHETHER
41  * TOGETHER WITH THE SOFTWARE TO WHICH THE CONTRIBUTION RELATES OR ON A STAND
42  * ALONE BASIS."
43  */
44
45 require_once dirname(__FILE__) . "/../../env.inc.php";
46 require_once $gfcommon . 'include/pre.php';
47 require_once forge_get_config('plugins_path') . '/wiki/common/WikiPlugin.class.php';
48 require_once forge_get_config('plugins_path') . '/wiki/common/wikiconfig.class.php';
49
50 $user = session_get_user(); // get the session user
51
52 if (!$user || !is_object($user)) {
53     exit_error(_('Invalid User'), 'home');
54 } elseif ($user->isError()) {
55     exit_error($user->getErrorMessage(), 'home');
56 } elseif (!$user->isActive()) {
57     exit_error(_('User not active'), 'home');
58 }
59
60 $type = getStringFromRequest('type');
61 $group_id = getIntFromRequest('group_id');
62 $pluginname = 'wiki';
63 $config = getArrayFromRequest('config');
64
65 if (!$type) {
66     exit_missing_param('', array(_('No TYPE specified')), 'home');
67 } elseif (!$group_id) {
68     exit_missing_param('', array(_('No ID specified')), 'home');
69 } else {
70     if ($type == 'admin_post') {
71         $group = group_get_object($group_id);
72         if (!$group) {
73             exit_no_group();
74         }
75         if (!($group->usesPlugin($pluginname))) { //check if the group has the wiki plugin active
76             exit_error(sprintf(_('First activate the %s plugin through the Project\'s Admin Interface'), $pluginname), 'home');
77         }
78         $userperm = $group->getPermission(); //we'll check if the user belongs to the group
79         if (!$userperm->IsMember()) {
80             exit_permission_denied(_('You are not a member of this project'), 'home');
81         }
82         //only project admin can access here
83         if ($userperm->isAdmin()) {
84
85             $wc = new WikiConfig($group_id);
86
87             foreach ($wc->getWikiConfigNames() as $c) {
88                 if (!array_key_exists($c, $config)) {
89                     $config[$c] = 0;
90                 }
91             }
92
93             foreach ($config as $config_name => $config_value) {
94                 $r = $wc->updateWikiConfig($config_name, $config_value);
95                 if (!$r) exit_error("Error", $wc->getErrorMessage());
96             }
97
98             $type = 'admin';
99             $feedback = _('Configuration saved.');
100         } else {
101             exit_permission_denied(_('You are not a project Admin'), 'home');
102         }
103     }
104     if ($type == 'admin') {
105         $group = group_get_object($group_id);
106         if (!$group) {
107             exit_no_group();
108         }
109         if (!($group->usesPlugin($pluginname))) { //check if the group has the plugin active
110             exit_error(sprintf(_('First activate the %s plugin through the Project\'s Admin Interface'), $pluginname), 'home');
111         }
112         $userperm = $group->getPermission(); //we'll check if the user belongs to the group
113         if (!$userperm->IsMember()) {
114             exit_permission_denied(_('You are not a member of this project'), 'home');
115         }
116         //only project admin can access here
117         if ($userperm->isAdmin()) {
118             site_project_header(array('title' => _("Configuration for your project's wiki"),
119                 'pagename' => $pluginname,
120                 'group' => $group_id,
121                 'toptab' => 'wiki',
122                 'sectionvals' => array(group_getname($group_id))));
123
124             $wc = new WikiConfig($group_id);
125
126             print "<table>\n";
127             print "<tr>\n";
128             print "<td>\n";
129             print "<fieldset>\n";
130             print "<legend>" . _('Wiki Configuration') . "</legend>\n";
131             print "<form action=\"/wiki/wikiadmin.php\" method=\"post\">\n";
132             print "<input type=\"hidden\" name=\"group_id\" value=\"$group_id\" />\n";
133             print "<input type=\"hidden\" name=\"pluginname\" value=\"$pluginname\" />\n";
134             print "<input type=\"hidden\" name=\"type\" value=\"admin_post\" />\n";
135
136             print '<table class="listing">';
137             print "\n<thead>\n<tr>\n<th>" .
138                 _("Parameter") .
139                 "</th>" .
140                 "<th>" .
141                 _("Value") .
142                 "</th>\n" .
143                 "</tr>\n</thead>\n";
144
145             foreach ($wc->getWikiConfigNames() as $c) {
146                 $checked = $wc->getWikiConfig($c) ? ' checked="checked"' : '';
147                 $desc = $wc->getWikiConfigDescription($c);
148
149                 print "<tr>\n<td>$desc</td>\n" .
150                     "<td align=\"center\">" .
151                     "<input type=\"checkbox\" name=\"config[$c]\" value=\"1\"$checked /></td>\n" .
152                     "</tr>\n";
153             }
154             print "</table>\n";
155             print "<p align=\"right\"><input type=\"submit\" value=\"" .
156                 _("Save Configuration") .
157                 "\" /></p>";
158             print "</form>\n";
159             print "</fieldset>\n";
160             print "</td>\n";
161             print "</tr>\n";
162             print "</table>\n";
163         } else {
164             exit_permission_denied(_('You are not a project Admin'), 'home');
165         }
166     }
167 }
168
169 site_project_footer(array());