> ------------------------------------------------------------------------------ See main.inc.php for release information LMT_Install : classe to manage plugin install --------------------------------------------------------------------------- */ include_once('lmt_version.inc.php'); // => Don't forget to update this file !! @include_once('lmt_root.class.inc.php'); @include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCTables.class.inc.php'); /* lmt class for install process */ class LMT_Install extends LMT_root { private $tablef; private $exportfile; public function __construct($prefixeTable, $filelocation) { parent::__construct($prefixeTable, $filelocation); $this->tablef= new GPCTables($this->tables); $this->exportfile=dirname($this->getFileLocation()).'/'.$this->getPluginNameFiles().'.sql'; } public function __destruct() { unset($this->tablef); unset($this->exportfile); parent::__destruct(); } /* function for installation process return true if install process is ok, otherwise false */ public function install() { $this->initConfig(); $this->loadConfig(); $this->config['installed']=LMT_VERSION2; $this->saveConfig(); $tables_def=array( "CREATE TABLE `".$this->tables['images']."` ( `image_id` mediumint(8) unsigned NOT NULL default '0', `licence_type` char(8) NOT NULL default 'cc-none', `author_id` int UNSIGNED NOT NULL default '0', PRIMARY KEY (`image_id`), KEY `by_licence` (`licence_type`), KEY `by_author_id` (`author_id`) ) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci", "CREATE TABLE `".$this->tables['licence_author']."` ( `id` int UNSIGNED NOT NULL AUTO_INCREMENT, `text1` CHAR(25) NOT NULL, `text2` CHAR(25) NOT NULL, PRIMARY KEY (`id`) ) ENGINE = MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci", ); //if present, try to import backup //if backup file $import=$this->tablef->import($this->exportfile); if($import['errors']<0) { $result=$this->tablef->create($tables_def); return($result); } else { return(true); } } /* function for uninstall process */ public function uninstall() { $this->tablef->export($this->exportfile); $this->deleteConfig(); $this->tablef->drop(); return(''); } public function activate() { global $template; $this->initConfig(); $this->loadConfig(); $this->config['installed']=LMT_VERSION2; $this->saveConfig(); return(''); } public function deactivate() { } } //class ?>