1 | <?php |
---|
2 | defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); |
---|
3 | |
---|
4 | class Google2Piwigo_maintain extends PluginMaintain |
---|
5 | { |
---|
6 | private $default_conf = array( |
---|
7 | 'api_key' => null, |
---|
8 | 'secret_key' => null, |
---|
9 | 'auth_endpoint' => 'https://accounts.google.com/o/oauth2/auth', |
---|
10 | 'token_endpoint' => 'https://accounts.google.com/o/oauth2/token' |
---|
11 | ); |
---|
12 | |
---|
13 | function install($plugin_version, &$errors=array()) |
---|
14 | { |
---|
15 | global $conf; |
---|
16 | |
---|
17 | if (empty($conf['google2piwigo'])) |
---|
18 | { |
---|
19 | conf_update_param('google2piwigo', $this->default_conf, true); |
---|
20 | } |
---|
21 | |
---|
22 | mkgetdir(PHPWG_ROOT_PATH . $conf['data_location'] . 'picasa_wa_cache/', MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR); |
---|
23 | } |
---|
24 | |
---|
25 | function update($old_version, $new_version, &$errors=array()) |
---|
26 | { |
---|
27 | $this->install($new_version, $errors); |
---|
28 | } |
---|
29 | |
---|
30 | function uninstall() |
---|
31 | { |
---|
32 | global $conf; |
---|
33 | |
---|
34 | conf_delete_param('google2piwigo'); |
---|
35 | |
---|
36 | self::rrmdir(PHPWG_ROOT_PATH . $conf['data_location'] . 'picasa_wa_cache/'); |
---|
37 | } |
---|
38 | |
---|
39 | static function rrmdir($dir) |
---|
40 | { |
---|
41 | if (!is_dir($dir)) |
---|
42 | { |
---|
43 | return false; |
---|
44 | } |
---|
45 | $dir = rtrim($dir, '/'); |
---|
46 | $objects = scandir($dir); |
---|
47 | $return = true; |
---|
48 | |
---|
49 | foreach ($objects as $object) |
---|
50 | { |
---|
51 | if ($object !== '.' && $object !== '..') |
---|
52 | { |
---|
53 | $path = $dir.'/'.$object; |
---|
54 | if (filetype($path) == 'dir') |
---|
55 | { |
---|
56 | $return = $return && self::rrmdir($path); |
---|
57 | } |
---|
58 | else |
---|
59 | { |
---|
60 | $return = $return && @unlink($path); |
---|
61 | } |
---|
62 | } |
---|
63 | } |
---|
64 | |
---|
65 | return $return && @rmdir($dir); |
---|
66 | } |
---|
67 | } |
---|