[6798] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
| 3 | // | User Tags - a plugin for Piwigo | |
---|
| 4 | // +-----------------------------------------------------------------------+ |
---|
| 5 | // | Copyright(C) 2010 Nicolas Roudaire http://www.nikrou.net | |
---|
| 6 | // +-----------------------------------------------------------------------+ |
---|
| 7 | // | This program is free software; you can redistribute it and/or modify | |
---|
| 8 | // | it under the terms of the GNU General Public License as published by | |
---|
| 9 | // | the Free Software Foundation | |
---|
| 10 | // | | |
---|
| 11 | // | This program is distributed in the hope that it will be useful, but | |
---|
| 12 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
| 13 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
| 14 | // | General Public License for more details. | |
---|
| 15 | // | | |
---|
| 16 | // | You should have received a copy of the GNU General Public License | |
---|
| 17 | // | along with this program; if not, write to the Free Software | |
---|
| 18 | // | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |
---|
| 19 | // | MA 02110-1301 USA. | |
---|
| 20 | // +-----------------------------------------------------------------------+ |
---|
| 21 | |
---|
| 22 | if (!defined('PHPWG_ROOT_PATH')) { |
---|
| 23 | die('Hacking attempt!'); |
---|
| 24 | } |
---|
| 25 | |
---|
[6813] | 26 | if (!empty($_GET['action']) && ($_GET['action']=='add') |
---|
| 27 | && !empty($_POST['tags']) && $me->getPermission('add')) { |
---|
| 28 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
| 29 | |
---|
| 30 | $tag_ids = get_fckb_tag_ids($_POST['tags']); |
---|
| 31 | set_tags($tag_ids, $_POST['image_id']); |
---|
[6798] | 32 | |
---|
[6813] | 33 | if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) { |
---|
| 34 | header("Content-Type: application/json"); |
---|
[6798] | 35 | |
---|
[6813] | 36 | $message['info'] = l10n('Tags updated'); |
---|
| 37 | echo json_encode($message); |
---|
| 38 | exit(); |
---|
| 39 | } else { |
---|
| 40 | redirect(get_absolute_root_url().$_POST['referer']); |
---|
| 41 | } |
---|
| 42 | } elseif (!empty($_GET['action']) && $_GET['action']=='get' && $me->getPermission('add')) { |
---|
| 43 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
| 44 | |
---|
| 45 | $query = ' |
---|
| 46 | SELECT |
---|
| 47 | id AS tag_id, |
---|
| 48 | name AS tag_name |
---|
| 49 | FROM '.TAGS_TABLE.' |
---|
| 50 | ;'; |
---|
| 51 | header("Content-Type: application/json"); |
---|
| 52 | echo json_encode(get_fckb_taglist($query)); |
---|
| 53 | exit(); |
---|
[6798] | 54 | } |
---|
| 55 | ?> |
---|