ILIAS  release_8 Revision v8.23
ilRemoteObjectBase Class Reference

Remote object app base class. More...

+ Inheritance diagram for ilRemoteObjectBase:
+ Collaboration diagram for ilRemoteObjectBase:

Public Member Functions

 __construct (int $a_id=0, bool $a_call_by_reference=true)
 
 getRealmPlain ()
 Get realm plain. More...
 
 setOrganization (string $a_organization)
 set organization More...
 
 getOrganization ()
 get organization More...
 
 getLocalInformation ()
 get local information More...
 
 setLocalInformation (string $a_info)
 set local information More...
 
 getMID ()
 get mid More...
 
 setMID (int $a_mid)
 set mid More...
 
 setRemoteLink (string $a_link)
 set remote link More...
 
 getRemoteLink ()
 get remote link More...
 
 getFullRemoteLink ()
 get full remote link Including ecs generated hash and auth mode More...
 
 createAuthResource (string $a_plain_realm)
 create authentication resource on ecs server More...
 
 createFromECSEContent (ilECSSetting $a_server, object $a_ecs_content, int $a_owner)
 create remote object from ECSContent object More...
 
 updateFromECSContent (ilECSSetting $a_server, object $a_ecs_content, int $a_owner)
 update remote object settings from ecs content More...
 
 isLocalObject ()
 Is remote object from same installation? More...
 
 handleCreate (ilECSSetting $a_server, int $a_econtent_id, array $a_mids)
 Handle creation. More...
 
 handleUpdate (ilECSSetting $a_server, int $a_econtent_id, array $a_mids)
 Handle update event. More...
 
 handleDelete (ilECSSetting $a_server, int $a_econtent_id, $a_mid=0)
 Handle delete event. More...
 
 getAllResourceIds (ilECSSetting $a_server, bool $a_sender_only=false)
 Get all available resources. More...
 
- Public Member Functions inherited from ilObject2
 __construct (int $a_id=0, bool $a_reference=true)
 Constructor. More...
 
 read ()
 
 create (bool $a_clone_mode=false)
 
 update ()
 
 delete ()
 
 cloneMetaData (ilObject $target_obj)
 
 cloneObject (int $target_id, int $copy_id=0, bool $omit_tree=false)
 
- Public Member Functions inherited from ilObject
 __construct (int $id=0, bool $reference=true)
 
 withReferences ()
 determines whether objects are referenced or not (got ref ids or not) More...
 
 processAutoRating ()
 
 read ()
 
 getId ()
 
 setId (int $id)
 
 setRefId (int $ref_id)
 
 getRefId ()
 
 getType ()
 
 setType (string $type)
 
 getPresentationTitle ()
 get presentation title Normally same as title Overwritten for sessions More...
 
 getTitle ()
 
 getUntranslatedTitle ()
 Get untranslated object title WebDAV needs to access the untranslated title of an object. More...
 
 setTitle (string $title)
 
 getDescription ()
 
 setDescription (string $desc)
 
 getLongDescription ()
 get object long description (stored in object_description) More...
 
 getImportId ()
 
 setImportId (string $import_id)
 
 setOfflineStatus (bool $status)
 
 getOfflineStatus ()
 
 supportsOfflineHandling ()
 
 getOwner ()
 
 getOwnerName ()
 get full name of object owner More...
 
 setOwner (int $usr_id)
 
 getCreateDate ()
 Get create date in YYYY-MM-DD HH-MM-SS format. More...
 
 getLastUpdateDate ()
 Get last update date in YYYY-MM-DD HH-MM-SS format. More...
 
 create ()
 note: title, description and type should be set when this function is called More...
 
 update ()
 
 MDUpdateListener (string $element)
 Metadata update listener. More...
 
 createMetaData ()
 
 updateMetaData ()
 
 deleteMetaData ()
 
 updateOwner ()
 update owner of object in db More...
 
 putInTree (int $parent_ref_id)
 maybe this method should be in tree object!? More...
 
 setPermissions (int $parent_ref_id)
 
 setParentRolePermissions (int $parent_ref_id)
 Initialize the permissions of parent roles (local roles of categories, global roles...) This method is overwritten in e.g. More...
 
 createReference ()
 creates reference for object More...
 
 countReferences ()
 
 delete ()
 delete object or referenced object (in the case of a referenced object, object data is only deleted if last reference is deleted) This function removes an object entirely from system!! More...
 
 initDefaultRoles ()
 init default roles settings Purpose of this function is to create a local role folder and local roles, that are needed depending on the object type. More...
 
 applyDidacticTemplate (int $tpl_id)
 
 getXMLZip ()
 
 getHTMLDirectory ()
 
 appendCopyInfo (int $target_id, int $copy_id)
 Prepend Copy info if object with same name exists in that container. More...
 
 cloneDependencies (int $target_id, int $copy_id)
 Clone object dependencies. More...
 
 cloneMetaData (ilObject $target_obj)
 Copy meta data. More...
 
 selfOrParentWithRatingEnabled ()
 
 getPossibleSubObjects (bool $filter=true)
 get all possible sub objects of this type the object can decide which types of sub objects are possible jut in time overwrite if the decision distinguish from standard model More...
 

Static Public Member Functions

static getInstanceByEventType (string $a_type)
 Get instance by ilECSEvent(QueueReader) type. More...
 
- Static Public Member Functions inherited from ilObject
static _lookupObjIdByImportId (string $import_id)
 Get (latest) object id for an import id. More...
 
static _lookupImportId (int $obj_id)
 
static _lookupOwnerName (int $owner_id)
 Lookup owner name for owner id. More...
 
static _getIdForImportId (string $import_id)
 
static _getAllReferences (int $id)
 get all reference ids for object ID More...
 
static _lookupTitle (int $obj_id)
 
static lookupOfflineStatus (int $obj_id)
 Lookup offline status using objectDataCache. More...
 
static _lookupOwner (int $obj_id)
 Lookup owner user ID for object ID. More...
 
static _getIdsForTitle (string $title, string $type='', bool $partial_match=false)
 
static _lookupDescription (int $obj_id)
 
static _lookupLastUpdate (int $obj_id, bool $formatted=false)
 
static _getLastUpdateOfObjects (array $obj_ids)
 
static _lookupObjId (int $ref_id)
 
static _setDeletedDate (int $ref_id, int $deleted_by)
 
static setDeletedDates (array $ref_ids, int $user_id)
 
static _resetDeletedDate (int $ref_id)
 
static _lookupDeletedDate (int $ref_id)
 
static _writeTitle (int $obj_id, string $title)
 write title to db (static) More...
 
static _writeDescription (int $obj_id, string $desc)
 write description to db (static) More...
 
static _writeImportId (int $obj_id, string $import_id)
 write import id to db (static) More...
 
static _lookupType (int $id, bool $reference=false)
 
static _isInTrash (int $ref_id)
 
static _hasUntrashedReference (int $obj_id)
 checks whether an object has at least one reference that is not in trash More...
 
static _lookupObjectId (int $ref_id)
 
static _getObjectsDataForType (string $type, bool $omit_trash=false)
 get all objects of a certain type More...
 
static _exists (int $id, bool $reference=false, ?string $type=null)
 checks if an object exists in object_data More...
 
static _getObjectsByType (string $obj_type="", int $owner=null)
 
static _prepareCloneSelection (array $ref_ids, string $new_type, bool $show_path=true)
 Prepare copy wizard object selection. More...
 
static _getIcon (int $obj_id=0, string $size="big", string $type="", bool $offline=false)
 Get icon for repository item. More...
 
static collectDeletionDependencies (array &$deps, int $ref_id, int $obj_id, string $type, int $depth=0)
 Collect deletion dependencies. More...
 
static getDeletionDependencies (int $obj_id)
 Get deletion dependencies. More...
 
static getLongDescriptions (array $obj_ids)
 
static getAllOwnedRepositoryObjects (int $user_id)
 
static fixMissingTitles ($type, array &$obj_title_map)
 Try to fix missing object titles. More...
 
static _lookupCreationDate (int $obj_id)
 
static _getObjectTypeIdByTitle (string $type, \ilDBInterface $ilDB=null)
 

Data Fields

const MAIL_SENDER = 6
 
const OBJECT_OWNER = 6
 
- Data Fields inherited from ilObject
const TITLE_LENGTH = 255
 
const DESC_LENGTH = 128
 
const LONG_DESC_LENGTH = 4000
 
const TABLE_OBJECT_DATA = "object_data"
 
array $objectList
 
string $untranslatedTitle
 

Protected Member Functions

 beforeCreate ()
 
 getTableName ()
 Get db table name. More...
 
 getECSObjectType ()
 Get ECS resource identifier, e.g. More...
 
 doCreate (bool $clone_mode=false)
 
 doCreateCustomFields (array &$a_fields)
 Add custom fields to db insert. More...
 
 doUpdate ()
 Update remote object. More...
 
 doUpdateCustomFields (array &$a_fields)
 Add custom fields to db update. More...
 
 doDelete ()
 Delete remote object. More...
 
 doRead ()
 
 doReadCustomFields (object $a_row)
 Read custom fields from db row. More...
 
 importMetadataFromJson (object $a_json, ilECSSetting $a_server, array $a_definition, int $a_mapping_mode)
 Add advanced metadata to json (export) More...
 
 updateCustomFromECSContent (ilECSSetting $a_server, $ecs_content)
 update remote object settings from ecs content More...
 
 sendNewContentNotification ($a_server_id)
 send notifications about new EContent More...
 
- Protected Member Functions inherited from ilObject2
 initType ()
 
 doRead ()
 
 doCreate (bool $clone_mode=false)
 
 beforeCreate ()
 If overwritten this method should return true, there is currently no "abort" handling for cases where "false" is returned. More...
 
 doUpdate ()
 
 beforeUpdate ()
 
 doDelete ()
 
 beforeDelete ()
 
 doCloneObject (ilObject2 $new_obj, int $a_target_id, ?int $a_copy_id=null)
 
 beforeCloneObject ()
 
- Protected Member Functions inherited from ilObject
 doMDUpdateListener (string $a_element)
 
 beforeMDUpdateListener (string $a_element)
 
 doCreateMetaData ()
 
 beforeCreateMetaData ()
 
 doUpdateMetaData ()
 
 beforeUpdateMetaData ()
 
 doDeleteMetaData ()
 
 beforeDeleteMetaData ()
 
 handleAutoRating ()
 
 hasAutoRating ()
 

Protected Attributes

string $local_information = null
 
string $remote_link = null
 
string $organization = null
 
int $mid = null
 
string $auth_hash = ''
 
string $realm_plain = ''
 
- Protected Attributes inherited from ilObject
ilLogger $obj_log
 
ILIAS $ilias
 
ilObjectDefinition $obj_definition
 
ilDBInterface $db
 
ilLogger $log
 
ilErrorHandling $error
 
ilTree $tree
 
ilAppEventHandler $app_event_handler
 
ilRbacAdmin $rbac_admin
 
ilRbacReview $rbac_review
 
ilObjUser $user
 
ilLanguage $lng
 
int $id
 
bool $referenced
 
bool $call_by_reference
 
int $max_title = self::TITLE_LENGTH
 
int $max_desc = self::DESC_LENGTH
 
bool $add_dots = true
 
int $ref_id = null
 
string $type = ""
 
string $title = ""
 
bool $offline = false
 
string $desc = ""
 
string $long_desc = ""
 
int $owner = 0
 
string $create_date = ""
 
string $last_update = ""
 
string $import_id = ""
 
bool $register = false
 

Private Attributes

ilLogger $logger
 

Detailed Description

Remote object app base class.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 25 of file class.ilRemoteObjectBase.php.

Constructor & Destructor Documentation

◆ __construct()

ilRemoteObjectBase::__construct ( int  $a_id = 0,
bool  $a_call_by_reference = true 
)

Definition at line 40 of file class.ilRemoteObjectBase.php.

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), and ILIAS\Repository\logger().

41  {
42  global $DIC;
43 
44  parent::__construct($a_id, $a_call_by_reference);
45 
46  $this->logger = $DIC->logger()->wsrv();
47  }
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ beforeCreate()

ilRemoteObjectBase::beforeCreate ( )
protected

Definition at line 86 of file class.ilRemoteObjectBase.php.

References getECSObjectType(), getTableName(), and ilObject\setOwner().

86  : bool
87  {
88  $this->setOwner(self::OBJECT_OWNER);
89  return parent::beforeCreate();
90  }
setOwner(int $usr_id)
+ Here is the call graph for this function:

◆ createAuthResource()

ilRemoteObjectBase::createAuthResource ( string  $a_plain_realm)

create authentication resource on ecs server

Definition at line 217 of file class.ilRemoteObjectBase.php.

References $auth, $auth_hash, ilObject\getId(), ilECSImportManager\getInstance(), ilECSSetting\getInstanceByServerId(), getMID(), getRemoteLink(), and ILIAS\Repository\logger().

Referenced by getFullRemoteLink().

218  {
219  try {
220  $server_id = ilECSImportManager::getInstance()->lookupServerId($this->getId());
221  $import_info = new ilECSImport($server_id, $this->getId());
222 
223  $connector = new ilECSConnector(ilECSSetting::getInstanceByServerId($server_id));
224  $auth = new ilECSAuth();
225  $auth->setPid($import_info->getMID());
226  //TODO URL is deprecated
227  $auth->setUrl($this->getRemoteLink());
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());
232  //TODO remove @
233  $this->auth_hash = $connector->addAuth(json_encode($auth, JSON_THROW_ON_ERROR), $this->getMID());
234  return $this->auth_hash;
235  } catch (ilECSConnectorException $exc) {
236  $this->logger->info(__METHOD__ . ': Caught error from ECS Auth resource: ' . $exc->getMessage());
237  return false;
238  }
239  }
getRemoteLink()
get remote link
$auth
Definition: metadata.php:76
static getInstance()
Get the singleton instance of this ilECSImportManager.
static getInstanceByServerId(int $a_server_id)
Get singleton instance per server.
Storage of ECS imported objects.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createFromECSEContent()

ilRemoteObjectBase::createFromECSEContent ( ilECSSetting  $a_server,
object  $a_ecs_content,
int  $a_owner 
)

create remote object from ECSContent object

Parameters
ilECSSetting$a_server
object$a_ecs_contentobject with object settings
int$a_owner

Definition at line 336 of file class.ilRemoteObjectBase.php.

References ilObject\create(), ilObject\createReference(), getECSObjectType(), ilECSSetting\getImportId(), ilECSUtils\getMatchableContent(), ilECSCategoryMapping\getMatchingCategory(), ilECSSetting\getServerId(), ilObject\putInTree(), ilObject\setPermissions(), and updateFromECSContent().

Referenced by handleUpdate().

336  : void
337  {
338  $this->create();
339  $this->log->info("Done calling create, creating reference");
340  // won't work for personal workspace
341  $this->createReference();
342  $this->log->info("Done creating reference, setting permissions");
343  $this->setPermissions($a_server->getImportId());
344  $this->log->info("Done setting permissions, putting object in tree");
345 
346  $matchable_content = ilECSUtils::getMatchableContent(
347  $this->getECSObjectType(),
348  $a_server->getServerId(),
349  $a_ecs_content,
350  $a_owner
351  );
352 
354  $a_server->getServerId(),
355  $matchable_content
356  ));
357  $this->log->info("Done putting object in tree, updateing object");
358 
359  $this->updateFromECSContent($a_server, $a_ecs_content, $a_owner);
360  }
getServerId()
Get current server id.
updateFromECSContent(ilECSSetting $a_server, object $a_ecs_content, int $a_owner)
update remote object settings from ecs content
getImportId()
get import id
getECSObjectType()
Get ECS resource identifier, e.g.
setPermissions(int $parent_ref_id)
createReference()
creates reference for object
create()
note: title, description and type should be set when this function is called
static getMatchingCategory(int $a_server_id, array $a_matchable_content)
get matching category
putInTree(int $parent_ref_id)
maybe this method should be in tree object!?
static getMatchableContent(string $a_resource_id, int $a_server_id, object $a_ecs_content, int $a_owner)
Convert ECS content to rule matchable values.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ doCreate()

ilRemoteObjectBase::doCreate ( bool  $clone_mode = false)
protected

Definition at line 241 of file class.ilRemoteObjectBase.php.

References doCreateCustomFields(), ilObject\getId(), and getTableName().

241  : void
242  {
243  $fields = array(
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", "")
249  );
250 
251  $this->doCreateCustomFields($fields);
252 
253  $this->db->insert($this->getTableName(), $fields);
254  }
getTableName()
Get db table name.
doCreateCustomFields(array &$a_fields)
Add custom fields to db insert.
+ Here is the call graph for this function:

◆ doCreateCustomFields()

ilRemoteObjectBase::doCreateCustomFields ( array &  $a_fields)
protected

Add custom fields to db insert.

Definition at line 259 of file class.ilRemoteObjectBase.php.

Referenced by doCreate().

259  : void
260  {
261  }
+ Here is the caller graph for this function:

◆ doDelete()

ilRemoteObjectBase::doDelete ( )
protected

Delete remote object.

Definition at line 292 of file class.ilRemoteObjectBase.php.

References $query, ilObject\getId(), ilECSImportManager\getInstance(), and getTableName().

292  : void
293  {
294  //put here your module specific stuff
295  ilECSImportManager::getInstance()->_deleteByObjId($this->getId());
296 
297  $query = "DELETE FROM " . $this->getTableName() .
298  " WHERE obj_id = " . $this->db->quote($this->getId(), 'integer') . " ";
299  $this->db->manipulate($query);
300  }
getTableName()
Get db table name.
static getInstance()
Get the singleton instance of this ilECSImportManager.
$query
+ Here is the call graph for this function:

◆ doRead()

ilRemoteObjectBase::doRead ( )
protected

Definition at line 302 of file class.ilRemoteObjectBase.php.

References $query, $res, doReadCustomFields(), ilDBConstants\FETCHMODE_OBJECT, ilObject\getId(), getTableName(), setLocalInformation(), setMID(), setOrganization(), and setRemoteLink().

302  : void
303  {
304  $query = "SELECT * FROM " . $this->getTableName() .
305  " WHERE obj_id = " . $this->db->quote($this->getId(), 'integer') . " ";
306  $res = $this->db->query($query);
307  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
308  if (!is_null($row->local_information)) {
309  $this->setLocalInformation($row->local_information);
310  }
311  if (!is_null($row->remote_link)) {
312  $this->setRemoteLink($row->remote_link);
313  }
314  $this->setMID((int) $row->mid);
315  if (!is_null($row->organization)) {
316  $this->setOrganization($row->organization);
317  }
318  $this->doReadCustomFields($row);
319  }
320  }
$res
Definition: ltiservices.php:69
getTableName()
Get db table name.
setRemoteLink(string $a_link)
set remote link
setOrganization(string $a_organization)
set organization
doReadCustomFields(object $a_row)
Read custom fields from db row.
setLocalInformation(string $a_info)
set local information
$query
setMID(int $a_mid)
set mid
+ Here is the call graph for this function:

◆ doReadCustomFields()

ilRemoteObjectBase::doReadCustomFields ( object  $a_row)
protected

Read custom fields from db row.

Definition at line 325 of file class.ilRemoteObjectBase.php.

Referenced by doRead().

325  : void
326  {
327  }
+ Here is the caller graph for this function:

◆ doUpdate()

ilRemoteObjectBase::doUpdate ( )
protected

Update remote object.

Definition at line 266 of file class.ilRemoteObjectBase.php.

References doUpdateCustomFields(), ilObject\getId(), getLocalInformation(), getMID(), getOrganization(), getRemoteLink(), and getTableName().

266  : void
267  {
268  $fields = array(
269  "local_information" => array("text", $this->getLocalInformation()),
270  "remote_link" => array("text", $this->getRemoteLink()),
271  "mid" => array("integer", $this->getMID()),
272  "organization" => array("text", $this->getOrganization())
273  );
274 
275  $this->doUpdateCustomFields($fields);
276 
277  $where = array("obj_id" => array("integer", $this->getId()));
278 
279  $this->db->update($this->getTableName(), $fields, $where);
280  }
getTableName()
Get db table name.
getOrganization()
get organization
getRemoteLink()
get remote link
doUpdateCustomFields(array &$a_fields)
Add custom fields to db update.
getLocalInformation()
get local information
+ Here is the call graph for this function:

◆ doUpdateCustomFields()

ilRemoteObjectBase::doUpdateCustomFields ( array &  $a_fields)
protected

Add custom fields to db update.

Definition at line 285 of file class.ilRemoteObjectBase.php.

Referenced by doUpdate().

285  : void
286  {
287  }
+ Here is the caller graph for this function:

◆ getAllResourceIds()

ilRemoteObjectBase::getAllResourceIds ( ilECSSetting  $a_server,
bool  $a_sender_only = false 
)

Get all available resources.

Definition at line 666 of file class.ilRemoteObjectBase.php.

References getECSObjectType(), and ILIAS\Repository\logger().

666  : array
667  {
668  try {
669  $connector = new ilECSConnector($a_server);
670  $connector->addHeader('X-EcsQueryStrings', $a_sender_only ? 'sender=true' : 'all=true'); // #11301
671  $list = $connector->getResourceList($this->getECSObjectType());
672  if ($list instanceof ilECSResult) {
673  return $list->getResult()->getLinkIds();
674  }
675  } catch (ilECSConnectorException $exc) {
676  $this->logger->error(__METHOD__ . ': Error getting resource list for type . ' . $this->getECSObjectType() . ' with message: ' . $exc->getMessage());
677  }
678 
679  return [];
680  }
getECSObjectType()
Get ECS resource identifier, e.g.
+ Here is the call graph for this function:

◆ getECSObjectType()

ilRemoteObjectBase::getECSObjectType ( )
abstractprotected

Get ECS resource identifier, e.g.

"/campusconnect/courselinks"

Referenced by beforeCreate(), createFromECSEContent(), getAllResourceIds(), handleUpdate(), and updateFromECSContent().

+ Here is the caller graph for this function:

◆ getFullRemoteLink()

ilRemoteObjectBase::getFullRemoteLink ( )

get full remote link Including ecs generated hash and auth mode

Exceptions
ilECSConnectorException

Definition at line 187 of file class.ilRemoteObjectBase.php.

References $auth_hash, $server, ilObject\$user, createAuthResource(), ilObject\getId(), ilECSImportManager\getInstance(), ilECSParticipantSetting\getInstance(), ilECSSetting\getInstanceByServerId(), getMID(), getRemoteLink(), ILIAS\Repository\logger(), and ILIAS\Repository\user().

187  : string
188  {
189  $server_id = ilECSImportManager::getInstance()->lookupServerId($this->getId());
191  $setting = ilECSParticipantSetting::getInstance($server_id, $this->mid);
192  $user = new ilECSUser($this->user);
193  $ecs_user_data = $user->toGET($setting);
194  $this->logger->info(__METHOD__ . ': Using ecs user data ' . $ecs_user_data);
195 
196  // check token mechanism enabled
197  $part = new ilECSParticipantSetting($server_id, $this->getMID());
198  if (!$part->isTokenEnabled()) {
199  return $this->getRemoteLink();
200  }
201 
202  $auth_hash = $this->createAuthResource($this->getRemoteLink() . $user->toREALM());
203  $ecs_url_hash = 'ecs_hash_url=' . urlencode($server->getServerURI() . '/sys/auths/' . $auth_hash);
204 
205  if (strpos($this->getRemoteLink(), '?')) {
206  $link = $this->getRemoteLink() . '&ecs_hash=' . $auth_hash . $ecs_user_data . '&' . $ecs_url_hash;
207  } else {
208  $link = $this->getRemoteLink() . '?ecs_hash=' . $auth_hash . $ecs_user_data . '&' . $ecs_url_hash;
209  }
210  $this->logger->info(__METHOD__ . ': ECS full link: ' . $link);
211  return $link;
212  }
static getInstance(int $a_server_id, int $mid)
Get instance by server id and mid.
getRemoteLink()
get remote link
createAuthResource(string $a_plain_realm)
create authentication resource on ecs server
static getInstance()
Get the singleton instance of this ilECSImportManager.
static getInstanceByServerId(int $a_server_id)
Get singleton instance per server.
$server
Stores relevant user data.
ilObjUser $user
+ Here is the call graph for this function:

◆ getInstanceByEventType()

static ilRemoteObjectBase::getInstanceByEventType ( string  $a_type)
static

Get instance by ilECSEvent(QueueReader) type.

Returns
?ilRemoteObjectBase

Definition at line 54 of file class.ilRemoteObjectBase.php.

References ilECSEventQueueReader\TYPE_REMOTE_CATEGORY, ilECSEventQueueReader\TYPE_REMOTE_COURSE, ilECSEventQueueReader\TYPE_REMOTE_FILE, ilECSEventQueueReader\TYPE_REMOTE_GLOSSARY, ilECSEventQueueReader\TYPE_REMOTE_GROUP, ilECSEventQueueReader\TYPE_REMOTE_LEARNING_MODULE, ilECSEventQueueReader\TYPE_REMOTE_TEST, and ilECSEventQueueReader\TYPE_REMOTE_WIKI.

Referenced by ilECSEventQueueReader\getAllResourceIds(), and ilECSTaskScheduler\handleEvents().

55  {
56  switch ($a_type) {
58  return new ilObjRemoteCourse();
59 
61  return new ilObjRemoteCategory();
62 
64  return new ilObjRemoteFile();
65 
67  return new ilObjRemoteGlossary();
68 
70  return new ilObjRemoteGroup();
71 
73  return new ilObjRemoteLearningModule();
74 
76  return new ilObjRemoteWiki();
77 
79  return new ilObjRemoteTest();
80 
81  default:
82  return null;
83  }
84  }
Remote test app class.
Remote file app class.
Remote glossary app class.
Remote learning module app class.
Remote wiki app class.
Remote course app class.
Remote group app class.
Remote category app class.
+ Here is the caller graph for this function:

◆ getLocalInformation()

ilRemoteObjectBase::getLocalInformation ( )

get local information

Definition at line 130 of file class.ilRemoteObjectBase.php.

Referenced by doUpdate().

130  : string
131  {
132  return $this->local_information ?? '';
133  }
+ Here is the caller graph for this function:

◆ getMID()

ilRemoteObjectBase::getMID ( )

get mid

Definition at line 148 of file class.ilRemoteObjectBase.php.

References $mid.

Referenced by createAuthResource(), doUpdate(), and getFullRemoteLink().

148  : int
149  {
150  return $this->mid;
151  }
+ Here is the caller graph for this function:

◆ getOrganization()

ilRemoteObjectBase::getOrganization ( )

get organization

Definition at line 122 of file class.ilRemoteObjectBase.php.

References $organization.

Referenced by doUpdate().

122  : string
123  {
124  return $this->organization;
125  }
+ Here is the caller graph for this function:

◆ getRealmPlain()

ilRemoteObjectBase::getRealmPlain ( )

Get realm plain.

Definition at line 106 of file class.ilRemoteObjectBase.php.

References $realm_plain.

106  : string
107  {
108  return $this->realm_plain;
109  }

◆ getRemoteLink()

ilRemoteObjectBase::getRemoteLink ( )

get remote link

Definition at line 176 of file class.ilRemoteObjectBase.php.

References $remote_link.

Referenced by createAuthResource(), doUpdate(), and getFullRemoteLink().

176  : string
177  {
178  return $this->remote_link;
179  }
+ Here is the caller graph for this function:

◆ getTableName()

ilRemoteObjectBase::getTableName ( )
abstractprotected

Get db table name.

Referenced by beforeCreate(), doCreate(), doDelete(), doRead(), and doUpdate().

+ Here is the caller graph for this function:

◆ handleCreate()

ilRemoteObjectBase::handleCreate ( ilECSSetting  $a_server,
int  $a_econtent_id,
array  $a_mids 
)

Handle creation.

called by ilTaskScheduler

Definition at line 511 of file class.ilRemoteObjectBase.php.

References handleUpdate().

511  : bool
512  {
513  return $this->handleUpdate($a_server, $a_econtent_id, $a_mids);
514  }
handleUpdate(ilECSSetting $a_server, int $a_econtent_id, array $a_mids)
Handle update event.
+ Here is the call graph for this function:

◆ handleDelete()

ilRemoteObjectBase::handleDelete ( ilECSSetting  $a_server,
int  $a_econtent_id,
  $a_mid = 0 
)

Handle delete event.

called by ilTaskScheduler

Definition at line 640 of file class.ilRemoteObjectBase.php.

References ilObject\$ref_id, ilObject\_getAllReferences(), ilECSImportManager\getInstance(), ilObjectFactory\getInstanceByRefId(), ilECSSetting\getServerId(), and ILIAS\Repository\logger().

Referenced by handleUpdate().

640  : bool
641  {
642  // there is no information about the original mid anymore.
643  // Therefor delete any remote objects with given econtent id
644  $obj_ids = ilECSImportManager::getInstance()->_lookupObjIds($a_server->getServerId(), $a_econtent_id);
645  $this->logger->info(__METHOD__ . ': Received obj_ids ' . print_r($obj_ids, true));
646 
647  foreach ($obj_ids as $obj_id) {
648  $references = ilObject::_getAllReferences($obj_id);
649  foreach ($references as $ref_id) {
650  if ($tmp_obj = ilObjectFactory::getInstanceByRefId($ref_id, false)) {
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));
655  $tmp_obj->delete();
656  }
657  unset($tmp_obj);
658  }
659  }
660  return true;
661  }
getServerId()
Get current server id.
static _getAllReferences(int $id)
get all reference ids for object ID
static getInstance()
Get the singleton instance of this ilECSImportManager.
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleUpdate()

ilRemoteObjectBase::handleUpdate ( ilECSSetting  $a_server,
int  $a_econtent_id,
array  $a_mids 
)

Handle update event.

called by ilTaskScheduler

Definition at line 521 of file class.ilRemoteObjectBase.php.

References ILIAS\LTI\ToolProvider\$details, $mid, $res, createFromECSEContent(), ilLogLevel\ERROR, getECSObjectType(), ilObject\getId(), ilECSImportManager\getInstance(), ilObjectFactory\getInstanceByObjId(), ilECSParticipantSettings\getInstanceByServerId(), ilECSEContentDetails\getInstanceFromServer(), ilECSSetting\getServerId(), handleDelete(), ilECSConnector\HTTP_CODE_NOT_FOUND, ILIAS\Repository\logger(), sendNewContentNotification(), and ilECSImport\setEContentId().

Referenced by handleCreate().

521  : bool
522  {
523  // get content details
525  $a_server->getServerId(),
526  $a_econtent_id,
527  $this->getECSObjectType()
528  );
529  if (!$details instanceof ilECSEContentDetails) {
530  $this->handleDelete($a_server, $a_econtent_id);
531  $this->logger->info(__METHOD__ . ': Handling delete of deprecated remote object. DONE');
532  return true;
533  }
534 
535  $this->logger->info(__METHOD__ . ': Receivers are ' . print_r($details->getReceivers(), true));
536  $this->logger->info(__METHOD__ . ': Senders are ' . print_r($details->getSenders(), true));
537 
538  // check owner (sender mid)
539  if (!ilECSParticipantSettings::getInstanceByServerId($a_server->getServerId())->isImportAllowed($details->getSenders())) {
540  $this->logger->info('Ignoring disabled participant. MID: ' . $details->getOwner());
541  return true;
542  }
543 
544  // new mids
545  foreach (array_intersect($a_mids, $details->getReceivers()) as $mid) {
546  try {
547  $connector = new ilECSConnector($a_server);
548  $res = $connector->getResource($this->getECSObjectType(), $a_econtent_id);
549  if ($res->getHTTPCode() === ilECSConnector::HTTP_CODE_NOT_FOUND) {
550  continue;
551  }
552  $json = $res->getResult();
553  $this->logger->info(__METHOD__ . ': Received json: ' . print_r($json, true));
554  if (!is_object($json)) {
555  // try as array (workaround for invalid content)
556  $json = $json[0];
557  if (!is_object($json)) {
558  throw new ilECSConnectorException('invalid json');
559  }
560  }
561  } catch (ilECSConnectorException $exc) {
562  $this->logger->error(__METHOD__ . ': Error parsing result. ' . $exc->getMessage());
563  $this->logger->logStack(ilLogLevel::ERROR);
564  return false;
565  }
566 
567  // Update existing
568 
569  // Check receiver mid
570  if ($obj_id = ilECSImportManager::getInstance()->_isImported($a_server->getServerId(), (string) $a_econtent_id, $mid)) {
571  $this->logger->info(__METHOD__ . ': Handling update for existing object');
572  $remote = ilObjectFactory::getInstanceByObjId($obj_id, false);
573  if (!$remote instanceof self) {
574  $this->logger->info(__METHOD__ . ': Cannot instantiate remote object. Got object type ' . $remote->getType());
575  continue;
576  }
577  $remote->updateFromECSContent($a_server, $json, $details->getMySender());
578  } else {
579  $this->logger->info(__METHOD__ . ': my sender ' . $details->getMySender() . 'vs mid' . $mid);
580 
581  $this->logger->info(__METHOD__ . ': Handling create for non existing object');
582  $this->createFromECSEContent($a_server, $json, $details->getMySender());
583 
584  // update import status
585  $this->logger->info(__METHOD__ . ': Updating import status');
586  $import = new ilECSImport($a_server->getServerId(), $this->getId());
587  $import->setEContentId((string) $a_econtent_id);
588  // Store receiver mid
589  $import->setMID($mid);
590  $import->save();
591 
592  $this->logger->info(__METHOD__ . ': Sending notification');
593  $this->sendNewContentNotification($a_server->getServerId());
594  }
595  }
596 
597  $this->logger->info(__METHOD__ . ': done');
598  return true;
599  }
$res
Definition: ltiservices.php:69
sendNewContentNotification($a_server_id)
send notifications about new EContent
static getInstanceByServerId(int $a_server_id)
Get instance by server id.
getServerId()
Get current server id.
Presentation of ecs content details (http://...campusconnect/courselinks/id/details) ...
getECSObjectType()
Get ECS resource identifier, e.g.
array $details
Details for error message relating to last request processed.
Definition: System.php:109
static getInstance()
Get the singleton instance of this ilECSImportManager.
Storage of ECS imported objects.
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
static getInstanceFromServer(int $a_server_id, int $a_econtent_id, string $a_resource_type)
Get data from server.
setEContentId($a_id)
set econtent id
createFromECSEContent(ilECSSetting $a_server, object $a_ecs_content, int $a_owner)
create remote object from ECSContent object
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ importMetadataFromJson()

ilRemoteObjectBase::importMetadataFromJson ( object  $a_json,
ilECSSetting  $a_server,
array  $a_definition,
int  $a_mapping_mode 
)
protected

Add advanced metadata to json (export)

Definition at line 414 of file class.ilRemoteObjectBase.php.

References $additional, ilObject\$id, ilObject\$type, ilObject\getId(), ilECSDataMappingSettings\getInstanceByServerId(), ilAdvancedMDValues\getInstancesForObjectId(), ilECSSetting\getServerId(), ilObject\getType(), ILIAS\Repository\logger(), and ilECSUtils\TYPE_TIMEPLACE.

Referenced by ilObjRemoteCourse\updateCustomFromECSContent().

414  : void
415  {
416  $this->logger->info("importing metadata from json: " . print_r($a_json, true));
417 
419  $values_records = ilAdvancedMDValues::getInstancesForObjectId($this->getId(), $this->getType());
420  foreach ($values_records as $values_record) {
421  // this correctly binds group and definitions
422  $values_record->read();
423  }
424 
425  $do_save = false;
426 
427  foreach ($a_definition as $id => $type) {
428  if (is_array($type)) {
429  [$type, $target] = $type;
430  } else {
431  $target = $id;
432  }
433 
434  $timePlace = null;
435  if ($field = $mappings->getMappingByECSName($a_mapping_mode, $id)) {
436  // find element in records
437  $adv_md_def = null;
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];
442  break;
443  }
444  }
445  if (!$adv_md_def) {
446  continue;
447  }
448 
449  $raw_value = $a_json->{$target};
450 
452  if (!is_object($timePlace)) {
453  $timePlace = new ilECSTimePlace();
454  if (is_object($raw_value)) {
455  $timePlace->loadFromJSON($raw_value);
456  }
457  }
458  $raw_value = $timePlace;
459  }
460 
461  if ($adv_md_def->importFromECS((string) $type, (string) $raw_value, $id)) {
462  $do_save = true;
463  }
464  }
465  }
466 
467  if ($do_save) {
468  foreach ($values_records as $values_record) {
469  $additional = array();
470  foreach ($values_record->getADTGroup()->getElements() as $element_id => $element) {
471  if (!$element->isNull()) {
472  $additional[$element_id] = array("disabled" => array("integer", 1));
473  }
474  }
475  $values_record->write($additional);
476  }
477  }
478  }
static getInstancesForObjectId(int $a_obj_id, ?string $a_obj_type=null, string $a_sub_type="-", int $a_sub_id=0)
string $type
static getInstanceByServerId(int $a_server_id)
Get singleton instance.
Representation of ECS EContent Time Place.
getServerId()
Get current server id.
const TYPE_TIMEPLACE
$additional
Definition: goto.php:53
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isLocalObject()

ilRemoteObjectBase::isLocalObject ( )

Is remote object from same installation?

Returns
boolean

Definition at line 495 of file class.ilRemoteObjectBase.php.

References ilObject\getId(), ilECSExportManager\getInstance(), and ilECSImportManager\getInstance().

495  : bool
496  {
497  if (ilECSExportManager::getInstance()->_isRemote(
498  ilECSImportManager::getInstance()->lookupServerId($this->getId()),
499  (int) ilECSImportManager::getInstance()->_lookupEContentId($this->getId())
500  )) {
501  return false;
502  }
503  return true;
504  }
static getInstance()
Get the singelton instance of this ilECSExportManager.
static getInstance()
Get the singleton instance of this ilECSImportManager.
+ Here is the call graph for this function:

◆ sendNewContentNotification()

ilRemoteObjectBase::sendNewContentNotification (   $a_server_id)
protected

send notifications about new EContent

Definition at line 604 of file class.ilRemoteObjectBase.php.

References ilObject\$desc, $lang, $message, ILIAS\LTI\ToolProvider\$settings, ilMail\_getAutoGeneratedMessageString(), ilLanguageFactory\_getLanguage(), ilLink\_getStaticLink(), ilObject\getDescription(), ilECSSetting\getInstanceByServerId(), ilObject\getRefId(), ilObject\getTitle(), and ilObject\getType().

Referenced by handleUpdate().

604  : void
605  {
607  if (!count($settings->getEContentRecipients())) {
608  return;
609  }
610 
612  $lang->loadLanguageModule('ecs');
613 
614  $mail = new ilMail(self::MAIL_SENDER);
615  $message = $lang->txt('ecs_' . $this->getType() . '_created_body_a') . "\n\n";
616  $message .= $lang->txt('title') . ': ' . $this->getTitle() . "\n";
617  if ($desc = ($this->getDescription() !== '')) {
618  $message .= $lang->txt('desc') . ': ' . $desc . "\n";
619  }
620 
621  $href = ilLink::_getStaticLink($this->getRefId(), $this->getType(), true);
622  $message .= $lang->txt("perma_link") . ': ' . $href . "\n\n";
624 
625  $mail->enqueue(
626  $settings->getEContentRecipientsAsString(),
627  '',
628  '',
629  $lang->txt('ecs_new_econtent_subject'),
630  $message,
631  array()
632  );
633  }
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
string $desc
static getInstanceByServerId(int $a_server_id)
Get singleton instance per server.
static _getLanguage(string $a_lang_key='')
Get language object.
$lang
Definition: xapiexit.php:26
static _getAutoGeneratedMessageString(ilLanguage $lang=null)
$message
Definition: xapiexit.php:32
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setLocalInformation()

ilRemoteObjectBase::setLocalInformation ( string  $a_info)

set local information

Parameters
string$a_info

Definition at line 140 of file class.ilRemoteObjectBase.php.

Referenced by doRead().

140  : void
141  {
142  $this->local_information = $a_info;
143  }
+ Here is the caller graph for this function:

◆ setMID()

ilRemoteObjectBase::setMID ( int  $a_mid)

set mid

Parameters
int$a_midmid

Definition at line 158 of file class.ilRemoteObjectBase.php.

Referenced by doRead(), and updateFromECSContent().

158  : void
159  {
160  $this->mid = $a_mid;
161  }
+ Here is the caller graph for this function:

◆ setOrganization()

ilRemoteObjectBase::setOrganization ( string  $a_organization)

set organization

Definition at line 114 of file class.ilRemoteObjectBase.php.

Referenced by doRead(), and updateFromECSContent().

114  : void
115  {
116  $this->organization = $a_organization;
117  }
+ Here is the caller graph for this function:

◆ setRemoteLink()

ilRemoteObjectBase::setRemoteLink ( string  $a_link)

set remote link

Parameters
string$a_linklink to original object

Definition at line 168 of file class.ilRemoteObjectBase.php.

Referenced by doRead(), and updateFromECSContent().

168  : void
169  {
170  $this->remote_link = $a_link;
171  }
+ Here is the caller graph for this function:

◆ updateCustomFromECSContent()

ilRemoteObjectBase::updateCustomFromECSContent ( ilECSSetting  $a_server,
  $ecs_content 
)
protected

update remote object settings from ecs content

Parameters
ilECSSetting$a_server
object$a_ecs_contentobject with object settings

Definition at line 486 of file class.ilRemoteObjectBase.php.

Referenced by updateFromECSContent().

486  : void
487  {
488  }
+ Here is the caller graph for this function:

◆ updateFromECSContent()

ilRemoteObjectBase::updateFromECSContent ( ilECSSetting  $a_server,
object  $a_ecs_content,
int  $a_owner 
)

update remote object settings from ecs content

Parameters
object$a_ecs_contentobject with object settings

Definition at line 367 of file class.ilRemoteObjectBase.php.

References getECSObjectType(), ilObject\getId(), ilECSCommunityReader\getInstanceByServerId(), ilECSUtils\getMatchableContent(), ilECSSetting\getServerId(), ilECSCategoryMapping\handleUpdate(), ILIAS\Repository\logger(), ilObject\setDescription(), setMID(), setOrganization(), setRemoteLink(), ilObject\setTitle(), ilObject2\update(), and updateCustomFromECSContent().

Referenced by createFromECSEContent().

367  : void
368  {
369  $this->logger->info('updateFromECSContent: ' . print_r($a_ecs_content, true));
370 
371  // Get organisation for owner (ObjectListGUI performance)
372  $organisation = null;
373  if ($a_owner) {
374  $organisation = ilECSCommunityReader::getInstanceByServerId($a_server->getServerId())
375  ->getParticipantNameByMid($a_owner);
376  $this->logger->info('found organisation: ' . $organisation);
377  }
378 
379  $this->setMID($a_owner); // obsolete?
380  $this->setOrganization($organisation);
381  $this->setTitle($a_ecs_content->title);
382  if (!is_null($a_ecs_content->abstract)) {
383  $this->setDescription($a_ecs_content->abstract);
384  }
385  $this->setRemoteLink($a_ecs_content->url);
386 
387  $this->logger->info('updateCustomFromECSContent');
388  $this->updateCustomFromECSContent($a_server, $a_ecs_content);
389 
390  // we are updating late so custom values can be set
391 
392  $this->logger->info('ilObject->update()');
393  $this->update();
394 
395  $matchable_content = ilECSUtils::getMatchableContent(
396  $this->getECSObjectType(),
397  $a_server->getServerId(),
398  $a_ecs_content,
399  $a_owner
400  );
401 
402  // rule-based category mapping
404  $this->getId(),
405  $a_server->getServerId(),
406  $matchable_content
407  );
408  }
setRemoteLink(string $a_link)
set remote link
setOrganization(string $a_organization)
set organization
getServerId()
Get current server id.
updateCustomFromECSContent(ilECSSetting $a_server, $ecs_content)
update remote object settings from ecs content
setTitle(string $title)
getECSObjectType()
Get ECS resource identifier, e.g.
setDescription(string $desc)
static getInstanceByServerId(int $a_server_id)
Get instance by server id.
setMID(int $a_mid)
set mid
static handleUpdate(int $a_obj_id, int $a_server_id, array $a_matchable_content)
Handle update of ecs content and create references.
static getMatchableContent(string $a_resource_id, int $a_server_id, object $a_ecs_content, int $a_owner)
Convert ECS content to rule matchable values.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $auth_hash

string ilRemoteObjectBase::$auth_hash = ''
protected

Definition at line 31 of file class.ilRemoteObjectBase.php.

Referenced by createAuthResource(), and getFullRemoteLink().

◆ $local_information

string ilRemoteObjectBase::$local_information = null
protected

Definition at line 27 of file class.ilRemoteObjectBase.php.

◆ $logger

ilLogger ilRemoteObjectBase::$logger
private

Definition at line 35 of file class.ilRemoteObjectBase.php.

◆ $mid

int ilRemoteObjectBase::$mid = null
protected

Definition at line 30 of file class.ilRemoteObjectBase.php.

Referenced by getMID(), and handleUpdate().

◆ $organization

string ilRemoteObjectBase::$organization = null
protected

Definition at line 29 of file class.ilRemoteObjectBase.php.

Referenced by getOrganization().

◆ $realm_plain

string ilRemoteObjectBase::$realm_plain = ''
protected

Definition at line 33 of file class.ilRemoteObjectBase.php.

Referenced by getRealmPlain().

◆ $remote_link

string ilRemoteObjectBase::$remote_link = null
protected

Definition at line 28 of file class.ilRemoteObjectBase.php.

Referenced by getRemoteLink().

◆ MAIL_SENDER

const ilRemoteObjectBase::MAIL_SENDER = 6

Definition at line 37 of file class.ilRemoteObjectBase.php.

◆ OBJECT_OWNER

const ilRemoteObjectBase::OBJECT_OWNER = 6

Definition at line 38 of file class.ilRemoteObjectBase.php.


The documentation for this class was generated from the following file: