4 * MediaWikiPlugin Class
7 * This file is part of GForge.
9 * GForge is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * GForge is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with GForge; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 class MediaWikiPlugin extends Plugin {
25 function MediaWikiPlugin () {
27 $this->name = "mediawiki" ;
28 $this->text = "Mediawiki" ; // To show in the tabs, use...
29 $this->hooks[] = "groupmenu" ; // To put into the project tabs
30 $this->hooks[] = "groupisactivecheckbox" ; // The "use ..." checkbox in editgroupinfo
31 $this->hooks[] = "groupisactivecheckboxpost" ; //
32 $this->hooks[] = "project_public_area";
33 $this->hooks[] = "role_get";
34 $this->hooks[] = "role_normalize";
35 $this->hooks[] = "role_translate_strings";
38 function CallHook ($hookname, $params) {
39 global $use_mediawikiplugin,$G_SESSION,$HTML;
41 if (isset($params['group_id'])) {
42 $group_id=$params['group_id'];
43 } elseif (isset($params['group'])) {
44 $group_id=$params['group'];
48 if ($hookname == "groupmenu") {
49 $project = &group_get_object($group_id);
50 if (!$project || !is_object($project)) {
53 if ($project->isError()) {
56 if (!$project->isProject()) {
59 if ( $project->usesPlugin ( $this->name ) ) {
60 $params['TITLES'][]=$this->text;
61 if ($GLOBALS['sys_use_mwframe']){
62 $params['DIRS'][]=util_make_url ('/plugins/mediawiki/frame.php?group_id=' . $project->getID()) ;
64 $params['DIRS'][]=util_make_url('/plugins/mediawiki/wiki/'.$project->getUnixName().'/index.php');
67 (($params['toptab'] == $this->name) ? $params['selected']=(count($params['TITLES'])-1) : '' );
68 } elseif ($hookname == "groupisactivecheckbox") {
69 //Check if the group is active
70 // this code creates the checkbox in the project edit public info page to activate/deactivate the plugin
71 $group = &group_get_object($group_id);
74 echo ' <input type="checkbox" name="use_mediawikiplugin" value="1" ';
75 // checked or unchecked?
76 if ( $group->usesPlugin ( $this->name ) ) {
82 echo "<strong>Use ".$this->text." Plugin</strong>";
85 } elseif ($hookname == "groupisactivecheckboxpost") {
86 // this code actually activates/deactivates the plugin after the form was submitted in the project edit public info page
87 $group = &group_get_object($group_id);
88 $use_mediawikiplugin = getStringFromRequest('use_mediawikiplugin');
89 if ( $use_mediawikiplugin == 1 ) {
90 $group->setPluginUse ( $this->name );
92 $group->setPluginUse ( $this->name, false );
94 } elseif ($hookname == "project_public_area") {
95 $project = &group_get_object($group_id);
96 if (!$project || !is_object($project)) {
99 if ($project->isError()) {
102 if (!$project->isProject()) {
105 if ( $project->usesPlugin ( $this->name ) ) {
106 print '<a href='. util_make_url ('/plugins/mediawiki/wiki/'.$project->getUnixName().'/index.php').'>';
107 print html_abs_image(util_make_url ('/plugins/mediawiki/wiki/'.$project->getUnixName().'/skins/fusionforge/wiki.png'),'20','20',array('alt'=>'Mediawiki'));
111 } elseif ($hookname == "role_get") {
112 $role =& $params['role'] ;
114 $edit = new PluginSpecificRoleSetting ($role,
115 'plugin_mediawiki_edit') ;
116 $edit->SetAllowedValues (array ('0', '1', '2')) ;
117 $edit->SetDefaultValues (array ('Admin' => '2',
118 'Senior Developer' => '2',
119 'Junior Developer' => '1',
121 'Support Tech' => '0')) ;
122 } elseif ($hookname == "role_normalize") {
123 $role =& $params['role'] ;
124 $new_sa =& $params['new_sa'] ;
126 $role->normalizeDataForSection ($new_sa, 'plugin_mediawiki_edit') ;
127 } elseif ($hookname == "role_translate_strings") {
128 $edit = new PluginSpecificRoleSetting ($role,
129 'plugin_mediawiki_edit') ;
130 $edit->setDescription (_('Mediawiki write access')) ;
131 $edit->setValueDescriptions (array ('0' => _('No editing'),
132 '1' => _('Edit existing pages only'),
133 '2' => _('Edit and create pages'))) ;
140 // c-file-style: "bsd"