source:
extensions/flickr2piwigo/maintain.inc.php
@
28121
Last change on this file since 28121 was 26180, checked in by , 10 years ago | |
---|---|
File size: 1.5 KB |
Rev | Line | |
---|---|---|
[16063] | 1 | <?php |
[26180] | 2 | defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); |
[16063] | 3 | |
[26180] | 4 | class flickr2piwigo_maintain extends PluginMaintain |
5 | { | |
6 | private $installed = false; | |
7 | ||
8 | private $default_conf = array( | |
[16063] | 9 | 'api_key' => null, |
10 | 'secret_key' => null, | |
[26180] | 11 | ); |
[16063] | 12 | |
[26180] | 13 | function install($plugin_version, &$errors=array()) |
14 | { | |
15 | global $conf; | |
[16071] | 16 | |
[26180] | 17 | if (empty($conf['flickr2piwigo'])) |
18 | { | |
19 | $conf['flickr2piwigo'] = serialize($this->default_conf); | |
20 | conf_update_param('flickr2piwigo', $conf['flickr2piwigo']); | |
21 | } | |
[16063] | 22 | |
[26180] | 23 | mkgetdir(PHPWG_ROOT_PATH . $conf['data_location'] . 'flickr_cache/', MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR); |
[16063] | 24 | |
[26180] | 25 | $this->installed = true; |
26 | } | |
27 | ||
28 | function activate($plugin_version, &$errors=array()) | |
[16063] | 29 | { |
[26180] | 30 | if (!$this->installed) |
31 | { | |
32 | $this->install($plugin_version, $errors); | |
33 | } | |
[16063] | 34 | } |
[26180] | 35 | |
36 | function deactivate() | |
[16063] | 37 | { |
38 | } | |
39 | ||
[26180] | 40 | function uninstall() |
41 | { | |
42 | global $conf; | |
[16063] | 43 | |
[26180] | 44 | conf_delete_param('flickr2piwigo'); |
45 | ||
46 | self::rrmdir(PHPWG_ROOT_PATH . $conf['data_location'] . 'flickr_cache/'); | |
[16071] | 47 | } |
[26180] | 48 | |
49 | static function rrmdir($dir) | |
[16071] | 50 | { |
[26180] | 51 | if (!is_dir($dir)) |
[16071] | 52 | { |
[26180] | 53 | return false; |
54 | } | |
55 | $dir = rtrim($dir, '/'); | |
56 | $objects = scandir($dir); | |
57 | $return = true; | |
58 | ||
59 | foreach ($objects as $object) | |
60 | { | |
61 | if ($object !== '.' && $object !== '..') | |
[16071] | 62 | { |
[26180] | 63 | $path = $dir.'/'.$object; |
64 | if (filetype($path) == 'dir') | |
65 | { | |
66 | $return = $return && self::rrmdir($path); | |
67 | } | |
68 | else | |
69 | { | |
70 | $return = $return && @unlink($path); | |
71 | } | |
[16071] | 72 | } |
73 | } | |
[26180] | 74 | |
75 | return $return && @rmdir($dir); | |
[16071] | 76 | } |
[26180] | 77 | } |
Note: See TracBrowser
for help on using the repository browser.