ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 {
12  const MAPPED_WHOLE_TREE = 1;
13  const MAPPED_MANUAL = 2;
14  const MAPPED_UNMAPPED = 3;
15 
16  const PARALLEL_UNDEFINED = 0;
21 
28  public static function lookupMappingStatus($a_server_id, $a_mid, $a_tree_id)
29  {
30  include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSNodeMappingAssignments.php';
31 
32  if(ilECSNodeMappingAssignments::hasAssignments($a_server_id, $a_mid, $a_tree_id))
33  {
34  if(ilECSNodeMappingAssignments::isWholeTreeMapped($a_server_id, $a_mid, $a_tree_id))
35  {
37  }
38  return self::MAPPED_MANUAL;
39  }
40  return self::MAPPED_UNMAPPED;
41  }
42 
47  public static function mappingStatusToString($a_status)
48  {
49  global $lng;
50 
51  return $lng->txt('ecs_node_mapping_status_'.$a_status);
52  }
53 
54 
55  public static function getCourseMappingFieldInfo()
56  {
57  global $lng;
58 
59  $field_info = array();
60  $counter = 0;
61  foreach(
62  array(
63  'organisation',
64  'term',
65  'title',
66  'lecturer',
67  'courseType',
68  'degreeProgramme',
69  'module',
70  'venue'
71  ) as $field)
72  {
73  $field_info[$counter]['name'] = $field;
74  $field_info[$counter]['translation'] = $lng->txt('ecs_cmap_att_'.$field);
75  $counter++;
76  }
77  return $field_info;
78  }
79 
80  public static function getCourseMappingFieldSelectOptions()
81  {
82  global $lng;
83 
84  $options[''] = $lng->txt('select_one');
85  foreach(self::getCourseMappingFieldInfo() as $info)
86  {
87  $options[$info['name']] = $info['translation'];
88  }
89  return $options;
90  }
91 
97  public static function getCourseValueByMappingAttribute($course, $a_field)
98  {
99  switch($a_field)
100  {
101  case 'organisation':
102  return (string) $course->organisation;
103 
104  case 'term':
105  return (string) $course->term;
106 
107  case 'title':
108  return (string) $course->title;
109 
110  case 'lecturer':
111  foreach((array) $course->groups as $group)
112  {
113  foreach((array) $group->lecturers as $lecturer)
114  {
115  return (string) ($lecturer->lastName.', '. $lecturer->firstName);
116  }
117  }
118  return '';
119 
120  case 'courseType':
121  return (string) $course->lectureType;
122 
123  case 'degreeProgramme':
124  foreach((array) $course->degreeProgrammes as $prog)
125  {
126  return (string) $prog->title;
127  }
128  return '';
129 
130  case 'module':
131  foreach((array) $course->modules as $mod)
132  {
133  return (string) $mod->title;
134  }
135  return '';
136 
137  case 'venue':
138  foreach((array) $course->groups as $group)
139  {
140  foreach((array) $group->datesAndVenues as $venue)
141  {
142  return (string) $venue->venue;
143  }
144  }
145  return '';
146  }
147  return '';
148  }
149 
150 
154  public static function getRoleMappingInfo($a_role_type_info = 0)
155  {
156  include_once './Services/Membership/classes/class.ilParticipants.php';
157  $roles = array(
158  IL_CRS_ADMIN => array(
159  'role' => IL_CRS_ADMIN,
160  'lang' => 'il_crs_admin',
161  'create' => true,
162  'required' => true,
163  'type' => 'crs'),
164  IL_CRS_TUTOR => array(
165  'role' => IL_CRS_TUTOR,
166  'lang' => 'il_crs_tutor',
167  'create' => true,
168  'required' => false,
169  'type' => 'crs'),
170  IL_CRS_MEMBER => array(
171  'role' => IL_CRS_MEMBER,
172  'lang' => 'il_crs_member',
173  'create' => false,
174  'required' => true,
175  'type' => 'crs'),
176  IL_GRP_ADMIN => array(
177  'role' => IL_GRP_ADMIN,
178  'lang' => 'il_grp_admin',
179  'create' => true,
180  'required' => false,
181  'type' => 'grp'),
182  IL_GRP_MEMBER => array(
183  'role' => IL_GRP_MEMBER,
184  'lang' => 'il_grp_member',
185  'create' => false,
186  'required' => false,
187  'type' => 'grp')
188  );
189  if(!$a_role_type_info)
190  {
191  return $roles;
192  }
193  else
194  {
195  return $roles[$a_role_type_info];
196  }
197 
198 
199 
200  }
201 
202 }
203 ?>