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";
36 $this->hooks[] = "project_admin_plugins"; // to show up in the admin page for group
39 function CallHook ($hookname, $params) {
40 global $use_mediawikiplugin,$G_SESSION,$HTML;
42 if (isset($params['group_id'])) {
43 $group_id=$params['group_id'];
44 } elseif (isset($params['group'])) {
45 $group_id=$params['group'];
49 if ($hookname == "groupmenu") {
50 $project = &group_get_object($group_id);
51 if (!$project || !is_object($project)) {
54 if ($project->isError()) {
57 if (!$project->isProject()) {
60 if ( $project->usesPlugin ( $this->name ) ) {
61 $params['TITLES'][]=$this->text;
62 if ($GLOBALS['sys_use_mwframe']){
63 $params['DIRS'][]=util_make_url ('/plugins/mediawiki/frame.php?group_id=' . $project->getID()) ;
65 $params['DIRS'][]=util_make_url('/plugins/mediawiki/wiki/'.$project->getUnixName().'/index.php');
68 (($params['toptab'] == $this->name) ? $params['selected']=(count($params['TITLES'])-1) : '' );
69 } elseif ($hookname == "groupisactivecheckbox") {
70 //Check if the group is active
71 // this code creates the checkbox in the project edit public info page to activate/deactivate the plugin
72 $group = &group_get_object($group_id);
75 echo ' <input type="checkbox" name="use_mediawikiplugin" value="1" ';
76 // checked or unchecked?
77 if ( $group->usesPlugin ( $this->name ) ) {
83 echo "<strong>Use ".$this->text." Plugin</strong>";
86 } elseif ($hookname == "groupisactivecheckboxpost") {
87 // this code actually activates/deactivates the plugin after the form was submitted in the project edit public info page
88 $group = &group_get_object($group_id);
89 $use_mediawikiplugin = getStringFromRequest('use_mediawikiplugin');
90 if ( $use_mediawikiplugin == 1 ) {
91 $group->setPluginUse ( $this->name );
93 $group->setPluginUse ( $this->name, false );
95 } elseif ($hookname == "project_public_area") {
96 $project = &group_get_object($group_id);
97 if (!$project || !is_object($project)) {
100 if ($project->isError()) {
103 if (!$project->isProject()) {
106 if ( $project->usesPlugin ( $this->name ) ) {
107 echo '<div class="public-area-box">';
108 print '<a href="'. util_make_url ('/plugins/mediawiki/wiki/'.$project->getUnixName().'/index.php').'">';
109 print html_abs_image(util_make_url ('/plugins/mediawiki/wiki/'.$project->getUnixName().'/skins/fusionforge/wiki.png'),'20','20',array('alt'=>'Mediawiki'));
114 } elseif ($hookname == "role_get") {
115 $role =& $params['role'] ;
117 $edit = new PluginSpecificRoleSetting ($role,
118 'plugin_mediawiki_edit') ;
119 $edit->SetAllowedValues (array ('0', '1', '2')) ;
120 $edit->SetDefaultValues (array ('Admin' => '2',
121 'Senior Developer' => '2',
122 'Junior Developer' => '1',
124 'Support Tech' => '0')) ;
125 } elseif ($hookname == "role_normalize") {
126 $role =& $params['role'] ;
127 $new_sa =& $params['new_sa'] ;
129 $role->normalizeDataForSection ($new_sa, 'plugin_mediawiki_edit') ;
130 } elseif ($hookname == "role_translate_strings") {
131 $edit = new PluginSpecificRoleSetting ($role,
132 'plugin_mediawiki_edit') ;
133 $edit->setDescription (_('Mediawiki write access')) ;
134 $edit->setValueDescriptions (array ('0' => _('No editing'),
135 '1' => _('Edit existing pages only'),
136 '2' => _('Edit and create pages'))) ;
137 } else if ($hookname == "project_admin_plugins") {
138 $group_id = $params['group_id'];
139 $group = &group_get_object($group_id);
140 if ($group->usesPlugin($this->name))
142 "/plugins/mediawiki/plugin_admin.php?group_id=" .
143 $group->getID(), _("MediaWiki Plugin admin")) .
151 // c-file-style: "bsd"