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