ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
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...
 

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)

Implements ILIAS\ResourceStorage\Stakeholder\ResourceStakeholder.

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

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

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

Implements ILIAS\ResourceStorage\Stakeholder\ResourceStakeholder.

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

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

88  : ?string
89  {
90  $this->initDB();
91  $r = $this->database->queryF(
92  "SELECT file_id FROM file_data WHERE rid = %s",
93  ['text'],
94  [$identification->serialize()]
95  );
96  $d = $this->database->fetchObject($r);
97  if ($d !== null && property_exists($d, 'file_id') && $d->file_id !== null) {
98  $references = ilObject::_getAllReferences($d->file_id);
99  $ref_id = array_shift($references);
100 
101  return ilLink::_getLink($ref_id, 'file');
102  }
103  return null;
104  }
static _getAllReferences(int $id)
get all reference ids for object ID
$ref_id
Definition: ltiauth.php:66
$r
+ Here is the call graph for this function:

◆ getOwnerOfNewResources()

◆ initDB()

ilObjFileStakeholder::initDB ( )
private

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

References $DIC.

Referenced by getLocationURIForResourceUsage(), and resolveObjectId().

106  : void
107  {
108  global $DIC;
109  $this->database = $DIC->database();
110  }
global $DIC
Definition: shib_login.php:25
+ Here is the caller graph for this function:

◆ resolveObjectId()

ilObjFileStakeholder::resolveObjectId ( ResourceIdentification  $identification)
private

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

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

Referenced by canBeAccessedByCurrentUser(), and resourceHasBeenDeleted().

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

Implements ILIAS\ResourceStorage\Stakeholder\ResourceStakeholder.

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

References resolveObjectId().

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