Changeset 8249 for trunk/include/ws_functions.inc.php
- Timestamp:
- Dec 23, 2010, 11:22:51 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/ws_functions.inc.php
r8126 r8249 1077 1077 function add_file($file_path, $type, $original_sum, $file_sum) 1078 1078 { 1079 include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php'); 1080 1079 1081 $file_path = file_path_for_type($file_path, $type); 1080 1082 … … 1336 1338 1337 1339 invalidate_user_cache(); 1340 } 1341 1342 function ws_images_addSimple($params, &$service) 1343 { 1344 global $conf; 1345 if (!is_admin() || is_adviser() ) 1346 { 1347 return new PwgError(401, 'Access denied'); 1348 } 1349 1350 if (!$service->isPost()) 1351 { 1352 return new PwgError(405, "This method requires HTTP POST"); 1353 } 1354 1355 // category 1356 $params['category'] = (int)$params['category']; 1357 if ($params['category'] <= 0) 1358 { 1359 return new PwgError(WS_ERR_INVALID_PARAM, "Invalid category_id"); 1360 } 1361 1362 include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php'); 1363 prepare_upload_configuration(); 1364 1365 $image_id = add_uploaded_file( 1366 $_FILES['image']['tmp_name'], 1367 $_FILES['image']['name'], 1368 array($params['category']), 1369 8 1370 ); 1371 1372 $info_columns = array( 1373 'name', 1374 'author', 1375 'comment', 1376 'level', 1377 'date_creation', 1378 ); 1379 1380 foreach ($info_columns as $key) 1381 { 1382 if (isset($params[$key])) 1383 { 1384 $update[$key] = $params[$key]; 1385 } 1386 } 1387 1388 if (count(array_keys($update)) > 0) 1389 { 1390 $update['id'] = $image_id; 1391 1392 include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); 1393 mass_updates( 1394 IMAGES_TABLE, 1395 array( 1396 'primary' => array('id'), 1397 'update' => array_diff(array_keys($update), array('id')) 1398 ), 1399 array($update) 1400 ); 1401 } 1402 1403 1404 if (isset($params['tags']) and !empty($params['tags'])) 1405 { 1406 $tag_ids = array(); 1407 $tag_names = explode(',', $params['tags']); 1408 foreach ($tag_names as $tag_name) 1409 { 1410 $tag_id = tag_id_from_tag_name($tag_name); 1411 array_push($tag_ids, $tag_id); 1412 } 1413 1414 add_tags($tag_ids, array($image_id)); 1415 } 1416 1417 $query = ' 1418 SELECT id, name, permalink 1419 FROM '.CATEGORIES_TABLE.' 1420 WHERE id = '.$params['category'].' 1421 ;'; 1422 $result = pwg_query($query); 1423 $category = pwg_db_fetch_assoc($result); 1424 1425 return array( 1426 'image_id' => $image_id, 1427 'url' => make_picture_url( 1428 array( 1429 'image_id' => $image_id, 1430 'section' => 'categories', 1431 'category' => $category 1432 ) 1433 ), 1434 ); 1338 1435 } 1339 1436 … … 1745 1842 1746 1843 if (isset($params[$param_name.'_sum'])) { 1844 include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php'); 1747 1845 $type_path = file_path_for_type($path, $type); 1748 1846 if (!is_file($type_path)) { … … 1761 1859 1762 1860 return $ret; 1763 }1764 1765 function file_path_for_type($file_path, $type='thumb')1766 {1767 // resolve the $file_path depending on the $type1768 if ('thumb' == $type) {1769 $file_path = get_thumbnail_location(1770 array(1771 'path' => $file_path,1772 'tn_ext' => 'jpg',1773 )1774 );1775 }1776 1777 if ('high' == $type) {1778 @include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php');1779 $file_path = get_high_location(1780 array(1781 'path' => $file_path,1782 'has_high' => 'true'1783 )1784 );1785 }1786 1787 return $file_path;1788 1861 } 1789 1862 … … 2153 2226 } 2154 2227 2228 include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php'); 2155 2229 $ret['message'] = ready_for_upload_message(); 2156 2230 $ret['ready_for_upload'] = true; … … 2163 2237 return $ret; 2164 2238 } 2165 2166 function ready_for_upload_message()2167 {2168 global $conf;2169 2170 $relative_dir = preg_replace('#^'.PHPWG_ROOT_PATH.'#', '', $conf['upload_dir']);2171 2172 if (!is_dir($conf['upload_dir']))2173 {2174 if (!is_writable(dirname($conf['upload_dir'])))2175 {2176 return sprintf(2177 l10n('Create the "%s" directory at the root of your Piwigo installation'),2178 $relative_dir2179 );2180 }2181 }2182 else2183 {2184 if (!is_writable($conf['upload_dir']))2185 {2186 @chmod($conf['upload_dir'], 0777);2187 2188 if (!is_writable($conf['upload_dir']))2189 {2190 return sprintf(2191 l10n('Give write access (chmod 777) to "%s" directory at the root of your Piwigo installation'),2192 $relative_dir2193 );2194 }2195 }2196 }2197 2198 return null;2199 }2200 2239 ?>
Note: See TracChangeset
for help on using the changeset viewer.