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[] = "user_personal_links";//to make a link to the user´s personal part of the plugin
30 $this->hooks[] = "usermenu" ;
31 $this->hooks[] = "outermenu" ;
32 $this->hooks[] = "groupmenu" ; // To put into the project tabs
33 $this->hooks[] = "groupisactivecheckbox" ; // The "use ..." checkbox in editgroupinfo
34 $this->hooks[] = "groupisactivecheckboxpost" ; //
35 $this->hooks[] = "userisactivecheckbox" ; // The "use ..." checkbox in user account
36 $this->hooks[] = "userisactivecheckboxpost" ; //
37 $this->hooks[] = "project_admin_plugins"; // to show up in the admin page fro group
40 function CallHook ($hookname, $params) {
41 global $use_mediawikiplugin,$G_SESSION,$HTML;
42 if ($hookname == "outermenu") {
43 $params['TITLES'][] = 'MediaWiki';
44 $params['DIRS'][] = '/mediawiki';
45 } elseif ($hookname == "usermenu") {
46 $text = $this->text; // this is what shows in the tab
47 if ($G_SESSION->usesPlugin("mediawiki")) {
48 echo ' | ' . $HTML->PrintSubMenu (array ($text),
49 array ('/mediawiki/index.php/User:' . $G_SESSION->getUnixName() ));
51 } elseif ($hookname == "groupmenu") {
52 $group_id=$params['group'];
53 $project = &group_get_object($group_id);
54 if (!$project || !is_object($project)) {
57 if ($project->isError()) {
60 if (!$project->isProject()) {
63 $params['DIRS'][]='/mediawiki/index.php/' . $project->getUnixName();
64 if ( $project->usesPlugin ( $this->name ) ) {
65 $params['TITLES'][]=$this->text;
67 $params['TITLES'][]=$this->text." is [Off]";
69 (($params['toptab'] == $this->name) ? $params['selected']=(count($params['TITLES'])-1) : '' );
70 } elseif ($hookname == "groupisactivecheckbox") {
71 //Check if the group is active
72 // this code creates the checkbox in the project edit public info page to activate/deactivate the plugin
73 $group_id=$params['group'];
74 $group = &group_get_object($group_id);
77 echo ' <input type="CHECKBOX" name="use_mediawikiplugin" value="1" ';
78 // CHECKED OR UNCHECKED?
79 if ( $group->usesPlugin ( $this->name ) ) {
85 echo "<strong>Use ".$this->text." Plugin</strong>";
88 } elseif ($hookname == "groupisactivecheckboxpost") {
89 // this code actually activates/deactivates the plugin after the form was submitted in the project edit public info page
90 $group_id=$params['group'];
91 $group = &group_get_object($group_id);
92 $use_mediawikiplugin = getStringFromRequest('use_mediawikiplugin');
93 if ( $use_mediawikiplugin == 1 ) {
94 $group->setPluginUse ( $this->name );
96 $group->setPluginUse ( $this->name, false );
98 } elseif ($hookname == "userisactivecheckbox") {
99 //check if user is active
100 // this code creates the checkbox in the user account manteinance page to activate/deactivate the plugin
101 $user = $params['user'];
104 echo ' <input type="CHECKBOX" name="use_mediawikiplugin" value="1" ';
105 // CHECKED OR UNCHECKED?
106 if ( $user->usesPlugin ( $this->name ) ) {
109 echo "> Use ".$this->text." Plugin";
112 } elseif ($hookname == "userisactivecheckboxpost") {
113 // this code actually activates/deactivates the plugin after the form was submitted in the user account manteinance page
114 $user = $params['user'];
115 $use_mediawikiplugin = getStringFromRequest('use_mediawikiplugin');
116 if ( $use_mediawikiplugin == 1 ) {
117 $user->setPluginUse ( $this->name );
119 $user->setPluginUse ( $this->name, false );
123 echo ' <input type="CHECKBOX" name="use_mediawikiplugin" value="1" ';
124 // CHECKED OR UNCHECKED?
125 if ( $user->usesPlugin ( $this->name ) ) {
128 echo "> Use ".$this->text." Plugin";
131 } elseif ($hookname == "user_personal_links") {
132 // this displays the link in the user´s profile page to it´s personal MediaWiki (if you want other sto access it, youll have to change the permissions in the index.php
133 $userid = $params['user_id'];
134 $user = user_get_object($userid);
135 $text = $params['text'];
136 //check if the user has the plugin activated
137 if ($user->usesPlugin($this->name)) {
139 <a href="/mediawiki/index.php/User:' . $user->getUnixName() . '">' . _('View Personal MediaWiki') .'</a></p>';
141 } elseif ($hookname == "project_admin_plugins") {
142 // this displays the link in the project admin options page to it´s MediaWiki administration
143 $group_id = $params['group_id'];
144 $group = &group_get_object($group_id);
145 if ( $group->usesPlugin ( $this->name ) ) {
146 echo '<a href="/mediawiki/index.php?title=' . $group->getUnixName() . '&action=edit' . '">' . _('View the MediaWiki Administration') . '</a><br />';
149 elseif ($hookname == "blahblahblah") {
157 // c-file-style: "bsd"