1 <?php // -*-php-*- $Id$
3 * Copyright (C) 2009 Alain Peyrat, Alcatel-Lucent
4 * Copyright (C) 2009 Marc-Etienne Vargenau, Alcatel-Lucent
6 * This file is part of PhpWiki.
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.
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.
18 * You should have received a copy of the GNU General Public License
19 * along with PhpWiki; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 * Standard Alcatel-Lucent disclaimer for contributing to open source
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
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
45 require_once dirname(__FILE__)."/../../env.inc.php";
46 require_once $gfwww.'include/pre.php';
47 require_once $sys_plugins_path.'wiki/common/WikiPlugin.class.php';
48 require_once $sys_plugins_path.'wiki/common/wikiconfig.class.php';
50 // the header that displays for the user portion of the plugin
51 function wiki_Project_Header($params) {
53 $params['toptab']='wiki';
58 site_project_header($params);
61 $user = session_get_user(); // get the session user
63 if (!$user || !is_object($user) || $user->isError() || !$user->isActive()) {
64 exit_error("Invalid User", "Cannot Process your request for this user.");
67 $type = getStringFromRequest('type');
68 $id = getIntFromRequest('id');
70 $config = getArrayFromRequest('config');
73 exit_error("Cannot Process your request","No TYPE specified");
75 exit_error("Cannot Process your request","No ID specified");
77 if ($type == 'admin_post') {
78 $group = group_get_object($id);
80 exit_error(_('Invalid Project'), _('Inexistent Project'));
82 if (!($group->usesPlugin($pluginname))) { //check if the group has the wiki plugin active
83 exit_error("Error", "First activate the $pluginname plugin through the Project's Admin Interface");
85 $userperm = $group->getPermission($user); //we'll check if the user belongs to the group
86 if ( !$userperm->IsMember()) {
87 exit_error(_('Access Denied'), _('You are not a member of this project'));
89 //only project admin can access here
90 if ( $userperm->isAdmin() ) {
92 $wc = new WikiConfig($id);
94 foreach ($wc->getWikiConfigNames() as $c) {
95 if ( ! array_key_exists($c, $config)) {
100 foreach ($config as $config_name => $config_value) {
101 $r = $wc->updateWikiConfig($config_name, $config_value);
102 if (!$r) exit_error("Error", $wc->getErrorMessage());
106 $feedback = _('Configuration saved.');
108 exit_error(_('Access Denied'), _('You are not a project Admin'));
111 if ($type == 'admin') {
112 $group = group_get_object($id);
114 exit_error(_('Invalid Project'), _('Inexistent Project'));
116 if ( ! ($group->usesPlugin ($pluginname)) ) {//check if the group has the plugin active
117 exit_error("Error", "First activate the $pluginname plugin through the Project's Admin Interface");
119 $userperm = $group->getPermission($user); //we'll check if the user belongs to the group
120 if ( !$userperm->IsMember()) {
121 exit_error(_('Access Denied'), _('You are not a member of this project'));
123 //only project admin can access here
124 if ( $userperm->isAdmin() ) {
125 wiki_Project_Header(array('title'=>$pluginname . ' Project Plugin!','pagename'=>"$pluginname",'sectionvals'=>array(group_getname($id))));
127 $wc = new WikiConfig($id);
129 print "\n<h1>"._("Configuration for your project's Wiki")."</h1>\n";
134 print "<fieldset>\n";
135 print "<legend>"._('Wiki Configuration')."</legend>\n";
136 print "<form action=\"/plugins/wiki/wikiadmin.php\" method=\"post\">\n";
137 print "<input type=\"hidden\" name=\"id\" value=\"$id\" />\n";
138 print "<input type=\"hidden\" name=\"pluginname\" value=\"$pluginname\" />\n";
139 print "<input type=\"hidden\" name=\"type\" value=\"admin_post\" />\n";
141 print '<table class="listing">';
142 print "\n<thead>\n<tr>\n<th>".
150 foreach ($wc->getWikiConfigNames() as $c) {
151 $checked = $wc->getWikiConfig($c) ? ' checked="checked"' : '';
152 $desc = $wc->getWikiConfigDescription($c);
154 print "<tr>\n<td>$desc</td>\n" .
155 "<td align=\"center\">" .
156 "<input type=\"checkbox\" name=\"config[$c]\" value=\"1\"$checked /></td>\n" .
160 print "<p align=\"right\"><input type=\"submit\" value=\"" .
161 _("Save Configuration").
164 print "</fieldset>\n";
169 exit_error(_('Access Denied'), _('You are not a project Admin'));
174 site_project_footer(array());