ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 42 of file class.ilObjFileStakeholder.php.

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

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  }
static _getAllReferences(int $id)
get all reference ids for object ID
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$ref_id
Definition: ltiauth.php:65
resolveObjectId(ResourceIdentification $identification)
global $DIC
Definition: shib_login.php:22
+ 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 90 of file class.ilObjFileStakeholder.php.

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

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  }
static _getAllReferences(int $id)
get all reference ids for object ID
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$ref_id
Definition: ltiauth.php:65
$r
+ Here is the call graph for this function:

◆ getOwnerOfNewResources()

◆ initDB()

ilObjFileStakeholder::initDB ( )
private

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

References $DIC.

Referenced by getLocationURIForResourceUsage(), and resolveObjectId().

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

◆ resolveObjectId()

ilObjFileStakeholder::resolveObjectId ( ResourceIdentification  $identification)
private

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

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

Referenced by canBeAccessedByCurrentUser(), and resourceHasBeenDeleted().

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  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$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 75 of file class.ilObjFileStakeholder.php.

References resolveObjectId().

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  }
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: