ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilRegistrationRoleAssignments Class Reference
+ Collaboration diagram for ilRegistrationRoleAssignments:

Public Member Functions

 __construct ()
 
 getRoleByEmail (string $a_email)
 
 getDomainsByRole (int $role_id)
 
 getAssignments ()
 
 setDomain (int $id, string $a_domain)
 
 setRole (int $id, string $a_role)
 
 getDefaultRole ()
 
 setDefaultRole ($a_role_id)
 
 deleteAll ()
 
 save ()
 
 __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 $ilDB
$DIC
Definition: xapitoken.php:46

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

+ Here is the call graph for this function:

Member Function Documentation

◆ __read()

ilRegistrationRoleAssignments::__read ( )

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

150 {
151 global $DIC;
152
153 $ilias = $DIC['ilias'];
154 $ilDB = $this->db;
155
156 $query = "SELECT * FROM reg_er_assignments ";
157 $res = $this->db->query($query);
158
159 $this->assignments = array();
160 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
161 $this->assignments[$row->assignment_id]['id'] = $row->assignment_id;
162 $this->assignments[$row->assignment_id]['role'] = $row->role;
163 $this->assignments[$row->assignment_id]['domain'] = $row->domain;
164 }
165
166 $this->default_role = $ilias->getSetting('reg_default_role');
167
168 return true;
169 }
$query
foreach($_POST as $key=> $value) $res

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

Referenced by __construct(), deleteAll(), and save().

+ Here is the caller graph for this function:

◆ deleteAll()

ilRegistrationRoleAssignments::deleteAll ( )

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

112 {
113 $ilDB = $this->db;
114
115 $query = "DELETE FROM reg_er_assignments ";
116 $ilDB->manipulate($query);
117 $this->__read();
118 return true;
119 }

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

+ Here is the call graph for this function:

◆ getAssignments()

ilRegistrationRoleAssignments::getAssignments ( )

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

89 {
90 return $this->assignments ? $this->assignments : array();
91 }

◆ getDefaultRole()

ilRegistrationRoleAssignments::getDefaultRole ( )

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

References $default_role.

Referenced by getRoleByEmail(), and save().

+ Here is the caller graph for this function:

◆ getDomainsByRole()

ilRegistrationRoleAssignments::getDomainsByRole ( int  $role_id)

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

74 {
75 $ilDB = $this->db;
76
77 $query = $ilDB->query("SELECT * FROM reg_er_assignments " .
78 "WHERE role = " . $ilDB->quote($role_id, 'integer'));
79
80
81 while ($row = $ilDB->fetchAssoc($query)) {
82 $res[] = $row["domain"];
83 }
84
85 return $res;
86 }

References $ilDB, $query, and $res.

◆ getRoleByEmail()

ilRegistrationRoleAssignments::getRoleByEmail ( string  $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 121 of file class.ilRegistrationEmailRoleAssignments.php.

122 {
123 global $DIC;
124
125 $ilias = $DIC['ilias'];
126 $ilDB = $this->db;
127
128 // Save default role
129 $ilias->setSetting('reg_default_role', $this->getDefaultRole());
130
131 foreach ($this->assignments as $assignment) {
132 if (empty($assignment['id'])) {
133 $next_id = $ilDB->nextId('reg_er_assignments');
134 $query = "INSERT INTO reg_er_assignments (assignment_id,domain,role) " .
135 "VALUES( " .
136 $ilDB->quote($next_id, 'integer') . ', ' .
137 $ilDB->quote($assignment['domain'], 'text') . ", " .
138 $ilDB->quote($assignment['role'], 'integer') .
139 ")";
140 $res = $ilDB->manipulate($query);
141 }
142 }
143 $this->__read();
144 return true;
145 }

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

+ Here is the call graph for this function:

◆ setDefaultRole()

ilRegistrationRoleAssignments::setDefaultRole (   $a_role_id)

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

107 {
108 $this->default_role = $a_role_id;
109 }

◆ setDomain()

ilRegistrationRoleAssignments::setDomain ( int  $id,
string  $a_domain 
)

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

94 {
95 $this->assignments[$id]['domain'] = $a_domain;
96 }

◆ setRole()

ilRegistrationRoleAssignments::setRole ( int  $id,
string  $a_role 
)

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

98 {
99 $this->assignments[$id]['role'] = $a_role;
100 }

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: