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('../../../env.inc.php');
12 require_once $gfwww.'include/pre.php';
13 require_once $gfconfig.'plugins/oslc/config.php';
15 // the header that displays for the user portion of the plugin
16 function oslc_Project_Header($params) {
17 global $DOCUMENT_ROOT,$HTML,$id;
18 $params['toptab']='oslc';
23 site_project_header($params);
26 // the header that displays for the project portion of the plugin
27 function oslc_User_Header($params) {
28 global $DOCUMENT_ROOT,$HTML,$user_id;
29 $params['toptab']='oslc';
30 $params['user']=$user_id;
34 site_user_header($params);
38 $user = session_get_user(); // get the session user
40 if (!$user || !is_object($user) || $user->isError() || !$user->isActive()) {
41 exit_error("Invalid User", "Cannot Process your request for this user.");
44 $type = getStringFromRequest('type');
45 $id = getStringFromRequest('id');
46 $pluginname = getStringFromRequest('pluginname');
49 exit_error("Cannot Process your request","No TYPE specified"); // you can create items in Base.tab and customize this messages
51 exit_error("Cannot Process your request","No ID specified");
53 if ($type == 'group') {
54 $group = group_get_object($id);
56 exit_error("Invalid Project", "Inexistent Project");
58 if ( ! ($group->usesPlugin ( $pluginname )) ) {//check if the group has the oslc plugin active
59 exit_error("Error", "First activate the $pluginname plugin through the Project's Admin Interface");
61 $userperm = $group->getPermission();//we'll check if the user belongs to the group (optional)
62 if ( !$userperm->IsMember()) {
63 exit_error("Access Denied", "You are not a member of this project");
65 // other perms checks here...
66 oslc_Project_Header(array('title'=>$pluginname . ' Project Plugin!','pagename'=>"$pluginname",'sectionvals'=>array(group_getname($id))));
67 // DO THE STUFF FOR THE PROJECT PART HERE
68 echo "We are in the Project oslc plugin <br>";
69 echo "Greetings from planet " . $world; // $world comes from the config file in /etc
70 } elseif ($type == 'user') {
71 $realuser = user_get_object($id);//
72 if (!($realuser) || !($realuser->usesPlugin($pluginname))) {
73 exit_error("Error", "First activate the User's $pluginname plugin through Account Manteinance Page");
75 if ( (!$user) || ($user->getID() != $id)) { // if someone else tried to access the private oslc part of this user
76 exit_error("Access Denied", "You cannot access other user's personal $pluginname");
78 oslc_User_Header(array('title'=>'My '.$pluginname,'pagename'=>"$pluginname",'sectionvals'=>array($realuser->getUnixName())));
79 // DO THE STUFF FOR THE USER PART HERE
80 echo "We are in the User oslc plugin <br>";
81 echo "Greetings from planet " . $world; // $world comes from the config file in /etc
82 } elseif ($type == 'admin') {
83 $group = group_get_object($id);
85 exit_error("Invalid Project", "Inexistent Project");
87 if ( ! ($group->usesPlugin ( $pluginname )) ) {//check if the group has the oslc plugin active
88 exit_error("Error", "First activate the $pluginname plugin through the Project's Admin Interface");
90 $userperm = $group->getPermission();//we'll check if the user belongs to the group
91 if ( !$userperm->IsMember()) {
92 exit_error("Access Denied", "You are not a member of this project");
94 //only project admin can access here
95 if ( $userperm->isAdmin() ) {
96 oslc_Project_Header(array('title'=>$pluginname . ' Project Plugin!','pagename'=>"$pluginname",'sectionvals'=>array(group_getname($id))));
97 // DO THE STUFF FOR THE PROJECT ADMINISTRATION PART HERE
98 echo "We are in the Project oslc plugin <font color=\"#ff0000\">ADMINISTRATION</font> <br>";
99 echo "Greetings from planet " . $world; // $world comes from the config file in /etc
101 exit_error("Access Denied", "You are not a project Admin");
106 site_project_footer(array());
110 // c-file-style: "bsd"