18 declare(strict_types=1);
31 private ?ilECSnodeMappingSettings
$mapping = null;
39 $this->log = $DIC->logger()->wsrv();
66 $details = $crsm_reader->getCourseMember($a_content_id,
true);
67 $this->mid =
$details->getMySender();
71 if (!$part->isImportEnabled()) {
72 $this->log->warning(
'Import disabled for mid ' . $this->
getMid());
80 return $this->mapping->isCourseAllocationEnabled();
82 $this->log->error(
'Reading course member details failed with message ' . $e->getMessage());
99 $this->
doUpdate($a_content_id, $course_member);
102 $this->log->error(
'Course member creation failed with mesage ' . $e->getMessage());
128 $this->
doUpdate($a_content_id, $course_member);
131 $this->log->error(
'Course member update failed with mesage ' . $e->getMessage());
141 protected function doUpdate($a_content_id, $course_member): bool
143 $this->log->debug(
'Starting ecs member update');
145 $course_id = (
int) $course_member->lectureID;
147 $this->log->warning(
'Missing course id');
150 $this->log->debug(
'sid: ' . $this->
getServer()->getServerId() .
' course_id: ' . $course_id .
' mid: ' . $this->mid);
155 $this->log->info(
'No main course created. Group scenario >= 3 ?');
159 if (is_null($course)) {
160 $this->log->info(
'No course found, skip processing' . print_r($course_member,
true));
166 $this->log->debug(
'Parallel group assignments');
168 $this->log->debug(
'------------------ End assignemtns');
171 foreach ($assignments as $cms_id => $assigned) {
172 $sub_id = ($cms_id === $course_id) ? null : (
string) $cms_id;
174 $this->log->debug(
'sub id is ' . is_null($sub_id) ?
"<null>" : $sub_id .
' for ' . $cms_id);
194 switch ((
int) $course->groupScenario) {
196 $this->log->debug(
'Parallel group scenario one course.');
200 $this->log->debug(
'Parallel group scenario groups in courses.');
204 $this->log->debug(
'Parallel group scenario only courses.');
208 $this->log->debug(
'Parallel group scenario undefined.');
212 $course_id = $course_member->lectureID;
214 foreach ((array) $course_member->members as $member) {
215 $assigned[$course_id][$member->personID] = array(
216 'id' => $member->personID,
217 'role' => $member->role
220 $this->log->debug(
'Group scenarion "one course". Ignoring group assignments');
224 foreach ((array) $member->groups as $pgroup) {
226 $sequence_number = (
int) $pgroup->num;
228 $tmp_pgroup = $course->groups[$sequence_number];
229 if (is_object($tmp_pgroup) && $tmp_pgroup->id !==
'') {
230 $this->log->debug(
'Found parallel group with id: ' . $tmp_pgroup->id .
': for sequence number: ' . $sequence_number);
233 $assigned[$tmp_pgroup->id][$member->personID] = array(
234 'id' => $member->personID,
235 'role' => $pgroup->role
238 $this->log->warning(
'Cannot find parallel group with sequence id: ' . $sequence_number);
242 $this->log->debug(
'ECS member assignments ' . print_r($assigned,
true));
253 $this->log->debug(
'Currrent sub_id = ' . $sub_id .
', obj_id = ' . $obj_id);
256 if (
$type ===
'crs') {
258 } elseif (
$type ===
'grp') {
261 $this->log->warning(
'Invalid object type given for obj_id: ' . $obj_id);
265 $course_id = (
int) $course_member->lectureID;
268 is_null($sub_id) ? $sub_id : (
int) $sub_id,
273 foreach ($usr_ids as $usr_id) {
274 if (!isset($assigned[$usr_id])) {
278 $this->mapping->getAuthMode(),
282 $this->log->debug(
'Local user assignment: ' . $usr_id .
' <-> ' . $login);
286 $part->delete($il_usr_id);
289 $this->log->notice(
'Deassigning unknown ILIAS user ' . $usr_id .
' ' .
'from course ' .
ilObject::_lookupTitle($obj_id));
297 $this->log->debug(
'Handled assignmnent...');
300 foreach ((array) $assigned as $person_id => $person) {
304 $this->log->debug(
'Using role info...');
306 $this->mapping->getAuthMode(),
309 $this->log->info(
'Handling user ' . $person_id);
310 if (in_array($person_id, $usr_ids)) {
312 $this->log->info(
'User exists, Updating role assignment for existing user: ' . $person_id);
313 $part->updateRoleAssignments($il_usr_id, array($part->getAutoGeneratedRoleId($role)));
314 } elseif ($role_info[
'create']) {
316 $this->log->info(
'Creating new user for' . $person_id);
318 $this->mapping->getAuthMode(),
322 $part->add($il_usr_id, $role);
331 $this->log->info(
'Assigning new user ' . $person_id .
' ' .
'to ' .
ilObject::_lookupTitle($obj_id) .
' using role: ' . $role);
332 $part->add($il_usr_id, $role);
337 if ($role_info[
'create']) {
339 $this->log->info(
'Created new user ' . $person_id);
341 $this->mapping->getAuthMode(),
347 $this->log->info(
'Assigning new user ' . $person_id .
' ' .
'to ' .
ilObject::_lookupTitle($obj_id) .
' using role: ' . $role);
348 $part->add($il_usr_id, $role);
354 $assignment->setServer($this->
getServer()->getServerId());
355 $assignment->setMid($this->mid);
356 $assignment->setCmsId($course_id);
357 $assignment->setCmsSubId((
int) $sub_id);
358 $assignment->setObjId($obj_id);
359 $assignment->setUid((
string) $person_id);
371 $role_mappings = $this->mapping->getRoleMappings();
375 $this->log->debug(
'No role assignment attribute: role');
377 foreach ($role_mappings as
$name => $map) {
379 $exploded_map = (array) explode(
',', $map);
380 if (in_array($role_value, $exploded_map,
true)) {
385 if ($a_obj_type ===
'crs') {
386 $this->log->debug(
'Role: ' . $role_value .
' maps: ' . $map);
393 if ($a_obj_type ===
'grp') {
394 $this->log->debug(
'Role: ' . $role_value .
' maps: ' . $map);
401 $this->log->info(
'No role assignment mapping for role ' . $role_value);
411 $this->log->warning(
'Node mapping settings not initialized.');
413 $auth_mode = $this->mapping->getAuthMode();
416 $this->mapping->getAuthMode() ===
419 $this->log->info(
'Not handling direct user creation for auth mode: ' . $auth_mode);
422 if (strpos($auth_mode,
'ldap') !== 0) {
423 $this->log->info(
'Not handling direct user creation for auth mode: ' . $auth_mode);
429 $server->doConnectionCheck();
434 $users =
$query->fetchUser($a_person_id);
439 $xml->setNewUserAuthMode($server->getAuthenticationMappingKey());
440 $xml->setUserData($users);
444 $this->log->error($exc->getMessage());
465 $course_member->lectureID
handleCreate(ilECSSetting $server, $a_content_id)
Handle create.
static _getFirstActiveServer()
Get first active server.
static getInstance(int $a_server_id, int $mid)
Get instance by server id and mid.
static getRoleMappingInfo($a_role_type_info=0)
Get role mapping info.
__construct(ilECSSetting $server)
Constructor.
const TYPE_ADMISSION_MEMBER
static getInstanceByServerId(int $a_server_id)
Get instance by server id.
static getInstanceByServerMid(int $a_server_id, int $a_mid)
Get instance.
ilECSnodeMappingSettings $mapping
static _lookupId($a_user_str)
lookupRole(string $role_value, $a_obj_type)
Lookup local role by assignment.
static _checkExternalAuthAccount(string $a_auth, string $a_account, bool $tryFallback=true)
check whether external account and authentication method matches with a user
const PARALLEL_ONE_COURSE
checkAllocationActivation(ilECSSetting $server, $a_content_id)
Check if course allocation is activated for one recipient of the.
static _getAuthModeName($a_auth_key)
Interface for all command queue handler classes.
handleDelete(ilECSSetting $server, $a_content_id)
Handle delete.
createMember($a_person_id)
Create user account.
static lookupAssignment(int $a_cms_id, ?int $a_cms_sub_id, int $a_obj_id, string $a_usr_id)
Lookup assignment of user.
Synchronize member assignments.
static getInstance()
Get the singleton instance of this ilECSImportManager.
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
doUpdate($a_content_id, $course_member)
Perform update.
static _lookupTitle(int $obj_id)
static _getInstanceByObjId(int $a_obj_id)
readAssignments($course, $course_member)
Read assignments for all parallel groups.
static lookupUserIds(int $a_cms_id, ?int $a_cms_sub_id, int $a_obj_id)
Lookup user ids.
Connector for course member ressource.
const PARALLEL_ALL_COURSES
Storage of ecs course assignments.
static _getInstanceByObjId(int $a_obj_id)
Get singleton instance.
readCourseMember(ilECSSetting $server, $a_content_id)
Read course from ecs.
handleUpdate(ilECSSetting $server, $a_content_id)
Handle update.
Update/create ILIAS user account by given LDAP attributes according to user attribute mapping setting...
const PARALLEL_GROUPS_IN_COURSE
refreshAssignmentStatus(object $course_member, int $obj_id, ?string $sub_id, $assigned)
Refresh status of course member assignments.
static _lookupType(int $id, bool $reference=false)
readCourse($course_member)
Read course from ecs.