/** * Check if the current license has a store and removes unwanted stores. * * @return bool true if a store was added, false otherwise. */ public static function checkLicenseStore() { require_once PATH_CORE . 'classes' . PATH_SEP . 'class.pmLicenseManager.php'; //getting the licenseManager.... $licenseManager =& pmLicenseManager::getSingleton(); if (isset($licenseManager->id)) { //Remove any license store that is not the active license $criteria = new Criteria(AddonsStorePeer::DATABASE_NAME); $criteria->addSelectColumn("*"); $criteria->add(AddonsStorePeer::STORE_TYPE, "license", Criteria::EQUAL); $criteria->add(AddonsStorePeer::STORE_ID, $licenseManager->id, Criteria::NOT_EQUAL); foreach (AddonsStorePeer::doSelect($criteria) as $store) { $store->clear(); } AddonsStorePeer::doDelete($criteria); //If the active license doesn't have a store, add one for it if (AddonsStorePeer::retrieveByPK($licenseManager->id) === null) { preg_match("/^license_(.*).dat\$/", $licenseManager->file, $matches); $realId = urlencode($matches[1]); $workspace = isset($licenseManager->workspace) ? $licenseManager->workspace : 'pmLicenseSrv'; $addonLocation = "http://{$licenseManager->server}/sys" . $workspace . "/en/green/services/addonsStore?action=getInfo&licId={$realId}"; self::addStore($licenseManager->id, $addonLocation); return true; } } return false; }