0
0
Fork 0
mirror of https://github.com/verdigado/organization_folders.git synced 2024-11-24 05:30:27 +01:00
organization_folders/lib/Db/FolderResource.php

76 lines
2.3 KiB
PHP
Raw Permalink Normal View History

2024-10-15 17:10:48 +02:00
<?php
namespace OCA\OrganizationFolders\Db;
class FolderResource extends Resource {
protected $membersAclPermission;
protected $managersAclPermission;
protected $inheritedAclPermission;
2024-10-31 17:51:20 +01:00
protected $fileId;
2024-10-15 17:10:48 +02:00
public function __construct() {
parent::__construct();
$this->addType('membersAclPermission','integer');
$this->addType('managersAclPermission','integer');
$this->addType('inheritedAclPermission','integer');
2024-10-31 17:51:20 +01:00
$this->addType('fileId','integer');
2024-10-15 17:10:48 +02:00
}
public static function fromRow(array $row): static {
$instance = new static();
$instance->setId($row["id"]);
$instance->setParentResource($row["parent_resource"]);
$instance->setOrganizationFolderId($row["organization_folder_id"]);
2024-10-15 17:10:48 +02:00
$instance->setName($row["name"]);
$instance->setActive($row["active"]);
$instance->setInheritManagers($row["inherit_managers"]);
2024-10-15 17:10:48 +02:00
$instance->setLastUpdatedTimestamp($row["last_updated_timestamp"]);
$instance->setMembersAclPermission($row["members_acl_permission"]);
$instance->setManagersAclPermission($row["managers_acl_permission"]);
$instance->setInheritedAclPermission($row["inherited_acl_permission"]);
2024-10-31 17:51:20 +01:00
$instance->setFileId($row["file_id"]);
2024-10-15 17:10:48 +02:00
$instance->resetUpdatedFields();
return $instance;
}
public function jsonSerialize(): array {
return [
'id' => $this->id,
'parentResource' => $this->parentResource,
'organizationFolderId' => $this->organizationFolderId,
2024-10-15 17:10:48 +02:00
'type' => "folder",
'name' => $this->name,
'active' => $this->active,
'inheritManagers' => $this->inheritManagers,
2024-10-15 17:10:48 +02:00
'lastUpdatedTimestamp' => $this->lastUpdatedTimestamp,
'membersAclPermission' => $this->membersAclPermission,
'managersAclPermission' => $this->managersAclPermission,
'inheritedAclPermission' => $this->inheritedAclPermission,
2024-10-31 17:51:20 +01:00
'fileId' => $this->fileId,
2024-10-15 17:10:48 +02:00
];
}
2024-10-30 04:45:56 +01:00
2024-10-31 17:29:15 +01:00
public function tableSerialize(?array $params = null): array {
2024-10-30 04:45:56 +01:00
return [
'Id' => $this->id,
'Name' => $this->name,
'Type' => "Folder",
'Active' => ((bool)$this->active) ? 'yes' : 'no',
'Inherit Managers' => ((bool)$this->inheritManagers) ? 'yes' : 'no',
2024-10-30 04:45:56 +01:00
'Last Updated' => $this->lastUpdatedTimestamp,
'Members ACL Permission' => $this->membersAclPermission,
'Managers ACL Permission' => $this->managersAclPermission,
'Inherited ACL Permission' => $this->inheritedAclPermission,
];
}
public function getType(): string {
return "folder";
}
2024-10-15 17:10:48 +02:00
}