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