ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilECSCmsCourseMemberCommandQueueHandler Class Reference

Description of class. More...

+ Inheritance diagram for ilECSCmsCourseMemberCommandQueueHandler:
+ Collaboration diagram for ilECSCmsCourseMemberCommandQueueHandler:

Public Member Functions

 __construct (ilECSSetting $server)
 Constructor.
 getServer ()
 Get server.
 getMid ()
 get current mid
 getMappingSettings ()
 Get mapping settings.
 checkAllocationActivation (ilECSSetting $server, $a_content_id)
 Check if course allocation is activated for one recipient of the.
 handleCreate (ilECSSetting $server, $a_content_id)
 Handle create.
 handleDelete (ilECSSetting $server, $a_content_id)
 Handle delete.
 handleUpdate (ilECSSetting $server, $a_content_id)
 Handle update.

Protected Member Functions

 doUpdate ($a_content_id, $course_member)
 Perform update.
 readAssignments ($course, $course_member)
 Read assignments for all parallel groups.
 refreshAssignmentStatus ($course_member, $obj_id, $sub_id, $assigned)
 Refresh status of course member assignments.
 lookupRole ($role_value)

Private Member Functions

 createMember ($a_person_id)
 Create user account.
 readCourseMember (ilECSSetting $server, $a_content_id)
 Read course from ecs.
 readCourse ($course_member)
 Read course from ecs.

Private Attributes

 $server = null
 $mid = 0
 $mapping = null

Detailed Description

Description of class.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e

Definition at line 15 of file class.ilECSCmsCourseMemberCommandQueueHandler.php.

Constructor & Destructor Documentation

ilECSCmsCourseMemberCommandQueueHandler::__construct ( ilECSSetting  $server)

Constructor.

Definition at line 25 of file class.ilECSCmsCourseMemberCommandQueueHandler.php.

References $server.

{
$this->server = $server;
}

Member Function Documentation

ilECSCmsCourseMemberCommandQueueHandler::checkAllocationActivation ( ilECSSetting  $server,
  $a_content_id 
)

Check if course allocation is activated for one recipient of the.

Parameters
ilECSSetting$server
type$a_content_id

Definition at line 63 of file class.ilECSCmsCourseMemberCommandQueueHandler.php.

References $GLOBALS, ilECSParticipantSetting\getInstance(), ilECSNodeMappingSettings\getInstanceByServerMid(), getMappingSettings(), getMid(), and getServer().

Referenced by handleCreate(), and handleUpdate().

{
try
{
include_once './Services/WebServices/ECS/classes/Course/class.ilECSCourseMemberConnector.php';
$crsm_reader = new ilECSCourseMemberConnector($server);
$details = $crsm_reader->getCourseMember($a_content_id,true);
$this->mid = $details->getMySender();
// Check if import is enabled
include_once './Services/WebServices/ECS/classes/class.ilECSParticipantSetting.php';
$part = ilECSParticipantSetting::getInstance($this->getServer()->getServerId(), $this->getMid());
if(!$part->isImportEnabled())
{
$GLOBALS['ilLog']->write(__METHOD__.': Import disabled for mid '.$this->getMid());
return false;
}
// Check course allocation setting
include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSNodeMappingSettings.php';
$this->getServer()->getServerId(),
$this->getMid()
);
return $this->getMappingSettings()->isCourseAllocationEnabled();
}
{
$GLOBALS['ilLog']->write(__METHOD__.': Reading course member details failed with message '. $e->getMessage());
return false;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilECSCmsCourseMemberCommandQueueHandler::createMember (   $a_person_id)
private

Create user account.

Parameters
type$a_person_id

Definition at line 423 of file class.ilECSCmsCourseMemberCommandQueueHandler.php.

References $query, $server, ilLDAPServer\_getFirstActiveServer(), ilLDAPServer\getInstanceByServerId(), and IL_LDAP_BIND_DEFAULT.

Referenced by refreshAssignmentStatus().

{
try
{
include_once './Services/LDAP/classes/class.ilLDAPServer.php';
$server->doConnectionCheck();
include_once './Services/LDAP/classes/class.ilLDAPQuery.php';
$users = $query->fetchUser($a_person_id);
if($users)
{
include_once './Services/LDAP/classes/class.ilLDAPAttributeToUser.php';
$xml->setNewUserAuthMode($server->getAuthenticationMappingKey());
$xml->setUserData($users);
$xml->refresh();
}
}
catch (ilLDAPQueryException $exc)
{
$this->log->write($exc->getMessage());
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilECSCmsCourseMemberCommandQueueHandler::doUpdate (   $a_content_id,
  $course_member 
)
protected

Perform update.

Parameters
type$a_content_id

Definition at line 168 of file class.ilECSCmsCourseMemberCommandQueueHandler.php.

References $GLOBALS, $mid, getMid(), getServer(), ilECSImport\lookupObjIdByContentId(), readAssignments(), readCourse(), and refreshAssignmentStatus().

Referenced by handleCreate(), and handleUpdate().

{
$GLOBALS['ilLog']->write(__METHOD__.': Starting ecs member update');
$course_id = (int) $course_member->lectureID;
if(!$course_id)
{
$GLOBALS['ilLog']->write(__METHOD__.': Missing course id');
return false;
}
include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
$GLOBALS['ilLog']->write(__METHOD__.': sid: '.$this->getServer()->getServerId().' course_id: '.$course_id.' mid: '.$this->mid);
//$crs_obj_id = ilECSImport::_lookupObjId($this->getServer()->getServerId(), $course_id, $this->mid);
$crs_obj_id = ilECSImport::lookupObjIdByContentId($this->getServer()->getServerId(), $this->mid, $course_id);
if(!$crs_obj_id)
{
// check for parallel scenario iv and create courses
$GLOBALS['ilLog']->write(__METHOD__.': Missing assigned course with id '. $course_id);
return false;
}
$course = $this->readCourse($course_member);
// Lookup already imported users and update their status
$assignments = $this->readAssignments($course,$course_member);
// iterate through all parallel groups
foreach((array) $assignments as $cms_id => $assigned)
{
$sub_id = ($cms_id == $course_id) ? 0 : $cms_id;
include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
$this->getServer()->getServerId(),
$this->getMid(),
$course_id,
$sub_id);
$this->refreshAssignmentStatus($course_member, $obj_id, $sub_id, $assigned);
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilECSCmsCourseMemberCommandQueueHandler::getMappingSettings ( )

Get mapping settings.

Returns
ilECSnodeMappingSettings

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

References $mapping.

Referenced by checkAllocationActivation(), and lookupRole().

{
}

+ Here is the caller graph for this function:

ilECSCmsCourseMemberCommandQueueHandler::getMid ( )

get current mid

Returns
int

Definition at line 43 of file class.ilECSCmsCourseMemberCommandQueueHandler.php.

References $mid.

Referenced by checkAllocationActivation(), doUpdate(), and readCourse().

{
return $this->mid;
}

+ Here is the caller graph for this function:

ilECSCmsCourseMemberCommandQueueHandler::getServer ( )

Get server.

Returns
ilECSServerSetting

Definition at line 34 of file class.ilECSCmsCourseMemberCommandQueueHandler.php.

References $server.

Referenced by checkAllocationActivation(), doUpdate(), readCourse(), and refreshAssignmentStatus().

{
return $this->server;
}

+ Here is the caller graph for this function:

ilECSCmsCourseMemberCommandQueueHandler::handleCreate ( ilECSSetting  $server,
  $a_content_id 
)

Handle create.

Parameters
ilECSSetting$server
type$a_content_id

Implements ilECSCommandQueueHandler.

Definition at line 101 of file class.ilECSCmsCourseMemberCommandQueueHandler.php.

References $GLOBALS, checkAllocationActivation(), doUpdate(), and readCourseMember().

{
include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsData.php';
include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsTree.php';
include_once './Services/WebServices/ECS/classes/Course/class.ilECSCourseConnector.php';
if(!$this->checkAllocationActivation($server, $a_content_id))
{
return true;
}
try
{
//$course = $this->readCourse($server, $a_content_id);
$course_member = $this->readCourseMember($server,$a_content_id);
$this->doUpdate($a_content_id,$course_member);
return true;
}
{
$GLOBALS['ilLog']->write(__METHOD__.': Course member creation failed with mesage ' . $e->getMessage());
return false;
}
return true;
}

+ Here is the call graph for this function:

ilECSCmsCourseMemberCommandQueueHandler::handleDelete ( ilECSSetting  $server,
  $a_content_id 
)

Handle delete.

Parameters
ilECSSetting$server
type$a_content_id

Implements ilECSCommandQueueHandler.

Definition at line 131 of file class.ilECSCmsCourseMemberCommandQueueHandler.php.

{
// nothing todo
return true;
}
ilECSCmsCourseMemberCommandQueueHandler::handleUpdate ( ilECSSetting  $server,
  $a_content_id 
)

Handle update.

Parameters
ilECSSetting$server
type$a_content_id

Implements ilECSCommandQueueHandler.

Definition at line 142 of file class.ilECSCmsCourseMemberCommandQueueHandler.php.

References $GLOBALS, checkAllocationActivation(), doUpdate(), and readCourseMember().

{
if(!$this->checkAllocationActivation($server, $a_content_id))
{
return true;
}
try
{
$course_member = $this->readCourseMember($server,$a_content_id);
$this->doUpdate($a_content_id, $course_member);
return true;
}
{
$GLOBALS['ilLog']->write(__METHOD__.': Course member update failed with mesage ' . $e->getMessage());
return false;
}
return true;
}

+ Here is the call graph for this function:

ilECSCmsCourseMemberCommandQueueHandler::lookupRole (   $role_value)
protected

Definition at line 398 of file class.ilECSCmsCourseMemberCommandQueueHandler.php.

References $GLOBALS, and getMappingSettings().

Referenced by refreshAssignmentStatus().

{
$role_mappings = $this->getMappingSettings()->getRoleMappings();
/* Zero is an allowed value */
if(!$role_value)
{
//$GLOBALS['ilLog']->write(__METHOD__.': No role assignment missing attribute: role');
//return 0;
}
foreach($role_mappings as $name => $map)
{
if($role_value == $map)
{
return $name;
}
}
$GLOBALS['ilLog']->write(__METHOD__.': No role assignment mapping for role ' . $role_value);
return 0;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilECSCmsCourseMemberCommandQueueHandler::readAssignments (   $course,
  $course_member 
)
protected

Read assignments for all parallel groups.

Parameters
type$course
type$course_member

Definition at line 216 of file class.ilECSCmsCourseMemberCommandQueueHandler.php.

References $GLOBALS, ilECSMappingUtils\PARALLEL_ALL_COURSES, ilECSMappingUtils\PARALLEL_GROUPS_IN_COURSE, ilECSMappingUtils\PARALLEL_ONE_COURSE, and ilECSMappingUtils\PARALLEL_UNDEFINED.

Referenced by doUpdate().

{
$put_in_course = true;
include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSMappingUtils.php';
switch((int) $course->groupScenario)
{
$GLOBALS['ilLog']->write(__METHOD__.': No parallel group scenario defined.');
$put_in_course = true;
break;
$GLOBALS['ilLog']->write(__METHOD__.': Parallel group scenario one course.');
$put_in_course = true;
break;
$GLOBALS['ilLog']->write(__METHOD__.': Parallel group scenario groups in courses.');
$put_in_course = false;
break;
$GLOBALS['ilLog']->write(__METHOD__.': Parallel group scenario only courses.');
$put_in_course = false;
break;
default:
$GLOBALS['ilLog']->write(__METHOD__.': Parallel group scenario undefined.');
$put_in_course = true;
break;
}
$course_id = $course_member->lectureID;
$assigned = array();
foreach((array) $course_member->members as $member)
{
$assigned[$course_id][$member->personID] = array(
'id' => $member->personID,
'role' => $member->role
);
foreach((array) $member->groups as $pgroup)
{
if(!$put_in_course)
{
// @todo check hierarchy of roles
$assigned[$pgroup->num][$member->personID] = array(
'id' => $member->personID,
'role' => $pgroup->role
);
}
}
}
$GLOBALS['ilLog']->write(__METHOD__.': ECS member assignments '.print_r($assigned,true));
return $assigned;
}

+ Here is the caller graph for this function:

ilECSCmsCourseMemberCommandQueueHandler::readCourse (   $course_member)
private

Read course from ecs.

Returns
boolean

Definition at line 479 of file class.ilECSCmsCourseMemberCommandQueueHandler.php.

References getMid(), getServer(), and ilECSImport\lookupEContentIdByContentId().

Referenced by doUpdate().

{
try
{
include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
$this->getServer()->getServerId(),
$this->getMid(),
$course_member->lectureID
);
include_once './Services/WebServices/ECS/classes/Course/class.ilECSCourseConnector.php';
$crs_reader = new ilECSCourseConnector($this->getServer());
return $crs_reader->getCourse($ecs_id);
}
{
throw $e;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilECSCmsCourseMemberCommandQueueHandler::readCourseMember ( ilECSSetting  $server,
  $a_content_id 
)
private

Read course from ecs.

Returns
boolean

Definition at line 457 of file class.ilECSCmsCourseMemberCommandQueueHandler.php.

Referenced by handleCreate(), and handleUpdate().

{
try
{
include_once './Services/WebServices/ECS/classes/Course/class.ilECSCourseMemberConnector.php';
$crs_member_reader = new ilECSCourseMemberConnector($server);
$member = $crs_member_reader->getCourseMember($a_content_id);
//$GLOBALS['ilLog']->write(__METHOD__.': ??????????? crs member:' . print_r($member,true));
//$GLOBALS['ilLog']->write(__METHOD__.': ??????????? content id :' . $a_content_id);
return $member;
}
{
throw $e;
}
}

+ Here is the caller graph for this function:

ilECSCmsCourseMemberCommandQueueHandler::refreshAssignmentStatus (   $course_member,
  $obj_id,
  $sub_id,
  $assigned 
)
protected

Refresh status of course member assignments.

Parameters
object$course_member
int$obj_id

Definition at line 281 of file class.ilECSCmsCourseMemberCommandQueueHandler.php.

References $GLOBALS, ilObjUser\_checkExternalAuthAccount(), ilGroupParticipants\_getInstanceByObjId(), ilCourseParticipants\_getInstanceByObjId(), ilObjUser\_lookupId(), ilObject\_lookupTitle(), ilObject\_lookupType(), createMember(), ilECSMappingUtils\getRoleMappingInfo(), getServer(), ilECSCourseMemberAssignment\lookupAssignment(), ilECSSetting\lookupAuthMode(), lookupRole(), and ilECSCourseMemberAssignment\lookupUserIds().

Referenced by doUpdate().

{
include_once './Services/WebServices/ECS/classes/Course/class.ilECSCourseMemberAssignment.php';
$type = ilObject::_lookupType($obj_id);
if($type == 'crs')
{
include_once './Modules/Course/classes/class.ilCourseParticipants.php';
}
else
{
include_once './Modules/Group/classes/class.ilGroupParticipants.php';
}
$course_id = (int) $course_member->lectureID;
$course_id,
$sub_id,
$obj_id);
// Delete remote deleted
foreach((array) $usr_ids as $usr_id)
{
if(!isset($assigned[$usr_id]))
{
$ass = ilECSCourseMemberAssignment::lookupAssignment($course_id, $sub_id,$obj_id, $usr_id);
if($ass instanceof ilECSCourseMemberAssignment)
{
(string) $usr_id);
if($il_usr_id = ilObjUser::_lookupId($acc))
{
// this removes also admin, tutor roles
$part->delete($il_usr_id);
$GLOBALS['ilLog']->write(__METHOD__.': Deassigning user ' . $usr_id. ' '. 'from course '. ilObject::_lookupTitle($obj_id));
}
else
{
$GLOBALS['ilLog']->write(__METHOD__.': Deassigning unknown ILIAS user ' . $usr_id. ' '. 'from course '. ilObject::_lookupTitle($obj_id));
}
$ass->delete();
}
}
}
// Assign new participants
foreach((array) $assigned as $person_id => $person)
{
$role = $this->lookupRole($person['role']);
(string) $person_id);
$GLOBALS['ilLog']->write(__METHOD__.': Handling user '. (string) $person_id);
if(in_array($person_id, $usr_ids))
{
if($il_usr_id = ilObjUser::_lookupId($acc))
{
$GLOBALS['ilLog']->write(__METHOD__.': '. print_r($role,true));
$part->updateRoleAssignments($il_usr_id, array($role));
// Nothing to do, user is member or is locally deleted
}
}
else
{
if($il_usr_id = ilObjUser::_lookupId($acc))
{
if($role)
{
// Add user
$GLOBALS['ilLog']->write(__METHOD__.': Assigning new user ' . $person_id. ' '. 'to '. ilObject::_lookupTitle($obj_id));
$part->add($il_usr_id,$role);
}
}
else
{
if($role_info['create'])
{
$this->createMember($person_id);
$GLOBALS['ilLog']->write(__METHOD__.': Added new user '. $person_id);
}
// Assign to role
if($role)
{
(string) $person_id);
if($il_usr_id = ilObjUser::_lookupId($acc))
{
$part->add($il_usr_id,$role);
}
}
}
$assignment = new ilECSCourseMemberAssignment();
$assignment->setServer($this->getServer()->getServerId());
$assignment->setMid($this->mid);
$assignment->setCmsId($course_id);
$assignment->setCmsSubId($sub_id);
$assignment->setObjId($obj_id);
$assignment->setUid($person_id);
$assignment->save();
}
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilECSCmsCourseMemberCommandQueueHandler::$mapping = null
private
ilECSCmsCourseMemberCommandQueueHandler::$mid = 0
private

Definition at line 18 of file class.ilECSCmsCourseMemberCommandQueueHandler.php.

Referenced by doUpdate(), and getMid().

ilECSCmsCourseMemberCommandQueueHandler::$server = null
private

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