Ignore:
Timestamp:
Jul 2, 2008, 3:11:26 AM (16 years ago)
Author:
rvelices
Message:
  • first use of web services as Ajax: change the privacy level directly from the picture page
File:
1 edited

Legend:

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

    r2409 r2413  
    823823      )
    824824    );
     825}
     826
     827function ws_images_setPrivacyLevel($params, &$service)
     828{
     829  if (!is_admin() || is_adviser() )
     830  {
     831    return new PwgError(401, 'Access denied');
     832  }
     833  if ( empty($params['image_id']) )
     834  {
     835    return new PwgError(WS_ERR_INVALID_PARAM, "Invalid image_id");
     836  }
     837  global $conf;
     838  if ( !in_array( (int)$params['level'], $conf['available_permission_levels']) )
     839  {
     840    return new PwgError(WS_ERR_INVALID_PARAM, "Invalid level");
     841  }
     842  $query = '
     843UPDATE '.IMAGES_TABLE.'
     844  SET level='.(int)$params['level'].'
     845  WHERE id IN ('.implode(',',$params['image_id']).')';
     846  $result = pwg_query($query);
     847  $affected_rows = mysql_affected_rows();
     848  if ($affected_rows)
     849  {
     850    include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
     851    invalidate_user_cache();
     852  }
     853  return $affected_rows;
    825854}
    826855
Note: See TracChangeset for help on using the changeset viewer.