[3396] | 1 | <?php |
---|
| 2 | /* ----------------------------------------------------------------------------- |
---|
| 3 | Plugin : LMT |
---|
| 4 | Author : Grum |
---|
| 5 | email : grum@piwigo.org |
---|
| 6 | website : http://photos.grum.fr |
---|
| 7 | |
---|
| 8 | << May the Little SpaceFrog be with you ! >> |
---|
| 9 | ------------------------------------------------------------------------------ |
---|
| 10 | See main.inc.php for release information |
---|
| 11 | |
---|
| 12 | LMT_Install : classe to manage plugin install |
---|
| 13 | |
---|
| 14 | --------------------------------------------------------------------------- */ |
---|
[5548] | 15 | |
---|
| 16 | include_once('lmt_version.inc.php'); // => Don't forget to update this file !! |
---|
[11032] | 17 | include_once('lmt_root.class.inc.php'); |
---|
| 18 | include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCTables.class.inc.php'); |
---|
| 19 | include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCRequestBuilder.class.inc.php'); |
---|
[3396] | 20 | |
---|
| 21 | /* lmt class for install process */ |
---|
| 22 | class LMT_Install extends LMT_root |
---|
| 23 | { |
---|
| 24 | private $tablef; |
---|
| 25 | private $exportfile; |
---|
| 26 | |
---|
[5548] | 27 | public function __construct($prefixeTable, $filelocation) |
---|
[3396] | 28 | { |
---|
| 29 | parent::__construct($prefixeTable, $filelocation); |
---|
[5548] | 30 | $this->tablef= new GPCTables($this->tables); |
---|
[3396] | 31 | } |
---|
| 32 | |
---|
[5548] | 33 | public function __destruct() |
---|
| 34 | { |
---|
| 35 | unset($this->tablef); |
---|
| 36 | unset($this->exportfile); |
---|
| 37 | parent::__destruct(); |
---|
| 38 | } |
---|
| 39 | |
---|
| 40 | /* |
---|
| 41 | function for installation process |
---|
| 42 | return true if install process is ok, otherwise false |
---|
| 43 | */ |
---|
[3396] | 44 | public function install() |
---|
| 45 | { |
---|
[5548] | 46 | $this->initConfig(); |
---|
| 47 | $this->loadConfig(); |
---|
| 48 | $this->config['installed']=LMT_VERSION2; |
---|
| 49 | $this->saveConfig(); |
---|
| 50 | |
---|
[3396] | 51 | $tables_def=array( |
---|
| 52 | "CREATE TABLE `".$this->tables['images']."` ( |
---|
| 53 | `image_id` mediumint(8) unsigned NOT NULL default '0', |
---|
| 54 | `licence_type` char(8) NOT NULL default 'cc-none', |
---|
| 55 | `author_id` int UNSIGNED NOT NULL default '0', |
---|
| 56 | PRIMARY KEY (`image_id`), |
---|
| 57 | KEY `by_licence` (`licence_type`), |
---|
| 58 | KEY `by_author_id` (`author_id`) |
---|
[5548] | 59 | ) |
---|
| 60 | ENGINE=MyISAM |
---|
[3396] | 61 | CHARACTER SET utf8 COLLATE utf8_general_ci", |
---|
| 62 | |
---|
| 63 | "CREATE TABLE `".$this->tables['licence_author']."` ( |
---|
| 64 | `id` int UNSIGNED NOT NULL AUTO_INCREMENT, |
---|
| 65 | `text1` CHAR(25) NOT NULL, |
---|
| 66 | `text2` CHAR(25) NOT NULL, |
---|
| 67 | PRIMARY KEY (`id`) |
---|
| 68 | ) |
---|
| 69 | ENGINE = MyISAM |
---|
| 70 | CHARACTER SET utf8 COLLATE utf8_general_ci", |
---|
| 71 | ); |
---|
| 72 | |
---|
[7560] | 73 | $result=$this->tablef->create($tables_def); |
---|
| 74 | GPCCore::register($this->getPluginName(), LMT_VERSION, LMT_GPC_NEEDED); |
---|
| 75 | |
---|
| 76 | return($result); |
---|
[3396] | 77 | } |
---|
| 78 | |
---|
[10974] | 79 | |
---|
[3396] | 80 | /* |
---|
| 81 | function for uninstall process |
---|
| 82 | */ |
---|
| 83 | public function uninstall() |
---|
| 84 | { |
---|
[5548] | 85 | $this->deleteConfig(); |
---|
| 86 | $this->tablef->drop(); |
---|
[7560] | 87 | GPCCore::unregister($this->getPluginName()); |
---|
[3396] | 88 | return(''); |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | public function activate() |
---|
| 92 | { |
---|
| 93 | global $template; |
---|
| 94 | |
---|
[5548] | 95 | $this->initConfig(); |
---|
| 96 | $this->loadConfig(); |
---|
| 97 | $this->config['installed']=LMT_VERSION2; |
---|
| 98 | $this->saveConfig(); |
---|
[7560] | 99 | |
---|
| 100 | GPCCore::register($this->getPluginName(), LMT_VERSION, LMT_GPC_NEEDED); |
---|
| 101 | GPCRequestBuilder::register($this->getPluginName(), dirname($this->getFileLocation()).'/lmt_rb_callback.class.inc.php'); |
---|
[3396] | 102 | return(''); |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | public function deactivate() |
---|
| 106 | { |
---|
[7560] | 107 | GPCRequestBuilder::unregister($this->getPluginName()); |
---|
[3396] | 108 | } |
---|
[10974] | 109 | |
---|
[3396] | 110 | } //class |
---|
| 111 | |
---|
| 112 | ?> |
---|