source: extensions/UserStat/maintain.inc.php @ 8295

Last change on this file since 8295 was 5549, 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
Line 
1<?php
2/* -----------------------------------------------------------------------------
3  Plugin     : UserStat
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//ini_set('error_reporting', E_ALL);
14//ini_set('display_errors', true);
15
16include_once('userstat_version.inc.php'); // => Don't forget to update this file !!
17
18if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); }
19
20if(!defined('USERSTAT_DIR')) define('USERSTAT_DIR' , basename(dirname(__FILE__)));
21if(!defined('USERSTAT_PATH')) define('USERSTAT_PATH' , PHPWG_PLUGINS_PATH . USERSTAT_DIR . '/');
22
23
24global $gpc_installed, $gpcNeeded, $lang; //needed for plugin manager compatibility
25
26/* -----------------------------------------------------------------------------
27UserStat needs the Grum Plugin Classe
28----------------------------------------------------------------------------- */
29$gpc_installed=false;
30$gpcNeeded="3.0.0";
31if(file_exists(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php'))
32{
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))
36  {
37    @include_once("userstat_aim.class.inc.php");
38    $gpc_installed=true;
39  }
40}
41
42function gpcMsgError(&$errors)
43{
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  }
54}
55// -----------------------------------------------------------------------------
56
57
58load_language('plugin.lang', USERSTAT_PATH);
59
60function plugin_install($plugin_id, $plugin_version, &$errors)
61{
62  global $prefixeTable, $gpc_installed, $gpcNeeded;
63  if($gpc_installed)
64  {
65    $obj = new UserStat_AIM($prefixeTable, __FILE__);
66    $obj->deleteConfig();
67    $obj->initConfig();
68    $obj->my_config['installed']=USERSTAT_VERSION2;
69    $obj->saveConfig();
70    GPCCore::register($obj->getPluginName(), USERSTAT_VERSION, $gpcNeeded);
71  }
72  else
73  {
74    gpcMsgError($errors);
75  }
76}
77
78function plugin_activate($plugin_id, $plugin_version, &$errors)
79{
80  global $prefixeTable, $gpc_installed, $gpcNeeded;
81  if($gpc_installed)
82  {
83    $obj = new UserStat_AIM($prefixeTable, __FILE__);
84    $obj->initConfig();
85    $obj->loadConfig();
86    $obj->my_config['installed']=USERSTAT_VERSION2;
87    $obj->saveConfig();
88  }
89  else
90  {
91    gpcMsgError($errors);
92  }
93}
94
95function plugin_deactivate($plugin_id)
96{
97}
98
99function plugin_uninstall($plugin_id)
100{
101  global $prefixeTable, $gpc_installed;
102  if($gpc_installed)
103  {
104    $obj = new UserStat_AIM($prefixeTable, __FILE__);
105    $obj->deleteConfig();
106    GPCCore::unregister($obj->getPluginName());
107  }
108  else
109  {
110    gpcMsgError($errors);
111  }
112}
113
114
115
116?>
Note: See TracBrowser for help on using the repository browser.