ILIAS  trunk Revision v11.0_alpha-1713-gd8962da2f67
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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
 getObjectProperties ()
 
 flushObjectProperties ()
 
 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 $description)
 
 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 getIconForType (string $type)
 
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
 
LOMServices $lom_services
 
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 = ""
 
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 26 of file class.ilRemoteObjectBase.php.

Constructor & Destructor Documentation

◆ __construct()

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

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

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

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

Member Function Documentation

◆ beforeCreate()

ilRemoteObjectBase::beforeCreate ( )
protected

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

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

87  : bool
88  {
89  $this->setOwner(self::OBJECT_OWNER);
90  return parent::beforeCreate();
91  }
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 218 of file class.ilRemoteObjectBase.php.

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

Referenced by getFullRemoteLink().

219  {
220  try {
221  $server_id = ilECSImportManager::getInstance()->lookupServerId($this->getId());
222  $import_info = new ilECSImport($server_id, $this->getId());
223 
224  $connector = new ilECSConnector(ilECSSetting::getInstanceByServerId($server_id));
225  $auth = new ilECSAuth();
226  $auth->setPid($import_info->getMID());
227  //TODO URL is deprecated
228  $auth->setUrl($this->getRemoteLink());
229  $realm = sha1($a_plain_realm);
230  $this->logger->info(__METHOD__ . ': Using realm ' . $a_plain_realm);
231  $auth->setRealm($realm);
232  $this->logger->info(__METHOD__ . ' Mid is ' . $this->getMID());
233  //TODO remove @
234  $this->auth_hash = $connector->addAuth(json_encode($auth, JSON_THROW_ON_ERROR), $this->getMID());
235  return $this->auth_hash;
236  } catch (ilECSConnectorException $exc) {
237  $this->logger->info(__METHOD__ . ': Caught error from ECS Auth resource: ' . $exc->getMessage());
238  return false;
239  }
240  }
getRemoteLink()
get remote link
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 337 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().

337  : void
338  {
339  $this->create();
340  $this->log->info("Done calling create, creating reference");
341  // won't work for personal workspace
342  $this->createReference();
343  $this->log->info("Done creating reference, setting permissions");
344  $this->setPermissions($a_server->getImportId());
345  $this->log->info("Done setting permissions, putting object in tree");
346 
347  $matchable_content = ilECSUtils::getMatchableContent(
348  $this->getECSObjectType(),
349  $a_server->getServerId(),
350  $a_ecs_content,
351  $a_owner
352  );
353 
355  $a_server->getServerId(),
356  $matchable_content
357  ));
358  $this->log->info("Done putting object in tree, updateing object");
359 
360  $this->updateFromECSContent($a_server, $a_ecs_content, $a_owner);
361  }
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 242 of file class.ilRemoteObjectBase.php.

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

242  : void
243  {
244  $fields = array(
245  "obj_id" => array("integer", $this->getId()),
246  "local_information" => array("text", ""),
247  "remote_link" => array("text", ""),
248  "mid" => array("integer", 0),
249  "organization" => array("text", "")
250  );
251 
252  $this->doCreateCustomFields($fields);
253 
254  $this->db->insert($this->getTableName(), $fields);
255  }
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 260 of file class.ilRemoteObjectBase.php.

Referenced by doCreate().

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

◆ doDelete()

ilRemoteObjectBase::doDelete ( )
protected

Delete remote object.

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

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

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

◆ doRead()

ilRemoteObjectBase::doRead ( )
protected

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

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

303  : void
304  {
305  $query = "SELECT * FROM " . $this->getTableName() .
306  " WHERE obj_id = " . $this->db->quote($this->getId(), 'integer') . " ";
307  $res = $this->db->query($query);
308  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
309  if (!is_null($row->local_information)) {
310  $this->setLocalInformation($row->local_information);
311  }
312  if (!is_null($row->remote_link)) {
313  $this->setRemoteLink($row->remote_link);
314  }
315  $this->setMID((int) $row->mid);
316  if (!is_null($row->organization)) {
317  $this->setOrganization($row->organization);
318  }
319  $this->doReadCustomFields($row);
320  }
321  }
$res
Definition: ltiservices.php:66
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
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 326 of file class.ilRemoteObjectBase.php.

Referenced by doRead().

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

◆ doUpdate()

ilRemoteObjectBase::doUpdate ( )
protected

Update remote object.

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

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

267  : void
268  {
269  $fields = array(
270  "local_information" => array("text", $this->getLocalInformation()),
271  "remote_link" => array("text", $this->getRemoteLink()),
272  "mid" => array("integer", $this->getMID()),
273  "organization" => array("text", $this->getOrganization())
274  );
275 
276  $this->doUpdateCustomFields($fields);
277 
278  $where = array("obj_id" => array("integer", $this->getId()));
279 
280  $this->db->update($this->getTableName(), $fields, $where);
281  }
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 286 of file class.ilRemoteObjectBase.php.

Referenced by doUpdate().

286  : void
287  {
288  }
+ 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 668 of file class.ilRemoteObjectBase.php.

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

668  : array
669  {
670  try {
671  $connector = new ilECSConnector($a_server);
672  $connector->addHeader('X-EcsQueryStrings', $a_sender_only ? 'sender=true' : 'all=true'); // #11301
673  $list = $connector->getResourceList($this->getECSObjectType());
674  if ($list instanceof ilECSResult) {
675  return $list->getResult()->getLinkIds();
676  }
677  } catch (ilECSConnectorException $exc) {
678  $this->logger->error(__METHOD__ . ': Error getting resource list for type . ' . $this->getECSObjectType() . ' with message: ' . $exc->getMessage());
679  }
680 
681  return [];
682  }
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 188 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().

188  : string
189  {
190  $server_id = ilECSImportManager::getInstance()->lookupServerId($this->getId());
192  $setting = ilECSParticipantSetting::getInstance($server_id, $this->mid);
193  $user = new ilECSUser($this->user);
194  $ecs_user_data = $user->toGET($setting);
195  $this->logger->info(__METHOD__ . ': Using ecs user data ' . $ecs_user_data);
196 
197  // check token mechanism enabled
198  $part = new ilECSParticipantSetting($server_id, $this->getMID());
199  if (!$part->isTokenEnabled()) {
200  return $this->getRemoteLink();
201  }
202 
203  $auth_hash = $this->createAuthResource($this->getRemoteLink() . $user->toREALM());
204  $ecs_url_hash = 'ecs_hash_url=' . urlencode($server->getServerURI() . '/sys/auths/' . $auth_hash);
205 
206  if (strpos($this->getRemoteLink(), '?')) {
207  $link = $this->getRemoteLink() . '&ecs_hash=' . $auth_hash . $ecs_user_data . '&' . $ecs_url_hash;
208  } else {
209  $link = $this->getRemoteLink() . '?ecs_hash=' . $auth_hash . $ecs_user_data . '&' . $ecs_url_hash;
210  }
211  $this->logger->info(__METHOD__ . ': ECS full link: ' . $link);
212  return $link;
213  }
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
Definition: shib_login.php:24
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 55 of file class.ilRemoteObjectBase.php.

References null, 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().

56  {
57  switch ($a_type) {
59  return new ilObjRemoteCourse();
60 
62  return new ilObjRemoteCategory();
63 
65  return new ilObjRemoteFile();
66 
68  return new ilObjRemoteGlossary();
69 
71  return new ilObjRemoteGroup();
72 
74  return new ilObjRemoteLearningModule();
75 
77  return new ilObjRemoteWiki();
78 
80  return new ilObjRemoteTest();
81 
82  default:
83  return null;
84  }
85  }
Remote test app class.
Remote file app class.
Remote glossary app class.
Remote learning module app class.
Remote wiki app class.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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 131 of file class.ilRemoteObjectBase.php.

Referenced by doUpdate().

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

◆ getMID()

ilRemoteObjectBase::getMID ( )

get mid

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

References $mid.

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

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

◆ getOrganization()

ilRemoteObjectBase::getOrganization ( )

get organization

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

References $organization.

Referenced by doUpdate().

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

◆ getRealmPlain()

ilRemoteObjectBase::getRealmPlain ( )

Get realm plain.

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

References $realm_plain.

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

◆ getRemoteLink()

ilRemoteObjectBase::getRemoteLink ( )

get remote link

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

References $remote_link.

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

177  : string
178  {
179  return $this->remote_link;
180  }
+ 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 513 of file class.ilRemoteObjectBase.php.

References handleUpdate().

513  : bool
514  {
515  return $this->handleUpdate($a_server, $a_econtent_id, $a_mids);
516  }
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 642 of file class.ilRemoteObjectBase.php.

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

Referenced by handleUpdate().

642  : bool
643  {
644  // there is no information about the original mid anymore.
645  // Therefor delete any remote objects with given econtent id
646  $obj_ids = ilECSImportManager::getInstance()->_lookupObjIds($a_server->getServerId(), $a_econtent_id);
647  $this->logger->info(__METHOD__ . ': Received obj_ids ' . print_r($obj_ids, true));
648 
649  foreach ($obj_ids as $obj_id) {
650  $references = ilObject::_getAllReferences($obj_id);
651  foreach ($references as $ref_id) {
652  if ($tmp_obj = ilObjectFactory::getInstanceByRefId($ref_id, false)) {
653  $this->logger->info(__METHOD__ . ': Deleting obsolete remote course: ' . $tmp_obj->getTitle());
654  $this->logger->info(print_r($this->tree->getNodeData($ref_id), true));
655  $this->logger->info(print_r($this->tree->getNodeData($tmp_obj->getId()), true));
656  $this->tree->deleteTree($this->tree->getNodeData($ref_id));
657  $tmp_obj->delete();
658  }
659  unset($tmp_obj);
660  }
661  }
662  return true;
663  }
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 523 of file class.ilRemoteObjectBase.php.

References $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().

523  : bool
524  {
525  // get content details
527  $a_server->getServerId(),
528  $a_econtent_id,
529  $this->getECSObjectType()
530  );
531  if (!$details instanceof ilECSEContentDetails) {
532  $this->handleDelete($a_server, $a_econtent_id);
533  $this->logger->info(__METHOD__ . ': Handling delete of deprecated remote object. DONE');
534  return true;
535  }
536 
537  $this->logger->info(__METHOD__ . ': Receivers are ' . print_r($details->getReceivers(), true));
538  $this->logger->info(__METHOD__ . ': Senders are ' . print_r($details->getSenders(), true));
539 
540  // check owner (sender mid)
541  if (!ilECSParticipantSettings::getInstanceByServerId($a_server->getServerId())->isImportAllowed($details->getSenders())) {
542  $this->logger->info('Ignoring disabled participant. MID: ' . $details->getOwner());
543  return true;
544  }
545 
546  // new mids
547  foreach (array_intersect($a_mids, $details->getReceivers()) as $mid) {
548  try {
549  $connector = new ilECSConnector($a_server);
550  $res = $connector->getResource($this->getECSObjectType(), $a_econtent_id);
551  if ($res->getHTTPCode() === ilECSConnector::HTTP_CODE_NOT_FOUND) {
552  continue;
553  }
554  $json = $res->getResult();
555  $this->logger->info(__METHOD__ . ': Received json: ' . print_r($json, true));
556  if (!is_object($json)) {
557  // try as array (workaround for invalid content)
558  $json = $json[0];
559  if (!is_object($json)) {
560  throw new ilECSConnectorException('invalid json');
561  }
562  }
563  } catch (ilECSConnectorException $exc) {
564  $this->logger->error(__METHOD__ . ': Error parsing result. ' . $exc->getMessage());
565  $this->logger->logStack(ilLogLevel::ERROR);
566  return false;
567  }
568 
569  // Update existing
570 
571  // Check receiver mid
572  if ($obj_id = ilECSImportManager::getInstance()->_isImported($a_server->getServerId(), (string) $a_econtent_id, $mid)) {
573  $this->logger->info(__METHOD__ . ': Handling update for existing object');
574  $remote = ilObjectFactory::getInstanceByObjId($obj_id, false);
575  if (!$remote instanceof self) {
576  $this->logger->info(__METHOD__ . ': Cannot instantiate remote object. Got object type ' . $remote->getType());
577  continue;
578  }
579  $remote->updateFromECSContent($a_server, $json, $details->getMySender());
580  } else {
581  $this->logger->info(__METHOD__ . ': my sender ' . $details->getMySender() . 'vs mid' . $mid);
582 
583  $this->logger->info(__METHOD__ . ': Handling create for non existing object');
584  $this->createFromECSEContent($a_server, $json, $details->getMySender());
585 
586  // update import status
587  $this->logger->info(__METHOD__ . ': Updating import status');
588  $import = new ilECSImport($a_server->getServerId(), $this->getId());
589  $import->setEContentId((string) $a_econtent_id);
590  // Store receiver mid
591  $import->setMID($mid);
592  $import->save();
593 
594  $this->logger->info(__METHOD__ . ': Sending notification');
595  $this->sendNewContentNotification($a_server->getServerId());
596  }
597  }
598 
599  $this->logger->info(__METHOD__ . ': done');
600  return true;
601  }
$res
Definition: ltiservices.php:66
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.
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 413 of file class.ilRemoteObjectBase.php.

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

Referenced by ilObjRemoteCourse\updateCustomFromECSContent().

413  : void
414  {
415  $this->logger->info("importing metadata from json: " . print_r($a_json, true));
416 
418  $values_records = ilAdvancedMDValues::getInstancesForObjectId($this->getId(), $this->getType());
419  foreach ($values_records as $values_record) {
420  // this correctly binds group and definitions
421  $values_record->read();
422  }
423 
424  $do_save = false;
425 
426  foreach ($a_definition as $id => $type) {
427  if (is_array($type)) {
428  [$type, $target] = $type;
429  } else {
430  $target = $id;
431  }
432 
433  $timePlace = null;
434  if ($field = $mappings->getMappingByECSName($a_mapping_mode, $id)) {
435  // find element in records
436  $adv_md_def = null;
437  foreach ($values_records as $values_record) {
438  $adv_md_defs = $values_record->getDefinitions();
439  if (isset($adv_md_defs[$field])) {
440  $adv_md_def = $adv_md_defs[$field];
441  break;
442  }
443  }
444  if (!$adv_md_def) {
445  continue;
446  }
447  if (property_exists($a_json, $target)){
448  $raw_value = $a_json->{$target};
449  } else {
450  $raw_value = '';
451  }
452 
454  if (!is_object($timePlace)) {
455  $timePlace = new ilECSTimePlace();
456  if (is_object($raw_value)) {
457  $timePlace->loadFromJSON($raw_value);
458  }
459  }
460  $raw_value = $timePlace;
461  }
462 
463  if ($adv_md_def->importFromECS((string) $type, (string) $raw_value, $id)) {
464  $do_save = true;
465  }
466  }
467  }
468 
469  if ($do_save) {
470  foreach ($values_records as $values_record) {
471  $additional = array();
472  foreach ($values_record->getADTGroup()->getElements() as $element_id => $element) {
473  if (!$element->isNull()) {
474  $additional[$element_id] = array("disabled" => array("integer", 1));
475  }
476  }
477  $values_record->write($additional);
478  }
479  }
480  }
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
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ 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 497 of file class.ilRemoteObjectBase.php.

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

497  : bool
498  {
499  if (ilECSExportManager::getInstance()->_isRemote(
500  ilECSImportManager::getInstance()->lookupServerId($this->getId()),
501  (int) ilECSImportManager::getInstance()->_lookupEContentId($this->getId())
502  )) {
503  return false;
504  }
505  return true;
506  }
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 606 of file class.ilRemoteObjectBase.php.

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

Referenced by handleUpdate().

606  : void
607  {
608  $settings = ilECSSetting::getInstanceByServerId($a_server_id);
609  if (!count($settings->getEContentRecipients())) {
610  return;
611  }
612 
614  $lang->loadLanguageModule('ecs');
615 
616  $mail = new ilMail(self::MAIL_SENDER);
617  $message = $lang->txt('ecs_' . $this->getType() . '_created_body_a') . "\n\n";
618  $message .= $lang->txt('title') . ': ' . $this->getTitle() . "\n";
619  if ($desc = ($this->getDescription() !== '')) {
620  $message .= $lang->txt('desc') . ': ' . $desc . "\n";
621  }
622 
623  $href = ilLink::_getStaticLink($this->getRefId(), $this->getType(), true);
624  $message .= $lang->txt("perma_link") . ': ' . $href . "\n\n";
626 
627  $mail->enqueue(
628  $settings->getEContentRecipientsAsString(),
629  '',
630  '',
631  $lang->txt('ecs_new_econtent_subject'),
632  $message,
633  array()
634  );
635  }
string $desc
static _getAutoGeneratedMessageString(?ilLanguage $lang=null)
static getInstanceByServerId(int $a_server_id)
Get singleton instance per server.
static _getLanguage(string $a_lang_key='')
Get language object.
$lang
Definition: xapiexit.php:25
$message
Definition: xapiexit.php:31
+ 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 141 of file class.ilRemoteObjectBase.php.

Referenced by doRead().

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

◆ setMID()

ilRemoteObjectBase::setMID ( int  $a_mid)

set mid

Parameters
int$a_midmid

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

Referenced by doRead(), and updateFromECSContent().

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

◆ setOrganization()

ilRemoteObjectBase::setOrganization ( string  $a_organization)

set organization

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

Referenced by doRead(), and updateFromECSContent().

115  : void
116  {
117  $this->organization = $a_organization;
118  }
+ 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 169 of file class.ilRemoteObjectBase.php.

Referenced by doRead(), and updateFromECSContent().

169  : void
170  {
171  $this->remote_link = $a_link;
172  }
+ 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 488 of file class.ilRemoteObjectBase.php.

Referenced by updateFromECSContent().

488  : void
489  {
490  }
+ 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 368 of file class.ilRemoteObjectBase.php.

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

Referenced by createFromECSEContent().

368  : void
369  {
370  $this->logger->info('updateFromECSContent: ' . print_r($a_ecs_content, true));
371 
372  // Get organisation for owner (ObjectListGUI performance)
373  $organisation = null;
374  if ($a_owner) {
375  $organisation = ilECSCommunityReader::getInstanceByServerId($a_server->getServerId())
376  ->getParticipantNameByMid($a_owner);
377  $this->logger->info('found organisation: ' . $organisation);
378  }
379 
380  $this->setMID($a_owner); // obsolete?
381  $this->setOrganization($organisation);
382  $this->setTitle($a_ecs_content->title);
383  $this->setDescription($a_ecs_content->abstract);
384  $this->setRemoteLink($a_ecs_content->url);
385 
386  $this->logger->info('updateCustomFromECSContent');
387  $this->updateCustomFromECSContent($a_server, $a_ecs_content);
388 
389  // we are updating late so custom values can be set
390 
391  $this->logger->info('ilObject->update()');
392  $this->update();
393 
394  $matchable_content = ilECSUtils::getMatchableContent(
395  $this->getECSObjectType(),
396  $a_server->getServerId(),
397  $a_ecs_content,
398  $a_owner
399  );
400 
401  // rule-based category mapping
403  $this->getId(),
404  $a_server->getServerId(),
405  $matchable_content
406  );
407  }
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.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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.
setDescription(string $description)
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 32 of file class.ilRemoteObjectBase.php.

Referenced by createAuthResource(), and getFullRemoteLink().

◆ $local_information

string ilRemoteObjectBase::$local_information = null
protected

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

◆ $logger

ilLogger ilRemoteObjectBase::$logger
private

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

◆ $mid

int ilRemoteObjectBase::$mid = null
protected

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

Referenced by getMID(), and handleUpdate().

◆ $organization

string ilRemoteObjectBase::$organization = null
protected

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

Referenced by getOrganization().

◆ $realm_plain

string ilRemoteObjectBase::$realm_plain = ''
protected

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

Referenced by getRealmPlain().

◆ $remote_link

string ilRemoteObjectBase::$remote_link = null
protected

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

Referenced by getRemoteLink().

◆ MAIL_SENDER

const ilRemoteObjectBase::MAIL_SENDER = 6

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

◆ OBJECT_OWNER

const ilRemoteObjectBase::OBJECT_OWNER = 6

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


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