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
20 * along with FusionForge; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 ));
48 } elseif ($hookname == "groupmenu") {
49 $group_id=$params['group'];
50 $project = &group_get_object($group_id);
51 if (!$project || !is_object($project)) {
54 if ($project->isError()) {
57 if (!$project->isProject()) {
60 if ( $project->usesPlugin ( $this->name ) ) {
61 $params['TITLES'][]=$this->text;
62 $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
64 $params['TITLES'][]=$this->text." is [Off]";
67 (($params['toptab'] == $this->name) ? $params['selected']=(count($params['TITLES'])-1) : '' );
68 } elseif ($hookname == "groupisactivecheckbox") {
69 //Check if the group is active
70 // this code creates the checkbox in the project edit public info page to activate/deactivate the plugin
71 $group_id=$params['group'];
72 $group = &group_get_object($group_id);
75 echo ' <input type="checkbox" name="use_helloworldplugin" value="1" ';
76 // checked or unchecked?
77 if ( $group->usesPlugin ( $this->name ) ) {
83 echo "<strong>Use ".$this->text." Plugin</strong>";
86 } elseif ($hookname == "groupisactivecheckboxpost") {
87 // this code actually activates/deactivates the plugin after the form was submitted in the project edit public info page
88 $group_id=$params['group'];
89 $group = &group_get_object($group_id);
90 $use_helloworldplugin = getStringFromRequest('use_helloworldplugin');
91 if ( $use_helloworldplugin == 1 ) {
92 $group->setPluginUse ( $this->name );
94 $group->setPluginUse ( $this->name, false );
96 } elseif ($hookname == "userisactivecheckbox") {
97 //check if user is active
98 // this code creates the checkbox in the user account manteinance page to activate/deactivate the plugin
99 $user = $params['user'];
102 echo ' <input type="checkbox" name="use_helloworldplugin" value="1" ';
103 // checked or unchecked?
104 if ( $user->usesPlugin ( $this->name ) ) {
107 echo " /> Use ".$this->text." Plugin";
110 } elseif ($hookname == "userisactivecheckboxpost") {
111 // this code actually activates/deactivates the plugin after the form was submitted in the user account manteinance page
112 $user = $params['user'];
113 $use_helloworldplugin = getStringFromRequest('use_helloworldplugin');
114 if ( $use_helloworldplugin == 1 ) {
115 $user->setPluginUse ( $this->name );
117 $user->setPluginUse ( $this->name, false );
121 echo ' <input type="checkbox" name="use_helloworldplugin" value="1" ';
122 // checked or unchecked?
123 if ( $user->usesPlugin ( $this->name ) ) {
126 echo " /> Use ".$this->text." Plugin";
129 } elseif ($hookname == "user_personal_links") {
130 // 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
131 $userid = $params['user_id'];
132 $user = user_get_object($userid);
133 $text = $params['text'];
134 //check if the user has the plugin activated
135 if ($user->usesPlugin($this->name)) {
137 echo util_make_link ("/plugins/helloworld/index.php?id=$userid&type=user&pluginname=".$this->name,
138 _('View Personal HelloWorld')
142 } elseif ($hookname == "project_admin_plugins") {
143 // this displays the link in the project admin options page to it's HelloWorld administration
144 $group_id = $params['group_id'];
145 $group = &group_get_object($group_id);
146 if ( $group->usesPlugin ( $this->name ) ) {
147 echo util_make_link ("/plugins/helloworld/admin/index.php?id=".$group->getID().'&type=admin&pluginname='.$this->name,
148 _('View the HelloWorld Administration')) ;
152 elseif ($hookname == "blahblahblah") {
160 // c-file-style: "bsd"