4 * quota_managementPlugin Class
7 * This file is part of GForge.
9 * GForge 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 * GForge 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 GForge; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 class quota_managementPlugin extends Plugin {
25 function quota_managementPlugin () {
27 $this->name = "quota_management" ;
28 $this->text = "quota_management!" ; // To show in the tabs, use...
29 $this->hooks[] = "user_personal_links";//to make a link to the user´s personal part of the plugin
30 $this->hooks[] = "usermenu" ;
31 $this->hooks[] = "groupmenu" ; // To put into the project tabs
32 $this->hooks[] = "groupisactivecheckbox" ; // The "use ..." checkbox in editgroupinfo
33 $this->hooks[] = "groupisactivecheckboxpost" ; //
34 $this->hooks[] = "userisactivecheckbox" ; // The "use ..." checkbox in user account
35 $this->hooks[] = "userisactivecheckboxpost" ; //
36 $this->hooks[] = "project_admin_plugins"; // to show up in the admin page fro group
37 $this->hooks[] = "site_admin_option_hook"; // to show in admin
38 $this->hooks[] = "quota_label_project_admin"; // to show in admin project
39 $this->hooks[] = "quota_link_project_admin"; // to show in admin project
42 function CallHook ($hookname, $params) {
43 global $use_quota_managementplugin,$G_SESSION,$HTML,$Language;
44 if ($hookname == "usermenu") {
45 $text = $this->text; // this is what shows in the tab
46 if ($G_SESSION->usesPlugin("quota_management")) {
47 $param = '?type=user&id=' . $G_SESSION->getId() . "&pluginname=" . $this->name; // we indicate the part we´re calling is the user one
48 echo ' | ' . $HTML->PrintSubMenu (array ($text),
49 array ('/plugins/quota_management/index.php' . $param ));
51 } elseif ($hookname == "groupmenu") {
52 $group_id=$params['group'];
53 $project = &group_get_object($group_id);
54 if (!$project || !is_object($project)) {
57 if ($project->isError()) {
60 if (!$project->isProject()) {
63 if ( $project->usesPlugin ( $this->name ) ) {
64 $params['TITLES'][]=$this->text;
65 $params['DIRS'][]='/plugins/quota_management/index.php?type=group&id=' . $group_id . "&pluginname=" . $this->name; // we indicate the part we´re calling is the project one
67 // $params['TITLES'][]=$this->text." is [Off]";
69 (($params['toptab'] == $this->name) ? $params['selected']=(count($params['TITLES'])-1) : '' );
70 } elseif ($hookname == "groupisactivecheckbox") {
71 //Check if the group is active
72 } elseif ($hookname == "groupisactivecheckboxpost") {
73 // this code actually activates/deactivates the plugin after the form was submitted in the project edit public info page
74 $group_id=$params['group'];
75 $group = &group_get_object($group_id);
76 $use_quota_managementplugin = getStringFromRequest('use_quota_managementplugin');
77 if ( $use_quota_managementplugin == 1 ) {
78 $group->setPluginUse ( $this->name );
80 $group->setPluginUse ( $this->name, false );
82 } elseif ($hookname == "userisactivecheckbox") {
83 //check if user is active
84 // this code creates the checkbox in the user account manteinance page to activate/deactivate the plugin
85 $user = $params['user'];
88 echo ' <input type="CHECKBOX" name="use_quota_managementplugin" value="1" ';
89 // CHECKED OR UNCHECKED?
90 if ( $user->usesPlugin ( $this->name ) ) {
93 echo "> Use ".$this->text." Plugin";
96 } elseif ($hookname == "userisactivecheckboxpost") {
97 // this code actually activates/deactivates the plugin after the form was submitted in the user account manteinance page
98 $user = $params['user'];
99 $use_quota_managementplugin = getStringFromRequest('use_quota_managementplugin');
100 if ( $use_quota_managementplugin == 1 ) {
101 $user->setPluginUse ( $this->name );
103 $user->setPluginUse ( $this->name, false );
107 echo ' <input type="CHECKBOX" name="use_quota_managementplugin" value="1" ';
108 // CHECKED OR UNCHECKED?
109 if ( $user->usesPlugin ( $this->name ) ) {
112 echo "> Use ".$this->text." Plugin";
115 } elseif ($hookname == "user_personal_links") {
117 // this displays the link in the user´s profile page to it´s personal quota_management (if you want other sto access it, youll have to change the permissions in the index.php
118 $userid = $params['user_id'];
119 $user = user_get_object($userid);
120 $text = $params['text'];
121 //check if the user has the plugin activated
122 if ($user->usesPlugin($this->name)) {
124 <a href="/plugins/quota_management/index.php?id=' . $userid . '&type=user&pluginname=' . $this->name . '">' . _('View Personal quota_management') .'</a></p>';
126 } elseif ($hookname == "project_admin_plugins") {
128 // this displays the link in the project admin options page to it´s quota_management administration
129 $group_id = $params['group_id'];
130 $group = &group_get_object($group_id);
131 if ( $group->usesPlugin ( $this->name ) ) {
132 echo '<a href="/plugins/quota_management/index.php?id=' . $group->getID() . '&type=admin&pluginname=' . $this->name . '">' . _('View the quota_management Administration') . '</a><br />';
135 elseif ($hookname == "blahblahblah") {
138 elseif ($hookname == "site_admin_option_hook") {
139 // www/admin/index.php line 167
142 <li><a href="/plugins/quota_management/quota.php"><?php echo _('Ressources usage and quota'); ?></a></li>
145 elseif ($hookname == "quota_label_project_admin") {
146 // www/project/admin/project_admin_utils.php line 80
147 $labels[] = _('Quota');
149 elseif ($hookname == "quota_link_project_admin") {
150 // www/project/admin/project_admin_utils.php line 99
151 $group_id=$params['group'];
152 $links[] = '/plugins/quota_management/quota.php?group_id='.$group_id;
159 // c-file-style: "bsd"