18 declare(strict_types=1);
30 protected ?
int $mid = null;
40 public function __construct(
int $a_id = 0,
bool $a_call_by_reference =
true)
46 $this->
logger = $DIC->logger()->wsrv();
89 return parent::beforeCreate();
116 $this->organization = $a_organization;
132 return $this->local_information ??
'';
142 $this->local_information = $a_info;
170 $this->remote_link = $a_link;
193 $ecs_user_data =
$user->toGET($setting);
194 $this->
logger->info(__METHOD__ .
': Using ecs user data ' . $ecs_user_data);
198 if (!$part->isTokenEnabled()) {
203 $ecs_url_hash =
'ecs_hash_url=' . urlencode(
$server->getServerURI() .
'/sys/auths/' .
$auth_hash);
206 $link = $this->
getRemoteLink() .
'&ecs_hash=' . $auth_hash . $ecs_user_data .
'&' . $ecs_url_hash;
208 $link = $this->
getRemoteLink() .
'?ecs_hash=' . $auth_hash . $ecs_user_data .
'&' . $ecs_url_hash;
210 $this->
logger->info(__METHOD__ .
': ECS full link: ' . $link);
225 $auth->setPid($import_info->getMID());
228 $realm = sha1($a_plain_realm);
229 $this->
logger->info(__METHOD__ .
': Using realm ' . $a_plain_realm);
230 $auth->setRealm($realm);
231 $this->
logger->info(__METHOD__ .
' Mid is ' . $this->
getMID());
233 $this->auth_hash = $connector->addAuth(json_encode(
$auth, JSON_THROW_ON_ERROR), $this->
getMID());
236 $this->
logger->info(__METHOD__ .
': Caught error from ECS Auth resource: ' . $exc->getMessage());
241 protected function doCreate(
bool $clone_mode =
false): void
244 "obj_id" => array(
"integer", $this->
getId()),
245 "local_information" => array(
"text",
""),
246 "remote_link" => array(
"text",
""),
247 "mid" => array(
"integer", 0),
248 "organization" => array(
"text",
"")
271 "mid" => array(
"integer", $this->
getMID()),
277 $where = array(
"obj_id" => array(
"integer", $this->
getId()));
279 $this->db->update($this->
getTableName(), $fields, $where);
298 " WHERE obj_id = " . $this->db->quote($this->
getId(),
'integer') .
" ";
299 $this->db->manipulate(
$query);
305 " WHERE obj_id = " . $this->db->quote($this->
getId(),
'integer') .
" ";
308 if (!is_null($row->local_information)) {
311 if (!is_null($row->remote_link)) {
314 $this->
setMID((
int) $row->mid);
315 if (!is_null($row->organization)) {
339 $this->log->info(
"Done calling create, creating reference");
342 $this->log->info(
"Done creating reference, setting permissions");
344 $this->log->info(
"Done setting permissions, putting object in tree");
357 $this->log->info(
"Done putting object in tree, updateing object");
369 $this->
logger->info(
'updateFromECSContent: ' . print_r($a_ecs_content,
true));
372 $organisation = null;
375 ->getParticipantNameByMid($a_owner);
376 $this->
logger->info(
'found organisation: ' . $organisation);
381 $this->
setTitle($a_ecs_content->title);
382 if (!is_null($a_ecs_content->abstract)) {
387 $this->
logger->info(
'updateCustomFromECSContent');
392 $this->
logger->info(
'ilObject->update()');
416 $this->
logger->info(
"importing metadata from json: " . print_r($a_json,
true));
420 foreach ($values_records as $values_record) {
422 $values_record->read();
427 foreach ($a_definition as
$id =>
$type) {
428 if (is_array(
$type)) {
435 if ($field = $mappings->getMappingByECSName($a_mapping_mode,
$id)) {
438 foreach ($values_records as $values_record) {
439 $adv_md_defs = $values_record->getDefinitions();
440 if (isset($adv_md_defs[$field])) {
441 $adv_md_def = $adv_md_defs[$field];
449 $raw_value = $a_json->{$target};
452 if (!is_object($timePlace)) {
454 if (is_object($raw_value)) {
455 $timePlace->loadFromJSON($raw_value);
458 $raw_value = $timePlace;
461 if ($adv_md_def->importFromECS((
string)
$type, (
string) $raw_value,
$id)) {
468 foreach ($values_records as $values_record) {
470 foreach ($values_record->getADTGroup()->getElements() as $element_id => $element) {
471 if (!$element->isNull()) {
472 $additional[$element_id] = array(
"disabled" => array(
"integer", 1));
513 return $this->
handleUpdate($a_server, $a_econtent_id, $a_mids);
531 $this->
logger->info(__METHOD__ .
': Handling delete of deprecated remote object. DONE');
535 $this->
logger->info(__METHOD__ .
': Receivers are ' . print_r(
$details->getReceivers(),
true));
536 $this->
logger->info(__METHOD__ .
': Senders are ' . print_r(
$details->getSenders(),
true));
540 $this->
logger->info(
'Ignoring disabled participant. MID: ' .
$details->getOwner());
545 foreach (array_intersect($a_mids,
$details->getReceivers()) as
$mid) {
552 $json =
$res->getResult();
553 $this->
logger->info(__METHOD__ .
': Received json: ' . print_r($json,
true));
554 if (!is_object($json)) {
557 if (!is_object($json)) {
562 $this->
logger->error(__METHOD__ .
': Error parsing result. ' . $exc->getMessage());
571 $this->
logger->info(__METHOD__ .
': Handling update for existing object');
573 if (!$remote instanceof
self) {
574 $this->
logger->info(__METHOD__ .
': Cannot instantiate remote object. Got object type ' . $remote->getType());
577 $remote->updateFromECSContent($a_server, $json,
$details->getMySender());
579 $this->
logger->info(__METHOD__ .
': my sender ' .
$details->getMySender() .
'vs mid' .
$mid);
581 $this->
logger->info(__METHOD__ .
': Handling create for non existing object');
585 $this->
logger->info(__METHOD__ .
': Updating import status');
589 $import->setMID($mid);
592 $this->
logger->info(__METHOD__ .
': Sending notification');
597 $this->
logger->info(__METHOD__ .
': done');
607 if (!count(
$settings->getEContentRecipients())) {
612 $lang->loadLanguageModule(
'ecs');
614 $mail =
new ilMail(self::MAIL_SENDER);
622 $message .=
$lang->txt(
"perma_link") .
': ' . $href .
"\n\n";
626 $settings->getEContentRecipientsAsString(),
629 $lang->txt(
'ecs_new_econtent_subject'),
645 $this->
logger->info(__METHOD__ .
': Received obj_ids ' . print_r($obj_ids,
true));
647 foreach ($obj_ids as $obj_id) {
649 foreach ($references as
$ref_id) {
651 $this->
logger->info(__METHOD__ .
': Deleting obsolete remote course: ' . $tmp_obj->getTitle());
652 $this->
logger->info(print_r($this->tree->getNodeData($ref_id),
true));
653 $this->
logger->info(print_r($this->tree->getNodeData($tmp_obj->getId()),
true));
654 $this->tree->deleteTree($this->tree->getNodeData($ref_id));
670 $connector->addHeader(
'X-EcsQueryStrings', $a_sender_only ?
'sender=true' :
'all=true');
673 return $list->getResult()->getLinkIds();
676 $this->
logger->error(__METHOD__ .
': Error getting resource list for type . ' . $this->
getECSObjectType() .
' with message: ' . $exc->getMessage());
const TYPE_REMOTE_CATEGORY
static getInstancesForObjectId(int $a_obj_id, ?string $a_obj_type=null, string $a_sub_type="-", int $a_sub_id=0)
static getInstance(int $a_server_id, int $mid)
Get instance by server id and mid.
doDelete()
Delete remote object.
sendNewContentNotification($a_server_id)
send notifications about new EContent
static getInstanceByServerId(int $a_server_id)
Get singleton instance.
getTableName()
Get db table name.
getOrganization()
get organization
doCreateCustomFields(array &$a_fields)
Add custom fields to db insert.
setRemoteLink(string $a_link)
set remote link
getRemoteLink()
get remote link
static getInstanceByServerId(int $a_server_id)
Get instance by server id.
Representation of ECS EContent Time Place.
createAuthResource(string $a_plain_realm)
create authentication resource on ecs server
Remote glossary app class.
setOrganization(string $a_organization)
set organization
getServerId()
Get current server id.
static getInstance()
Get the singelton instance of this ilECSExportManager.
doUpdateCustomFields(array &$a_fields)
Add custom fields to db update.
static _getAllReferences(int $id)
get all reference ids for object ID
updateFromECSContent(ilECSSetting $a_server, object $a_ecs_content, int $a_owner)
update remote object settings from ecs content
doReadCustomFields(object $a_row)
Read custom fields from db row.
updateCustomFromECSContent(ilECSSetting $a_server, $ecs_content)
update remote object settings from ecs content
static getInstanceByEventType(string $a_type)
Get instance by ilECSEvent(QueueReader) type.
Presentation of ecs content details (http://...campusconnect/courselinks/id/details) ...
Remote learning module app class.
getImportId()
get import id
getECSObjectType()
Get ECS resource identifier, e.g.
getRealmPlain()
Get realm plain.
setPermissions(int $parent_ref_id)
__construct(int $a_id=0, bool $a_call_by_reference=true)
importMetadataFromJson(object $a_json, ilECSSetting $a_server, array $a_definition, int $a_mapping_mode)
Add advanced metadata to json (export)
setLocalInformation(string $a_info)
set local information
isLocalObject()
Is remote object from same installation?
getAllResourceIds(ilECSSetting $a_server, bool $a_sender_only=false)
Get all available resources.
doCreate(bool $clone_mode=false)
handleUpdate(ilECSSetting $a_server, int $a_econtent_id, array $a_mids)
Handle update event.
createReference()
creates reference for object
setDescription(string $desc)
static getInstance()
Get the singleton instance of this ilECSImportManager.
string $local_information
create()
note: title, description and type should be set when this function is called
static _getStaticLink(?int $a_ref_id, string $a_type='', bool $a_fallback_goto=true, string $append="")
Get static link.
static getInstanceByServerId(int $a_server_id)
Get singleton instance per server.
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
getFullRemoteLink()
get full remote link Including ecs generated hash and auth mode
Storage of ECS imported objects.
handleCreate(ilECSSetting $a_server, int $a_econtent_id, array $a_mids)
Handle creation.
static _getLanguage(string $a_lang_key='')
Get language object.
Remote object app base class.
static getMatchingCategory(int $a_server_id, array $a_matchable_content)
get matching category
const TYPE_REMOTE_LEARNING_MODULE
setMID(int $a_mid)
set mid
handleDelete(ilECSSetting $a_server, int $a_econtent_id, $a_mid=0)
Handle delete event.
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
putInTree(int $parent_ref_id)
maybe this method should be in tree object!?
const TYPE_REMOTE_GLOSSARY
__construct(Container $dic, ilPlugin $plugin)
static getInstanceFromServer(int $a_server_id, int $a_econtent_id, string $a_resource_type)
Get data from server.
static _getAutoGeneratedMessageString(ilLanguage $lang=null)
setEContentId($a_id)
set econtent id
doUpdate()
Update remote object.
createFromECSEContent(ilECSSetting $a_server, object $a_ecs_content, int $a_owner)
create remote object from ECSContent object
Remote category app class.
static handleUpdate(int $a_obj_id, int $a_server_id, array $a_matchable_content)
Handle update of ecs content and create references.
const HTTP_CODE_NOT_FOUND
Stores relevant user data.
getLocalInformation()
get local information
static getMatchableContent(string $a_resource_id, int $a_server_id, object $a_ecs_content, int $a_owner)
Convert ECS content to rule matchable values.