1 | <?php |
---|
2 | /* ----------------------------------------------------------------------------- |
---|
3 | Plugin : EStat |
---|
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 | EStat_Install : classe to manage plugin install |
---|
13 | |
---|
14 | --------------------------------------------------------------------------- */ |
---|
15 | |
---|
16 | include_once('estat_version.inc.php'); // => Don't forget to update this file !! |
---|
17 | include_once('estat_root.class.inc.php'); |
---|
18 | |
---|
19 | /* EStat class for install process */ |
---|
20 | class EStat_Install extends EStat_root |
---|
21 | { |
---|
22 | /* |
---|
23 | function for installation process |
---|
24 | return true if install process is ok, otherwise false |
---|
25 | */ |
---|
26 | public function install() |
---|
27 | { |
---|
28 | if(!file_exists($this->fileStatDir)) |
---|
29 | mkdir($this->fileStatDir, 0755, true); |
---|
30 | |
---|
31 | $this->initConfig(); |
---|
32 | $this->loadConfig(); |
---|
33 | |
---|
34 | // create Global Stat File |
---|
35 | $gStatFile=new StatDBGlobal($this->fileStatDir, self::FILE_GLOBAL); |
---|
36 | $gStatFile->open(ASDF_OPEN_WRITE); |
---|
37 | $gStatFile->close(); |
---|
38 | |
---|
39 | $this->config['installed']=ESTAT_VERSION2; |
---|
40 | $this->config['plugin.newInstall']='y'; |
---|
41 | $this->saveConfig(); |
---|
42 | |
---|
43 | GPCCore::register($this->getPluginName(), ESTAT_VERSION, ESTAT_GPC_NEEDED); |
---|
44 | return(true); |
---|
45 | } |
---|
46 | |
---|
47 | |
---|
48 | /* |
---|
49 | function for uninstall process |
---|
50 | */ |
---|
51 | public function uninstall() |
---|
52 | { |
---|
53 | //GPCCore::rmDir(dirname(GPCCore::getPiwigoSystemPath().'/'.PWG_LOCAL_DIR.self::DATA_DIRECTORY)); |
---|
54 | $this->deleteConfig(); |
---|
55 | GPCCore::unregister($this->getPluginName()); |
---|
56 | return(''); |
---|
57 | } |
---|
58 | |
---|
59 | public function activate() |
---|
60 | { |
---|
61 | $this->initConfig(); |
---|
62 | $this->loadConfig(); |
---|
63 | |
---|
64 | // check if ip database need to be updated |
---|
65 | $this->checkIpCountryFile(); |
---|
66 | |
---|
67 | /* |
---|
68 | * migration code |
---|
69 | */ |
---|
70 | switch($this->config['installed']) |
---|
71 | { |
---|
72 | case '01.00.00': |
---|
73 | //$this->updateFrom_010000(); |
---|
74 | default: |
---|
75 | // nothing to do... |
---|
76 | break; |
---|
77 | } |
---|
78 | |
---|
79 | $this->config['installed']=ESTAT_VERSION2; |
---|
80 | $this->saveConfig(); |
---|
81 | |
---|
82 | GPCCore::register($this->getPluginName(), ESTAT_VERSION, ESTAT_GPC_NEEDED); |
---|
83 | return(''); |
---|
84 | } |
---|
85 | |
---|
86 | public function deactivate() |
---|
87 | { |
---|
88 | } |
---|
89 | |
---|
90 | |
---|
91 | /** |
---|
92 | * update from release 1.0.0 |
---|
93 | * |
---|
94 | * -- dummy -- |
---|
95 | * |
---|
96 | */ |
---|
97 | private function updateFrom_010000() |
---|
98 | { |
---|
99 | return(false); |
---|
100 | } |
---|
101 | |
---|
102 | |
---|
103 | /** |
---|
104 | * check version of the ipCountry.bin file |
---|
105 | * |
---|
106 | * if database need an update, the config value 'plugin.newInstall' is set to "u" |
---|
107 | */ |
---|
108 | private function checkIpCountryFile() |
---|
109 | { |
---|
110 | if($this->config['plugin.newInstall']=='y') return(false); |
---|
111 | |
---|
112 | $dbCountry=new StatDBCountry($this->fileStatDir, self::FILE_COUNTRY); |
---|
113 | $ipFileInfo=$dbCountry->getIpFileInfo(ESTAT_PATH.'data/ipCountry.bin'); |
---|
114 | $ipDBVersion=$dbCountry->getInfoProperty('nfo', 'ipFileVersion'); |
---|
115 | |
---|
116 | if($ipFileInfo['fileVersion']>$ipDBVersion) |
---|
117 | { |
---|
118 | $this->config['plugin.newInstall']=='u'; |
---|
119 | return(true); |
---|
120 | } |
---|
121 | |
---|
122 | return(false); |
---|
123 | } |
---|
124 | |
---|
125 | } //class |
---|
126 | |
---|
127 | ?> |
---|