7 * This file is part of FusionForge.
9 * FusionForge 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 * FusionForge 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 along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 forge_define_config_item('src_path','moinmoin', "/usr/share/moin");
25 forge_define_config_item('wiki_data_path','moinmoin', '$core/data_path/plugins/moinmoin/wikidata');
26 forge_define_config_item('use_frame', 'moinmoin', false);
27 forge_set_config_item_bool('use_frame', 'moinmoin');
29 class MoinMoinPlugin extends Plugin {
30 function MoinMoinPlugin () {
32 $this->name = "moinmoin" ;
33 $this->text = "MoinMoin" ; // To show in the tabs, use...
34 $this->hooks[] = "groupmenu" ; // To put into the project tabs
35 $this->hooks[] = "groupisactivecheckbox" ; // The "use ..." checkbox in editgroupinfo
36 $this->hooks[] = "groupisactivecheckboxpost" ; //
37 $this->hooks[] = "project_public_area";
38 $this->hooks[] = "role_get";
39 $this->hooks[] = "role_normalize";
40 $this->hooks[] = "role_translate_strings";
41 $this->hooks[] = "role_has_permission";
42 $this->hooks[] = "role_get_setting";
43 $this->hooks[] = "list_roles_by_permission";
44 $this->hooks[] = "project_admin_plugins"; // to show up in the admin page for group
45 $this->hooks[] = "clone_project_from_template" ;
48 function getWikiUrl ($project) {
49 if (forge_get_config('use_frame', 'moinmoin')){
50 return util_make_url ('/plugins/moinmoin/frame.php?group_id=' . $project->getID()) ;
52 return util_make_url('/plugins/moinmoin/'.$project->getUnixName().'/FrontPage');
56 function CallHook ($hookname, &$params) {
57 if (isset($params['group_id'])) {
58 $group_id=$params['group_id'];
59 } elseif (isset($params['group'])) {
60 $group_id=$params['group'];
64 if ($hookname == "groupmenu") {
65 $project = group_get_object($group_id);
66 if (!$project || !is_object($project)) {
69 if ($project->isError()) {
72 if (!$project->isProject()) {
75 if ( $project->usesPlugin ( $this->name ) ) {
76 $params['TITLES'][]=$this->text;
77 $params['DIRS'][]=$this->getWikiUrl($project);
79 (($params['toptab'] == $this->name) ? $params['selected']=(count($params['TITLES'])-1) : '' );
80 } elseif ($hookname == "groupisactivecheckbox") {
81 //Check if the group is active
82 // this code creates the checkbox in the project edit public info page to activate/deactivate the plugin
83 $group = group_get_object($group_id);
86 echo ' <input type="checkbox" name="use_moinmoinplugin" value="1" ';
87 // checked or unchecked?
88 if ( $group->usesPlugin ( $this->name ) ) {
94 echo "<strong>Use ".$this->text." Plugin</strong>";
97 } elseif ($hookname == "groupisactivecheckboxpost") {
98 // this code actually activates/deactivates the plugin after the form was submitted in the project edit public info page
99 $group = group_get_object($group_id);
100 $use_moinmoinplugin = getStringFromRequest('use_moinmoinplugin');
101 if ( $use_moinmoinplugin == 1 ) {
102 $group->setPluginUse ( $this->name );
104 $group->setPluginUse ( $this->name, false );
106 } elseif ($hookname == "project_public_area") {
107 $project = group_get_object($group_id);
108 if (!$project || !is_object($project)) {
111 if ($project->isError()) {
114 if (!$project->isProject()) {
117 if ( $project->usesPlugin ( $this->name ) ) {
118 echo '<div class="public-area-box">';
119 print '<a href="'. $this->getWikiUrl($project).'">';
130 // c-file-style: "bsd"