ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilObjFileStakeholder Class Reference

Class ilObjFileStakeholder. More...

+ Inheritance diagram for ilObjFileStakeholder:
+ Collaboration diagram for ilObjFileStakeholder:

Public Member Functions

 getId ()
 
 getOwnerOfNewResources ()
 
 canBeAccessedByCurrentUser (ResourceIdentification $identification)
 
 resourceHasBeenDeleted (ResourceIdentification $identification)
 
 getLocationURIForResourceUsage (ResourceIdentification $identification)
 
- Public Member Functions inherited from ILIAS\ResourceStorage\Stakeholder\AbstractResourceStakeholder
 __construct (?int $user_id_of_owner=null)
 
 setOwner (int $user_id_of_owner)
 
 getFullyQualifiedClassName ()
 
 isResourceInUse (ResourceIdentification $identification)
 
 canBeAccessedByCurrentUser (ResourceIdentification $identification)
 
 resourceHasBeenDeleted (ResourceIdentification $identification)
 
 getOwnerOfResource (ResourceIdentification $identification)
 
 getConsumerNameForPresentation ()
 
 getLocationURIForResourceUsage (ResourceIdentification $identification)
 
- Public Member Functions inherited from ILIAS\ResourceStorage\Stakeholder\ResourceStakeholder
 __construct ()
 Constructor must not have any parameters. More...
 
 getId ()
 
 getConsumerNameForPresentation ()
 
 getFullyQualifiedClassName ()
 
 canBeAccessedByCurrentUser (ResourceIdentification $identification)
 
 isResourceInUse (ResourceIdentification $identification)
 
 resourceHasBeenDeleted (ResourceIdentification $identification)
 
 getOwnerOfResource (ResourceIdentification $identification)
 
 getOwnerOfNewResources ()
 
 getLocationURIForResourceUsage (ResourceIdentification $identification)
 

Protected Attributes

ilDBInterface $database = null
 
- Protected Attributes inherited from ILIAS\ResourceStorage\Stakeholder\AbstractResourceStakeholder
int $default_owner
 
int $current_user
 

Private Member Functions

 resolveObjectId (ResourceIdentification $identification)
 
 initDB ()
 

Detailed Description

Member Function Documentation

◆ canBeAccessedByCurrentUser()

ilObjFileStakeholder::canBeAccessedByCurrentUser ( ResourceIdentification  $identification)

Reimplemented from ILIAS\ResourceStorage\Stakeholder\AbstractResourceStakeholder.

Definition at line 42 of file class.ilObjFileStakeholder.php.

42 : bool
43 {
44 global $DIC;
45
46 $object_id = $this->resolveObjectId($identification);
47 if ($object_id === null) {
48 return true;
49 }
50
51 $ref_ids = ilObject2::_getAllReferences($object_id);
52 foreach ($ref_ids as $ref_id) {
53 if ($DIC->access()->checkAccessOfUser($this->current_user, 'read', '', $ref_id)) {
54 return true;
55 }
56 }
57
58 return false;
59 }
resolveObjectId(ResourceIdentification $identification)
static _getAllReferences(int $id)
get all reference ids for object ID
$ref_id
Definition: ltiauth.php:66
global $DIC
Definition: shib_login.php:26

References $DIC, $ref_id, ilObject\_getAllReferences(), and resolveObjectId().

+ Here is the call graph for this function:

◆ getId()

ilObjFileStakeholder::getId ( )
Returns
string not longer than 64 characters

Implements ILIAS\ResourceStorage\Stakeholder\ResourceStakeholder.

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

31 : string
32 {
33 return 'file_obj';
34 }

◆ getLocationURIForResourceUsage()

ilObjFileStakeholder::getLocationURIForResourceUsage ( ResourceIdentification  $identification)

Reimplemented from ILIAS\ResourceStorage\Stakeholder\AbstractResourceStakeholder.

Definition at line 90 of file class.ilObjFileStakeholder.php.

90 : ?string
91 {
92 $this->initDB();
93 $r = $this->database->queryF(
94 "SELECT file_id FROM file_data WHERE rid = %s",
95 ['text'],
96 [$identification->serialize()]
97 );
98 $d = $this->database->fetchObject($r);
99 if ($d !== null && property_exists($d, 'file_id') && $d->file_id !== null) {
100 $references = ilObject::_getAllReferences($d->file_id);
101 $ref_id = array_shift($references);
102
103 return ilLink::_getLink($ref_id, 'file');
104 }
105 return null;
106 }

References Vendor\Package\$d, $ref_id, ilObject\_getAllReferences(), ILIAS\Repository\database(), initDB(), and ILIAS\ResourceStorage\Identification\AbstractIdentification\serialize().

+ Here is the call graph for this function:

◆ getOwnerOfNewResources()

◆ initDB()

ilObjFileStakeholder::initDB ( )
private

Definition at line 108 of file class.ilObjFileStakeholder.php.

108 : void
109 {
110 global $DIC;
111 $this->database = $DIC->database();
112 }

References $DIC, and ILIAS\Repository\database().

Referenced by getLocationURIForResourceUsage(), and resolveObjectId().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resolveObjectId()

ilObjFileStakeholder::resolveObjectId ( ResourceIdentification  $identification)
private

Definition at line 61 of file class.ilObjFileStakeholder.php.

61 : ?int
62 {
63 $this->initDB();
64 $r = $this->database->queryF(
65 "SELECT file_id FROM file_data WHERE rid = %s",
66 ['text'],
67 [$identification->serialize()]
68 );
69 $d = $this->database->fetchObject($r);
70
71 return (isset($d->file_id) ? (int) $d->file_id : null);
72 }

References Vendor\Package\$d, ILIAS\Repository\database(), initDB(), and ILIAS\ResourceStorage\Identification\AbstractIdentification\serialize().

Referenced by canBeAccessedByCurrentUser(), and resourceHasBeenDeleted().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resourceHasBeenDeleted()

ilObjFileStakeholder::resourceHasBeenDeleted ( ResourceIdentification  $identification)
Returns
bool true: if the Stakeholder could handle the deletion; false: if the Stakeholder could not handle the deletion of the resource.

Reimplemented from ILIAS\ResourceStorage\Stakeholder\AbstractResourceStakeholder.

Definition at line 75 of file class.ilObjFileStakeholder.php.

75 : bool
76 {
77 $object_id = $this->resolveObjectId($identification);
78 try {
79 $this->database->manipulateF(
80 "UPDATE object_data SET offline = 1 WHERE obj_id = %s",
81 ['text'],
82 [$object_id]
83 );
84 } catch (Throwable) {
85 return false;
86 }
87 return true;
88 }

References ILIAS\Repository\database(), and resolveObjectId().

+ Here is the call graph for this function:

Field Documentation

◆ $database

ilDBInterface ilObjFileStakeholder::$database = null
protected

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


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