ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilECSMappingUtils.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
11{
13 const MAPPED_MANUAL = 2;
14 const MAPPED_UNMAPPED = 3;
15
20
27 public static function lookupMappingStatus($a_server_id, $a_mid, $a_tree_id)
28 {
29 include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSNodeMappingAssignments.php';
30
31 if (ilECSNodeMappingAssignments::hasAssignments($a_server_id, $a_mid, $a_tree_id)) {
32 if (ilECSNodeMappingAssignments::isWholeTreeMapped($a_server_id, $a_mid, $a_tree_id)) {
34 }
36 }
38 }
39
44 public static function mappingStatusToString($a_status)
45 {
46 global $DIC;
47
48 $lng = $DIC['lng'];
49
50 return $lng->txt('ecs_node_mapping_status_' . $a_status);
51 }
52
53
54 public static function getCourseMappingFieldInfo()
55 {
56 global $DIC;
57
58 $lng = $DIC['lng'];
59
60 $field_info = array();
61 $counter = 0;
62 foreach (
63 array(
64 'organisation',
65 'orgunit',
66 'term',
67 'title',
68 'lecturer',
69 'courseType',
70 'degreeProgramme',
71 'module',
72 'venue'
73 ) as $field) {
74 $field_info[$counter]['name'] = $field;
75 $field_info[$counter]['translation'] = $lng->txt('ecs_cmap_att_' . $field);
76 $counter++;
77 }
78 return $field_info;
79 }
80
81 public static function getCourseMappingFieldSelectOptions()
82 {
83 global $DIC;
84
85 $lng = $DIC['lng'];
86
87 $options[''] = $lng->txt('select_one');
88 foreach (self::getCourseMappingFieldInfo() as $info) {
89 $options[$info['name']] = $info['translation'];
90 }
91 return $options;
92 }
93
100 public static function getCourseValueByMappingAttribute($course, $a_field)
101 {
102 switch ($a_field) {
103 case 'organisation':
104 return array((string) $course->organisation);
105
106 case 'term':
107 return array((string) $course->term);
108
109 case 'title':
110 return array((string) $course->title);
111
112 case 'orgunit':
113 $units = array();
114 foreach ((array) $course->organisationalUnits as $unit) {
115 $units[] = (string) $unit->title;
116 }
117 return $units;
118
119 case 'lecturer':
120 $lecturers = array();
121 foreach ((array) $course->groups as $group) {
122 foreach ((array) $group->lecturers as $lecturer) {
123 $lecturers[] = (string) ($lecturer->lastName . ', ' . $lecturer->firstName);
124 }
125 }
126 return $lecturers;
127
128 case 'courseType':
129 return array((string) $course->lectureType);
130
131 case 'degreeProgramme':
132 $degree_programmes = array();
133 foreach ((array) $course->degreeProgrammes as $prog) {
134 $degree_programmes[] = (string) $prog->title;
135 }
136 return $degree_programmes;
137
138 case 'module':
139 $modules = array();
140 foreach ((array) $course->modules as $mod) {
141 $modules[] = (string) $mod->title;
142 }
143 return $modules;
144
145 case 'venue':
146 $venues[] = array();
147 foreach ((array) $course->groups as $group) {
148 foreach ((array) $group->datesAndVenues as $venue) {
149 $venues[] = (string) $venue->venue;
150 }
151 }
152 return $venues;
153 }
154 return array();
155 }
156
157
161 public static function getRoleMappingInfo($a_role_type_info = 0)
162 {
163 include_once './Services/Membership/classes/class.ilParticipants.php';
164 $roles = array(
165 IL_CRS_ADMIN => array(
166 'role' => IL_CRS_ADMIN,
167 'lang' => 'il_crs_admin',
168 'create' => true,
169 'required' => true,
170 'type' => 'crs'),
171 IL_CRS_TUTOR => array(
172 'role' => IL_CRS_TUTOR,
173 'lang' => 'il_crs_tutor',
174 'create' => true,
175 'required' => false,
176 'type' => 'crs'),
177 IL_CRS_MEMBER => array(
178 'role' => IL_CRS_MEMBER,
179 'lang' => 'il_crs_member',
180 'create' => false,
181 'required' => true,
182 'type' => 'crs'),
183 IL_GRP_ADMIN => array(
184 'role' => IL_GRP_ADMIN,
185 'lang' => 'il_grp_admin',
186 'create' => true,
187 'required' => false,
188 'type' => 'grp'),
189 IL_GRP_MEMBER => array(
190 'role' => IL_GRP_MEMBER,
191 'lang' => 'il_grp_member',
192 'create' => false,
193 'required' => false,
194 'type' => 'grp')
195 );
196 if (!$a_role_type_info) {
197 return $roles;
198 } else {
199 return $roles[$a_role_type_info];
200 }
201 }
202
207 public static function getAuthModeSelection()
208 {
209 global $DIC;
210
211 $lng = $DIC->language();
212 $ilSetting = $DIC->settings();
213
214
215 $options[0] = $lng->txt('select_one');
216 $options['local'] = $lng->txt('auth_local');
217
218 include_once './Services/LDAP/classes/class.ilLDAPServer.php';
219 foreach (ilLDAPServer::getServerIds() as $sid) {
221 $options['ldap_' . $server->getServerId()] = 'LDAP (' . $server->getName() . ')';
222 }
223
224 if ($ilSetting->get('shib_active', 0)) {
226 $lng->txt('auth_shibboleth');
227 }
228
229 return $options;
230 }
231}
An exception for terminatinating execution or to throw for unit testing.
const AUTH_SHIBBOLETH
const IL_CRS_ADMIN
Base class for course and group participants.
const IL_CRS_MEMBER
const IL_GRP_MEMBER
const IL_CRS_TUTOR
const IL_GRP_ADMIN
static _getAuthModeName($a_auth_key)
static getRoleMappingInfo($a_role_type_info=0)
Get role mapping info.
static mappingStatusToString($a_status)
Get mapping status as string.
static getAuthModeSelection()
Get auth mode selection.
static getCourseValueByMappingAttribute($course, $a_field)
Get course value by mapping.
static getCourseMappingFieldSelectOptions()
static lookupMappingStatus($a_server_id, $a_mid, $a_tree_id)
Lookup mapping status.
static hasAssignments($a_server_id, $a_mid, $a_tree_id)
Check if there is any assignment for a cms tree.
static isWholeTreeMapped($a_server_id, $a_mid, $a_tree_id)
Check if whole tree is mapped.
static getInstanceByServerId($a_server_id)
Get instance by server id.
static getServerIds()
Get all server ids @global ilDB $ilDB.
$server
global $ilSetting
Definition: privfeed.php:17
$lng
$DIC
Definition: xapitoken.php:46