Index: extensions/UserCollections/main.inc.php
===================================================================
--- extensions/UserCollections/main.inc.php	(revision 19843)
+++ extensions/UserCollections/main.inc.php	(revision 20090)
@@ -13,25 +13,40 @@
 global $conf, $prefixeTable;
 
-define('USER_COLLEC_PATH',       PHPWG_PLUGINS_PATH . 'UserCollections/');
+defined('USER_COLLEC_ID') or define('USER_COLLEC_ID', basename(dirname(__FILE__)));
+define('USER_COLLEC_PATH',       PHPWG_PLUGINS_PATH . USER_COLLEC_ID . '/');
 define('COLLECTIONS_TABLE',      $prefixeTable.'collections');
 define('COLLECTION_IMAGES_TABLE',$prefixeTable.'collection_images');
-define('USER_COLLEC_ADMIN',      get_root_url() . 'admin.php?page=plugin-UserCollections');
+define('USER_COLLEC_ADMIN',      get_root_url() . 'admin.php?page=plugin-' . USER_COLLEC_ID);
 define('USER_COLLEC_PUBLIC',     get_absolute_root_url() . make_index_url(array('section' => 'collections')) . '/');
 define('USER_COLLEC_VERSION',    'auto');
 
-
 add_event_handler('init', 'user_collections_init');
 
-add_event_handler('loc_end_section_init', 'user_collections_section_init');
-add_event_handler('loc_end_index', 'user_collections_page', EVENT_HANDLER_PRIORITY_NEUTRAL-10);
+add_event_handler('ws_add_methods', 'user_collections_ws_add_methods');
 
-add_event_handler('loc_end_index', 'user_collections_index_actions');
-add_event_handler('loc_end_index_thumbnails', 'user_collections_thumbnails_list', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
+if (defined('IN_ADMIN'))
+{
+  add_event_handler('get_admin_plugin_menu_links', 'user_collections_admin_menu');
+}
+else
+{
+  // collections page
+  add_event_handler('loc_begin_index', 'user_collections_save_pagination', EVENT_HANDLER_PRIORITY_NEUTRAL-10);
+  add_event_handler('loc_end_section_init', 'user_collections_section_init');
+  add_event_handler('loc_end_index', 'user_collections_page', EVENT_HANDLER_PRIORITY_NEUTRAL-10);
 
-add_event_handler('loc_end_picture', 'user_collections_picture_page');
+  // thumbnails actions
+  add_event_handler('loc_end_index', 'user_collections_index_actions');
+  add_event_handler('loc_end_index_thumbnails', 'user_collections_thumbnails_list', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
 
-add_event_handler('blockmanager_register_blocks', 'user_collections_add_menublock');
-add_event_handler('blockmanager_apply', 'user_collections_applymenu');
+  // picture action
+  add_event_handler('loc_end_picture', 'user_collections_picture_page');
 
+  // menu
+  add_event_handler('blockmanager_register_blocks', 'user_collections_add_menublock');
+  add_event_handler('blockmanager_apply', 'user_collections_applymenu');
+}
+
+require(USER_COLLEC_PATH . 'include/ws_functions.inc.php');
 require(USER_COLLEC_PATH . 'include/functions.inc.php');
 require(USER_COLLEC_PATH . 'include/UserCollection.class.php');
@@ -44,10 +59,10 @@
 function user_collections_init()
 {
-  global $pwg_loaded_plugins;
+  global $pwg_loaded_plugins, $conf;
   
   if (
     USER_COLLEC_VERSION == 'auto' or
-    $pwg_loaded_plugins['UserCollections']['version'] == 'auto' or
-    version_compare($pwg_loaded_plugins['UserCollections']['version'], USER_COLLEC_VERSION, '<')
+    $pwg_loaded_plugins[USER_COLLEC_ID]['version'] == 'auto' or
+    version_compare($pwg_loaded_plugins[USER_COLLEC_ID]['version'], USER_COLLEC_VERSION, '<')
   )
   {
@@ -55,13 +70,13 @@
     user_collections_install();
     
-    if ( $pwg_loaded_plugins['UserCollections']['version'] != 'auto' and USER_COLLEC_VERSION != 'auto' )
+    if ( $pwg_loaded_plugins[USER_COLLEC_ID]['version'] != 'auto' and USER_COLLEC_VERSION != 'auto' )
     {
       $query = '
 UPDATE '. PLUGINS_TABLE .'
 SET version = "'. USER_COLLEC_VERSION .'"
-WHERE id = "UserCollections"';
+WHERE id = "'. USER_COLLEC_ID .'"';
       pwg_query($query);
       
-      $pwg_loaded_plugins['UserCollections']['version'] = USER_COLLEC_VERSION;
+      $pwg_loaded_plugins[USER_COLLEC_ID]['version'] = USER_COLLEC_VERSION;
       
       if (defined('IN_ADMIN'))
@@ -73,4 +88,18 @@
   
   load_language('plugin.lang', USER_COLLEC_PATH);
+  
+  $conf['user_collections'] = unserialize($conf['user_collections']);
+}
+
+/**
+ * admin plugins menu
+ */
+function user_collections_admin_menu($menu) 
+{
+  array_push($menu, array(
+    'NAME' => 'User Collections',
+    'URL' => USER_COLLEC_ADMIN,
+  ));
+  return $menu;
 }
 
