Example #1
0
 /**
  * Get list of upgrade waves
  *
  * @return array
  */
 protected function getWaves()
 {
     if (!isset(static::$waves)) {
         static::$waves = \XLite\Core\Marketplace::getInstance()->getWaves();
     }
     return static::$waves;
 }
Example #2
0
 /**
  * Action of license key registration
  *
  * @return void
  */
 protected function doActionRegisterKey()
 {
     $key = \XLite\Core\Request::getInstance()->key;
     $addonsInfo = \XLite\Core\Marketplace::getInstance()->checkAddonKey($key);
     if ($addonsInfo && $addonsInfo[$key]) {
         $addonsInfo = $addonsInfo[$key];
         $repo = \XLite\Core\Database::getRepo('\\XLite\\Model\\ModuleKey');
         foreach ($addonsInfo as $info) {
             $module = \XLite\Core\Database::getRepo('\\XLite\\Model\\Module')->findOneBy(array('author' => $info['author'], 'name' => $info['name']));
             if ($module) {
                 $entity = $repo->findKey($info['author'], $info['name']);
                 if ($entity) {
                     $entity->setKeyValue($key);
                     $repo->update($entity);
                 } else {
                     $entity = $repo->insert($info + array('keyValue' => $key));
                 }
                 \XLite\Core\Database::getEM()->flush();
                 // Clear cache for proper installation
                 \XLite\Core\Marketplace::getInstance()->clearActionCache(\XLite\Core\Marketplace::ACTION_GET_ADDONS_LIST);
                 $this->showInfo(__FUNCTION__, 'License key has been successfully verified for "{{name}}" module by "{{author}}" author', array('name' => $module->getModuleName(), 'author' => $module->getAuthorName()));
             } else {
                 $this->showError(__FUNCTION__, 'Key is validated, but the module [' . implode(',', $info) . '] was not found');
             }
         }
     } else {
         $error = \XLite\Core\Marketplace::getInstance()->getError();
         if ($error) {
             $this->showError(__FUNCTION__, 'Response from marketplace: ' . $error);
         } else {
             $this->showError(__FUNCTION__, 'Response from marketplace is not received');
         }
     }
     $this->setReturnURL($this->buildURL('addons_list_marketplace'));
 }
Example #3
0
 /**
  * Initialize controller
  *
  * @return void
  */
 public function init()
 {
     parent::init();
     // Download data from marketplace
     \XLite\Core\Marketplace::getInstance()->saveAddonsList();
     // Download data from marketplace
     \XLite\Core\Marketplace::getInstance()->checkAddonsKeys();
 }
Example #4
0
 /**
  * Check if marketplace is accessible
  *
  * The admin is able to access the marketplate if:
  * 1) PHAR is installed on the server (the module packages can be installed to the shop)
  *
  * and
  *
  * 2) The marketplace is online and the cache is up-to-dated
  *
  * @return boolean
  */
 public function isMarketplaceAccessible()
 {
     // Check Phar availability and marketplace accessibility
     $result = extension_loaded('phar') && \XLite\Core\Marketplace::getInstance()->doTestMarketplace();
     if ($result) {
         // Check modules from marketplace is presented in the database
         $cnd = new \XLite\Core\CommonCell();
         $cnd->{\XLite\Model\Repo\Module::P_FROM_MARKETPLACE} = true;
         $countModules = \XLite\Core\Database::getRepo('XLite\\Model\\Module')->search($cnd, true);
         $result = 0 < $countModules;
     }
     return $result;
 }
Example #5
0
 /**
  * Return LICENSE text for the module
  *
  * @return string
  */
 public function getLicense()
 {
     $result = null;
     $info = \XLite\Core\Marketplace::getInstance()->getAddonInfo($this->getModule()->getMarketplaceID());
     if ($info) {
         $result = $info[\XLite\Core\Marketplace::FIELD_LICENSE];
     } else {
         $this->showError(__FUNCTION__, 'License is not received');
     }
     // Since this action is performed in popup
     if (!isset($result)) {
         $this->redirect();
     }
     return $result;
 }
Example #6
0
 /**
  * Download package
  *
  * @return boolean
  */
 public function download()
 {
     $result = false;
     $majorVersion = $this->getMajorVersionNew();
     $minorVersion = $this->getMinorVersionNew();
     $path = \XLite\Core\Marketplace::getInstance()->getCorePack($majorVersion, $minorVersion);
     $params = array('major' => $majorVersion, 'minor' => $minorVersion);
     if (isset($path)) {
         $this->addFileInfoMessage('Core pack (v.{{major}}.{{minor}}) is received', $path, true, $params);
         $this->setRepositoryPath($path);
         $this->saveHashesForInstalledFiles();
         $result = parent::download();
     } else {
         $this->addFileErrorMessage('Core pack (v.{{major}}.{{minor}}) is not received', \XLite\Core\Marketplace::getInstance()->getError(), true, $params);
     }
     return $result;
 }
Example #7
0
 /**
  * Fetch messages
  *
  * @return array
  */
 protected function fetchMessages()
 {
     $result = array();
     $messages = \XLite\Core\Marketplace::getInstance()->getXC5Notifications();
     if ($messages) {
         foreach ($messages as $message) {
             if ($message['type'] == 'warning') {
                 $result[] = $message;
             }
         }
     }
     return $result;
 }
Example #8
0
 /**
  * Check if there are updates (new core revision and/or module revisions)
  *
  * @return boolean
  */
 protected function areUpdatesAvailable()
 {
     if (!isset($this->updateFlags)) {
         $this->updateFlags = \XLite\Core\Marketplace::getInstance()->checkForUpdates();
         if (!is_array($this->updateFlags)) {
             $this->updateFlags = array();
         }
     }
     return !empty($this->updateFlags[\XLite\Core\Marketplace::FIELD_ARE_UPDATES_AVAILABLE]);
 }
Example #9
0
File: Cell.php Project: kingsj/core
 /**
  * Protected constructor
  *
  * @return void
  */
 protected function __construct()
 {
     parent::__construct();
     // Upload addons info into the database
     \XLite\Core\Marketplace::getInstance()->saveAddonsList($this->getCacheTTL());
     list($entries, $incompatibleModules, $isUpgraded) = \XLite\Core\TmpVars::getInstance()->{self::CELL_NAME};
     if (is_array($entries)) {
         $this->entries = array_merge($this->entries, $entries);
         $this->incompatibleModules = $this->incompatibleModules + (array) $incompatibleModules;
         $this->setUpgraded(!empty($isUpgraded));
     } else {
         $this->collectEntries();
     }
 }
Example #10
0
 /**
  * Get purchase page URL
  *
  * :FIXME: is it really needed?
  *
  * @return string
  */
 protected function getPurchaseURL()
 {
     $apiURL = trim(\Includes\Utils\Converter::trimTrailingChars(\XLite\Core\Marketplace::getInstance()->getMarketplaceURL(), '/'));
     // Remove 'api' directory
     $apiURL = preg_replace('/\\?q=.+/Ss', '', $apiURL);
     $apiURL = preg_replace('/\\/api$/Ss', '/', $apiURL);
     return $apiURL;
 }
Example #11
0
 /**
  * The certain request handler
  *
  * @param integer $ttl Data TTL OPTIONAL
  *
  * @return boolean
  */
 public function checkAddonsKeys($ttl = self::TTL_LONG)
 {
     $repoModuleKey = \XLite\Core\Database::getRepo('\\XLite\\Model\\ModuleKey');
     $keys = array_unique(\Includes\Utils\ArrayManager::getObjectsArrayFieldValues($repoModuleKey->findAll(), 'getKeyValue', true));
     $result = $this->performActionWithTTL($ttl, static::ACTION_CHECK_ADDON_KEY, array(static::FIELD_KEY => $keys), false);
     if (static::TTL_NOT_EXPIRED !== $result) {
         $repoModule = \XLite\Core\Database::getRepo('\\XLite\\Model\\Module');
         foreach ((array) $result as $key => $addonsInfo) {
             $repoModuleKey->deleteInBatch($repoModuleKey->findBy(array('keyValue' => $key)));
             foreach ($addonsInfo as $info) {
                 $module = $repoModule->findOneBy(array('author' => $info['author'], 'name' => $info['name']));
                 if ($module) {
                     $repoModuleKey->insert($info + array('keyValue' => $key));
                     // Clear cache for proper installation
                     \XLite\Core\Marketplace::getInstance()->clearActionCache(\XLite\Core\Marketplace::ACTION_GET_ADDONS_LIST);
                 } else {
                     // No module has been found
                 }
             }
         }
     }
     return (bool) $result;
 }
Example #12
0
 /**
  * Module has license restriction if the core has free license but the module does not have free edition
  * The empty editions field means the module has no license restriction
  *
  * @return boolean
  */
 public function hasLicenseRestriction()
 {
     $result = false;
     $coreKey = \XLite::getXCNLicenseKey();
     // The store without any license (trial license active) has no license-restricted module
     if ($coreKey !== '') {
         $editions = $this->getEditionNames();
         // The module with the empty editions structure has no restrictions
         if (!empty($editions)) {
             $freeEdition = \XLite\Core\Marketplace::getInstance()->getFreeLicenseEdition();
             // Module has restricted if there is no freeEdition in the editions structure
             $result = !in_array($freeEdition, $editions);
         }
     }
     return $result;
 }
Example #13
0
 /**
  * Check if the core has update (but not upgrade) available
  *
  * @return boolean
  */
 protected function hasCoreUpdate()
 {
     $update = \XLite\Core\Marketplace::getInstance()->checkForUpdates();
     return !empty($update) && ($update[\XLite\Core\Marketplace::FIELD_ARE_UPDATES_AVAILABLE] && !$update[\XLite\Core\Marketplace::FIELD_IS_UPGRADE_AVAILABLE]);
 }
Example #14
0
 /**
  * Returns purchase license URL
  *
  * @return string
  */
 protected function getPurchaseLicenseURL()
 {
     return \XLite\Core\Marketplace::getPurchaseURL();
 }
Example #15
0
 /**
  * Defines the tags data structure
  *
  * @return array
  */
 protected function getTagsData()
 {
     $result = array();
     foreach (\XLite\Core\Marketplace::getInstance()->getAllTags() as $tag) {
         $result[$tag] = $this->buildURL('addons_list_marketplace', '', array('tag' => $tag, 'clearPager' => '1', 'clearSearch' => 1));
     }
     return $result;
 }
Example #16
0
 /**
  * Initialize handler
  *
  * @return void
  */
 public function init()
 {
     \XLite\Core\Marketplace::getInstance()->getXC5Notifications();
 }
 /**
  * Clear marketplace cache
  *
  * @return void
  */
 protected function doActionClearCache()
 {
     \XLite\Core\Marketplace::getInstance()->clearActionCache();
     $params = \XLite\Core\Request::getInstance()->landing ? array('landing' => 1) : array();
     $this->setReturnURL($this->buildURL('addons_list_marketplace', '', $params));
 }
Example #18
0
 /**
  * Return list of core versions for update
  *
  * @return array
  */
 protected function getCoreVersions()
 {
     if (!isset($this->coreVersions)) {
         $this->coreVersions = (array) \XLite\Core\Marketplace::getInstance()->getCores();
     }
     return $this->coreVersions;
 }
Example #19
0
 /**
  * Defines the tag promo banner
  *
  * @return boolean|array
  */
 protected function getPromoBanner()
 {
     if (is_null($this->bannerInfo)) {
         $this->bannerInfo = false;
         $tag = $this->getTagValue();
         if ($tag && !$this->isLandingPage()) {
             $tags = \XLite\Core\Marketplace::getInstance()->getAllTagsInfo();
             if (isset($tags[$tag])) {
                 $tagInfo = $tags[$tag];
                 // We show promo banner if
                 // banner image is defined
                 // and
                 // module for banner is defined
                 // and
                 // banner is not expired (or expiration date is 0, nonexpiry-type banner)
                 if ($tagInfo[\XLite\Core\Marketplace::FIELD_TAG_BANNER_IMG] && (!empty($tagInfo[\XLite\Core\Marketplace::FIELD_TAG_MODULE_BANNER]) || !empty($tagInfo[\XLite\Core\Marketplace::FIELD_TAG_BANNER_URL])) && $this->isPromoBannerActive($tagInfo[\XLite\Core\Marketplace::FIELD_TAG_BANNER_EXPIRATION_DATE])) {
                     $this->bannerInfo = array('banner_url' => $tagInfo[\XLite\Core\Marketplace::FIELD_TAG_BANNER_IMG], 'module_banner_url' => !empty($tagInfo[\XLite\Core\Marketplace::FIELD_TAG_BANNER_URL]) ? $tagInfo[\XLite\Core\Marketplace::FIELD_TAG_BANNER_URL] : $this->getBannerURL($tagInfo[\XLite\Core\Marketplace::FIELD_TAG_MODULE_BANNER]), 'is_external_link' => !empty($tagInfo[\XLite\Core\Marketplace::FIELD_TAG_BANNER_URL]));
                 }
             }
         }
     }
     return $this->bannerInfo;
 }
Example #20
0
 /**
  * Download package
  *
  * @return boolean
  */
 public function download()
 {
     $result = false;
     $licenseKey = $this->getModuleForUpgrade()->getLicenseKey();
     $path = \XLite\Core\Marketplace::getInstance()->getAddonPack($this->getMarketplaceID(), $licenseKey ? $licenseKey->getKeyValue() : null);
     $params = array('name' => $this->getActualName());
     if (isset($path)) {
         $this->addFileInfoMessage('Module pack ("{{name}}") is received', $path, true, $params);
         $this->setRepositoryPath($path);
         $this->saveHashesForInstalledFiles();
         $result = parent::download();
     } else {
         $error = \XLite\Core\Marketplace::getInstance()->getError();
         if (static::LICENSE_ERROR === $error) {
             $this->addToPremiumLicenseModules();
         } else {
             $this->addFileErrorMessage('Module pack ("{{name}}") is not received', $error, true, $params);
         }
     }
     return $result;
 }
Example #21
0
 /**
  * Marketplace modules list (nonFree and Business)
  *
  * @param boolean $enabledFlag Edition OPTIONAL
  *
  * @return array
  */
 public function getBusinessEditionModulesList()
 {
     $result = array();
     $cnd = new \XLite\Core\CommonCell();
     $cnd->{static::P_FROM_MARKETPLACE} = true;
     $modules = $this->search($cnd);
     $freeEdition = \XLite\Core\Marketplace::getInstance()->getFreeLicenseEdition();
     foreach ($modules as $key => $module) {
         $editions = $module->getEditionNames();
         if (!empty($editions) && !in_array($freeEdition, $editions)) {
             $installedModule = $this->findOneBy(array('name' => $module->getName(), 'author' => $module->getAuthor(), 'fromMarketplace' => 0, 'installed' => 1));
             \XLite\Core\Database::getEM()->detach($module);
             if ($installedModule) {
                 $module->setInstalled(true);
                 $module->setEnabled($installedModule->getEnabled());
             } elseif (!in_array('Business', $editions) || preg_match('/\\[DEPRECATED\\]$/', $module->getModuleName())) {
                 continue;
             }
             $result[$key] = $module;
         }
     }
     return $result;
 }
Example #22
0
 /**
  * Get container tag attributes 
  * 
  * @return array
  */
 protected function getContainerTagAttributes()
 {
     $state = 'post-opened';
     $tmpVarHash = \XLite\Core\TmpVars::getInstance()->{static::READ_MARK_KEY};
     $realHash = \XLite\Core\Marketplace::getInstance()->unseenUpdatesHash();
     if ($realHash !== $tmpVarHash) {
         \XLite\Core\TmpVars::getInstance()->{static::READ_MARK_KEY} = null;
     } elseif (!empty($tmpVarHash)) {
         $state = 'post-closed';
     }
     return array('class' => array('upgrade-box', $state));
 }
Example #23
0
 /**
  * Preprocess option Environment - update_wave
  *
  * @param \XLite\Model\Config $option Option entity
  *
  * @return boolean
  */
 protected function preprocessUpgradeWaveOption($option)
 {
     $result = false;
     $value = $option->getNewValue();
     $waves = \XLite\Core\Marketplace::getInstance()->getWaves();
     if ($waves && isset($waves[$value])) {
         if (\XLite\Core\Marketplace::getInstance()->changeKeysWave($value)) {
             \XLite\Core\TopMessage::addInfo('Upgrade access level has been successfully assigned to your license keys');
             $result = true;
         } else {
             \XLite\Core\TopMessage::addError('Could not assign upgrade access level to your license keys');
         }
     }
     return $result;
 }
Example #24
0
 /**
  * Protected constructor
  *
  * @return void
  */
 protected function __construct()
 {
     parent::__construct();
     // Upload addons info into the database
     \XLite\Core\Marketplace::getInstance()->saveAddonsList($this->getCacheTTL());
     $coreVersionBeforeUpgrade = \XLite\Core\Config::getInstance()->Internal->coreVersionBeforeUpgrade;
     // WARNING! Do not change the order of the structure data.
     // The NEW information must be added to the TAIL of the structure strictly!
     list($entries, $isUpgraded, $disabledModulesHooks, $incompatibleModules, $preUpgradeWarningModules) = \XLite\Core\TmpVars::getInstance()->{self::CELL_NAME};
     // Hack for the 5.1.2 and previous versions.
     // @see #BUG-537 for more details
     if ($coreVersionBeforeUpgrade && version_compare($coreVersionBeforeUpgrade, '5.1.2', '<=')) {
         list($entries, $incompatibleModules, $isUpgraded, $disabledModulesHooks, $preUpgradeWarningModules) = \XLite\Core\TmpVars::getInstance()->{self::CELL_NAME};
     }
     if (is_array($entries)) {
         $this->entries = array_merge($this->entries, $entries);
         $this->incompatibleModules = $this->incompatibleModules + (array) $incompatibleModules;
         $this->disabledModulesHooks = $this->disabledModulesHooks + (array) $disabledModulesHooks;
         $this->preUpgradeWarningModules = $this->preUpgradeWarningModules + (array) $preUpgradeWarningModules;
         $this->setUpgraded(!empty($isUpgraded));
     } else {
         $this->collectEntries();
     }
 }
Example #25
0
 /**
  * Run controller
  *
  * @return void
  */
 protected function run()
 {
     \XLite\Core\Marketplace::getInstance()->updateShippingMethods();
     parent::run();
 }
Example #26
0
 /**
  * Return upgrade flags
  *
  * @return array
  */
 protected function getUpdateFlags()
 {
     if (!isset($this->updateFlags)) {
         $this->updateFlags = \XLite\Core\Marketplace::getInstance()->checkForUpdates();
     }
     return is_array($this->updateFlags) ? $this->updateFlags : array();
 }
Example #27
0
 /**
  * Request marketplace to resend license key info on the specified email
  *
  * @return void
  */
 protected function doActionResendKey()
 {
     $result = \XLite\Core\Marketplace::getInstance()->doResendLicenseKey(\XLite\Core\Request::getInstance()->email);
     if ($result) {
         \XLite\Core\TopMessage::addInfo('Information about free license key has been sent', array('email' => \XLite\Core\Request::getInstance()->email));
     } else {
         \XLite\Core\TopMessage::addError(\XLite\Core\Marketplace::getInstance()->getError());
     }
     $this->setReturnURL($this->buildURL('activate_free_license'));
 }
Example #28
0
 /**
  * URL of the X-Cart company's License Agreement page
  *
  * @return string
  */
 protected function getLicenseAgreementURL()
 {
     return \XLite\Core\Marketplace::getLicenseAgreementURL();
 }
Example #29
0
 /**
  * Action 'Re-validate license keys'
  *
  * @return void
  */
 protected function doActionValidateKeys()
 {
     $result = \XLite\Core\Marketplace::getInstance()->checkAddonsKeys(10);
     $this->setReturnURL($this->buildURL('upgrade'));
 }
Example #30
0
 /**
  * Uninstall module
  *
  * @return void
  */
 protected function doActionUninstall()
 {
     $module = $this->getModule();
     if ($module) {
         $pack = new \XLite\Core\Pack\Module($module);
         $dirs = $pack->getDirs();
         $nonWritableDirs = array();
         // Check permissions
         foreach ($dirs as $dir) {
             if (!\Includes\Utils\FileManager::isDirWriteable($dir)) {
                 $nonWritableDirs[] = \Includes\Utils\FileManager::getRelativePath($dir, LC_DIR_ROOT);
             }
         }
         $params = array('name' => $module->getActualName());
         if (empty($nonWritableDirs)) {
             $yaml = \Includes\Utils\FileManager::read(\Includes\Utils\ModulesManager::getModuleYAMLFile($module->getAuthor(), $module->getName()));
             // Remove from FS
             foreach ($dirs as $dir) {
                 \Includes\Utils\FileManager::unlinkRecursive($dir);
             }
             // Disable this and depended modules
             \Includes\Utils\ModulesManager::disableModule($module->getActualName());
             \Includes\Utils\ModulesManager::removeModuleFromDisabledStructure($module->getActualName());
             // Remove from DB
             \XLite\Core\Database::getRepo('\\XLite\\Model\\Module')->delete($module);
             if ($module->getModuleID()) {
                 $message = 'A DB error occured while uninstalling the module "{{name}}"';
                 $this->showError(__FUNCTION__, $message, $params);
             } else {
                 if (!empty($yaml)) {
                     \XLite\Core\Database::getInstance()->unloadFixturesFromYaml($yaml);
                 }
                 $message = 'The module "{{name}}" has been uninstalled successfully';
                 $this->showInfo(__FUNCTION__, $message, $params);
             }
             // To restore previous state
             \XLite\Core\Marketplace::getInstance()->saveAddonsList(0);
             // Flag to rebuild cache
             \XLite::setCleanUpCacheFlag(true);
         } else {
             $message = 'Unable to delete module "{{name}}" files: some dirs have no writable permissions: {{dirs}}';
             $this->showError(__FUNCTION__, $message, $params + array('dirs' => implode(', ', $nonWritableDirs)));
         }
     }
 }