Ignore:
Timestamp:
Dec 26, 2013, 12:48:21 PM (10 years ago)
Author:
mistic100
Message:

update for 2.6

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/instagram2piwigo/maintain.inc.php

    r24817 r26199  
    11<?php
    2 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
     2defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
    33
    4 define(
    5   'Instagram2Piwigo_default_config',
    6   serialize(array(
     4class instagram2piwigo_maintain extends PluginMaintain
     5{
     6  private $installed = false;
     7
     8  private $default_conf = array(
    79    'api_key' => null,
    810    'secret_key' => null,
    9     ))
    10   );
     11    );
    1112
     13  function install($plugin_version, &$errors=array())
     14  {
     15    global $conf;
    1216
    13 function plugin_install()
    14 {
    15   global $conf;
    16  
    17   conf_update_param('Instagram2Piwigo', Instagram2Piwigo_default_config);
    18  
    19   mkdir($conf['data_location'].'instagram_cache/', 0755);
    20 }
     17    if (empty($conf['Instagram2Piwigo']))
     18    {
     19      $conf['Instagram2Piwigo'] = serialize($this->default_conf);
     20      conf_update_param('Instagram2Piwigo', $conf['Instagram2Piwigo']);
     21    }
    2122
    22 function plugin_activate()
    23 {
    24   global $conf;
     23    mkgetdir(PHPWG_ROOT_PATH . $conf['data_location'] . 'instagram_cache/', MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR);
    2524
    26   if (empty($conf['Instagram2Piwigo']))
     25    $this->installed = true;
     26  }
     27
     28  function activate($plugin_version, &$errors=array())
    2729  {
    28     conf_update_param('Instagram2Piwigo', Instagram2Piwigo_default_config);
     30    if (!$this->installed)
     31    {
     32      $this->install($plugin_version, $errors);
     33    }
    2934  }
    30  
    31   if (!file_exists($conf['data_location'].'instagram_cache/'))
     35
     36  function deactivate()
    3237  {
    33     mkdir($conf['data_location'].'instagram_cache/', 0755);
     38  }
     39
     40  function uninstall()
     41  {
     42    global $conf;
     43
     44    conf_delete_param('Instagram2Piwigo');
     45
     46    self::rrmdir(PHPWG_ROOT_PATH . $conf['data_location'] . 'instagram_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);
    3476  }
    3577}
    36 
    37 function plugin_uninstall()
    38 {
    39   global $conf;
    40  
    41   pwg_query('DELETE FROM `'. CONFIG_TABLE .'` WHERE param = "Instagram2Piwigo";');
    42   unset($conf['Instagram2Piwigo']);
    43  
    44   rrmdir($conf['data_location'].'instagram_cache/');
    45 }
    46 
    47 function rrmdir($dir)
    48 {
    49   if (!is_dir($dir))
    50   {
    51     return false;
    52   }
    53   $dir = rtrim($dir, '/');
    54   $objects = scandir($dir);
    55   $return = true;
    56  
    57   foreach ($objects as $object)
    58   {
    59     if ($object !== '.' && $object !== '..')
    60     {
    61       $path = $dir.'/'.$object;
    62       if (filetype($path) == 'dir')
    63       {
    64         $return = $return && rrmdir($path);
    65       }
    66       else
    67       {
    68         $return = $return && @unlink($path);
    69       }
    70     }
    71   }
    72  
    73   return $return && @rmdir($dir);
    74 }
    75 
    76 ?>
Note: See TracChangeset for help on using the changeset viewer.