source: extensions/ColorStat/maintain.inc.php @ 6107

Last change on this file since 6107 was 6107, checked in by grum, 14 years ago

Plugin is now in a usable state (color analysis is not yet tuned)

  • Property svn:executable set to *
File size: 3.2 KB
Line 
1<?php
2/* -----------------------------------------------------------------------------
3  Plugin     : ColorStat
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
14if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); }
15
16if(!defined('CSTAT_DIR')) define('CSTAT_DIR' , basename(dirname(__FILE__)));
17if(!defined('CSTAT_PATH')) define('CSTAT_PATH' , PHPWG_PLUGINS_PATH . CSTAT_DIR . '/');
18
19//ini_set('error_reporting', E_ALL);
20//ini_set('display_errors', true);
21
22global $gpc_installed, $gpcNeeded, $lang; //needed for plugin manager compatibility
23
24/* -----------------------------------------------------------------------------
25ColorStat needs the Grum Plugin Classe
26----------------------------------------------------------------------------- */
27$gpc_installed=false;
28$gpcNeeded="3.1.0";
29if(file_exists(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php'))
30{
31  include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php');
32  // need GPC release greater or equal than 3.1.0
33  if(CommonPlugin::checkGPCRelease(3,1,0))
34  {
35    include_once('cstat_install.class.inc.php');
36    $gpc_installed=true;
37  }
38}
39
40function gpcMsgError(&$errors)
41{
42  global $gpcNeeded;
43  $msg=sprintf(l10n('To install this plugin, you need to install Grum Plugin Classes %s before'), $gpcNeeded);
44  if(is_array($errors))
45  {
46    array_push($errors, $msg);
47  }
48  else
49  {
50    $errors=Array($msg);
51  }
52}
53// -----------------------------------------------------------------------------
54
55
56
57
58load_language('plugin.lang', CSTAT_PATH);
59
60
61function plugin_install($plugin_id, $plugin_version, &$errors)
62{
63  global $prefixeTable, $gpc_installed, $gpcNeeded;
64
65  if($gpc_installed)
66  {
67    $obj = new CStat_Install($prefixeTable, __FILE__);
68    $result=$obj->install();
69    if(!$result)
70    {
71      array_push($errors, "error");
72    }
73    GPCCore::register($obj->getPluginName(), CSTAT_VERSION, $gpcNeeded);
74    GPCRequestBuilder::register($obj->getPluginName(), dirname($obj->getFileLocation()).'/cstat_rb_callback.class.inc.php');
75  }
76  else
77  {
78    gpcMsgError($errors);
79  }
80}
81
82function plugin_activate($plugin_id, $plugin_version, &$errors)
83{
84  global $prefixeTable, $gpc_installed;
85
86  if($gpc_installed)
87  {
88    $obj = new CStat_Install($prefixeTable, __FILE__);
89    $result=$obj->activate();
90    if($result===false or $result!='')
91    {
92      if(is_string($result))
93      {
94        array_push($errors, $result);
95      }
96      else
97      {
98        array_push($errors, "");
99      }
100    }
101  }
102  else
103  {
104    gpcMsgError($errors);
105  }
106}
107
108function plugin_deactivate($plugin_id)
109{
110}
111
112function plugin_uninstall($plugin_id)
113{
114  global $prefixeTable, $gpc_installed;
115
116  if($gpc_installed)
117  {
118    $obj = new CStat_Install($prefixeTable, __FILE__);
119    $obj->uninstall();
120    GPCRequestBuilder::unregister($obj->getPluginName());
121    GPCCore::unregister($obj->getPluginName());
122  }
123  else
124  {
125    gpcMsgError($errors);
126  }
127}
128
129
130?>
Note: See TracBrowser for help on using the repository browser.