Beispiel #1
0
 public function __construct()
 {
     // HACK : force loading translation here to avoid having to rewrite the kernel !
     language::load_translation();
     $this->header = ClaroHeader::getInstance();
     $this->body = ClaroBody::getInstance();
     $this->banner = ClaroBanner::getInstance();
     $this->footer = ClaroFooter::getInstance();
 }
// As we are trying to get the authorization of a particular user, it works better if this one is logged in.
if (!claro_is_user_authenticated()) {
    claro_disp_auth_form();
}
// Initialization of the OAuth Server.
require_once __DIR__ . '/lib/InitServer.php';
// Set up the request from the Globals.
$request = OAuth2\Request::createFromGlobals();
$response = new OAuth2\Response();
// Submit the request to the OAuth server. In particular, the server check that the client asking access is well registered,
// all the requested parameters are presents and the scope, if any, is valid.
if (!$server->validateAuthorizeRequest($request, $response)) {
    $response->send();
    die;
}
// If POST is empty, we know that the user has not authorized the client yet. So we show the form.
if (empty($_POST)) {
    // Get the client name from the Storage.
    $client_name = $server->getStorage('client')->getClientDetails($request->query('client_id'))['client_name'];
    $template = new ModuleTemplate($tlabelReq, 'authorization_form.tpl.php');
    $template->assign('clientName', $client_name);
    ClaroBody::getInstance()->appendContent($template->render());
    echo Claroline::getDisplay()->render();
} else {
    // is_authorized is TRUE iff the user clicked "Yes" on the Authorization Form.
    $is_authorized = isset($_POST['authorized']);
    // If the client is authorized, we can process and associate a freshly created Authorization Token to the user_id,
    // and return it to the client.
    $server->handleAuthorizeRequest($request, $response, $is_authorized, claro_get_current_user_id());
    $response->send();
}
Beispiel #3
0
        $dialogBox->question($question);
    }
    if ($cmd == 'exMerge') {
        $uidToKeep = $userInput->getMandatory('uidToKeep');
        $uidToRemove = $userInput->getMandatory('uidToRemove');
        if ($uidToKeep == $uidToRemove) {
            throw new Exception(get_lang('Cannot merge one user account with itself'));
        }
        if (!user_get_properties($uidToKeep)) {
            throw new Exception(get_lang('User to keep not found'));
        }
        if (!user_get_properties($uidToRemove)) {
            throw new Exception(get_lang('User to remove not found'));
        }
        $mergeUser = new MergeUser();
        $mergeUser->merge($uidToRemove, $uidToKeep);
        if ($mergeUser->hasError()) {
            $dialogBox->error(get_lang('Some errors have occured while merging those user account, check the log table in the platform main database for more details'));
        } else {
            $dialogBox->success(get_lang('User accounts merged'));
        }
    }
} catch (Exception $e) {
    $dialogBox->error(get_lang('Cannot perform the requested action') . ' : <br />' . $e->getMessage());
    pushClaroMessage('<pre>' . $e->__toString() . '</pre>');
}
ClaroBreadCrumbs::getInstance()->prepend(get_lang('Administration'), get_path('rootAdminWeb'));
ClaroBreadCrumbs::getInstance()->setCurrent(get_lang('Merge user accounts'), php_self());
ClaroBody::getInstance()->appendContent(claro_html_tool_title(get_lang('Merge user accounts')));
ClaroBody::getInstance()->appendContent($dialogBox->render());
echo Claroline::getInstance()->display->render();
Beispiel #4
0
 public static function getInstance()
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }