forked from mantisbt-plugins/GoogleOauth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GoogleOauth.php
executable file
·55 lines (45 loc) · 1.18 KB
/
GoogleOauth.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
<?php
class GoogleOauthPlugin extends MantisPlugin {
var $cmv_pages;
var $current_page;
function register() {
$this->name = 'Google Authentication Module';
$this->description = 'Add Google authentication to MantisBT.';
$this->page = 'config';
$this->version = '2.0';
$this->requires = array(
'MantisCore' => '2.0.0',
);
$this->author = 'Alleen Wang';
$this->contact = '[email protected]';
$this->url = 'http://alleen.tw';
}
function init() {
$this->cmv_pages = array(
'login_page.php'
);
$this->current_page = basename( $_SERVER['PHP_SELF'] );
}
function hooks() {
return array(
'EVENT_LAYOUT_RESOURCES' => 'resources'
);
}
function config() {
return array(
'clientId' => '',
'clientSecret' => '',
'redirect_uri' => '',
);
}
function resources() {
if ( ! in_array( $this->current_page, $this->cmv_pages ) ) {
return '';
}
return '
<meta name="redirectUri" content="' . plugin_config_get( 'redirect_uri' ) . '" />
<meta name="clientId" content="' . plugin_config_get( 'clientId' ) . '" />
<script type="text/javascript" src="plugins/GoogleOauth/pages/assets/js/plugin.js"></script>
';
}
}