source: extensions/instagram2piwigo/maintain.inc.php @ 26980

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

update for 2.6

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