Changeset 3262 for plugins/dcFilterDuplicate/_install.php
- Timestamp:
- 11/14/13 08:32:17 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/dcFilterDuplicate/_install.php
r2902 r3262 1 1 <?php 2 2 # -- BEGIN LICENSE BLOCK ---------------------------------- 3 # 3 4 # This file is part of dcFilterDuplicate, a plugin for Dotclear 2. 4 5 # 5 # Copyright (c) 2009-201 1 JCDenis and contributors6 # jcdenis@gdwd.com6 # Copyright (c) 2009-2013 Jean-Christian Denis and contributors 7 # contact@jcdenis.fr http://jcd.lv 7 8 # 8 9 # Licensed under the GPL version 2.0 license. 9 10 # A copy of this license is available in LICENSE file or at 10 11 # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 12 # 11 13 # -- END LICENSE BLOCK ------------------------------------ 12 14 13 if (!defined('DC_CONTEXT_ADMIN')) {return;}15 if (!defined('DC_CONTEXT_ADMIN')) { 14 16 15 # Get new version 16 $new_version = $core->plugins->moduleInfo('dcFilterDuplicate','version'); 17 $old_version = $core->getVersion('dcFilterDuplicate'); 17 return null; 18 } 18 19 19 # Compare versions 20 if (version_compare($old_version,$new_version,'>=')) {return;} 20 # -- Module specs -- 21 21 22 # Install or update 23 try 24 { 25 # Check version 26 if (version_compare(str_replace("-r","-p",DC_VERSION),'2.2-alpha','<')) 27 { 28 throw new Exception('dcFilterDuplicate requires Dotclear 2.2'); 22 $dc_min = '2.6'; 23 $mod_id = 'dcFilterDuplicate'; 24 $mod_conf = array( 25 array( 26 'dcfilterduplicate_minlen', 27 'Minimum lenght of comment to filter', 28 30, 29 'integer' 30 ) 31 ); 32 33 # -- Nothing to change below -- 34 35 try { 36 37 # Check module version 38 if (version_compare( 39 $core->getVersion($mod_id), 40 $core->plugins->moduleInfo($mod_id, 'version'), 41 '>=' 42 )) { 43 44 return null; 29 45 } 30 31 # Settings32 $core->blog->settings->addNamespace('dcFilterDuplicate');33 $core->blog->settings->dcFilterDuplicate->put('dcfilterduplicate_minlen',30,'integer','Minimum lenght of comment to filter',false,true);34 46 35 # Version 36 $core->setVersion('dcFilterDuplicate',$new_version); 47 # Check Dotclear version 48 if (!method_exists('dcUtils', 'versionsCompare') 49 || dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)) { 50 throw new Exception(sprintf( 51 '%s requires Dotclear %s', $mod_id, $dc_min 52 )); 53 } 54 55 # Set module settings 56 $core->blog->settings->addNamespace($mod_id); 57 foreach($mod_conf as $v) { 58 $core->blog->settings->{$mod_id}->put( 59 $v[0], $v[2], $v[3], $v[1], false, true 60 ); 61 } 62 63 # Set module version 64 $core->setVersion( 65 $mod_id, 66 $core->plugins->moduleInfo($mod_id, 'version') 67 ); 37 68 38 69 return true; 39 70 } 40 catch (Exception $e) 41 { 71 catch (Exception $e) { 42 72 $core->error->add($e->getMessage()); 73 43 74 return false; 44 75 } 45 ?>
Note: See TracChangeset
for help on using the changeset viewer.