source: extensions/Google2Piwigo/maintain.inc.php @ 28832

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

fix oauth flow

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