ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f87
ilECSCmsCourseMemberCommandQueueHandler Class Reference

Description of class. More...

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

Public Member Functions

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

Protected Member Functions

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

Private Member Functions

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

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

◆ __construct()

ilECSCmsCourseMemberCommandQueueHandler::__construct ( ilECSSetting  $server)

Constructor.

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

References $server.

Member Function Documentation

◆ checkAllocationActivation()

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().

64  {
65  try
66  {
67  include_once './Services/WebServices/ECS/classes/Course/class.ilECSCourseMemberConnector.php';
68  $crsm_reader = new ilECSCourseMemberConnector($server);
69  $details = $crsm_reader->getCourseMember($a_content_id,true);
70  $this->mid = $details->getMySender();
71 
72  // Check if import is enabled
73  include_once './Services/WebServices/ECS/classes/class.ilECSParticipantSetting.php';
74  $part = ilECSParticipantSetting::getInstance($this->getServer()->getServerId(), $this->getMid());
75  if(!$part->isImportEnabled())
76  {
77  $GLOBALS['ilLog']->write(__METHOD__.': Import disabled for mid '.$this->getMid());
78  return false;
79  }
80  // Check course allocation setting
81  include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSNodeMappingSettings.php';
83  $this->getServer()->getServerId(),
84  $this->getMid()
85  );
86  return $this->getMappingSettings()->isCourseAllocationEnabled();
87  }
88  catch(ilECSConnectorException $e)
89  {
90  $GLOBALS['ilLog']->write(__METHOD__.': Reading course member details failed with message '. $e->getMessage());
91  return false;
92  }
93  }
static getInstanceByServerMid($a_server_id, $a_mid)
Get instance.
$GLOBALS['ct_recipient']
static getInstance($a_server_id, $mid)
Get instance by server id and mid.
Connector for course member ressource.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createMember()

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().

424  {
425  try
426  {
427  include_once './Services/LDAP/classes/class.ilLDAPServer.php';
429  $server->doConnectionCheck();
430 
431  include_once './Services/LDAP/classes/class.ilLDAPQuery.php';
432  $query = new ilLDAPQuery($server);
434 
435  $users = $query->fetchUser($a_person_id);
436  if($users)
437  {
438  include_once './Services/LDAP/classes/class.ilLDAPAttributeToUser.php';
439  $xml = new ilLDAPAttributeToUser($server);
440  $xml->setNewUserAuthMode($server->getAuthenticationMappingKey());
441  $xml->setUserData($users);
442  $xml->refresh();
443  }
444 
445  }
446  catch (ilLDAPQueryException $exc)
447  {
448  $this->log->write($exc->getMessage());
449  }
450  }
static _getFirstActiveServer()
Get first active server.
const IL_LDAP_BIND_DEFAULT
static getInstanceByServerId($a_server_id)
Update/create ILIAS user account by given LDAP attributes according to user attribute mapping setting...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ doUpdate()

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().

169  {
170  $GLOBALS['ilLog']->write(__METHOD__.': Starting ecs member update');
171 
172  $course_id = (int) $course_member->lectureID;
173  if(!$course_id)
174  {
175  $GLOBALS['ilLog']->write(__METHOD__.': Missing course id');
176  return false;
177  }
178  include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
179  $GLOBALS['ilLog']->write(__METHOD__.': sid: '.$this->getServer()->getServerId().' course_id: '.$course_id.' mid: '.$this->mid);
180  //$crs_obj_id = ilECSImport::_lookupObjId($this->getServer()->getServerId(), $course_id, $this->mid);
181  $crs_obj_id = ilECSImport::lookupObjIdByContentId($this->getServer()->getServerId(), $this->mid, $course_id);
182 
183  if(!$crs_obj_id)
184  {
185  // check for parallel scenario iv and create courses
186  $GLOBALS['ilLog']->write(__METHOD__.': Missing assigned course with id '. $course_id);
187  return false;
188  }
189 
190  $course = $this->readCourse($course_member);
191  // Lookup already imported users and update their status
192  $assignments = $this->readAssignments($course,$course_member);
193 
194  // iterate through all parallel groups
195  foreach((array) $assignments as $cms_id => $assigned)
196  {
197  $sub_id = ($cms_id == $course_id) ? 0 : $cms_id;
198 
199  include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
201  $this->getServer()->getServerId(),
202  $this->getMid(),
203  $course_id,
204  $sub_id);
205 
206  $this->refreshAssignmentStatus($course_member, $obj_id, $sub_id, $assigned);
207  }
208  return true;
209  }
static lookupObjIdByContentId($a_server_id, $a_mid, $a_content_id, $a_sub_id='')
Lookup obj_id by content id.
refreshAssignmentStatus($course_member, $obj_id, $sub_id, $assigned)
Refresh status of course member assignments.
$GLOBALS['ct_recipient']
readAssignments($course, $course_member)
Read assignments for all parallel groups.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMappingSettings()

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:

◆ getMid()

ilECSCmsCourseMemberCommandQueueHandler::getMid ( )

get current mid

Returns
int

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

References $mid.

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

+ Here is the caller graph for this function:

◆ getServer()

ilECSCmsCourseMemberCommandQueueHandler::getServer ( )

Get server.

Returns
ilECSServerSetting

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

References $server.

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

+ Here is the caller graph for this function:

◆ handleCreate()

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().

102  {
103  include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsData.php';
104  include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsTree.php';
105  include_once './Services/WebServices/ECS/classes/Course/class.ilECSCourseConnector.php';
106 
107  if(!$this->checkAllocationActivation($server, $a_content_id))
108  {
109  return true;
110  }
111  try
112  {
113  //$course = $this->readCourse($server, $a_content_id);
114  $course_member = $this->readCourseMember($server,$a_content_id);
115  $this->doUpdate($a_content_id,$course_member);
116  return true;
117  }
118  catch(ilECSConnectorException $e)
119  {
120  $GLOBALS['ilLog']->write(__METHOD__.': Course member creation failed with mesage ' . $e->getMessage());
121  return false;
122  }
123  return true;
124  }
checkAllocationActivation(ilECSSetting $server, $a_content_id)
Check if course allocation is activated for one recipient of the.
$GLOBALS['ct_recipient']
readCourseMember(ilECSSetting $server, $a_content_id)
Read course from ecs.
+ Here is the call graph for this function:

◆ handleDelete()

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.

132  {
133  // nothing todo
134  return true;
135  }

◆ handleUpdate()

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().

143  {
144  if(!$this->checkAllocationActivation($server, $a_content_id))
145  {
146  return true;
147  }
148 
149  try
150  {
151  $course_member = $this->readCourseMember($server,$a_content_id);
152  $this->doUpdate($a_content_id, $course_member);
153  return true;
154  }
155  catch(ilECSConnectorException $e)
156  {
157  $GLOBALS['ilLog']->write(__METHOD__.': Course member update failed with mesage ' . $e->getMessage());
158  return false;
159  }
160  return true;
161  }
checkAllocationActivation(ilECSSetting $server, $a_content_id)
Check if course allocation is activated for one recipient of the.
$GLOBALS['ct_recipient']
readCourseMember(ilECSSetting $server, $a_content_id)
Read course from ecs.
+ Here is the call graph for this function:

◆ lookupRole()

ilECSCmsCourseMemberCommandQueueHandler::lookupRole (   $role_value)
protected

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

References $GLOBALS, and getMappingSettings().

Referenced by refreshAssignmentStatus().

399  {
400  $role_mappings = $this->getMappingSettings()->getRoleMappings();
401 
402  /* Zero is an allowed value */
403  if(!$role_value)
404  {
405  //$GLOBALS['ilLog']->write(__METHOD__.': No role assignment missing attribute: role');
406  //return 0;
407  }
408  foreach($role_mappings as $name => $map)
409  {
410  if($role_value == $map)
411  {
412  return $name;
413  }
414  }
415  $GLOBALS['ilLog']->write(__METHOD__.': No role assignment mapping for role ' . $role_value);
416  return 0;
417  }
$GLOBALS['ct_recipient']
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readAssignments()

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().

217  {
218  $put_in_course = true;
219 
220  include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSMappingUtils.php';
221  switch((int) $course->groupScenario)
222  {
224  $GLOBALS['ilLog']->write(__METHOD__.': No parallel group scenario defined.');
225  $put_in_course = true;
226  break;
227 
229  $GLOBALS['ilLog']->write(__METHOD__.': Parallel group scenario one course.');
230  $put_in_course = true;
231  break;
232 
234  $GLOBALS['ilLog']->write(__METHOD__.': Parallel group scenario groups in courses.');
235  $put_in_course = false;
236  break;
237 
239  $GLOBALS['ilLog']->write(__METHOD__.': Parallel group scenario only courses.');
240  $put_in_course = false;
241  break;
242 
243  default:
244  $GLOBALS['ilLog']->write(__METHOD__.': Parallel group scenario undefined.');
245  $put_in_course = true;
246  break;
247  }
248 
249  $course_id = $course_member->lectureID;
250  $assigned = array();
251  foreach((array) $course_member->members as $member)
252  {
253  $assigned[$course_id][$member->personID] = array(
254  'id' => $member->personID,
255  'role' => $member->role
256  );
257 
258  foreach((array) $member->groups as $pgroup)
259  {
260  if(!$put_in_course)
261  {
262  // @todo check hierarchy of roles
263  $assigned[$pgroup->num][$member->personID] = array(
264  'id' => $member->personID,
265  'role' => $pgroup->role
266  );
267  }
268  }
269  }
270  $GLOBALS['ilLog']->write(__METHOD__.': ECS member assignments '.print_r($assigned,true));
271  return $assigned;
272  }
$GLOBALS['ct_recipient']
+ Here is the caller graph for this function:

◆ readCourse()

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().

480  {
481  try
482  {
483  include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
485  $this->getServer()->getServerId(),
486  $this->getMid(),
487  $course_member->lectureID
488  );
489 
490  include_once './Services/WebServices/ECS/classes/Course/class.ilECSCourseConnector.php';
491  $crs_reader = new ilECSCourseConnector($this->getServer());
492  return $crs_reader->getCourse($ecs_id);
493  }
494  catch(ilECSConnectorException $e)
495  {
496  throw $e;
497  }
498  }
static lookupEContentIdByContentId($a_server_id, $a_mid, $a_content_id)
Lookup econtent id The econtent id is the unique id from ecs.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readCourseMember()

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().

458  {
459  try
460  {
461  include_once './Services/WebServices/ECS/classes/Course/class.ilECSCourseMemberConnector.php';
462  $crs_member_reader = new ilECSCourseMemberConnector($server);
463 
464  $member = $crs_member_reader->getCourseMember($a_content_id);
465  //$GLOBALS['ilLog']->write(__METHOD__.': ??????????? crs member:' . print_r($member,true));
466  //$GLOBALS['ilLog']->write(__METHOD__.': ??????????? content id :' . $a_content_id);
467  return $member;
468  }
469  catch(ilECSConnectorException $e)
470  {
471  throw $e;
472  }
473  }
Connector for course member ressource.
+ Here is the caller graph for this function:

◆ refreshAssignmentStatus()

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().

282  {
283  include_once './Services/WebServices/ECS/classes/Course/class.ilECSCourseMemberAssignment.php';
284 
285  $type = ilObject::_lookupType($obj_id);
286  if($type == 'crs')
287  {
288  include_once './Modules/Course/classes/class.ilCourseParticipants.php';
290  }
291  else
292  {
293  include_once './Modules/Group/classes/class.ilGroupParticipants.php';
295  }
296 
297 
298 
299  $course_id = (int) $course_member->lectureID;
301  $course_id,
302  $sub_id,
303  $obj_id);
304 
305  // Delete remote deleted
306  foreach((array) $usr_ids as $usr_id)
307  {
308  if(!isset($assigned[$usr_id]))
309  {
310  $ass = ilECSCourseMemberAssignment::lookupAssignment($course_id, $sub_id,$obj_id, $usr_id);
311  if($ass instanceof ilECSCourseMemberAssignment)
312  {
315  (string) $usr_id);
316  if($il_usr_id = ilObjUser::_lookupId($acc))
317  {
318  // this removes also admin, tutor roles
319  $part->delete($il_usr_id);
320  $GLOBALS['ilLog']->write(__METHOD__.': Deassigning user ' . $usr_id. ' '. 'from course '. ilObject::_lookupTitle($obj_id));
321  }
322  else
323  {
324  $GLOBALS['ilLog']->write(__METHOD__.': Deassigning unknown ILIAS user ' . $usr_id. ' '. 'from course '. ilObject::_lookupTitle($obj_id));
325  }
326 
327  $ass->delete();
328  }
329  }
330  }
331 
332  // Assign new participants
333  foreach((array) $assigned as $person_id => $person)
334  {
335  $role = $this->lookupRole($person['role']);
336  $role_info = ilECSMappingUtils::getRoleMappingInfo($role);
337 
340  (string) $person_id);
341  $GLOBALS['ilLog']->write(__METHOD__.': Handling user '. (string) $person_id);
342 
343  if(in_array($person_id, $usr_ids))
344  {
345  if($il_usr_id = ilObjUser::_lookupId($acc))
346  {
347  $GLOBALS['ilLog']->write(__METHOD__.': '. print_r($role,true));
348  $part->updateRoleAssignments($il_usr_id, array($role));
349  // Nothing to do, user is member or is locally deleted
350  }
351  }
352  else
353  {
354  if($il_usr_id = ilObjUser::_lookupId($acc))
355  {
356  if($role)
357  {
358  // Add user
359  $GLOBALS['ilLog']->write(__METHOD__.': Assigning new user ' . $person_id. ' '. 'to '. ilObject::_lookupTitle($obj_id));
360  $part->add($il_usr_id,$role);
361  }
362 
363  }
364  else
365  {
366  if($role_info['create'])
367  {
368  $this->createMember($person_id);
369  $GLOBALS['ilLog']->write(__METHOD__.': Added new user '. $person_id);
370  }
371  // Assign to role
372  if($role)
373  {
376  (string) $person_id);
377 
378  if($il_usr_id = ilObjUser::_lookupId($acc))
379  {
380  $part->add($il_usr_id,$role);
381  }
382  }
383  }
384 
385  $assignment = new ilECSCourseMemberAssignment();
386  $assignment->setServer($this->getServer()->getServerId());
387  $assignment->setMid($this->mid);
388  $assignment->setCmsId($course_id);
389  $assignment->setCmsSubId($sub_id);
390  $assignment->setObjId($obj_id);
391  $assignment->setUid($person_id);
392  $assignment->save();
393  }
394  }
395  return true;
396  }
static getRoleMappingInfo($a_role_type_info=0)
Get role mapping info.
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static _lookupId($a_user_str)
lookup id by login
static _lookupTitle($a_id)
lookup object title
$GLOBALS['ct_recipient']
static lookupUserIds($a_cms_id, $a_cms_sub_id, $a_obj_id)
Lookup user ids type $ilDB.
static lookupAssignment($a_cms_id, $a_cms_sub_id, $a_obj_id, $a_usr_id)
Lookup assignment of user type $ilDB.
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static _lookupType($a_id, $a_reference=false)
lookup object type
Storage of ecs course assignments.
static lookupAuthMode()
Lookup auth mode.
static _checkExternalAuthAccount($a_auth, $a_account)
check whether external account and authentication method matches with a user
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $mapping

ilECSCmsCourseMemberCommandQueueHandler::$mapping = null
private

◆ $mid

ilECSCmsCourseMemberCommandQueueHandler::$mid = 0
private

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

Referenced by doUpdate(), and getMid().

◆ $server

ilECSCmsCourseMemberCommandQueueHandler::$server = null
private

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