Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LabNbook
LabNbook-Moodle
Commits
1be7bd66
Commit
1be7bd66
authored
Feb 26, 2019
by
Francois Gannaz
Browse files
session::createAuthenticatedUrl()
parent
9a3c3633
Changes
1
Hide whitespace changes
Inline
Side-by-side
classes/session.php
View file @
1be7bd66
...
...
@@ -39,6 +39,9 @@ class mod_labnbook_session
private
$autoCreateUser
=
true
;
/**
* @return \mod_labnbook_session
*/
public
static
function
load
()
{
if
(
empty
(
self
::
$singleton
))
{
self
::
$singleton
=
new
self
;
...
...
@@ -53,6 +56,9 @@ class mod_labnbook_session
$this
->
userId
=
$this
->
fetchUserId
(
$USER
->
id
);
}
/**
* Empties the cache and session, so forces to fetch data from the LabNbook server.
*/
public
function
refresh
()
{
global
$SESSION
;
unset
(
$this
->
userId
);
...
...
@@ -76,6 +82,9 @@ class mod_labnbook_session
return
$this
->
userId
;
}
/**
* @return array mission[]
*/
public
function
getMissions
()
{
if
(
!
isset
(
$this
->
missions
))
{
$this
->
missions
=
$this
->
fetchMissions
();
...
...
@@ -83,10 +92,37 @@ class mod_labnbook_session
return
$this
->
missions
;
}
/**
* @global moodle_database $DB
*
* @param int $instanceId
* @return int|null
*/
public
function
instanceIdToMissionId
(
$instanceId
)
{
global
$DB
;
return
$DB
->
get_field
(
"labnbook"
,
"labnbook_missionid"
,
[
'id'
=>
$instanceId
]);
}
/**
* Return an URL that will authenticate the user in LabNbook
*
* @param string $urlPath final URL
* @return string URL with added parameters
*/
public
function
createAuthenticatedUrl
(
$urlPath
)
{
$params
=
[
'key'
=>
$this
->
secret
,
'userid'
=>
$this
->
getUserId
(),
'redirect'
=>
$urlPath
,
];
return
"
{
$this
->
url
}
'/auth/api/login.php?"
.
http_build_query
(
$params
);
}
/**
* @global moodle_database $DB
* @global object $SESSION
* @global object $USER
*
* @param boolean $force
* @return int
*/
...
...
@@ -121,6 +157,7 @@ class mod_labnbook_session
/**
* @global object $SESSION
*
* @param boolean $force
* @return array assoc: ID => name
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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