Merged in feature/HOR-3825 (pull request #6033)

HOR-3825

Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
Approved-by: Paula Quispe <paula.quispe@processmaker.com>
This commit is contained in:
David Callizaya
2017-09-01 20:37:13 +00:00
committed by Paula Quispe
2 changed files with 15 additions and 1 deletions

View File

@@ -1,7 +1,10 @@
<?php <?php
use Illuminate\Support\Facades\Cache;
use Carbon\Carbon;
class PMLicensedFeatures class PMLicensedFeatures
{ {
private $featuresDetails = array (); private $featuresDetails = array ();
private $features = array (); private $features = array ();
private $newFeatures = array( private $newFeatures = array(
@@ -334,6 +337,11 @@ class PMLicensedFeatures
/*----------------------------------********---------------------------------*/ /*----------------------------------********---------------------------------*/
public function verifyfeature ($featureName) public function verifyfeature ($featureName)
{ {
$cached = Cache::get(PmLicenseManager::CACHE_KEY . '.' . SYS_SYS, []);
if (isset($cached[$featureName])) {
return $cached[$featureName];
}
$licenseManager = PmLicenseManager::getSingleton(false); $licenseManager = PmLicenseManager::getSingleton(false);
$_SESSION['__sw__'] = true; $_SESSION['__sw__'] = true;
@@ -350,6 +358,10 @@ class PMLicensedFeatures
$this->featuresDetails[$value[0]] = new stdclass(); $this->featuresDetails[$value[0]] = new stdclass();
} }
$this->featuresDetails[$value[0]]->enabled = $enable; $this->featuresDetails[$value[0]]->enabled = $enable;
$cached[$featureName] = $enable;
Cache::put(PmLicenseManager::CACHE_KEY . '.' . SYS_SYS, $cached, Carbon::now()->addDay(1));
return $enable; return $enable;
} }

View File

@@ -1,7 +1,7 @@
<?php <?php
use ProcessMaker\Plugins\PluginRegistry; use ProcessMaker\Plugins\PluginRegistry;
use Illuminate\Support\Facades\Cache;
/** /**
* class.pmLicenseManager.php * class.pmLicenseManager.php
@@ -10,6 +10,7 @@ use ProcessMaker\Plugins\PluginRegistry;
class PmLicenseManager class PmLicenseManager
{ {
const CACHE_KEY = 'license';
private static $instance = null; private static $instance = null;
@@ -474,6 +475,7 @@ class PmLicenseManager
$tr->setLicenseType ( $LicenseType ); $tr->setLicenseType ( $LicenseType );
$res = $tr->save (); $res = $tr->save ();
Cache::forget(PmLicenseManager::CACHE_KEY . '.' . SYS_SYS);
} catch ( Exception $e ) { } catch ( Exception $e ) {
G::pr($e); G::pr($e);
} }