From 1726e2327b8b7210a4d1652b05678e214cc81ae6 Mon Sep 17 00:00:00 2001 From: vargenau Date: Tue, 4 May 2010 13:49:26 +0000 Subject: [PATCH] Add Gforge Wiki Configurator git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@7378 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- wikiadmin.php | 177 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 177 insertions(+) create mode 100644 wikiadmin.php diff --git a/wikiadmin.php b/wikiadmin.php new file mode 100644 index 000000000..0e84dce79 --- /dev/null +++ b/wikiadmin.php @@ -0,0 +1,177 @@ +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'=>$pluginname . ' Project Plugin!','pagename'=>"$pluginname",'sectionvals'=>array(group_getname($id)))); + + $wc = new WikiConfig($id); + + print "\n

"._("Configuration for your project's Wiki")."

\n"; + + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "
\n"; + print "
\n"; + print ""._('Wiki Configuration')."\n"; + print "
\n"; + print "\n"; + print "\n"; + print "\n"; + + print ''; + print "\n\n\n" . + "\n" . + "\n\n"; + + foreach ($wc->getWikiConfigNames() as $c) { + $checked = $wc->getWikiConfig($c) ? ' checked="checked"' : ''; + $desc = $wc->getWikiConfigDescription($c); + + print "\n\n" . + "\n" . + "\n"; + } + print "
". + _("Parameter"). + "". + _("Value"). + "
$desc" . + "
\n"; + print "

"; + print "
\n"; + print "
\n"; + print "
\n"; + } else { + exit_error(_('Access Denied'), _('You are not a project Admin')); + } + } +} + +site_project_footer(array()); + +?> -- 2.45.0