Skip to content

Commit

Permalink
load stored net volumes config on init
Browse files Browse the repository at this point in the history
  • Loading branch information
dio-el-claire committed Apr 14, 2012
1 parent 18b22ba commit 67cd614
Showing 1 changed file with 29 additions and 18 deletions.
47 changes: 29 additions & 18 deletions php/elFinder.class.php
Expand Up @@ -166,7 +166,8 @@ class elFinder {
* @author Dmitry (dio) Levashov
**/
public function __construct($opts) {

session_start();

$this->time = $this->utime();
$this->debug = (isset($opts['debug']) && $opts['debug'] ? true : false);

Expand All @@ -179,31 +180,41 @@ public function __construct($opts) {
}
}

if (!isset($opts['roots']) || !is_array($opts['roots'])) {
$opts['roots'] = array();
}

$netVolumes = isset($_SESSION['netVolumes']) && is_array($_SESSION['netVolumes']) ? $_SESSION['netVolumes'] : array();

foreach ($netVolumes as $root) {
if ($root['driver'] && $root['host'] && $root['user']) {
$opts['roots'][] = $root;
}
}

// "mount" volumes
if (isset($opts['roots']) && is_array($opts['roots'])) {

foreach ($opts['roots'] as $i => $o) {
$class = 'elFinderVolume'.(isset($o['driver']) ? $o['driver'] : '');
foreach ($opts['roots'] as $i => $o) {
$class = 'elFinderVolume'.(isset($o['driver']) ? $o['driver'] : '');

if (class_exists($class)) {
$volume = new $class();
if (class_exists($class)) {
$volume = new $class();

if ($volume->mount($o)) {
// unique volume id (ends on "_") - used as prefix to files hash
$id = $volume->id();

$this->volumes[$id] = $volume;
if (!$this->default && $volume->isReadable()) {
$this->default = $this->volumes[$id];
}
} else {
$this->mountErrors[] = 'Driver "'.$class.'" : '.implode(' ', $volume->error());
if ($volume->mount($o)) {
// unique volume id (ends on "_") - used as prefix to files hash
$id = $volume->id();

$this->volumes[$id] = $volume;
if (!$this->default && $volume->isReadable()) {
$this->default = $this->volumes[$id];
}
} else {
$this->mountErrors[] = 'Driver "'.$class.'" does not exists';
$this->mountErrors[] = 'Driver "'.$class.'" : '.implode(' ', $volume->error());
}
} else {
$this->mountErrors[] = 'Driver "'.$class.'" does not exists';
}
}

// if at least one redable volume - ii desu >_<
$this->loaded = !empty($this->default);
}
Expand Down

0 comments on commit 67cd614

Please sign in to comment.