Changeset 17716 for extensions
- Timestamp:
- Sep 3, 2012, 3:06:50 PM (12 years ago)
- Location:
- extensions/SmartAlbums
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/SmartAlbums/main.inc.php
r17207 r17716 12 12 global $prefixeTable; 13 13 14 define('SMART_PATH', PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/');14 define('SMART_PATH', PHPWG_PLUGINS_PATH . 'SmartAlbums/'); 15 15 define('CATEGORY_FILTERS_TABLE', $prefixeTable . 'category_filters'); 16 define('SMART_ADMIN', get_root_url() . 'admin.php?page=plugin-' . basename(dirname(__FILE__))); 16 define('SMART_ADMIN', get_root_url() . 'admin.php?page=plugin-SmartAlbums'); 17 define('SMART_VERSION', '2.0.3'); 18 17 19 18 20 add_event_handler('invalidate_user_cache', 'smart_make_all_associations'); 19 21 add_event_handler('init', 'smart_init'); 20 22 23 if (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 21 32 include_once(SMART_PATH.'include/functions.inc.php'); 22 33 34 35 /** 36 * update plugin & unserialize conf & load language 37 */ 23 38 function smart_init() 24 39 { 25 global $conf ;40 global $conf, $pwg_loaded_plugins; 26 41 27 load_language('plugin.lang', SMART_PATH); 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 = ' 53 UPDATE '. PLUGINS_TABLE .' 54 SET version = "'. SMART_VERSION .'" 55 WHERE 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 } 28 71 $conf['SmartAlbums'] = unserialize($conf['SmartAlbums']); 29 72 … … 33 76 include_once(SMART_PATH.'include/page_items.php'); 34 77 } 35 else if (script_basename() == 'admin')36 {37 include_once(SMART_PATH.'include/cat_list.php');38 39 add_event_handler('loc_begin_cat_list', 'smart_cat_list');40 add_event_handler('tabsheet_before_select','smart_tab', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);41 add_event_handler('get_admin_plugin_menu_links', 'smart_admin_menu');42 add_event_handler('delete_categories', 'smart_delete_categories');43 }44 78 } 45 79 80 /** 81 * new tab on album properties page 82 */ 46 83 function smart_tab($sheets, $id) 47 84 { … … 61 98 } 62 99 100 101 /** 102 * admin plugins menu link 103 */ 63 104 function smart_admin_menu($menu) 64 105 { -
extensions/SmartAlbums/maintain.inc.php
r16939 r17716 2 2 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 3 3 4 global $prefixeTable; 5 define('smart_table', $prefixeTable . 'category_filters'); 6 7 define('smart_default_config', serialize(array( 8 'update_on_upload' => false, 9 'show_list_messages' => true, 10 'smart_is_forbidden' => true, 11 ))); 4 include_once(PHPWG_PLUGINS_PATH . 'SmartAlbums/include/install.inc.php'); 12 5 13 6 function plugin_install() 14 7 { 15 /* create table to store filters */ 16 pwg_query( 17 'CREATE TABLE IF NOT EXISTS `' . smart_table . '` ( 18 `category_id` smallint(5) unsigned NOT NULL, 19 `type` varchar(16) NOT NULL, 20 `cond` varchar(16) NULL, 21 `value` text 22 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 23 ;'); 24 25 /* add a collumn to image_category_table */ 26 pwg_query('ALTER TABLE `' . IMAGE_CATEGORY_TABLE . '` ADD `smart` ENUM(\'true\', \'false\') NOT NULL DEFAULT \'false\';'); 27 28 /* config parameter */ 29 conf_update_param('SmartAlbums', smart_default_config); 8 smart_albums_install(); 9 define('smart_albums_installed', true); 30 10 } 31 11 32 12 function plugin_activate() 33 13 { 34 global $conf; 35 36 if (!isset($conf['SmartAlbums'])) 14 if (!defined('smart_albums_installed')) 37 15 { 38 conf_update_param('SmartAlbums', smart_default_config); 39 } 40 else 41 { 42 $new_conf = unserialize($conf['SmartAlbums']); 43 // new param in 2.0.2 44 if (!isset($new_conf['smart_is_forbidden'])) 45 { 46 $new_conf['smart_is_forbidden'] = true; 47 conf_update_param('SmartAlbums', smart_default_config); 48 } 49 } 50 51 // some filters renamed in 2.0 52 $name_changes = array( 53 'the' => 'the_post', 54 'before' => 'before_post', 55 'after' => 'after_post', 56 'the_crea' => 'the_taken', 57 'before_crea' => 'before_taken', 58 'after_crea' => 'after_taken', 59 ); 60 foreach ($name_changes as $old => $new) 61 { 62 pwg_query('UPDATE ' . smart_table . ' SET cond = "'.$new.'" WHERE cond = "'.$old.'";'); 16 smart_albums_install(); 63 17 } 64 18 } 65 19 66 20 function plugin_uninstall() 67 { 68 pwg_query('DROP TABLE `' . smart_table . '`;'); 21 { 22 global $prefixeTable; 23 24 pwg_query('DROP TABLE `' . $prefixeTable . 'category_filters`;'); 69 25 pwg_query('ALTER TABLE `' . IMAGE_CATEGORY_TABLE . '` DROP `smart`;'); 70 26 pwg_query('DELETE FROM `' . CONFIG_TABLE . '` WHERE param = \'SmartAlbums\' LIMIT 1;');
Note: See TracChangeset
for help on using the changeset viewer.