Ignore:
Timestamp:
Jan 4, 2014, 4:13:08 PM (10 years ago)
Author:
mistic100
Message:

update for Piwigo 2.6

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/SmartAlbums/main.inc.php

    r19446 r26442  
    44Version: auto
    55Description: Easily create dynamic albums with tags, date and other criteria
    6 Plugin URI: http://piwigo.org/ext/extension_view.php?eid=544
     6Plugin URI: auto
    77Author: Mistic
    88Author URI: http://www.strangeplanet.fr
    99*/
    1010
    11 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
     11defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
     12
    1213global $prefixeTable;
    1314
    14 define('SMART_PATH',     PHPWG_PLUGINS_PATH . 'SmartAlbums/');
     15define('SMART_ID',      'SmartAlbums');
     16define('SMART_PATH',    PHPWG_PLUGINS_PATH . SMART_ID . '/');
    1517define('CATEGORY_FILTERS_TABLE', $prefixeTable . 'category_filters');
    16 define('SMART_ADMIN',    get_root_url() . 'admin.php?page=plugin-SmartAlbums');
    17 define('SMART_VERSION',  'auto');
    18 //define('SMART_DEBUG',    true);
     18define('SMART_ADMIN',   get_root_url() . 'admin.php?page=plugin-' . SMART_ID);
     19define('SMART_VERSION', 'auto');
     20// define('SMART_DEBUG',   true);
    1921
    2022
    2123add_event_handler('init', 'smart_init');
    2224add_event_handler('init', 'smart_periodic_update');
    23 add_event_handler('invalidate_user_cache', 'smart_make_all_associations');
     25add_event_handler('delete_categories', 'smart_delete_categories');
    2426
    2527if (defined('IN_ADMIN'))
    2628{
    27   include_once(SMART_PATH.'include/cat_list.php');
     29  include_once(SMART_PATH.'include/events_admin.inc.php');
    2830  add_event_handler('loc_begin_cat_list', 'smart_cat_list');
    29   add_event_handler('tabsheet_before_select','smart_tab', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); 
     31  add_event_handler('tabsheet_before_select','smart_tab', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
    3032  add_event_handler('get_admin_plugin_menu_links', 'smart_admin_menu');
    31   add_event_handler('delete_categories', 'smart_delete_categories');
    3233}
    3334
     35include_once(SMART_PATH.'include/events.inc.php');
    3436include_once(SMART_PATH.'include/functions.inc.php');
    3537
     
    4042function smart_init()
    4143{
    42   global $conf, $pwg_loaded_plugins;
    43  
    44   if (
    45     SMART_VERSION == 'auto' or
    46     $pwg_loaded_plugins['SmartAlbums']['version'] == 'auto' or
    47     version_compare($pwg_loaded_plugins['SmartAlbums']['version'], SMART_VERSION, '<')
    48   )
    49   {
    50     include_once(SMART_PATH . 'include/install.inc.php');
    51     smart_albums_install();
    52    
    53     if ( $pwg_loaded_plugins['SmartAlbums']['version'] != 'auto' and SMART_VERSION != 'auto' )
    54     {
    55       $query = '
    56 UPDATE '. PLUGINS_TABLE .'
    57 SET version = "'. SMART_VERSION .'"
    58 WHERE id = "SmartAlbums"';
    59       pwg_query($query);
    60      
    61       $pwg_loaded_plugins['SmartAlbums']['version'] = SMART_VERSION;
    62      
    63       if (defined('IN_ADMIN'))
    64       {
    65         $_SESSION['page_infos'][] = 'Smart Albums updated to version '. SMART_VERSION;
    66       }
    67     }
    68   }
    69  
     44  global $conf;
     45
     46  include_once(SMART_PATH . 'maintain.inc.php');
     47  $maintain = new SmartAlbums_maintain(SMART_ID);
     48  $maintain->autoUpdate(SMART_VERSION, 'install');
     49
    7050  if (defined('IN_ADMIN'))
    7151  {
     
    7353  }
    7454  $conf['SmartAlbums'] = unserialize($conf['SmartAlbums']);
    75  
    76   if ( script_basename() == 'index' and $conf['SmartAlbums']['smart_is_forbidden'] )
     55
     56  if (script_basename() == 'index' and $conf['SmartAlbums']['smart_is_forbidden'])
    7757  {
    7858    add_event_handler('loc_end_section_init', 'smart_init_page_items');
    79     include_once(SMART_PATH.'include/page_items.php');
     59  }
     60
     61  if ($conf['SmartAlbums']['update_on_upload'])
     62  {
     63    add_event_handler('invalidate_user_cache', 'smart_make_all_associations');
    8064  }
    8165}
    82 
    83 /**
    84  * new tab on album properties page
    85  */
    86 function smart_tab($sheets, $id)
    87 {
    88   if ($id != 'album') return $sheets;
    89  
    90   global $category;
    91  
    92   if ($category['dir'] == null)
    93   {
    94     $sheets['smartalbum'] = array(
    95       'caption' => 'SmartAlbum',
    96       'url' => SMART_ADMIN.'-album&amp;cat_id='.$_GET['cat_id'],
    97       );
    98   }
    99  
    100   return $sheets;
    101 }
    102 
    103 
    104 /**
    105  * admin plugins menu link
    106  */
    107 function smart_admin_menu($menu)
    108 {
    109   array_push($menu, array(
    110       'NAME' => 'SmartAlbums',
    111       'URL' => SMART_ADMIN,
    112     ));
    113   return $menu;
    114 }
    115 
    116 ?>
Note: See TracChangeset for help on using the changeset viewer.