ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilObjFileStakeholder Class Reference

Class ilObjFileStakeholder. More...

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

Public Member Functions

 __construct (protected int $owner=6)
 ilObjFileStakeholder constructor. More...
 
 getId ()
 
 getOwnerOfNewResources ()
 
 canBeAccessedByCurrentUser (ResourceIdentification $identification)
 
 resourceHasBeenDeleted (ResourceIdentification $identification)
 
 getLocationURIForResourceUsage (ResourceIdentification $identification)
 
- Public Member Functions inherited from ILIAS\ResourceStorage\Stakeholder\AbstractResourceStakeholder
 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
 

Private Member Functions

 resolveObjectId (ResourceIdentification $identification)
 
 initDB ()
 

Private Attributes

int $current_user
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilObjFileStakeholder::__construct ( protected int  $owner = 6)

ilObjFileStakeholder constructor.

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

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

35  {
36  global $DIC;
37  $this->current_user = (int) ($DIC->isDependencyAvailable('user') ? $DIC->user()->getId() : 13);
38  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ canBeAccessedByCurrentUser()

ilObjFileStakeholder::canBeAccessedByCurrentUser ( ResourceIdentification  $identification)

Implements ILIAS\ResourceStorage\Stakeholder\ResourceStakeholder.

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

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

53  : bool
54  {
55  global $DIC;
56 
57  $object_id = $this->resolveObjectId($identification);
58  if ($object_id === null) {
59  return true;
60  }
61 
62  $ref_ids = ilObject2::_getAllReferences($object_id);
63  foreach ($ref_ids as $ref_id) {
64  if ($DIC->access()->checkAccessOfUser($this->current_user, 'read', '', $ref_id)) {
65  return true;
66  }
67  }
68 
69  return false;
70  }
static _getAllReferences(int $id)
get all reference ids for object ID
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
resolveObjectId(ResourceIdentification $identification)
+ Here is the call graph for this function:

◆ getId()

ilObjFileStakeholder::getId ( )

Implements ILIAS\ResourceStorage\Stakeholder\ResourceStakeholder.

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

43  : string
44  {
45  return 'file_obj';
46  }

◆ getLocationURIForResourceUsage()

ilObjFileStakeholder::getLocationURIForResourceUsage ( ResourceIdentification  $identification)

Implements ILIAS\ResourceStorage\Stakeholder\ResourceStakeholder.

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

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

100  : ?string
101  {
102  $this->initDB();
103  $r = $this->database->queryF(
104  "SELECT file_id FROM file_data WHERE rid = %s",
105  ['text'],
106  [$identification->serialize()]
107  );
108  $d = $this->database->fetchObject($r);
109  if ($d !== null && property_exists($d, 'file_id') && $d->file_id !== null) {
110  $references = ilObject::_getAllReferences($d->file_id);
111  $ref_id = array_shift($references);
112 
113  return ilLink::_getLink($ref_id, 'file');
114  }
115  return null;
116  }
static _getAllReferences(int $id)
get all reference ids for object ID
$ref_id
Definition: ltiauth.php:67
$r
+ Here is the call graph for this function:

◆ getOwnerOfNewResources()

ilObjFileStakeholder::getOwnerOfNewResources ( )

Implements ILIAS\ResourceStorage\Stakeholder\ResourceStakeholder.

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

48  : int
49  {
50  return $this->owner;
51  }

◆ initDB()

ilObjFileStakeholder::initDB ( )
private

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

References $DIC.

Referenced by getLocationURIForResourceUsage(), and resolveObjectId().

118  : void
119  {
120  global $DIC;
121  $this->database = $DIC->database();
122  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ resolveObjectId()

ilObjFileStakeholder::resolveObjectId ( ResourceIdentification  $identification)
private

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

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

Referenced by canBeAccessedByCurrentUser(), and resourceHasBeenDeleted().

72  : ?int
73  {
74  $this->initDB();
75  $r = $this->database->queryF(
76  "SELECT file_id FROM file_data WHERE rid = %s",
77  ['text'],
78  [$identification->serialize()]
79  );
80  $d = $this->database->fetchObject($r);
81 
82  return (isset($d->file_id) ? (int) $d->file_id : null);
83  }
$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 85 of file class.ilObjFileStakeholder.php.

References resolveObjectId().

85  : bool
86  {
87  $object_id = $this->resolveObjectId($identification);
88  try {
89  $this->database->manipulateF(
90  "UPDATE object_data SET offline = 1 WHERE obj_id = %s",
91  ['text'],
92  [$object_id]
93  );
94  } catch (Throwable) {
95  return false;
96  }
97  return true;
98  }
resolveObjectId(ResourceIdentification $identification)
+ Here is the call graph for this function:

Field Documentation

◆ $current_user

int ilObjFileStakeholder::$current_user
private

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

◆ $database

ilDBInterface ilObjFileStakeholder::$database = null
protected

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


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