4 * quota_management plugin
6 * Daniel Perez <danielperez.arg@gmail.com>
8 * This is an example to watch things in action. You can obviously modify things and logic as you see fit
11 require_once('pre.php');
12 require_once ('plugins/quota_management/config.php');
14 // the header that displays for the user portion of the plugin
15 function quota_management_Project_Header($params) {
16 global $DOCUMENT_ROOT,$HTML,$id;
17 $params['toptab']='quota_management';
22 site_project_header($params);
25 // the header that displays for the project portion of the plugin
26 function quota_management_User_Header($params) {
27 global $DOCUMENT_ROOT,$HTML,$user_id;
28 $params['toptab']='quota_management';
29 $params['user']=$user_id;
33 site_user_header($params);
37 $user = session_get_user(); // get the session user
39 if (!$user || !is_object($user) || $user->isError() || !$user->isActive()) {
40 exit_error("Invalid User", "Cannot Process your request for this user.");
43 $type = getStringFromRequest('type');
44 $id = getStringFromRequest('id');
45 $pluginname = getStringFromRequest('pluginname');
48 exit_error("Cannot Process your request","No TYPE specified"); // you can create items in Base.tab and customize this messages
50 exit_error("Cannot Process your request","No ID specified");
52 if ($type == 'group') {
53 $group = group_get_object($id);
55 exit_error("Invalid Project", "Inexistent Project");
57 if ( ! ($group->usesPlugin ( $pluginname )) ) {//check if the group has the quota_management plugin active
58 exit_error("Error", "First activate the $pluginname plugin through the Project's Admin Interface");
60 $userperm = $group->getPermission($user);//we´ll check if the user belongs to the group (optional)
61 if ( !$userperm->IsMember()) {
62 exit_error("Access Denied", "You are not a member of this project");
64 // other perms checks here...
65 quota_management_Project_Header(array('title'=>$pluginname . ' Project Plugin!','pagename'=>"$pluginname",'sectionvals'=>array(group_getname($id))));
66 // DO THE STUFF FOR THE PROJECT PART HERE
67 echo "We are in the Project quota_management plugin <br>";
68 echo "Greetings from planet " . $world; // $world comes from the config file in /etc
69 } elseif ($type == 'user') {
70 $realuser = user_get_object($id);//
71 if (!($realuser) || !($realuser->usesPlugin($pluginname))) {
72 exit_error("Error", "First activate the User's $pluginname plugin through Account Manteinance Page");
74 if ( (!$user) || ($user->getID() != $id)) { // if someone else tried to access the private quota_management part of this user
75 exit_error("Access Denied", "You cannot access other user's personal $pluginname");
77 quota_management_User_Header(array('title'=>'My '.$pluginname,'pagename'=>"$pluginname",'sectionvals'=>array($realuser->getUnixName())));
78 // DO THE STUFF FOR THE USER PART HERE
79 echo "We are in the User quota_management plugin <br>";
80 echo "Greetings from planet " . $world; // $world comes from the config file in /etc
81 } elseif ($type == 'admin') {
82 $group = group_get_object($id);
84 exit_error("Invalid Project", "Inexistent Project");
86 if ( ! ($group->usesPlugin ( $pluginname )) ) {//check if the group has the quota_management plugin active
87 exit_error("Error", "First activate the $pluginname plugin through the Project's Admin Interface");
89 $userperm = $group->getPermission($user);//we´ll check if the user belongs to the group
90 if ( !$userperm->IsMember()) {
91 exit_error("Access Denied", "You are not a member of this project");
93 //only project admin can access here
94 if ( $userperm->isAdmin() ) {
95 quota_management_Project_Header(array('title'=>$pluginname . ' Project Plugin!','pagename'=>"$pluginname",'sectionvals'=>array(group_getname($id))));
96 // DO THE STUFF FOR THE PROJECT ADMINISTRATION PART HERE
97 echo "We are in the Project quota_management plugin <font color=\"#ff0000\">ADMINISTRATION</font> <br>";
98 echo "Greetings from planet " . $world; // $world comes from the config file in /etc
100 exit_error("Access Denied", "You are not a project Admin");
105 site_project_footer(array());
109 // c-file-style: "bsd"