source: extensions/UserCollections/main.inc.php @ 23551

Last change on this file since 23551 was 23551, checked in by mistic100, 11 years ago

many corrections & optimizations + remove useless code + clean

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