[3681] | 1 | <?php |
---|
| 2 | /* ----------------------------------------------------------------------------- |
---|
| 3 | Plugin : Advanced Menu Manager |
---|
| 4 | Author : Grum |
---|
| 5 | email : grum@grum.dnsalias.com |
---|
[5421] | 6 | website : http://photos.grum.fr |
---|
[3681] | 7 | PWG user : http://forum.phpwebgallery.net/profile.php?id=3706 |
---|
| 8 | |
---|
| 9 | << May the Little SpaceFrog be with you ! >> |
---|
| 10 | ------------------------------------------------------------------------------ |
---|
| 11 | See main.inc.php for release information |
---|
| 12 | |
---|
| 13 | MyPolls_Install : classe to manage plugin install |
---|
| 14 | |
---|
| 15 | --------------------------------------------------------------------------- */ |
---|
[5421] | 16 | include_once('amm_version.inc.php'); |
---|
| 17 | include_once('amm_root.class.inc.php'); |
---|
[5545] | 18 | include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCTables.class.inc.php'); |
---|
[3681] | 19 | |
---|
| 20 | |
---|
| 21 | class AMM_install extends AMM_root |
---|
| 22 | { |
---|
[5545] | 23 | private $tablesManager; |
---|
[3681] | 24 | private $exportfile; |
---|
| 25 | |
---|
| 26 | public function AMM_install($prefixeTable, $filelocation) |
---|
| 27 | { |
---|
| 28 | parent::__construct($prefixeTable, $filelocation); |
---|
[5545] | 29 | $this->tablesManager= new GPCTables($this->tables); |
---|
| 30 | $this->exportfile=dirname($this->getFileLocation()).'/'.$this->getPluginNameFiles().'.sql'; |
---|
[3681] | 31 | } |
---|
| 32 | |
---|
[4391] | 33 | /* |
---|
| 34 | function for installation process |
---|
| 35 | return true if install process is ok, otherwise false |
---|
| 36 | */ |
---|
[3681] | 37 | public function install() |
---|
| 38 | { |
---|
[5545] | 39 | $this->initConfig(); |
---|
| 40 | $this->loadConfig(); |
---|
| 41 | $this->config['installed']=AMM_VERSION2; |
---|
| 42 | $this->saveConfig(); |
---|
[3681] | 43 | |
---|
| 44 | $tables_def=array( |
---|
| 45 | "CREATE TABLE `".$this->tables['urls']."` ( |
---|
| 46 | `id` int(11) NOT NULL auto_increment, |
---|
| 47 | `label` varchar(50) NOT NULL default '', |
---|
| 48 | `url` varchar(255) NOT NULL default '', |
---|
| 49 | `mode` int(11) NOT NULL default '0', |
---|
| 50 | `icon` varchar(50) NOT NULL default '', |
---|
| 51 | `position` int(11) NOT NULL default '0', |
---|
| 52 | `visible` char(1) NOT NULL default 'y', |
---|
| 53 | PRIMARY KEY (`id`), |
---|
| 54 | KEY `order_key` (`position`) |
---|
| 55 | )", |
---|
| 56 | |
---|
| 57 | "CREATE TABLE `".$this->tables['personalised']."` ( |
---|
| 58 | `id` int(11) NOT NULL default '0', |
---|
| 59 | `lang` varchar(5) NOT NULL default '', |
---|
[5421] | 60 | `title` varchar(255) NOT NULL default '', |
---|
[3681] | 61 | `content` text NOT NULL, |
---|
| 62 | `visible` char(1) NOT NULL default 'y', |
---|
[5421] | 63 | `nfo` varchar(255) NOT NULL default '', |
---|
[3681] | 64 | PRIMARY KEY (`id`,`lang`) |
---|
| 65 | )" |
---|
| 66 | ); |
---|
| 67 | //$table_def array |
---|
| 68 | $tables_def = create_table_add_character_set($tables_def); |
---|
[5545] | 69 | $result=$this->tablesManager->create($tables_def); |
---|
[3681] | 70 | return($result); |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | |
---|
| 74 | /* |
---|
| 75 | function for uninstall process |
---|
| 76 | */ |
---|
| 77 | public function uninstall() |
---|
| 78 | { |
---|
[5545] | 79 | $this->tablesManager->export($this->exportfile); |
---|
| 80 | $this->deleteConfig(); |
---|
| 81 | $this->tablesManager->drop(); |
---|
[3681] | 82 | } |
---|
| 83 | |
---|
| 84 | public function activate() |
---|
| 85 | { |
---|
| 86 | global $template; |
---|
| 87 | |
---|
[5545] | 88 | $this->initConfig(); |
---|
| 89 | $this->loadConfig(); |
---|
[5421] | 90 | |
---|
| 91 | $this->udpateTablesDef(); |
---|
| 92 | |
---|
[5545] | 93 | $this->config['installed']=AMM_VERSION2; //update the installed release number |
---|
| 94 | $this->saveConfig(); |
---|
[5421] | 95 | } |
---|
| 96 | |
---|
| 97 | public function deactivate() |
---|
| 98 | { |
---|
| 99 | } |
---|
| 100 | |
---|
| 101 | |
---|
| 102 | /** |
---|
| 103 | * update tables & config between releases |
---|
| 104 | * |
---|
| 105 | */ |
---|
| 106 | protected function udpateTablesDef() |
---|
| 107 | { |
---|
[4391] | 108 | /* AMM release earlier than the 2.1.3 uses two parameters to manage the display |
---|
| 109 | * of the menu items ("amm_sections_modspecials" and "amm_sections_modmenu") |
---|
| 110 | * |
---|
| 111 | * These two parameters are replaced by a single parameter "amm_sections_items" |
---|
| 112 | * |
---|
| 113 | * This function aim to import the old conf into the new conf property |
---|
| 114 | */ |
---|
[5545] | 115 | if(isset($this->config['amm_sections_modspecials'])) |
---|
[4391] | 116 | { |
---|
[5545] | 117 | foreach($this->config['amm_sections_modspecials'] as $key=>$val) |
---|
[4391] | 118 | { |
---|
[5545] | 119 | $this->config['amm_sections_items'][$key]['visibility']=($val=="y")?"guest,generic,normal,admin/":"admin/"; |
---|
[4391] | 120 | } |
---|
[5545] | 121 | unset($this->config['amm_sections_modspecials']); |
---|
[4391] | 122 | } |
---|
| 123 | |
---|
[5545] | 124 | if(isset($this->config['amm_sections_modmenu'])) |
---|
[4391] | 125 | { |
---|
[5545] | 126 | foreach($this->config['amm_sections_modmenu'] as $key=>$val) |
---|
[4391] | 127 | { |
---|
[5545] | 128 | $this->config['amm_sections_items'][$key]['visibility']=($val=="y")?"guest,generic,normal,admin/":"admin/"; |
---|
[4391] | 129 | } |
---|
[5545] | 130 | unset($this->config['amm_sections_modmenu']); |
---|
[4391] | 131 | } |
---|
| 132 | |
---|
[5545] | 133 | if(!array_key_exists('installed', $this->config)) |
---|
[5421] | 134 | { |
---|
| 135 | /* |
---|
| 136 | * if key does not exist, probably try to update a plugin older than the |
---|
| 137 | * 2.2.0 release |
---|
| 138 | */ |
---|
[5545] | 139 | $this->config['installed']="02.01.06"; |
---|
[5421] | 140 | } |
---|
[3681] | 141 | |
---|
[5545] | 142 | if($this->config['installed']<="02.01.06") |
---|
[5421] | 143 | { |
---|
| 144 | /* |
---|
| 145 | * 2.2.0 updates |
---|
| 146 | * |
---|
| 147 | * - update fields length for table 'personalised' |
---|
| 148 | * - update config for menu translation |
---|
| 149 | */ |
---|
| 150 | $sql="ALTER TABLE `".$this->tables['personalised']."` |
---|
| 151 | MODIFY COLUMN `title` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, |
---|
| 152 | MODIFY COLUMN `nfo` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;"; |
---|
| 153 | pwg_query($sql); |
---|
| 154 | |
---|
[5545] | 155 | foreach($this->config['amm_sections_items'] as $key => $val) |
---|
[5421] | 156 | { |
---|
[5545] | 157 | $this->config['amm_sections_items'][$key]['translation'] = $this->defaultMenus[$key]['translation']; |
---|
[5421] | 158 | } |
---|
| 159 | } |
---|
[3681] | 160 | } |
---|
| 161 | |
---|
| 162 | } //class |
---|
| 163 | |
---|
| 164 | ?> |
---|