This repository has been archived by the owner on Sep 28, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
start.php
58 lines (45 loc) · 1.54 KB
/
start.php
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
<?php
/**
* This file is included when the plugin gets initialized
*/
use Elgg\Project\Paths;
use Elgg\Includer;
elgg_register_event_handler('plugins_boot', 'system', 'simplesaml_plugins_boot');
/**
* Called on the 'plugins_boot' 'system' event
*
* @return void
*/
function simplesaml_plugins_boot() {
$path = elgg_get_plugin_setting('simplesamlphp_path', 'simplesaml');
if (empty($path)) {
return;
}
$path = Paths::sanitize($path);
if (!file_exists("{$path}lib/_autoload.php")) {
return;
}
// register library
Includer::includeFile("{$path}lib/_autoload.php");
elgg_register_event_handler('init', 'system', 'simplesaml_init');
}
/**
* Called on the 'init' 'system' event
*
* @return void
*/
function simplesaml_init() {
// load libraries
Includer::requireFileOnce(dirname(__FILE__) . '/lib/functions.php');
// check for force authentication
elgg_extend_view('page/default', 'simplesaml/force_authentication', 200);
elgg_extend_view('page/walled_garden', 'simplesaml/force_authentication', 200);
// allow login
elgg_extend_view('forms/login', 'simplesaml/login');
// register events
elgg_register_event_handler('login:after', 'user', '\ColdTrick\SimpleSAML\Login::loginEvent');
// register plugin hooks
elgg_register_plugin_hook_handler('entity:url', 'object', '\ColdTrick\SimpleSAML\Widgets::widgetURL');
elgg_register_plugin_hook_handler('setting', 'plugin', '\ColdTrick\SimpleSAML\PluginSettings::saveSetting');
elgg_register_plugin_hook_handler('action:validate', 'logout', '\ColdTrick\SimpleSAML\Logout::action');
}