ILIAS
release_5-4 Revision v5.4.26-12-gabc799a52e6
◀ ilDoc Overview
class.ilRegistrationEmailRoleAssignments.php
Go to the documentation of this file.
1
<?
php
2
/*
3
+-----------------------------------------------------------------------------+
4
| ILIAS open source |
5
+-----------------------------------------------------------------------------+
6
| Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7
| |
8
| This program is free software; you can redistribute it and/or |
9
| modify it under the terms of the GNU General Public License |
10
| as published by the Free Software Foundation; either version 2 |
11
| of the License, or (at your option) any later version. |
12
| |
13
| This program is distributed in the hope that it will be useful, |
14
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
15
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16
| GNU General Public License for more details. |
17
| |
18
| You should have received a copy of the GNU General Public License |
19
| along with this program; if not, write to the Free Software |
20
| Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21
+-----------------------------------------------------------------------------+
22
*/
23
33
define(
'IL_REG_MISSING_DOMAIN'
, 1);
34
define(
'IL_REG_MISSING_ROLE'
, 2);
35
36
class
ilRegistrationRoleAssignments
37
{
38
public
$assignments
= array();
39
public
$default_role
= 0;
40
41
public
function
__construct
()
42
{
43
global
$DIC
;
44
45
$ilDB
= $DIC[
'ilDB'
];
46
47
$this->db =
$ilDB
;
48
$this->
__read
();
49
}
50
51
public
function
getRoleByEmail
($a_email)
52
{
53
global
$DIC
;
54
55
$ilObjDataCache = $DIC[
'ilObjDataCache'
];
56
57
foreach
($this->assignments as $assignment) {
58
if
(!$assignment[
'domain'
]
or
!$assignment[
'role'
]) {
59
continue
;
60
}
61
if
(stristr($a_email, $assignment[
'domain'
])) {
62
// check if role exists
63
if
(!$ilObjDataCache->lookupType($assignment[
'role'
])) {
64
continue
;
65
}
66
return
$assignment[
'role'
];
67
}
68
}
69
// return default
70
return
$this->
getDefaultRole
();
71
}
72
73
public
function
getAssignments
()
74
{
75
return
$this->assignments ? $this->assignments : array();
76
}
77
78
public
function
setDomain
($a_id, $a_domain)
79
{
80
$this->assignments[$a_id][
'domain'
] = $a_domain;
81
}
82
public
function
setRole
($a_id, $a_role)
83
{
84
$this->assignments[$a_id][
'role'
] = $a_role;
85
}
86
87
public
function
getDefaultRole
()
88
{
89
return
$this->default_role
;
90
}
91
public
function
setDefaultRole
($a_role_id)
92
{
93
$this->default_role = $a_role_id;
94
}
95
96
public
function
delete
($a_id)
97
{
98
global
$DIC
;
99
100
$ilDB
= $DIC[
'ilDB'
];
101
102
$query
=
"DELETE FROM reg_er_assignments "
.
103
"WHERE assignment_id = "
.
$ilDB
->quote($a_id,
'integer'
);
104
$res
=
$ilDB
->manipulate(
$query
);
105
$this->
__read
();
106
return
true
;
107
}
108
109
public
function
add
()
110
{
111
global
$DIC
;
112
113
$ilDB
= $DIC[
'ilDB'
];
114
115
$next_id =
$ilDB
->nextId(
'reg_er_assignments'
);
116
$query
=
"INSERT INTO reg_er_assignments (assignment_id,domain,role) "
.
117
"VALUES( "
.
118
$ilDB
->quote($next_id,
'integer'
) .
', '
.
119
$ilDB
->quote(
''
,
'text'
) .
", "
.
120
$ilDB
->quote(0,
'integer'
) .
121
")"
;
122
$res
=
$ilDB
->manipulate(
$query
);
123
$this->
__read
();
124
return
true
;
125
}
126
127
public
function
save
()
128
{
129
global
$DIC
;
130
131
$ilias = $DIC[
'ilias'
];
132
$ilDB
= $DIC[
'ilDB'
];
133
134
// Save default role
135
$ilias->setSetting(
'reg_default_role'
, $this->
getDefaultRole
());
136
137
foreach
($this->assignments as $assignment) {
138
$query
=
"UPDATE reg_er_assignments "
.
139
"SET domain = "
.
$ilDB
->quote($assignment[
'domain'
],
'text'
) .
", "
.
140
"role = "
.
$ilDB
->quote($assignment[
'role'
],
'integer'
) .
" "
.
141
"WHERE assignment_id = "
.
$ilDB
->quote($assignment[
'id'
],
'integer'
);
142
$res
=
$ilDB
->manipulate(
$query
);
143
}
144
return
true
;
145
}
146
147
public
function
validate
()
148
{
149
foreach
($this->assignments as $assignment) {
150
if
(!strlen($assignment[
'domain'
])) {
151
return
IL_REG_MISSING_DOMAIN
;
152
}
153
if
(!$assignment[
'role'
]) {
154
return
IL_REG_MISSING_ROLE
;
155
}
156
}
157
if
(!$this->
getDefaultRole
()) {
158
return
IL_REG_MISSING_ROLE
;
159
}
160
return
0;
161
}
162
163
164
165
166
// Private
167
public
function
__read
()
168
{
169
global
$DIC
;
170
171
$ilias = $DIC[
'ilias'
];
172
$ilDB
= $DIC[
'ilDB'
];
173
174
$query
=
"SELECT * FROM reg_er_assignments "
;
175
$res
= $this->db->query(
$query
);
176
177
$this->assignments = array();
178
while
(
$row
=
$res
->fetchRow(
ilDBConstants::FETCHMODE_OBJECT
)) {
179
$this->assignments[
$row
->assignment_id][
'id'
] =
$row
->assignment_id;
180
$this->assignments[
$row
->assignment_id][
'role'
] =
$row
->role;
181
$this->assignments[
$row
->assignment_id][
'domain'
] =
$row
->domain;
182
}
183
184
$this->default_role = $ilias->getSetting(
'reg_default_role'
);
185
186
return
true
;
187
}
188
}
ilRegistrationRoleAssignments\save
save()
Definition:
class.ilRegistrationEmailRoleAssignments.php:127
ilRegistrationRoleAssignments\$default_role
$default_role
Definition:
class.ilRegistrationEmailRoleAssignments.php:39
ilRegistrationRoleAssignments\setDomain
setDomain($a_id, $a_domain)
Definition:
class.ilRegistrationEmailRoleAssignments.php:78
$DIC
global $DIC
Definition:
saml.php:7
ilRegistrationRoleAssignments
Definition:
class.ilRegistrationEmailRoleAssignments.php:36
IL_REG_MISSING_ROLE
const IL_REG_MISSING_ROLE
Definition:
class.ilRegistrationEmailRoleAssignments.php:34
ilRegistrationRoleAssignments\setDefaultRole
setDefaultRole($a_role_id)
Definition:
class.ilRegistrationEmailRoleAssignments.php:91
ilRegistrationRoleAssignments\setRole
setRole($a_id, $a_role)
Definition:
class.ilRegistrationEmailRoleAssignments.php:82
$res
foreach($_POST as $key=> $value) $res
Definition:
save_question_post_data.php:15
ilRegistrationRoleAssignments\getRoleByEmail
getRoleByEmail($a_email)
Definition:
class.ilRegistrationEmailRoleAssignments.php:51
ilRegistrationRoleAssignments\$assignments
$assignments
Definition:
class.ilRegistrationEmailRoleAssignments.php:38
IL_REG_MISSING_DOMAIN
const IL_REG_MISSING_DOMAIN
Class class.ilregistrationEmailRoleAssignments.
Definition:
class.ilRegistrationEmailRoleAssignments.php:33
$query
$query
Definition:
proxy_ylocal.php:13
ilRegistrationRoleAssignments\add
add()
Definition:
class.ilRegistrationEmailRoleAssignments.php:109
ilRegistrationRoleAssignments\getDefaultRole
getDefaultRole()
Definition:
class.ilRegistrationEmailRoleAssignments.php:87
$row
$row
Definition:
migrateto20.php:360
ilRegistrationRoleAssignments\validate
validate()
Definition:
class.ilRegistrationEmailRoleAssignments.php:147
$ilDB
global $ilDB
Definition:
storeScorm2004.php:16
ilRegistrationRoleAssignments\__construct
__construct()
Definition:
class.ilRegistrationEmailRoleAssignments.php:41
ilRegistrationRoleAssignments\__read
__read()
Definition:
class.ilRegistrationEmailRoleAssignments.php:167
php
ilDBConstants\FETCHMODE_OBJECT
const FETCHMODE_OBJECT
Definition:
class.ilDBConstants.php:13
or
ilRegistrationRoleAssignments\getAssignments
getAssignments()
Definition:
class.ilRegistrationEmailRoleAssignments.php:73
Services
Registration
classes
class.ilRegistrationEmailRoleAssignments.php
Generated on Thu Feb 27 2025 19:02:03 for ILIAS by
1.8.13 (using
Doxyfile
)