4 * extratab -> headermenu migration script
6 * Copyright 2013, Franck Villaume - TrivialDev
7 * http://fusionforge.org
9 * This file is part of FusionForge. FusionForge is free software;
10 * you can redistribute it and/or modify it under the terms of the
11 * GNU General Public License as published by the Free Software
12 * Foundation; either version 2 of the Licence, or (at your option)
15 * FusionForge is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 require_once dirname(__FILE__).'/../www/env.inc.php';
26 require_once $gfcommon.'include/pre.php';
28 $pm = plugin_manager_get_object();
30 if ($pm->PluginIsInstalled('extratabs')) {
32 $groupnames = db_query_params('SELECT g.group_name FROM plugins p, group_plugin gp, groups g WHERE plugin_name = $1 and gp.group_id = g.group_id and p.plugin_id = gp.plugin_id',
35 if (db_numrows($groupnames) > 0) {
41 // is headermenu activated ?
42 // no ... -> activate the plugin
43 if (!$pm->PluginIsInstalled('headermenu')) {
44 $pm->activate('headermenu');
45 $pm->LoadPlugin('headermenu');
46 $pluginHeaderMenu = $pm->GetPluginObject('headermenu');
47 $pluginHeaderMenu->install();
49 $pm->LoadPlugin('headermenu');
50 $pluginHeaderMenu = $pm->GetPluginObject('headermenu');
53 // loop on the list of groups using extratab
54 while ($arrGroupNames = db_fetch_array($groupnames)) {
55 // -> register headermenu for these groups
56 $projectObject = group_get_object_by_publicname($arrGroupNames['group_name']);
57 $projectObject->setPluginUse('headermenu');
59 $extratabsDesc = db_query_params('SELECT * FROM plugin_extratabs_main WHERE group_id=$1', array($projectObject->getID()));
60 if (db_numrows($extratabsDesc) > 0) {
61 while($arrExtraTabsDesc = db_fetch_array($extratabsDesc)) {
62 $url = $arrExtraTabsDesc['tab_url'];
63 $name = $arrExtraTabsDesc['tab_name'];
64 $description = $arrExtraTabsDesc['tab_name'];
65 $linkmenu = 'groupmenu';
66 $linktype = ($arrExtraTabsDesc['type']? 'iframe' : 'url');
67 $project = $projectObject->getID();
68 $ordering = $arrExtraTabsDesc['index'];
69 $pluginHeaderMenu->addLink($url, $name, $description, $linkmenu, $linktype, $project, '', $ordering);
72 $projectObject->setPluginUse('extratabs', false);
75 $pm->deactivate('extratabs');
76 // Remove the symbolic link made if plugin has a www.
77 if (is_dir(forge_get_config('plugins_path') . '/extratabs/www')) { // if the plugin has a www dir delete the link to it
78 if (file_exists('../www/plugins/extratabs')) {
79 $result = unlink('../www/plugins/extratabs');
81 $feedback .= "\n"._('Soft link wasn\'t removed in www/plugins folder, please do so manually.');
86 // Remove the symbolic link made if plugin has a config.
87 if (file_exists(forge_get_config('config_path'). '/plugins/headermenu')) {
88 $result = unlink(forge_get_config('config_path'). '/plugins/headermenu'); // the apache group or user should have write perms in forge_get_config('config_path')/plugins folder...
90 $feedback .= _('Soft link wasn\'t removed in config folder, please do so manually.');