4 * helloworldPlugin Class
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 class helloworldPlugin extends Plugin {
25 public function __construct($id=0) {
27 $this->name = "helloworld";
28 $this->text = "HelloWorld!"; // To show in the tabs, use...
29 $this->_addHook("user_personal_links");//to make a link to the user's personal part of the plugin
30 $this->_addHook("usermenu");
31 $this->_addHook("groupmenu"); // To put into the project tabs
32 $this->_addHook("groupisactivecheckbox"); // The "use ..." checkbox in editgroupinfo
33 $this->_addHook("groupisactivecheckboxpost"); //
34 $this->_addHook("userisactivecheckbox"); // The "use ..." checkbox in user account
35 $this->_addHook("userisactivecheckboxpost"); //
36 $this->_addHook("project_admin_plugins"); // to show up in the admin page fro group
39 function CallHook ($hookname, &$params) {
40 global $use_helloworldplugin,$G_SESSION,$HTML;
41 if ($hookname == "usermenu") {
42 $text = $this->text; // this is what shows in the tab
43 if ($G_SESSION->usesPlugin("helloworld")) {
44 $param = '?type=user&id=' . $G_SESSION->getId() . "&pluginname=" . $this->name; // we indicate the part we're calling is the user one
45 echo $HTML->PrintSubMenu (array ($text),
46 array ('/plugins/helloworld/index.php' . $param ));
49 } elseif ($hookname == "groupmenu") {
50 $group_id=$params['group'];
51 $project = group_get_object($group_id);
52 if (!$project || !is_object($project)) {
55 if ($project->isError()) {
58 if (!$project->isProject()) {
61 if ( $project->usesPlugin ( $this->name ) ) {
62 $params['TITLES'][]=$this->text;
63 $params['DIRS'][]=util_make_url ('/plugins/helloworld/index.php?type=group&id=' . $group_id . "&pluginname=" . $this->name) ; // we indicate the part we're calling is the project one
65 $params['TITLES'][]=$this->text." is [Off]";
68 (($params['toptab'] == $this->name) ? $params['selected']=(count($params['TITLES'])-1) : '' );
69 } elseif ($hookname == "groupisactivecheckbox") {
70 //Check if the group is active
71 // this code creates the checkbox in the project edit public info page to activate/deactivate the plugin
72 $group_id=$params['group'];
73 $group = group_get_object($group_id);
76 echo ' <input type="checkbox" name="use_helloworldplugin" value="1" ';
77 // checked or unchecked?
78 if ( $group->usesPlugin ( $this->name ) ) {
84 echo "<strong>Use ".$this->text." Plugin</strong>";
87 } elseif ($hookname == "groupisactivecheckboxpost") {
88 // this code actually activates/deactivates the plugin after the form was submitted in the project edit public info page
89 $group_id=$params['group'];
90 $group = group_get_object($group_id);
91 $use_helloworldplugin = getStringFromRequest('use_helloworldplugin');
92 if ( $use_helloworldplugin == 1 ) {
93 $group->setPluginUse ( $this->name );
95 $group->setPluginUse ( $this->name, false );
97 } elseif ($hookname == "user_personal_links") {
98 // this displays the link in the user's profile page to it's personal HelloWorld (if you want other sto access it, youll have to change the permissions in the index.php
99 $userid = $params['user_id'];
100 $user = user_get_object($userid);
101 $text = $params['text'];
102 //check if the user has the plugin activated
103 if ($user->usesPlugin($this->name)) {
105 echo util_make_link ("/plugins/helloworld/index.php?id=$userid&type=user&pluginname=".$this->name,
106 _('View Personal HelloWorld')
110 } elseif ($hookname == "project_admin_plugins") {
111 // this displays the link in the project admin options page to it's HelloWorld administration
112 $group_id = $params['group_id'];
113 $group = group_get_object($group_id);
114 if ( $group->usesPlugin ( $this->name ) ) {
115 echo '<p>'.util_make_link ("/plugins/helloworld/admin/index.php?id=".$group->getID().'&type=admin&pluginname='.$this->name,
116 _('HelloWorld Admin')).'</p>' ;
119 elseif ($hookname == "blahblahblah") {
127 // c-file-style: "bsd"