Changeset 12727

Show
Ignore:
Timestamp:
12/13/11 15:58:39 (18 months ago)
Author:
plg
Message:

feature 2532 added: pwg.images.add returns image_id (+url)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/2.3/include/ws_functions.inc.php

    r12725 r12727  
    17861786  } 
    17871787 
     1788  $url_params = array('image_id' => $image_id); 
     1789   
    17881790  // let's add links between the image and the categories 
    17891791  if (isset($params['categories'])) 
    17901792  { 
    17911793    ws_add_image_category_relations($image_id, $params['categories']); 
     1794 
     1795    if (preg_match('/^\d+/', $params['categories'], $matches)) { 
     1796      $category_id = $matches[0]; 
     1797     
     1798      $query = ' 
     1799SELECT id, name, permalink 
     1800  FROM '.CATEGORIES_TABLE.' 
     1801  WHERE id = '.$category_id.' 
     1802;'; 
     1803      $result = pwg_query($query); 
     1804      $category = pwg_db_fetch_assoc($result); 
     1805       
     1806      $url_params['section'] = 'categories'; 
     1807      $url_params['category'] = $category; 
     1808    } 
    17921809  } 
    17931810 
     
    18021819 
    18031820  invalidate_user_cache(); 
     1821 
     1822  return array( 
     1823    'image_id' => $image_id, 
     1824    'url' => make_picture_url($url_params), 
     1825    ); 
    18041826} 
    18051827