3 * FusionForge extratabs plugin
5 * Copyright 2005, Raphaƫl Hertzog
6 * Copyright 2009, Roland Mas
7 * Copyright (C) 2010 Alain Peyrat - Alcatel-Lucent
8 * Copyright 2010, Franck Villaume - Capgemini
9 * http://fusionforge.org
11 * This file is part of FusionForge.
13 * FusionForge is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published
15 * by the Free Software Foundation; either version 2 of the License,
16 * or (at your option) any later version.
18 * FusionForge is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * General Public License for more details.
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 class ExtraTabsPlugin extends Plugin {
29 function ExtraTabsPlugin () {
31 $this->name = "extratabs" ;
32 $this->text = "Extra tabs";
33 $this->_addHook('groupisactivecheckbox'); // The "use ..." checkbox in editgroupinfo
34 $this->_addHook('groupisactivecheckboxpost');
35 $this->_addHook('project_admin_plugins');
36 $this->_addHook('groupmenu'); // To put into the project tabs
37 $this->_addHook('clone_project_from_template');
40 function CallHook($hookname, &$params) {
44 case "project_admin_plugins": {
45 $group_id = $params['group_id'];
46 $project = group_get_object($group_id);
47 if ($project->usesPlugin($this->name)) {
48 echo '<p>'.util_make_link('/plugins/extratabs/index.php?group_id='.$group_id,
49 _('Extra Tabs Admin')) . '</p>';
55 $group_id = $params['group'];
56 $project = group_get_object($group_id);
57 if (!$project || !is_object($project))
59 if ($project->isError())
61 if (!$project->isProject())
63 $res_tabs = db_query_params('SELECT tab_name, tab_url, type FROM plugin_extratabs_main WHERE group_id=$1 ORDER BY index',
65 while ($row_tab = db_fetch_array($res_tabs)) {
66 $params['TITLES'][] = $row_tab['tab_name'];
67 switch ($row_tab['type']) {
69 $params['DIRS'][] = $row_tab['tab_url'];
70 $params['ADMIN'][] = '';
71 $params['TOOLTIPS'][] = '';
75 $params['DIRS'][] = '/plugins/'.$this->name.'/iframe.php?group_id='.$group_id.'&tab_name='.$row_tab['tab_name'];
76 $params['ADMIN'][] = '';
77 $params['TOOLTIPS'][] = '';
78 if (isset($params['toptab']) && ($params['toptab'] == $row_tab['tab_name'])) {
79 $params['selected'] = count($params['TITLES']) - 1;
89 case "clone_project_from_template": {
91 $res = db_query_params ('SELECT tab_name, tab_url, index FROM plugin_extratabs_main WHERE group_id=$1 ORDER BY index',
92 array ($params['template']->getID())) ;
93 while ($row = db_fetch_array($res)) {
95 $data['tab_url'] = $params['project']->replaceTemplateStrings ($row['tab_url']) ;
96 $data['tab_name'] = $params['project']->replaceTemplateStrings ($row['tab_name']) ;
97 $data['index'] = $row['index'] ;
101 foreach ($tabs as $tab) {
102 db_query_params ('INSERT INTO plugin_extratabs_main (tab_url, tab_name, index, group_id) VALUES ($1,$2,$3,$4)',
103 array ($data['tab_url'],
106 $params['project']->getID())) ;
115 // c-file-style: "bsd"