Skip to content
Snippets Groups Projects
Commit 99a4ea44 authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

hotline #104609 : add customizable folders to display in filemanager

parent 5180bde1
Branches
Tags
2 merge requests!3384Hotline,!3383hotline #104609 : add customizable folders to display in filemanager
Pipeline #9261 passed with stage
in 49 minutes and 56 seconds
- ticket #104609 : Explorateur de fichiers : Ajout de la possibilité de définir d'autres répertoires à afficher dans l'explorateur
\ No newline at end of file
...@@ -505,7 +505,8 @@ class Class_AdminVarLoader extends Storm_Model_Loader { ...@@ -505,7 +505,8 @@ class Class_AdminVarLoader extends Storm_Model_Loader {
['value' => '90'])->bePrivate(), ['value' => '90'])->bePrivate(),
'IMAGICK_SAMPLING_FACTORS' => Class_AdminVar_Meta::newMultiInput($this->_('Facteur d\'échantillonnage utilisé dans le redimensionnement et la compression des images.'), 'IMAGICK_SAMPLING_FACTORS' => Class_AdminVar_Meta::newMultiInput($this->_('Facteur d\'échantillonnage utilisé dans le redimensionnement et la compression des images.'),
['value' => '2x2;1x1;1x1'])->bePrivate()]; ['value' => '2x2;1x1;1x1'])->bePrivate(),
'FILEMANAGER_OTHER_ROOTS' => Class_AdminVar_Meta::newMultiInput($this->_('Autres répertoires à afficher, uniquement visibles pour les rôles "Super administrateur".'))->bePrivate()];
} }
......
...@@ -79,8 +79,24 @@ class Class_FileManager extends Class_Entity { ...@@ -79,8 +79,24 @@ class Class_FileManager extends Class_Entity {
public static function getRoots() { public static function getRoots() {
return array_filter([static::getUserfiles(), $roots = [static::getUserfiles(),
static::getSkins()]); static::getSkins()];
if (!Class_Users::isCurrentUserSuperAdmin())
return array_filter($roots);
foreach(explode(';', Class_AdminVar::get('FILEMANAGER_OTHER_ROOTS')) as $other)
$roots = static::_injectRootInto($other, $roots);
return array_filter($roots);
}
protected static function _injectRootInto($other, $roots) {
if ($other && ($directory = static::directory($other)))
$roots[] = $directory->setPermissionRegExp('/' . str_replace('/', '\/', $other). '\/(.*)/');
return $roots;
} }
......
...@@ -339,6 +339,57 @@ class FileManagerControllerDispatchTest extends FileManagerControllerTestCase { ...@@ -339,6 +339,57 @@ class FileManagerControllerDispatchTest extends FileManagerControllerTestCase {
class FileManagerControllerIndexWithOtherRootsTest extends FileManagerControllerTestCase {
public function setUp() {
parent::setUp();
Class_AdminVar::set('FILEMANAGER_OTHER_ROOTS', 'cosmogramme/fichiers;non-existing');
Class_FileManager::getFileSystem()
->whenCalled('directoryAt')->with('cosmogramme/fichiers')
->answers((new Class_FileManager)
->setId('cosmogramme/fichiers')
->setParentPath('cosmogramme')
->setPath('cosmogramme/fichier')
->setName('fichiers')
->setDir(true))
->whenCalled('directoryAt')->with('non-existing')
->answers(null)
;
}
/** @test */
public function pageShouldContainsFichiersDirectory() {
$this->dispatch('/admin/file-manager/index');
$this->assertXPathContentContains('//a[contains(@class, "directory")]', 'fichiers');
}
/** @test */
public function pageShouldNotContainsNonExistingDirectory() {
$this->dispatch('/admin/file-manager/index');
$this->assertNotXPathContentContains('//a[contains(@class, "directory")]', 'non-existing');
}
/** @test */
public function withoutSuperAdminPageShouldNotContainsFichiersDirectory() {
$user = $this->fixture('Class_Users',
['id' => 34,
'login' => 'admin',
'password' => 's3cr3t \o/',
'role_level' => ZendAfi_Acl_AdminControllerRoles::ADMIN_PORTAIL,
]);
ZendAfi_Auth::getInstance()->logUser($user);
$this->dispatch('/admin/file-manager/index');
$this->assertNotXPathContentContains('//a[contains(@class, "directory")]', 'fichiers');
}
}
class FileManagerControllerBrowseTest extends FileManagerControllerTestCase { class FileManagerControllerBrowseTest extends FileManagerControllerTestCase {
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment