ILIAS  release_8 Revision v8.24
class.ilECSMappingUtils.php
Go to the documentation of this file.
1<?php
2
18declare(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)) {
44 }
46 }
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 return array((string) $course->term);
112
113 case 'title':
114 return array((string) $course->title);
115
116 case 'orgunit':
117 $units = array();
118 foreach ((array) $course->organisationalUnits as $unit) {
119 $units[] = (string) $unit->title;
120 }
121 return $units;
122
123 case 'lecturer':
124 $lecturers = array();
125 foreach ((array) $course->groups as $group) {
126 foreach ((array) $group->lecturers as $lecturer) {
127 $lecturers[] = $lecturer->lastName . ', ' . $lecturer->firstName;
128 }
129 }
130 return $lecturers;
131
132 case 'courseType':
133 return array((string) $course->lectureType);
134
135 case 'degreeProgramme':
136 $degree_programmes = array();
137 foreach ((array) $course->degreeProgrammes as $prog) {
138 $degree_programmes[] = (string) $prog->title;
139 }
140 return $degree_programmes;
141
142 case 'module':
143 $modules = array();
144 foreach ((array) $course->modules as $mod) {
145 $modules[] = (string) $mod->title;
146 }
147 return $modules;
148
149 case 'venue':
150 $venues = [];
151 foreach ((array) $course->groups as $group) {
152 foreach ((array) $group->datesAndVenues as $venue) {
153 $venues[] = (string) $venue->venue;
154 }
155 }
156 return $venues;
157 }
158 return array();
159 }
160
161
165 public static function getRoleMappingInfo($a_role_type_info = 0): array
166 {
167 //KEEP!!! until the defines are turned into proper constants
168 include_once './Services/Membership/classes/class.ilParticipants.php';
169 $roles = array(
172 'lang' => 'il_crs_admin',
173 'create' => true,
174 'required' => true,
175 'type' => 'crs'),
178 'lang' => 'il_crs_tutor',
179 'create' => true,
180 'required' => false,
181 'type' => 'crs'),
184 'lang' => 'il_crs_member',
185 'create' => false,
186 'required' => true,
187 'type' => 'crs'),
190 'lang' => 'il_grp_admin',
191 'create' => true,
192 'required' => false,
193 'type' => 'grp'),
196 'lang' => 'il_grp_member',
197 'create' => false,
198 'required' => false,
199 'type' => 'grp')
200 );
201 if (!$a_role_type_info) {
202 return $roles;
203 }
204 return $roles[$a_role_type_info];
205 }
206
211 public static function getAuthModeSelection(): array
212 {
213 global $DIC;
214
215 $lng = $DIC->language();
216 $active_auth_modes = ilAuthUtils::_getActiveAuthModes();
217 $options = [];
218 $options["0"] = $lng->txt('select_one');
219 foreach ($active_auth_modes as $auth_string => $auth_int) {
220 if (
221 $auth_string === 'default' ||
222 $auth_string === 'ecs' ||
223 substr($auth_string, 0, 3) === 'lti'
224 ) {
225 continue;
226 }
227 $options[$auth_string] = ilAuthUtils::getAuthModeTranslation((string) $auth_int);
228 }
229 return $options;
230 }
231}
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.
global $DIC
Definition: feed.php:28
$lng