2024-06-19 16:47:56 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Collections;
|
|
|
|
|
|
|
|
use Principal\RolesBackend;
|
|
|
|
use Sabre\DAV\Collection;
|
|
|
|
use Sabre\DAV\FSExt\Directory as SabreDirectory;
|
|
|
|
|
|
|
|
class RolesCollection extends Collection {
|
|
|
|
|
|
|
|
private RolesBackend $principalBackend;
|
2024-06-20 01:29:02 +02:00
|
|
|
private string $dataPath;
|
2024-06-19 16:47:56 +02:00
|
|
|
|
2024-06-20 01:29:02 +02:00
|
|
|
public function __construct(RolesBackend $principal_backend, string $dataPath)
|
2024-06-19 16:47:56 +02:00
|
|
|
{
|
2024-06-20 01:29:02 +02:00
|
|
|
$this->dataPath = $dataPath;
|
2024-06-19 16:47:56 +02:00
|
|
|
$this->principalBackend = $principal_backend;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getChildren() : array {
|
2024-06-20 01:29:02 +02:00
|
|
|
$path = $this->dataPath;
|
2024-06-19 16:47:56 +02:00
|
|
|
$dirs = [];
|
|
|
|
foreach ($this->principalBackend->roles as $role) {
|
2024-06-20 01:29:02 +02:00
|
|
|
if (!is_dir($path . '/groups/' . $role)){
|
|
|
|
mkdir($path . '/groups/' . $role, 0777, true);
|
2024-06-19 16:47:56 +02:00
|
|
|
}
|
2024-06-20 01:29:02 +02:00
|
|
|
$dirs[] = new SabreDirectory($path . '/groups/' . $role, $role);
|
2024-06-19 16:47:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return $dirs;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getName() : string
|
|
|
|
{
|
|
|
|
return "Groups";
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|