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++);
324 case 'consultation_hour':
325 $this->lng->loadLanguageModule(
'dateplaner');
326 $this->
addCol($this->lng->txt(
'cal_ch_field_ch'),
$row, $col++);
330 if(substr($field,0,4) ==
'udf_')
332 $field_id = explode(
'_',$field);
333 include_once(
'Services/User/classes/class.ilUserDefinedFields.php');
335 $def = $udf->getDefinition($field_id[1]);
336 #$this->csv->addColumn($def['field_name']); 337 $this->
addCol($def[
'field_name'],
$row, $col++);
339 elseif(substr($field,0,4) ==
'cdf_')
341 $field_id = explode(
'_',$field);
342 #$this->csv->addColumn(ilCourseDefinedFieldDefinition::_lookupName($field_id[1])); 347 #$this->csv->addColumn($this->lng->txt($field)); 348 $this->
addCol($this->lng->txt($field),
$row, $col++);
353 #$this->csv->addRow(); 356 foreach($this->user_ids as
$usr_id)
362 foreach($all_fields as $field)
380 switch($this->user_course_data[$usr_id][
'role'])
383 #$this->csv->addColumn($this->lng->txt('crs_admin')); 384 $this->
addCol($this->lng->txt(
'crs_admin'),
$row, $col++);
388 #$this->csv->addColumn($this->lng->txt('crs_tutor')); 389 $this->
addCol($this->lng->txt(
'crs_tutor'),
$row, $col++);
393 #$this->csv->addColumn($this->lng->txt('crs_member')); 394 $this->
addCol($this->lng->txt(
'crs_member'),
$row, $col++);
398 #$this->csv->addColumn($this->lng->txt('il_grp_admin')); 399 $this->
addCol($this->lng->txt(
'il_grp_admin'),
$row, $col++);
403 #$this->csv->addColumn($this->lng->txt('il_grp_member')); 404 $this->
addCol($this->lng->txt(
'il_grp_member'),
$row, $col++);
408 #$this->csv->addColumn($this->lng->txt($this->getType().'_subscriber')); 409 $this->
addCol($this->lng->txt($this->getType().
'_subscriber'),
$row, $col++);
413 #$this->csv->addColumn($this->lng->txt('crs_waiting_list')); 414 $this->
addCol($this->lng->txt(
'crs_waiting_list'),
$row, $col++);
421 if(isset($this->agreement[$usr_id]))
423 if($this->agreement[$usr_id][
'accepted'])
425 #$this->csv->addColumn(ilFormat::formatUnixTime($this->agreement[$usr_id]['acceptance_time'],true)); 430 #$this->csv->addColumn($this->lng->txt('ps_not_accepted')); 431 $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)
465 if(strlen($ut[
'explanation']))
467 $tmp .=
' '.$ut[
'explanation'];
471 $uts_str = implode(
',',$uts);
478 or $this->agreement[$usr_id][
'accepted'])
480 #$this->csv->addColumn($this->user_profile_data[$usr_id][$field]); 481 $this->
addCol($this->user_profile_data[$usr_id][$field],
$row,$col++);
485 #$this->csv->addColumn(''); 492 #$this->csv->addRow(); 510 if($this->settings->enabled(
'admin'))
512 $this->user_ids = $tmp_ids = $this->members->getAdmins();
515 if($this->settings->enabled(
'tutor'))
517 $this->user_ids = array_merge($tmp_ids = $this->members->getTutors(),
$this->user_ids);
520 if($this->settings->enabled(
'member'))
522 $this->user_ids = array_merge($tmp_ids = $this->members->getMembers(),
$this->user_ids);
525 if($this->settings->enabled(
'subscribers'))
527 $this->user_ids = array_merge($tmp_ids = $this->members->getSubscribers(),
$this->user_ids);
530 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);
538 $this->user_ids =
ilUtil::_sortIds($this->user_ids,
'usr_data',
'lastname',
'usr_id');
552 foreach($a_user_ids as $user_id)
555 if($this->members->isAdmin($user_id))
559 elseif($this->members->isTutor($user_id))
561 $this->user_course_data[$user_id][
'role'] =
IL_CRS_TUTOR;
563 elseif($this->members->isMember($user_id))
569 $this->user_course_data[$user_id][
'role'] =
'subscriber';
583 include_once(
'Modules/Course/classes/Export/class.ilCourseUserData.php');
598 if(substr($a_field,0,4) !=
'cdf_')
603 or $this->agreement[$a_usr_id][
'accepted'])
605 $field_info = explode(
'_',$a_field);
606 $field_id = $field_info[1];
607 $value = $this->user_course_fields[$a_usr_id][$field_id];
608 #$this->csv->addColumn($value); 612 #$this->csv->addColumn(''); 628 if(substr($a_field,0,4) !=
'udf_')
632 if(!$this->privacy->courseConfirmationRequired() or $this->agreement[$udf_data->getUserId()][
'accepted'])
634 $field_info = explode(
'_',$a_field);
635 $field_id = $field_info[1];
636 $value = $udf_data->get(
'f_'.$field_id);
637 #$this->csv->addColumn($value); 641 #$this->csv->addColumn('');
__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.
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
Class ilExcelWriterAdapter.
getFilename()
get filename
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
static _hasFields($a_container_id)
Check if there are any define fields.
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.