Changeset 2584


Ignore:
Timestamp:
Sep 24, 2008, 11:30:33 PM (16 years ago)
Author:
plg
Message:

new: WebService method pwg.tags.getAdminList was added. The difference with
pwg.tags.getList is that this new method doesn't take permissions into
account, and so is available only for administrator connected users.

Location:
trunk
Files:
3 edited

Legend:

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

    r2583 r2584  
    11931193}
    11941194
     1195/**
     1196 * returns the list of tags as you can see them in administration (web
     1197 * service method).
     1198 *
     1199 * Only admin can run this method and permissions are not taken into
     1200 * account.
     1201 */
     1202function ws_tags_getAdminList($params, &$service)
     1203{
     1204  if (!is_admin())
     1205  {
     1206    return new PwgError(401, 'Access denied');
     1207  }
     1208 
     1209  $tags = get_all_tags();
     1210  return array(
     1211    'tags' => new PwgNamedArray(
     1212      $tags,
     1213      'tag',
     1214      array(
     1215        'name',
     1216        'id',
     1217        'url_name',
     1218        )
     1219      )
     1220    );
     1221}
    11951222
    11961223/**
  • trunk/tools/piwigo_remote.pl

    r2583 r2584  
    117117}
    118118
     119if ($opt{action} eq 'pwg.tags.getAdminList') {
     120    $query = pwg_ws_get_query(
     121        method => 'pwg.tags.getAdminList'
     122    );
     123
     124    $result = $ua->get($query);
     125    my $tags = from_json($result->content)->{result}{tags};
     126
     127    foreach my $tag (@{$tags}) {
     128        # print join(',', keys %{$tag}), "\n"; exit();
     129        printf(
     130            '{%u} %s ',
     131            $tag->{id},
     132            $tag->{name}
     133        );
     134    }
     135
     136    print "\n";
     137}
     138
    119139if ($opt{action} eq 'pwg.categories.add') {
    120140    $form = {
  • trunk/ws.php

    r2583 r2584  
    212212    'administration method only'
    213213    );
     214
     215  $service->addMethod(
     216    'pwg.tags.getAdminList',
     217    'ws_tags_getAdminList',
     218    array(),
     219    'administration method only'
     220    );
    214221}
    215222
Note: See TracChangeset for help on using the changeset viewer.