Changeset 6051


Ignore:
Timestamp:
05/03/10 11:56:22 (9 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)

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/photos_add_direct.php

    r6025 r6051  
    445445$setup_errors = array(); 
    446446 
    447 $upload_base_dir = 'upload'; 
    448 $upload_dir = PHPWG_ROOT_PATH.$upload_base_dir; 
    449  
    450 if (!is_dir($upload_dir)) 
    451 { 
    452   if (!is_writable(PHPWG_ROOT_PATH)) 
    453   { 
    454     array_push( 
    455       $setup_errors, 
    456       sprintf( 
    457         l10n('Create the "%s" directory at the root of your Piwigo installation'), 
    458         $upload_base_dir 
    459         ) 
    460       ); 
    461   } 
    462 } 
    463 else 
    464 { 
    465   if (!is_writable($upload_dir)) 
    466   { 
    467     @chmod($upload_dir, 0777); 
    468  
    469     if (!is_writable($upload_dir)) 
    470     { 
    471       array_push( 
    472         $setup_errors, 
    473         sprintf( 
    474           l10n('Give write access (chmod 777) to "%s" directory at the root of your Piwigo installation'), 
    475           $upload_base_dir 
    476           ) 
    477         ); 
    478     } 
    479   } 
     447$error_message = ready_for_upload_message(); 
     448if (!empty($error_message)) 
     449{ 
     450  array_push($setup_errors, $error_message); 
    480451} 
    481452 
  • 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.