23 include_once(
'Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
24 include_once(
'Services/Membership/classes/class.ilMemberAgreement.php');
25 include_once(
'Modules/Course/classes/class.ilCourseParticipants.php');
26 include_once(
'Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
27 include_once(
'Services/User/classes/class.ilUserDefinedData.php');
28 include_once(
'Services/User/classes/class.ilUserFormSettings.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 $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 include_once(
'Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
261 include_once(
'Services/PrivacySecurity/classes/class.ilExportFieldsInfo.php');
262 include_once(
'Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
263 include_once(
'Services/User/classes/class.ilUserDefinedFields.php');
272 $fields[] =
'agreement';
275 foreach($field_info->getExportableFields() as $field)
277 if($this->settings->enabled($field))
284 foreach($udf->getCourseExportableFields() as $field_id => $udf_data)
286 if($this->settings->enabled(
'udf_'.$field_id))
288 $fields[] =
'udf_'.$field_id;
295 if($this->settings->enabled(
'cdf_'.$field_obj->getId()))
297 $fields[] =
'cdf_'.$field_obj->getId();
300 return $fields ? $fields : array();
317 #$this->csv->addColumn($this->lng->txt($this->getType().'_role_status'));
318 $this->
addCol($this->lng->txt($this->getType().
'_role_status'),
$row, $col++);
321 #$this->csv->addColumn($this->lng->txt('ps_agreement_accepted'));
322 $this->
addCol($this->lng->txt(
'ps_agreement_accepted'),
$row, $col++);
325 if(substr($field,0,4) ==
'udf_')
327 $field_id = explode(
'_',$field);
328 include_once(
'Services/User/classes/class.ilUserDefinedFields.php');
330 $def = $udf->getDefinition($field_id[1]);
331 #$this->csv->addColumn($def['field_name']);
332 $this->
addCol($def[
'field_name'],
$row, $col++);
334 elseif(substr($field,0,4) ==
'cdf_')
336 $field_id = explode(
'_',$field);
337 #$this->csv->addColumn(ilCourseDefinedFieldDefinition::_lookupName($field_id[1]));
342 #$this->csv->addColumn($this->lng->txt($field));
343 $this->
addCol($this->lng->txt($field),
$row, $col++);
348 #$this->csv->addRow();
351 foreach($this->user_ids as
$usr_id)
357 foreach($all_fields as $field)
375 switch($this->user_course_data[$usr_id][
'role'])
378 #$this->csv->addColumn($this->lng->txt('crs_admin'));
379 $this->
addCol($this->lng->txt(
'crs_admin'),
$row, $col++);
383 #$this->csv->addColumn($this->lng->txt('crs_tutor'));
384 $this->
addCol($this->lng->txt(
'crs_tutor'),
$row, $col++);
388 #$this->csv->addColumn($this->lng->txt('crs_member'));
389 $this->
addCol($this->lng->txt(
'crs_member'),
$row, $col++);
393 #$this->csv->addColumn($this->lng->txt('il_grp_admin'));
394 $this->
addCol($this->lng->txt(
'il_grp_admin'),
$row, $col++);
398 #$this->csv->addColumn($this->lng->txt('il_grp_member'));
399 $this->
addCol($this->lng->txt(
'il_grp_member'),
$row, $col++);
403 #$this->csv->addColumn($this->lng->txt($this->getType().'_subscriber'));
404 $this->
addCol($this->lng->txt($this->getType().
'_subscriber'),
$row, $col++);
408 #$this->csv->addColumn($this->lng->txt('crs_waiting_list'));
409 $this->
addCol($this->lng->txt(
'crs_waiting_list'),
$row, $col++);
416 if(isset($this->agreement[$usr_id]))
418 if($this->agreement[$usr_id][
'accepted'])
420 #$this->csv->addColumn(ilFormat::formatUnixTime($this->agreement[$usr_id]['acceptance_time'],true));
425 #$this->csv->addColumn($this->lng->txt('ps_not_accepted'));
426 $this->
addCol($this->lng->txt(
'ps_not_accepted'),
$row,$col++);
431 #$this->csv->addColumn($this->lng->txt('ps_not_accepted'));
432 $this->
addCol($this->lng->txt(
'ps_not_accepted'),
$row,$col++);
438 #$this->csv->addColumn($this->user_profile_data[$usr_id]['login']);
439 $this->
addCol($this->user_profile_data[$usr_id][
'login'],
$row,$col++);
444 #$this->csv->addColumn($this->user_profile_data[$usr_id][$field]);
445 $this->
addCol($this->user_profile_data[$usr_id][$field],
$row,$col++);
451 or $this->agreement[$usr_id][
'accepted'])
453 #$this->csv->addColumn($this->user_profile_data[$usr_id][$field]);
454 $this->
addCol($this->user_profile_data[$usr_id][$field],
$row,$col++);
458 #$this->csv->addColumn('');
465 #$this->csv->addRow();
483 if($this->settings->enabled(
'admin'))
485 $this->user_ids = $tmp_ids = $this->members->getAdmins();
488 if($this->settings->enabled(
'tutor'))
490 $this->user_ids = array_merge($tmp_ids = $this->members->getTutors(),
$this->user_ids);
493 if($this->settings->enabled(
'member'))
495 $this->user_ids = array_merge($tmp_ids = $this->members->getMembers(),
$this->user_ids);
498 if($this->settings->enabled(
'subscribers'))
500 $this->user_ids = array_merge($tmp_ids = $this->members->getSubscribers(),
$this->user_ids);
503 if($this->settings->enabled(
'waiting_list'))
505 include_once(
'Modules/Course/classes/class.ilCourseWaitingList.php');
507 $this->user_ids = array_merge($waiting_list->getUserIds(),
$this->user_ids);
511 $this->user_ids =
ilUtil::_sortIds($this->user_ids,
'usr_data',
'lastname',
'usr_id');
525 foreach($a_user_ids as $user_id)
528 if($this->members->isAdmin($user_id))
532 elseif($this->members->isTutor($user_id))
534 $this->user_course_data[$user_id][
'role'] =
IL_CRS_TUTOR;
536 elseif($this->members->isMember($user_id))
542 $this->user_course_data[$user_id][
'role'] =
'subscriber';
556 include_once(
'Modules/Course/classes/Export/class.ilCourseUserData.php');
571 if(substr($a_field,0,4) !=
'cdf_')
576 or $this->agreement[$a_usr_id][
'accepted'])
578 $field_info = explode(
'_',$a_field);
579 $field_id = $field_info[1];
580 $value = $this->user_course_fields[$a_usr_id][$field_id];
581 #$this->csv->addColumn($value);
585 #$this->csv->addColumn('');
601 if(substr($a_field,0,4) !=
'udf_')
605 if(!$this->privacy->courseConfirmationRequired() or $this->agreement[$udf_data->getUserId()][
'accepted'])
607 $field_info = explode(
'_',$a_field);
608 $field_id = $field_info[1];
609 $value = $udf_data->get(
'f_'.$field_id);
610 #$this->csv->addColumn($value);
614 #$this->csv->addColumn('');