Changeset 28990 for extensions/LLGBO2/maintain.inc.php
- Timestamp:
- Jul 7, 2014, 9:26:18 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/LLGBO2/maintain.inc.php
r22143 r28990 24 24 // | USA. | 25 25 // +-----------------------------------------------------------------------+ 26 /* */ 27 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 26 28 27 // ****************************************** 28 // ** Database install - uninstall queries ** 29 // ****************************************** 30 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 31 function plugin_install() 32 { global $prefixeTable,$conf; 33 if (!defined('LLGBO_PATH')) 34 {define('LLGBO_PATH', PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)). '/');} 35 include(LLGBO_PATH.'defaultvalues.php'); 36 plugin_uninstall(); // en cas de mauvaise deinstallation anterieure 37 $q = ' 38 INSERT INTO '.CONFIG_TABLE.' (param,value,comment) 39 VALUES 40 ("LLGBO","'.$plugvalues.'","look like gbo global settings");'; 41 pwg_query($q); 42 $q = ' 43 INSERT INTO '.CONFIG_TABLE.' (param,value,comment) 44 VALUES 45 ("LLGBOTOOLTIP","'.$ttvalues.'","look like gbo tooltip settings");'; 46 pwg_query($q); 47 $q = ' 48 INSERT INTO '.CONFIG_TABLE.' (param,value,comment) 49 VALUES 50 ("LLGBOFRAME","'.$frvalues.'","look like gbo frame settings");'; 51 pwg_query($q); 52 $q = ' 53 INSERT INTO '.CONFIG_TABLE.' (param,value,comment) 54 VALUES 55 ("LLGBOHEADER","'.$headvalues.'","look like gbo header settings");'; 56 pwg_query($q); 57 58 $conf['LLGBO_SETTINGS'] = explode("," , $plugvalues); 59 $conf['LLGBO_TOOLTIP'] = explode(",",$ttvalues); 60 $conf['LLGBO_FRAME'] = explode (",", $frvalues); 61 $conf['LLGBO_HEADER'] = explode (",", $headvalues); 62 29 class MyLLGBO_maintain extends PluginMaintain 30 { 31 // +-----------------------------------------------------------------------+ 32 // +--------------- Install all settings --------------------------------+ 33 // +-----------------------------------------------------------------------+ 34 function install($plugin_version, &$errors=array()) { 35 global $conf; 36 // +-----------------------------------------------------------------------+ 37 // +----------------- default values ---------------------------+ 38 // +-----------------------------------------------------------------------+ 39 include(LLGBO_PATH.'defaultvalues.php'); 40 // +-----------------------------------------------------------------------+ 41 if (empty($conf['LLGBO2settings'])) 42 { if (isset($conf['LLGBO'])) // compatibility 2.6 --> 2.7 43 { $Oldvalues = explode("," , $conf['LLGBO']); 44 foreach($Oldvalues as $cle => $valeur) 45 { if ($Oldvalues[$cle] == 'true' ) 46 {$Oldvalues[$cle] = (boolean)true ;} else { $Oldvalues[$cle] = (boolean)false;} 47 } 48 $default_Main = array( 49 'version' => 1, 50 'frame' => $Oldvalues[0] , 51 'tooltipdisp' => $Oldvalues[1], 52 'exifunderbt' => $Oldvalues[2], 53 'titleframe' => $Oldvalues[5], 54 'manageheader'=> $Oldvalues[6], 55 'alwaysdisplayexif' => $Oldvalues[10],); 56 conf_delete_param('LLGBO'); // old values before 2.7 57 } 58 conf_update_param('LLGBO2settings',serialize($default_Main), true); 59 } 60 // +-----------------------------------------------------------------------+ 61 if (empty($conf['LLGBO2tooltip'])) 62 { if (isset($conf['LLGBOTOOLTIP'])) // compatibility 2.6 --> 2.7 63 { $Oldvalues = explode("," , $conf['LLGBOTOOLTIP']); 64 $default_tooltip = array( 65 'TT-width' => $Oldvalues[0], 66 'TT-size' => $Oldvalues[1], 67 'TT-bordercolor' => $Oldvalues[2], 68 'TT-bgcolor' => $Oldvalues[3], 69 'TT-titlecolor' => $Oldvalues[4], 70 'TT-textcolor' => $Oldvalues[5]); 71 72 conf_delete_param('LLGBOTOOLTIP'); // old values before 2.7 73 } 74 conf_update_param('LLGBO2tooltip',serialize($default_tooltip), true); 75 } 76 // +-----------------------------------------------------------------------+ 77 if (empty($conf['LLGBO2frame'])) 78 { if (isset($conf['LLGBOFRAME'])) // compatibility 2.6 --> 2.7 79 { $Oldvalues = explode("," , $conf['LLGBOFRAME']); 80 $i=0; 81 for ($x = 1 ;$x < 32 ; $x =$x +2) 82 { $newcolors[$i] = $Oldvalues[$x]; 83 $newsizes[$i] = $Oldvalues[$x +1]; 84 $i = $i +1; 85 } 86 $default_frame = array( 87 'FR-titlecolor' => $Oldvalues[0], 88 'FR-sizes' => $newsizes, 89 'FR-colors' => $newcolors ); 90 91 conf_delete_param('LLGBOFRAME'); // old values before 2.7 92 } 93 conf_update_param('LLGBO2frame', serialize($default_frame), true); 94 } 95 // +-----------------------------------------------------------------------+ 96 if (empty($conf['LLGBO2header'])) 97 { if (isset($conf['LLGBOHEADER'])) // compatibility 2.6 --> 2.7 98 { $Oldvalues = explode("," , $conf['LLGBOHEADER']); 99 $i = 0; 100 foreach($default_header['HD-dispheader'] as $cle => $valeur) 101 { if ($Oldvalues[$i] == 'true' ) {$Oldvalues[$i] = (boolean)true ;} else { $Oldvalues[$i] = (boolean)false;} 102 $default_header['HD-dispheader'][$cle] = $Oldvalues[$i]; 103 $i = $i +1;} 104 conf_delete_param('LLGBOHEADER'); // old values before 2.7 105 } 106 conf_update_param('LLGBO2header',serialize($default_header), true); 107 } 108 } 109 110 111 // +-----------------------------------------------------------------------+ 112 // +-----------------------------------------------------------------------+ 113 function activate($plugin_version, &$errors=array()) 114 { $this->install($plugin_version, $errors); 115 } 116 // +-----------------------------------------------------------------------+ 117 function deactivate() { 118 /* */ 119 } 120 // +-----------------------------------------------------------------------+ 121 function uninstall() { 122 conf_delete_param('LLGBO2settings'); 123 conf_delete_param('LLGBO2tooltip'); 124 conf_delete_param('LLGBO2frame'); 125 conf_delete_param('LLGBO2header'); 126 } 63 127 } 64 function plugin_activate()65 { global $prefixeTable,$conf;66 ///////////////////////////////////////////////////67 // Vérification de la config, si pas bon -> reinstallation68 69 //70 if ( (!isset($conf['LLGBO'])) or (substr_count($conf['LLGBO'], ',') != 10)71 or (!isset($conf['LLGBOTOOLTIP'])) or (substr_count($conf['LLGBOTOOLTIP'], ',') != 5)72 or (!isset($conf['LLGBOFRAME'])) or (substr_count($conf['LLGBOFRAME'], ',') != 32)73 or (!isset($conf['LLGBOHEADER'])) or (substr_count($conf['LLGBOHEADER'], ',') != 21))74 {75 plugin_install(); }76 }77 78 function plugin_uninstall()79 { global $prefixeTable;80 $q = '81 DELETE FROM '.CONFIG_TABLE.' WHERE param like "LLGBO%" LIMIT 5;';82 pwg_query( $q );83 }84 85 128 ?>
Note: See TracChangeset
for help on using the changeset viewer.