[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 | |
---|
| 22 | global $gpc_installed, $gpcNeeded, $lang; //needed for plugin manager compatibility |
---|
| 23 | |
---|
| 24 | /* ----------------------------------------------------------------------------- |
---|
| 25 | ColorStat needs the Grum Plugin Classe |
---|
| 26 | ----------------------------------------------------------------------------- */ |
---|
| 27 | $gpc_installed=false; |
---|
[6893] | 28 | $gpcNeeded="3.2.0"; |
---|
[5961] | 29 | if(file_exists(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php')) |
---|
| 30 | { |
---|
| 31 | include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php'); |
---|
[6893] | 32 | // need GPC release greater or equal than 3.2.0 |
---|
| 33 | if(CommonPlugin::checkGPCRelease(3,2,0)) |
---|
[5961] | 34 | { |
---|
| 35 | include_once('cstat_install.class.inc.php'); |
---|
| 36 | $gpc_installed=true; |
---|
| 37 | } |
---|
| 38 | } |
---|
| 39 | |
---|
| 40 | function 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 | |
---|
| 58 | load_language('plugin.lang', CSTAT_PATH); |
---|
| 59 | |
---|
| 60 | |
---|
| 61 | function 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); |
---|
[6107] | 74 | GPCRequestBuilder::register($obj->getPluginName(), dirname($obj->getFileLocation()).'/cstat_rb_callback.class.inc.php'); |
---|
[5961] | 75 | } |
---|
| 76 | else |
---|
| 77 | { |
---|
| 78 | gpcMsgError($errors); |
---|
| 79 | } |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | function 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 | |
---|
| 108 | function plugin_deactivate($plugin_id) |
---|
| 109 | { |
---|
| 110 | } |
---|
| 111 | |
---|
| 112 | function 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(); |
---|
[6107] | 120 | GPCRequestBuilder::unregister($obj->getPluginName()); |
---|
[5961] | 121 | GPCCore::unregister($obj->getPluginName()); |
---|
| 122 | } |
---|
| 123 | else |
---|
| 124 | { |
---|
| 125 | gpcMsgError($errors); |
---|
| 126 | } |
---|
| 127 | } |
---|
| 128 | |
---|
| 129 | |
---|
| 130 | ?> |
---|