1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
<?php
/*
* SoapAdmin plugin
*
* Daniel Perez <danielperez.arg@gmail.com>
*
* This is an example to watch things in action. You can obviously modify things and logic as you see fit
*/
require_once '../../env.inc.php';
require_once $gfwww.'include/pre.php';
require_once $gfconfig.'plugins/soapadmin/config.php';
// the header that displays for the user portion of the plugin
function soapadmin_Project_Header($params) {
global $DOCUMENT_ROOT,$HTML,$id;
$params['toptab']='soapadmin';
$params['group']=$id;
/*
Show horizontal links
*/
site_project_header($params);
}
// the header that displays for the project portion of the plugin
function soapadmin_User_Header($params) {
global $DOCUMENT_ROOT,$HTML,$user_id;
$params['toptab']='soapadmin';
$params['user']=$user_id;
/*
Show horizontal links
*/
site_user_header($params);
}
$user = session_get_user(); // get the session user
if (!$user || !is_object($user) || $user->isError() || !$user->isActive()) {
exit_error("Invalid User", "Cannot Process your request for this user.");
}
$type = getStringFromRequest('type');
$id = getStringFromRequest('id');
$pluginname = getStringFromRequest('pluginname');
if (!$type) {
exit_error("Cannot Process your request","No TYPE specified"); // you can create items in Base.tab and customize this messages
} elseif (!$id) {
exit_error("Cannot Process your request","No ID specified");
} else {
if ($type == 'group') {
$group = group_get_object($id);
if ( !$group) {
exit_error("Invalid Project", "Inexistent Project");
}
if ( ! ($group->usesPlugin ( $pluginname )) ) {//check if the group has the SoapAdmin plugin active
exit_error("Error", "First activate the $pluginname plugin through the Project's Admin Interface");
}
$userperm = $group->getPermission();//we'll check if the user belongs to the group (optional)
if ( !$userperm->IsMember()) {
exit_error("Access Denied", "You are not a member of this project");
}
// other perms checks here...
soapadmin_Project_Header(array('title'=>$pluginname . ' Project Plugin!','pagename'=>"$pluginname",'sectionvals'=>array(group_getname($id))));
// DO THE STUFF FOR THE PROJECT PART HERE
echo "We are in the Project SoapAdmin plugin <br>";
echo "Greetings from planet " . $world; // $world comes from the config file in /etc
} elseif ($type == 'user') {
$realuser = user_get_object($id);//
if (!($realuser) || !($realuser->usesPlugin($pluginname))) {
exit_error("Error", "First activate the User's $pluginname plugin through Account Manteinance Page");
}
if ( (!$user) || ($user->getID() != $id)) { // if someone else tried to access the private SoapAdmin part of this user
exit_error("Access Denied", "You cannot access other user's personal $pluginname");
}
soapadmin_User_Header(array('title'=>'My '.$pluginname,'pagename'=>"$pluginname",'sectionvals'=>array($realuser->getUnixName())));
// DO THE STUFF FOR THE USER PART HERE
echo "We are in the User SoapAdmin plugin <br>";
echo "Greetings from planet " . $world; // $world comes from the config file in /etc
} elseif ($type == 'admin') {
$group = group_get_object($id);
if ( !$group) {
exit_error("Invalid Project", "Inexistent Project");
}
if ( ! ($group->usesPlugin ( $pluginname )) ) {//check if the group has the SoapAdmin plugin active
exit_error("Error", "First activate the $pluginname plugin through the Project's Admin Interface");
}
$userperm = $group->getPermission();//we'll check if the user belongs to the group
if ( !$userperm->IsMember()) {
exit_error("Access Denied", "You are not a member of this project");
}
//only project admin can access here
if ( $userperm->isAdmin() ) {
soapadmin_Project_Header(array('title'=>$pluginname . ' Project Plugin!','pagename'=>"$pluginname",'sectionvals'=>array(group_getname($id))));
// DO THE STUFF FOR THE PROJECT ADMINISTRATION PART HERE
echo "We are in the Project SoapAdmin plugin <font color=\"#ff0000\">ADMINISTRATION</font> <br>";
echo "Greetings from planet " . $world; // $world comes from the config file in /etc
} else {
exit_error("Access Denied", "You are not a project Admin");
}
}
}
site_project_footer(array());
// Local Variables:
// mode: php
// c-file-style: "bsd"
// End:
|