/** * 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; }
/** * Removes this object from datastore and sets delete attribute. * * @param Connection $con * @return void * @throws PropelException * @see BaseObject::setDeleted() * @see BaseObject::isDeleted() */ public function delete($con = null) { if ($this->isDeleted()) { throw new PropelException("This object has already been deleted."); } if ($con === null) { $con = Propel::getConnection(AddonsStorePeer::DATABASE_NAME); } try { $con->begin(); AddonsStorePeer::doDelete($this, $con); $this->setDeleted(true); $con->commit(); } catch (PropelException $e) { $con->rollback(); throw $e; } }