Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
153669e6
Commit
153669e6
authored
Jan 04, 2012
by
Francois Marier
Committed by
Gerrit Code Review
Jan 04, 2012
Browse files
Merge "Allow auth plugins to provide extra login form javascript"
parents
e90ff142
8228bbcb
Changes
1
Hide whitespace changes
Inline
Side-by-side
htdocs/auth/lib.php
View file @
153669e6
...
...
@@ -1092,7 +1092,7 @@ function get_login_form_js($form) {
$form
=
str_replace
(
'/'
,
'\/'
,
str_replace
(
"'"
,
"\'"
,
(
str_replace
(
array
(
"
\n
"
,
"
\t
"
),
''
,
$form
))));
$strcookiesnotenabled
=
json_encode
(
get_string
(
'cookiesnotenabled'
));
$cookiename
=
get_config
(
'cookieprefix'
)
.
'ctest'
;
return
<<<EOF
$js
=
<<<
EOF
<
script
type
=
"text/javascript"
>
var
loginbox
=
$
(
'loginform_container'
);
document
.
cookie
=
"
$cookiename
=1"
;
...
...
@@ -1105,6 +1105,47 @@ else {
}
</
script
>
EOF
;
$authplugins
=
auth_get_enabled_auth_plugins
();
foreach
(
$authplugins
as
$plugin
)
{
$classname
=
'PluginAuth'
.
ucfirst
(
strtolower
(
$plugin
));
$pluginjs
=
call_static_method
(
$classname
,
'login_form_js'
);
if
(
!
empty
(
$pluginjs
))
{
$js
.
=
$pluginjs
;
}
}
return
$js
;
}
/**
* Return a list of all enabled and usable auth plugins.
*/
function
auth_get_enabled_auth_plugins
()
{
$sql
=
'SELECT
DISTINCT(authname)
FROM
{auth_instance} ai
JOIN
{institution} i ON ai.institution = i.name
JOIN
{auth_installed} inst ON inst.name = ai.authname
WHERE
i.suspended = 0 AND
inst.active = 1'
;
$authplugins
=
get_column_sql
(
$sql
);
$usableplugins
=
array
();
foreach
(
$authplugins
as
$plugin
)
{
safe_require
(
'auth'
,
strtolower
(
$plugin
));
$classname
=
'PluginAuth'
.
ucfirst
(
strtolower
(
$plugin
));
if
(
call_static_method
(
$classname
,
'is_usable'
))
{
$usableplugins
[]
=
$plugin
;
}
}
return
$usableplugins
;
}
...
...
@@ -1751,4 +1792,12 @@ class PluginAuth extends Plugin {
public
static
function
can_be_disabled
()
{
return
false
;
}
/**
* Can be overridden by plugins that need to inject more
* Javascript to make the login form work.
*/
public
static
function
login_form_js
()
{
return
false
;
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment