Ignore:
Timestamp:
Nov 24, 2013, 6:09:57 PM (10 years ago)
Author:
mistic100
Message:

very big update for Piwigo 2.6

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/UserCollections/include/ws_functions.inc.php

    r24421 r25678  
    66  $service = &$arr[0];
    77  global $conf;
    8  
     8
    99  $service->addMethod(
    1010    'pwg.collections.create',
     
    1717    'Create a new User Collection.'
    1818    );
    19    
     19
    2020  $service->addMethod(
    2121    'pwg.collections.delete',
     
    2626    'Delete a User Collection.'
    2727    );
    28    
     28
    2929  $service->addMethod(
    3030    'pwg.collections.getList',
     
    4242    'Returns a list of collections.'
    4343    );
    44    
     44
    4545  $service->addMethod(
    4646    'pwg.collections.addImages',
     
    5252    'Add images to a collection.'
    5353    );
    54    
     54
    5555  $service->addMethod(
    5656    'pwg.collections.removeImages',
     
    6262    'Remove images from a collection.'
    6363    );
    64    
     64
    6565  $service->addMethod(
    6666    'pwg.collections.getImages',
     
    7474    'Returns elements for the corresponding  collection.'
    7575    );
    76    
     76
    7777  $service->addMethod(
    7878    'pwg.collections.getSerialized',
     
    8888    'Returns a serialized version of the collection in CSV.<br>The return type is plain/text whatever you select as response format.'
    8989    );
    90    
     90
    9191  $service->addMethod(
    9292    'pwg.collections.getInfo',
     
    105105{
    106106  global $conf, $user;
    107  
    108   // check status
    109   if (is_a_guest())
    110   {
    111     return new PwgError(403, 'Forbidden');
    112   }
    113  
     107
     108  // check status
     109  if (is_a_guest())
     110  {
     111    return new PwgError(403, 'Forbidden');
     112  }
     113
    114114  // check name
    115115  if (empty($params['name']))
     
    117117    return new PwgError(WS_ERR_MISSING_PARAM, 'Empty collection name');
    118118  }
    119  
     119
    120120  // check user id
    121121  if (!empty($params['user_id']))
     
    135135    $params['user_id'] = $user['id'];
    136136  }
    137  
     137
    138138  $collection = new UserCollection('new', $params['name'], $params['comment'], $params['user_id']);
    139  
     139
    140140  return array_change_key_case($collection->getCollectionInfo(), CASE_LOWER);
    141141}
     
    147147{
    148148  global $user;
    149  
    150   // check status
    151   if (is_a_guest())
    152   {
    153     return new PwgError(403, 'Forbidden');
    154   }
    155  
    156   try {
    157     $collection = new UserCollection($params['col_id']);
    158     $collection->checkUser();
    159    
     149
     150  // check status
     151  if (is_a_guest())
     152  {
     153    return new PwgError(403, 'Forbidden');
     154  }
     155
     156  try {
     157    $collection = new UserCollection($params['col_id']);
     158    $collection->checkUser();
     159
    160160    $collection->delete();
    161161  }
     
    172172{
    173173  global $user, $conf;
    174  
    175   // check status
    176   if (is_a_guest())
    177   {
    178     return new PwgError(403, 'Forbidden');
    179   }
    180  
     174
     175  // check status
     176  if (is_a_guest())
     177  {
     178    return new PwgError(403, 'Forbidden');
     179  }
     180
    181181  // check user_id
    182182  if (!empty($params['user_id']))
     
    196196    $params['user_id'] = $user['id'];
    197197  }
    198  
     198
    199199  // search
    200200  $where_clauses = array('1=1');
     
    207207    $where_clauses[] = 'name LIKE("%'.pwg_db_real_escape_string($params['name']).'%")';
    208208  }
    209  
     209
    210210  $order_by = !empty($params['order']) ? $params['order'] : 'username ASC, name ASC';
    211  
     211
    212212  $query = '
    213 SELECT 
     213SELECT
    214214    c.*,
    215215    u.'.$conf['user_fields']['username'].' AS username
     
    223223;';
    224224  $sets = hash_from_query($query, 'id');
    225  
     225
    226226  $data = array();
    227227  foreach ($sets as $row)
     
    238238      );
    239239  }
    240  
     240
    241241  return array(
    242242    'paging' => new PwgNamedStruct(array(
     
    250250      )
    251251    );
    252  
     252
    253253  return $ret;
    254254}
     
    260260{
    261261  global $conf, $user;
    262  
    263   // check status
    264   if (is_a_guest())
    265   {
    266     return new PwgError(403, 'Forbidden');
    267   }
    268 
    269   try {
    270     $collection = new UserCollection($params['col_id']);
    271     $collection->checkUser();
    272    
     262
     263  // check status
     264  if (is_a_guest())
     265  {
     266    return new PwgError(403, 'Forbidden');
     267  }
     268
     269  try {
     270    $collection = new UserCollection($params['col_id']);
     271    $collection->checkUser();
     272
    273273    $collection->addImages($params['image_ids']);
    274    
     274
    275275    return array('nb_images' => $collection->getParam('nb_images'));
    276276  }
     
    287287{
    288288  global $conf, $user;
    289  
    290   // check status
    291   if (is_a_guest())
    292   {
    293     return new PwgError(403, 'Forbidden');
    294   }
    295  
    296   try {
    297     $collection = new UserCollection($params['col_id']);
    298     $collection->checkUser();
    299    
     289
     290  // check status
     291  if (is_a_guest())
     292  {
     293    return new PwgError(403, 'Forbidden');
     294  }
     295
     296  try {
     297    $collection = new UserCollection($params['col_id']);
     298    $collection->checkUser();
     299
    300300    $collection->removeImages($params['image_ids']);
    301    
     301
    302302    return array('nb_images' => $collection->getParam('nb_images'));
    303303  }
     
    314314{
    315315  global $conf, $user;
    316  
    317   // check status
    318   if (is_a_guest())
    319   {
    320     return new PwgError(403, 'Forbidden');
    321   }
    322 
    323   try {
    324     $collection = new UserCollection($params['col_id']);
    325     $collection->checkUser();
    326    
     316
     317  // check status
     318  if (is_a_guest())
     319  {
     320    return new PwgError(403, 'Forbidden');
     321  }
     322
     323  try {
     324    $collection = new UserCollection($params['col_id']);
     325    $collection->checkUser();
     326
    327327    $image_ids = $collection->getImages();
    328328    $images = array();
    329    
     329
    330330    if (!empty($image_ids))
    331331    {
     
    343343SELECT i.*
    344344  FROM '.IMAGES_TABLE.' i
    345   WHERE 
     345  WHERE
    346346    '. implode("\n AND ", $where_clauses).'
    347347  GROUP BY i.id
     
    366366        }
    367367        $image = array_merge($image, ws_std_get_urls($row));
    368        
     368
    369369        array_push($images, $image);
    370370      }
    371371    }
    372    
     372
    373373    return array(
    374374      'paging' => new PwgNamedStruct(array(
     
    396396{
    397397  global $conf, $user;
    398  
    399   // check status
    400   if (is_a_guest())
    401   {
    402     return new PwgError(403, 'Forbidden');
    403   }
    404 
    405   try {
    406     $collection = new UserCollection($params['col_id']);
    407     $collection->checkUser();
    408    
     398
     399  // check status
     400  if (is_a_guest())
     401  {
     402    return new PwgError(403, 'Forbidden');
     403  }
     404
     405  try {
     406    $collection = new UserCollection($params['col_id']);
     407    $collection->checkUser();
     408
    409409    // change encoder to plain text
    410410    include_once(USER_COLLEC_PATH.'include/plain_encoder.php');
    411411    $encoder = new PwgPlainEncoder();
    412412    $service->setEncoder('plain', $encoder);
    413  
     413
    414414    return $collection->serialize($params['content']);
    415415  }
     
    426426{
    427427  global $conf, $user;
    428  
    429   // check status
    430   if (is_a_guest())
    431   {
    432     return new PwgError(403, 'Forbidden');
    433   }
    434 
    435   try {
    436     $collection = new UserCollection($params['col_id']);
    437     $collection->checkUser();
    438  
     428
     429  // check status
     430  if (is_a_guest())
     431  {
     432    return new PwgError(403, 'Forbidden');
     433  }
     434
     435  try {
     436    $collection = new UserCollection($params['col_id']);
     437    $collection->checkUser();
     438
    439439    return array_change_key_case($collection->getCollectionInfo(), CASE_LOWER);
    440440  }
     
    444444  }
    445445}
    446 
    447 ?>
Note: See TracChangeset for help on using the changeset viewer.