[16591] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | Plugin Name: User Collections |
---|
| 4 | Version: auto |
---|
[16597] | 5 | Description: Registered users can select pictures from the gallery and save them into collections, like advanced favorites. |
---|
| 6 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=615 |
---|
[16591] | 7 | Author: Mistic |
---|
| 8 | Author URI: http://www.strangeplanet.fr |
---|
| 9 | */ |
---|
| 10 | |
---|
| 11 | defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); |
---|
| 12 | |
---|
| 13 | global $conf, $prefixeTable; |
---|
| 14 | |
---|
[20090] | 15 | defined('USER_COLLEC_ID') or define('USER_COLLEC_ID', basename(dirname(__FILE__))); |
---|
| 16 | define('USER_COLLEC_PATH', PHPWG_PLUGINS_PATH . USER_COLLEC_ID . '/'); |
---|
[16597] | 17 | define('COLLECTIONS_TABLE', $prefixeTable.'collections'); |
---|
[16591] | 18 | define('COLLECTION_IMAGES_TABLE',$prefixeTable.'collection_images'); |
---|
[20090] | 19 | define('USER_COLLEC_ADMIN', get_root_url() . 'admin.php?page=plugin-' . USER_COLLEC_ID); |
---|
[17519] | 20 | define('USER_COLLEC_PUBLIC', get_absolute_root_url() . make_index_url(array('section' => 'collections')) . '/'); |
---|
[19843] | 21 | define('USER_COLLEC_VERSION', 'auto'); |
---|
[16591] | 22 | |
---|
| 23 | add_event_handler('init', 'user_collections_init'); |
---|
| 24 | |
---|
[20090] | 25 | add_event_handler('ws_add_methods', 'user_collections_ws_add_methods'); |
---|
[16591] | 26 | |
---|
[20090] | 27 | if (defined('IN_ADMIN')) |
---|
| 28 | { |
---|
| 29 | add_event_handler('get_admin_plugin_menu_links', 'user_collections_admin_menu'); |
---|
| 30 | } |
---|
| 31 | else |
---|
| 32 | { |
---|
| 33 | // collections page |
---|
| 34 | add_event_handler('loc_end_section_init', 'user_collections_section_init'); |
---|
| 35 | add_event_handler('loc_end_index', 'user_collections_page', EVENT_HANDLER_PRIORITY_NEUTRAL-10); |
---|
[16591] | 36 | |
---|
[20090] | 37 | // thumbnails actions |
---|
| 38 | add_event_handler('loc_end_index', 'user_collections_index_actions'); |
---|
[20097] | 39 | add_event_handler('loc_end_index_thumbnails', 'user_collections_thumbnails_list', EVENT_HANDLER_PRIORITY_NEUTRAL-10, 2); |
---|
[16591] | 40 | |
---|
[20090] | 41 | // picture action |
---|
| 42 | add_event_handler('loc_end_picture', 'user_collections_picture_page'); |
---|
[16591] | 43 | |
---|
[20090] | 44 | // menu |
---|
| 45 | add_event_handler('blockmanager_register_blocks', 'user_collections_add_menublock'); |
---|
| 46 | add_event_handler('blockmanager_apply', 'user_collections_applymenu'); |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | require(USER_COLLEC_PATH . 'include/ws_functions.inc.php'); |
---|
[16591] | 50 | require(USER_COLLEC_PATH . 'include/functions.inc.php'); |
---|
| 51 | require(USER_COLLEC_PATH . 'include/UserCollection.class.php'); |
---|
| 52 | require(USER_COLLEC_PATH . 'include/events.inc.php'); |
---|
| 53 | |
---|
[17657] | 54 | |
---|
| 55 | /** |
---|
| 56 | * update plugin & load language |
---|
| 57 | */ |
---|
| 58 | function user_collections_init() |
---|
| 59 | { |
---|
[20090] | 60 | global $pwg_loaded_plugins, $conf; |
---|
[17657] | 61 | |
---|
| 62 | if ( |
---|
[19843] | 63 | USER_COLLEC_VERSION == 'auto' or |
---|
[20090] | 64 | $pwg_loaded_plugins[USER_COLLEC_ID]['version'] == 'auto' or |
---|
| 65 | version_compare($pwg_loaded_plugins[USER_COLLEC_ID]['version'], USER_COLLEC_VERSION, '<') |
---|
[17657] | 66 | ) |
---|
| 67 | { |
---|
| 68 | include_once(USER_COLLEC_PATH . 'include/install.inc.php'); |
---|
| 69 | user_collections_install(); |
---|
| 70 | |
---|
[20090] | 71 | if ( $pwg_loaded_plugins[USER_COLLEC_ID]['version'] != 'auto' and USER_COLLEC_VERSION != 'auto' ) |
---|
[17657] | 72 | { |
---|
| 73 | $query = ' |
---|
| 74 | UPDATE '. PLUGINS_TABLE .' |
---|
| 75 | SET version = "'. USER_COLLEC_VERSION .'" |
---|
[20090] | 76 | WHERE id = "'. USER_COLLEC_ID .'"'; |
---|
[17657] | 77 | pwg_query($query); |
---|
| 78 | |
---|
[20090] | 79 | $pwg_loaded_plugins[USER_COLLEC_ID]['version'] = USER_COLLEC_VERSION; |
---|
[17657] | 80 | |
---|
| 81 | if (defined('IN_ADMIN')) |
---|
| 82 | { |
---|
| 83 | $_SESSION['page_infos'][] = 'UserCollections updated to version '. USER_COLLEC_VERSION; |
---|
| 84 | } |
---|
| 85 | } |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | load_language('plugin.lang', USER_COLLEC_PATH); |
---|
[20090] | 89 | |
---|
| 90 | $conf['user_collections'] = unserialize($conf['user_collections']); |
---|
[17657] | 91 | } |
---|
| 92 | |
---|
[20090] | 93 | /** |
---|
| 94 | * admin plugins menu |
---|
| 95 | */ |
---|
| 96 | function user_collections_admin_menu($menu) |
---|
| 97 | { |
---|
| 98 | array_push($menu, array( |
---|
| 99 | 'NAME' => 'User Collections', |
---|
| 100 | 'URL' => USER_COLLEC_ADMIN, |
---|
| 101 | )); |
---|
| 102 | return $menu; |
---|
| 103 | } |
---|
| 104 | |
---|
[16591] | 105 | ?> |
---|