Files
luos/workflow/engine/methods/login/licenseUpdate.php
Ronald Quenta 651d22a71d up observations
2017-08-08 15:47:02 -04:00

56 lines
2.3 KiB
PHP

<?php
$aInfoLoadFile = array();
$aInfoLoadFile['name'] = $_FILES['form']['name']['licenseFile'];
$aInfoLoadFile['tmp_name'] = $_FILES['form']['tmp_name']['licenseFile'];
$aux = pathinfo($aInfoLoadFile['name']);
//validating the extention before to upload it
if ($aux['extension'] != 'dat') {
G::SendTemporalMessage('ID_WARNING_ENTERPRISE_LICENSE_MSG_DAT', 'warning');
} else {
$dir = PATH_DATA_SITE;
G::uploadFile($aInfoLoadFile["tmp_name"], $dir, $aInfoLoadFile["name"]);
//reading the file that was uploaded
$licenseManager =& pmLicenseManager::getSingleton();
$response = $licenseManager->installLicense($dir . $aInfoLoadFile["name"], false, false);
if ($response) {
$licenseManager = new pmLicenseManager();
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";
///////
$cnn = Propel::getConnection("workflow");
$oCriteriaSelect = new Criteria("workflow");
$oCriteriaSelect->add(AddonsStorePeer::STORE_ID, $licenseManager->id);
$oCriteriaUpdate = new Criteria("workflow");
$oCriteriaUpdate->add(AddonsStorePeer::STORE_ID, $licenseManager->id);
$oCriteriaUpdate->add(AddonsStorePeer::STORE_LOCATION, $addonLocation);
BasePeer::doUpdate($oCriteriaSelect, $oCriteriaUpdate, $cnn);
//are all the plugins that are enabled in the workspace
$pluginRegistry = ProcessMaker\Plugins\PluginRegistry::loadSingleton();
/** @var \ProcessMaker\Plugins\Interfaces\PluginDetail $plugin */
foreach ($pluginRegistry->getPlugins() as $plugin) {
if ($plugin->enabled && !in_array($plugin->sNamespace, $licenseManager->features)) {
$pluginRegistry->disablePlugin($plugin->sNamespace);
$pluginRegistry->savePlugin($plugin->sNamespace);
}
}
G::SendTemporalMessage('ID_NLIC', 'info');
} else {
G::SendTemporalMessage('ID_WARNING_ENTERPRISE_LICENSE_MSG', 'warning');
}
}
G::header('Location: ../login/login');
die();