ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.ilECSMappingUtils.php
Go to the documentation of this file.
1 <?php
2 
18 declare(strict_types=1);
19 
26 {
27  public const MAPPED_WHOLE_TREE = 1;
28  public const MAPPED_MANUAL = 2;
29  public const MAPPED_UNMAPPED = 3;
30 
31  public const PARALLEL_ONE_COURSE = 0;
32  public const PARALLEL_GROUPS_IN_COURSE = 1;
33  public const PARALLEL_ALL_COURSES = 2;
35 
39  public static function lookupMappingStatus(int $a_server_id, int $a_mid, int $a_tree_id): int
40  {
41  if (ilECSNodeMappingAssignments::hasAssignments($a_server_id, $a_mid, $a_tree_id)) {
42  if (ilECSNodeMappingAssignments::isWholeTreeMapped($a_server_id, $a_mid, $a_tree_id)) {
43  return self::MAPPED_WHOLE_TREE;
44  }
45  return self::MAPPED_MANUAL;
46  }
47  return self::MAPPED_UNMAPPED;
48  }
49 
53  public static function mappingStatusToString(int $a_status): string
54  {
55  global $DIC;
56 
57  return $DIC->language()->txt('ecs_node_mapping_status_' . $a_status);
58  }
59 
60 
61  public static function getCourseMappingFieldInfo(): array
62  {
63  global $DIC;
64 
65  $lng = $DIC['lng'];
66 
67  $field_info = array();
68  $counter = 0;
69  foreach (
70  array(
71  'organisation',
72  'orgunit',
73  'term',
74  'title',
75  'lecturer',
76  'courseType',
77  'degreeProgramme',
78  'module',
79  'venue'
80  ) as $field) {
81  $field_info[$counter]['name'] = $field;
82  $field_info[$counter]['translation'] = $lng->txt('ecs_cmap_att_' . $field);
83  $counter++;
84  }
85  return $field_info;
86  }
87 
88  public static function getCourseMappingFieldSelectOptions(): array
89  {
90  global $DIC;
91 
92  $lng = $DIC['lng'];
93 
94  $options[''] = $lng->txt('select_one');
95  foreach (self::getCourseMappingFieldInfo() as $info) {
96  $options[$info['name']] = $info['translation'];
97  }
98  return $options;
99  }
100 
104  public static function getCourseValueByMappingAttribute($course, $a_field): array
105  {
106  switch ($a_field) {
107  case 'organisation':
108  return array((string) $course->organisation);
109 
110  case 'term':
111  if (property_exists($course, "term")) {
112  return array((string) $course->term);
113  }
114  return [];
115 
116  case 'title':
117  return array((string) $course->title);
118 
119  case 'orgunit':
120  $units = array();
121  foreach ((array) $course->organisationalUnits as $unit) {
122  $units[] = (string) $unit->title;
123  }
124  return $units;
125 
126  case 'lecturer':
127  $lecturers = array();
128  foreach ((array) $course->groups as $group) {
129  foreach ((array) $group->lecturers as $lecturer) {
130  $lecturers[] = $lecturer->lastName . ', ' . $lecturer->firstName;
131  }
132  }
133  return $lecturers;
134 
135  case 'courseType':
136  return array((string) $course->lectureType);
137 
138  case 'degreeProgramme':
139  $degree_programmes = array();
140  foreach ((array) $course->degreeProgrammes as $prog) {
141  $degree_programmes[] = (string) $prog->title;
142  }
143  return $degree_programmes;
144 
145  case 'module':
146  $modules = array();
147  foreach ((array) $course->modules as $mod) {
148  $modules[] = (string) $mod->title;
149  }
150  return $modules;
151 
152  case 'venue':
153  $venues = [];
154  foreach ((array) $course->groups as $group) {
155  foreach ((array) $group->datesAndVenues as $venue) {
156  $venues[] = (string) $venue->venue;
157  }
158  }
159  return $venues;
160  }
161  return array();
162  }
163 
164 
168  public static function getRoleMappingInfo($a_role_type_info = 0): array
169  {
170  //KEEP!!! until the defines are turned into proper constants
171  $roles = array(
174  'lang' => 'il_crs_admin',
175  'create' => true,
176  'required' => true,
177  'type' => 'crs'),
180  'lang' => 'il_crs_tutor',
181  'create' => true,
182  'required' => false,
183  'type' => 'crs'),
186  'lang' => 'il_crs_member',
187  'create' => false,
188  'required' => true,
189  'type' => 'crs'),
192  'lang' => 'il_grp_admin',
193  'create' => true,
194  'required' => false,
195  'type' => 'grp'),
198  'lang' => 'il_grp_member',
199  'create' => false,
200  'required' => false,
201  'type' => 'grp')
202  );
203  if (!$a_role_type_info) {
204  return $roles;
205  }
206  return $roles[$a_role_type_info];
207  }
208 
213  public static function getAuthModeSelection(): array
214  {
215  global $DIC;
216 
217  $lng = $DIC->language();
218  $active_auth_modes = ilAuthUtils::_getActiveAuthModes();
219  $options = [];
220  $options["0"] = $lng->txt('select_one');
221  foreach ($active_auth_modes as $auth_string => $auth_int) {
222  if (
223  $auth_string === 'default' ||
224  $auth_string === 'ecs' ||
225  substr($auth_string, 0, 3) === 'lti'
226  ) {
227  continue;
228  }
229  $options[$auth_string] = ilAuthUtils::getAuthModeTranslation((string) $auth_int);
230  }
231  return $options;
232  }
233 }
static getRoleMappingInfo($a_role_type_info=0)
Get role mapping info.
static getAuthModeTranslation(string $a_auth_key, string $auth_name='')
static getCourseValueByMappingAttribute($course, $a_field)
Get course value by mapping.
static _getActiveAuthModes()
static isWholeTreeMapped(int $a_server_id, int $a_mid, int $a_tree_id)
Check if whole tree is mapped.
static lookupMappingStatus(int $a_server_id, int $a_mid, int $a_tree_id)
Lookup mapping status.
static getCourseMappingFieldSelectOptions()
static mappingStatusToString(int $a_status)
Get mapping status as string.
static getAuthModeSelection()
Get auth mode selection with active authentication modes.
global $DIC
Definition: shib_login.php:25
global $lng
Definition: privfeed.php:32