23 include_once(
'Modules/Course/classes/Export/class.ilExportUserSettings.php');
24 include_once(
'Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
25 include_once(
'Services/Membership/classes/class.ilMemberAgreement.php');
26 include_once(
'Modules/Course/classes/class.ilCourseParticipants.php');
27 include_once(
'Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
28 include_once(
'Services/User/classes/class.ilUserDefinedData.php');
30 define(
"IL_MEMBER_EXPORT_CSV_FIELD_SEPERATOR",
',');
31 define(
"IL_MEMBER_EXPORT_CSV_STRING_DELIMITER",
'"');
72 public function __construct($a_ref_id, $a_type = self::EXPORT_CSV)
74 global $ilUser,$ilObjDataCache,
$lng;
78 $this->export_type = $a_type;
80 $this->ref_id = $a_ref_id;
81 $this->obj_id = $ilObjDataCache->lookupObjId($this->ref_id);
98 $this->filename = $a_file;
159 case self::EXPORT_CSV:
163 case self::EXPORT_EXCEL:
178 return $this->csv->getCSVString();
188 include_once
"./Services/Excel/classes/class.ilExcelUtils.php";
189 include_once
"./Services/Excel/classes/class.ilExcelWriterAdapter.php";
191 $workbook = $adapter->getWorkbook();
192 $this->worksheet = $workbook->addWorksheet();
205 include_once(
'Services/Utilities/classes/class.ilCSVWriter.php');
220 protected function addCol($a_value,$a_row,$a_col)
224 case self::EXPORT_CSV:
225 $this->csv->addColumn($a_value);
228 case self::EXPORT_EXCEL:
229 $this->worksheet->write($a_row,$a_col,$a_value);
242 case self::EXPORT_CSV:
243 $this->csv->addRow();
246 case self::EXPORT_EXCEL:
260 foreach($all_fields = $this->settings->getOrderedExportableFields() as $field)
265 #$this->csv->addColumn($this->lng->txt($this->getType().'_role_status'));
266 $this->
addCol($this->lng->txt($this->getType().
'_role_status'),
$row, $col++);
269 #$this->csv->addColumn($this->lng->txt('ps_agreement_accepted'));
270 $this->
addCol($this->lng->txt(
'ps_agreement_accepted'),
$row, $col++);
273 if(substr($field,0,4) ==
'udf_')
275 $field_id = explode(
'_',$field);
276 include_once(
'Services/User/classes/class.ilUserDefinedFields.php');
278 $def = $udf->getDefinition($field_id[1]);
279 #$this->csv->addColumn($def['field_name']);
280 $this->
addCol($def[
'field_name'],
$row, $col++);
282 elseif(substr($field,0,4) ==
'cdf_')
284 $field_id = explode(
'_',$field);
285 #$this->csv->addColumn(ilCourseDefinedFieldDefinition::_lookupName($field_id[1]));
290 #$this->csv->addColumn($this->lng->txt($field));
291 $this->
addCol($this->lng->txt($field),
$row, $col++);
296 #$this->csv->addRow();
299 foreach($this->user_ids as
$usr_id)
305 foreach($all_fields as $field)
323 switch($this->user_course_data[$usr_id][
'role'])
326 #$this->csv->addColumn($this->lng->txt('crs_admin'));
327 $this->
addCol($this->lng->txt(
'crs_admin'),
$row, $col++);
331 #$this->csv->addColumn($this->lng->txt('crs_tutor'));
332 $this->
addCol($this->lng->txt(
'crs_tutor'),
$row, $col++);
336 #$this->csv->addColumn($this->lng->txt('crs_member'));
337 $this->
addCol($this->lng->txt(
'crs_member'),
$row, $col++);
341 #$this->csv->addColumn($this->lng->txt('il_grp_admin'));
342 $this->
addCol($this->lng->txt(
'il_grp_admin'),
$row, $col++);
346 #$this->csv->addColumn($this->lng->txt('il_grp_member'));
347 $this->
addCol($this->lng->txt(
'il_grp_member'),
$row, $col++);
351 #$this->csv->addColumn($this->lng->txt($this->getType().'_subscriber'));
352 $this->
addCol($this->lng->txt($this->getType().
'_subscriber'),
$row, $col++);
356 #$this->csv->addColumn($this->lng->txt('crs_waiting_list'));
357 $this->
addCol($this->lng->txt(
'crs_waiting_list'),
$row, $col++);
364 if(isset($this->agreement[$usr_id]))
366 if($this->agreement[$usr_id][
'accepted'])
368 #$this->csv->addColumn(ilFormat::formatUnixTime($this->agreement[$usr_id]['acceptance_time'],true));
373 #$this->csv->addColumn($this->lng->txt('ps_not_accepted'));
374 $this->
addCol($this->lng->txt(
'ps_not_accepted'),
$row,$col++);
379 #$this->csv->addColumn($this->lng->txt('ps_not_accepted'));
380 $this->
addCol($this->lng->txt(
'ps_not_accepted'),
$row,$col++);
386 #$this->csv->addColumn($this->user_profile_data[$usr_id]['login']);
387 $this->
addCol($this->user_profile_data[$usr_id][
'login'],
$row,$col++);
392 #$this->csv->addColumn($this->user_profile_data[$usr_id][$field]);
393 $this->
addCol($this->user_profile_data[$usr_id][$field],
$row,$col++);
399 or $this->agreement[$usr_id][
'accepted'])
401 #$this->csv->addColumn($this->user_profile_data[$usr_id][$field]);
402 $this->
addCol($this->user_profile_data[$usr_id][$field],
$row,$col++);
406 #$this->csv->addColumn('');
413 #$this->csv->addRow();
431 if($this->settings->enabled(
'admin'))
433 $this->user_ids = $tmp_ids = $this->members->getAdmins();
436 if($this->settings->enabled(
'tutor'))
438 $this->user_ids = array_merge($tmp_ids = $this->members->getTutors(),
$this->user_ids);
441 if($this->settings->enabled(
'member'))
443 $this->user_ids = array_merge($tmp_ids = $this->members->getMembers(),
$this->user_ids);
446 if($this->settings->enabled(
'subscribers'))
448 $this->user_ids = array_merge($tmp_ids = $this->members->getSubscribers(),
$this->user_ids);
451 if($this->settings->enabled(
'waiting_list'))
453 include_once(
'Modules/Course/classes/class.ilCourseWaitingList.php');
455 $this->user_ids = array_merge($waiting_list->getUserIds(),
$this->user_ids);
459 $this->user_ids =
ilUtil::_sortIds($this->user_ids,
'usr_data',
'lastname',
'usr_id');
473 foreach($a_user_ids as $user_id)
476 if($this->members->isAdmin($user_id))
480 elseif($this->members->isTutor($user_id))
482 $this->user_course_data[$user_id][
'role'] =
IL_CRS_TUTOR;
484 elseif($this->members->isMember($user_id))
490 $this->user_course_data[$user_id][
'role'] =
'subscriber';
504 include_once(
'Modules/Course/classes/Export/class.ilCourseUserData.php');
519 if(substr($a_field,0,4) !=
'cdf_')
524 or $this->agreement[$a_usr_id][
'accepted'])
526 $field_info = explode(
'_',$a_field);
527 $field_id = $field_info[1];
528 $value = $this->user_course_fields[$a_usr_id][$field_id];
529 #$this->csv->addColumn($value);
533 #$this->csv->addColumn('');
549 if(substr($a_field,0,4) !=
'udf_')
553 if(!$this->privacy->courseConfirmationRequired() or $this->agreement[$udf_data->getUserId()][
'accepted'])
555 $field_info = explode(
'_',$a_field);
556 $field_id = $field_info[1];
557 $value = $udf_data->get(
'f_'.$field_id);
558 #$this->csv->addColumn($value);
562 #$this->csv->addColumn('');