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",
'"');
79 $ilObjDataCache = $DIC[
'ilObjDataCache'];
86 $this->ref_id = $a_ref_id;
87 $this->obj_id = $ilObjDataCache->lookupObjId($this->ref_id);
101 return $GLOBALS[
'DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
116 $this->filename = $a_file;
176 case self::EXPORT_CSV:
180 case self::EXPORT_EXCEL:
195 return $this->csv->getCSVString();
205 include_once
"./Services/Excel/classes/class.ilExcel.php";
206 $this->worksheet =
new ilExcel();
207 $this->worksheet->addSheet($this->lng->txt(
"members"));
211 $this->worksheet->writeToFile($this->
getFilename());
222 include_once(
'Services/Utilities/classes/class.ilCSVWriter.php');
237 protected function addCol($a_value, $a_row, $a_col)
240 case self::EXPORT_CSV:
241 $this->csv->addColumn($a_value);
244 case self::EXPORT_EXCEL:
245 $this->worksheet->setCell($a_row + 1, $a_col, $a_value);
257 case self::EXPORT_CSV:
258 $this->csv->addRow();
261 case self::EXPORT_EXCEL:
275 include_once(
'Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
276 include_once(
'Services/PrivacySecurity/classes/class.ilExportFieldsInfo.php');
277 include_once(
'Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
278 include_once(
'Services/User/classes/class.ilUserDefinedFields.php');
281 $field_info->sortExportFields();
285 if (
$privacy->courseConfirmationRequired()) {
286 $fields[] =
'agreement';
289 foreach ($field_info->getExportableFields() as $field) {
290 if ($this->
settings->enabled($field)) {
296 foreach ($udf->getCourseExportableFields() as $field_id => $udf_data) {
297 if ($this->
settings->enabled(
'udf_' . $field_id)) {
298 $fields[] =
'udf_' . $field_id;
304 if ($this->
settings->enabled(
'cdf_' . $field_obj->getId())) {
305 $fields[] =
'cdf_' . $field_obj->getId();
308 if ($this->
settings->enabled(
'group_memberships')) {
309 $fields[] =
'crs_members_groups';
312 return $fields ? $fields : array();
327 #$this->csv->addColumn($this->lng->txt($this->getType().'_role_status')); 328 $this->
addCol($this->lng->txt($this->getType() .
'_role_status'),
$row, $col++);
331 #$this->csv->addColumn($this->lng->txt('ps_agreement_accepted')); 332 $this->
addCol($this->lng->txt(
'ps_agreement_accepted'),
$row, $col++);
334 case 'consultation_hour':
335 $this->lng->loadLanguageModule(
'dateplaner');
336 $this->
addCol($this->lng->txt(
'cal_ch_field_ch'),
$row, $col++);
340 $this->
addCol($this->lng->txt(
'org_units'),
$row, $col++);
344 if (substr($field, 0, 4) ==
'udf_') {
345 $field_id = explode(
'_', $field);
346 include_once(
'Services/User/classes/class.ilUserDefinedFields.php');
348 $def = $udf->getDefinition($field_id[1]);
349 #$this->csv->addColumn($def['field_name']); 351 } elseif (substr($field, 0, 4) ==
'cdf_') {
352 $field_id = explode(
'_', $field);
353 #$this->csv->addColumn(ilCourseDefinedFieldDefinition::_lookupName($field_id[1])); 355 } elseif ($field ==
"username") {
356 $this->
addCol($this->lng->txt(
"login"),
$row, $col++);
358 #$this->csv->addColumn($this->lng->txt($field)); 359 $this->
addCol($this->lng->txt($field),
$row, $col++);
364 #$this->csv->addRow(); 367 foreach ($this->user_ids as $usr_id) {
372 foreach ($all_fields as $field) {
386 switch ($this->user_course_data[$usr_id][
'role']) {
388 #$this->csv->addColumn($this->lng->txt('crs_admin')); 389 $this->
addCol($this->lng->txt(
'crs_admin'),
$row, $col++);
393 #$this->csv->addColumn($this->lng->txt('crs_tutor')); 394 $this->
addCol($this->lng->txt(
'crs_tutor'),
$row, $col++);
398 #$this->csv->addColumn($this->lng->txt('crs_member')); 399 $this->
addCol($this->lng->txt(
'crs_member'),
$row, $col++);
403 #$this->csv->addColumn($this->lng->txt('il_grp_admin')); 404 $this->
addCol($this->lng->txt(
'il_grp_admin'),
$row, $col++);
408 #$this->csv->addColumn($this->lng->txt('il_grp_member')); 409 $this->
addCol($this->lng->txt(
'il_grp_member'),
$row, $col++);
413 #$this->csv->addColumn($this->lng->txt($this->getType().'_subscriber')); 414 $this->
addCol($this->lng->txt($this->getType() .
'_subscriber'),
$row, $col++);
418 #$this->csv->addColumn($this->lng->txt('crs_waiting_list')); 419 $this->
addCol($this->lng->txt(
'crs_waiting_list'),
$row, $col++);
426 if (isset($this->agreement[$usr_id])) {
427 if ($this->agreement[$usr_id][
'accepted']) {
428 #$this->csv->addColumn(il-Format::format-Unix-Time($this->agreement[$usr_id]['acceptance_time'],true)); 432 #$this->csv->addColumn($this->lng->txt('ps_not_accepted')); 433 $this->
addCol($this->lng->txt(
'ps_not_accepted'),
$row, $col++);
436 #$this->csv->addColumn($this->lng->txt('ps_not_accepted')); 437 $this->
addCol($this->lng->txt(
'ps_not_accepted'),
$row, $col++);
443 #$this->csv->addColumn($this->user_profile_data[$usr_id]['login']); 444 $this->
addCol($this->user_profile_data[$usr_id][
'login'],
$row, $col++);
449 #$this->csv->addColumn($this->user_profile_data[$usr_id][$field]); 450 $this->
addCol($this->user_profile_data[$usr_id][$field],
$row, $col++);
453 case 'consultation_hour':
454 include_once
'./Services/Booking/classes/class.ilBookingEntry.php';
458 foreach ((array) $bookings[$usr_id] as $ut) {
464 if (strlen($ut[
'explanation'])) {
465 $tmp .=
' ' . $ut[
'explanation'];
469 $uts_str = implode(
',', $uts);
472 case 'crs_members_groups':
475 foreach (array_keys($this->groups) as $grp_ref) {
476 if (in_array($usr_id, $this->groups_participants[$grp_ref])
477 && $this->groups_rights[$grp_ref]) {
478 $groups[] = $this->groups[$grp_ref];
490 if (!$this->privacy->courseConfirmationRequired()
or $this->agreement[$usr_id][
'accepted']) {
491 #$this->csv->addColumn($this->user_profile_data[$usr_id][$field]); 492 $this->
addCol($this->user_profile_data[$usr_id][$field],
$row, $col++);
494 #$this->csv->addColumn(''); 501 #$this->csv->addRow(); 518 if ($this->
settings->enabled(
'admin')) {
519 $this->user_ids = $tmp_ids = $this->members->getAdmins();
522 if ($this->
settings->enabled(
'tutor')) {
523 $this->user_ids = array_merge($tmp_ids = $this->members->getTutors(),
$this->user_ids);
526 if ($this->
settings->enabled(
'member')) {
527 $this->user_ids = array_merge($tmp_ids = $this->members->getMembers(),
$this->user_ids);
530 if ($this->
settings->enabled(
'subscribers')) {
531 $this->user_ids = array_merge($tmp_ids = $this->members->getSubscribers(),
$this->user_ids);
534 if ($this->
settings->enabled(
'waiting_list')) {
535 include_once(
'Modules/Course/classes/class.ilCourseWaitingList.php');
537 $this->user_ids = array_merge($waiting_list->getUserIds(),
$this->user_ids);
539 $this->user_ids = $this->
filterUsers($this->user_ids);
542 $this->user_ids =
ilUtil::_sortIds($this->user_ids,
'usr_data',
'lastname',
'usr_id');
556 foreach ($a_user_ids as $user_id) {
558 if ($this->members->isAdmin($user_id)) {
560 } elseif ($this->members->isTutor($user_id)) {
561 $this->user_course_data[$user_id][
'role'] =
IL_CRS_TUTOR;
562 } elseif ($this->members->isMember($user_id)) {
565 $this->user_course_data[$user_id][
'role'] =
'subscriber';
579 include_once(
'Modules/Course/classes/Export/class.ilCourseUserData.php');
594 if (substr($a_field, 0, 4) !=
'cdf_') {
597 if (!$this->privacy->courseConfirmationRequired()
or $this->agreement[$a_usr_id][
'accepted']) {
598 $field_info = explode(
'_', $a_field);
599 $field_id = $field_info[1];
600 $value = $this->user_course_fields[$a_usr_id][$field_id];
601 #$this->csv->addColumn($value); 605 #$this->csv->addColumn(''); 620 if (substr($a_field, 0, 4) !=
'udf_') {
624 if (!$this->privacy->courseConfirmationRequired()
or $this->agreement[$udf_data->getUserId()][
'accepted']) {
625 $field_info = explode(
'_', $a_field);
626 $field_id = $field_info[1];
627 $value = $udf_data->get(
'f_' . $field_id);
628 #$this->csv->addColumn($value); 643 if ($this->
getType() ==
'crs') {
646 if ($this->
getType() ==
'grp') {
656 $tree = $DIC[
'tree'];
657 $ilAccess = $DIC[
'ilAccess'];
658 $parent_node =
$tree->getNodeData($this->ref_id);
661 include_once(
'./Modules/Group/classes/class.ilGroupParticipants.php');
662 $this->groups_rights = array();
663 foreach (
$groups as $idx => $group_data) {
665 if ($group_data[
"parent"] != $this->ref_id &&
$tree->checkForParentType($group_data[
"ref_id"],
"grp",
true)) {
668 $this->groups[$group_data[
"ref_id"]] = $group_data[
"title"];
671 $this->groups_rights[$group_data[
"ref_id"]] = (bool) $ilAccess->checkAccess(
"write",
"", $group_data[
"ref_id"]);
673 $this->groups_participants[$group_data[
"ref_id"]] = $gobj->getParticipants();
__construct($a_ref_id, $a_type=self::EXPORT_CSV)
Constructor.
Class for generation of member export files.
getCSVString()
toString method
static _getInstance()
Get instance.
Helper class to generate CSV files.
createCSV()
Create CSV File.
readCourseData($a_user_ids, $a_status='member')
Read All User related course data.
getOrderedExportableFields()
Get ordered enabled fields.
static lookupManagedBookingsForObject($a_obj_id, $a_usr_id)
Lookup bookings for own and managed consultation hours of an object.
addUserDefinedField($udf_data, $a_field, $row, $col)
Add user defined fields.
static _getValuesByObjId($a_obj_id)
Get values by obj_id (for all users)
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
readCourseSpecificFieldsData()
Read course specific fields data.
static setUseRelativeDates($a_status)
set use relative dates
create()
Create Export File.
static _readByObjId($a_obj_id)
Read user data by object id.
static _readUsersProfileData($a_user_ids)
STATIC METHOD get user data of selected users.
setFilename($a_file)
set filename
getFilename()
get filename
static lookupOrgUnitsRepresentation($a_usr_id)
lokup org unit representation
static _sortIds($a_ids, $a_table, $a_field, $a_id_name)
Function that sorts ids by a given table field using WHERE IN E.g: __sort(array(6,7),'usr_data','lastname','usr_id') => sorts by lastname.
static _getInstanceByType($a_type)
Get Singleton Instance.
addCol($a_value, $a_row, $a_col)
Write on column.
const IL_CRS_ADMIN
Base class for course and group participants.
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static _lookupType($a_id, $a_reference=false)
lookup object type
addCourseField($a_usr_id, $a_field, $row, $col)
fill course specific fields
getExportType()
get current export type
static formatPeriod(ilDateTime $start, ilDateTime $end, $a_skip_starting_day=false)
Format a period of two date Shows: 14.
fetchUsers()
Fetch all users that will be exported.
initMembers()
Init member object.
static _getInstance()
Get instance of ilPrivacySettings.
static _lookupName($a_field_id)
Lookup field name.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
static _getFields($a_container_id, $a_sort=IL_CDF_SORT_NAME)
Get all fields of a container.