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