source: extensions/user_tags/include/t4u_admin_action.inc.php @ 9037

Last change on this file since 9037 was 9037, checked in by nikrou, 13 years ago

Fix translation issue
Fix bugs with special configuration params :

Prepare piwigo release 2.2 (func_combine_script instead of func_known_script)

File size: 2.4 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | User Tags  - a plugin for Piwigo                                      |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2010-2011 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
22if (!defined('PHPWG_ROOT_PATH')) {
23  die('Hacking attempt!');
24}
25
26if (!empty($_GET['action']) && ($_GET['action']=='add') 
27    && isset($_POST['tags']) && $plugin_config->getPermission('add') ) {
28  include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
29
30  if (empty($_POST['tags'])) {
31    $_POST['tags'] = array();
32  }
33  $tag_ids = get_fckb_tag_ids($_POST['tags']);
34  set_tags($tag_ids, $_POST['image_id']);
35
36  if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) {
37    header("Content-Type: application/json");
38    $message['info'] = 'Tags updated';
39
40    echo json_encode($message);
41    exit();
42  } else {
43    redirect(get_absolute_root_url().$_POST['referer']);
44  }
45} elseif (!empty($_GET['action']) && $_GET['action']=='get' && $plugin_config->getPermission('add') ) {
46  include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
47     
48  $query = '
49SELECT
50    id AS tag_id,
51    name AS tag_name
52  FROM '.TAGS_TABLE.'
53;';
54  header("Content-Type: application/json");
55  echo json_encode(get_fckb_taglist($query));
56  exit();
57}
58?>
Note: See TracBrowser for help on using the repository browser.