source: extensions/flickr2piwigo/maintain.inc.php @ 26180

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

update for piwigo 2.6

File size: 1.5 KB
Line 
1<?php
2defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
3
4class flickr2piwigo_maintain extends PluginMaintain
5{
6  private $installed = false;
7
8  private $default_conf = array(
9    'api_key' => null,
10    'secret_key' => null,
11    );
12
13  function install($plugin_version, &$errors=array())
14  {
15    global $conf;
16
17    if (empty($conf['flickr2piwigo']))
18    {
19      $conf['flickr2piwigo'] = serialize($this->default_conf);
20      conf_update_param('flickr2piwigo', $conf['flickr2piwigo']);
21    }
22
23    mkgetdir(PHPWG_ROOT_PATH . $conf['data_location'] . 'flickr_cache/', MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR);
24
25    $this->installed = true;
26  }
27
28  function activate($plugin_version, &$errors=array())
29  {
30    if (!$this->installed)
31    {
32      $this->install($plugin_version, $errors);
33    }
34  }
35
36  function deactivate()
37  {
38  }
39
40  function uninstall()
41  {
42    global $conf;
43
44    conf_delete_param('flickr2piwigo');
45
46    self::rrmdir(PHPWG_ROOT_PATH . $conf['data_location'] . 'flickr_cache/');
47  }
48
49  static function rrmdir($dir)
50  {
51    if (!is_dir($dir))
52    {
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 !== '..')
62      {
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        }
72      }
73    }
74
75    return $return && @rmdir($dir);
76  }
77}
Note: See TracBrowser for help on using the repository browser.