function MediaWikiPlugin () {
$this->Plugin() ;
$this->name = "mediawiki" ;
- $this->text = "MediaWiki!" ; // To show in the tabs, use...
- $this->hooks[] = "user_personal_links";//to make a link to the user´s personal part of the plugin
- $this->hooks[] = "usermenu" ;
- $this->hooks[] = "outermenu" ;
+ $this->text = "Mediawiki" ; // To show in the tabs, use...
$this->hooks[] = "groupmenu" ; // To put into the project tabs
$this->hooks[] = "groupisactivecheckbox" ; // The "use ..." checkbox in editgroupinfo
$this->hooks[] = "groupisactivecheckboxpost" ; //
- $this->hooks[] = "userisactivecheckbox" ; // The "use ..." checkbox in user account
- $this->hooks[] = "userisactivecheckboxpost" ; //
- $this->hooks[] = "project_admin_plugins"; // to show up in the admin page fro group
+ $this->hooks[] = "project_public_area";
+ $this->hooks[] = "role_get";
+ $this->hooks[] = "role_translate_strings";
}
function CallHook ($hookname, $params) {
global $use_mediawikiplugin,$G_SESSION,$HTML;
- if ($hookname == "outermenu") {
- $params['TITLES'][] = 'MediaWiki';
- $params['DIRS'][] = '/mediawiki';
- } elseif ($hookname == "usermenu") {
- $text = $this->text; // this is what shows in the tab
- if ($G_SESSION->usesPlugin("mediawiki")) {
- echo ' | ' . $HTML->PrintSubMenu (array ($text),
- array ('/mediawiki/index.php/User:' . $G_SESSION->getUnixName() ));
- }
- } elseif ($hookname == "groupmenu") {
+
+ if (isset($params['group_id'])) {
+ $group_id=$params['group_id'];
+ } elseif (isset($params['group'])) {
$group_id=$params['group'];
+ } else {
+ $group_id=null;
+ }
+ if ($hookname == "groupmenu") {
$project = &group_get_object($group_id);
if (!$project || !is_object($project)) {
return;
if (!$project->isProject()) {
return;
}
- $params['DIRS'][]='/mediawiki/index.php/' . $project->getUnixName();
if ( $project->usesPlugin ( $this->name ) ) {
$params['TITLES'][]=$this->text;
- } else {
- $params['TITLES'][]=$this->text." is [Off]";
- }
+ if ($GLOBALS['sys_use_mwframe']){
+ $params['DIRS'][]=util_make_url ('/plugins/mediawiki/frame.php?group_id=' . $project->getID()) ;
+ } else {
+ $params['DIRS'][]=util_make_url('/plugins/mediawiki/wiki/'.$project->getUnixName().'/index.php');
+ }
+ }
(($params['toptab'] == $this->name) ? $params['selected']=(count($params['TITLES'])-1) : '' );
} elseif ($hookname == "groupisactivecheckbox") {
//Check if the group is active
// this code creates the checkbox in the project edit public info page to activate/deactivate the plugin
- $group_id=$params['group'];
$group = &group_get_object($group_id);
echo "<tr>";
echo "<td>";
- echo ' <input type="CHECKBOX" name="use_mediawikiplugin" value="1" ';
- // CHECKED OR UNCHECKED?
+ echo ' <input type="checkbox" name="use_mediawikiplugin" value="1" ';
+ // checked or unchecked?
if ( $group->usesPlugin ( $this->name ) ) {
- echo "CHECKED";
+ echo "checked";
}
- echo "><br/>";
+ echo " /><br/>";
echo "</td>";
echo "<td>";
echo "<strong>Use ".$this->text." Plugin</strong>";
echo "</tr>";
} elseif ($hookname == "groupisactivecheckboxpost") {
// this code actually activates/deactivates the plugin after the form was submitted in the project edit public info page
- $group_id=$params['group'];
$group = &group_get_object($group_id);
$use_mediawikiplugin = getStringFromRequest('use_mediawikiplugin');
if ( $use_mediawikiplugin == 1 ) {
} else {
$group->setPluginUse ( $this->name, false );
}
- } elseif ($hookname == "userisactivecheckbox") {
- //check if user is active
- // this code creates the checkbox in the user account manteinance page to activate/deactivate the plugin
- $user = $params['user'];
- echo "<tr>";
- echo "<td>";
- echo ' <input type="CHECKBOX" name="use_mediawikiplugin" value="1" ';
- // CHECKED OR UNCHECKED?
- if ( $user->usesPlugin ( $this->name ) ) {
- echo "CHECKED";
- }
- echo "> Use ".$this->text." Plugin";
- echo "</td>";
- echo "</tr>";
- } elseif ($hookname == "userisactivecheckboxpost") {
- // this code actually activates/deactivates the plugin after the form was submitted in the user account manteinance page
- $user = $params['user'];
- $use_mediawikiplugin = getStringFromRequest('use_mediawikiplugin');
- if ( $use_mediawikiplugin == 1 ) {
- $user->setPluginUse ( $this->name );
- } else {
- $user->setPluginUse ( $this->name, false );
+ } elseif ($hookname == "project_public_area") {
+ $project = &group_get_object($group_id);
+ if (!$project || !is_object($project)) {
+ return;
}
- echo "<tr>";
- echo "<td>";
- echo ' <input type="CHECKBOX" name="use_mediawikiplugin" value="1" ';
- // CHECKED OR UNCHECKED?
- if ( $user->usesPlugin ( $this->name ) ) {
- echo "CHECKED";
+ if ($project->isError()) {
+ return;
}
- echo "> Use ".$this->text." Plugin";
- echo "</td>";
- echo "</tr>";
- } elseif ($hookname == "user_personal_links") {
- // 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
- $userid = $params['user_id'];
- $user = user_get_object($userid);
- $text = $params['text'];
- //check if the user has the plugin activated
- if ($user->usesPlugin($this->name)) {
- echo ' <p>
- <a href="/mediawiki/index.php/User:' . $user->getUnixName() . '">' . _('View Personal MediaWiki') .'</a></p>';
+ if (!$project->isProject()) {
+ return;
}
- } elseif ($hookname == "project_admin_plugins") {
- // this displays the link in the project admin options page to it´s MediaWiki administration
- $group_id = $params['group_id'];
- $group = &group_get_object($group_id);
- if ( $group->usesPlugin ( $this->name ) ) {
- echo '<a href="/mediawiki/index.php?title=' . $group->getUnixName() . '&action=edit' . '">' . _('View the MediaWiki Administration') . '</a><br />';
+ if ( $project->usesPlugin ( $this->name ) ) {
+ print '<a href='. util_make_url ('/plugins/mediawiki/wiki/'.$project->getUnixName().'/index.php').'>';
+ print html_abs_image(util_make_url ('/plugins/mediawiki/wiki/'.$project->getUnixName().'/skins/fusionforge/wiki.png'),'20','20',array('alt'=>'Mediawiki'));
+ print ' Mediawiki';
+ print '</a>';
}
- }
- elseif ($hookname == "blahblahblah") {
- // ...
- }
+ } elseif ($hookname == "role_get") {
+ $role =& $params['role'] ;
+
+ $edit = new PluginSpecificRoleSetting ($role,
+ 'plugin_mediawiki_edit') ;
+ $edit->SetAllowedValues (array ('0', '1', '2')) ;
+ $edit->SetDefaultValues (array ('Admin' => '2',
+ 'Senior Developer' => '2',
+ 'Junior Developer' => '1',
+ 'Doc Writer' => '2',
+ 'Support Tech' => '0')) ;
+ } elseif ($hookname == "role_normalize") {
+ $role =& $params['role'] ;
+ $new_sa =& $params['new_sa'] ;
+
+ $role->normalizeDataForSection ($new_sa, 'plugin_mediawiki_edit') ;
+ } elseif ($hookname == "role_translate_strings") {
+ $edit = new PluginSpecificRoleSetting ($role,
+ 'plugin_mediawiki_edit') ;
+ $edit->setDescription (_('Mediawiki write access')) ;
+ $edit->setValueDescriptions (array ('0' => _('No editing'),
+ '1' => _('Edit existing pages only'),
+ '2' => _('Edit and create pages'))) ;
+ }
}
-}
+ }
// Local Variables:
// mode: php