diff --git a/gulliver/system/class.bootstrap.php b/gulliver/system/class.bootstrap.php index fe35fa8e8..1466842fa 100644 --- a/gulliver/system/class.bootstrap.php +++ b/gulliver/system/class.bootstrap.php @@ -225,6 +225,8 @@ class Bootstrap self::registerClass("cronFile", PATH_CLASSES . "class.plugin.php"); self::registerClass("pluginDetail", PATH_CLASSES . "class.pluginRegistry.php"); self::registerClass("PMPluginRegistry", PATH_CLASSES . "class.pluginRegistry.php"); + self::registerClass("featuresDetail", PATH_CLASSES . "class.licensedFeatures.php"); + self::registerClass("PMLicensedFeatures", PATH_CLASSES . "class.licensedFeatures.php"); self::registerClass("PMDashlet", PATH_CLASSES . "class.pmDashlet.php"); self::registerClass("pmGauge", PATH_CLASSES . "class.pmGauge.php"); self::registerClass("pmPhing", PATH_CLASSES . "class.pmPhing.php"); diff --git a/workflow/engine/classes/class.licensedFeatures.php b/workflow/engine/classes/class.licensedFeatures.php new file mode 100644 index 000000000..50ccb71e6 --- /dev/null +++ b/workflow/engine/classes/class.licensedFeatures.php @@ -0,0 +1,89 @@ +featureName = $featureName; + $this->description = $description; + } +} + + +class PMLicensedFeatures +{ + private $featuresDetails = array (); + private $features = array (); + + private static $instancefeature = null; + + /** + * This function is the constructor of the PMLicensedFeatures class + * param + * + * @return void + */ + public function __construct () + { + $criteria = new Criteria(); + $criteria->addAscendingOrderByColumn(AddonsManagerPeer::ADDON_ID); + $criteria->add(AddonsManagerPeer::ADDON_TYPE, 'feature', Criteria::EQUAL); + $addons = AddonsManagerPeer::doSelect($criteria); + foreach ($addons as $addon) { + $this->features[] = $addon->getAddonId(); + $detail = new featuresDetail($addon->getAddonNick(), $addon->getAddonDescription()); + $this->featuresDetails[$addon->getAddonId()] = $detail; + } + } + + /** + * This function is instancing to this class + * param + * + * @return object + */ + public static function getSingleton () + { + if (self::$instancefeature == null) { + self::$instancefeature = new PMLicensedFeatures(); + } + return self::$instancefeature; + } + + public function verifyfeature ($featureName) + { + $licenseManager = &pmLicenseManager::getSingleton(); + $_SESSION['__sw__'] = true; + $padl = new padl(); + + $enable = in_array($padl->_decrypt($featureName), $licenseManager->features); + + $this->featuresDetails[$padl->_decrypt($featureName)]->enabled = $enable; + return $enable; + } + + public static function loadSingleton($file) + { + self::$instancefeature = unserialize(file_get_contents($file)); + + if (! is_object(self::$instancefeature) || get_class(self::$instancefeature) != "PMLicensedFeatures") { + throw new Exception("Can't load main PMLicensedFeatures object."); + } + + return self::$instancefeature; + } +} + diff --git a/workflow/engine/classes/class.pmLicenseManager.php b/workflow/engine/classes/class.pmLicenseManager.php index 8c2386a44..ace704336 100644 --- a/workflow/engine/classes/class.pmLicenseManager.php +++ b/workflow/engine/classes/class.pmLicenseManager.php @@ -53,6 +53,9 @@ class pmLicenseManager ); $this->result = $results['RESULT']; + $this->features = array(); + $this->licensedfeatures = array(); + $this->licensedfeaturesList = array(); if (in_array($this->result, $validStatus)) { $this->serial="3ptta7Xko2prrptrZnSd356aqmPXvMrayNPFj6CLdaR1pWtrW6qPw9jV0OHjxrDGu8LVxtmSm9nP5kR23HRpdZWccpeui+bKkK°DoqCt2Kqgpq6Vg37s"; $info['FIRST_NAME'] = $results['DATA']['FIRST_NAME']; @@ -64,7 +67,9 @@ class pmLicenseManager $this->plan = isset($results ['DATA']['PLAN'])?$results ['DATA']['PLAN']:""; $this->id = $results ['ID']; $this->expireIn = $this->getExpireIn (); - $this->features = $this->result!='TMINUS'?isset($results ['DATA']['CUSTOMER_PLUGIN'])?$results ['DATA']['CUSTOMER_PLUGIN']:$this->getActiveFeatures():array(); + $this->features = $this->result!='TMINUS'?isset($results ['DATA']['CUSTOMER_PLUGIN'])? $results ['DATA']['CUSTOMER_PLUGIN'] : $this->getActiveFeatures() : array(); + $this->licensedfeatures = $this->result!='TMINUS'?isset($results ['DATA']['CUSTOMER_LICENSED_FEATURES'])? $results ['DATA']['CUSTOMER_LICENSED_FEATURES'] : array() : array(); + $this->licensedfeaturesList = isset($results ['DATA']['LICENSED_FEATURES_LIST'])? $results ['DATA']['LICENSED_FEATURES_LIST'] : null; $this->status = $this->getCurrentLicenseStatus (); if (isset ( $results ['LIC'] )) { @@ -352,7 +357,9 @@ class pmLicenseManager public function installLicense($path, $redirect = true) { $application = new license_application ( $path, false, true, false, true, true ); + $results = $application->validate ( false, false, "", "", "80", true ); + //if the result is ok then it is saved into DB $res = $results ['RESULT']; if (( $res != 'OK') && ($res != 'EXPIRED' ) && ($res != 'TMINUS') ) { @@ -496,6 +503,9 @@ class pmLicenseManager public function getActiveFeatures() { + if (file_exists ( PATH_PLUGINS . 'enterprise/data/default' )) { + return array(); + } return unserialize(G::decrypt($this->serial, file_get_contents(PATH_PLUGINS . 'enterprise/data/default'))); } } diff --git a/workflow/engine/classes/class.wsTools.php b/workflow/engine/classes/class.wsTools.php index a52b9ee03..b1323e394 100755 --- a/workflow/engine/classes/class.wsTools.php +++ b/workflow/engine/classes/class.wsTools.php @@ -1506,6 +1506,13 @@ class workspaceTools $versionOld = ( isset($version[0])) ? $version[0] : ''; CLI::logging(CLI::info("$versionOld < $versionPresent") . "\n"); + $start = microtime(true); + CLI::logging("> Verify enterprise old...\n"); + $this->verifyEnterprise($workSpace); + $stop = microtime(true); + $final = $stop - $start; + CLI::logging("<*> Verify took $final seconds.\n"); + if ( $versionOld < $versionPresent || strpos($versionPresent, "Branch")) { $start = microtime(true); CLI::logging("> Updating database...\n"); diff --git a/workflow/engine/classes/model/AddonsStore.php b/workflow/engine/classes/model/AddonsStore.php index 30e861fec..132b26a9b 100644 --- a/workflow/engine/classes/model/AddonsStore.php +++ b/workflow/engine/classes/model/AddonsStore.php @@ -64,7 +64,115 @@ class AddonsStore extends BaseAddonsStore return false; } - public static function addonList() + public static function addonList($type = 'plugin') + { + $result = array(); + + AddonsStore::checkLicenseStore(); + + $licenseManager = &pmLicenseManager::getSingleton(); //Getting the licenseManager + + $result["store_errors"] = array(); + list($stores, $errors) = AddonsStore::updateAll(false, $type); + + foreach ($errors as $store_id => $store_error) { + $result["store_errors"][] = array("id" => $store_id, "msg" => $store_error); + } + + $result["addons"] = array(); + $result["errors"] = array(); + + $criteria = new Criteria(); + $criteria->addAscendingOrderByColumn(AddonsManagerPeer::ADDON_TYPE); + $criteria->addAscendingOrderByColumn(AddonsManagerPeer::ADDON_ID); + $criteria->add(AddonsManagerPeer::ADDON_TYPE, $type, Criteria::EQUAL); + $addons = AddonsManagerPeer::doSelect($criteria); + + foreach ($addons as $addon) { + + $status = $addon->getAddonStatus(); + $version = $addon->getAddonVersion(); + $enabled = null; + + if (!$addon->checkState()) { + $result["errors"][] = array("addonId" => $addon->getAddonId(), "storeId" => $addon->getStoreId()); + } + + $sw = 1; + $addonInLicense = in_array($addon->getAddonId(), $licenseManager->features); + + if ($sw == 1 && $addon->getAddonId() != "enterprise" && !$addonInLicense) { + $sw = 0; + } + + if ($type == 'plugin') { + if ($sw == 1 && $addon->isInstalled()) { + if ($addon->isEnabled()) { + $status = "installed"; + } else { + $status = "disabled"; + } + + $version = $addon->getInstalledVersion(); + + if (version_compare($version . "", $addon->getAddonVersion() . "", "<")) { + $status = "upgrade"; + } + + $enabled = $addon->isEnabled(); + $sw = 0; + } + } else { + $status = "available"; + $enabled = false; + if (!$addonInLicense && in_array($addon->getAddonName(), $licenseManager->licensedfeatures) == 1) { + $status = "installed"; + $enabled = true; + } + } + + if ($sw == 1 && $addonInLicense) { + $status = "ready"; + $sw = 0; + } + + $state = $addon->getAddonState(); + $log = null; + + if ($state != null) { + $status = $state; + $log = $addon->getInstallLog(); + } + if ($addon->getAddonId() == "enterprise" && $status== 'ready') { + $status = 'installed'; + } + if ($status == 'minus-circle' ) { + $status = "available"; + } + + $result["addons"][$addon->getAddonId()] = array( + "id" => $addon->getAddonId(), + "store" => $addon->getStoreId(), + "name" => $addon->getAddonName(), + "nick" => $addon->getAddonNick(), + "version" => $version, + "enabled" => $enabled, + "latest_version" => $addon->getAddonVersion(), + "type" => $addon->getAddonType(), + "release_type" => $addon->getAddonReleaseType(), + "url" => $addon->getAddonDownloadUrl(), + "publisher" => $addon->getAddonPublisher(), + "description" => $addon->getAddonDescription(), + "status" => $status, + "log" => $log, + "progress" => round($addon->getAddonDownloadProgress()) + ); + } + + return $result; + } + + public static function addonFeatureList() { $result = array(); @@ -135,6 +243,9 @@ class AddonsStore extends BaseAddonsStore if ($addon->getAddonId() == "enterprise" && $status== 'ready') { $status = 'installed'; } + if ($status == 'minus-circle' ) { + $status = "available"; + } $result["addons"][$addon->getAddonId()] = array( "id" => $addon->getAddonId(), @@ -175,14 +286,14 @@ class AddonsStore extends BaseAddonsStore * * @return array containing a 'stores' array and a 'errors' array */ - public static function updateAll($force = false) + public static function updateAll($force = false, $type = 'plugin') { $stores = array(); $errors = array(); foreach (self::listStores() as $store) { try { - $stores[$store->getStoreId()] = $store->update($force); + $stores[$store->getStoreId()] = $store->update($force, $type); } catch (Exception $e) { $errors[$store->getStoreId()] = $e->getMessage(); } @@ -196,11 +307,12 @@ class AddonsStore extends BaseAddonsStore * * @return int number of addons removed */ - public function clear() + public function clear($type = 'plugin') { /* Remove old items from this store */ $criteria = new Criteria(AddonsManagerPeer::DATABASE_NAME); $criteria->add(AddonsManagerPeer::STORE_ID, $this->getStoreId(), Criteria::EQUAL); + $criteria->add(AddonsManagerPeer::ADDON_TYPE, $type, Criteria::EQUAL); return AddonsManagerPeer::doDelete($criteria); } @@ -210,7 +322,7 @@ class AddonsStore extends BaseAddonsStore * * @return bool true if updated, false otherwise */ - public function update($force = false) + public function update($force = false, $type = 'plugin') { require_once PATH_CORE . 'classes' . PATH_SEP . 'class.pmLicenseManager.php'; @@ -221,12 +333,13 @@ class AddonsStore extends BaseAddonsStore //If we have any addon that is installing or updating, don't update store $criteria = new Criteria(AddonsManagerPeer::DATABASE_NAME); $criteria->add(AddonsManagerPeer::ADDON_STATE, '', Criteria::NOT_EQUAL); + $criteria->add(AddonsManagerPeer::ADDON_TYPE, $type); if (AddonsManagerPeer::doCount($criteria) > 0) { return false; } - $this->clear(); + $this->clear($type); //Fill with local information @@ -241,74 +354,98 @@ class AddonsStore extends BaseAddonsStore $pmLicenseManagerO = &pmLicenseManager::getSingleton(); $localPlugins = array(); - foreach ($aPluginsPP as $aPlugin) { - $sClassName = substr($aPlugin['sFilename'], 0, strpos($aPlugin['sFilename'], '-')); + if ($type == 'plugin') { + foreach ($aPluginsPP as $aPlugin) { + $sClassName = substr($aPlugin['sFilename'], 0, strpos($aPlugin['sFilename'], '-')); - if (file_exists(PATH_PLUGINS . $sClassName . '.php')) { - require_once PATH_PLUGINS . $sClassName . '.php'; + if (file_exists(PATH_PLUGINS . $sClassName . '.php')) { + require_once PATH_PLUGINS . $sClassName . '.php'; - $oDetails = $oPluginRegistry->getPluginDetails($sClassName . '.php'); + $oDetails = $oPluginRegistry->getPluginDetails($sClassName . '.php'); - if ($oDetails) { - $sStatus = $oDetails->enabled ? G::LoadTranslation('ID_ENABLED') : G::LoadTranslation('ID_DISABLED'); + if ($oDetails) { + $sStatus = $oDetails->enabled ? G::LoadTranslation('ID_ENABLED') : G::LoadTranslation('ID_DISABLED'); - if (isset($oDetails->aWorkspaces)) { - if (!in_array(SYS_SYS, $oDetails->aWorkspaces)) { + if (isset($oDetails->aWorkspaces)) { + if (!in_array(SYS_SYS, $oDetails->aWorkspaces)) { + continue; + } + } + + if ($sClassName == "pmLicenseManager" || $sClassName == "pmTrial") { continue; } + + $sEdit = (($oDetails->sSetupPage != '') && ($oDetails->enabled)? G::LoadTranslation('ID_SETUP') : ' '); + $aPlugin = array(); + $aPluginId = $sClassName; + $aPluginTitle = $oDetails->sFriendlyName; + $aPluginDescription = $oDetails->sDescription; + $aPluginVersion = $oDetails->iVersion; + + if (@in_array($sClassName, $pmLicenseManagerO->features)) { + $aPluginStatus = $sStatus; + $aPluginLinkStatus = 'pluginsChange?id=' . $sClassName . '.php&status=' . $oDetails->enabled; + $aPluginEdit = $sEdit; + $aPluginLinkEdit = 'pluginsSetup?id=' . $sClassName . '.php'; + $aPluginStatusA = $sStatus == "Enabled" ? "installed" : 'disabled'; + $enabledStatus = true; + } else { + $aPluginStatus = ""; + $aPluginLinkStatus = ''; + $aPluginEdit = ''; + $aPluginLinkEdit = ''; + $aPluginStatusA = 'minus-circle'; + $enabledStatus = false; + } + + $addon = new AddonsManager(); + //G::pr($addon); + $addon->setAddonId($aPluginId); + $addon->setStoreId($this->getStoreId()); + //Don't trust external data + $addon->setAddonName($aPluginId); + $addon->setAddonDescription($aPluginDescription); + $addon->setAddonNick($aPluginTitle); + $addon->setAddonVersion(""); + $addon->setAddonStatus($aPluginStatusA); + $addon->setAddonType("plugin"); + $addon->setAddonPublisher("Colosa"); + $addon->setAddonDownloadUrl(""); + $addon->setAddonDownloadMd5(""); + $addon->setAddonReleaseDate(null); + $addon->setAddonReleaseType('localRegistry'); + $addon->setAddonReleaseNotes(""); + $addon->setAddonState(""); + + $addon->save(); + + $localPlugins[$aPluginId] = $addon; } - - if ($sClassName == "pmLicenseManager" || $sClassName == "pmTrial") { - continue; - } - - $sEdit = (($oDetails->sSetupPage != '') && ($oDetails->enabled)? G::LoadTranslation('ID_SETUP') : ' '); - $aPlugin = array(); - $aPluginId = $sClassName; - $aPluginTitle = $oDetails->sFriendlyName; - $aPluginDescription = $oDetails->sDescription; - $aPluginVersion = $oDetails->iVersion; - - if (@in_array($sClassName, $pmLicenseManagerO->features)) { - $aPluginStatus = $sStatus; - $aPluginLinkStatus = 'pluginsChange?id=' . $sClassName . '.php&status=' . $oDetails->enabled; - $aPluginEdit = $sEdit; - $aPluginLinkEdit = 'pluginsSetup?id=' . $sClassName . '.php'; - $aPluginStatusA = $sStatus == "Enabled" ? "installed" : 'disabled'; - $enabledStatus = true; - } else { - $aPluginStatus = ""; - $aPluginLinkStatus = ''; - $aPluginEdit = ''; - $aPluginLinkEdit = ''; - $aPluginStatusA = 'minus-circle'; - $enabledStatus = false; - } - - $addon = new AddonsManager(); - //G::pr($addon); - $addon->setAddonId($aPluginId); - $addon->setStoreId($this->getStoreId()); - //Don't trust external data - $addon->setAddonName($aPluginId); - $addon->setAddonDescription($aPluginDescription); - $addon->setAddonNick($aPluginTitle); - $addon->setAddonVersion(""); - $addon->setAddonStatus($aPluginStatusA); - $addon->setAddonType("plugin"); - $addon->setAddonPublisher("Colosa"); - $addon->setAddonDownloadUrl(""); - $addon->setAddonDownloadMd5(""); - $addon->setAddonReleaseDate(null); - $addon->setAddonReleaseType('localRegistry'); - $addon->setAddonReleaseNotes(""); - $addon->setAddonState(""); - - $addon->save(); - - $localPlugins[$aPluginId] = $addon; } } + } else { + $list = unserialize($pmLicenseManagerO->licensedfeaturesList); + foreach ($list['addons'] as $key => $feature) { + $addon = new AddonsManager(); + $addon->setAddonId($feature['name']); + $addon->setStoreId($feature['guid']); + $addon->setAddonName($feature['name']); + $addon->setAddonDescription($feature['description']); + $addon->setAddonNick($feature['nick']); + $addon->setAddonVersion(""); + $addon->setAddonStatus($feature['status']); + $addon->setAddonType("features"); + $addon->setAddonPublisher("Colosa"); + $addon->setAddonDownloadUrl(""); + $addon->setAddonDownloadMd5(""); + $addon->setAddonReleaseDate(null); + $addon->setAddonReleaseType('localRegistry'); + $addon->setAddonReleaseNotes(""); + $addon->setAddonState(""); + + $addon->save(); + } } $this->setStoreLastUpdated(time()); @@ -359,6 +496,7 @@ class AddonsStore extends BaseAddonsStore $context = stream_context_create($option); //This may block for a while, always use AJAX to call this method + $url = $url . '&type=' . strtoupper($type); $data = file_get_contents($url, false, $context); if ($data === false) { @@ -388,7 +526,7 @@ class AddonsStore extends BaseAddonsStore throw (new Exception("Addons not found on store data")); } - $this->clear(); + $this->clear($type); try { //Add each item to this stores addons @@ -451,7 +589,7 @@ class AddonsStore extends BaseAddonsStore $this->save(); } catch (Exception $e) { //If we had issues, don't keep only a part of the items - $this->clear(); + $this->clear($type); throw $e; } diff --git a/workflow/engine/controllers/main.php b/workflow/engine/controllers/main.php index 295e11bd1..ebb7151c9 100644 --- a/workflow/engine/controllers/main.php +++ b/workflow/engine/controllers/main.php @@ -44,11 +44,12 @@ class Main extends Controller // license notification $expireInLabel = ''; - if (class_exists( 'pmLicenseManager' )) { - $pmLicenseManager = &pmLicenseManager::getSingleton(); - $expireIn = $pmLicenseManager->getExpireIn(); - $expireInLabel = $pmLicenseManager->getExpireInLabel(); - } + + require_once ("classes" . PATH_SEP . "class.pmLicenseManager.php"); + $pmLicenseManager = &pmLicenseManager::getSingleton(); + $expireIn = $pmLicenseManager->getExpireIn(); + $expireInLabel = $pmLicenseManager->getExpireInLabel(); + $this->setVar( 'licenseNotification', $expireInLabel ); // setting variables on javascript env. diff --git a/workflow/engine/methods/enterprise/addonsStoreAction.php b/workflow/engine/methods/enterprise/addonsStoreAction.php index 1c0e30942..2c4120e13 100644 --- a/workflow/engine/methods/enterprise/addonsStoreAction.php +++ b/workflow/engine/methods/enterprise/addonsStoreAction.php @@ -347,7 +347,9 @@ try { exit(0); break; case "addonslist": - $result = AddonsStore::addonList(); + $type = (isset($_REQUEST['type'])) ? $_REQUEST['type']: 'plugin'; + $result = AddonsStore::addonList($type); + break; break; default: throw (new Exception("Action \"$action\" is not valid")); diff --git a/workflow/engine/methods/enterprise/enterprise.php b/workflow/engine/methods/enterprise/enterprise.php index d8a122412..2ae816c76 100644 --- a/workflow/engine/methods/enterprise/enterprise.php +++ b/workflow/engine/methods/enterprise/enterprise.php @@ -21,8 +21,8 @@ class enterprisePlugin extends PMPlugin $VERSION = System::getVersion(); $res = parent::PMPlugin($sNamespace, $sFilename); - $this->sFriendlyName = "ProcessMaker Enterprise Edition"; - $this->sDescription = "ProcessMaker Enterprise Edition $VERSION"; + $this->sFriendlyName = "ProcessMaker Enterprise Core Edition"; + $this->sDescription = "ProcessMaker Enterprise Core Edition $VERSION"; $this->sPluginFolder = "enterprise"; $this->sSetupPage = "../enterprise/addonsStore.php"; $this->iVersion = $VERSION; diff --git a/workflow/engine/skinEngine/skinEngine.php b/workflow/engine/skinEngine/skinEngine.php index 45334f0f9..af5f412a8 100755 --- a/workflow/engine/skinEngine/skinEngine.php +++ b/workflow/engine/skinEngine/skinEngine.php @@ -755,16 +755,16 @@ class SkinEngine $name = $conf->userNameFormat(isset($_SESSION['USR_USERNAME']) ? $_SESSION['USR_USERNAME']: '', isset($_SESSION['USR_FULLNAME']) ? htmlentities($_SESSION['USR_FULLNAME'] , ENT_QUOTES, 'UTF-8'): '', isset($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : ''); $smarty->assign('user',$name); } - if(class_exists('pmLicenseManager')){ - $pmLicenseManagerO = &pmLicenseManager::getSingleton(); - $expireIn = $pmLicenseManagerO->getExpireIn(); - $expireInLabel = $pmLicenseManagerO->getExpireInLabel(); - //if($expireIn<=30){ - if($expireInLabel != ""){ - $smarty->assign('msgVer', '  '); + + if (defined('SYS_SYS')) { + require_once ("classes" . PATH_SEP . "class.pmLicenseManager.php"); + $pmLicenseManagerO = &pmLicenseManager::getSingleton(); + $expireIn = $pmLicenseManagerO->getExpireIn(); + $expireInLabel = $pmLicenseManagerO->getExpireInLabel(); + if($expireInLabel != ""){ + $smarty->assign('msgVer', '  '); + } } - //} - } if (defined('SYS_SYS')) { $logout = '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/login/login'; diff --git a/workflow/engine/templates/enterprise/addonsStore.js b/workflow/engine/templates/enterprise/addonsStore.js index 33bda2d8e..f1c2906ff 100644 --- a/workflow/engine/templates/enterprise/addonsStore.js +++ b/workflow/engine/templates/enterprise/addonsStore.js @@ -499,6 +499,11 @@ Ext.onReady(function() { "force": true } }); + addonsFeaturesStore.load({ + params: { + "force": true + } + }); Ext.getCmp("refresh-btn").setDisabled(!Ext.getCmp("chkEeInternetConnection").checked); @@ -518,8 +523,9 @@ Ext.onReady(function() { url: "addonsStoreAction", method: "POST" }), - baseParams: {"action": "addonsList" - }, + baseParams: { + "action": "addonsList" + }, //url: "addonsStoreAction?action=addonsList", @@ -608,6 +614,79 @@ Ext.onReady(function() { } }); + + var addonsFeaturesStore = new Ext.data.JsonStore({ + proxy: new Ext.data.HttpProxy({ + url: "addonsStoreAction", + method: "POST" + }), + baseParams: { + "action": "addonsList", + "type" : "features" + }, + autoDestroy: true, + messageProperty: 'error', + storeId: 'addonsFeaturesStore', + root: 'addons', + idProperty: 'id', + sortInfo: { + field: 'nick', + direction: 'ASC' // or 'DESC' (case sensitive for local sorting) + }, + fields: ['id', 'name', 'store', 'nick', 'latest_version', 'version', 'status', + 'type', 'release_type', 'url', 'enabled', 'publisher', 'description', + 'log', 'progress'], + listeners: { + 'beforeload': function(store, options) { + Ext.ComponentMgr.get('loading-features-indicator').setValue(''); + return true; + }, + "exception": function(e, type, action, options, response, arg) { + Ext.ComponentMgr.get('loading-features-indicator').setValue(' '); + }, + "load": function(store, records, options) { + Ext.ComponentMgr.get('loading-features-indicator').setValue(""); + progressWindow.hide(); + store.filterBy(function (record, id) { + if (record.get('type') == 'core') { + coreRecord = record.copy(); + status = record.get('status'); + if (status == "download-start" || status == "download" || status == "install" || status == "install-finish") { + upgradeStatus(record.get('id'), record.get('store'), record); + } + return false; + } + return true; + }); + + if (addonsFeatureGrid.disabled) { + addonsFeatureGrid.enable(); + } + + errors = store.reader.jsonData.errors; + for (var i = 0, n = errors.length; i"; + } + + if (store_errors.length > 0) { + Ext.ComponentMgr.get('loading-features-indicator').setValue(' '); + //storeError(error_msg); + reloadTask.cancel(); + } else { + Ext.ComponentMgr.get('loading-features-indicator').setValue(' '); + } + } + } + }); + var upgradeStore = new Ext.data.Store({ recordType: addonsStore.recordType }); @@ -930,8 +1009,8 @@ Ext.onReady(function() { var pnlSetup = new Ext.FormPanel({ frame: true, title: _('ID_SETUP_WEBSERVICES'), - height: 188, - bodyStyle: "padding: 5px 5px 5px 5px;", + height: 178, + //bodyStyle: "padding: 5px 5px 5px 5px;", disabled: !licensed, items: [ @@ -966,7 +1045,7 @@ Ext.onReady(function() { }); var pnlSystem = new Ext.Container({ - autoEl: "div", + //autoEl: "div", //width: 550, anchor: "right 50%", //items: [pnlUpgrade, pnlSetup] @@ -976,62 +1055,62 @@ Ext.onReady(function() { var licensePanel = new Ext.FormPanel( { frame: true, title: _('ID_YOUR_LICENSE'), - labelWidth: 150, + labelWidth: 130, labelAlign: "right", //width : '50%', anchor: "right 50%", - bodyStyle: "padding: 5px 5px 5px 5px;", + //bodyStyle: "padding: 5px 5px 5px 5px;", defaultType: "displayfield", autoHeight: true, items: [ - { - id: "license_name", - fieldLabel: _('ID_CURRENT_LICENSE'), - value: license_name - }, - { - id: "license_server", - fieldLabel: _('ID_LICENSE_SERVER'), - value: license_server - }, - { - id: "license_message", - fieldLabel:_('ID_STATUS'), - hidden: licensed, - hideLabel: licensed, - value: ""+license_message+" ("+license_start_date+"/"+license_end_date+")
"+license_user - }, - - { - id: "license_user", - fieldLabel: _('ID_ISSUED_TO'), - value: license_user, - hidden: !licensed, - hideLabel: !licensed - }, - - { - id: "license_expires", - fieldLabel: _('ID_EXPIRES'), - value: license_expires+'/'+license_span+" ("+license_start_date+" / "+license_end_date+")", - hidden: !licensed, - hideLabel: !licensed - } - ], - buttons : [ - { - text: _('ID_IMPORT_LICENSE'), - disable: false, - handler: function() { - addLicenseWindow.show(); - } - }, - { - text : _('ID_RENEW'), - hidden: true, - disabled : true - } + { + id: "license_name", + fieldLabel: _('ID_CURRENT_LICENSE'), + value: license_name + }, + { + id: "license_server", + fieldLabel: _('ID_LICENSE_SERVER'), + value: license_server + }, + { + id: "license_message", + fieldLabel:_('ID_STATUS'), + hidden: licensed, + hideLabel: licensed, + value: ""+license_message+" ("+license_start_date+"/"+license_end_date+")
"+license_user + }, + + { + id: "license_user", + fieldLabel: _('ID_ISSUED_TO'), + value: license_user, + hidden: !licensed, + hideLabel: !licensed + }, + + { + id: "license_expires", + fieldLabel: _('ID_EXPIRES'), + value: license_expires+'/'+license_span+" ("+license_start_date+" / "+license_end_date+")", + hidden: !licensed, + hideLabel: !licensed + } + ], + buttons : [ + { + text: _('ID_IMPORT_LICENSE'), + disable: false, + handler: function() { + addLicenseWindow.show(); + } + }, + { + text : _('ID_RENEW'), + hidden: true, + disabled : true + } ] }); @@ -1178,257 +1257,426 @@ Ext.onReady(function() { items: [btnEnable, btnDisable, btnAdmin] }); - var addonsGrid = new Ext.grid.GridPanel({ - store: addonsStore, - colspan: 2, - flex: 1, - padding: 5, - disabled: !licensed, - columns: [ - expander, - { - id : 'icon-column', - header : '', - width : 30, - //sortable : true, - menuDisabled: true, - hideable : false, - dataIndex: 'status', - renderer : function (val, metadata, record, rowIndex, colIndex, store) { - return ""; - } - }, - { - id :'nick-column', - header : _('ID_NAME'), - //width : 160, - //sortable : true, - menuDisabled: true, - dataIndex: 'nick', - renderer: function (val, metadata, record, rowIndex, colIndex, store) { - if (record.get('release_type') == 'beta') { - return val + " (Beta)"; - } else if (record.get('release_type') == 'localRegistry') { - return val + " (Local)"; - } else { - return val; - } - } - }, - { - id : 'publisher-column', - header : _('ID_PUBLISHER'), - //sortable : true, - menuDisabled: true, - dataIndex: 'publisher' - }, - { - id : 'version-column', - header : _('ID_VERSION'), - //width : 160, - //sortable : true, - menuDisabled: true, - dataIndex: 'version' - }, - { - id : 'latest-version-column', - header : _('ID_LATEST_VERSION'), - //width : 160, - //sortable : true, - menuDisabled: true, - dataIndex: 'latest_version' - }, - { - id : 'enabled-column', - header : _('ID_ENABLED'), - width : 60, - //sortable : true, - menuDisabled: true, - dataIndex: 'enabled', - renderer: function (val) { - if (val === true) { - return ""; - } else if (val === false) { - return ""; - } - return ''; - } - }, - { - id : "status", - header : "", - width : 120, - //sortable : true, - menuDisabled: true, - hideable : false, - dataIndex: "status", - renderer: function (val) { - var str = ""; - var text = ""; - - switch (val) { - case "available": text = _('ID_BUY_NOW'); break; - case "installed": text = _('ID_INSTALLED'); break; - case "ready": text = _('ID_INSTALL_NOW'); break; - case "upgrade": text = _('ID_UPGRADE_NOW'); break; - case "download": text = _('ID_CANCEL'); break; - case "install": text = _('ID_INSTALLING'); break; - case "cancel": text = _('ID_CANCELLING'); break; - case "disabled": text = _('ID_DISABLED'); break; - case "download-start": text = ""; break; - default: text = val; break; - } - - switch (val) { - case "available": - case "ready": - case "upgrade": - case "download": - case "install": - case "cancel": - case "download-start": - str = "
" + text + "
"; - break; - - case "installed": - case "disabled": - str = "
" + text + "
"; - break; - - default: - str = "
" + text + "
"; - break; - } - - return (str); - } - } - ], - tbar:[/*{ - text:'Install', - tooltip:'Install this addon', - //iconCls:'add', - handler: function(b, e) { - record = addonsGrid.getSelectionModel().getSelected(); - console.log(record.get('name') + ' ' + record.get('store')); - installAddon(record.get('name'), record.get('store')); - } - }, - btnUninstall, - '-',*/ - btnEnable, - btnDisable, - btnAdmin, - '-', - { - id: "import-btn", - text: _('ID_INSTALL_FROM_FILE'), - tooltip: _('ID_INSTALL_FROM_FILE_PLUGIN_TIP'), - iconCls:"button_menu_ext ss_sprite ss_application_add", - - //ref: "../removeButton", - disabled: false, - handler: function () { - var sw = 1; - var msg = ""; - if (sw == 1 && PATH_PLUGINS_WRITABLE == 0) { - sw = 0; - msg = PATH_PLUGINS_WRITABLE_MESSAGE; - } - if (sw == 1) { - addPluginWindow.show(); - } else { - Ext.MessageBox.alert(_('ID_WARNING'), msg); - } - } - }, - '-', - { - id: 'refresh-btn', - text:_('ID_REFRESH_LABEL'), - iconCls:'button_menu_ext ss_sprite ss_database_refresh', - tooltip: _('ID_REFRESH_LABEL_PLUGIN_TIP'), - disabled: (INTERNET_CONNECTION == 1)? false : true, - handler: function (b, e) { - reloadTask.cancel(); - addonsStore.load({ - params: { - "force": true - } - }); - } - }, - '->', - { - xtype:"displayfield", - id:'loading-indicator' - } - ], - plugins: expander, - collapsible: false, - animCollapse: false, - stripeRows: true, - autoExpandColumn: 'nick-column', - title: _('ID_ENTERPRISE_PLUGINS'), - sm: new Ext.grid.RowSelectionModel({ - singleSelect:true, - listeners: { - selectionchange: function (sel) { - if (sel.getCount() == 0 || sel.getSelected().get("name") == "enterprise") { - //btnUninstall.setDisabled(true); - btnEnable.setDisabled(true); - btnDisable.setDisabled(true); - btnAdmin.setDisabled(true); - } else { - record = sel.getSelected(); - - //btnUninstall.setDisabled(!(record.get("status") == "installed" || record.get("status") == "upgrade" || record.get("status") == "disabled")); - btnEnable.setDisabled(!(record.get("enabled") === false)); - btnDisable.setDisabled(!(record.get("enabled") === true)); - btnAdmin.setDisabled(!(record.get("enabled") === true)); - } - } - } - }), - //config options for stateful behavior - stateful: true, - stateId: "grid", - listeners: { - "cellclick": function (grid, rowIndex, columnIndex, e) { - var record = grid.getStore().getAt(rowIndex); - var fieldName = grid.getColumnModel().getDataIndex(columnIndex); - //var data = record.get(fieldName); - - if (fieldName != "status") { - return; - } - - switch (record.get("status")) { - case "upgrade": - case "ready": - if (INTERNET_CONNECTION == 1) { - installAddon(record.get("id"), record.get("store")); - } else { - Ext.MessageBox.alert(_('ID_INFORMATION'), _('ID_NO_INTERNET_CONECTION')); + var addonsGrid = new Ext.grid.GridPanel({ + store: addonsStore, + colspan: 2, + flex: 1, + padding: 5, + //anchor : '100%', + //height: 300, + autoHeight : true, + disabled: !licensed, + columns: [ + expander, + { + id : 'icon-column', + header : '', + width : 30, + //sortable : true, + menuDisabled: true, + hideable : false, + dataIndex: 'status', + renderer : function (val, metadata, record, rowIndex, colIndex, store) { + return ""; } - break; - case "download": - Ext.Ajax.request({ - url: "addonsStoreAction", - params: { - "action": "cancel", - "addon": record.get("id"), - "store": record.get("store") + }, + { + id :'nick-column', + header : _('ID_NAME'), + width : 160, + //sortable : true, + menuDisabled: true, + dataIndex: 'nick', + renderer: function (val, metadata, record, rowIndex, colIndex, store) { + if (record.get('release_type') == 'beta') { + return val + " (Beta)"; + } else if (record.get('release_type') == 'localRegistry') { + return val + " (Local)"; + } else { + return val; + } + } + }, + { + id : 'publisher-column', + header : _('ID_PUBLISHER'), + //sortable : true, + menuDisabled: true, + dataIndex: 'publisher' + }, + { + id : 'version-column', + header : _('ID_VERSION'), + //width : 160, + //sortable : true, + menuDisabled: true, + dataIndex: 'version' + }, + { + id : 'latest-version-column', + header : _('ID_LATEST_VERSION'), + //width : 160, + //sortable : true, + menuDisabled: true, + dataIndex: 'latest_version' + }, + { + id : 'enabled-column', + header : _('ID_ENABLED'), + width : 60, + //sortable : true, + menuDisabled: true, + dataIndex: 'enabled', + renderer: function (val) { + if (val === true) { + return ""; + } else if (val === false) { + return ""; } - }); - break; - case "available": - addonAvailable(record.get("id")); - break; + return ''; + } + }, + { + id : "status", + header : "", + width : 120, + //sortable : true, + menuDisabled: true, + hideable : false, + dataIndex: "status", + renderer: function (val) { + var str = ""; + var text = ""; + + switch (val) { + case "available": text = _('ID_BUY_NOW'); break; + case "installed": text = _('ID_INSTALLED'); break; + case "ready": text = _('ID_INSTALL_NOW'); break; + case "upgrade": text = _('ID_UPGRADE_NOW'); break; + case "download": text = _('ID_CANCEL'); break; + case "install": text = _('ID_INSTALLING'); break; + case "cancel": text = _('ID_CANCELLING'); break; + case "disabled": text = _('ID_DISABLED'); break; + case "download-start": text = ""; break; + default: text = val; break; + } + + switch (val) { + case "available": + case "ready": + case "upgrade": + case "download": + case "install": + case "cancel": + case "download-start": + str = "
" + text + "
"; + break; + + case "installed": + case "disabled": + str = "
" + text + "
"; + break; + + default: + str = "
" + text + "
"; + break; + } + + return (str); + } + } + ], + tbar:[ + /*{ + text:'Install', + tooltip:'Install this addon', + //iconCls:'add', + handler: function(b, e) { + record = addonsGrid.getSelectionModel().getSelected(); + console.log(record.get('name') + ' ' + record.get('store')); + installAddon(record.get('name'), record.get('store')); + } + }, + btnUninstall, + '-',*/ + btnEnable, + btnDisable, + btnAdmin, + '-', + { + id: "import-btn", + text: _('ID_INSTALL_FROM_FILE'), + tooltip: _('ID_INSTALL_FROM_FILE_PLUGIN_TIP'), + iconCls:"button_menu_ext ss_sprite ss_application_add", + + //ref: "../removeButton", + disabled: false, + handler: function () { + var sw = 1; + var msg = ""; + if (sw == 1 && PATH_PLUGINS_WRITABLE == 0) { + sw = 0; + msg = PATH_PLUGINS_WRITABLE_MESSAGE; + } + if (sw == 1) { + addPluginWindow.show(); + } else { + Ext.MessageBox.alert(_('ID_WARNING'), msg); + } + } + }, + '-', + { + id: 'refresh-btn', + text:_('ID_REFRESH_LABEL'), + iconCls:'button_menu_ext ss_sprite ss_database_refresh', + tooltip: _('ID_REFRESH_LABEL_PLUGIN_TIP'), + disabled: (INTERNET_CONNECTION == 1)? false : true, + handler: function (b, e) { + reloadTask.cancel(); + addonsStore.load({ + params: { + "force": true + } + }); + } + }, + '->', + { + xtype:"displayfield", + id:'loading-indicator' + } + ], + plugins: expander, + collapsible: false, + animCollapse: false, + stripeRows: true, + autoExpandColumn: 'nick-column', + //title: _('ID_ENTERPRISE_PLUGINS'), + sm: new Ext.grid.RowSelectionModel({ + singleSelect:true, + listeners: { + selectionchange: function (sel) { + if (sel.getCount() == 0 || sel.getSelected().get("name") == "enterprise") { + //btnUninstall.setDisabled(true); + btnEnable.setDisabled(true); + btnDisable.setDisabled(true); + btnAdmin.setDisabled(true); + } else { + record = sel.getSelected(); + //btnUninstall.setDisabled(!(record.get("status") == "installed" || record.get("status") == "upgrade" || record.get("status") == "disabled")); + btnEnable.setDisabled(!(record.get("enabled") === false)); + btnDisable.setDisabled(!(record.get("enabled") === true)); + btnAdmin.setDisabled(!(record.get("enabled") === true)); + } + } + } + }), + //config options for stateful behavior + stateful: true, + stateId: "grid", + listeners: { + "cellclick": function (grid, rowIndex, columnIndex, e) { + var record = grid.getStore().getAt(rowIndex); + var fieldName = grid.getColumnModel().getDataIndex(columnIndex); + //var data = record.get(fieldName); + + if (fieldName != "status") { + return; + } + + switch (record.get("status")) { + case "upgrade": + case "ready": + if (INTERNET_CONNECTION == 1) { + installAddon(record.get("id"), record.get("store")); + } else { + Ext.MessageBox.alert(_('ID_INFORMATION'), _('ID_NO_INTERNET_CONECTION')); + } + break; + case "download": + Ext.Ajax.request({ + url: "addonsStoreAction", + params: { + "action": "cancel", + "addon": record.get("id"), + "store": record.get("store") + } + }); + break; + case "available": + addonAvailable(record.get("id")); + break; + } + } } - } - } - }); + }); + + // create the Grid Features + var addonsFeatureGrid = new Ext.grid.GridPanel({ + store: addonsFeaturesStore, + colspan: 2, + flex: 1, + padding: 5, + columns: [ + { + id : 'icon-column-feature', + header : '', + width : 30, + hideable : false, + dataIndex: 'status', + renderer : function (val, metadata, record, rowIndex, colIndex, store) { + return ""; + } + }, + { + id :'nick-column-feature', + header : _('ID_NAME'), + width : 300, + sortable : true, + dataIndex: 'nick', + renderer: function (val, metadata, record, rowIndex, colIndex, store) { + if (record.get('release_type') == 'beta') { + return val + " (Beta)"; + } else if (record.get('release_type') == 'localRegistry') { + return val + " (Local)"; + } else { + return val; + } + } + }, + { + id :'description-column-feature', + header : _('ID_DESCRIPTION'), + width : 400, + dataIndex: 'description' + }, + { + id : 'enabled-column-feature', + header : _('ID_ENABLED'), + width : 60, + dataIndex: 'enabled', + renderer: function (val) { + if (val === true) { + return ""; + } else if (val === false) { + return ""; + } + return ''; + } + }, + { + id : "status-feature", + header : _('ID_STATUS'), + width : 120, + sortable : false, + hideable : false, + dataIndex: "status", + renderer: function (val) { + var str = ""; + var text = ""; + + switch (val) { + case "available": text = _('ID_BUY_NOW'); break; + case "installed": text = _('ID_INSTALLED'); break; + case "ready": text = _('ID_INSTALL_NOW'); break; + case "upgrade": text = _('ID_UPGRADE_NOW'); break; + case "download": text = _('ID_CANCEL'); break; + case "install": text = _('ID_INSTALLING'); break; + case "cancel": text = _('ID_CANCELLING'); break; + case "disabled": text = _('ID_DISABLED'); break; + case "download-start": text = ""; break; + default: text = val; break; + } + + switch (val) { + case "available": + case "ready": + case "upgrade": + case "download": + case "install": + case "cancel": + case "download-start": + str = "
" + text + "
"; + break; + + case "installed": + case "disabled": + str = "
" + text + "
"; + break; + + default: + str = "
" + text + "
"; + break; + } + + return (str); + } + } + ], + stripeRows: true, + autoHeight : true, + stateId: "grid", + tbar: + [ + { + id: 'refresh-btn', + text:_('ID_REFRESH_LABEL'), + iconCls:'button_menu_ext ss_sprite ss_database_refresh', + tooltip: _('ID_REFRESH_LABEL_PLUGIN_TIP'), + disabled: (INTERNET_CONNECTION == 1)? false : true, + handler: function (b, e) { + reloadTask.cancel(); + addonsFeaturesStore.load({ + params: { + "force": true + } + }); + } + }, + '->', + { + xtype:"displayfield", + id:'loading-features-indicator' + } + ], + listeners: { + "cellclick": function (grid, rowIndex, columnIndex, e) { + var record = grid.getStore().getAt(rowIndex); + var fieldName = grid.getColumnModel().getDataIndex(columnIndex); + + if (fieldName != "status") { + return; + } + + switch (record.get("status")) { + case "upgrade": + case "ready": + if (INTERNET_CONNECTION == 1) { + installAddon(record.get("id"), record.get("store")); + } else { + Ext.MessageBox.alert(_('ID_INFORMATION'), _('ID_NO_INTERNET_CONECTION')); + } + break; + case "download": + Ext.Ajax.request({ + url: "addonsStoreAction", + params: { + "action": "cancel", + "addon": record.get("id"), + "store": record.get("store") + } + }); + break; + case "available": + addonAvailable(record.get("id")); + break; + } + } + } + }); + + var topBox = new Ext.Panel({ id:'main-panel-hbox', @@ -1444,28 +1692,47 @@ Ext.onReady(function() { defaults: { frame:true, flex: 1, - height: 210 + height: 182 }, items:[licensePanel, pnlSystem] }); - var fullBox = new Ext.Panel({ - id:'main-panel-vbox', - baseCls:'x-plain', - anchor: "right 100%", - layout:'vbox', - //padding: 10, - //defaultMargins: "5", - layoutConfig: { - align : 'stretch', - pack : 'start' - }, + var tabEnterprise = new Ext.TabPanel({ + activeTab: 0, + //width:600, + anchor: '100%', + height: 370, + plain:true, + defaults:{autoScroll: true}, + items:[{ + title: _('ID_ENTERPRISE_PLUGINS'), + items : addonsGrid + },{ + title: _('ID_ENTERPRISE_FIXTURES'), + items : addonsFeatureGrid + } + ] + }); - defaults: { - frame:true - }, - items:[topBox, addonsGrid] - }); + + var fullBox = new Ext.Panel({ + id:'main-panel-vbox', + baseCls:'x-plain', + anchor: "right 100%", + layout:'vbox', + //padding: 10, + //defaultMargins: "5", + layoutConfig: { + align : 'stretch', + pack : 'start' + }, + + defaults: { + frame:true + }, + //items:[topBox, addonsGrid] + items:[topBox, tabEnterprise] + }); /////// addonsGrid.on("rowcontextmenu", @@ -1477,6 +1744,16 @@ Ext.onReady(function() { ); addonsGrid.addListener("rowcontextmenu", onMessageMnuContext, this); + + addonsFeatureGrid.on("rowcontextmenu", + function (grid, rowIndex, evt) { + var sm = grid.getSelectionModel(); + sm.selectRow(rowIndex, sm.isSelected(rowIndex)); + }, + this + ); + + addonsFeatureGrid.addListener("rowcontextmenu", onMessageMnuContext, this); /////// var viewport = new Ext.Viewport({ @@ -1490,6 +1767,7 @@ Ext.onReady(function() { if (licensed) { addonsStore.load(); + addonsFeaturesStore.load(); } });