Index: /extensions/virtualAutoGrant/language/en_UK/plugin.lang.php
===================================================================
--- /extensions/virtualAutoGrant/language/en_UK/plugin.lang.php	(revision 6649)
+++ /extensions/virtualAutoGrant/language/en_UK/plugin.lang.php	(revision 6650)
@@ -1,3 +1,5 @@
 <?php
+$lang['On'] = 'Yes, maybe';
+$lang['Off'] = 'No, in general';
 $lang['Virtual AutoGrant configuration'] = 'Virtual AutoGrant configuration';
 $lang['New virtual categories will be assumed private, access granted to creator and webmaster and/or uploaded pictures will have "Who can see" set to creator privacy level'] 
@@ -10,5 +12,5 @@
 
 $lang['Force "Who can see" at the creator privacy level'] = 'Force "Who can see" at the creator privacy level';
-$lang['"Who can see" is not forced for private categories'] = '"Who can see" is not forced for private categories';
+$lang['"Who can see" is free for private categories'] = '"Who can see" is free for private categories';
 $lang['"Who can see" is free on webmasters uploads'] = '"Who can see" is free on webmasters uploads';
 
@@ -18,3 +20,6 @@
 $lang['You are not authorized to change this configuration (Webmaster only).'] = 'You are not authorized to change this configuration (Webmaster only).';
 $lang['Your configuration is saved.'] = 'Your configuration is saved.';
+$lang['You have got a private access to %s'] = 'You have got a private access to %s';
+$lang['Virtual AutoGrant has forced "Who can see" on %d image']  = 'Virtual AutoGrant has forced "Who can see" on %d image';
+$lang['Virtual AutoGrant has forced "Who can see" on %d images'] = 'Virtual AutoGrant has forced "Who can see" on %d images';
 ?>
Index: /extensions/virtualAutoGrant/language/fr_FR/plugin.lang.php
===================================================================
--- /extensions/virtualAutoGrant/language/fr_FR/plugin.lang.php	(revision 6649)
+++ /extensions/virtualAutoGrant/language/fr_FR/plugin.lang.php	(revision 6650)
@@ -12,6 +12,6 @@
 
 $lang['Force "Who can see" at the creator privacy level'] = 'Force le "Qui peut voir" au niveau de confidentialité du créateur';
-$lang['"Who can see" is not forced for private categories'] = '"Qui peut voir" n\'est pas forcé en cas de categories privées';
-$lang['"Who can see" is free on webmasters uploads'] = '"Qui peut voir" est libre pour les chargements du webmaster';
+$lang['"Who can see" is free for private categories'] = 'Le "Qui peut voir" reste libre en cas de categories privées';
+$lang['"Who can see" is free on webmasters uploads'] = 'Le "Qui peut voir" est libre pour les chargements du webmaster';
 
 $lang['Only the default webmaster can change this option.'] = 'Uniquement le webmaster par défaut peut modifier cette option.';
@@ -22,4 +22,6 @@
 $lang['Your configuration is NOT saved due to above reasons.'] = 'Votre configuration n\'a PAS été enregistré suite aux erreurs ci-dessus.';
 $lang['Your configuration is saved.'] = 'Votre configuration a été enregistrée.';
-
+$lang['You have got a private access to %s'] = 'Vous avez obtenu un accès privé à %s';
+$lang['Virtual AutoGrant has forced "Who can see" on %d image']  = 'Virtual AutoGrant a forcé le "Qui peut voir" pour %d élément';
+$lang['Virtual AutoGrant has forced "Who can see" on %d images'] = 'Virtual AutoGrant a forcé le "Qui peut voir" pour %d éléments';
 ?>
Index: /extensions/virtualAutoGrant/main.inc.php
===================================================================
--- /extensions/virtualAutoGrant/main.inc.php	(revision 6649)
+++ /extensions/virtualAutoGrant/main.inc.php	(revision 6650)
@@ -4,5 +4,5 @@
 Version: 2.1.a
 Description: External uploaders assume New virtual categories as Private, and authorize access only to creator
-Plugin URI: http://piwigo.org/ext/extension_view.php?eid=xxx
+Plugin URI: http://piwigo.org/ext/extension_view.php?eid=410
 Author: VDigital
 Author URI: http://piwigo.org/
Index: /extensions/virtualAutoGrant/template/VAG_admin.tpl
===================================================================
--- /extensions/virtualAutoGrant/template/VAG_admin.tpl	(revision 6649)
+++ /extensions/virtualAutoGrant/template/VAG_admin.tpl	(revision 6650)
@@ -60,5 +60,5 @@
    </tr>
    <tr>
-    <td class="label">{'"Who can see" is not forced for private categories'|@translate}</td>
+    <td class="label">{'"Who can see" is free for private categories'|@translate}</td>
 	<td>
 		<input type="radio" value="1"  name="ignore_who_can_see_on_private" {if ($VAG.ignore_who_can_see_on_private)}  checked="checked" {/if}/>{'On'|@translate}
Index: /extensions/virtualAutoGrant/virtual_categories_granted_to_creator.php
===================================================================
--- /extensions/virtualAutoGrant/virtual_categories_granted_to_creator.php	(revision 6649)
+++ /extensions/virtualAutoGrant/virtual_categories_granted_to_creator.php	(revision 6650)
@@ -4,79 +4,52 @@
 global $conf;
 include_once( VAG_PATH . 'VAG_default.php');
-$vag = & $conf['virtual_AutoGrant'];
 
-// General case for set private (exception synchronisation (categories are not virtual ones))
-if ( $conf['newcat_default_status'] == 'public' and $vag['set_private'] == 1 
-    and defined('IN_ADMIN') and IN_ADMIN and !function_exists( 'VAG_set_private' ) ) {
-  add_event_handler('get_admin_plugin_menu_links', 'VAG_set_private');
-  function VAG_set_private($menu) {
-    global $page, $conf;
-    if ( isset($page['page']) and $page['page'] != 'site_manager' )
-      $conf['newcat_default_status'] = 'private';
-    return $menu;
-  }
-} 
-// General case for set public (exception synchronisation (categories are not virtual ones))
-if ( $conf['newcat_default_status'] == 'private' and $vag['set_private'] == 0 
-    and defined('IN_ADMIN') and IN_ADMIN and !function_exists( 'VAG_set_public' ) ) {
-  add_event_handler('get_admin_plugin_menu_links', 'VAG_set_public');
-  function VAG_set_public($menu) {
-    global $page, $conf;
-    if ( isset($page['page']) and $page['page'] != 'site_manager' )
-      $conf['newcat_default_status'] = 'public';
-    return $menu;
-  }
-} 
-// General case for grant to someone
-// Don't grant on physical categories 
-if ( ($vag['grant_to_creator'] == 1 or $vag['grant_to_webmaster'] == 1)
-    and defined('IN_ADMIN') and IN_ADMIN and !function_exists( 'VAG_grant_to_prepare' ) ) {
-		add_event_handler('get_admin_plugin_menu_links', 'VAG_grant_to_prepare');
-  function VAG_grant_to_prepare($menu) {
-    global $conf, $page, $vag;
-    if ( !isset($page['page']) or $page['page'] == 'site_manager' ) return false; # Not Virtual
-    list($max_id) = pwg_db_fetch_row(pwg_query('SELECT MAX(id) FROM '.CATEGORIES_TABLE . ';'));
-    $vag['lastcat before'] == $max_id;
-    list($max_id) = pwg_db_fetch_row(pwg_query('SELECT MAX(id) FROM '.IMAGES_TABLE . ';'));
-    $vag['lastimg before'] == $max_id;
-    add_event_handler('loc_end_admin', 'VAG_grant_to_somebody');
-    return $menu;
-  }
-  if ( !function_exists( 'VAG_grant_to_somebody' ) ) {
-    function VAG_grant_to_somebody() {
-      global $conf, $vag, $user;
-      if ( empty($vag['lastcat before']) ) $vag['lastcat before'] = 0;
-      if ( empty($vag['lastimg before']) ) $vag['lastimg before'] = 0;
-      list($new_id) = pwg_db_fetch_row(pwg_query('SELECT MAX(id) FROM '.CATEGORIES_TABLE
-      . ' WHERE id > ' . $vag['lastcat before'] . ' AND site_id IS NULL;'));
-      if ( empty($newid) ) return false;
-      if ( $vag['grant_to_creator'] == 1 or $vag['grant_to_webmaster'] == 1 ) {
-        if ( $vag['grant_to_creator'] == 1 ) $insert[] = array('user_id' => $user['id'], 'cat_id' => $newid);
-        if ( $user['id'] != $conf['webmaster_id'] and $vag['grant_to_webmaster'] == 1 )
-          $insert[] = array('user_id' => $conf['webmaster_id'], 'cat_id' => $newid);
+// Internal case 
+if ( defined('IN_ADMIN') and IN_ADMIN and !function_exists( 'VAG_internal_add_case' ) ) {
+		add_event_handler('invalidate_user_cache', 'VAG_internal_add_case', 21 );
+  function VAG_internal_add_case($full) {
+    if ( !defined('PHOTOS_ADD_BASE_URL') ) return false; # Nothing else to do
+    global $conf, $user, $page, $category_id, $image_ids, $category_name;
+    load_language('plugin.lang', VAG_PATH);
+    $vag = & $conf['virtual_AutoGrant'];
+      # Note:  don't change it if existing
+    if ( 'new' == $_POST['category_type'] ) {
+      if ( $vag['set_private'] == 1 ) set_cat_status(array($category_id), 'private');
+        else set_cat_status(array($category_id), 'public');
+      if ( $vag['grant_to_creator'] == 1 ) $insert[] = array('user_id' => $user['id'], 'cat_id' => $category_id);
+      if ( $user['id'] != $conf['webmaster_id'] and $vag['grant_to_webmaster'] == 1 )
+        $insert[] = array('user_id' => $conf['webmaster_id'], 'cat_id' => $category_id);
+      if ( $vag['grant_to_creator'] == 1 or $vag['grant_to_webmaster'] == 1 and $vag['set_private'] == 1 )
         mass_inserts(USER_ACCESS_TABLE, array('user_id','cat_id'), $insert);
-      }
-      // Who can see
-      if ( $vag['set_who_can_see'] == 0 ) return false;
-      if ( is_webmaster() and $vag['webmaster_set_who_can_see'] == 1) return false;
-      // New image_ids
-      $img_ids = array_from_query('SELECT id FROM ' . IMAGES_TABLE . ' WHERE id > ' . $vag['lastimg before'] . ';', 'id');
-      if (count($img_ids) == 0) return false;
-      // New image_ids which are associated to a public category at least
-      if ($vag['ignore_who_can_see_on_private'] == 1)
-        $img_ids = array_from_query('SELECT image_id FROM ' . IMAGE_CATEGORY_TABLE 
-            . ' WHERE category_id IN (SELECT id FROM ' . CATEGORIES_TABLE . ' WHERE status = \'public\')'
-            . ' AND image_id IN ('.implode(',', $img_ids).');');
+      array_push( $page['infos'], sprintf( l10n('You have got a private access to %s'), '<em>'.$category_name.'</em>') );
+    }
+    // Who can see New image_ids
+    if (count($image_ids) == 0) return true;
+    if ( $vag['set_who_can_see'] == 0 ) return true;
+    if ( is_webmaster() and $vag['webmaster_set_who_can_see'] == 1) return true;
+    // New image_ids which are associated to a public category at least
+    if ($vag['ignore_who_can_see_on_private'] == 1)
+      $image_ids = array_from_query('SELECT image_id FROM ' . IMAGE_CATEGORY_TABLE 
+          . ' WHERE category_id IN (SELECT id FROM ' . CATEGORIES_TABLE . ' WHERE status = \'public\')'
+          . ' AND image_id IN ('.implode(',', $image_ids).');');
+    if (count($image_ids) > 0) { 
       $r = pwg_query('UPDATE '.IMAGES_TABLE.' SET level = ' . $user['level'] . ' WHERE level < '. $user['level'] 
-            . ' AND id IN ('.implode(',', $img_ids).');');
+            . ' AND id IN ('.implode(',', $image_ids).');');
+      array_push( $page['infos'], 
+        l10n_dec( 'Virtual AutoGrant has forced "Who can see" on %d image', 
+                  'Virtual AutoGrant has forced "Who can see" on %d images', 
+                  pwg_db_changes($r) ) . ' - ' .
+        sprintf( l10n('Privacy level set to "%s"'), l10n( sprintf('Level %d', $user['level']) ) )
+        );
     }
+    return true;
   }
 } 
 
 // API cases : Just do it   
-if ( !function_exists( 'VAG_set_private_by_API' ) ) {
-	add_event_handler('invalidate_user_cache', 'VAG_set_private_by_API', 20);
+if ( !function_exists( 'VAG_add_case_by_API' ) ) {
+	add_event_handler('invalidate_user_cache', 'VAG_add_case_by_API', 22 );
 
-	function  VAG_set_private_by_API($full) {
+	function  VAG_add_case_by_API($full) {
     if ( !function_exists( 'ws_categories_add' ) ) return false; // That isn't an API request
 	  global $user, $conf;
@@ -94,5 +67,4 @@
         mass_inserts(USER_ACCESS_TABLE, array('user_id','cat_id'), $insert);
       }
-      $vag['lastcat before'] = $inserted_id; # Admin Photos Add does not need to redo the job
     }
     // "Who can see" management ( only for API, Synchro or old HTTP management on gallery side are ignored )
@@ -129,4 +101,5 @@
 		add_event_handler('get_admin_plugin_menu_links', 'VAG_admin_menu');
     function VAG_admin_menu($menu) {
+        global $conf;
         array_push($menu, array(
                 'NAME' => 'Virtual AutoGrant',
