mirror of
https://github.com/verdigado/organization_folders.git
synced 2024-11-22 04:38:09 +01:00
reference organization folder by id not groupfolder id (same id, different nomenclature)
This commit is contained in:
parent
efca199c7f
commit
949e1a42d1
5 changed files with 15 additions and 11 deletions
|
@ -19,7 +19,7 @@ class FolderResource extends Resource {
|
||||||
|
|
||||||
$instance->setId($row["id"]);
|
$instance->setId($row["id"]);
|
||||||
$instance->setParentResource($row["parent_resource"]);
|
$instance->setParentResource($row["parent_resource"]);
|
||||||
$instance->setGroupFolderId($row["group_folder_id"]);
|
$instance->setOrganizationFolderId($row["organization_folder_id"]);
|
||||||
$instance->setName($row["name"]);
|
$instance->setName($row["name"]);
|
||||||
$instance->setActive($row["active"]);
|
$instance->setActive($row["active"]);
|
||||||
$instance->setLastUpdatedTimestamp($row["last_updated_timestamp"]);
|
$instance->setLastUpdatedTimestamp($row["last_updated_timestamp"]);
|
||||||
|
@ -36,7 +36,7 @@ class FolderResource extends Resource {
|
||||||
return [
|
return [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'parentResource' => $this->parentResource,
|
'parentResource' => $this->parentResource,
|
||||||
'groupFolderId' => $this->groupFolderId,
|
'organizationFolderId' => $this->organizationFolderId,
|
||||||
'type' => "folder",
|
'type' => "folder",
|
||||||
'name' => $this->name,
|
'name' => $this->name,
|
||||||
'active' => $this->active,
|
'active' => $this->active,
|
||||||
|
|
|
@ -7,14 +7,14 @@ use JsonSerializable;
|
||||||
use OCP\AppFramework\Db\Entity;
|
use OCP\AppFramework\Db\Entity;
|
||||||
|
|
||||||
abstract class Resource extends Entity implements JsonSerializable {
|
abstract class Resource extends Entity implements JsonSerializable {
|
||||||
protected $groupFolderId;
|
protected $organizationFolderId;
|
||||||
protected $parentResource;
|
protected $parentResource;
|
||||||
protected $name;
|
protected $name;
|
||||||
protected $active;
|
protected $active;
|
||||||
protected $lastUpdatedTimestamp;
|
protected $lastUpdatedTimestamp;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->addType('groupFolderId','integer');
|
$this->addType('organizationFolderId','integer');
|
||||||
$this->addType('parentResource','integer');
|
$this->addType('parentResource','integer');
|
||||||
$this->addType('active','bool');
|
$this->addType('active','bool');
|
||||||
$this->addType('lastUpdatedTimestamp','integer');
|
$this->addType('lastUpdatedTimestamp','integer');
|
||||||
|
|
|
@ -52,17 +52,17 @@ class ResourceMapper extends QBMapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $groupfolderId
|
* @param int $organizationFolderId
|
||||||
* @param int $parentResourceId
|
* @param int $parentResourceId
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function findAll(int $groupfolderId, ?int $parentResourceId = null): array {
|
public function findAll(int $organizationFolderId, ?int $parentResourceId = null): array {
|
||||||
/* @var $qb IQueryBuilder */
|
/* @var $qb IQueryBuilder */
|
||||||
$qb = $this->db->getQueryBuilder();
|
$qb = $this->db->getQueryBuilder();
|
||||||
|
|
||||||
$qb->select('resource.*', 'folder.members_acl_permission', 'folder.managers_acl_permission', 'folder.inherited_acl_permission')
|
$qb->select('resource.*', 'folder.members_acl_permission', 'folder.managers_acl_permission', 'folder.inherited_acl_permission')
|
||||||
->from(self::RESOURCES_TABLE, "resource")
|
->from(self::RESOURCES_TABLE, "resource")
|
||||||
->where($qb->expr()->eq('group_folder_id', $qb->createNamedParameter($groupfolderId, IQueryBuilder::PARAM_INT)));
|
->where($qb->expr()->eq('organization_folder_id', $qb->createNamedParameter($organizationFolderId, IQueryBuilder::PARAM_INT)));
|
||||||
|
|
||||||
if(is_null($parentResourceId)) {
|
if(is_null($parentResourceId)) {
|
||||||
$qb->andWhere($qb->expr()->isNull('parent_resource'));
|
$qb->andWhere($qb->expr()->isNull('parent_resource'));
|
||||||
|
|
|
@ -34,7 +34,7 @@ class Version000000Date20241014120000 extends SimpleMigrationStep {
|
||||||
$table->addColumn('parent_resource', Types::INTEGER, [
|
$table->addColumn('parent_resource', Types::INTEGER, [
|
||||||
'notnull' => false,
|
'notnull' => false,
|
||||||
]);
|
]);
|
||||||
$table->addColumn('group_folder_id', Types::BIGINT, [
|
$table->addColumn('organization_folder_id', Types::BIGINT, [
|
||||||
'length' => 20,
|
'length' => 20,
|
||||||
'notnull' => true,
|
'notnull' => true,
|
||||||
]);
|
]);
|
||||||
|
@ -62,10 +62,14 @@ class Version000000Date20241014120000 extends SimpleMigrationStep {
|
||||||
'organizationfolders_resources_parent_resource_id_fk');
|
'organizationfolders_resources_parent_resource_id_fk');
|
||||||
$table->addForeignKeyConstraint(
|
$table->addForeignKeyConstraint(
|
||||||
$schema->getTable(self::GROUP_FOLDERS_TABLE),
|
$schema->getTable(self::GROUP_FOLDERS_TABLE),
|
||||||
['group_folder_id'],
|
['organization_folder_id'],
|
||||||
['folder_id'],
|
['folder_id'],
|
||||||
['onDelete' => 'CASCADE'],
|
['onDelete' => 'CASCADE'],
|
||||||
'organizationfolders_resources_group_folder_id_fk');
|
'organizationfolders_resources_organization_folder_id_fk');
|
||||||
|
|
||||||
|
// WARNING: CONSTRAINT CURRENTLY DOES NOT WORK FOR TOP LEVEL RESOURCES, AS ROWS WITH A NULL IN ONE OF THE UNIQUE COLUMNS WILL NOT BE CHECKED BY THIS
|
||||||
|
// TODO: use NULLS NOT DISTINCT (postgres supported only)
|
||||||
|
$table->addUniqueConstraint(['organization_folder_id', 'parent_resource', 'name'], "organizationfolders_resources_name_unique");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$schema->hasTable(self::FOLDER_RESOURCES_TABLE)) {
|
if (!$schema->hasTable(self::FOLDER_RESOURCES_TABLE)) {
|
||||||
|
|
|
@ -39,7 +39,7 @@ class ResourceService {
|
||||||
/* Use named arguments to call this function */
|
/* Use named arguments to call this function */
|
||||||
public function create(
|
public function create(
|
||||||
string $type,
|
string $type,
|
||||||
int $groupFolderId,
|
int $organizationFolderId,
|
||||||
?int $parentResource = null,
|
?int $parentResource = null,
|
||||||
bool $active = true,
|
bool $active = true,
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue