ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ILIAS\WOPI\Handler\GetFileInfoResponse Class Reference
+ Inheritance diagram for ILIAS\WOPI\Handler\GetFileInfoResponse:
+ Collaboration diagram for ILIAS\WOPI\Handler\GetFileInfoResponse:

Public Member Functions

 __construct (Revision $revision, int $current_user_id, bool $editable=false, ?bool $user_can_write=null)
 $editable describes this session - the file was opened through an edit action and may be written back. More...
 
- Public Member Functions inherited from ILIAS\WOPI\Handler\Response
 __construct (private array $data)
 
 jsonSerialize ()
 

Additional Inherited Members

- Protected Attributes inherited from ILIAS\WOPI\Handler\Response
const BASE_FILE_NAME = 'BaseFileName'
 
const VERSION = 'Version'
 
const OWNER_ID = 'OwnerId'
 
const USER_ID = 'UserId'
 
const SIZE = 'Size'
 
const SUPPORTS_CONTAINERS = 'SupportsContainers'
 
const SUPPORTS_DELETE_FILE = 'SupportsDeleteFile'
 
const SUPPORTS_UPDATE = 'SupportsUpdate'
 
const READ_ONLY = 'ReadOnly'
 
const LAST_MODIFIED_TIME = 'LastModifiedTime'
 
const USER_CAN_ATTEND = 'UserCanAttend'
 
const USER_FRIENDLY_NAME = 'UserFriendlyName'
 
const USER_CAN_WRITE = 'UserCanWrite'
 
const RESTRICTED_WEB_VIEW_ONLY = 'RestrictedWebViewOnly'
 
const USER_CAN_NOT_WRITE_RELATIVE = 'UserCanNotWriteRelative'
 
const POST_MESSAGE_ORIGIN = 'PostMessageOrigin'
 
const CLOSE_BUTTON_CLOSES_WINDOW = 'CloseButtonClosesWindow'
 
const CLOSE_URL = 'CloseUrl'
 
const EDIT_MODE_POST_MESSAGE = 'EditModePostMessage'
 
const EDIT_NOTIFICATION_POST_MESSAGE = 'EditNotificationPostMessage'
 
const CLOSE_POST_MESSAGE = 'ClosePostMessage'
 
const SUPPORTS_LOCKS = 'SupportsLocks'
 
const SUPPORTS_GET_LOCK = 'SupportsGetLock'
 
const SUPPORTS_EXTENDED_LOCK_LENGTH = 'SupportsExtendedLockLength'
 
const USER_CAN_RENAME = 'UserCanRename'
 

Detailed Description

Author
Fabian Schmid fabia.nosp@m.n@sr.nosp@m..solu.nosp@m.tion.nosp@m.s

Definition at line 29 of file GetFileInfoResponse.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\WOPI\Handler\GetFileInfoResponse::__construct ( Revision  $revision,
int  $current_user_id,
bool  $editable = false,
?bool  $user_can_write = null 
)

$editable describes this session - the file was opened through an edit action and may be written back.

$user_can_write describes the user - they hold the permission to edit this file, no matter which action they launched just now. Keeping the two apart is what this response is about:

  • ReadOnly and SupportsUpdate follow the session, so a viewer stays a viewer.
  • UserCanWrite follows the permission. WOPI clients explain a read-only session with it: OnlyOffice, for one, opens its viewer with "forcedViewMode" and tells the user the file is locked or their rights do not allow editing, which is plainly wrong for someone who may edit the file and simply opened the content tab.

Two properties are deliberately not part of the response:

  • RestrictedWebViewOnly asks the client to restrict what the user may do with the file, and what that means is up to the client. It describes a restriction on the file, not the fact that this session opened a viewer.
  • UserCanAttend is about the permission to view a broadcast of the file and has nothing to do with editing.

Both used to be derived from $editable, which only says which WOPI action was launched. See https://mantis.ilias.de/view.php?id=48246

Definition at line 54 of file GetFileInfoResponse.php.

59 {
60 $user_can_write ??= $editable;
61 $URI = new URI(ILIAS_HTTP_PATH);
62 $origin = $URI->getSchema() . '://' . $URI->getHost();
63 $lookup_name = \ilObjUser::_lookupName($current_user_id);
64
65 $title = preg_replace('/\.[^.]*$/', '', $revision->getTitle())
66 . '.' . $revision->getInformation()->getSuffix();
67
69 self::BASE_FILE_NAME => $title,
70 self::VERSION => (string) $revision->getVersionNumber(),
71 // the WOPI specification asks for strings
72 self::OWNER_ID => (string) $revision->getOwnerId(),
73 self::USER_ID => (string) $current_user_id,
74 self::SIZE => $revision->getInformation()->getSize(),
75 self::SUPPORTS_CONTAINERS => false,
76 self::SUPPORTS_DELETE_FILE => false,
77 self::SUPPORTS_UPDATE => $editable,
78 self::READ_ONLY => !$editable,
79 self::USER_CAN_WRITE => $user_can_write,
80 self::USER_FRIENDLY_NAME => $lookup_name['firstname'] . ' ' . $lookup_name['lastname'],
81 self::LAST_MODIFIED_TIME => $revision->getInformation()->getCreationDate()->format(DATE_ATOM),
82 self::USER_CAN_NOT_WRITE_RELATIVE => true,
83 self::POST_MESSAGE_ORIGIN => $origin,
84 self::CLOSE_BUTTON_CLOSES_WINDOW => false,
85 // ILIAS has no handler for the UI_Edit message, so it must not announce one:
86 // clients offer a way into edit mode when EditModePostMessage is true, and
87 // that button would do nothing here.
88 self::EDIT_MODE_POST_MESSAGE => false,
89 self::EDIT_NOTIFICATION_POST_MESSAGE => true,
90 // ILIAS closes the client itself (mode info of the editor page, the modal of the
91 // preview) and has no handler for the UI_Close message. Without CloseUrl and
92 // ClosePostMessage clients do not show a close button of their own.
93 self::CLOSE_POST_MESSAGE => false,
94 self::SUPPORTS_LOCKS => true,
95 self::SUPPORTS_GET_LOCK => true,
96 self::SUPPORTS_EXTENDED_LOCK_LENGTH => true,
97 self::USER_CAN_RENAME => false
98 ]);
99 }
static _lookupName(int $a_user_id)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct(), ilObjUser\_lookupName(), ILIAS\ResourceStorage\Revision\Revision\getInformation(), ILIAS\ResourceStorage\Revision\Revision\getOwnerId(), ILIAS\ResourceStorage\Revision\Revision\getTitle(), and ILIAS\ResourceStorage\Revision\Revision\getVersionNumber().

+ Here is the call graph for this function:

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