ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 165 of file class.ilRegistrationEmailRoleAssignments.php.

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

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

166  {
167  global $ilias, $ilDB;
168 
169  $query = "SELECT * FROM reg_er_assignments ";
170  $res = $this->db->query($query);
171 
172  $this->assignments = array();
173  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
174  {
175  $this->assignments[$row->assignment_id]['id'] = $row->assignment_id;
176  $this->assignments[$row->assignment_id]['role'] = $row->role;
177  $this->assignments[$row->assignment_id]['domain'] = $row->domain;
178  }
179 
180  $this->default_role = $ilias->getSetting('reg_default_role');
181 
182  return true;
183  }
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 107 of file class.ilRegistrationEmailRoleAssignments.php.

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

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

◆ delete()

ilRegistrationRoleAssignments::delete (   $a_id)

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

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

97  {
98  global $ilDB;
99 
100  $query = "DELETE FROM reg_er_assignments ".
101  "WHERE assignment_id = ".$ilDB->quote($a_id ,'integer');
102  $res = $ilDB->manipulate($query);
103  $this->__read();
104  return true;
105  }
global $ilDB
+ Here is the call graph for this function:

◆ getAssignments()

ilRegistrationRoleAssignments::getAssignments ( )

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

References array.

74  {
75  return $this->assignments ? $this->assignments : array();
76  }
Create styles array
The data for the language used.

◆ 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 49 of file class.ilRegistrationEmailRoleAssignments.php.

References getDefaultRole().

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

◆ save()

ilRegistrationRoleAssignments::save ( )

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

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

124  {
125  global $ilias, $ilDB;
126 
127  // Save default role
128  $ilias->setSetting('reg_default_role',$this->getDefaultRole());
129 
130  foreach($this->assignments as $assignment)
131  {
132  $query = "UPDATE reg_er_assignments ".
133  "SET domain = ".$ilDB->quote($assignment['domain'] ,'text').", ".
134  "role = ".$ilDB->quote($assignment['role'] ,'integer')." ".
135  "WHERE assignment_id = ".$ilDB->quote($assignment['id'] ,'integer');
136  $res = $ilDB->manipulate($query);
137  }
138  return true;
139  }
global $ilDB
+ 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 141 of file class.ilRegistrationEmailRoleAssignments.php.

References getDefaultRole(), IL_REG_MISSING_DOMAIN, and IL_REG_MISSING_ROLE.

142  {
143  foreach($this->assignments as $assignment)
144  {
145  if(!strlen($assignment['domain']))
146  {
147  return IL_REG_MISSING_DOMAIN;
148  }
149  if(!$assignment['role'])
150  {
151  return IL_REG_MISSING_ROLE;
152  }
153  }
154  if(!$this->getDefaultRole())
155  {
156  return IL_REG_MISSING_ROLE;
157  }
158  return 0;
159  }
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: