ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
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)
 Constructor. More...
 
 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 ()
 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...
 
 cloneMetaData (ilObject $target_obj)
 Copy meta data. More...
 
 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, int $new_obj_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 ()
 If overwritten this method should return true, there is currently no "abort" handling for cases where "false" is returned. More...
 
 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 28 of file class.ilRemoteObjectBase.php.

Constructor & Destructor Documentation

◆ __construct()

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

Constructor.

Parameters
int$a_idreference_id or object_id
bool$a_referencetreat the id as reference_id (true) or object_id (false)

Reimplemented from ilObject2.

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

44 {
45 global $DIC;
46
47 parent::__construct($a_id, $a_call_by_reference);
48
49 $this->logger = $DIC->logger()->wsrv();
50 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

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

+ Here is the call graph for this function:

Member Function Documentation

◆ beforeCreate()

ilRemoteObjectBase::beforeCreate ( )
protected

If overwritten this method should return true, there is currently no "abort" handling for cases where "false" is returned.

Returns
bool

Reimplemented from ilObject2.

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

89 : bool
90 {
91 $this->setOwner(self::OBJECT_OWNER);
92 return parent::beforeCreate();
93 }
setOwner(int $usr_id)

References ilObject\setOwner().

+ Here is the call graph for this function:

◆ createAuthResource()

ilRemoteObjectBase::createAuthResource ( string  $a_plain_realm)

create authentication resource on ecs server

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

221 {
222 try {
223 $server_id = ilECSImportManager::getInstance()->lookupServerId($this->getId());
224 $import_info = new ilECSImport($server_id, $this->getId());
225
226 $connector = new ilECSConnector(ilECSSetting::getInstanceByServerId($server_id));
227 $auth = new ilECSAuth();
228 $auth->setPid($import_info->getMID());
229 //TODO URL is deprecated
230 $auth->setUrl($this->getRemoteLink());
231 $realm = sha1($a_plain_realm);
232 $this->logger->info(__METHOD__ . ': Using realm ' . $a_plain_realm);
233 $auth->setRealm($realm);
234 $this->logger->info(__METHOD__ . ' Mid is ' . $this->getMID());
235 //TODO remove @
236 $this->auth_hash = $connector->addAuth(json_encode($auth, JSON_THROW_ON_ERROR), $this->getMID());
237 return $this->auth_hash;
238 } catch (ilECSConnectorException $exc) {
239 $this->logger->info(__METHOD__ . ': Caught error from ECS Auth resource: ' . $exc->getMessage());
240 return false;
241 }
242 }
static getInstance()
Get the singleton instance of this ilECSImportManager.
Storage of ECS imported objects.
static getInstanceByServerId(int $a_server_id)
Get singleton instance per server.

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

Referenced by getFullRemoteLink().

+ 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 339 of file class.ilRemoteObjectBase.php.

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

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

+ Here is the call graph for this function:

◆ doCreate()

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

Reimplemented from ilObject2.

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

244 : void
245 {
246 $fields = array(
247 "obj_id" => array("integer", $this->getId()),
248 "local_information" => array("text", ""),
249 "remote_link" => array("text", ""),
250 "mid" => array("integer", 0),
251 "organization" => array("text", "")
252 );
253
254 $this->doCreateCustomFields($fields);
255
256 $this->db->insert($this->getTableName(), $fields);
257 }
getTableName()
Get db table name.
doCreateCustomFields(array &$a_fields)
Add custom fields to db insert.

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

+ Here is the call graph for this function:

◆ doCreateCustomFields()

ilRemoteObjectBase::doCreateCustomFields ( array &  $a_fields)
protected

Add custom fields to db insert.

Reimplemented in ilObjRemoteCourse, ilObjRemoteFile, ilObjRemoteGlossary, ilObjRemoteGroup, ilObjRemoteLearningModule, ilObjRemoteTest, and ilObjRemoteWiki.

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

262 : void
263 {
264 }

Referenced by doCreate().

+ Here is the caller graph for this function:

◆ doDelete()

ilRemoteObjectBase::doDelete ( )
protected

Delete remote object.

Reimplemented from ilObject2.

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

295 : void
296 {
297 //put here your module specific stuff
298 ilECSImportManager::getInstance()->_deleteByObjId($this->getId());
299
300 $query = "DELETE FROM " . $this->getTableName() .
301 " WHERE obj_id = " . $this->db->quote($this->getId(), 'integer') . " ";
302 $this->db->manipulate($query);
303 }

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

+ Here is the call graph for this function:

◆ doRead()

ilRemoteObjectBase::doRead ( )
protected

Reimplemented from ilObject2.

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

305 : void
306 {
307 $query = "SELECT * FROM " . $this->getTableName() .
308 " WHERE obj_id = " . $this->db->quote($this->getId(), 'integer') . " ";
309 $res = $this->db->query($query);
310 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
311 if (!is_null($row->local_information)) {
312 $this->setLocalInformation($row->local_information);
313 }
314 if (!is_null($row->remote_link)) {
315 $this->setRemoteLink($row->remote_link);
316 }
317 $this->setMID((int) $row->mid);
318 if (!is_null($row->organization)) {
319 $this->setOrganization($row->organization);
320 }
321 $this->doReadCustomFields($row);
322 }
323 }
const FETCHMODE_OBJECT
setRemoteLink(string $a_link)
set remote link
setLocalInformation(string $a_info)
set local information
doReadCustomFields(object $a_row)
Read custom fields from db row.
setOrganization(string $a_organization)
set organization
foreach($_POST as $key=> $value) $res

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

+ Here is the call graph for this function:

◆ doReadCustomFields()

ilRemoteObjectBase::doReadCustomFields ( object  $a_row)
protected

Read custom fields from db row.

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

328 : void
329 {
330 }

Referenced by doRead().

+ Here is the caller graph for this function:

◆ doUpdate()

ilRemoteObjectBase::doUpdate ( )
protected

Update remote object.

Reimplemented from ilObject2.

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

269 : void
270 {
271 $fields = array(
272 "local_information" => array("text", $this->getLocalInformation()),
273 "remote_link" => array("text", $this->getRemoteLink()),
274 "mid" => array("integer", $this->getMID()),
275 "organization" => array("text", $this->getOrganization())
276 );
277
278 $this->doUpdateCustomFields($fields);
279
280 $where = array("obj_id" => array("integer", $this->getId()));
281
282 $this->db->update($this->getTableName(), $fields, $where);
283 }
doUpdateCustomFields(array &$a_fields)
Add custom fields to db update.
getOrganization()
get organization
getLocalInformation()
get local information

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

+ Here is the call graph for this function:

◆ doUpdateCustomFields()

ilRemoteObjectBase::doUpdateCustomFields ( array &  $a_fields)
protected

Add custom fields to db update.

Reimplemented in ilObjRemoteCourse, ilObjRemoteFile, ilObjRemoteGlossary, ilObjRemoteGroup, ilObjRemoteLearningModule, ilObjRemoteTest, and ilObjRemoteWiki.

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

288 : void
289 {
290 }

Referenced by doUpdate().

+ 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 669 of file class.ilRemoteObjectBase.php.

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

References ILIAS\Repository\logger().

+ Here is the call graph for this function:

◆ getECSObjectType()

ilRemoteObjectBase::getECSObjectType ( )
abstractprotected

Get ECS resource identifier, e.g.

"/campusconnect/courselinks"

Reimplemented in ilObjRemoteCategory, ilObjRemoteCourse, ilObjRemoteFile, ilObjRemoteGlossary, ilObjRemoteGroup, ilObjRemoteLearningModule, ilObjRemoteTest, and ilObjRemoteWiki.

Referenced by createFromECSEContent(), 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 190 of file class.ilRemoteObjectBase.php.

190 : string
191 {
192 $server_id = ilECSImportManager::getInstance()->lookupServerId($this->getId());
194 $setting = ilECSParticipantSetting::getInstance($server_id, $this->mid);
195 $user = new ilECSUser($this->user);
196 $ecs_user_data = $user->toGET($setting);
197 $this->logger->info(__METHOD__ . ': Using ecs user data ' . $ecs_user_data);
198
199 // check token mechanism enabled
200 $part = new ilECSParticipantSetting($server_id, $this->getMID());
201 if (!$part->isTokenEnabled()) {
202 return $this->getRemoteLink();
203 }
204
205 $auth_hash = $this->createAuthResource($this->getRemoteLink() . $user->toREALM());
206 $ecs_url_hash = 'ecs_hash_url=' . urlencode($server->getServerURI() . '/sys/auths/' . $auth_hash);
207
208 if (strpos($this->getRemoteLink(), '?')) {
209 $link = $this->getRemoteLink() . '&ecs_hash=' . $auth_hash . $ecs_user_data . '&' . $ecs_url_hash;
210 } else {
211 $link = $this->getRemoteLink() . '?ecs_hash=' . $auth_hash . $ecs_user_data . '&' . $ecs_url_hash;
212 }
213 $this->logger->info(__METHOD__ . ': ECS full link: ' . $link);
214 return $link;
215 }
static getInstance(int $a_server_id, int $mid)
Get instance by server id and mid.
Stores relevant user data.
ilObjUser $user
createAuthResource(string $a_plain_realm)
create authentication resource on ecs server
$server
Definition: shib_login.php:28

References $auth_hash, $server, ilObject\$user, createAuthResource(), ilObject\getId(), ilECSImportManager\getInstance(), ilECSParticipantSetting\getInstance(), ilECSSetting\getInstanceByServerId(), getMID(), getRemoteLink(), ILIAS\Repository\logger(), and ILIAS\Repository\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 57 of file class.ilRemoteObjectBase.php.

58 {
59 switch ($a_type) {
61 return new ilObjRemoteCourse();
62
64 return new ilObjRemoteCategory();
65
67 return new ilObjRemoteFile();
68
70 return new ilObjRemoteGlossary();
71
73 return new ilObjRemoteGroup();
74
76 return new ilObjRemoteLearningModule();
77
79 return new ilObjRemoteWiki();
80
82 return new ilObjRemoteTest();
83
84 default:
85 return null;
86 }
87 }
Remote category app class.
Remote course app class.
Remote file app class.
Remote glossary app class.
Remote group app class.
Remote learning module app class.
Remote test app class.
Remote wiki app class.

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

+ Here is the caller graph for this function:

◆ getLocalInformation()

ilRemoteObjectBase::getLocalInformation ( )

get local information

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

133 : string
134 {
135 return $this->local_information ?? '';
136 }

Referenced by doUpdate().

+ Here is the caller graph for this function:

◆ getMID()

ilRemoteObjectBase::getMID ( )

get mid

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

151 : int
152 {
153 return $this->mid;
154 }

References $mid.

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

+ Here is the caller graph for this function:

◆ getOrganization()

ilRemoteObjectBase::getOrganization ( )

get organization

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

125 : string
126 {
127 return $this->organization ?? '';
128 }

Referenced by doUpdate().

+ Here is the caller graph for this function:

◆ getRealmPlain()

ilRemoteObjectBase::getRealmPlain ( )

Get realm plain.

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

109 : string
110 {
111 return $this->realm_plain;
112 }

References $realm_plain.

◆ getRemoteLink()

ilRemoteObjectBase::getRemoteLink ( )

get remote link

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

179 : string
180 {
181 return $this->remote_link;
182 }

References $remote_link.

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

+ Here is the caller graph for this function:

◆ getTableName()

ilRemoteObjectBase::getTableName ( )
abstractprotected

Get db table name.

Reimplemented in ilObjRemoteCategory, ilObjRemoteCourse, ilObjRemoteFile, ilObjRemoteGlossary, ilObjRemoteGroup, ilObjRemoteLearningModule, ilObjRemoteTest, and ilObjRemoteWiki.

Referenced by 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 514 of file class.ilRemoteObjectBase.php.

514 : bool
515 {
516 return $this->handleUpdate($a_server, $a_econtent_id, $a_mids);
517 }
handleUpdate(ilECSSetting $a_server, int $a_econtent_id, array $a_mids)
Handle update event.

◆ handleDelete()

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

Handle delete event.

called by ilTaskScheduler

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

643 : bool
644 {
645 // there is no information about the original mid anymore.
646 // Therefor delete any remote objects with given econtent id
647 $obj_ids = ilECSImportManager::getInstance()->_lookupObjIds($a_server->getServerId(), $a_econtent_id);
648 $this->logger->info(__METHOD__ . ': Received obj_ids ' . print_r($obj_ids, true));
649
650 foreach ($obj_ids as $obj_id) {
651 $references = ilObject::_getAllReferences($obj_id);
652 foreach ($references as $ref_id) {
653 if ($tmp_obj = ilObjectFactory::getInstanceByRefId($ref_id, false)) {
654 $this->logger->info(__METHOD__ . ': Deleting obsolete remote course: ' . $tmp_obj->getTitle());
655 $this->logger->info(print_r($this->tree->getNodeData($ref_id), true));
656 $this->logger->info(print_r($this->tree->getNodeData($tmp_obj->getId()), true));
657 $this->tree->deleteTree($this->tree->getNodeData($ref_id));
658 $tmp_obj->delete();
659 }
660 unset($tmp_obj);
661 }
662 }
663 return true;
664 }
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
static _getAllReferences(int $id)
get all reference ids for object ID

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

+ Here is the call 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 524 of file class.ilRemoteObjectBase.php.

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

References $res, ilLogLevel\ERROR, ilECSImportManager\getInstance(), ilObjectFactory\getInstanceByObjId(), ilECSParticipantSettings\getInstanceByServerId(), ilECSEContentDetails\getInstanceFromServer(), ilECSSetting\getServerId(), ilECSConnector\HTTP_CODE_NOT_FOUND, and ILIAS\Repository\logger().

+ Here is the call 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 415 of file class.ilRemoteObjectBase.php.

415 : void
416 {
417 $this->logger->info("importing metadata from json: " . print_r($a_json, true));
418
420 $values_records = ilAdvancedMDValues::getInstancesForObjectId($this->getId(), $this->getType());
421 foreach ($values_records as $values_record) {
422 // this correctly binds group and definitions
423 $values_record->read();
424 }
425
426 $do_save = false;
427
428 foreach ($a_definition as $id => $type) {
429 if (is_array($type)) {
430 [$type, $target] = $type;
431 } else {
432 $target = $id;
433 }
434
435 $timePlace = null;
436 if ($field = $mappings->getMappingByECSName($a_mapping_mode, $id)) {
437 // find element in records
438 $adv_md_def = null;
439 foreach ($values_records as $values_record) {
440 $adv_md_defs = $values_record->getDefinitions();
441 if (isset($adv_md_defs[$field])) {
442 $adv_md_def = $adv_md_defs[$field];
443 break;
444 }
445 }
446 if (!$adv_md_def) {
447 continue;
448 }
449 if (property_exists($a_json, $target)) {
450 $raw_value = $a_json->{$target};
451 } else {
452 $raw_value = '';
453 }
454
456 if (!is_object($timePlace)) {
457 $timePlace = new ilECSTimePlace();
458 if (is_object($raw_value)) {
459 $timePlace->loadFromJSON($raw_value);
460 }
461 }
462 $raw_value = $timePlace;
463 }
464 if (is_string($raw_value) && $adv_md_def->importFromECS((string) $type, (string) $raw_value, $id)) {
465 $do_save = true;
466 }
467 }
468 }
469
470 if ($do_save) {
471 foreach ($values_records as $values_record) {
472 $additional = array();
473 foreach ($values_record->getADTGroup()->getElements() as $element_id => $element) {
474 if (!$element->isNull()) {
475 $additional[$element_id] = array("disabled" => array("integer", 1));
476 }
477 }
478 $values_record->write($additional);
479 }
480 }
481 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static getInstancesForObjectId(int $a_obj_id, ?string $a_obj_type=null, string $a_sub_type="-", int $a_sub_id=0)
static getInstanceByServerId(int $a_server_id)
Get singleton instance.
Representation of ECS EContent Time Place.
const TYPE_TIMEPLACE
string $type

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

Referenced by ilObjRemoteCourse\updateCustomFromECSContent().

+ 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 498 of file class.ilRemoteObjectBase.php.

498 : bool
499 {
500 if (ilECSExportManager::getInstance()->_isRemote(
501 ilECSImportManager::getInstance()->lookupServerId($this->getId()),
502 (int) ilECSImportManager::getInstance()->_lookupEContentId($this->getId())
503 )) {
504 return false;
505 }
506 return true;
507 }
static getInstance()
Get the singelton instance of this ilECSExportManager.

References ILIAS\Survey\Mode\getId(), ilECSExportManager\getInstance(), and ilECSImportManager\getInstance().

+ Here is the call graph for this function:

◆ sendNewContentNotification()

ilRemoteObjectBase::sendNewContentNotification (   $a_server_id)
protected

send notifications about new EContent

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

607 : void
608 {
610 if (!count($settings->getEContentRecipients())) {
611 return;
612 }
613
615 $lang->loadLanguageModule('ecs');
616
617 $mail = new ilMail(self::MAIL_SENDER);
618 $message = $lang->txt('ecs_' . $this->getType() . '_created_body_a') . "\n\n";
619 $message .= $lang->txt('title') . ': ' . $this->getTitle() . "\n";
620 if ($desc = ($this->getDescription() !== '')) {
621 $message .= $lang->txt('desc') . ': ' . $desc . "\n";
622 }
623
624 $href = ilLink::_getStaticLink($this->getRefId(), $this->getType(), true);
625 $message .= $lang->txt("perma_link") . ': ' . $href . "\n\n";
627
628 $mail->enqueue(
629 $settings->getEContentRecipientsAsString(),
630 '',
631 '',
632 $lang->txt('ecs_new_econtent_subject'),
633 $message,
634 MailAttachments::empty()
635 );
636 }
$settings
Definition: index.php:44
static _getLanguage(string $a_lang_key='')
Get language object.
static _getAutoGeneratedMessageString(?ilLanguage $lang=null)
string $desc

References $message, $settings, ilMail\_getAutoGeneratedMessageString(), ilLanguageFactory\_getLanguage(), ilLink\_getStaticLink(), ilECSSetting\getInstanceByServerId(), and ILIAS\GlobalScreen\Scope\Footer\Factory\getTitle().

+ Here is the call graph for this function:

◆ setLocalInformation()

ilRemoteObjectBase::setLocalInformation ( string  $a_info)

set local information

Parameters
string$a_info

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

143 : void
144 {
145 $this->local_information = $a_info;
146 }

Referenced by doRead().

+ Here is the caller graph for this function:

◆ setMID()

ilRemoteObjectBase::setMID ( int  $a_mid)

set mid

Parameters
int$a_midmid

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

161 : void
162 {
163 $this->mid = $a_mid;
164 }

Referenced by doRead(), and updateFromECSContent().

+ Here is the caller graph for this function:

◆ setOrganization()

ilRemoteObjectBase::setOrganization ( string  $a_organization)

set organization

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

117 : void
118 {
119 $this->organization = $a_organization;
120 }

Referenced by doRead(), and updateFromECSContent().

+ 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 171 of file class.ilRemoteObjectBase.php.

171 : void
172 {
173 $this->remote_link = $a_link;
174 }

Referenced by doRead(), and updateFromECSContent().

+ 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

Reimplemented in ilObjRemoteCourse, ilObjRemoteGroup, ilObjRemoteLearningModule, ilObjRemoteTest, ilObjRemoteWiki, ilObjRemoteFile, and ilObjRemoteGlossary.

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

489 : void
490 {
491 }

Referenced by updateFromECSContent().

+ 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 370 of file class.ilRemoteObjectBase.php.

370 : void
371 {
372 $this->logger->info('updateFromECSContent: ' . print_r($a_ecs_content, true));
373
374 // Get organisation for owner (ObjectListGUI performance)
375 $organisation = null;
376 if ($a_owner) {
377 $organisation = ilECSCommunityReader::getInstanceByServerId($a_server->getServerId())
378 ->getParticipantNameByMid($a_owner);
379 $this->logger->info('found organisation: ' . $organisation);
380 }
381
382 $this->setMID($a_owner); // obsolete?
383 $this->setOrganization($organisation);
384 $this->setTitle($a_ecs_content->title);
385 $this->setDescription($a_ecs_content->abstract ?? '');
386 $this->setRemoteLink($a_ecs_content->url);
387
388 $this->logger->info('updateCustomFromECSContent');
389 $this->updateCustomFromECSContent($a_server, $a_ecs_content);
390
391 // we are updating late so custom values can be set
392
393 $this->logger->info('ilObject->update()');
394 $this->update();
395
396 $matchable_content = ilECSUtils::getMatchableContent(
397 $this->getECSObjectType(),
398 $a_server->getServerId(),
399 $a_ecs_content,
400 $a_owner
401 );
402
403 // rule-based category mapping
405 $this->getId(),
406 $a_server->getServerId(),
407 $matchable_content
408 );
409 }
static handleUpdate(int $a_obj_id, int $a_server_id, array $a_matchable_content)
Handle update of ecs content and create references.
static getInstanceByServerId(int $a_server_id)
Get instance by server id.
setTitle(string $title)
setDescription(string $description)
updateCustomFromECSContent(ilECSSetting $a_server, $ecs_content)
update remote object settings from ecs content

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

+ 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 34 of file class.ilRemoteObjectBase.php.

Referenced by createAuthResource(), and getFullRemoteLink().

◆ $local_information

string ilRemoteObjectBase::$local_information = null
protected

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

◆ $logger

ilLogger ilRemoteObjectBase::$logger
private

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

◆ $mid

int ilRemoteObjectBase::$mid = null
protected

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

Referenced by getMID().

◆ $organization

string ilRemoteObjectBase::$organization = null
protected

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

◆ $realm_plain

string ilRemoteObjectBase::$realm_plain = ''
protected

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

Referenced by getRealmPlain().

◆ $remote_link

string ilRemoteObjectBase::$remote_link = null
protected

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

Referenced by getRemoteLink().

◆ MAIL_SENDER

const ilRemoteObjectBase::MAIL_SENDER = 6

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

◆ OBJECT_OWNER

const ilRemoteObjectBase::OBJECT_OWNER = 6

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


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