Changeset 26665 for extensions/typetags/maintain.inc.php
- Timestamp:
- Jan 12, 2014, 7:13:40 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/typetags/maintain.inc.php
r21361 r26665 1 1 <?php 2 if (!defined('PHPWG_ROOT_PATH'))die('Hacking attempt!');2 defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); 3 3 4 function plugin_install() 4 class typetags_maintain extends PluginMaintain 5 5 { 6 global $prefixeTable;6 private $installed = false; 7 7 8 $query = 'SHOW FULL COLUMNS FROM ' . TAGS_TABLE . ';'; 9 $result = array_from_query($query, 'Field'); 10 if (!in_array('id_typetags', $result)) 8 private $default_conf = array( 9 'show_all'=>true, 10 ); 11 12 function install($plugin_version, &$errors=array()) 11 13 { 12 pwg_query('ALTER TABLE '.TAGS_TABLE.' ADD COLUMN `id_typetags` SMALLINT(5);'); 13 } 14 global $conf, $prefixeTable; 14 15 15 $result = pwg_query('SHOW TABLES LIKE "' . $prefixeTable .'typetags"'); 16 if (!pwg_db_num_rows($result)) 17 { 16 if (empty($conf['TypeTags'])) 17 { 18 $conf['TypeTags'] = serialize($this->default_conf); 19 conf_update_param('TypeTags', $conf['TypeTags']); 20 } 21 22 $result = pwg_query('SHOW COLUMNS FROM `' . TAGS_TABLE . '` LIKE "id_typetags";'); 23 if (!pwg_db_num_rows($result)) 24 { 25 pwg_query('ALTER TABLE `' . TAGS_TABLE . '` ADD `id_typetags` SMALLINT(5) DEFAULT NULL;'); 26 } 27 18 28 $query = ' 19 CREATE TABLE `'. $prefixeTable .'typetags` (29 CREATE TABLE IF NOT EXISTS `' . $prefixeTable . 'typetags` ( 20 30 `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, 21 31 `name` varchar(255) NOT NULL, … … 25 35 ;'; 26 36 pwg_query($query); 37 38 $this->installed = true; 27 39 } 28 29 conf_update_param('TypeTags', serialize(array('show_all'=>true)));30 }31 40 32 function plugin_activate() 33 { 34 global $conf; 35 36 if (!isset($conf['TypeTags'])) 41 function activate($plugin_version, &$errors=array()) 37 42 { 38 conf_update_param('TypeTags', serialize(array('show_all'=>true))); 43 if (!$this->installed) 44 { 45 $this->install($plugin_version, $errors); 46 } 47 } 48 49 function deactivate() 50 { 51 } 52 53 function uninstall() 54 { 55 global $prefixeTable; 56 57 conf_delete_param('TypeTags'); 58 59 pwg_query('ALTER TABLE `' . TAGS_TABLE . '` DROP `id_typetags`'); 60 pwg_query('DROP TABLE `' . $prefixeTable . 'typetags`;'); 39 61 } 40 62 } 41 42 function plugin_uninstall()43 {44 global $prefixeTable;45 46 pwg_query('ALTER TABLE '.TAGS_TABLE.' DROP COLUMN `id_typetags`');47 pwg_query('DROP TABLE '. $prefixeTable .'typetags;');48 pwg_query('DELETE FROM '.CONFIG_TABLE.' WHERE param = "TypeTags" LIMIT 1;');49 }50 51 ?>
Note: See TracChangeset
for help on using the changeset viewer.