[5961] | 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 | |
---|
| 14 | if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); } |
---|
| 15 | |
---|
| 16 | if(!defined('CSTAT_DIR')) define('CSTAT_DIR' , basename(dirname(__FILE__))); |
---|
| 17 | if(!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 | |
---|
[6976] | 22 | global $gpcInstalled, $lang; //needed for plugin manager compatibility |
---|
[5961] | 23 | |
---|
[6976] | 24 | /* |
---|
| 25 | * ----------------------------------------------------------------------------- |
---|
| 26 | * ColorStat needs the Grum Plugin Classes |
---|
| 27 | * ----------------------------------------------------------------------------- |
---|
| 28 | */ |
---|
| 29 | $gpcInstalled=false; |
---|
[5961] | 30 | if(file_exists(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php')) |
---|
| 31 | { |
---|
| 32 | include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php'); |
---|
[6893] | 33 | // need GPC release greater or equal than 3.2.0 |
---|
| 34 | if(CommonPlugin::checkGPCRelease(3,2,0)) |
---|
[5961] | 35 | { |
---|
| 36 | include_once('cstat_install.class.inc.php'); |
---|
[6976] | 37 | $gpcInstalled=true; |
---|
[5961] | 38 | } |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | function gpcMsgError(&$errors) |
---|
| 42 | { |
---|
[6976] | 43 | $msg=sprintf(l10n('To install this plugin, you need to install Grum Plugin Classes %s before'), CSTAT_GPC_NEEDED); |
---|
[5961] | 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 | |
---|
| 58 | load_language('plugin.lang', CSTAT_PATH); |
---|
| 59 | |
---|
| 60 | |
---|
| 61 | function plugin_install($plugin_id, $plugin_version, &$errors) |
---|
| 62 | { |
---|
[6976] | 63 | global $prefixeTable, $gpcInstalled; |
---|
[5961] | 64 | |
---|
[6976] | 65 | if($gpcInstalled) |
---|
[5961] | 66 | { |
---|
[6976] | 67 | $cstat = new CStat_Install($prefixeTable, __FILE__); |
---|
| 68 | if(!$cstat->install()) |
---|
[5961] | 69 | { |
---|
| 70 | array_push($errors, "error"); |
---|
| 71 | } |
---|
| 72 | } |
---|
| 73 | else |
---|
| 74 | { |
---|
| 75 | gpcMsgError($errors); |
---|
| 76 | } |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | function plugin_activate($plugin_id, $plugin_version, &$errors) |
---|
| 80 | { |
---|
[6976] | 81 | global $prefixeTable, $gpcInstalled; |
---|
[5961] | 82 | |
---|
[6976] | 83 | if($gpcInstalled) |
---|
[5961] | 84 | { |
---|
[6976] | 85 | $cstat = new CStat_Install($prefixeTable, __FILE__); |
---|
| 86 | $result=$cstat->activate(); |
---|
[5961] | 87 | if($result===false or $result!='') |
---|
| 88 | { |
---|
| 89 | if(is_string($result)) |
---|
| 90 | { |
---|
| 91 | array_push($errors, $result); |
---|
| 92 | } |
---|
| 93 | else |
---|
| 94 | { |
---|
| 95 | array_push($errors, ""); |
---|
| 96 | } |
---|
| 97 | } |
---|
| 98 | } |
---|
| 99 | else |
---|
| 100 | { |
---|
| 101 | gpcMsgError($errors); |
---|
| 102 | } |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | function plugin_deactivate($plugin_id) |
---|
| 106 | { |
---|
[6976] | 107 | global $prefixeTable, $gpcInstalled; |
---|
| 108 | |
---|
| 109 | if($gpcInstalled) |
---|
| 110 | { |
---|
| 111 | $cstat = new CStat_Install($prefixeTable, __FILE__); |
---|
| 112 | $cstat->deactivate(); |
---|
| 113 | } |
---|
[5961] | 114 | } |
---|
| 115 | |
---|
| 116 | function plugin_uninstall($plugin_id) |
---|
| 117 | { |
---|
[6976] | 118 | global $prefixeTable, $gpcInstalled; |
---|
[5961] | 119 | |
---|
[6976] | 120 | if($gpcInstalled) |
---|
[5961] | 121 | { |
---|
[6976] | 122 | $cstat = new CStat_Install($prefixeTable, __FILE__); |
---|
| 123 | $cstat->uninstall(); |
---|
[5961] | 124 | } |
---|
| 125 | else |
---|
| 126 | { |
---|
| 127 | gpcMsgError($errors); |
---|
| 128 | } |
---|
| 129 | } |
---|
| 130 | |
---|
| 131 | |
---|
| 132 | ?> |
---|