19declare(strict_types=1);
32 private ?ilECSnodeMappingSettings
$mapping =
null;
40 $this->log =
$DIC->logger()->wsrv();
67 $details = $crsm_reader->getCourseMember($a_content_id,
true);
68 $this->mid = $details->getMySender();
72 if (!$part->isImportEnabled()) {
73 $this->log->warning(
'Import disabled for mid ' . $this->
getMid());
81 return $this->mapping->isCourseAllocationEnabled();
83 $this->log->error(
'Reading course member details failed with message ' .
$e->getMessage());
100 $this->
doUpdate($a_content_id, $course_member);
103 $this->log->error(
'Course member creation failed with mesage ' .
$e->getMessage());
129 $this->
doUpdate($a_content_id, $course_member);
132 $this->log->error(
'Course member update failed with mesage ' .
$e->getMessage());
142 protected function doUpdate($a_content_id, $course_member): bool
144 $this->log->debug(
'Starting ecs member update');
146 if (is_array($course_member) && !isset($course_member[
"lectureID"])) {
147 $this->log->warning(
'Missing course id in course_member');
151 $course_id = (
int) $course_member->lectureID;
153 $this->log->warning(
'Missing course id');
156 $this->log->debug(
'sid: ' . $this->
getServer()->getServerId() .
' course_id: ' . $course_id .
' mid: ' .
$this->mid);
161 $this->log->info(
'No main course created. Group scenario >= 3 ?');
165 if (is_null($course)) {
166 $this->log->info(
'No course found, skip processing' . print_r($course_member,
true));
172 $this->log->debug(
'Parallel group assignments');
174 $this->log->debug(
'------------------ End assignemtns');
177 foreach ($assignments as $cms_id => $assigned) {
178 $sub_id = ($cms_id === $course_id) ?
null : (
string) $cms_id;
180 $this->log->debug(
'sub id is ' . is_null($sub_id) ?
"<null>" : $sub_id .
' for ' . $cms_id);
200 if (!property_exists($course,
'groupScenario')) {
204 switch ((
int) $course->groupScenario) {
206 $this->log->debug(
'Parallel group scenario one course.');
210 $this->log->debug(
'Parallel group scenario groups in courses.');
214 $this->log->debug(
'Parallel group scenario only courses.');
218 $this->log->debug(
'Parallel group scenario undefined.');
222 $course_id = $course_member->lectureID;
224 foreach ((array) $course_member->members as $member) {
225 $assigned[$course_id][$member->personID] = array(
226 'id' => $member->personID,
227 'role' => $member->role
230 $this->log->debug(
'Group scenarion "one course". Ignoring group assignments');
234 if (property_exists($member,
'groups')) {
235 foreach ((array) $member->groups as $pgroup) {
237 $sequence_number = (
int) $pgroup->num;
239 if (property_exists($course,
'groups')) {
240 $tmp_pgroup = $course->groups[$sequence_number] ??
null;
242 if (is_object($tmp_pgroup) && $tmp_pgroup->id !==
'') {
243 $this->log->debug(
'Found parallel group with id: ' . $tmp_pgroup->id .
': for sequence number: ' . $sequence_number);
246 $assigned[$tmp_pgroup->id][$member->personID] = array(
247 'id' => $member->personID,
248 'role' => $pgroup->role
251 $this->log->warning(
'Cannot find parallel group with sequence id: ' . $sequence_number);
254 $this->log->error(
'Invalid course/group-configuration found, ignoring}');
260 $this->log->debug(
'ECS member assignments ' . print_r($assigned,
true));
271 $this->log->debug(
'Currrent sub_id = ' . $sub_id .
', obj_id = ' . $obj_id);
274 if ($type ===
'crs') {
276 } elseif ($type ===
'grp') {
279 $this->log->warning(
'Invalid object type given for obj_id: ' . $obj_id);
283 $course_id = (
int) $course_member->lectureID;
286 is_null($sub_id) ? $sub_id : (
int) $sub_id,
289 $this->log->debug(
'Current coursemember assignments:');
293 foreach ($usr_ids as $usr_id) {
294 if (!isset($assigned[$usr_id])) {
298 $this->mapping->getAuthMode(),
302 $this->log->debug(
'Local user assignment: ' . $usr_id .
' <-> ' . $login);
306 $part->delete($il_usr_id);
309 $this->log->notice(
'Deassigning unknown ILIAS user ' . $usr_id .
' ' .
'from course ' .
ilObject::_lookupTitle($obj_id));
317 $this->log->debug(
'Handled assignmnent...');
320 foreach ((array) $assigned as $person_id => $person) {
321 $role = $this->
lookupRole((
string) $person[
'role'], $type);
324 $this->log->debug(
'Using role info...');
326 $this->mapping->getAuthMode(),
329 $this->log->info(
'Handling user ' . $person_id);
331 if (in_array($person_id, $usr_ids,
true)) {
333 $this->log->info(
'Update user assignment for: ' . $person_id);
334 $part->updateRoleAssignments($il_usr_id, array($part->getAutoGeneratedRoleId($role)));
335 } elseif ($role_info[
'create']) {
337 $this->log->info(
'Added new user ' . $person_id);
339 $this->mapping->getAuthMode(),
343 $part->add($il_usr_id, $role);
352 $this->log->info(
'Assigning new user ' . $person_id .
' ' .
'to ' .
ilObject::_lookupTitle($obj_id) .
' using role: ' . $role);
353 $part->add($il_usr_id, $role);
358 if ($role_info[
'create']) {
360 $this->log->info(
'Added new user ' . $person_id);
362 $this->mapping->getAuthMode(),
368 $this->log->info(
'Assigning new role to existing user ' . $person_id .
' ' .
'to ' .
ilObject::_lookupTitle($obj_id) .
' using role: ' . $role);
369 $part->add($il_usr_id, $role);
375 $assignment->setServer($this->
getServer()->getServerId());
376 $assignment->setMid($this->mid);
377 $assignment->setCmsId($course_id);
378 $assignment->setCmsSubId(is_null($sub_id) ? $sub_id : (
int) $sub_id);
379 $assignment->setObjId($obj_id);
380 $assignment->setUid((
string) $person_id);
392 $role_mappings = $this->mapping->getRoleMappings();
396 $this->log->debug(
'No role assignment attribute: role');
398 foreach ($role_mappings as $name => $map) {
399 $this->log->debug(
'Role "name" is ' . $name);
402 $exploded_map = (array) explode(
',', $map);
403 if (in_array($role_value, $exploded_map,
true)) {
408 if ($a_obj_type ===
'crs') {
409 $this->log->debug(
'Role: ' . $role_value .
' maps: ' . $map);
416 if ($a_obj_type ===
'grp') {
417 $this->log->debug(
'Role: ' . $role_value .
' maps: ' . $map);
424 $this->log->info(
'No role assignment mapping for role ' . $role_value);
434 $this->log->warning(
'Node mapping settings not initialized.');
436 $auth_mode = $this->mapping->getAuthMode();
439 $this->mapping->getAuthMode() ===
442 $this->log->info(
'Not handling direct user creation for auth mode: ' . $auth_mode);
445 if (strpos($auth_mode,
'ldap') !== 0) {
446 $this->log->info(
'Not handling direct user creation for auth mode: ' . $auth_mode);
457 $users = $query->fetchUser((
string) $a_person_id);
462 $xml->setNewUserAuthMode(
$server->getAuthenticationMappingKey());
463 $xml->setUserData($users);
467 $this->log->error($exc->getMessage());
488 $course_member->lectureID
const int AUTH_SHIBBOLETH
static _getAuthModeName($a_auth_key)
const TYPE_ADMISSION_MEMBER
static _getInstanceByObjId(int $a_obj_id)
Synchronize member assignments.
handleCreate(ilECSSetting $server, $a_content_id)
Handle create.
refreshAssignmentStatus(object $course_member, int $obj_id, ?string $sub_id, $assigned)
Refresh status of course member assignments.
readCourse($course_member)
Read course from ecs.
readCourseMember(ilECSSetting $server, $a_content_id)
Read course from ecs.
readAssignments($course, $course_member)
Read assignments for all parallel groups.
doUpdate($a_content_id, $course_member)
Perform update.
ilECSnodeMappingSettings $mapping
lookupRole(string $role_value, $a_obj_type)
Lookup local role by assignment.
__construct(ilECSSetting $server)
Constructor.
createMember($a_person_id)
Create user account.
checkAllocationActivation(ilECSSetting $server, $a_content_id)
Check if course allocation is activated for one recipient of the.
handleUpdate(ilECSSetting $server, $a_content_id)
Handle update.
handleDelete(ilECSSetting $server, $a_content_id)
Handle delete.
Storage of ecs course assignments.
static lookupAssignment(int $a_cms_id, ?int $a_cms_sub_id, int $a_obj_id, string $a_usr_id)
Lookup assignment of user.
static lookupUserIds(int $a_cms_id, ?int $a_cms_sub_id, int $a_obj_id)
Lookup user ids.
Connector for course member ressource.
static getInstance()
Get the singleton instance of this ilECSImportManager.
const PARALLEL_ONE_COURSE
const PARALLEL_ALL_COURSES
static getRoleMappingInfo($a_role_type_info=0)
Get role mapping info.
const PARALLEL_GROUPS_IN_COURSE
static getInstanceByServerMid(int $a_server_id, int $a_mid)
Get instance.
static getInstance(int $a_server_id, int $mid)
Get instance by server id and mid.
static _getInstanceByObjId(int $a_obj_id)
Get singleton instance.
Update/create ILIAS user account by given LDAP attributes according to user attribute mapping setting...
static getInstanceByServerId(int $a_server_id)
Get instance by server id.
static _getFirstActiveServer()
Get first active server.
Component logger with individual log levels by component id.
static _lookupId(string|array $a_user_str)
static _checkExternalAuthAccount(string $a_auth, string $a_account, bool $tryFallback=true)
check whether external account and authentication method matches with a user
static _lookupType(int $id, bool $reference=false)
static _lookupTitle(int $obj_id)
Interface for all command queue handler classes.
if(!file_exists('../ilias.ini.php'))