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",
'"');
77 global $ilObjDataCache,
$lng;
83 $this->ref_id = $a_ref_id;
84 $this->obj_id = $ilObjDataCache->lookupObjId($this->ref_id);
98 return $GLOBALS[
'DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
113 $this->filename = $a_file;
173 case self::EXPORT_CSV:
177 case self::EXPORT_EXCEL:
192 return $this->csv->getCSVString();
202 include_once
"./Services/Excel/classes/class.ilExcel.php";
204 $this->
worksheet->addSheet($this->lng->txt(
"members"));
219 include_once(
'Services/Utilities/classes/class.ilCSVWriter.php');
234 protected function addCol($a_value, $a_row, $a_col)
237 case self::EXPORT_CSV:
238 $this->csv->addColumn($a_value);
241 case self::EXPORT_EXCEL:
242 $this->
worksheet->setCell($a_row+1, $a_col, $a_value);
254 case self::EXPORT_CSV:
255 $this->csv->addRow();
258 case self::EXPORT_EXCEL:
272 include_once(
'Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
273 include_once(
'Services/PrivacySecurity/classes/class.ilExportFieldsInfo.php');
274 include_once(
'Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
275 include_once(
'Services/User/classes/class.ilUserDefinedFields.php');
278 $field_info->sortExportFields();
282 if (
$privacy->courseConfirmationRequired()) {
283 $fields[] =
'agreement';
286 foreach ($field_info->getExportableFields() as $field) {
287 if ($this->
settings->enabled($field)) {
293 foreach ($udf->getCourseExportableFields() as $field_id => $udf_data) {
294 if ($this->
settings->enabled(
'udf_' . $field_id)) {
295 $fields[] =
'udf_' . $field_id;
301 if ($this->
settings->enabled(
'cdf_' . $field_obj->getId())) {
302 $fields[] =
'cdf_' . $field_obj->getId();
305 if ($this->
settings->enabled(
'group_memberships')) {
306 $fields[] =
'crs_members_groups';
309 return $fields ? $fields :
array();
324 #$this->csv->addColumn($this->lng->txt($this->getType().'_role_status')); 325 $this->
addCol($this->lng->txt($this->getType() .
'_role_status'),
$row, $col++);
328 #$this->csv->addColumn($this->lng->txt('ps_agreement_accepted')); 329 $this->
addCol($this->lng->txt(
'ps_agreement_accepted'),
$row, $col++);
331 case 'consultation_hour':
332 $this->lng->loadLanguageModule(
'dateplaner');
333 $this->
addCol($this->lng->txt(
'cal_ch_field_ch'),
$row, $col++);
337 $this->
addCol($this->lng->txt(
'org_units'),
$row, $col++);
341 if (substr($field, 0, 4) ==
'udf_') {
342 $field_id = explode(
'_', $field);
343 include_once(
'Services/User/classes/class.ilUserDefinedFields.php');
345 $def = $udf->getDefinition($field_id[1]);
346 #$this->csv->addColumn($def['field_name']); 348 } elseif (substr($field, 0, 4) ==
'cdf_') {
349 $field_id = explode(
'_', $field);
350 #$this->csv->addColumn(ilCourseDefinedFieldDefinition::_lookupName($field_id[1])); 352 } elseif ($field ==
"username") {
353 $this->
addCol($this->lng->txt(
"login"),
$row, $col++);
355 #$this->csv->addColumn($this->lng->txt($field)); 356 $this->
addCol($this->lng->txt($field),
$row, $col++);
361 #$this->csv->addRow(); 364 foreach ($this->user_ids as $usr_id) {
369 foreach ($all_fields as $field) {
383 switch ($this->user_course_data[$usr_id][
'role']) {
385 #$this->csv->addColumn($this->lng->txt('crs_admin')); 386 $this->
addCol($this->lng->txt(
'crs_admin'),
$row, $col++);
390 #$this->csv->addColumn($this->lng->txt('crs_tutor')); 391 $this->
addCol($this->lng->txt(
'crs_tutor'),
$row, $col++);
395 #$this->csv->addColumn($this->lng->txt('crs_member')); 396 $this->
addCol($this->lng->txt(
'crs_member'),
$row, $col++);
400 #$this->csv->addColumn($this->lng->txt('il_grp_admin')); 401 $this->
addCol($this->lng->txt(
'il_grp_admin'),
$row, $col++);
405 #$this->csv->addColumn($this->lng->txt('il_grp_member')); 406 $this->
addCol($this->lng->txt(
'il_grp_member'),
$row, $col++);
410 #$this->csv->addColumn($this->lng->txt($this->getType().'_subscriber')); 411 $this->
addCol($this->lng->txt($this->getType() .
'_subscriber'),
$row, $col++);
415 #$this->csv->addColumn($this->lng->txt('crs_waiting_list')); 416 $this->
addCol($this->lng->txt(
'crs_waiting_list'),
$row, $col++);
423 if (isset($this->agreement[$usr_id])) {
424 if ($this->agreement[$usr_id][
'accepted']) {
425 #$this->csv->addColumn(il-Format::format-Unix-Time($this->agreement[$usr_id]['acceptance_time'],true)); 429 #$this->csv->addColumn($this->lng->txt('ps_not_accepted')); 430 $this->
addCol($this->lng->txt(
'ps_not_accepted'),
$row, $col++);
433 #$this->csv->addColumn($this->lng->txt('ps_not_accepted')); 434 $this->
addCol($this->lng->txt(
'ps_not_accepted'),
$row, $col++);
440 #$this->csv->addColumn($this->user_profile_data[$usr_id]['login']); 441 $this->
addCol($this->user_profile_data[$usr_id][
'login'],
$row, $col++);
446 #$this->csv->addColumn($this->user_profile_data[$usr_id][$field]); 447 $this->
addCol($this->user_profile_data[$usr_id][$field],
$row, $col++);
450 case 'consultation_hour':
451 include_once
'./Services/Booking/classes/class.ilBookingEntry.php';
455 foreach ((
array) $bookings[$usr_id] as $ut) {
461 if (strlen($ut[
'explanation'])) {
462 $tmp .=
' ' . $ut[
'explanation'];
466 $uts_str = implode(
',', $uts);
469 case 'crs_members_groups':
472 foreach (array_keys($this->groups) as $grp_ref) {
473 if (in_array($usr_id, $this->groups_participants[$grp_ref])
474 && $this->groups_rights[$grp_ref]) {
475 $groups[] = $this->groups[$grp_ref];
487 if (!$this->privacy->courseConfirmationRequired() or $this->agreement[$usr_id][
'accepted']) {
488 #$this->csv->addColumn($this->user_profile_data[$usr_id][$field]); 489 $this->
addCol($this->user_profile_data[$usr_id][$field],
$row, $col++);
491 #$this->csv->addColumn(''); 498 #$this->csv->addRow(); 515 if ($this->
settings->enabled(
'admin')) {
516 $this->user_ids = $tmp_ids = $this->members->getAdmins();
519 if ($this->
settings->enabled(
'tutor')) {
520 $this->user_ids = array_merge($tmp_ids = $this->members->getTutors(),
$this->user_ids);
523 if ($this->
settings->enabled(
'member')) {
524 $this->user_ids = array_merge($tmp_ids = $this->members->getMembers(),
$this->user_ids);
527 if ($this->
settings->enabled(
'subscribers')) {
528 $this->user_ids = array_merge($tmp_ids = $this->members->getSubscribers(),
$this->user_ids);
531 if ($this->
settings->enabled(
'waiting_list')) {
532 include_once(
'Modules/Course/classes/class.ilCourseWaitingList.php');
534 $this->user_ids = array_merge($waiting_list->getUserIds(),
$this->user_ids);
536 $this->user_ids = $this->
filterUsers($this->user_ids);
539 $this->user_ids =
ilUtil::_sortIds($this->user_ids,
'usr_data',
'lastname',
'usr_id');
553 foreach ($a_user_ids as $user_id) {
555 if ($this->members->isAdmin($user_id)) {
557 } elseif ($this->members->isTutor($user_id)) {
558 $this->user_course_data[$user_id][
'role'] =
IL_CRS_TUTOR;
559 } elseif ($this->members->isMember($user_id)) {
562 $this->user_course_data[$user_id][
'role'] =
'subscriber';
576 include_once(
'Modules/Course/classes/Export/class.ilCourseUserData.php');
591 if (substr($a_field, 0, 4) !=
'cdf_') {
594 if (!$this->privacy->courseConfirmationRequired() or $this->agreement[$a_usr_id][
'accepted']) {
595 $field_info = explode(
'_', $a_field);
596 $field_id = $field_info[1];
597 $value = $this->user_course_fields[$a_usr_id][$field_id];
598 #$this->csv->addColumn($value); 602 #$this->csv->addColumn(''); 617 if (substr($a_field, 0, 4) !=
'udf_') {
620 if (!$this->privacy->courseConfirmationRequired() or $this->agreement[$udf_data->getUserId()][
'accepted']) {
621 $field_info = explode(
'_', $a_field);
622 $field_id = $field_info[1];
623 $value = $udf_data->get(
'f_' . $field_id);
624 #$this->csv->addColumn($value); 628 #$this->csv->addColumn(''); 638 if ($this->
getType() ==
'crs') {
641 if ($this->
getType() ==
'grp') {
649 global $tree, $ilAccess;
650 $parent_node = $tree->getNodeData($this->ref_id);
651 $groups = $tree->getSubTree($parent_node,
true,
"grp");
653 include_once(
'./Modules/Group/classes/class.ilGroupParticipants.php');
654 $this->groups_rights =
array();
655 foreach (
$groups as $idx => $group_data) {
657 if ($group_data[
"parent"] != $this->ref_id && $tree->checkForParentType($group_data[
"ref_id"],
"grp",
true)) {
660 $this->groups[$group_data[
"ref_id"]] = $group_data[
"title"];
663 $this->groups_rights[$group_data[
"ref_id"]] = (bool) $ilAccess->checkAccess(
"write",
"", $group_data[
"ref_id"]);
665 $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)
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
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.
Create styles array
The data for the language used.
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.
static _getFields($a_container_id, $a_sort=IL_CDF_SORT_NAME)
Get all fields of a container.