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