source: extensions/flickr2piwigo/maintain.class.php @ 28833

Last change on this file since 28833 was 28833, checked in by mistic100, 10 years ago

use new maintain class

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