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