Changeset 9191 for trunk/include/ws_functions.inc.php
- Timestamp:
- Feb 11, 2011, 11:57:23 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/ws_functions.inc.php
r8728 r9191 1353 1353 return new PwgError(405, "This method requires HTTP POST"); 1354 1354 } 1355 1356 $params['image_id'] = (int)$params['image_id']; 1357 if ($params['image_id'] > 0) 1358 { 1359 include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); 1360 1361 $query=' 1362 SELECT * 1363 FROM '.IMAGES_TABLE.' 1364 WHERE id = '.$params['image_id'].' 1365 ;'; 1366 1367 $image_row = pwg_db_fetch_assoc(pwg_query($query)); 1368 if ($image_row == null) 1369 { 1370 return new PwgError(404, "image_id not found"); 1371 } 1372 } 1355 1373 1356 1374 // category 1357 1375 $params['category'] = (int)$params['category']; 1358 if ($params['category'] <= 0 )1376 if ($params['category'] <= 0 and $params['image_id'] <= 0) 1359 1377 { 1360 1378 return new PwgError(WS_ERR_INVALID_PARAM, "Invalid category_id"); … … 1367 1385 $_FILES['image']['tmp_name'], 1368 1386 $_FILES['image']['name'], 1369 array($params['category']), 1370 8 1387 $params['category'] > 0 ? array($params['category']) : null, 1388 8, 1389 $params['image_id'] > 0 ? $params['image_id'] : null 1371 1390 ); 1372 1391 … … 1416 1435 } 1417 1436 1418 $query = ' 1437 $url_params = array('image_id' => $image_id); 1438 1439 if ($params['category'] > 0) 1440 { 1441 $query = ' 1419 1442 SELECT id, name, permalink 1420 1443 FROM '.CATEGORIES_TABLE.' 1421 1444 WHERE id = '.$params['category'].' 1422 1445 ;'; 1423 $result = pwg_query($query); 1424 $category = pwg_db_fetch_assoc($result); 1446 $result = pwg_query($query); 1447 $category = pwg_db_fetch_assoc($result); 1448 1449 $url_params['section'] = 'categories'; 1450 $url_params['category'] = $category; 1451 } 1425 1452 1426 1453 return array( 1427 1454 'image_id' => $image_id, 1428 'url' => make_picture_url( 1429 array( 1430 'image_id' => $image_id, 1431 'section' => 'categories', 1432 'category' => $category 1433 ) 1434 ), 1455 'url' => make_picture_url($url_params), 1435 1456 ); 1436 1457 }
Note: See TracChangeset
for help on using the changeset viewer.