/usr/share/gforge/plugins/moinmoin/common/MoinMoinPlugin.class.php is in fusionforge-plugin-moinmoin 5.3.2+20141104-3+deb8u3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | <?php
/**
* MoinMoinPlugin Class
*
*
* This file is part of FusionForge.
*
* FusionForge is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* FusionForge is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
forge_define_config_item('wiki_data_path','moinmoin', '$core/data_path/plugins/moinmoin/wikidata');
forge_define_config_item('use_frame', 'moinmoin', false);
forge_set_config_item_bool('use_frame', 'moinmoin');
class MoinMoinPlugin extends Plugin {
function MoinMoinPlugin () {
$this->Plugin() ;
$this->name = "moinmoin" ;
$this->text = "MoinMoinWiki" ; // 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[] = "project_public_area";
$this->hooks[] = "role_get";
$this->hooks[] = "role_normalize";
$this->hooks[] = "role_unlink_project";
$this->hooks[] = "role_translate_strings";
$this->hooks[] = "role_get_setting";
$this->hooks[] = "project_admin_plugins"; // to show up in the admin page for group
$this->hooks[] = "clone_project_from_template" ;
}
function getWikiUrl ($project) {
if (forge_get_config('use_frame', 'moinmoin')){
return util_make_uri('/plugins/moinmoin/frame.php?group_id=' . $project->getID());
} else {
return util_make_uri('/plugins/moinmoin/'.$project->getUnixName().'/FrontPage');
}
}
function CallHook ($hookname, &$params) {
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->isError()) {
return;
}
if (!$project->isProject()) {
return;
}
if ( $project->usesPlugin ( $this->name ) ) {
$params['TITLES'][]=$this->text;
$params['DIRS'][]=$this->getWikiUrl($project);
}
(($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 = group_get_object($group_id);
echo "<tr>";
echo "<td>";
echo ' <input type="checkbox" name="use_moinmoinplugin" value="1" ';
// checked or unchecked?
if ( $group->usesPlugin ( $this->name ) ) {
echo "checked";
}
echo " /><br/>";
echo "</td>";
echo "<td>";
echo "<strong>Use ".$this->text." Plugin</strong>";
echo "</td>";
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 = group_get_object($group_id);
$use_moinmoinplugin = getStringFromRequest('use_moinmoinplugin');
if ( $use_moinmoinplugin == 1 ) {
$group->setPluginUse ( $this->name );
} else {
$group->setPluginUse ( $this->name, false );
}
} elseif ($hookname == "project_public_area") {
$project = group_get_object($group_id);
if (!$project || !is_object($project)) {
return;
}
if ($project->isError()) {
return;
}
if (!$project->isProject()) {
return;
}
if ( $project->usesPlugin ( $this->name ) ) {
echo '<div class="public-area-box">';
print '<a href="'. $this->getWikiUrl($project).'">';
print 'MoinMoin';
print '</a>';
echo '</div>';
}
} elseif ($hookname == "role_get") {
$role =& $params['role'] ;
// MoinMoin access
// 0 - None
// 1 - Read
// 2 - Write
// 3 - Admin
$right = new PluginSpecificRoleSetting ($role,
'plugin_moinmoin_access') ;
$right->SetAllowedValues (array ('0', '1', '2', '3')) ;
$right->SetDefaultValues (array ('Admin' => '3',
'Senior Developer' => '2',
'Junior Developer' => '2',
'Doc Writer' => '2',
'Support Tech' => '1')) ;
} elseif ($hookname == "role_normalize") {
$role =& $params['role'] ;
$new_pa =& $params['new_pa'] ;
$projects = $role->getLinkedProjects() ;
foreach ($projects as $p) {
$role->normalizePermsForSection ($new_pa, 'plugin_moinmoin_access', $p->getID()) ;
}
} elseif ($hookname == "role_unlink_project") {
$role =& $params['role'] ;
$project =& $params['project'] ;
$settings = array('plugin_moinmoin_access');
foreach ($settings as $s) {
db_query_params('DELETE FROM pfo_role_setting WHERE role_id=$1 AND section_name=$2 AND ref_id=$3',
array($role->getID(),
$s,
$project->getID()));
}
} elseif ($hookname == "role_translate_strings") {
$right = new PluginSpecificRoleSetting ($role,
'plugin_moinmoin_access') ;
$right->setDescription (_('MoinMoin Wiki access')) ;
$right->setValueDescriptions (array ('0' => _('No Access'),
'1' => _('Read access'),
'2' => _('Write access'),
'3' => _('Admin access'))) ;
} elseif ($hookname == "role_get_setting") {
$role = $params['role'] ;
$reference = $params['reference'] ;
$value = $params['value'] ;
switch ($params['section']) {
case 'plugin_moinmoin_access':
if ($role->hasPermission('project_admin', $reference)) {
$params['result'] = 3 ;
} else {
$params['result'] = $value ;
}
break ;
}
}
}
}
// Local Variables:
// mode: php
// c-file-style: "bsd"
// End:
|