ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilECSEnrolmentStatusCommandQueueHandler.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25{
27 private int $mid = 0;
28
29 protected \ilRecommendedContentManager $recommended_content_manager;
30
32
37 {
38 global $DIC;
39
40 $this->logger = $DIC->logger()->wsrv();
41 $this->server = $server;
42 $this->recommended_content_manager = new ilRecommendedContentManager();
43 }
44
48 public function getServer(): \ilECSSetting
49 {
50 return $this->server;
51 }
52
56 public function getMid(): int
57 {
58 return $this->mid;
59 }
60
64 public function handleCreate(ilECSSetting $server, $a_content_id): bool
65 {
66 try {
67 $enrolment_con = new ilECSEnrolmentStatusConnector($server);
68 $status = $enrolment_con->getEnrolmentStatus($a_content_id);
69 $this->logger->debug(print_r($status, true));
70 $this->logger->debug($status->getPersonIdType());
71 $this->logger->debug($status->getPersonId());
72 $i = $status->getPersonIdType();
74 $id_arr = ilUtil::parseImportId($status->getPersonId());
75 $this->logger->debug('Handling status change to ' . $status->getStatus() . ' for user ' . $id_arr['id']);
76 $this->doUpdate($id_arr['id'], $status);
77 } else {
78 $this->logger->debug('Not implemented yes: person id type: ' . $status->getPersonIdType());
79 }
80 } catch (ilECSConnectorException $e) {
81 $this->logger->error('Enrollment status change failed with message: ' . $e->getMessage());
82 }
83 return true;
84 }
85
89 public function handleDelete(ilECSSetting $server, $a_content_id): bool
90 {
91 // nothing todo
92 return true;
93 }
94
99 public function handleUpdate(ilECSSetting $server, $a_content_id): bool
100 {
101 // Shouldn't happen
102 return true;
103 }
104
105
109 protected function doUpdate($a_usr_id, ilECSEnrolmentStatus $status): bool
110 {
111 $obj_ids = ilECSImportManager::getInstance()->lookupObjIdsByContentId($status->getId());
112 $obj_id = end($obj_ids);
113 $ref_ids = ilObject::_getAllReferences($obj_id);
114 $ref_id = end($ref_ids);
115
116
117 if (!$ref_id) {
118 // Remote object not found
119 return true;
120 }
121
122 switch ($status->getStatus()) {
124 // nothing todo in the moment: maybe send mail
125 break;
126
128 $this->logger->info(': Add recommended content: ' . $a_usr_id . ' ' . $ref_id . ' ' . $obj_id);
129 // deactivated for now, see discussion at
130 // https://docu.ilias.de/goto_docu_wiki_wpage_5620_1357.html
131 //$this->recommended_content_manager->addObjectRecommendation($a_usr_id, $ref_id);
132 break;
133
138 $this->logger->info(': Remove recommended content: ' . $a_usr_id . ' ' . $ref_id . ' ' . $obj_id);
139 $this->recommended_content_manager->removeObjectRecommendation($a_usr_id, $ref_id);
140 break;
141 }
142 return true;
143 }
144}
handleUpdate(ilECSSetting $server, $a_content_id)
Handle update.
doUpdate($a_usr_id, ilECSEnrolmentStatus $status)
Perform update.
handleDelete(ilECSSetting $server, $a_content_id)
Handle delete.
handleCreate(ilECSSetting $server, $a_content_id)
Handle create.
Connector for course member ressource.
Presentation of ecs enrolment status.
static getInstance()
Get the singleton instance of this ilECSImportManager.
Component logger with individual log levels by component id.
static _getAllReferences(int $id)
get all reference ids for object ID
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static parseImportId(string $a_import_id)
Parse an ilias import id Typically of type il_[IL_INST_ID]_[OBJ_TYPE]_[OBJ_ID] returns array( 'orig' ...
Interface for all command queue handler classes.
$ref_id
Definition: ltiauth.php:66
global $DIC
Definition: shib_login.php:26