ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilRegistrationRoleAssignments Class Reference
+ Collaboration diagram for ilRegistrationRoleAssignments:

Public Member Functions

 __construct ()
 
 getRoleByEmail ($a_email)
 
 getAssignments ()
 
 setDomain ($a_id, $a_domain)
 
 setRole ($a_id, $a_role)
 
 getDefaultRole ()
 
 setDefaultRole ($a_role_id)
 
 delete ($a_id)
 
 add ()
 
 save ()
 
 validate ()
 
 __read ()
 

Data Fields

 $assignments = array()
 
 $default_role = 0
 

Detailed Description

Definition at line 36 of file class.ilRegistrationEmailRoleAssignments.php.

Constructor & Destructor Documentation

◆ __construct()

ilRegistrationRoleAssignments::__construct ( )

Definition at line 41 of file class.ilRegistrationEmailRoleAssignments.php.

42 {
43 global $DIC;
44
45 $ilDB = $DIC['ilDB'];
46
47 $this->db = $ilDB;
48 $this->__read();
49 }
global $DIC
Definition: saml.php:7
global $ilDB

References $DIC, $ilDB, and __read().

+ Here is the call graph for this function:

Member Function Documentation

◆ __read()

ilRegistrationRoleAssignments::__read ( )

Definition at line 167 of file class.ilRegistrationEmailRoleAssignments.php.

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 }
$row
$query
foreach($_POST as $key=> $value) $res

References $DIC, $ilDB, $query, $res, $row, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by __construct(), add(), and delete().

+ Here is the caller graph for this function:

◆ add()

ilRegistrationRoleAssignments::add ( )

Definition at line 109 of file class.ilRegistrationEmailRoleAssignments.php.

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 }

References $DIC, $ilDB, $query, $res, and __read().

+ Here is the call graph for this function:

◆ delete()

ilRegistrationRoleAssignments::delete (   $a_id)

Definition at line 96 of file class.ilRegistrationEmailRoleAssignments.php.

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 }

References $DIC, $ilDB, $query, $res, and __read().

+ Here is the call graph for this function:

◆ getAssignments()

ilRegistrationRoleAssignments::getAssignments ( )

Definition at line 73 of file class.ilRegistrationEmailRoleAssignments.php.

74 {
75 return $this->assignments ? $this->assignments : array();
76 }

◆ getDefaultRole()

ilRegistrationRoleAssignments::getDefaultRole ( )

Definition at line 87 of file class.ilRegistrationEmailRoleAssignments.php.

References $default_role.

Referenced by getRoleByEmail(), save(), and validate().

+ Here is the caller graph for this function:

◆ getRoleByEmail()

ilRegistrationRoleAssignments::getRoleByEmail (   $a_email)

Definition at line 51 of file class.ilRegistrationEmailRoleAssignments.php.

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 }

References $DIC, and getDefaultRole().

+ Here is the call graph for this function:

◆ save()

ilRegistrationRoleAssignments::save ( )

Definition at line 127 of file class.ilRegistrationEmailRoleAssignments.php.

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 }

References $DIC, $ilDB, $query, $res, and getDefaultRole().

+ Here is the call graph for this function:

◆ setDefaultRole()

ilRegistrationRoleAssignments::setDefaultRole (   $a_role_id)

Definition at line 91 of file class.ilRegistrationEmailRoleAssignments.php.

92 {
93 $this->default_role = $a_role_id;
94 }

◆ setDomain()

ilRegistrationRoleAssignments::setDomain (   $a_id,
  $a_domain 
)

Definition at line 78 of file class.ilRegistrationEmailRoleAssignments.php.

79 {
80 $this->assignments[$a_id]['domain'] = $a_domain;
81 }

◆ setRole()

ilRegistrationRoleAssignments::setRole (   $a_id,
  $a_role 
)

Definition at line 82 of file class.ilRegistrationEmailRoleAssignments.php.

83 {
84 $this->assignments[$a_id]['role'] = $a_role;
85 }

◆ validate()

ilRegistrationRoleAssignments::validate ( )

Definition at line 147 of file class.ilRegistrationEmailRoleAssignments.php.

148 {
149 foreach ($this->assignments as $assignment) {
150 if (!strlen($assignment['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 }
const IL_REG_MISSING_DOMAIN
Class class.ilregistrationEmailRoleAssignments.

References getDefaultRole(), IL_REG_MISSING_DOMAIN, and IL_REG_MISSING_ROLE.

+ Here is the call graph for this function:

Field Documentation

◆ $assignments

ilRegistrationRoleAssignments::$assignments = array()

Definition at line 38 of file class.ilRegistrationEmailRoleAssignments.php.

◆ $default_role

ilRegistrationRoleAssignments::$default_role = 0

Definition at line 39 of file class.ilRegistrationEmailRoleAssignments.php.

Referenced by getDefaultRole().


The documentation for this class was generated from the following file: