Changeset 6049


Ignore:
Timestamp:
05/03/10 11:09:40 (9 years ago)
Author:
plg
Message:

bug 1635 fixed: new API method pwg.images.checkUpload tells pLoader if Piwigo
is ready for upload (currently, it checks write access on the upload directory)

Location:
trunk
Files:
2 edited

Legend:

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

    r5930 r6049  
    21272127    ); 
    21282128} 
     2129 
     2130function ws_images_checkUpload($params, &$service) 
     2131{ 
     2132  global $conf; 
     2133 
     2134  if (!is_admin() or is_adviser()) 
     2135  { 
     2136    return new PwgError(401, 'Access denied'); 
     2137  } 
     2138 
     2139  $relative_dir = preg_replace('#^'.PHPWG_ROOT_PATH.'#', '', $conf['upload_dir']); 
     2140 
     2141  $ret['message'] = null; 
     2142  $ret['ready_for_upload'] = true; 
     2143   
     2144  if (!is_dir($conf['upload_dir'])) 
     2145  { 
     2146    if (!is_writable(dirname($conf['upload_dir']))) 
     2147    { 
     2148      $ret['message'] = sprintf( 
     2149        l10n('Create the "%s" directory at the root of your Piwigo installation'), 
     2150        $relative_dir 
     2151        ); 
     2152    } 
     2153  } 
     2154  else 
     2155  { 
     2156    if (!is_writable($conf['upload_dir'])) 
     2157    { 
     2158      @chmod($conf['upload_dir'], 0777); 
     2159       
     2160      if (!is_writable($conf['upload_dir'])) 
     2161      { 
     2162        $ret['message'] = sprintf( 
     2163          l10n('Give write access (chmod 777) to "%s" directory at the root of your Piwigo installation'), 
     2164          $relative_dir 
     2165          ); 
     2166      } 
     2167    } 
     2168  } 
     2169 
     2170  if (!empty($ret['message'])) 
     2171  { 
     2172    $ret['ready_for_upload'] = false; 
     2173  } 
     2174   
     2175  return $ret; 
     2176} 
    21292177?> 
  • trunk/ws.php

    r5196 r6049  
    277277 
    278278  $service->addMethod( 
     279    'pwg.images.checkUpload', 
     280    'ws_images_checkUpload', 
     281    null, 
     282    'check if Piwigo is ready for upload' 
     283    ); 
     284 
     285  $service->addMethod( 
    279286    'pwg.images.setInfo', 
    280287    'ws_images_setInfo', 
Note: See TracChangeset for help on using the changeset viewer.