Skip to content

Commit

Permalink
Merge pull request Studio-42#426 from boekkooi/patch-1
Browse files Browse the repository at this point in the history
Add closure support for `accessControl`
  • Loading branch information
dio-el-claire committed Feb 27, 2013
2 parents 24eee26 + a8614ac commit 4b8941a
Showing 1 changed file with 5 additions and 28 deletions.
33 changes: 5 additions & 28 deletions php/elFinderVolumeDriver.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -610,16 +610,8 @@ public function mount(array $opts) {
}
}

if (!empty($this->options['accessControl'])) {
if (is_string($this->options['accessControl'])
&& function_exists($this->options['accessControl'])) {
$this->access = $this->options['accessControl'];
} elseif (is_array($this->options['accessControl'])
&& count($this->options['accessControl']) > 1
&& is_object($this->options['accessControl'][0])
&& method_exists($this->options['accessControl'][0], $this->options['accessControl'][1])) {
$this->access = array($this->options['accessControl'][0], $this->options['accessControl'][1]);
}
if (!empty($this->options['accessControl']) && is_callable($this->options['accessControl'])) {
$this->access = $this->options['accessControl'];
}

$this->today = mktime(0,0,0, date('m'), date('d'), date('Y'));
Expand Down Expand Up @@ -1961,15 +1953,8 @@ protected function attr($path, $name, $val=null) {
$perm = null;

if ($this->access) {
if (is_array($this->access)) {
$obj = $this->access[0];
$method = $this->access[1];
$perm = $obj->{$method}($name, $path, $this->options['accessControlData'], $this);
} else {
$func = $this->access;
$perm = $func($name, $path, $this->options['accessControlData'], $this);
}

$perm = call_user_func($this->access, $name, $path, $this->options['accessControlData'], $this);

if ($perm !== null) {
return !!$perm;
}
Expand Down Expand Up @@ -2007,15 +1992,7 @@ protected function allowCreate($dir, $name) {
$perm = null;

if ($this->access) {
if (is_array($this->access)) {
$obj = $this->access[0];
$method = $this->access[1];
$perm = $obj->{$method}('write', $path, $this->options['accessControlData'], $this);
} else {
$func = $this->access;
$perm = $func('write', $path, $this->options['accessControlData'], $this);
}

$perm = call_user_func('write', $path, $this->options['accessControlData'], $this);
if ($perm !== null) {
return !!$perm;
}
Expand Down

0 comments on commit 4b8941a

Please sign in to comment.