4 * globaldashboardPlugin Class
6 * Copyright 2011, Sabri LABBENE - Institut Télécom
8 * This file is part of FusionForge.
10 * FusionForge is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
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 this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 class globaldashboardPlugin extends Plugin {
26 public function __construct($id=0) {
28 $this->name = "globaldashboard";
29 $this->text = "Global Dashboard"; // Text to show in the tabs
31 $this->_addHook("usermenu"); // Shows in the tabs an entry for the plugin.
32 $this->_addHook("userisactivecheckbox"); // The "use ..." checkbox in user account
33 $this->_addHook("userisactivecheckboxpost"); //
35 $this->_addHook('widget_instance'); // creates widgets when requested
36 $this->_addHook('widgets'); // declares which widgets are provided by the plugin
40 global $G_SESSION,$HTML;
41 $text = $this->text; // this is what shows in the tab
42 if ($G_SESSION->usesPlugin("globaldashboard")) {
43 $param = '?type=user&id=' . $G_SESSION->getId() . "&pluginname=" . $this->name; // we indicate the part we're calling is the user one
44 echo $HTML->PrintSubMenu (array ($text),
45 array ('/plugins/globaldashboard/index.php' . $param ), array());
49 function widgets(&$params) {
50 require_once('common/widget/WidgetLayoutManager.class.php');
51 if ($params['owner_type'] == WidgetLayoutManager::OWNER_TYPE_USER) {
52 $params['fusionforge_widgets'][] = 'plugin_globalDashboard_MyProjects';
53 $params['fusionforge_widgets'][] = 'plugin_globalDashboard_MyArtifacts';
59 * Process the 'widget_instance' hook to create instances of the widgets
60 * @param array $params
62 function widget_instance($params) {
64 //$user = UserManager::instance()->getCurrentUser();
65 require_once('common/widget/WidgetLayoutManager.class.php');
66 if ($params['widget'] == 'plugin_globalDashboard_MyProjects') {
67 require_once $gfplugins.$this->name.'/include/globalDashboard_Widget_MyProjects.php';
68 $params['instance'] = new globalDashboard_Widget_MyProjects(WidgetLayoutManager::OWNER_TYPE_USER, $this);
70 if ($params['widget'] == 'plugin_globalDashboard_MyArtifacts') {
71 require_once $gfplugins.$this->name.'/include/globalDashboard_Widget_MyArtifacts.php';
72 $params['instance'] = new globalDashboard_Widget_MyArtifacts(WidgetLayoutManager::OWNER_TYPE_USER, $this);
76 // TODO: move this to its corresponding widget.
77 function getMyArtifacts() {
78 return array('Artifact 1', 'Artifact 2');
85 // c-file-style: "bsd"