ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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.

References $ilDB, and __read().

42  {
43  global $ilDB;
44 
45  $this->db = $ilDB;
46  $this->__read();
47  }
global $ilDB
+ Here is the call graph for this function:

Member Function Documentation

◆ __read()

ilRegistrationRoleAssignments::__read ( )

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

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

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

157  {
158  global $ilias, $ilDB;
159 
160  $query = "SELECT * FROM reg_er_assignments ";
161  $res = $this->db->query($query);
162 
163  $this->assignments = array();
164  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
165  $this->assignments[$row->assignment_id]['id'] = $row->assignment_id;
166  $this->assignments[$row->assignment_id]['role'] = $row->role;
167  $this->assignments[$row->assignment_id]['domain'] = $row->domain;
168  }
169 
170  $this->default_role = $ilias->getSetting('reg_default_role');
171 
172  return true;
173  }
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ add()

ilRegistrationRoleAssignments::add ( )

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

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

104  {
105  global $ilDB;
106 
107  $next_id = $ilDB->nextId('reg_er_assignments');
108  $query = "INSERT INTO reg_er_assignments (assignment_id,domain,role) " .
109  "VALUES( " .
110  $ilDB->quote($next_id, 'integer') . ', ' .
111  $ilDB->quote('', 'text') . ", " .
112  $ilDB->quote(0, 'integer') .
113  ")";
114  $res = $ilDB->manipulate($query);
115  $this->__read();
116  return true;
117  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the call graph for this function:

◆ delete()

ilRegistrationRoleAssignments::delete (   $a_id)

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

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

93  {
94  global $ilDB;
95 
96  $query = "DELETE FROM reg_er_assignments " .
97  "WHERE assignment_id = " . $ilDB->quote($a_id, 'integer');
98  $res = $ilDB->manipulate($query);
99  $this->__read();
100  return true;
101  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the call graph for this function:

◆ getAssignments()

ilRegistrationRoleAssignments::getAssignments ( )

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

References array.

70  {
71  return $this->assignments ? $this->assignments : array();
72  }
Create styles array
The data for the language used.

◆ getDefaultRole()

ilRegistrationRoleAssignments::getDefaultRole ( )

Definition at line 83 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 49 of file class.ilRegistrationEmailRoleAssignments.php.

References getDefaultRole().

50  {
51  global $ilObjDataCache;
52 
53  foreach ($this->assignments as $assignment) {
54  if (!$assignment['domain'] or !$assignment['role']) {
55  continue;
56  }
57  if (stristr($a_email, $assignment['domain'])) {
58  // check if role exists
59  if (!$ilObjDataCache->lookupType($assignment['role'])) {
60  continue;
61  }
62  return $assignment['role'];
63  }
64  }
65  // return default
66  return $this->getDefaultRole();
67  }
+ Here is the call graph for this function:

◆ save()

ilRegistrationRoleAssignments::save ( )

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

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

120  {
121  global $ilias, $ilDB;
122 
123  // Save default role
124  $ilias->setSetting('reg_default_role', $this->getDefaultRole());
125 
126  foreach ($this->assignments as $assignment) {
127  $query = "UPDATE reg_er_assignments " .
128  "SET domain = " . $ilDB->quote($assignment['domain'], 'text') . ", " .
129  "role = " . $ilDB->quote($assignment['role'], 'integer') . " " .
130  "WHERE assignment_id = " . $ilDB->quote($assignment['id'], 'integer');
131  $res = $ilDB->manipulate($query);
132  }
133  return true;
134  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the call graph for this function:

◆ setDefaultRole()

ilRegistrationRoleAssignments::setDefaultRole (   $a_role_id)

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

88  {
89  $this->default_role = $a_role_id;
90  }

◆ setDomain()

ilRegistrationRoleAssignments::setDomain (   $a_id,
  $a_domain 
)

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

75  {
76  $this->assignments[$a_id]['domain'] = $a_domain;
77  }

◆ setRole()

ilRegistrationRoleAssignments::setRole (   $a_id,
  $a_role 
)

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

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

◆ validate()

ilRegistrationRoleAssignments::validate ( )

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

References getDefaultRole(), IL_REG_MISSING_DOMAIN, and IL_REG_MISSING_ROLE.

137  {
138  foreach ($this->assignments as $assignment) {
139  if (!strlen($assignment['domain'])) {
140  return IL_REG_MISSING_DOMAIN;
141  }
142  if (!$assignment['role']) {
143  return IL_REG_MISSING_ROLE;
144  }
145  }
146  if (!$this->getDefaultRole()) {
147  return IL_REG_MISSING_ROLE;
148  }
149  return 0;
150  }
const IL_REG_MISSING_DOMAIN
Class class.ilregistrationEmailRoleAssignments.
+ 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: