4 * This file contains the functionality of the different checks
5 * needed to be done before displaying any page of the
9 require_once $gfwww.'include/pre.php';
11 $pluginname = 'oauthconsumer';
12 // the header that displays for the user portion of the plugin
13 function oauthconsumer_User_Header($params) {
14 global $DOCUMENT_ROOT,$HTML, $user_id, $pluginname;
15 $params['toptab']=$pluginname;
16 $params['user']=$user_id;
17 site_user_header($params);
21 * checks whether the user is logged in and has activated the plugin
23 function oauthconsumer_CheckUser() {
25 if (!session_loggedin()) { //check if user logged in
31 $user = session_get_user(); // get the session user
33 if (!$user || !is_object($user) || $user->isError() || !$user->isActive()) {
34 exit_error("Invalid User, Cannot Process your request for this user.", $pluginname);
40 exit_error("Cannot Process your request: Invalid User", $pluginname);
43 $realuser = user_get_object($id);
44 if (!($realuser) || !($realuser->usesPlugin($pluginname))) { //check if user has activated the plugin
45 exit_error("First activate the User's $pluginname plugin through Account Maintenance Page", $pluginname);
48 //displays the page header
49 oauthconsumer_User_Header(array('title'=>'Personal page for OAuth','pagename'=>"$pluginname",'sectionvals'=>array($realuser->getUnixName())));
54 * checks whether the user is a forge admin
56 function oauthconsumer_CheckForgeAdmin() {
58 if(! forge_check_global_perm ('forge_admin')) {
62 oauthconsumer_User_Header(array('title'=>'Admin page for OAuthConsumer','pagename'=>"$pluginname"));
67 * checks whether the user is a forge admin and exits
69 function oauthconsumer_CheckForgeAdminExit() {
71 if(! forge_check_global_perm ('forge_admin')) {
72 exit_error("Access Denied, You are not a forge Admin", 'oauthconsumer');
75 oauthconsumer_User_Header(array('title'=>'Admin page for OAuthConsumer','pagename'=>"$pluginname"));