> ------------------------------------------------------------------------------ See main.inc.php for release information EStat_Install : classe to manage plugin install --------------------------------------------------------------------------- */ include_once('estat_version.inc.php'); // => Don't forget to update this file !! include_once('estat_root.class.inc.php'); /* EStat class for install process */ class EStat_Install extends EStat_root { /* function for installation process return true if install process is ok, otherwise false */ public function install() { if(!file_exists($this->fileStatDir)) mkdir($this->fileStatDir, 0755, true); $this->initConfig(); $this->loadConfig(); // create Global Stat File $gStatFile=new StatDBGlobal($this->fileStatDir, self::FILE_GLOBAL); $gStatFile->open(ASDF_OPEN_WRITE); $gStatFile->close(); $this->config['installed']=ESTAT_VERSION2; $this->config['plugin.newInstall']='y'; $this->saveConfig(); GPCCore::register($this->getPluginName(), ESTAT_VERSION, ESTAT_GPC_NEEDED); return(true); } /* function for uninstall process */ public function uninstall() { //GPCCore::rmDir(dirname(GPCCore::getPiwigoSystemPath().'/'.PWG_LOCAL_DIR.self::DATA_DIRECTORY)); $this->deleteConfig(); GPCCore::unregister($this->getPluginName()); return(''); } public function activate() { $this->initConfig(); $this->loadConfig(); // check if ip database need to be updated $this->checkIpCountryFile(); /* * migration code */ switch($this->config['installed']) { case '01.00.00': //$this->updateFrom_010000(); default: // nothing to do... break; } $this->config['installed']=ESTAT_VERSION2; $this->saveConfig(); GPCCore::register($this->getPluginName(), ESTAT_VERSION, ESTAT_GPC_NEEDED); return(''); } public function deactivate() { } /** * update from release 1.0.0 * * -- dummy -- * */ private function updateFrom_010000() { return(false); } /** * check version of the ipCountry.bin file * * if database need an update, the config value 'plugin.newInstall' is set to "u" */ private function checkIpCountryFile() { if($this->config['plugin.newInstall']=='y') return(false); $dbCountry=new StatDBCountry($this->fileStatDir, self::FILE_COUNTRY); $ipFileInfo=$dbCountry->getIpFileInfo(ESTAT_PATH.'data/ipCountry.bin'); $ipDBVersion=$dbCountry->getInfoProperty('nfo', 'ipFileVersion'); if($ipFileInfo['fileVersion']>$ipDBVersion) { $this->config['plugin.newInstall']=='u'; return(true); } return(false); } } //class ?>