-
Notifications
You must be signed in to change notification settings - Fork 0
/
locallib.php
79 lines (72 loc) · 2.54 KB
/
locallib.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php defined('MOODLE_INTERNAL') || die();
function eklaseoauth_convert_to_eu_data($data)
{
$eudata = array();
if (isset($data['persontype'])) {
$role = $data['persontype'];
switch ($role) {
case ROLE_STUDENT:
case ROLE_TEACHER:
$school = (isset($data['school']) && !empty($data['school'])) ? $data['school'] : '';
$convertedschools = eu_convert_to_schools($school);
if (ROLE_STUDENT === $role && !empty($convertedschools['schools'])) {
$classlevel = isset($data['classlevel']) ? $data['classlevel'] : '';
if (!$classname = eu_convert_to_classname($classlevel)) {
error_log('[auth/eklase] Failed to get class number. Userdata: ' . serialize($data));
}
$convertedschools['schools'][0]->entities = array($classname);
}
break;
case ROLE_PARENT:
break;
default:
}
$eudata[$role] = isset($convertedschools) ? $convertedschools : array();
}
return $eudata;
}
class eklase_moodle_url extends moodle_url
{
private $eklaseurl;
public function __construct($url, array $params = null)
{
parent::__construct($url);
$this->eklaseurl = $url;
}
/**
* @param bool $escaped
* @param array $overrideparams
* @return string
*/
public function get_query_string($escaped = true, array $overrideparams = null)
{
$arr = array();
if ($overrideparams !== null) {
$params = $this->merge_overrideparams($overrideparams);
} else {
$params = $this->params;
}
foreach ($params as $key => $val) {
if (!empty($val)) {
if (is_array($val)) {
foreach ($val as $index => $value) {
$arr[] = rawurlencode($key . '[' . $index . ']') . "=" . rawurlencode($value);
}
} else {
$arr[] = rawurlencode($key) . "=" . rawurlencode($val);
}
// ja ir atribūta nosaukums, bet nav vērtības
} else {
// pārbauda vai atribūta nosaukums beidzas uz '/'
if (strpos(substr($key, 0, -1), '/') !== 0) {
$arr[] = $key;
}
}
}
if ($escaped) {
return implode('&', $arr);
} else {
return implode('&', $arr);
}
}
}