Index: /extensions/flickr2piwigo/admin/config.php
===================================================================
--- /extensions/flickr2piwigo/admin/config.php	(revision 16070)
+++ /extensions/flickr2piwigo/admin/config.php	(revision 16071)
@@ -7,5 +7,4 @@
     'api_key' => trim($_POST['api_key']),
     'secret_key' => trim($_POST['secret_key']),
-    'username' => trim($_POST['username']),
     );
   unset($_SESSION['phpFlickr_auth_token']);
@@ -14,14 +13,12 @@
 
 
-$template->assign('flickr2piwigo', $conf['flickr2piwigo']);
-
 $template->assign(array(
+  'flickr2piwigo' => $conf['flickr2piwigo'],
   'FLICKR_HELP_CONTENT' => load_language('help_api_key.html', FLICKR_PATH, array('return'=>true)),
-  'FLICKR_CALLBACK' => get_absolute_root_url().FLICKR_ADMIN.'-import',
+  'FLICKR_CALLBACK' => get_absolute_root_url() . FLICKR_ADMIN . '-import',
   ));
 
 
-$template->set_filename('flickr2piwigo', dirname(__FILE__).'/template/config.tpl');
-
+$template->set_filename('flickr2piwigo', dirname(__FILE__) . '/template/config.tpl');
 
 ?>
Index: /extensions/flickr2piwigo/admin/import.php
===================================================================
--- /extensions/flickr2piwigo/admin/import.php	(revision 16070)
+++ /extensions/flickr2piwigo/admin/import.php	(revision 16071)
@@ -3,5 +3,5 @@
 
 // check API parameters and connect to flickr
-if (empty($conf['flickr2piwigo']['api_key']) or empty($conf['flickr2piwigo']['secret_key']) or empty($conf['flickr2piwigo']['username']))
+if ( empty($conf['flickr2piwigo']['api_key']) or empty($conf['flickr2piwigo']['secret_key']) )
 {
   array_push($page['warnings'], l10n('Please fill your API keys on the configuration tab'));
@@ -16,19 +16,9 @@
   
   // must authenticate
-  if (empty($_SESSION['phpFlickr_auth_token']) and @$_GET['action']!='login')
+  $u = $flickr->test_login();
+  if ( ($u === false or empty($_SESSION['phpFlickr_auth_token'])) and @$_GET['action']!='login' )
   {
     $_GET['action'] = 'init_login';
   }
-  else
-  {
-    // get user id
-    $u = $flickr->people_findByUsername($conf['flickr2piwigo']['username']);
-    if ($u === false)
-    {
-      array_push($page['errors'], l10n('Unknown username, please verify your configuration'));
-      $_GET['action'] = 'error';
-    }
-  }
-  
   
   // generate token after authentication
@@ -48,5 +38,5 @@
   case 'init_login':
   {
-    $template->assign('flickr_login', FLICKR_ADMIN.'-import&amp;action=login');
+    $template->assign('flickr_login', FLICKR_ADMIN . '-import&amp;action=login');
     break;
   }
@@ -63,5 +53,5 @@
   {
     $_SESSION['page_infos'][] = l10n('Successfully logued to you Flickr account');
-    redirect(FLICKR_ADMIN.'-import');
+    redirect(FLICKR_ADMIN . '-import');
     break;
   }
@@ -72,5 +62,5 @@
     unset($_SESSION['phpFlickr_auth_token']);
     $_SESSION['page_infos'][] = l10n('Logued out');
-    redirect(FLICKR_ADMIN.'-import');
+    redirect(FLICKR_ADMIN . '-import');
     break;
   }
@@ -81,9 +71,9 @@
     $u = $flickr->people_getInfo($u['id']);
     $template->assign(array(
-      'username' => $conf['flickr2piwigo']['username'],
-      'profile_url' => $u['photosurl'],
-      'logout_url' => FLICKR_ADMIN.'-import&amp;action=logout',
-      'list_albums_url' => FLICKR_ADMIN.'-import&amp;action=list_albums',
-      'import_all_url' => FLICKR_ADMIN.'-import&amp;action=list_all',
+      'username' => $u['username'],
+      'profile_url' => $u['profileurl'],
+      'logout_url' => FLICKR_ADMIN . '-import&amp;action=logout',
+      'list_albums_url' => FLICKR_ADMIN . '-import&amp;action=list_albums',
+      'import_all_url' => FLICKR_ADMIN . '-import&amp;action=list_all',
       ));
     break;
@@ -100,6 +90,5 @@
     foreach ($albums as &$album)
     {
-      //$album['U_IMPORT_ALL'] = FLICKR_ADMIN.'-import&amp;action=import_album&amp;album='.$album['id'];
-      $album['U_LIST'] = FLICKR_ADMIN.'-import&amp;action=list_photos&amp;album='.$album['id'];
+      $album['U_LIST'] = FLICKR_ADMIN . '-import&amp;action=list_photos&amp;album='.$album['id'];
     }
     unset($album);
@@ -114,6 +103,5 @@
         'description' => null,
         'photos' => $wo_albums['photos']['total'],
-        //'U_IMPORT_ALL' => FLICKR_ADMIN.'-import&amp;action=import_album&amp;album='.$album['id'],
-        'U_LIST' => FLICKR_ADMIN.'-import&amp;action=list_photos&amp;album=not_in_set',
+        'U_LIST' => FLICKR_ADMIN . '-import&amp;action=list_photos&amp;album=not_in_set',
         ));
     }
@@ -129,4 +117,9 @@
   case 'list_photos':
   {
+    $self_url = FLICKR_ADMIN . '-import&amp;action=list_photos&amp;album='.$_GET['album'];
+    $flickr_prefix = 'flickr-'.$u['username'].'-';
+    $flickr_root_url = $flickr->urls_getUserPhotos($u['id']);
+    
+    // pagination
     if (isset($_GET['start']))   $page['start'] = intval($_GET['start']);
     else                         $page['start'] = 0;
@@ -134,7 +127,15 @@
     else                         $page['display'] = 20;
     
-    $self_url = FLICKR_ADMIN.'-import&amp;action=list_photos&amp;album='.$_GET['album'];
-    $flickr_prefix = 'flickr-'.$conf['flickr2piwigo']['username'].'-';
-    $flickr_root_url = $flickr->urls_getUserPhotos($u['id']);
+    // get photos
+    if ($_GET['album'] == 'not_in_set')
+    {
+      $all_photos = $flickr->photos_getNotInSet(NULL, NULL, NULL, NULL, 'photos', NULL, NULL, 500);
+      $all_photos = $all_photos['photos']['photo'];
+    }
+    else
+    {
+      $all_photos = $flickr->photosets_getPhotos($_GET['album'], NULL, NULL, 500, NULL, 'photos');
+      $all_photos = $all_photos['photoset']['photo'];
+    }
     
     // get existing photos
@@ -147,17 +148,5 @@
     $existing_photos = array_map(create_function('$p', '$p=preg_replace("#^'.$flickr_prefix.'([0-9]+)\.([a-z]{3,4})$#i", "$1", $p); return $p;'), $existing_photos);
     
-    // get photos
-    if ($_GET['album'] == 'not_in_set')
-    {
-      $all_photos = $flickr->photos_getNotInSet(NULL, NULL, NULL, NULL, 'photos', NULL, NULL, 500);
-      $all_photos = $all_photos['photos']['photo'];
-    }
-    else
-    {
-      $all_photos = $flickr->photosets_getPhotos($_GET['album'], NULL, NULL, 500, NULL, 'photos');
-      $all_photos = $all_photos['photoset']['photo'];
-    }
-    
-    // remove existing
+    // remove existing photos
     $duplicates = 0;
     foreach ($all_photos as $i => $photo)
@@ -169,4 +158,5 @@
       }
     }
+    
     if ($duplicates>0)
     {
@@ -214,8 +204,9 @@
     break;
   }
-    
+  
+  // list all photos of the user
   case 'list_all':
   {
-    $flickr_prefix = 'flickr-'.$conf['flickr2piwigo']['username'].'-';
+    $flickr_prefix = 'flickr-'.$u['username'].'-';
     
     // get all photos in all albums
@@ -246,5 +237,5 @@
     $existing_photos = array_map(create_function('$p', '$p=preg_replace("#^'.$flickr_prefix.'([0-9]+)\.([a-z]{3,4})$#i", "$1", $p); return $p;'), $existing_photos);
     
-    // remove duplicates
+    // remove existing photos
     $duplicates = 0;
     foreach ($all_photos as $id => &$photo)
@@ -264,14 +255,15 @@
     }
     unset($photo);
+    $all_photos = array_values($all_photos);
+    
     if ($duplicates>0)
     {
       array_push($page['infos'], l10n_dec('%d picture is not displayed because already existing in the database.', '%d pictures are not displayed because already existing in the database.', $duplicates));
     }
-    $all_photos = array_values($all_photos);
     
     $template->assign(array(
       'nb_elements' => count($all_photos),
       'all_elements' => json_encode($all_photos),
-      'F_ACTION' => FLICKR_ADMIN.'-import&amp;action=import_set',
+      'F_ACTION' => FLICKR_ADMIN . '-import&amp;action=import_set',
       ));
       
@@ -293,11 +285,12 @@
       $_SESSION['page_infos'][] = sprintf(l10n('%d pictures imported'), $_POST['done']);
     }
-    redirect(FLICKR_ADMIN.'-import');
+    redirect(FLICKR_ADMIN . '-import');
   }
 }
 
+
 $template->assign('ACTION', $_GET['action']);
 
-$template->set_filename('flickr2piwigo', dirname(__FILE__).'/template/import.tpl');
+$template->set_filename('flickr2piwigo', dirname(__FILE__) . '/template/import.tpl');
 
 ?>
Index: /extensions/flickr2piwigo/admin/template/config.tpl
===================================================================
--- /extensions/flickr2piwigo/admin/template/config.tpl	(revision 16070)
+++ /extensions/flickr2piwigo/admin/template/config.tpl	(revision 16071)
@@ -23,11 +23,4 @@
       </label>
     </li>
-
-    <li>
-      <label>
-        <span class="property">{'Username'|@translate}</span>
-        <input type="text" name="username" value="{$flickr2piwigo.username}" size="20"></label>
-      </label>
-    </li>
   </ul>
 </fieldset>
Index: /extensions/flickr2piwigo/admin/template/import.list_photos.tpl
===================================================================
--- /extensions/flickr2piwigo/admin/template/import.list_photos.tpl	(revision 16070)
+++ /extensions/flickr2piwigo/admin/template/import.list_photos.tpl	(revision 16071)
@@ -330,5 +330,5 @@
   /* pagination loader */
   jQuery('#navigation a').click(function() {
-    $("#loader_display").fadeIn()
+    $("#loader_display").fadeIn();
   });
 });
Index: /extensions/flickr2piwigo/admin/template/import.tpl
===================================================================
--- /extensions/flickr2piwigo/admin/template/import.tpl	(revision 16070)
+++ /extensions/flickr2piwigo/admin/template/import.tpl	(revision 16071)
@@ -5,32 +5,55 @@
 </div>
 
+{* <!-- LOGIN --> *}
 {if $ACTION == 'init_login'}
 <p><input type="submit" onClick="javascript:window.location.href ='{$flickr_login}';" value="{'Login'|@translate}"></p>
 
+{* <!-- MAIN MENU --> *}
 {elseif $ACTION == 'main'}
+{footer_script}{literal}
+jQuery('input[type="submit"]').click(function() {
+  window.location.href = $(this).attr("data");
+});
+jQuery('.load').click(function() {
+  $("#loader_import").fadeIn();
+});
+{/literal}{/footer_script}
+
 <p>
   <b>{'Logued as'|@translate}</b> : <a href="{$profile_url}" target="_blank">{$username}</a><br><br>
-  <input type="submit" onClick="javascript:window.location.href ='{$logout_url}';" value="{'Logout'|@translate}">
+  <input type="submit" data="{$logout_url}" value="{'Logout'|@translate}">
 </p>
 <br>
 <p>
-  <input type="submit" onClick="javascript:window.location.href ='{$list_albums_url}';" value="{'List my albums'|@translate}">
-  <input type="submit" onClick="javascript:window.location.href ='{$import_all_url}';" value="{'Import all my pictures'|@translate}">
+  <input type="submit" data="{$list_albums_url}" class="load" value="{'List my albums'|@translate}">
+  <input type="submit" data="{$import_all_url}" class="load" value="{'Import all my pictures'|@translate}">
+  <br>
+  <span id="loader_import" style="display:none;"><img src="admin/themes/default/images/ajax-loader.gif"> <i>{'Processing...'|@translate}</i></span>
 </p>
 
+{* <!-- ALBUMS LIST --> *}
 {elseif $ACTION == 'list_albums'}
+{footer_script}{literal}
+jQuery('.load').click(function() {
+  $("#loader_import").fadeIn();
+});
+{/literal}{/footer_script}
+
 <h3>{'%d albums'|@translate|@sprintf:$total_albums}</h3>
 <ul id="albumsList">
 {foreach from=$albums item=album}
   <li {if $album.id == "not_in_set"}class="not_in_set"{/if}>
-    <b><a href="{$album.U_LIST}">{$album.title}</a></b> <i>{'(%d photos)'|@translate|@sprintf:$album.photos}</i> {if $album.description}- {$album.description|@truncate:100}{/if}
-    {*- <a href="{$album.U_IMPORT_ALL}">{'Import all pictures of this album'|@translate}</a>*}
+    <b><a href="{$album.U_LIST}" class="load">{$album.title}</a></b> <i>{'(%d photos)'|@translate|@sprintf:$album.photos}</i> 
+    {if $album.description}- {$album.description|@truncate:100}{/if}
   </li>
 {/foreach}
 </ul>
+<span id="loader_import" style="display:none;"><img src="admin/themes/default/images/ajax-loader.gif"> <i>{'Processing...'|@translate}</i></span>
 
+{* <!-- PHOTOS LIST --> *}
 {elseif $ACTION == 'list_photos'}
 {include file=$FLICKR_ABS_PATH|@cat:'admin/template/import.list_photos.tpl'}
 
+{* <!-- IMPORT ALL --> *}
 {elseif $ACTION == 'list_all'}
 {include file=$FLICKR_ABS_PATH|@cat:'admin/template/import.list_all.tpl'}
Index: /extensions/flickr2piwigo/include/ws_functions.inc.php
===================================================================
--- /extensions/flickr2piwigo/include/ws_functions.inc.php	(revision 16071)
+++ /extensions/flickr2piwigo/include/ws_functions.inc.php	(revision 16071)
@@ -0,0 +1,133 @@
+<?php
+if (!defined('FLICKR_PATH')) die('Hacking attempt!');
+
+function flickr_add_ws_method($arr)
+{
+  $service = &$arr[0];
+  
+  $service->addMethod(
+    'pwg.images.addFlickr',
+    'ws_images_addFlickr',
+    array(
+      'category' => array('default' => null),   
+      'id' => array('default' => null),
+      'fills' => array('default' =>null),
+      ),
+    'Used by Flickr2Piwigo, fills € (fill_name,fill_posted,fill_taken,fill_author,fill_tags)'
+    );
+}
+
+function ws_images_addFlickr($photo, &$service)
+{
+  if (!is_admin())
+  {
+    return new PwgError(403, 'Forbidden');
+  }
+  
+  global $conf;
+  $conf['flickr2piwigo'] = unserialize($conf['flickr2piwigo']);
+  
+  if ( empty($conf['flickr2piwigo']['api_key']) or empty($conf['flickr2piwigo']['secret_key']) )
+  {
+    return new PwgError(500, l10n('Please fill your API keys on the configuration tab'));
+  }
+  
+  include_once(PHPWG_ROOT_PATH . 'admin/include/functions.php');
+  include_once(PHPWG_ROOT_PATH . 'admin/include/functions_upload.inc.php');
+  
+  // init flickr API
+  include_once(FLICKR_PATH . 'include/phpFlickr/phpFlickr.php');
+  $flickr = new phpFlickr($conf['flickr2piwigo']['api_key'], $conf['flickr2piwigo']['secret_key']);
+  $flickr->enableCache('fs', FLICKR_FS_CACHE);
+  
+  // user
+  $u = $flickr->test_login();
+  if ( $u === false or empty($_SESSION['phpFlickr_auth_token']) )
+  {
+    return new PwgError(403, l10n('API not authenticated'));
+  }
+  
+  // photos infos
+  $photo_f = $flickr->photos_getInfo($photo['id']);
+  $photo = array_merge($photo, $photo_f['photo']);
+  $photo['url'] = $flickr->get_biggest_size($photo['id'], 'original');
+  $photo['path'] = FLICKR_FS_CACHE . 'flickr-'.$u['username'].'-'.$photo['id'].'.'.get_extension($photo['url']);
+  
+  // copy file
+  $file = fopen($photo['url'], "rb");
+  $newf = fopen($photo['path'], "wb");
+  while (!feof($file))
+  {
+    fwrite($newf, fread($file, 1024 * 8 ), 1024 * 8 );
+  }
+  fclose($file);
+  fclose($newf);
+  
+  // category
+  if (!preg_match('#^[0-9]+$#', $photo['category']))
+  {
+    $categories_names = explode(',', $photo['category']);
+    
+    $photo['category'] = array();
+    foreach ($categories_names as $category_name)
+    {
+      $query = '
+SELECT id FROM '.CATEGORIES_TABLE.'
+  WHERE LOWER(name) = "'.strtolower($category_name).'"
+;';
+      $result = pwg_query($query);
+      
+      if (pwg_db_num_rows($result))
+      {
+        list($cat_id) = pwg_db_fetch_row($result);
+        array_push($photo['category'], $cat_id);
+      }
+      else
+      {
+        
+        $cat = create_virtual_category($category_name);
+        array_push($photo['category'], $cat['id']);
+      }
+    }
+  }
+  else
+  {
+    $photo['category'] = array($photo['category']);
+  }
+  
+  // add photo
+  $photo['image_id'] = add_uploaded_file($photo['path'], basename($photo['path']), $photo['category']);
+  
+  // do some updates
+  if (!empty($photo['fills']))
+  {
+    $photo['fills'] = rtrim($photo['fills'], ',');
+    $photo['fills'] = explode(',', $photo['fills']);
+  
+    $updates = array();
+    if (in_array('fill_name', $photo['fills']))   $updates['name'] = $photo['title']; 
+    if (in_array('fill_posted', $photo['fills'])) $updates['date_available'] = date('Y-d-m H:i:s', $photo['dates']['posted']);
+    if (in_array('fill_taken', $photo['fills']))  $updates['date_creation'] = $photo['dates']['taken'];
+    if (in_array('fill_author', $photo['fills'])) $updates['author'] = $photo['owner']['username'];
+    
+    if (count($updates))
+    {
+      single_update(
+        IMAGES_TABLE,
+        $updates,
+        array('id' => $photo['image_id'])
+        );
+    }
+    
+    if ( !empty($photo['tags']['tag']) and in_array('fill_tags', $photo['fills']) )
+    {
+      $raw_tags = array_map(create_function('$t', 'return $t["_content"];'), $photo['tags']['tag']);
+      $raw_tags = implode(',', $raw_tags);
+      set_tags(get_tag_ids($raw_tags), $photo['image_id']);
+    }
+  }
+  
+  return sprintf(l10n('%s imported'), $photo['title']);
+}
+
+?>
Index: /extensions/flickr2piwigo/language/en_UK/help_api_key.html
===================================================================
--- /extensions/flickr2piwigo/language/en_UK/help_api_key.html	(revision 16070)
+++ /extensions/flickr2piwigo/language/en_UK/help_api_key.html	(revision 16071)
@@ -8,5 +8,4 @@
   <li>Click <b>Edit auth flow for this app</b></li>
   <li>Enter a desciption again, past in <b>Callback URL</b> the above URL and click <b>Save changes</b></li>
-  <li>Don't forget to write your exact username in Flickr2Piwigo configuration</li>
   <li>You're done!</li>
 </ol>
Index: /extensions/flickr2piwigo/language/en_UK/plugin.lang.php
===================================================================
--- /extensions/flickr2piwigo/language/en_UK/plugin.lang.php	(revision 16070)
+++ /extensions/flickr2piwigo/language/en_UK/plugin.lang.php	(revision 16071)
@@ -25,5 +25,4 @@
 $lang['(%d photos)'] = '(%d photos)';
 $lang['%d albums'] = '%d albums';
-//$lang['Import all pictures of this album'] = 'Import all pictures of this album';
 $lang['List pictures of this album'] = 'List pictures of this album';
 $lang['Begin transfert'] = 'Begin transfert';
Index: /extensions/flickr2piwigo/language/fr_FR/help_api_key.html
===================================================================
--- /extensions/flickr2piwigo/language/fr_FR/help_api_key.html	(revision 16070)
+++ /extensions/flickr2piwigo/language/fr_FR/help_api_key.html	(revision 16071)
@@ -8,5 +8,4 @@
   <li>Cliquez sur <b>Modifier le flux d'authentification</b></li>
   <li>Entrer à nouveau une description, collez dans <b>URL de rappel</b> l'URL ci-dessus et cliquez sur <b>Save changes</b></li>
-  <li>N'oubliez pas de renseigner votre nom d'utilisateur exact dans la configuration de Flickr2Piwigo</li>
   <li>Terminé!</li>
 </ol>
Index: /extensions/flickr2piwigo/language/fr_FR/plugin.lang.php
===================================================================
--- /extensions/flickr2piwigo/language/fr_FR/plugin.lang.php	(revision 16070)
+++ /extensions/flickr2piwigo/language/fr_FR/plugin.lang.php	(revision 16071)
@@ -25,5 +25,4 @@
 $lang['(%d photos)'] = '(%d photos)';
 $lang['%d albums'] = '%d albums';
-//$lang['Import all pictures of this album'] = 'Importer toutes les photos de cet album';
 $lang['List pictures of this album'] = 'Lister les photos de cet album';
 $lang['Begin transfert'] = 'Commencer les transfert';
Index: /extensions/flickr2piwigo/main.inc.php
===================================================================
--- /extensions/flickr2piwigo/main.inc.php	(revision 16070)
+++ /extensions/flickr2piwigo/main.inc.php	(revision 16071)
@@ -17,7 +17,8 @@
 define('FLICKR_FS_CACHE', $conf['data_location'].'flickr_cache/');
 
-add_event_handler('get_admin_plugin_menu_links', 'flickr2_admin_menu');
 
-function flickr2_admin_menu($menu) 
+add_event_handler('get_admin_plugin_menu_links', 'flickr_admin_menu');
+
+function flickr_admin_menu($menu) 
 {
   array_push($menu, array(
@@ -28,131 +29,8 @@
 }
 
-add_event_handler('ws_add_methods', 'flickr2_add_ws_method');
 
-function flickr2_add_ws_method($arr)
-{
-  $service = &$arr[0];
-  
-  $service->addMethod(
-    'pwg.images.addFlickr',
-    'ws_images_addFlickr',
-    array(
-      'category' => array('default' => null),   
-      'id' => array('default' => null),
-      'fills' => array('default' =>null),
-      ),
-    'Used by Flickr2Piwigo, fills  (fill_name,fill_posted,fill_taken,fill_author,fill_tags)'
-    );
-}
+include_once(FLICKR_PATH . 'include/ws_functions.inc.php');
 
-function ws_images_addFlickr($photo, &$service)
-{
-  global $conf;
-  
-  if (!is_admin())
-  {
-    return new PwgError(403, 'Forbidden');
-  }
-  
-  $conf['flickr2piwigo'] = unserialize($conf['flickr2piwigo']);
-  
-  if (empty($conf['flickr2piwigo']['api_key']) or empty($conf['flickr2piwigo']['secret_key']) or empty($conf['flickr2piwigo']['username']))
-  {
-    return new PwgError(500, l10n('Please fill your API keys on the configuration tab'));
-  }
-  
-  if (empty($_SESSION['phpFlickr_auth_token']))
-  {
-    return new PwgError(403, l10n('API not authenticated'));
-  }
-  
-  // category
-  if (!preg_match('#^[0-9]+$#', $photo['category']))
-  {
-    $categories_names = explode(',', $photo['category']);
-    
-    $photo['category'] = array();
-    foreach ($categories_names as $category_name)
-    {
-      $query = '
-SELECT id FROM '.CATEGORIES_TABLE.'
-  WHERE LOWER(name) = "'.strtolower($category_name).'"
-;';
-      $result = pwg_query($query);
-      
-      if (pwg_db_num_rows($result))
-      {
-        list($cat_id) = pwg_db_fetch_row($result);
-        array_push($photo['category'], $cat_id);
-      }
-      else
-      {
-        include_once(PHPWG_ROOT_PATH . 'admin/include/functions.php');
-        $cat = create_virtual_category($category_name);
-        array_push($photo['category'], $cat_id['id']);
-      }
-    }
-  }
-  else
-  {
-    $photo['category'] = array($photo['category']);
-  }
-  
-  // init flickr API
-  include_once(FLICKR_PATH . 'include/phpFlickr/phpFlickr.php');
-  $flickr = new phpFlickr($conf['flickr2piwigo']['api_key'], $conf['flickr2piwigo']['secret_key']);
-  $flickr->enableCache('fs', FLICKR_FS_CACHE);
-  
-  // photos infos
-  $photo_f = $flickr->photos_getInfo($photo['id']);
-  $photo = array_merge($photo, $photo_f['photo']);
-  $photo['url'] = $flickr->get_biggest_size($photo['id'], 'original');
-  $photo['path'] = FLICKR_FS_CACHE . 'flickr-'.$conf['flickr2piwigo']['username'].'-'.$photo['id'].'.'.get_extension($photo['url']);
-  
-  // copy file
-  $file = fopen($photo['url'], "rb");
-  $newf = fopen($photo['path'], "wb");
-  while (!feof($file))
-  {
-    fwrite($newf, fread($file, 1024 * 8 ), 1024 * 8 );
-  }
-  fclose($file);
-  fclose($newf);
-  
-  // add to database
-  include_once(PHPWG_ROOT_PATH . 'admin/include/functions_upload.inc.php');
-  $photo['image_id'] = add_uploaded_file($photo['path'], basename($photo['path']), $photo['category']);
-  
-  // do some updates
-  if (!empty($photo['fills']))
-  {
-    $photo['fills'] = rtrim($photo['fills'], ',');
-    $photo['fills'] = explode(',', $photo['fills']);
-  
-    $updates = array();
-    if (in_array('fill_name', $photo['fills']))   $updates['name'] = $photo['title']; 
-    if (in_array('fill_posted', $photo['fills'])) $updates['date_available'] = date('Y-d-m H:i:s', $photo['dates']['posted']);
-    if (in_array('fill_taken', $photo['fills']))  $updates['date_creation'] = $photo['dates']['taken'];
-    if (in_array('fill_author', $photo['fills'])) $updates['author'] = $conf['flickr2piwigo']['username'];
-    
-    if (count($updates))
-    {
-      single_update(
-        IMAGES_TABLE,
-        $updates,
-        array('id' => $photo['image_id'])
-        );
-    }
-    
-    if ( !empty($photo['tags']['tag']) and in_array('fill_tags', $photo['fills']) )
-    {
-      $raw_tags = array_map(create_function('$t', 'return $t["_content"];'), $photo['tags']['tag']);
-      $raw_tags = implode(',', $raw_tags);
-      set_tags(get_tag_ids($raw_tags), $photo['image_id']);
-    }
-  }
-  
-  return sprintf(l10n('%s imported'), $photo['title']);
-}
+add_event_handler('ws_add_methods', 'flickr_add_ws_method');
 
 ?>
Index: /extensions/flickr2piwigo/maintain.inc.php
===================================================================
--- /extensions/flickr2piwigo/maintain.inc.php	(revision 16070)
+++ /extensions/flickr2piwigo/maintain.inc.php	(revision 16071)
@@ -7,13 +7,14 @@
     'api_key' => null,
     'secret_key' => null,
-    'username' => null,
     ))
   );
-  
+
 
 function plugin_install() 
 {
   global $conf;
+  
   conf_update_param('flickr2piwigo', flickr2piwigo_default_config);
+  
   mkdir($conf['data_location'].'flickr_cache/', 0755);
 }
@@ -30,5 +31,5 @@
   if (!file_exists($conf['data_location'].'flickr_cache/'))
   {
-    mdir($conf['data_location'].'flickr_cache/', 0755);
+    mkdir($conf['data_location'].'flickr_cache/', 0755);
   }
 }
@@ -37,5 +38,36 @@
 {
   pwg_query('DELETE FROM `'. CONFIG_TABLE .'` WHERE param = "flickr2piwigo" LIMIT 1;');
+  
+  rrmdir($conf['data_location'].'flickr_cache/');
 }
 
+function rrmdir($dir)
+{
+  if (!is_dir($dir))
+  {
+    return false;
+  }
+  $dir = rtrim($dir, '/');
+  $objects = scandir($dir);
+  $return = true;
+  
+  foreach ($objects as $object)
+  {
+    if ($object !== '.' && $object !== '..')
+    {
+      $path = $dir.'/'.$object;
+      if (filetype($path) == 'dir') 
+      {
+        $return = $return && rrmdir($path); 
+      }
+      else 
+      {
+        $return = $return && @unlink($path);
+      }
+    }
+  }
+  
+  return $return && @rmdir($dir);
+} 
+
 ?>
