Index: /extensions/properties_mass_update/admin.php
===================================================================
--- /extensions/properties_mass_update/admin.php	(revision 15389)
+++ /extensions/properties_mass_update/admin.php	(revision 15389)
@@ -0,0 +1,97 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based picture gallery                                  |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2012      Pierrick LE GALL   http://le-gall.net/pierrick |
+// +-----------------------------------------------------------------------+
+// | 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
+// +-----------------------------------------------------------------------+
+
+if( !defined("PHPWG_ROOT_PATH") )
+{
+  die ("Hacking attempt!");
+}
+
+include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
+include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
+load_language('plugin.lang', PPMU_PATH);
+
+$base_url = get_root_url().'admin.php?page=plugin-properties_mass_update';
+
+// +-----------------------------------------------------------------------+
+// | Check Access and exit when user status is not ok                      |
+// +-----------------------------------------------------------------------+
+
+check_status(ACCESS_ADMINISTRATOR);
+
+// +-----------------------------------------------------------------------+
+// | Tabs                                                                  |
+// +-----------------------------------------------------------------------+
+
+$tabs = array(
+  array(
+    'code' => 'update',
+    'label' => l10n('Update'),
+    ),
+  );
+
+$tab_codes = array_map(
+  create_function('$a', 'return $a["code"];'),
+  $tabs
+  );
+
+if (isset($_GET['tab']) and in_array($_GET['tab'], $tab_codes))
+{
+  $page['tab'] = $_GET['tab'];
+}
+else
+{
+  $page['tab'] = $tabs[0]['code'];
+}
+
+$tabsheet = new tabsheet();
+foreach ($tabs as $tab)
+{
+  $tabsheet->add(
+    $tab['code'],
+    $tab['label'],
+    $base_url.'-'.$tab['code']
+    );
+}
+$tabsheet->select($page['tab']);
+$tabsheet->assign();
+
+// +-----------------------------------------------------------------------+
+// |                             template init                             |
+// +-----------------------------------------------------------------------+
+
+$template->set_filenames(
+  array(
+    'plugin_admin_content' => dirname(__FILE__).'/admin_'.$page['tab'].'.tpl'
+    )
+  );
+
+// +-----------------------------------------------------------------------+
+// |                             Load the tab                              |
+// +-----------------------------------------------------------------------+
+
+include(PPMU_PATH.'admin_'.$page['tab'].'.php');
+
+// +-----------------------------------------------------------------------+
+// | sending html code                                                     |
+// +-----------------------------------------------------------------------+
+
+$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
+?>
Index: /extensions/properties_mass_update/admin_update.php
===================================================================
--- /extensions/properties_mass_update/admin_update.php	(revision 15389)
+++ /extensions/properties_mass_update/admin_update.php	(revision 15389)
@@ -0,0 +1,152 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based picture gallery                                  |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2012     Pierrick LE GALL    http://le-gall.net/pierrick |
+// +-----------------------------------------------------------------------+
+// | 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
+// +-----------------------------------------------------------------------+
+
+if( !defined("PHPWG_ROOT_PATH") )
+{
+  die ("Hacking attempt!");
+}
+
+include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
+include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php');
+
+$admin_base_url = get_root_url().'admin.php?page=plugin-properties_mass_update-update';
+
+// +-----------------------------------------------------------------------+
+// | Check Access and exit when user status is not ok                      |
+// +-----------------------------------------------------------------------+
+
+check_status(ACCESS_ADMINISTRATOR);
+
+// +-----------------------------------------------------------------------+
+// |                                actions                                |
+// +-----------------------------------------------------------------------+
+
+if (isset($_FILES) and !empty($_FILES['update']))
+{
+  $starttime = get_moment();
+  
+  if (UPLOAD_ERR_OK == $_FILES['update']['error'])
+  {
+    if ('text/plain' == $_FILES['update']['type'])
+    {
+      $text_file = $_FILES['update']['tmp_name'];
+    }
+    else
+    {
+      array_push($page['errors'], l10n('Wrong file, please select a plain text file'));
+    }
+
+    if (isset($text_file))
+    {
+      $raw = file_get_contents($text_file);
+      $raw_lines = explode("\n", $raw);
+      
+      $query = 'SELECT file FROM '.IMAGES_TABLE.';';
+      $existing_files = hash_from_query($query, 'file');
+            
+      $updates = array();
+      $update_files = array();
+      $missing_files = array();
+      
+      foreach ($raw_lines as $raw_line)
+      {
+        if (!preg_match('/^([^\t]+)\t+(.*)$/', $raw_line, $matches))
+        {
+          continue;
+        }
+        
+        // in case the same file is defined twice, we only save the first occurence
+        if (isset($update_files[$matches[1]]) or isset($missing_files[$matches[1]]))
+        {
+          continue;
+        }
+
+        if (isset($existing_files[$matches[1]]))
+        {        
+          $update_files[$matches[1]] = true;
+        }
+        else
+        {
+          $missing_files[$matches[1]] = true;
+          continue;
+        }
+        
+        array_push(
+          $updates,
+          array(
+            'file' => pwg_db_real_escape_string($matches[1]),
+            'comment' => pwg_db_real_escape_string($matches[2]), // TODO right trim
+            )
+          );
+      }
+      
+      mass_updates(
+        IMAGES_TABLE,
+          array(
+            'primary' => array('file'),
+            'update' => array('comment'),
+          ),
+          $updates
+        );
+
+      $endtime = get_moment();
+      $elapsed = ($endtime - $starttime);
+
+      array_push(
+        $page['infos'],
+        sprintf(
+          l10n('%d photos updated'),
+          count($updates)
+          )
+        );
+      
+      if (count($missing_files) > 0)
+      {
+        array_push(
+          $page['errors'],
+          sprintf(
+            l10n('%d photos are missing in Piwigo: %s'),
+            count($missing_files),
+            implode(', ', array_keys($missing_files))
+            )
+          );
+      }
+    }
+  }
+  else
+  {
+    array_push($page['errors'], $_FILES['mascarille_update']['error']);
+  }
+}
+
+// +-----------------------------------------------------------------------+
+// | form options                                                          |
+// +-----------------------------------------------------------------------+
+
+// image level options
+$selected_level = isset($_POST['level']) ? $_POST['level'] : 0;
+$template->assign(
+    array(
+      'level_options'=> get_privacy_level_options(),
+      'level_options_selected' => array($selected_level)
+    )
+  );
+?>
Index: /extensions/properties_mass_update/admin_update.tpl
===================================================================
--- /extensions/properties_mass_update/admin_update.tpl	(revision 15389)
+++ /extensions/properties_mass_update/admin_update.tpl	(revision 15389)
@@ -0,0 +1,17 @@
+<div class="titrePage">
+  <h2>{'Send File - Photo Properties Mass Update'|@translate}</h2>
+</div>
+
+<form method="post" action="{$F_ACTION}" enctype="multipart/form-data">
+<fieldset>
+  <legend>{'Text file'|@translate}</legend>
+  <p style="margin:0 0 15px 0; text-align:left;"><strong>{'File pattern'|@translate}</strong><br>
+  img_001.jpg&lt;Tab&gt;{'Photo description, until the end of the line'|@translate}<br>
+  IMG_002.JPG&lt;Tab&gt;{'Description for another photo'|@translate}
+  </p>
+<input type="file" name="update">
+<p style="text-align:left">
+<input class="submit" type="submit" name="validate" value="{'Submit'|@translate}">
+</p>
+</fieldset>
+</form>
Index: /extensions/properties_mass_update/language/en_UK/description.txt
===================================================================
--- /extensions/properties_mass_update/language/en_UK/description.txt	(revision 15389)
+++ /extensions/properties_mass_update/language/en_UK/description.txt	(revision 15389)
@@ -0,0 +1,1 @@
+Mise à jour de propriétés de plusieurs photos à la fois par l'import d'un fichier texte
Index: /extensions/properties_mass_update/language/en_UK/index.php
===================================================================
--- /extensions/properties_mass_update/language/en_UK/index.php	(revision 15389)
+++ /extensions/properties_mass_update/language/en_UK/index.php	(revision 15389)
@@ -0,0 +1,30 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based picture gallery                                  |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2008-2009 Piwigo Team                  http://piwigo.org |
+// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
+// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
+// +-----------------------------------------------------------------------+
+// | 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
+// +-----------------------------------------------------------------------+
+
+// Recursive call
+$url = '../';
+header( 'Request-URI: '.$url );
+header( 'Content-Location: '.$url );
+header( 'Location: '.$url );
+exit();
+?>
Index: /extensions/properties_mass_update/language/en_UK/plugin.lang.php
===================================================================
--- /extensions/properties_mass_update/language/en_UK/plugin.lang.php	(revision 15389)
+++ /extensions/properties_mass_update/language/en_UK/plugin.lang.php	(revision 15389)
@@ -0,0 +1,11 @@
+<?php
+$lang['Send File - Photo Properties Mass Update'] = 'Send File - Photo Properties Mass Update';
+$lang['Text file'] = 'Text file';
+$lang['File pattern'] = 'File pattern';
+$lang['Photo description, until the end of the line'] = 'Photo description, until the end of the line';
+$lang['Description for another photo'] = 'Description for another photo';
+$lang['%d photos updated'] = '%d photos updated';
+$lang['%d photos are missing in Piwigo: %s'] = '%d photos are missing in Piwigo: %s';
+$lang['Wrong file, please select a plain text file'] = 'Wrong file, please select a plain text file';
+$lang['Update'] = 'Update';
+?>
Index: /extensions/properties_mass_update/language/fr_FR/description.txt
===================================================================
--- /extensions/properties_mass_update/language/fr_FR/description.txt	(revision 15389)
+++ /extensions/properties_mass_update/language/fr_FR/description.txt	(revision 15389)
@@ -0,0 +1,1 @@
+Ajouter le lien vers la page about en menu de niveau 1
Index: /extensions/properties_mass_update/language/fr_FR/index.php
===================================================================
--- /extensions/properties_mass_update/language/fr_FR/index.php	(revision 15389)
+++ /extensions/properties_mass_update/language/fr_FR/index.php	(revision 15389)
@@ -0,0 +1,30 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based picture gallery                                  |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2008-2009 Piwigo Team                  http://piwigo.org |
+// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
+// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
+// +-----------------------------------------------------------------------+
+// | 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
+// +-----------------------------------------------------------------------+
+
+// Recursive call
+$url = '../';
+header( 'Request-URI: '.$url );
+header( 'Content-Location: '.$url );
+header( 'Location: '.$url );
+exit();
+?>
Index: /extensions/properties_mass_update/language/index.php
===================================================================
--- /extensions/properties_mass_update/language/index.php	(revision 15389)
+++ /extensions/properties_mass_update/language/index.php	(revision 15389)
@@ -0,0 +1,30 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based picture gallery                                  |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2008-2009 Piwigo Team                  http://piwigo.org |
+// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
+// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
+// +-----------------------------------------------------------------------+
+// | 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
+// +-----------------------------------------------------------------------+
+
+// Recursive call
+$url = '../';
+header( 'Request-URI: '.$url );
+header( 'Content-Location: '.$url );
+header( 'Location: '.$url );
+exit();
+?>
Index: /extensions/properties_mass_update/main.inc.php
===================================================================
--- /extensions/properties_mass_update/main.inc.php	(revision 15389)
+++ /extensions/properties_mass_update/main.inc.php	(revision 15389)
@@ -0,0 +1,34 @@
+<?php
+/*
+Plugin Name: Properties Mass Update
+Version: auto
+Description: Update many photo properties at once
+Plugin URI: 
+Author: plg
+Author URI: http://piwigo.org
+*/
+
+if (!defined('PHPWG_ROOT_PATH'))
+{
+  die('Hacking attempt!');
+}
+
+define('PPMU_PATH', PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
+
+/* Plugin admin */
+add_event_handler('get_admin_plugin_menu_links', 'ppmu_admin_menu');
+function ppmu_admin_menu($menu)
+{
+  global $page;
+  
+  array_push(
+    $menu,
+    array(
+      'NAME' => 'Properties Mass Update',
+      'URL'  => get_root_url().'admin.php?page=plugin-properties_mass_update'
+      )
+    );
+
+  return $menu;
+}
+?>
