Index: /extensions/NBC_UserAdvManager/trunk/admin/UAM_admin.php
===================================================================
--- /extensions/NBC_UserAdvManager/trunk/admin/UAM_admin.php	(revision 9134)
+++ /extensions/NBC_UserAdvManager/trunk/admin/UAM_admin.php	(revision 9135)
@@ -105,5 +105,5 @@
   case 'global':
 
-	if (isset($_POST['submit']) and isset($_POST['UAM_Mail_Info']) and isset($_POST['UAM_Username_Char']) and isset($_POST['UAM_Confirm_Mail']) and isset($_POST['UAM_No_Comment_Anonymous']) and isset($_POST['UAM_Password_Enforced']) and isset($_POST['UAM_AdminPassword_Enforced']) and isset($_POST['UAM_GhostUser_Tracker']) and isset($_POST['UAM_Admin_ConfMail']) and isset($_POST['UAM_RedirToProfile']) and isset($_POST['UAM_GTAuto']))
+	if (isset($_POST['submit']) and isset($_POST['UAM_Mail_Info']) and isset($_POST['UAM_Username_Char']) and isset($_POST['UAM_Confirm_Mail']) and isset($_POST['UAM_No_Comment_Anonymous']) and isset($_POST['UAM_Password_Enforced']) and isset($_POST['UAM_AdminPassword_Enforced']) and isset($_POST['UAM_GhostUser_Tracker']) and isset($_POST['UAM_Admin_ConfMail']) and isset($_POST['UAM_RedirToProfile']) and isset($_POST['UAM_GTAuto']) and isset($_POST['UAM_CustomPasswRetr']))
   {
 
@@ -118,6 +118,8 @@
 
     $_POST['UAM_GTAutoMailText'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_GTAutoMailText'])));
-    
+
     $_POST['UAM_AdminValidationMail_Text'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_AdminValidationMail_Text'])));
+
+    $_POST['UAM_CustomPasswRetr_Text'] = str_replace('\"', '"', str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UAM_CustomPasswRetr_Text'])));
 
     //Check if CR-LF exist at begining and end of mail exclusion list - If yes, removes them
@@ -167,5 +169,7 @@
       (isset($_POST['UAM_Downgrade_Group'])?$_POST['UAM_Downgrade_Group']:''),
       (isset($_POST['UAM_Downgrade_Status'])?$_POST['UAM_Downgrade_Status']:''),
-      $_POST['UAM_AdminValidationMail_Text']
+      $_POST['UAM_AdminValidationMail_Text'],
+      $_POST['UAM_CustomPasswRetr'],
+      $_POST['UAM_CustomPasswRetr_Text']
       );
 
@@ -405,4 +409,7 @@
 		'UAM_Downgrade_Status'           => $conf_UAM[27],
     'UAM_ADMINVALIDATIONMAIL_TEXT'   => $conf_UAM[28],
+    'UAM_CUSTOMPASSWRETR_TRUE'       => $conf_UAM[29]=='true' ?  'checked="checked"' : '' ,
+    'UAM_CUSTOMPASSWRETR_FALSE'      => $conf_UAM[29]=='false' ?  'checked="checked"' : '' ,
+    'UAM_CUSTOMPASSWRETR_TEXT'       => $conf_UAM[30],
 		'UAM_PASSWORD_TEST_SCORE'        => $UAM_Password_Test_Score,
     'UAM_ERROR_REPORTS4'             => $UAM_Exclusionlist_Error,
Index: /extensions/NBC_UserAdvManager/trunk/admin/template/global.tpl
===================================================================
--- /extensions/NBC_UserAdvManager/trunk/admin/template/global.tpl	(revision 9134)
+++ /extensions/NBC_UserAdvManager/trunk/admin/template/global.tpl	(revision 9135)
@@ -514,4 +514,14 @@
             <input type="radio" value="true" {$UAM_REDIRTOPROFILE_TRUE} name="UAM_RedirToProfile">{'UAM_RedirToProfile_true'|@translate}<br><br>
           </li>
+
+          <br><hr><br>
+
+          <li><label class="cluetip" title="{'UAM_CustomPasswRetrTitle'|translate}|{'UAM_CustomPasswRetrTitle_d'|translate}">{'UAM_CustomPasswRetr'|@translate}</label><br><br>
+            <input type="radio" value="false" {$UAM_CUSTOMPASSWRETR_FALSE} name="UAM_CustomPasswRetr">{'UAM_CustomPasswRetr_false'|@translate}<br>
+            <input type="radio" value="true" {$UAM_CUSTOMPASSWRETR_TRUE} name="UAM_CustomPasswRetr">{'UAM_CustomPasswRetr_true'|@translate}<br>
+          <br><br>
+            <textarea class="uam_textfields" name="UAM_CustomPasswRetr_Text" id="UAM_CustomPasswRetr_Text" rows="10" {$TAG_INPUT_ENABLED}>{$UAM_CUSTOMPASSWRETR_TEXT}</textarea>
+          <br><br>
+          </li>
         </ul>
       </fieldset>
Index: /extensions/NBC_UserAdvManager/trunk/changelog.txt.php
===================================================================
--- /extensions/NBC_UserAdvManager/trunk/changelog.txt.php	(revision 9134)
+++ /extensions/NBC_UserAdvManager/trunk/changelog.txt.php	(revision 9135)
@@ -219,4 +219,13 @@
             Add of Latvian (lv_LV) translation (Thx to Aivars Baldone)
 
+**************************************************************
+***** Plugin history (branch 2.20 - Piwigo 2.2 compliant)*****
+**************************************************************
+-- 2.20.0 : Compliance with Piwigo 2.2
+            Bug 1666 fixed - Customizing "lost password" email
+            Bug 2072 fixed - Remove sort on "difference in days" in user tracking tab
+            Bug 2140 fixed - English sentence corrections
+            Bug 
+
 */
 ?>
Index: /extensions/NBC_UserAdvManager/trunk/include/functions.inc.php
===================================================================
--- /extensions/NBC_UserAdvManager/trunk/include/functions.inc.php	(revision 9134)
+++ /extensions/NBC_UserAdvManager/trunk/include/functions.inc.php	(revision 9135)
@@ -636,4 +636,32 @@
 }
 
+
+/**
+ * Triggered on render_lost_password_mail_content
+ * 
+ * Adds a customized text in lost password email content
+ * Added text is inserted before users login name and new password
+ *
+ * @param : Standard Piwigo email content
+ * 
+ * @return : Customized content added to standard content
+ * 
+ */
+function UAM_lost_password_mail_content($infos)
+{
+  global $conf;
+  
+  load_language('plugin.lang', UAM_PATH);
+  
+  $conf_UAM = unserialize($conf['UserAdvManager']);
+  
+  if (isset($conf_UAM[29]) and $conf_UAM[29] == 'true')
+  {
+    $infos = $conf_UAM[30]."\n"."\n".$infos;
+  }
+  return $infos;
+}
+
+
 /**
  * Triggered on user_comment_check
Index: /extensions/NBC_UserAdvManager/trunk/include/upgradedb.inc.php
===================================================================
--- /extensions/NBC_UserAdvManager/trunk/include/upgradedb.inc.php	(revision 9134)
+++ /extensions/NBC_UserAdvManager/trunk/include/upgradedb.inc.php	(revision 9135)
@@ -312,3 +312,49 @@
   pwg_query($query);
 }
+
+
+/* upgrade from 2.16.x to 2.20.0 */
+/* ***************************** */
+function upgrade_216_220()
+{
+  global $conf;
+
+  $uam_new_version = "2.20.0";
+
+  // Upgrading options
+  $query = '
+SELECT value
+  FROM '.CONFIG_TABLE.'
+WHERE param = "UserAdvManager"
+;';
+
+  $result = pwg_query($query);
+  $conf_UAM = pwg_db_fetch_assoc($result);
+    
+  $Newconf_UAM = unserialize($conf_UAM['value']);
+  
+  $Newconf_UAM[29] = 'false';
+  $Newconf_UAM[30] = 'You have requested a password reset on our gallery. Please, find below your new connection settings.';
+  
+  $update_conf = serialize($Newconf_UAM);
+    
+  $query = '
+UPDATE '.CONFIG_TABLE.'
+SET value="'.addslashes($update_conf).'"
+WHERE param="UserAdvManager"
+LIMIT 1
+;';
+
+	pwg_query($query);
+
+  // Update plugin version 
+  $query = '
+UPDATE '.CONFIG_TABLE.'
+SET value="'.$uam_new_version.'"
+WHERE param="UserAdvManager_Version"
+LIMIT 1
+;';
+  
+  pwg_query($query);
+}
 ?>
Index: /extensions/NBC_UserAdvManager/trunk/main.inc.php
===================================================================
--- /extensions/NBC_UserAdvManager/trunk/main.inc.php	(revision 9134)
+++ /extensions/NBC_UserAdvManager/trunk/main.inc.php	(revision 9135)
@@ -49,4 +49,6 @@
 add_event_handler('login_success', 'UAM_LoginTasks');
 
+// Adding customized text to lost password email
+add_event_handler('render_lost_password_mail_content', 'UAM_lost_password_mail_content');
 
 // *** Important ! This is necessary to make email exclusion work in admin's users management panel ***
Index: /extensions/NBC_UserAdvManager/trunk/maintain.inc.php
===================================================================
--- /extensions/NBC_UserAdvManager/trunk/maintain.inc.php	(revision 9134)
+++ /extensions/NBC_UserAdvManager/trunk/maintain.inc.php	(revision 9135)
@@ -26,5 +26,5 @@
 Best regards,
 
-The admin of the gallery.','false','false','false','false','false','Sorry, your account has been deleted due to a too long time passed since your last visit.','Sorry, your account has been deprecated due to a too long time passed since your last visit. Please, use the following link to revalidate your account.',-1,-1,'Thank you for registering at _name_of_site_. Your account has been manually validated by _admin_. You may now log in at _link_to_site_ and make any appropriate changes to your profile. Welcome to _name_of_site_!');
+The admin of the gallery.','false','false','false','false','false','Sorry, your account has been deleted due to a too long time passed since your last visit.','Sorry, your account has been deprecated due to a too long time passed since your last visit. Please, use the following link to revalidate your account.',-1,-1,'Thank you for registering at _name_of_site_. Your account has been manually validated by _admin_. You may now log in at _link_to_site_ and make any appropriate changes to your profile. Welcome to _name_of_site_!','false','You have requested a password reset on our gallery. Please, find below your new connection settings.');
 
   $q = '
@@ -196,4 +196,21 @@
   }
 
+/* Check for upgrade from 2.16 to 2.20 */
+/* *********************************** */
+	$query = '
+SELECT value
+  FROM '.CONFIG_TABLE.'
+WHERE param = "UserAdvManager_Version"
+;';
+
+  $data = pwg_db_fetch_assoc(pwg_query($query));
+  
+  if ($data['value'] != '2.20.0')
+  {
+    /* upgrade from branch 2.16 to 2.20 */
+    /* ******************************** */
+    upgrade_216_220();
+  }
+
 load_conf_from_db('param like \'UserAdvManager\\_%\'');
 }
