Index: extensions/NBC_UserAdvManager/trunk/include/functions.inc.php
===================================================================
--- extensions/NBC_UserAdvManager/trunk/include/functions.inc.php	(revision 5056)
+++ extensions/NBC_UserAdvManager/trunk/include/functions.inc.php	(revision 5064)
@@ -7,11 +7,5 @@
 {
   /* Only available for next Piwigo release (bug in switch_lang function) */
-  //global $conf;
-  
-  /* ****************************************************************** */
-  /* Delete this after new Piwigo release (bug in switch_lang function) */
-  global $conf, $user;
-  $save_user = $user; 
-  /* ****************************************************************** */
+  global $conf;
 
   $conf_UAM = unserialize($conf['nbc_UserAdvManager']);
@@ -122,8 +116,4 @@
 
 /* Switching back to default language */
-  /* ****************************************************************** */
-  /* Delete this after new Piwigo release (bug in switch_lang function) */
-$user=$save_user ;
-  /* ****************************************************************** */
 switch_lang_back();
 }
@@ -134,11 +124,5 @@
 {
   /* Only available for next Piwigo release (bug in switch_lang function) */
-  //global $conf;
-  
-  /* ****************************************************************** */
-  /* Delete this after new Piwigo release (bug in switch_lang function) */
-  global $conf, $user;
-  $save_user = $user; 
-  /* ****************************************************************** */
+  global $conf;
 
   $conf_UAM = unserialize($conf['nbc_UserAdvManager']);
@@ -234,8 +218,4 @@
 
 /* Switching back to default language */
-  /* ****************************************************************** */
-  /* Delete this after new Piwigo release (bug in switch_lang function) */
-$user=$save_user ;
-  /* ****************************************************************** */
 switch_lang_back();
 }
@@ -246,11 +226,5 @@
 {
   /* Only available for next Piwigo release (bug in switch_lang function) */
-  //global $conf;
-  
-  /* ****************************************************************** */
-  /* Delete this after new Piwigo release (bug in switch_lang function) */
-  global $conf, $user;
-  $save_user = $user; 
-  /* ****************************************************************** */
+  global $conf;
 
   $conf_UAM = unserialize($conf['nbc_UserAdvManager']);
@@ -306,8 +280,4 @@
 
 /* Switching back to default language */
-  /* ****************************************************************** */
-  /* Delete this after new Piwigo release (bug in switch_lang function) */
-$user=$save_user ;
-  /* ****************************************************************** */
 switch_lang_back();
 }
@@ -500,5 +470,5 @@
 
 /*              Time limit process              */
-/* ****************** begin ******************* */  
+/* ******************************************** */  
       if (!empty($registration_date))
       {
@@ -985,5 +955,5 @@
 
 /*              Time limit process              */
-/* ****************** begin ******************* */  
+/* ******************************************** */  
 	if (!empty($registration_date))
   {
@@ -1106,5 +1076,5 @@
    fwrite($fo, 'Langue : '."\n" . $language . "\r\n") ;
    fclose($fo) ;
- //return mail ($to,$subject) ;
+   //return mail ($to,$subject) ;
 }
 
@@ -1155,47 +1125,21 @@
 }
 
-/* Funtion called in maintain.inc.php to clean obsolete files */
-function clean_obsolete_files($obsolete_file_list)
-{
-  if (!file_exists(NBC_UAM_PATH.$obsolete_file_list))
-  {
-    return TRUE;
-  }
-  $obsolete = file(NBC_UAM_PATH.$obsolete_file_list);
-  array_push($obsolete, $obsolete_file_list);
-  return clean_obsolete_list($obsolete);
-}
-
-function clean_obsolete_list($file_list = array(), &$errors = array())
-{
-  if (!function_exists('unlink'))
-  {
-      // No unlink available...
-      array_push($errors, l10n('uam_no_unlink'));
-      return FALSE;
-  }
-  $success = TRUE;
-  foreach ($file_list as $file)
-  {
-    $file = NBC_UAM_PATH . $file;
-  $to = '';
-  $subject ='';
-  $language = '';
-  MailLog  ($to, $subject, $file, $language);
-    //if (file_exists($file))
-    //{
-      // Remove obsolete file
-      $success &= unlink($file);
-  $to = '';
-  $subject ='';
-  $language = '';
-  MailLog  ($to, $subject, $file, $success);
-    //}
-  }
-  if (!$success)
-  {
-      array_push($errors, l10n('uam_unlink_errors'));
-  }
-  return $success;
+
+function clean_obsolete_files()
+{
+  if (file_exists(NBC_UAM_PATH.'obsolete.list')
+    and $old_files = file(NBC_UAM_PATH.'obsolete.list', FILE_IGNORE_NEW_LINES)
+    and !empty($old_files))
+  {
+    array_push($old_files, 'obsolete.list');
+    foreach($old_files as $old_file)
+    {
+      $path = NBC_UAM_PATH.$old_file;
+      if (is_file($path))
+      {
+        @unlink($path);
+      }
+    }
+  }
 }
 ?>
