Commit 78852a65 authored by Patrick Barroca's avatar Patrick Barroca 😁
Browse files

Merge branch...

Merge branch 'hotline#104609_charger_un_fichier_unimarc_directement_dans_cosmogramme' into 'hotline'

hotline #104609 : add customizable folders to display in filemanager

See merge request !3383
parents 604ed99b 99a4ea44
Pipeline #9268 passed with stage
in 50 minutes and 11 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 {
['value' => '90'])->bePrivate(),
'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 {
public static function getRoots() {
return array_filter([static::getUserfiles(),
static::getSkins()]);
$roots = [static::getUserfiles(),
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 {
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 {
public function setUp() {
parent::setUp();
......
Markdown is supported
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