aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2010-05-03 09:56:22 +0000
committerplegall <plg@piwigo.org>2010-05-03 09:56:22 +0000
commit89384aa6b1b8808ec8ceda6b9673236383c94cfe (patch)
tree1d9ad0935a210e677041bb575a58dcfd651aa2f8
parent2de8344c97468ea9a833f470885243fc94ee7742 (diff)
improvement: use the same code to check upload readiness in admin>photos>add
screen and in web API. bug fixed: UploadForm partly takes into account the configurable upload directory (must be propagated everywhere in the UploadForm process) git-svn-id: http://piwigo.org/svn/trunk@6051 68402e56-0260-453c-a942-63ccdbb3a9ee
-rw-r--r--admin/photos_add_direct.php35
-rw-r--r--include/ws_functions.inc.php29
2 files changed, 21 insertions, 43 deletions
diff --git a/admin/photos_add_direct.php b/admin/photos_add_direct.php
index 31cfd1e4f..6f3991732 100644
--- a/admin/photos_add_direct.php
+++ b/admin/photos_add_direct.php
@@ -444,39 +444,10 @@ $template->assign(
$setup_errors = array();
-$upload_base_dir = 'upload';
-$upload_dir = PHPWG_ROOT_PATH.$upload_base_dir;
-
-if (!is_dir($upload_dir))
-{
- if (!is_writable(PHPWG_ROOT_PATH))
- {
- array_push(
- $setup_errors,
- sprintf(
- l10n('Create the "%s" directory at the root of your Piwigo installation'),
- $upload_base_dir
- )
- );
- }
-}
-else
+$error_message = ready_for_upload_message();
+if (!empty($error_message))
{
- if (!is_writable($upload_dir))
- {
- @chmod($upload_dir, 0777);
-
- if (!is_writable($upload_dir))
- {
- array_push(
- $setup_errors,
- sprintf(
- l10n('Give write access (chmod 777) to "%s" directory at the root of your Piwigo installation'),
- $upload_base_dir
- )
- );
- }
- }
+ array_push($setup_errors, $error_message);
}
$template->assign(
diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php
index 87cb72393..162cd4371 100644
--- a/include/ws_functions.inc.php
+++ b/include/ws_functions.inc.php
@@ -2136,16 +2136,28 @@ function ws_images_checkUpload($params, &$service)
return new PwgError(401, 'Access denied');
}
- $relative_dir = preg_replace('#^'.PHPWG_ROOT_PATH.'#', '', $conf['upload_dir']);
-
- $ret['message'] = null;
+ $ret['message'] = ready_for_upload_message();
$ret['ready_for_upload'] = true;
+ if (!empty($ret['message']))
+ {
+ $ret['ready_for_upload'] = false;
+ }
+
+ return $ret;
+}
+
+function ready_for_upload_message()
+{
+ global $conf;
+
+ $relative_dir = preg_replace('#^'.PHPWG_ROOT_PATH.'#', '', $conf['upload_dir']);
+
if (!is_dir($conf['upload_dir']))
{
if (!is_writable(dirname($conf['upload_dir'])))
{
- $ret['message'] = sprintf(
+ return sprintf(
l10n('Create the "%s" directory at the root of your Piwigo installation'),
$relative_dir
);
@@ -2159,7 +2171,7 @@ function ws_images_checkUpload($params, &$service)
if (!is_writable($conf['upload_dir']))
{
- $ret['message'] = sprintf(
+ return sprintf(
l10n('Give write access (chmod 777) to "%s" directory at the root of your Piwigo installation'),
$relative_dir
);
@@ -2167,11 +2179,6 @@ function ws_images_checkUpload($params, &$service)
}
}
- if (!empty($ret['message']))
- {
- $ret['ready_for_upload'] = false;
- }
-
- return $ret;
+ return null;
}
?>