ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilMemberExport Class Reference

Class for generation of member export files. More...

+ Collaboration diagram for ilMemberExport:

Public Member Functions

 __construct ($a_ref_id)
 Constructor.
 create ()
 Create Export File.
 getCSVString ()
 toString method
 createCSV ()
 Create CSV File.

Private Member Functions

 fetchUsers ()
 Fetch all users that will be exported.
 readCourseData ($a_user_ids, $a_status= 'member')
 Read All User related course data.
 readCourseSpecificFieldsData ()
 Read course specific fields data.
 addCourseField ($a_usr_id, $a_field)
 fill course specific fields
 addUserDefinedField ($udf_data, $a_field)
 Add user defined fields.

Private Attributes

 $ref_id
 $obj_id
 $course
 $members
 $lng
 $settings
 $user_ids = array()
 $user_course_data = array()
 $user_course_fields = array()
 $user_profile_data = array()
 $privacy

Detailed Description

Class for generation of member export files.

Author
Stefan Meyer smeye.nosp@m.r@da.nosp@m.tabay.nosp@m..de
Version
$Id$

/

Definition at line 42 of file class.ilMemberExport.php.

Constructor & Destructor Documentation

ilMemberExport::__construct (   $a_ref_id)

Constructor.

public

Definition at line 65 of file class.ilMemberExport.php.

References $lng, $obj_id, ilPrivacySettings\_getInstance(), ilCourseParticipants\_getInstanceByObjId(), ilCourseAgreement\_readByObjId(), and ilObjectFactory\getInstanceByRefId().

{
global $ilUser,$ilObjDataCache,$lng;
$this->lng = $lng;
$this->ref_id = $a_ref_id;
$this->obj_id = $ilObjDataCache->lookupObjId($this->ref_id);
$this->course = ilObjectFactory::getInstanceByRefId($this->ref_id,false);
$this->members = ilCourseParticipants::_getInstanceByObjId($this->obj_id);
$this->agreement = ilCourseAgreement::_readByObjId($this->obj_id);
$this->settings = new ilExportUserSettings($ilUser->getId(),$this->obj_id);
$this->privacy = ilPrivacySettings::_getInstance();
}

+ Here is the call graph for this function:

Member Function Documentation

ilMemberExport::addCourseField (   $a_usr_id,
  $a_field 
)
private

fill course specific fields

private

Parameters
intusr_id
stringfield
Returns
bool

Definition at line 339 of file class.ilMemberExport.php.

References ilCourseDefinedFieldDefinition\_getFields().

Referenced by createCSV().

{
if(substr($a_field,0,4) != 'cdf_')
{
return false;
}
if((!$this->privacy->confirmationRequired() and ilCourseDefinedFieldDefinition::_getFields($this->obj_id))
or $this->agreement[$a_usr_id]['accepted'])
{
$field_info = explode('_',$a_field);
$field_id = $field_info[1];
$value = $this->user_course_fields[$a_usr_id][$field_id];
$this->csv->addColumn($value);
return true;
}
$this->csv->addColumn('');
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilMemberExport::addUserDefinedField (   $udf_data,
  $a_field 
)
private

Add user defined fields.

private

Parameters
objectuser defined data object
intfield

Definition at line 367 of file class.ilMemberExport.php.

Referenced by createCSV().

{
if(substr($a_field,0,4) != 'udf_')
{
return false;
}
if(!$this->privacy->confirmationRequired() or $this->agreement[$udf_data->getUserId()]['accepted'])
{
$field_info = explode('_',$a_field);
$field_id = $field_info[1];
$value = $udf_data->get($field_id);
$this->csv->addColumn($value);
return true;
}
$this->csv->addColumn('');
}

+ Here is the caller graph for this function:

ilMemberExport::create ( )

Create Export File.

public

Definition at line 87 of file class.ilMemberExport.php.

References createCSV(), and fetchUsers().

{
$this->fetchUsers();
// TODO: Switch different export types
$this->createCSV();
}

+ Here is the call graph for this function:

ilMemberExport::createCSV ( )

Create CSV File.

public

Definition at line 114 of file class.ilMemberExport.php.

References ilCourseDefinedFieldDefinition\_getFields(), ilUserDefinedFields\_getInstance(), ilCourseDefinedFieldDefinition\_lookupName(), addCourseField(), addUserDefinedField(), ilFormat\formatUnixTime(), IL_CRS_ADMIN, IL_CRS_MEMBER, and IL_CRS_TUTOR.

Referenced by create().

{
include_once('Services/Utilities/classes/class.ilCSVWriter.php');
$this->csv = new ilCSVWriter();
// Add header line
foreach($all_fields = $this->settings->getOrderedExportableFields() as $field)
{
switch($field)
{
case 'role':
$this->csv->addColumn($this->lng->txt('crs_role_status'));
break;
case 'agreement':
$this->csv->addColumn($this->lng->txt('ps_agreement_accepted'));
break;
default:
if(substr($field,0,4) == 'udf_')
{
$field_id = explode('_',$field);
include_once('Services/User/classes/class.ilUserDefinedFields.php');
$def = $udf->getDefinition($field_id[1]);
$this->csv->addColumn($def['field_name']);
}
elseif(substr($field,0,4) == 'cdf_')
{
$field_id = explode('_',$field);
$this->csv->addColumn(ilCourseDefinedFieldDefinition::_lookupName($field_id[1]));
}
else
{
$this->csv->addColumn($this->lng->txt($field));
}
break;
}
}
$this->csv->addRow();
// Add user data
foreach($this->user_ids as $usr_id)
{
$udf_data = new ilUserDefinedData($usr_id);
foreach($all_fields as $field)
{
// Handle course defined fields
if($this->addUserDefinedField($udf_data,$field))
{
continue;
}
if($this->addCourseField($usr_id,$field))
{
continue;
}
switch($field)
{
case 'role':
switch($this->user_course_data[$usr_id]['role'])
{
$this->csv->addColumn($this->lng->txt('crs_admin'));
break;
$this->csv->addColumn($this->lng->txt('crs_tutor'));
break;
$this->csv->addColumn($this->lng->txt('crs_member'));
break;
case 'subscriber':
$this->csv->addColumn($this->lng->txt('crs_subscriber'));
break;
default:
$this->csv->addColumn($this->lng->txt('crs_waiting_list'));
break;
}
break;
case 'agreement':
if(isset($this->agreement[$usr_id]))
{
if($this->agreement[$usr_id]['accepted'])
{
$this->csv->addColumn(ilFormat::formatUnixTime($this->agreement[$usr_id]['acceptance_time'],true));
}
else
{
$this->csv->addColumn($this->lng->txt('ps_not_accepted'));
}
}
else
{
$this->csv->addColumn($this->lng->txt('ps_not_accepted'));
}
break;
// These fields are always enabled
case 'login':
case 'firstname':
case 'lastname':
$this->csv->addColumn($this->user_profile_data[$usr_id][$field]);
break;
default:
// Check aggreement
if((!$this->privacy->confirmationRequired() and !ilCourseDefinedFieldDefinition::_getFields($this->obj_id))
or $this->agreement[$usr_id]['accepted'])
{
$this->csv->addColumn($this->user_profile_data[$usr_id][$field]);
}
else
{
$this->csv->addColumn('');
}
break;
}
}
$this->csv->addRow();
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilMemberExport::fetchUsers ( )
private

Fetch all users that will be exported.

private

Definition at line 249 of file class.ilMemberExport.php.

References $user_ids, ilObjUser\_readUsersProfileData(), ilUtil\_sortIds(), readCourseData(), and readCourseSpecificFieldsData().

Referenced by create().

{
if($this->settings->enabled('admin'))
{
$this->user_ids = $tmp_ids = $this->members->getAdmins();
$this->readCourseData($tmp_ids);
}
if($this->settings->enabled('tutor'))
{
$this->user_ids = array_merge($tmp_ids = $this->members->getTutors(),$this->user_ids);
$this->readCourseData($tmp_ids);
}
if($this->settings->enabled('member'))
{
$this->user_ids = array_merge($tmp_ids = $this->members->getMembers(),$this->user_ids);
$this->readCourseData($tmp_ids);
}
if($this->settings->enabled('subscribers'))
{
$this->user_ids = array_merge($tmp_ids = $this->members->getSubscribers(),$this->user_ids);
$this->readCourseData($tmp_ids,'subscriber');
}
if($this->settings->enabled('waiting_list'))
{
include_once('Modules/Course/classes/class.ilCourseWaitingList.php');
$waiting_list = new ilCourseWaitingList($this->obj_id);
$this->user_ids = array_merge($waiting_list->getUserIds(),$this->user_ids);
}
// Sort by lastname
$this->user_ids = ilUtil::_sortIds($this->user_ids,'usr_data','lastname','usr_id');
// Finally read user profile data
$this->user_profile_data = ilObjUser::_readUsersProfileData($this->user_ids);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilMemberExport::getCSVString ( )

toString method

public

Parameters

Definition at line 103 of file class.ilMemberExport.php.

{
return $this->csv->getCSVString();
}
ilMemberExport::readCourseData (   $a_user_ids,
  $a_status = 'member' 
)
private

Read All User related course data.

private

Definition at line 293 of file class.ilMemberExport.php.

References IL_CRS_ADMIN, IL_CRS_MEMBER, and IL_CRS_TUTOR.

Referenced by fetchUsers().

{
foreach($a_user_ids as $user_id)
{
// Read course related data
if($this->members->isAdmin($user_id))
{
$this->user_course_data[$user_id]['role'] = IL_CRS_ADMIN;
}
elseif($this->members->isTutor($user_id))
{
$this->user_course_data[$user_id]['role'] = IL_CRS_TUTOR;
}
elseif($this->members->isMember($user_id))
{
$this->user_course_data[$user_id]['role'] = IL_CRS_MEMBER;
}
else
{
$this->user_course_data[$user_id]['role'] = 'subscriber';
}
}
}

+ Here is the caller graph for this function:

ilMemberExport::readCourseSpecificFieldsData ( )
private

Read course specific fields data.

private

Parameters

Definition at line 324 of file class.ilMemberExport.php.

References ilCourseUserData\_getValuesByObjId().

Referenced by fetchUsers().

{
include_once('Modules/Course/classes/Export/class.ilCourseUserData.php');
$this->user_course_fields = ilCourseUserData::_getValuesByObjId($this->obj_id);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilMemberExport::$course
private

Definition at line 46 of file class.ilMemberExport.php.

ilMemberExport::$lng
private

Definition at line 49 of file class.ilMemberExport.php.

Referenced by __construct().

ilMemberExport::$members
private

Definition at line 47 of file class.ilMemberExport.php.

ilMemberExport::$obj_id
private

Definition at line 45 of file class.ilMemberExport.php.

Referenced by __construct().

ilMemberExport::$privacy
private

Definition at line 57 of file class.ilMemberExport.php.

ilMemberExport::$ref_id
private

Definition at line 44 of file class.ilMemberExport.php.

ilMemberExport::$settings
private

Definition at line 51 of file class.ilMemberExport.php.

ilMemberExport::$user_course_data = array()
private

Definition at line 54 of file class.ilMemberExport.php.

ilMemberExport::$user_course_fields = array()
private

Definition at line 55 of file class.ilMemberExport.php.

ilMemberExport::$user_ids = array()
private

Definition at line 53 of file class.ilMemberExport.php.

Referenced by fetchUsers().

ilMemberExport::$user_profile_data = array()
private

Definition at line 56 of file class.ilMemberExport.php.


The documentation for this class was generated from the following file: