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

Last change on this file since 20090 was 20090, checked in by mistic100, 11 years ago
  • add webservices
  • add mail function
  • add admin list
  • add admin export function
  • try to deal with Gthumb+
  • activate multisize dropdown menu of collection page

TODO : use webservices instead of toggle_image.php

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