ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilRegistrationRoleAssignments Class Reference

Class class.ilregistrationEmailRoleAssignments. More...

+ 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, int $a_role)
 
 getDefaultRole ()
 
 setDefaultRole (int $a_role_id)
 
 deleteAll ()
 
 save ()
 
 read ()
 

Data Fields

const IL_REG_MISSING_DOMAIN = 1
 
const IL_REG_MISSING_ROLE = 2
 
array $assignments = []
 
int $default_role = 0
 

Protected Attributes

ilDBInterface $db
 
ilSetting $settings
 

Detailed Description

Class class.ilregistrationEmailRoleAssignments.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 25 of file class.ilRegistrationRoleAssignments.php.

Constructor & Destructor Documentation

◆ __construct()

ilRegistrationRoleAssignments::__construct ( )

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

37 {
38 global $DIC;
39
40 $this->db = $DIC->database();
41 $this->settings = $DIC->settings();
42 $this->read();
43 }
global $DIC
Definition: shib_login.php:26

References $DIC, read(), and ILIAS\Repository\settings().

+ Here is the call graph for this function:

Member Function Documentation

◆ deleteAll()

ilRegistrationRoleAssignments::deleteAll ( )

Definition at line 100 of file class.ilRegistrationRoleAssignments.php.

100 : bool
101 {
102 $query = "DELETE FROM reg_er_assignments ";
103 $this->db->manipulate($query);
104 $this->read();
105 return true;
106 }

References read().

+ Here is the call graph for this function:

◆ getAssignments()

ilRegistrationRoleAssignments::getAssignments ( )

Definition at line 75 of file class.ilRegistrationRoleAssignments.php.

References $assignments.

◆ getDefaultRole()

ilRegistrationRoleAssignments::getDefaultRole ( )

Definition at line 90 of file class.ilRegistrationRoleAssignments.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 63 of file class.ilRegistrationRoleAssignments.php.

63 : array
64 {
65 $query = $this->db->query("SELECT * FROM reg_er_assignments " .
66 "WHERE role = " . $this->db->quote($role_id, 'integer'));
67
68 $res = [];
69 while ($row = $this->db->fetchAssoc($query)) {
70 $res[] = $row["domain"];
71 }
72 return $res;
73 }
$res
Definition: ltiservices.php:69

References $res.

◆ getRoleByEmail()

ilRegistrationRoleAssignments::getRoleByEmail ( string  $a_email)

Definition at line 45 of file class.ilRegistrationRoleAssignments.php.

45 : int
46 {
47 foreach ($this->assignments as $assignment) {
48 if (!$assignment['domain'] || !$assignment['role']) {
49 continue;
50 }
51 if (stripos($a_email, $assignment['domain']) !== false) {
52 // check if role exists
53 if (!ilObject::_lookupType($assignment['role'])) {
54 continue;
55 }
56 return $assignment['role'];
57 }
58 }
59 // return default
60 return $this->getDefaultRole();
61 }
static _lookupType(int $id, bool $reference=false)

References ilObject\_lookupType(), and getDefaultRole().

+ Here is the call graph for this function:

◆ read()

ilRegistrationRoleAssignments::read ( )

Definition at line 129 of file class.ilRegistrationRoleAssignments.php.

129 : bool
130 {
131 $query = "SELECT * FROM reg_er_assignments ";
132 $res = $this->db->query($query);
133
134 $this->assignments = [];
135 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
136 $this->assignments[$row->assignment_id]['id'] = (int) $row->assignment_id;
137 $this->assignments[$row->assignment_id]['role'] = (int) $row->role;
138 $this->assignments[$row->assignment_id]['domain'] = $row->domain;
139 }
140 $this->default_role = (int) $this->settings->get('reg_default_role', '0');
141 return true;
142 }

References $res, ilDBConstants\FETCHMODE_OBJECT, ILIAS\Repository\int(), and ILIAS\Repository\settings().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilRegistrationRoleAssignments::save ( )

Definition at line 108 of file class.ilRegistrationRoleAssignments.php.

108 : bool
109 {
110 // Save default role
111 $this->settings->set('reg_default_role', (string) $this->getDefaultRole());
112
113 foreach ($this->assignments as $assignment) {
114 if (empty($assignment['id'])) {
115 $next_id = $this->db->nextId('reg_er_assignments');
116 $query = "INSERT INTO reg_er_assignments (assignment_id,domain,role) " .
117 "VALUES( " .
118 $this->db->quote($next_id, 'integer') . ', ' .
119 $this->db->quote($assignment['domain'], 'text') . ", " .
120 $this->db->quote($assignment['role'], 'integer') .
121 ")";
122 $res = $this->db->manipulate($query);
123 }
124 }
125 $this->read();
126 return true;
127 }

References $res, getDefaultRole(), read(), and ILIAS\Repository\settings().

+ Here is the call graph for this function:

◆ setDefaultRole()

ilRegistrationRoleAssignments::setDefaultRole ( int  $a_role_id)

Definition at line 95 of file class.ilRegistrationRoleAssignments.php.

95 : void
96 {
97 $this->default_role = $a_role_id;
98 }

◆ setDomain()

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

Definition at line 80 of file class.ilRegistrationRoleAssignments.php.

80 : void
81 {
82 $this->assignments[$id]['domain'] = $a_domain;
83 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

References $id.

◆ setRole()

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

Definition at line 85 of file class.ilRegistrationRoleAssignments.php.

85 : void
86 {
87 $this->assignments[$id]['role'] = $a_role;
88 }

References $id.

Field Documentation

◆ $assignments

array ilRegistrationRoleAssignments::$assignments = []

Definition at line 30 of file class.ilRegistrationRoleAssignments.php.

Referenced by getAssignments().

◆ $db

ilDBInterface ilRegistrationRoleAssignments::$db
protected

Definition at line 33 of file class.ilRegistrationRoleAssignments.php.

◆ $default_role

int ilRegistrationRoleAssignments::$default_role = 0

Definition at line 31 of file class.ilRegistrationRoleAssignments.php.

Referenced by getDefaultRole().

◆ $settings

ilSetting ilRegistrationRoleAssignments::$settings
protected

Definition at line 34 of file class.ilRegistrationRoleAssignments.php.

◆ IL_REG_MISSING_DOMAIN

const ilRegistrationRoleAssignments::IL_REG_MISSING_DOMAIN = 1

Definition at line 27 of file class.ilRegistrationRoleAssignments.php.

◆ IL_REG_MISSING_ROLE

const ilRegistrationRoleAssignments::IL_REG_MISSING_ROLE = 2

Definition at line 28 of file class.ilRegistrationRoleAssignments.php.


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