Ignore:
Timestamp:
Jan 18, 2013, 8:21:30 PM (11 years ago)
Author:
nikrou
Message:

Mise à jour année du copyright

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/user_tags/include/t4u_ws.class.php

    r20139 r20251  
    66// +-----------------------------------------------------------------------+
    77// | This program is free software; you can redistribute it and/or modify  |
    8 // | it under the terms of the GNU General Public License version2 as      |
     8// | it under the terms of the GNU General Public License version 2 as     |
    99// | published by the Free Software Foundation                             |
    1010// |                                                                       |
     
    2828
    2929    $service->addMethod(T4U_WS.'list', array($this, 'tagsList'),
    30                         array(),
     30                        array('q' => array()),
    3131                        'retrieves a list of tags than can be filtered'
    3232                        );
     
    4141
    4242  public function tagsList($params, &$service) {
    43     $query = '
    44 SELECT
    45     id AS tag_id,
    46     name AS tag_name
    47   FROM '.TAGS_TABLE.'
    48 ;';
    49    
     43    $query = 'SELECT id AS tag_id, name AS tag_name FROM '.TAGS_TABLE;
     44    if (!empty($params['q'])) {
     45      $query .= sprintf(' WHERE name like \'%%%s%%\'', $params['q']);
     46    }
     47
    5048    $tagslist = $this->__makeTagsList($query);
    5149    unset($tagslist['__associative_tags']);
     
    106104    }
    107105
    108     if (!empty($tags_to_associate)) {
    109       $tag_ids = get_tag_ids(implode(',', $tags_to_associate));
    110       set_tags($tag_ids, $params['image_id']); 
     106    if (empty($message['error'])) {
     107      if (empty($tags_to_associate)) { // remove all tags for an image
     108        $query = 'DELETE FROM '.IMAGE_TAG_TABLE;
     109        $query .= sprintf(' WHERE image_id = %d', $params['image_id']);
     110        pwg_query($query);
     111      } else {
     112        $tag_ids = get_tag_ids(implode(',', $tags_to_associate));
     113        set_tags($tag_ids, $params['image_id']); 
     114      }
    111115    }
    112116   
Note: See TracChangeset for help on using the changeset viewer.