Index: /extensions/user_tags/CHANGELOG
===================================================================
--- /extensions/user_tags/CHANGELOG	(revision 6812)
+++ /extensions/user_tags/CHANGELOG	(revision 6813)
@@ -1,2 +1,6 @@
+User Tags 0.3.0 - 2010-08-28
+================================
+* update tags with ajax request
+
 User Tags 0.2.1 - 2010-08-28
 ================================
Index: /extensions/user_tags/MANIFEST
===================================================================
--- /extensions/user_tags/MANIFEST	(revision 6812)
+++ /extensions/user_tags/MANIFEST	(revision 6813)
@@ -33,4 +33,5 @@
 user_tags/include/default_values.inc.php
 user_tags/include/t4u_config.class.php
+user_tags/include/t4u_admin_action.inc.php
 user_tags/admin.php
 user_tags/COPYING
Index: /extensions/user_tags/admin.php
===================================================================
--- /extensions/user_tags/admin.php	(revision 6812)
+++ /extensions/user_tags/admin.php	(revision 6813)
@@ -28,4 +28,8 @@
 $me = get_plugin_data($plugin_id);
 $save_config = false;
+
+if (!empty($_GET['action']) && in_array($_GET['action'], array('add', 'get'))) {
+  include_once T4U_PLUGIN_ROOT . "/include/t4u_admin_action.inc.php";
+}
 
 $status_options[null] = '----------';
Index: /extensions/user_tags/css/style.css
===================================================================
--- /extensions/user_tags/css/style.css	(revision 6812)
+++ /extensions/user_tags/css/style.css	(revision 6813)
@@ -1,2 +1,6 @@
+#flash-messages{position:fixed;width:60%;display:none;top:30%;left:200px;font-size:.85em;}
+#flash-messages div{margin-left:120px;min-height:30px;padding:10px;font-weight:bold;}
+#flash-messages div.errors{color:red;background-color:#ffe1e1;border:1px solid red;}
+#flash-messages div.infos{color:green;background-color:#98fb98;}
 #t4u-update{float:right;}
 #t4u-cancel,#t4u-update{margin-top:5px;}
Index: /extensions/user_tags/include/t4u_admin_action.inc.php
===================================================================
--- /extensions/user_tags/include/t4u_admin_action.inc.php	(revision 6813)
+++ /extensions/user_tags/include/t4u_admin_action.inc.php	(revision 6813)
@@ -0,0 +1,55 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | User Tags  - a plugin for Piwigo                                      |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2010 Nicolas Roudaire             http://www.nikrou.net  |
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify  |
+// | it under the terms of the GNU General Public License as published by  |
+// | the Free Software Foundation                                          |
+// |                                                                       |
+// | This program is distributed in the hope that it will be useful, but   |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
+// | General Public License for more details.                              |
+// |                                                                       |
+// | You should have received a copy of the GNU General Public License     |
+// | along with this program; if not, write to the Free Software           |
+// | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,            |
+// | MA 02110-1301 USA.                                                    |
+// +-----------------------------------------------------------------------+
+
+if (!defined('PHPWG_ROOT_PATH')) {
+  die('Hacking attempt!');
+}
+
+if (!empty($_GET['action']) && ($_GET['action']=='add') 
+    && !empty($_POST['tags']) && $me->getPermission('add')) {
+  include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
+  
+  $tag_ids = get_fckb_tag_ids($_POST['tags']);
+  set_tags($tag_ids, $_POST['image_id']);
+
+  if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) {
+    header("Content-Type: application/json");
+
+    $message['info'] = l10n('Tags updated');
+    echo json_encode($message);
+    exit();
+  } else {
+    redirect(get_absolute_root_url().$_POST['referer']);
+  }
+} elseif (!empty($_GET['action']) && $_GET['action']=='get' && $me->getPermission('add')) {
+  include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
+      
+  $query = '
+SELECT
+    id AS tag_id,
+    name AS tag_name
+  FROM '.TAGS_TABLE.'
+;';
+  header("Content-Type: application/json");
+  echo json_encode(get_fckb_taglist($query));
+  exit();
+}
+?>
Index: /extensions/user_tags/include/t4u_config.class.php
===================================================================
--- /extensions/user_tags/include/t4u_config.class.php	(revision 6812)
+++ /extensions/user_tags/include/t4u_config.class.php	(revision 6813)
@@ -76,4 +76,11 @@
   }
 
+
+  public function hasPermission($permission='add') {
+    return 
+      (($this->getPermission($permission)!='')
+       and is_autorize_status(get_access_type_status($this->getPermission($permission))));
+  }
+
   public function plugin_admin_menu($menu) {
     array_push($menu,
@@ -86,5 +93,22 @@
 
   public function get_admin_help($help_content, $page) {
-    return load_language('help/'.$page.'.html', $this->plugin_dir .'/', array('return'=>true) );
+    return load_language('help/'.$page.'.html', 
+			 $this->plugin_dir .'/', 
+			 array('return'=>true) 
+			 );
+  }
+  
+  public function getActionUrl($action, $method='POST') {
+    $url = get_root_url().'admin.php?page=plugin';
+    $file = basename($this->plugin_dir) . '/' .'admin.php';
+    if (strtoupper($method)=='POST') {
+	$url .= '&amp;section='.urlencode($file);      
+	$url .= '&amp;action='.urlencode($action);      
+    } else {
+	$url .= '&section='.$file;           
+	$url .= '&action='.$action;           
+    }
+
+    return $url;
   }
 
Index: /extensions/user_tags/include/t4u_content.class.php
===================================================================
--- /extensions/user_tags/include/t4u_content.class.php	(revision 6812)
+++ /extensions/user_tags/include/t4u_content.class.php	(revision 6813)
@@ -23,29 +23,5 @@
 {
   public function __construct($config) {
-    $this->plugin_config = $config;
-
-    if (preg_match('!/t4u_addtags.*!', $_SERVER['QUERY_STRING']) 
-	&& !empty($_POST['tags'])
-	&& $this->hasPermission('add')) {
-      include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
-
-      $tag_ids = get_fckb_tag_ids($_POST['tags']);
-      set_tags($tag_ids, $_POST['image_id']);
-      redirect(get_absolute_root_url().$_POST['referer']);
-    }
-
-    if (preg_match('!/t4u_gettags.*!', $_SERVER['QUERY_STRING'])
-	&& $this->hasPermission('add')) {
-      include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
-
-      $query = '
-SELECT
-    id AS tag_id,
-    name AS tag_name
-  FROM '.TAGS_TABLE.'
-;';
-      echo json_encode(get_fckb_taglist($query));
-      exit();
-    }
+    $this->plugin_config = &$config;
   }
 
@@ -53,5 +29,5 @@
     global $template;
 
-    if (!$this->hasPermission('add')) {
+    if (!$this->plugin_config->hasPermission('add')) {
       return false;
     }
@@ -66,9 +42,9 @@
     $template->assign('T4U_CSS', T4U_CSS);
     $template->assign('T4U_IMGS', T4U_IMGS);
-    $template->assign('T4U_ADD_SCRIPT', $this->public_addtags_url());
-    $template->assign('T4U_GET_SCRIPT', $this->public_gettags_url());
+    $template->assign('T4U_ADD_SCRIPT', $this->plugin_config->getActionUrl('add', 'GET'));
+    $template->assign('T4U_GET_SCRIPT', $this->plugin_config->getActionUrl('get', 'GET'));
     $template->assign('T4U_IMAGE_ID', $picture['id']);
     $template->assign('T4U_REFERER', htmlentities($picture['url']));
-    $template->assign('T4U_PERMISSION_DELETE', $this->hasPermission('delete'));
+    $template->assign('T4U_PERMISSION_DELETE', $this->plugin_config->hasPermission('delete'));
 
     $related_tags = array();
@@ -83,34 +59,4 @@
     $template->assign_var_from_handle('PLUGIN_PICTURE_BEFORE', 'add_tags');
   }    
-
-  private function public_addtags_url() {
-    $url = get_root_url().'index';
-    if ($GLOBALS['conf']['php_extension_in_urls']) {
-      $url .= '.php';
-    }
-    if ($GLOBALS['conf']['question_mark_in_urls']) {
-      $url .= '?';
-    }
-    $url .= '/t4u_addtags';
-    return $url;
-  }
-
-  private function public_gettags_url() {
-    $url = get_root_url().'index';
-    if ($GLOBALS['conf']['php_extension_in_urls']) {
-      $url .= '.php';
-    }
-    if ($GLOBALS['conf']['question_mark_in_urls']) {
-      $url .= '?';
-    }
-    $url .= '/t4u_gettags';
-    return $url;
-  }
-
-  private function hasPermission($permission='add') {
-    return 
-      (($this->plugin_config->getPermission($permission)!='')
-       and is_autorize_status(get_access_type_status($this->plugin_config->getPermission($permission))));
-  }
 }
 ?>
Index: /extensions/user_tags/init.php
===================================================================
--- /extensions/user_tags/init.php	(revision 6812)
+++ /extensions/user_tags/init.php	(revision 6813)
@@ -35,5 +35,7 @@
 
 if (defined('IN_ADMIN')) { 
-  add_event_handler('get_admin_plugin_menu_links', array($plugin_config, 'plugin_admin_menu')); 
+  add_event_handler('get_admin_plugin_menu_links', 
+		    array($plugin_config, 'plugin_admin_menu')
+		    ); 
   add_event_handler('get_popup_help_content', 
 		    array($plugin_config, 'get_admin_help'),
Index: /extensions/user_tags/js/jquery.addtags.js
===================================================================
--- /extensions/user_tags/js/jquery.addtags.js	(revision 6812)
+++ /extensions/user_tags/js/jquery.addtags.js	(revision 6813)
@@ -1,1 +1,1 @@
-eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('1G(1g(p,a,c,k,e,d){e=1g(c){1f(c<a?\'\':e(1F(c/a)))+((c=c%a)>1E?1i.1I(c+29):c.1J(1M))};1h(!\'\'.1k(/^/,1i)){1j(c--){d[e(c)]=k[c]||e(c)}k=[1g(e){1f d[e]}];e=1g(){1f\'\\\\w+\'};c=1};1j(c--){1h(k[c]){p=p.1k(1L 1K(\'\\\\b\'+e(c)+\'\\\\b\',\'g\'),k[c])}}1f p}(\'d h(y){$(\\\'#2-k\\\').A(\\\'2-3\\\').s(\\\'3\\\');B}$(d(){f 1=\\\'<c J="\\\'+4[\\\'K\\\']+\\\'" C="E" 7="2-G-c">\\\';1+=\\\'<r 7="a" 9="a">\\\';1+=z;1+=\\\'</r>\\\';1+=\\\'<e b="q" 9="w" 5="\\\'+4[\\\'H\\\']+\\\'">\\\';1+=\\\'<e b="q" 9="L" 5="\\\'+4[\\\'D\\\']+\\\'">\\\';1+=\\\'<e b="I" 7="2-k" 3="3" t="2-3" 5="\\\'+8[\\\'u\\\']+\\\'">\\\';1+=\\\'</c>\\\';v($(\\\'#m\\\').x>0){$(\\\'#m j.F\\\').1b(\\\'<16 7="2-15" 14="\\\'+4[\\\'12\\\']+\\\'" 13="\\\'+8[\\\'l\\\']+\\\'">\\\').17(\\\'M\\\',8[\\\'l\\\']).18(\\\'2-1e\\\').o(d(){$(i).1d(\\\'o\\\');f g=$(i).1c().19(\\\'j.5\\\');f 1a=g.p();g.p(1);$(\\\'#a\\\').11({10:4[\\\'R\\\'],S:8[\\\'Q\\\'],P:n,N:n,O:6,T:6,U:6,Z:h,Y:h,X:V,W:6})})}});\',1H,1N,\'|1O|1U|1V|1W|1T|1S|1P|1Q|1D|1X|1B|1r|1g|1p|1s|1n|1Y|1l|1o|1m|1q|1C|1z|1A|1t|1y|1x|1u|1v|1w|1h|1R|2j|2t|2u|2v|1f|2w|2y|2r|2n|2o|2p|2q|2x|2C|2F|2H|2G|2D|2z|2E|2A|2B|2s|2l|25|26|27|28|24|2m|23|1Z|20|21|22|2a|2b|2i|2k|2h|2g|2c|2d|2e\'.2f(\'|\'),0,{}))',62,168,'|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||return|function|if|String|while|replace|this|update|tags_value|td|input|click_to_add_tags|form|var|html|removeAttr|class|update_tags|select|hidden|false|click|type|Tags|name|35|parseInt|eval|62|fromCharCode|toString|RegExp|new|36|77|newRow|id|vocab|image_id|true|value|t4u|disabled|path|tags|t4u_onchange|t4u_edit_icon|alt|src|edit|fcbkcomplete|onremove|100|newel|maxitems|onselect||img|attr|parent|unbind|clickable|split|append|old_tags_value|addClass|length|find|filter_selected|json_url|label|addtags|t4u_image_id|submit|post|firstselected|item|related_tags|removeClass|method|action|t4u_referer|cache|t4u_get_script|complete_text|t4u_add_script|filter_hide|start_to_type|referer|filter_case|title'.split('|'),0,{}))
+eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('(2($){$.c=2(s,1){$(s).l(\'\');$(s).Q().o(1).M(16).15(10)};$.Z.c=2(1){7.U(2(){T $.c(7,1)})};z 7})(V);2 I(1){b 9=\'\';i(1.G){9=\'<8 m="13">\'+1.G+\'</8>\'}X i(1.D){9=\'<8 m="Y">\'+1.D+\'</8>\'}i(9!=\'\'){$(\'W\').o(\'<8 5="B-u"></8>\');$(\'#B-u\').c(9)}}2 r(14){$(\'#3-E\').S(\'3-a\').11(\'a\');z}$(2(){b 4=\'<g 12="\'+6[\'L\']+\'" 17="J" 5="3-x-g">\';4+=\'<y 5="q" n="q">\';4+=N;4+=\'</y>\';4+=\'<k 5="3-P-5" j="C" n="R" f="\'+6[\'O\']+\'">\';4+=\'<k 5="3-K" j="C" n="K" f="\'+6[\'1p\']+\'">\';4+=\'<k 5="3-E" j="H" a="a" m="3-a" f="\'+h[\'1v\']+\'">\';4+=\'</g>\';i($(\'#w\').1w>0){$(\'#w v.1u\').o(\'<1t 5="3-1r" 1s="\'+6[\'18\']+\'" 1B="\'+h[\'A\']+\'">\').1D(\'1F\',h[\'A\']).1E(\'3-1C\').t(2(){$(7).1z(\'t\');b p=$(7).1A().1x(\'v.f\');b 1q=p.l();p.l(4);$(\'#q\').1e({1f:6[\'1d\'],1c:h[\'19\'],1a:F,1b:F,1g:d,1h:d,1n:d,1o:r,1m:r,1l:1i,1j:d});$(\'#3-x-g\').H(2(e){$.J(6[\'L\'],$(7).1k(),2(1){I(1)});e.1y()})})}});',62,104,'|data|function|t4u|newRow|id|path|this|div|message|disabled|var|flashMessage|true||value|form|vocab|if|type|input|html|class|name|append|tags_value|tags|t4u_onchange|source|click|messages|td|Tags|addtags|select|return|click_to_add_tags|flash|hidden|error|update|false|info|submit|t4u_form_sucess|post|referer|t4u_add_script|fadeIn|related_tags|t4u_image_id|image|hide|image_id|removeClass|new|each|jQuery|body|else|errors|fn|3000|removeAttr|action|infos|item|fadeOut|500|method|t4u_edit_icon|start_to_type|cache|filter_case|complete_text|t4u_get_script|fcbkcomplete|json_url|filter_hide|firstselected|100|newel|serialize|maxitems|onselect|filter_selected|onremove|t4u_referer|old_tags_value|edit|src|img|label|update_tags|length|find|preventDefault|unbind|parent|alt|clickable|attr|addClass|title'.split('|'),0,{}))
Index: /extensions/user_tags/language/fr_FR/plugin.lang.php
===================================================================
--- /extensions/user_tags/language/fr_FR/plugin.lang.php	(revision 6812)
+++ /extensions/user_tags/language/fr_FR/plugin.lang.php	(revision 6813)
@@ -23,4 +23,5 @@
 $lang['Start to type'] = 'Commencez à taper';
 $lang['Update tags'] = 'Mettre à jour les tags';
+$lang['Tags updated'] = 'Les tags ont été mis à jour';
 $lang['Cancel'] = 'Annuler';
 
Index: /extensions/user_tags/language/templates/plugin.lang.php
===================================================================
--- /extensions/user_tags/language/templates/plugin.lang.php	(revision 6812)
+++ /extensions/user_tags/language/templates/plugin.lang.php	(revision 6813)
@@ -23,4 +23,5 @@
 $lang['Start to type'] = '';
 $lang['Update tags'] = '';
+$lang['Tags updated'] = '';
 $lang['Cancel'] = '';
 
Index: /extensions/user_tags/main.inc.php
===================================================================
--- /extensions/user_tags/main.inc.php	(revision 6812)
+++ /extensions/user_tags/main.inc.php	(revision 6813)
@@ -22,5 +22,5 @@
 /*
 Plugin Name: User Tags
-Version: 0.2.1
+Version: 0.3.0
 Description: Allow visitors to add tag to images
 Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=441
