Index: /extensions/virtualAutoGrant/language/en_UK/description.txt
===================================================================
--- /extensions/virtualAutoGrant/language/en_UK/description.txt	(revision 6603)
+++ /extensions/virtualAutoGrant/language/en_UK/description.txt	(revision 6603)
@@ -0,0 +1,1 @@
+For external uploaders (API usage), Virtual AutoGrant forces added virtual categories as 'private', grants access only to creator, and set "Who can see these photos?" to creator's privacy level at least (except webmaster).
Index: /extensions/virtualAutoGrant/language/fr_FR/description.txt
===================================================================
--- /extensions/virtualAutoGrant/language/fr_FR/description.txt	(revision 6603)
+++ /extensions/virtualAutoGrant/language/fr_FR/description.txt	(revision 6603)
@@ -0,0 +1,1 @@
+Pour les uploaders externes (via l'API), Virtual AutoGrant passe les catégories virtuelles ajoutées en 'private', autorise les accès uniquement au créateur, et positionne "Qui peut voir ces photos ?" au niveau de confidentialité du créateur au minimum (exception faite du webmaster).
Index: /extensions/virtualAutoGrant/main.inc.php
===================================================================
--- /extensions/virtualAutoGrant/main.inc.php	(revision 6603)
+++ /extensions/virtualAutoGrant/main.inc.php	(revision 6603)
@@ -0,0 +1,16 @@
+<?php
+/*
+Plugin Name: Virtual AutoGrant
+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
+Author: VDigital
+Author URI: http://piwigo.org/
+*/
+
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+define('VAG_DIR' , basename(dirname(__FILE__)));
+define('VAG_PATH' , PHPWG_PLUGINS_PATH . VAG_DIR . '/');
+define('VAG_VER' , '2.1.a');
+include_once( VAG_PATH . 'virtual_categories_granted_to_creator.php');
+?>
Index: /extensions/virtualAutoGrant/virtual_categories_granted_to_creator.php
===================================================================
--- /extensions/virtualAutoGrant/virtual_categories_granted_to_creator.php	(revision 6603)
+++ /extensions/virtualAutoGrant/virtual_categories_granted_to_creator.php	(revision 6603)
@@ -0,0 +1,30 @@
+<?php
+/* Virtual AutoGrant */
+if (!defined('PHPWG_ROOT_PATH') or !defined('VAG_DIR')) die('Hacking attempt!');
+if ( !function_exists( 'virtual_categories_granted_to_creator' ) ) {
+	add_event_handler('invalidate_user_cache', 'virtual_categories_granted_to_creator', 20);
+
+	function  virtual_categories_granted_to_creator($full) {
+    if ( !function_exists( 'ws_categories_add' ) ) return false;
+	  global $user, $conf;
+    if ( $_REQUEST['method'] == 'pwg.categories.add' ) {
+      list($inserted_id) = pwg_db_fetch_row(pwg_query('SELECT MAX(id) FROM '.CATEGORIES_TABLE
+      . ' WHERE name = \'' .pwg_db_real_escape_string($_REQUEST['name']) . '\';'));
+      set_cat_status(array($inserted_id), 'private');      
+      $insert[] = array('user_id' => $user['id'], 'cat_id' => $inserted_id);
+      $insert[] = array('user_id' => $conf['webmaster_id'], 'cat_id' => $inserted_id);
+      mass_inserts(USER_ACCESS_TABLE, array('user_id','cat_id'), $insert);
+    }
+    if ( $_REQUEST['method'] == 'pwg.images.add' and isset($_REQUEST['original_sum']) ) {
+      # image to update
+      if ('md5sum' == $conf['uniqueness_mode']) $where_clause = "md5sum = '".pwg_db_real_escape_string($_REQUEST['original_sum'])."'";
+      if ('filename' == $conf['uniqueness_mode'] and isset($_REQUEST['original_filename']) ) 
+          $where_clause = "file = '".pwg_db_real_escape_string($_REQUEST['original_filename'])."'";
+      if ( !isset($where_clause) or is_webmaster() ) return false;
+      if ( $user['level'] == $conf['available_permission_levels'][0] ) return false;    
+      $r = pwg_query('UPDATE '.IMAGES_TABLE.' SET level = ' . $user['level'] . ' WHERE level < '. $user['level'] 
+          .' AND ' . $where_clause . ';');
+    }
+	}
+}
+?>
