Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
bug 1635 fixed: new API method pwg.images.checkUpload tells pLoader i…
…f Piwigo

is ready for upload (currently, it checks write access on the upload directory)

git-svn-id: http://piwigo.org/svn/trunk@6049 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
plegall committed May 3, 2010
1 parent e803366 commit 2de8344
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
48 changes: 48 additions & 0 deletions include/ws_functions.inc.php
Expand Up @@ -2126,4 +2126,52 @@ function ws_logfile($string)
FILE_APPEND
);
}

function ws_images_checkUpload($params, &$service)
{
global $conf;

if (!is_admin() or is_adviser())
{
return new PwgError(401, 'Access denied');
}

$relative_dir = preg_replace('#^'.PHPWG_ROOT_PATH.'#', '', $conf['upload_dir']);

$ret['message'] = null;
$ret['ready_for_upload'] = true;

if (!is_dir($conf['upload_dir']))
{
if (!is_writable(dirname($conf['upload_dir'])))
{
$ret['message'] = sprintf(
l10n('Create the "%s" directory at the root of your Piwigo installation'),
$relative_dir
);
}
}
else
{
if (!is_writable($conf['upload_dir']))
{
@chmod($conf['upload_dir'], 0777);

if (!is_writable($conf['upload_dir']))
{
$ret['message'] = sprintf(
l10n('Give write access (chmod 777) to "%s" directory at the root of your Piwigo installation'),
$relative_dir
);
}
}
}

if (!empty($ret['message']))
{
$ret['ready_for_upload'] = false;
}

return $ret;
}
?>
7 changes: 7 additions & 0 deletions ws.php
Expand Up @@ -275,6 +275,13 @@ function ws_addDefaultMethods( $arr )
'check if you have updated version of your files for a given photo, for each requested file type, the answer can be "missing", "equals" or "differs"'
);

$service->addMethod(
'pwg.images.checkUpload',
'ws_images_checkUpload',
null,
'check if Piwigo is ready for upload'
);

$service->addMethod(
'pwg.images.setInfo',
'ws_images_setInfo',
Expand Down

0 comments on commit 2de8344

Please sign in to comment.