source: extensions/AStat/maintain.inc.php @ 6695

Last change on this file since 6695 was 5546, checked in by grum, 15 years ago

Update the plugin for compatibility with Piwigo 2.1

  • Property svn:executable set to *
File size: 3.0 KB
RevLine 
[3394]1<?php
2/* -----------------------------------------------------------------------------
3  Plugin     : AStat.2
4  Author     : Grum
5    email    : grum@piwigo.org
6    website  : http://photos.grum.fr
7
8    << May the Little SpaceFrog be with you ! >>
9  ------------------------------------------------------------------------------
10  See main.inc.php for release information
11
12  --------------------------------------------------------------------------- */
13
[5423]14if(!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); }
[3394]15
[5423]16if(!defined('ASTAT_DIR')) define('ASTAT_DIR' , basename(dirname(__FILE__)));
17if(!defined('ASTAT_PATH')) define('ASTAT_PATH' , PHPWG_PLUGINS_PATH . ASTAT_DIR . '/');
[3394]18
[5546]19include_once('astat_version.inc.php');
20
[3394]21//ini_set('error_reporting', E_ALL);
22//ini_set('display_errors', true);
23
[5546]24global $gpc_installed, $gpcNeeded, $lang; //needed for plugin manager compatibility
[3394]25
26/* -----------------------------------------------------------------------------
27AStat-2 needs the Grum Plugin Classe
28----------------------------------------------------------------------------- */
29$gpc_installed=false;
[5546]30$gpcNeeded="3.0.0";
31if(file_exists(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php'))
[3394]32{
[5546]33  @include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php');
34  // need GPC release greater or equal than 3.0.0
35  if(CommonPlugin::checkGPCRelease(3,0,0))
[3394]36  {
37    @include_once("astat_aim.class.inc.php");
38    $gpc_installed=true;
39  }
40}
41
42function gpcMsgError(&$errors)
43{
[5546]44  global $gpcNeeded;
45  $msg=sprintf(l10n('To install this plugin, you need to install Grum Plugin Classes %s before'), $gpcNeeded);
46  if(is_array($errors))
47  {
48    array_push($errors, $msg);
49  }
50  else
51  {
52    $errors=Array($msg);
53  }
[3394]54}
55// -----------------------------------------------------------------------------
56
57
58load_language('plugin.lang', ASTAT_PATH);
59
[5423]60function plugin_install($plugin_id, $plugin_version, &$errors)
[3394]61{
[5546]62  global $prefixeTable, $gpc_installed, $gpcNeeded;
[3394]63  if($gpc_installed)
64  {
65    $obj = new AStat_AIM($prefixeTable, __FILE__);
[5546]66    $obj->deleteConfig();
67    $obj->initConfig();
68    $obj->my_config['installed']=ASTAT_VERSION2;
69    $obj->saveConfig();
70    GPCCore::register($obj->getPluginName(), ASTAT_VERSION, $gpcNeeded);
[3394]71  }
72  else
73  {
74    gpcMsgError($errors);
75  }
76}
77
78function plugin_activate($plugin_id, $plugin_version, &$errors)
79{
80  global $prefixeTable, $gpc_installed;
81  if($gpc_installed)
82  {
83    $obj = new AStat_AIM($prefixeTable, __FILE__);
[5546]84    $obj->initConfig();
85    $obj->loadConfig();
86    $obj->my_config['installed']=ASTAT_VERSION2;
87    $obj->saveConfig();
[3394]88    $obj->alter_history_section_enum('deleted_cat');
89  }
90  else
91  {
92    gpcMsgError($errors);
93  }
94}
95
96function plugin_deactivate($plugin_id)
97{
98}
99
100function plugin_uninstall($plugin_id)
101{
102  global $prefixeTable, $gpc_installed;
103  if($gpc_installed)
104  {
105    $obj = new AStat_AIM($prefixeTable, __FILE__);
[5546]106    $obj->deleteConfig();
107    GPCCore::unregister($obj->getPluginName());
[3394]108  }
109  else
110  {
111    gpcMsgError($errors);
112  }
113}
114
115
116
117?>
Note: See TracBrowser for help on using the repository browser.