Ignore:
Timestamp:
May 3, 2010, 11:56:22 AM (14 years ago)
Author:
plg
Message:

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)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/ws_functions.inc.php

    r6049 r6051  
    21372137  }
    21382138
    2139   $relative_dir = preg_replace('#^'.PHPWG_ROOT_PATH.'#', '', $conf['upload_dir']);
    2140 
    2141   $ret['message'] = null;
     2139  $ret['message'] = ready_for_upload_message();
    21422140  $ret['ready_for_upload'] = true;
    21432141 
     2142  if (!empty($ret['message']))
     2143  {
     2144    $ret['ready_for_upload'] = false;
     2145  }
     2146 
     2147  return $ret;
     2148}
     2149
     2150function ready_for_upload_message()
     2151{
     2152  global $conf;
     2153
     2154  $relative_dir = preg_replace('#^'.PHPWG_ROOT_PATH.'#', '', $conf['upload_dir']);
     2155
    21442156  if (!is_dir($conf['upload_dir']))
    21452157  {
    21462158    if (!is_writable(dirname($conf['upload_dir'])))
    21472159    {
    2148       $ret['message'] = sprintf(
     2160      return sprintf(
    21492161        l10n('Create the "%s" directory at the root of your Piwigo installation'),
    21502162        $relative_dir
     
    21602172      if (!is_writable($conf['upload_dir']))
    21612173      {
    2162         $ret['message'] = sprintf(
     2174        return sprintf(
    21632175          l10n('Give write access (chmod 777) to "%s" directory at the root of your Piwigo installation'),
    21642176          $relative_dir
     
    21682180  }
    21692181
    2170   if (!empty($ret['message']))
    2171   {
    2172     $ret['ready_for_upload'] = false;
    2173   }
    2174  
    2175   return $ret;
     2182  return null;
    21762183}
    21772184?>
Note: See TracChangeset for help on using the changeset viewer.