mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 23:13:15 +00:00
Fix check path
This commit is contained in:
@@ -159,32 +159,29 @@ class Root implements ControllerProviderInterface
|
|||||||
})->bind('admin_display_tree');
|
})->bind('admin_display_tree');
|
||||||
|
|
||||||
$controllers->get('/test-paths/', function (Application $app, Request $request) {
|
$controllers->get('/test-paths/', function (Application $app, Request $request) {
|
||||||
|
if (!$request->isXmlHttpRequest()) {
|
||||||
if (!$request->isXmlHttpRequest() || !array_key_exists($request->getMimeType('json'), array_flip($request->getAcceptableContentTypes()))) {
|
$app->abort(400);
|
||||||
|
}
|
||||||
|
if (!array_key_exists($request->getMimeType('json'), array_flip($request->getAcceptableContentTypes()))) {
|
||||||
$app->abort(400, $app->trans('Bad request format, only JSON is allowed'));
|
$app->abort(400, $app->trans('Bad request format, only JSON is allowed'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 !== count($tests = $request->query->get('tests', []))) {
|
if (0 === count($tests = $request->query->get('tests', []))) {
|
||||||
$app->abort(400, $app->trans('Missing tests parameter'));
|
$app->abort(400, $app->trans('Missing tests parameter'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $path = $request->query->get('path')) {
|
if (null === $path = $request->query->get('path')) {
|
||||||
$app->abort(400, $app->trans('Missing path parameter'));
|
$app->abort(400, $app->trans('Missing path parameter'));
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($tests as $test) {
|
foreach ($tests as $test) {
|
||||||
switch ($test) {
|
switch ($test) {
|
||||||
case 'writeable':
|
case 'writeable':
|
||||||
if (!is_writable($path)) {
|
$result = is_writable($path);
|
||||||
$result = false;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 'readable':
|
case 'readable':
|
||||||
default:
|
default:
|
||||||
if (!is_readable($path)) {
|
$result = is_readable($path);
|
||||||
$result = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
var methods = {
|
var methods = {
|
||||||
init: function (options) {
|
init: function (options) {
|
||||||
var settings = {
|
var settings = {
|
||||||
'url': '/admin/tests/pathurl/path/'
|
'url': '/admin/test-paths/'
|
||||||
};
|
};
|
||||||
return this.each(function () {
|
return this.each(function () {
|
||||||
|
|
||||||
@@ -24,6 +24,8 @@
|
|||||||
var el_loader = $this.nextAll('.loader');
|
var el_loader = $this.nextAll('.loader');
|
||||||
var el_status = $this.nextAll('.status');
|
var el_status = $this.nextAll('.status');
|
||||||
|
|
||||||
|
var tests = [];
|
||||||
|
|
||||||
if ($this.data('ajax_path_test') && typeof $this.data('ajax_path_test').abort == 'function')
|
if ($this.data('ajax_path_test') && typeof $this.data('ajax_path_test').abort == 'function')
|
||||||
$this.data('ajax_path_test').abort();
|
$this.data('ajax_path_test').abort();
|
||||||
|
|
||||||
@@ -36,12 +38,23 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this.hasClass('test_executable')) {
|
||||||
|
tests.push('executable');
|
||||||
|
}
|
||||||
|
if ($this.hasClass('test_writeable')) {
|
||||||
|
tests.push('writeable');
|
||||||
|
}
|
||||||
|
if ($this.hasClass('test_readable')) {
|
||||||
|
tests.push('readable');
|
||||||
|
}
|
||||||
|
|
||||||
var ajax = $.ajax({
|
var ajax = $.ajax({
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: settings.url,
|
url: settings.url,
|
||||||
data: {
|
data: {
|
||||||
path: $this.val()
|
path: $this.val(),
|
||||||
|
tests: tests
|
||||||
},
|
},
|
||||||
beforeSend: function () {
|
beforeSend: function () {
|
||||||
el_loader.css('visibility', 'visible');
|
el_loader.css('visibility', 'visible');
|
||||||
|
Reference in New Issue
Block a user