source: extensions/SmartAlbums/main.inc.php @ 17716

Last change on this file since 17716 was 17716, checked in by mistic100, 12 years ago

consolidate upgrade process

File size: 2.8 KB
Line 
1<?php
2/*
3Plugin Name: SmartAlbums
4Version: auto
5Description: Easily create dynamic albums with tags, date and other criteria
6Plugin URI: http://piwigo.org/ext/extension_view.php?eid=544
7Author: Mistic
8Author URI: http://www.strangeplanet.fr
9*/
10
11if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
12global $prefixeTable;
13
14define('SMART_PATH',    PHPWG_PLUGINS_PATH . 'SmartAlbums/');
15define('CATEGORY_FILTERS_TABLE', $prefixeTable . 'category_filters');
16define('SMART_ADMIN',   get_root_url() . 'admin.php?page=plugin-SmartAlbums');
17define('SMART_VERSION', '2.0.3');
18
19
20add_event_handler('invalidate_user_cache', 'smart_make_all_associations');
21add_event_handler('init', 'smart_init');
22
23if (defined('IN_ADMIN'))
24{
25  include_once(SMART_PATH.'include/cat_list.php');
26  add_event_handler('loc_begin_cat_list', 'smart_cat_list');
27  add_event_handler('tabsheet_before_select','smart_tab', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); 
28  add_event_handler('get_admin_plugin_menu_links', 'smart_admin_menu');
29  add_event_handler('delete_categories', 'smart_delete_categories');
30}
31
32include_once(SMART_PATH.'include/functions.inc.php');
33
34
35/**
36 * update plugin & unserialize conf & load language
37 */
38function smart_init()
39{
40  global $conf, $pwg_loaded_plugins;
41 
42  if (
43    $pwg_loaded_plugins['SmartAlbums']['version'] == 'auto' or
44    version_compare($pwg_loaded_plugins['SmartAlbums']['version'], SMART_VERSION, '<')
45  )
46  {
47    include_once(SMART_PATH . 'include/install.inc.php');
48    smart_albums_install();
49   
50    if ($pwg_loaded_plugins['SmartAlbums']['version'] != 'auto')
51    {
52      $query = '
53UPDATE '. PLUGINS_TABLE .'
54SET version = "'. SMART_VERSION .'"
55WHERE id = "SmartAlbums"';
56      pwg_query($query);
57     
58      $pwg_loaded_plugins['SmartAlbums']['version'] = SMART_VERSION;
59     
60      if (defined('IN_ADMIN'))
61      {
62        $_SESSION['page_infos'][] = 'Smart Albums updated to version '. SMART_VERSION;
63      }
64    }
65  }
66 
67  if (defined('IN_ADMIN'))
68  {
69    load_language('plugin.lang', SMART_PATH);
70  }
71  $conf['SmartAlbums'] = unserialize($conf['SmartAlbums']);
72 
73  if ( script_basename() == 'index' and $conf['SmartAlbums']['smart_is_forbidden'] )
74  {
75    add_event_handler('loc_end_section_init', 'smart_init_page_items');
76    include_once(SMART_PATH.'include/page_items.php');
77  }
78}
79
80/**
81 * new tab on album properties page
82 */
83function smart_tab($sheets, $id)
84{
85  if ($id != 'album') return $sheets;
86 
87  global $category;
88 
89  if ($category['dir'] == null)
90  {
91    $sheets['smartalbum'] = array(
92      'caption' => 'SmartAlbum',
93      'url' => SMART_ADMIN.'-album&amp;cat_id='.$_GET['cat_id'],
94      );
95  }
96 
97  return $sheets;
98}
99
100
101/**
102 * admin plugins menu link
103 */
104function smart_admin_menu($menu) 
105{
106  array_push($menu, array(
107      'NAME' => 'SmartAlbums',
108      'URL' => SMART_ADMIN,
109    ));
110  return $menu;
111}
112
113?>
Note: See TracBrowser for help on using the repository browser.