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);
102 $this->filename = $a_file;
163 case self::EXPORT_CSV:
167 case self::EXPORT_EXCEL:
182 return $this->csv->getCSVString();
192 include_once
"./Services/Excel/classes/class.ilExcel.php";
194 $this->
worksheet->addSheet($this->lng->txt(
"members"));
209 include_once(
'Services/Utilities/classes/class.ilCSVWriter.php');
224 protected function addCol($a_value,$a_row,$a_col)
228 case self::EXPORT_CSV:
229 $this->csv->addColumn($a_value);
232 case self::EXPORT_EXCEL:
233 $this->
worksheet->setCell($a_row+1,$a_col,$a_value);
246 case self::EXPORT_CSV:
247 $this->csv->addRow();
250 case self::EXPORT_EXCEL:
264 include_once(
'Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
265 include_once(
'Services/PrivacySecurity/classes/class.ilExportFieldsInfo.php');
266 include_once(
'Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
267 include_once(
'Services/User/classes/class.ilUserDefinedFields.php');
270 $field_info->sortExportFields();
274 if(
$privacy->courseConfirmationRequired())
276 $fields[] =
'agreement';
279 foreach($field_info->getExportableFields() as $field)
281 if($this->
settings->enabled($field))
288 foreach($udf->getCourseExportableFields() as $field_id => $udf_data)
290 if($this->
settings->enabled(
'udf_'.$field_id))
292 $fields[] =
'udf_'.$field_id;
299 if($this->
settings->enabled(
'cdf_'.$field_obj->getId()))
301 $fields[] =
'cdf_'.$field_obj->getId();
304 if($this->
settings->enabled(
'group_memberships'))
306 $fields[] =
'crs_members_groups';
309 return $fields ? $fields :
array();
326 #$this->csv->addColumn($this->lng->txt($this->getType().'_role_status')); 327 $this->
addCol($this->lng->txt($this->getType().
'_role_status'),
$row, $col++);
330 #$this->csv->addColumn($this->lng->txt('ps_agreement_accepted')); 331 $this->
addCol($this->lng->txt(
'ps_agreement_accepted'),
$row, $col++);
333 case 'consultation_hour':
334 $this->lng->loadLanguageModule(
'dateplaner');
335 $this->
addCol($this->lng->txt(
'cal_ch_field_ch'),
$row, $col++);
339 $this->
addCol($this->lng->txt(
'org_units'),
$row, $col++);
343 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']); 350 $this->
addCol($def[
'field_name'],
$row, $col++);
352 elseif(substr($field,0,4) ==
'cdf_')
354 $field_id = explode(
'_',$field);
355 #$this->csv->addColumn(ilCourseDefinedFieldDefinition::_lookupName($field_id[1])); 357 }elseif($field ==
"username")
359 $this->
addCol($this->lng->txt(
"login"),
$row, $col++);
363 #$this->csv->addColumn($this->lng->txt($field)); 364 $this->
addCol($this->lng->txt($field),
$row, $col++);
369 #$this->csv->addRow(); 372 foreach($this->user_ids as $usr_id)
378 foreach($all_fields as $field)
396 switch($this->user_course_data[$usr_id][
'role'])
399 #$this->csv->addColumn($this->lng->txt('crs_admin')); 400 $this->
addCol($this->lng->txt(
'crs_admin'),
$row, $col++);
404 #$this->csv->addColumn($this->lng->txt('crs_tutor')); 405 $this->
addCol($this->lng->txt(
'crs_tutor'),
$row, $col++);
409 #$this->csv->addColumn($this->lng->txt('crs_member')); 410 $this->
addCol($this->lng->txt(
'crs_member'),
$row, $col++);
414 #$this->csv->addColumn($this->lng->txt('il_grp_admin')); 415 $this->
addCol($this->lng->txt(
'il_grp_admin'),
$row, $col++);
419 #$this->csv->addColumn($this->lng->txt('il_grp_member')); 420 $this->
addCol($this->lng->txt(
'il_grp_member'),
$row, $col++);
424 #$this->csv->addColumn($this->lng->txt($this->getType().'_subscriber')); 425 $this->
addCol($this->lng->txt($this->getType().
'_subscriber'),
$row, $col++);
429 #$this->csv->addColumn($this->lng->txt('crs_waiting_list')); 430 $this->
addCol($this->lng->txt(
'crs_waiting_list'),
$row, $col++);
437 if(isset($this->agreement[$usr_id]))
439 if($this->agreement[$usr_id][
'accepted'])
441 #$this->csv->addColumn(il-Format::format-Unix-Time($this->agreement[$usr_id]['acceptance_time'],true)); 447 #$this->csv->addColumn($this->lng->txt('ps_not_accepted')); 448 $this->
addCol($this->lng->txt(
'ps_not_accepted'),
$row,$col++);
453 #$this->csv->addColumn($this->lng->txt('ps_not_accepted')); 454 $this->
addCol($this->lng->txt(
'ps_not_accepted'),
$row,$col++);
460 #$this->csv->addColumn($this->user_profile_data[$usr_id]['login']); 461 $this->
addCol($this->user_profile_data[$usr_id][
'login'],
$row,$col++);
466 #$this->csv->addColumn($this->user_profile_data[$usr_id][$field]); 467 $this->
addCol($this->user_profile_data[$usr_id][$field],
$row,$col++);
470 case 'consultation_hour':
471 include_once
'./Services/Booking/classes/class.ilBookingEntry.php';
475 foreach((
array) $bookings[$usr_id] as $ut)
482 if(strlen($ut[
'explanation']))
484 $tmp .=
' '.$ut[
'explanation'];
488 $uts_str = implode(
',',$uts);
491 case 'crs_members_groups':
494 foreach(array_keys($this->groups) as $grp_ref)
496 if(in_array($usr_id, $this->groups_participants[$grp_ref])
497 && $this->groups_rights[$grp_ref])
499 $groups[] = $this->groups[$grp_ref];
511 if(!$this->privacy->courseConfirmationRequired()
or $this->agreement[$usr_id][
'accepted'])
513 #$this->csv->addColumn($this->user_profile_data[$usr_id][$field]); 514 $this->
addCol($this->user_profile_data[$usr_id][$field],
$row,$col++);
518 #$this->csv->addColumn(''); 525 #$this->csv->addRow(); 543 if($this->
settings->enabled(
'admin'))
545 $this->user_ids = $tmp_ids = $this->members->getAdmins();
548 if($this->
settings->enabled(
'tutor'))
550 $this->user_ids = array_merge($tmp_ids = $this->members->getTutors(),
$this->user_ids);
553 if($this->
settings->enabled(
'member'))
555 $this->user_ids = array_merge($tmp_ids = $this->members->getMembers(),
$this->user_ids);
558 if($this->
settings->enabled(
'subscribers'))
560 $this->user_ids = array_merge($tmp_ids = $this->members->getSubscribers(),
$this->user_ids);
563 if($this->
settings->enabled(
'waiting_list'))
565 include_once(
'Modules/Course/classes/class.ilCourseWaitingList.php');
567 $this->user_ids = array_merge($waiting_list->getUserIds(),
$this->user_ids);
571 $this->user_ids =
ilUtil::_sortIds($this->user_ids,
'usr_data',
'lastname',
'usr_id');
585 foreach($a_user_ids as $user_id)
588 if($this->members->isAdmin($user_id))
592 elseif($this->members->isTutor($user_id))
594 $this->user_course_data[$user_id][
'role'] =
IL_CRS_TUTOR;
596 elseif($this->members->isMember($user_id))
602 $this->user_course_data[$user_id][
'role'] =
'subscriber';
616 include_once(
'Modules/Course/classes/Export/class.ilCourseUserData.php');
631 if(substr($a_field,0,4) !=
'cdf_')
635 if(!$this->privacy->courseConfirmationRequired()
or $this->agreement[$a_usr_id][
'accepted'])
637 $field_info = explode(
'_',$a_field);
638 $field_id = $field_info[1];
639 $value = $this->user_course_fields[$a_usr_id][$field_id];
640 #$this->csv->addColumn($value); 644 #$this->csv->addColumn(''); 660 if(substr($a_field,0,4) !=
'udf_')
664 if(!$this->privacy->courseConfirmationRequired()
or $this->agreement[$udf_data->getUserId()][
'accepted'])
666 $field_info = explode(
'_',$a_field);
667 $field_id = $field_info[1];
668 $value = $udf_data->get(
'f_'.$field_id);
669 #$this->csv->addColumn($value); 673 #$this->csv->addColumn(''); 696 global $tree, $ilAccess;
697 $parent_node = $tree->getNodeData($this->ref_id);
698 $groups = $tree->getSubTree($parent_node,
true,
"grp");
701 include_once(
'./Modules/Group/classes/class.ilGroupParticipants.php');
702 $this->groups_rights =
array();
703 foreach(
$groups as $idx => $group_data)
706 if($group_data[
"parent"] != $this->ref_id && $tree->checkForParentType($group_data[
"ref_id"],
"grp",
true))
712 $this->groups[$group_data[
"ref_id"]] = $group_data[
"title"];
715 $this->groups_rights[$group_data[
"ref_id"]] = (bool)$ilAccess->checkAccess(
"write",
"", $group_data[
"ref_id"]);
717 $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 formatPeriod(ilDateTime $start, ilDateTime $end)
Format a period of two date Shows: 14.
$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
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.