PM-520 Cambios en el Enterprise Plugins Manager
- Se agrego una interfaz para administrar los fixtures.
This commit is contained in:
@@ -53,6 +53,8 @@ class pmLicenseManager
|
||||
);
|
||||
|
||||
$this->result = $results['RESULT'];
|
||||
$this->features = array();
|
||||
$this->fixtures = array();
|
||||
if (in_array($this->result, $validStatus)) {
|
||||
$this->serial="3ptta7Xko2prrptrZnSd356aqmPXvMrayNPFj6CLdaR1pWtrW6qPw9jV0OHjxrDGu8LVxtmSm9nP5kR23HRpdZWccpeui+bKkK<6B>DoqCt2Kqgpq6Vg37s";
|
||||
$info['FIRST_NAME'] = $results['DATA']['FIRST_NAME'];
|
||||
@@ -64,7 +66,9 @@ class pmLicenseManager
|
||||
$this->plan = isset($results ['DATA']['PLAN'])?$results ['DATA']['PLAN']:"";
|
||||
$this->id = $results ['ID'];
|
||||
$this->expireIn = $this->getExpireIn ();
|
||||
$this->features = $this->result!='TMINUS'?isset($results ['DATA']['CUSTOMER_PLUGIN'])?$results ['DATA']['CUSTOMER_PLUGIN']:$this->getActiveFeatures():array();
|
||||
$this->features = $this->result!='TMINUS'?isset($results ['DATA']['CUSTOMER_PLUGIN'])? $results ['DATA']['CUSTOMER_PLUGIN'] : $this->getActiveFeatures() : array();
|
||||
$this->fixtures = $this->result!='TMINUS'?isset($results ['DATA']['CUSTOMER_FIXTURE'])? $results ['DATA']['CUSTOMER_FIXTURE'] : $this->getActiveFixtures() : array();
|
||||
$this->fixturesList = isset($results ['DATA']['FIXTURE_LIST'])? $results ['DATA']['FIXTURE_LIST'] : null;
|
||||
$this->status = $this->getCurrentLicenseStatus ();
|
||||
|
||||
if (isset ( $results ['LIC'] )) {
|
||||
@@ -352,7 +356,9 @@ class pmLicenseManager
|
||||
public function installLicense($path, $redirect = true)
|
||||
{
|
||||
$application = new license_application ( $path, false, true, false, true, true );
|
||||
|
||||
$results = $application->validate ( false, false, "", "", "80", true );
|
||||
|
||||
//if the result is ok then it is saved into DB
|
||||
$res = $results ['RESULT'];
|
||||
if (( $res != 'OK') && ($res != 'EXPIRED' ) && ($res != 'TMINUS') ) {
|
||||
@@ -496,6 +502,17 @@ class pmLicenseManager
|
||||
|
||||
public function getActiveFeatures()
|
||||
{
|
||||
if (file_exists ( PATH_PLUGINS . 'enterprise/data/default' )) {
|
||||
return array();
|
||||
}
|
||||
return unserialize(G::decrypt($this->serial, file_get_contents(PATH_PLUGINS . 'enterprise/data/default')));
|
||||
}
|
||||
|
||||
public function getActiveFixtures()
|
||||
{
|
||||
if (!file_exists ( PATH_PLUGINS . 'enterprise/data/default' )) {
|
||||
return array();
|
||||
}
|
||||
return unserialize(G::decrypt($this->serial, file_get_contents(PATH_PLUGINS . 'enterprise/data/default')));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1504,6 +1504,13 @@ class workspaceTools
|
||||
$versionOld = ( isset($version[0])) ? $version[0] : '';
|
||||
CLI::logging(CLI::info("$versionOld < $versionPresent") . "\n");
|
||||
|
||||
$start = microtime(true);
|
||||
CLI::logging("> Verify enterprise old...\n");
|
||||
$this->verifyEnterprise($workSpace);
|
||||
$stop = microtime(true);
|
||||
$final = $stop - $start;
|
||||
CLI::logging("<*> Verify took $final seconds.\n");
|
||||
|
||||
if ( $versionOld < $versionPresent || strpos($versionPresent, "Branch")) {
|
||||
$start = microtime(true);
|
||||
CLI::logging("> Updating database...\n");
|
||||
|
||||
@@ -64,7 +64,115 @@ class AddonsStore extends BaseAddonsStore
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function addonList()
|
||||
public static function addonList($type = 'plugin')
|
||||
{
|
||||
$result = array();
|
||||
|
||||
AddonsStore::checkLicenseStore();
|
||||
|
||||
$licenseManager = &pmLicenseManager::getSingleton(); //Getting the licenseManager
|
||||
|
||||
$result["store_errors"] = array();
|
||||
list($stores, $errors) = AddonsStore::updateAll(false, $type);
|
||||
|
||||
foreach ($errors as $store_id => $store_error) {
|
||||
$result["store_errors"][] = array("id" => $store_id, "msg" => $store_error);
|
||||
}
|
||||
|
||||
$result["addons"] = array();
|
||||
$result["errors"] = array();
|
||||
|
||||
$criteria = new Criteria();
|
||||
$criteria->addAscendingOrderByColumn(AddonsManagerPeer::ADDON_TYPE);
|
||||
$criteria->addAscendingOrderByColumn(AddonsManagerPeer::ADDON_ID);
|
||||
$criteria->add(AddonsManagerPeer::ADDON_TYPE, $type, Criteria::EQUAL);
|
||||
$addons = AddonsManagerPeer::doSelect($criteria);
|
||||
|
||||
foreach ($addons as $addon) {
|
||||
|
||||
$status = $addon->getAddonStatus();
|
||||
$version = $addon->getAddonVersion();
|
||||
$enabled = null;
|
||||
|
||||
if (!$addon->checkState()) {
|
||||
$result["errors"][] = array("addonId" => $addon->getAddonId(), "storeId" => $addon->getStoreId());
|
||||
}
|
||||
|
||||
$sw = 1;
|
||||
$addonInLicense = in_array($addon->getAddonId(), $licenseManager->features);
|
||||
|
||||
if ($sw == 1 && $addon->getAddonId() != "enterprise" && !$addonInLicense) {
|
||||
$sw = 0;
|
||||
}
|
||||
|
||||
if ($type == 'plugin') {
|
||||
if ($sw == 1 && $addon->isInstalled()) {
|
||||
if ($addon->isEnabled()) {
|
||||
$status = "installed";
|
||||
} else {
|
||||
$status = "disabled";
|
||||
}
|
||||
|
||||
$version = $addon->getInstalledVersion();
|
||||
|
||||
if (version_compare($version . "", $addon->getAddonVersion() . "", "<")) {
|
||||
$status = "upgrade";
|
||||
}
|
||||
|
||||
$enabled = $addon->isEnabled();
|
||||
$sw = 0;
|
||||
}
|
||||
} else {
|
||||
$status = "available";
|
||||
$enabled = false;
|
||||
if (!$addonInLicense && in_array($addon->getAddonName(), $licenseManager->fixtures) == 1) {
|
||||
$status = "installed";
|
||||
$enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($sw == 1 && $addonInLicense) {
|
||||
$status = "ready";
|
||||
$sw = 0;
|
||||
}
|
||||
|
||||
$state = $addon->getAddonState();
|
||||
$log = null;
|
||||
|
||||
if ($state != null) {
|
||||
$status = $state;
|
||||
$log = $addon->getInstallLog();
|
||||
}
|
||||
if ($addon->getAddonId() == "enterprise" && $status== 'ready') {
|
||||
$status = 'installed';
|
||||
}
|
||||
if ($status == 'minus-circle' ) {
|
||||
$status = "available";
|
||||
}
|
||||
|
||||
$result["addons"][$addon->getAddonId()] = array(
|
||||
"id" => $addon->getAddonId(),
|
||||
"store" => $addon->getStoreId(),
|
||||
"name" => $addon->getAddonName(),
|
||||
"nick" => $addon->getAddonNick(),
|
||||
"version" => $version,
|
||||
"enabled" => $enabled,
|
||||
"latest_version" => $addon->getAddonVersion(),
|
||||
"type" => $addon->getAddonType(),
|
||||
"release_type" => $addon->getAddonReleaseType(),
|
||||
"url" => $addon->getAddonDownloadUrl(),
|
||||
"publisher" => $addon->getAddonPublisher(),
|
||||
"description" => $addon->getAddonDescription(),
|
||||
"status" => $status,
|
||||
"log" => $log,
|
||||
"progress" => round($addon->getAddonDownloadProgress())
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function addonFixtureList()
|
||||
{
|
||||
$result = array();
|
||||
|
||||
@@ -135,6 +243,9 @@ class AddonsStore extends BaseAddonsStore
|
||||
if ($addon->getAddonId() == "enterprise" && $status== 'ready') {
|
||||
$status = 'installed';
|
||||
}
|
||||
if ($status == 'minus-circle' ) {
|
||||
$status = "available";
|
||||
}
|
||||
|
||||
$result["addons"][$addon->getAddonId()] = array(
|
||||
"id" => $addon->getAddonId(),
|
||||
@@ -175,14 +286,14 @@ class AddonsStore extends BaseAddonsStore
|
||||
*
|
||||
* @return array containing a 'stores' array and a 'errors' array
|
||||
*/
|
||||
public static function updateAll($force = false)
|
||||
public static function updateAll($force = false, $type = 'plugin')
|
||||
{
|
||||
$stores = array();
|
||||
$errors = array();
|
||||
|
||||
foreach (self::listStores() as $store) {
|
||||
try {
|
||||
$stores[$store->getStoreId()] = $store->update($force);
|
||||
$stores[$store->getStoreId()] = $store->update($force, $type);
|
||||
} catch (Exception $e) {
|
||||
$errors[$store->getStoreId()] = $e->getMessage();
|
||||
}
|
||||
@@ -196,11 +307,12 @@ class AddonsStore extends BaseAddonsStore
|
||||
*
|
||||
* @return int number of addons removed
|
||||
*/
|
||||
public function clear()
|
||||
public function clear($type = 'plugin')
|
||||
{
|
||||
/* Remove old items from this store */
|
||||
$criteria = new Criteria(AddonsManagerPeer::DATABASE_NAME);
|
||||
$criteria->add(AddonsManagerPeer::STORE_ID, $this->getStoreId(), Criteria::EQUAL);
|
||||
$criteria->add(AddonsManagerPeer::ADDON_TYPE, $type, Criteria::EQUAL);
|
||||
|
||||
return AddonsManagerPeer::doDelete($criteria);
|
||||
}
|
||||
@@ -210,7 +322,7 @@ class AddonsStore extends BaseAddonsStore
|
||||
*
|
||||
* @return bool true if updated, false otherwise
|
||||
*/
|
||||
public function update($force = false)
|
||||
public function update($force = false, $type = 'plugin')
|
||||
{
|
||||
require_once PATH_CORE . 'classes' . PATH_SEP . 'class.pmLicenseManager.php';
|
||||
|
||||
@@ -221,12 +333,13 @@ class AddonsStore extends BaseAddonsStore
|
||||
//If we have any addon that is installing or updating, don't update store
|
||||
$criteria = new Criteria(AddonsManagerPeer::DATABASE_NAME);
|
||||
$criteria->add(AddonsManagerPeer::ADDON_STATE, '', Criteria::NOT_EQUAL);
|
||||
$criteria->add(AddonsManagerPeer::ADDON_TYPE, $type);
|
||||
|
||||
if (AddonsManagerPeer::doCount($criteria) > 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->clear();
|
||||
$this->clear($type);
|
||||
|
||||
//Fill with local information
|
||||
|
||||
@@ -241,74 +354,98 @@ class AddonsStore extends BaseAddonsStore
|
||||
$pmLicenseManagerO = &pmLicenseManager::getSingleton();
|
||||
$localPlugins = array();
|
||||
|
||||
foreach ($aPluginsPP as $aPlugin) {
|
||||
$sClassName = substr($aPlugin['sFilename'], 0, strpos($aPlugin['sFilename'], '-'));
|
||||
if ($type == 'plugin') {
|
||||
foreach ($aPluginsPP as $aPlugin) {
|
||||
$sClassName = substr($aPlugin['sFilename'], 0, strpos($aPlugin['sFilename'], '-'));
|
||||
|
||||
if (file_exists(PATH_PLUGINS . $sClassName . '.php')) {
|
||||
require_once PATH_PLUGINS . $sClassName . '.php';
|
||||
if (file_exists(PATH_PLUGINS . $sClassName . '.php')) {
|
||||
require_once PATH_PLUGINS . $sClassName . '.php';
|
||||
|
||||
$oDetails = $oPluginRegistry->getPluginDetails($sClassName . '.php');
|
||||
$oDetails = $oPluginRegistry->getPluginDetails($sClassName . '.php');
|
||||
|
||||
if ($oDetails) {
|
||||
$sStatus = $oDetails->enabled ? G::LoadTranslation('ID_ENABLED') : G::LoadTranslation('ID_DISABLED');
|
||||
if ($oDetails) {
|
||||
$sStatus = $oDetails->enabled ? G::LoadTranslation('ID_ENABLED') : G::LoadTranslation('ID_DISABLED');
|
||||
|
||||
if (isset($oDetails->aWorkspaces)) {
|
||||
if (!in_array(SYS_SYS, $oDetails->aWorkspaces)) {
|
||||
if (isset($oDetails->aWorkspaces)) {
|
||||
if (!in_array(SYS_SYS, $oDetails->aWorkspaces)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ($sClassName == "pmLicenseManager" || $sClassName == "pmTrial") {
|
||||
continue;
|
||||
}
|
||||
|
||||
$sEdit = (($oDetails->sSetupPage != '') && ($oDetails->enabled)? G::LoadTranslation('ID_SETUP') : ' ');
|
||||
$aPlugin = array();
|
||||
$aPluginId = $sClassName;
|
||||
$aPluginTitle = $oDetails->sFriendlyName;
|
||||
$aPluginDescription = $oDetails->sDescription;
|
||||
$aPluginVersion = $oDetails->iVersion;
|
||||
|
||||
if (@in_array($sClassName, $pmLicenseManagerO->features)) {
|
||||
$aPluginStatus = $sStatus;
|
||||
$aPluginLinkStatus = 'pluginsChange?id=' . $sClassName . '.php&status=' . $oDetails->enabled;
|
||||
$aPluginEdit = $sEdit;
|
||||
$aPluginLinkEdit = 'pluginsSetup?id=' . $sClassName . '.php';
|
||||
$aPluginStatusA = $sStatus == "Enabled" ? "installed" : 'disabled';
|
||||
$enabledStatus = true;
|
||||
} else {
|
||||
$aPluginStatus = "";
|
||||
$aPluginLinkStatus = '';
|
||||
$aPluginEdit = '';
|
||||
$aPluginLinkEdit = '';
|
||||
$aPluginStatusA = 'minus-circle';
|
||||
$enabledStatus = false;
|
||||
}
|
||||
|
||||
$addon = new AddonsManager();
|
||||
//G::pr($addon);
|
||||
$addon->setAddonId($aPluginId);
|
||||
$addon->setStoreId($this->getStoreId());
|
||||
//Don't trust external data
|
||||
$addon->setAddonName($aPluginId);
|
||||
$addon->setAddonDescription($aPluginDescription);
|
||||
$addon->setAddonNick($aPluginTitle);
|
||||
$addon->setAddonVersion("");
|
||||
$addon->setAddonStatus($aPluginStatusA);
|
||||
$addon->setAddonType("plugin");
|
||||
$addon->setAddonPublisher("Colosa");
|
||||
$addon->setAddonDownloadUrl("");
|
||||
$addon->setAddonDownloadMd5("");
|
||||
$addon->setAddonReleaseDate(null);
|
||||
$addon->setAddonReleaseType('localRegistry');
|
||||
$addon->setAddonReleaseNotes("");
|
||||
$addon->setAddonState("");
|
||||
|
||||
$addon->save();
|
||||
|
||||
$localPlugins[$aPluginId] = $addon;
|
||||
}
|
||||
|
||||
if ($sClassName == "pmLicenseManager" || $sClassName == "pmTrial") {
|
||||
continue;
|
||||
}
|
||||
|
||||
$sEdit = (($oDetails->sSetupPage != '') && ($oDetails->enabled)? G::LoadTranslation('ID_SETUP') : ' ');
|
||||
$aPlugin = array();
|
||||
$aPluginId = $sClassName;
|
||||
$aPluginTitle = $oDetails->sFriendlyName;
|
||||
$aPluginDescription = $oDetails->sDescription;
|
||||
$aPluginVersion = $oDetails->iVersion;
|
||||
|
||||
if (@in_array($sClassName, $pmLicenseManagerO->features)) {
|
||||
$aPluginStatus = $sStatus;
|
||||
$aPluginLinkStatus = 'pluginsChange?id=' . $sClassName . '.php&status=' . $oDetails->enabled;
|
||||
$aPluginEdit = $sEdit;
|
||||
$aPluginLinkEdit = 'pluginsSetup?id=' . $sClassName . '.php';
|
||||
$aPluginStatusA = $sStatus == "Enabled" ? "installed" : 'disabled';
|
||||
$enabledStatus = true;
|
||||
} else {
|
||||
$aPluginStatus = "";
|
||||
$aPluginLinkStatus = '';
|
||||
$aPluginEdit = '';
|
||||
$aPluginLinkEdit = '';
|
||||
$aPluginStatusA = 'minus-circle';
|
||||
$enabledStatus = false;
|
||||
}
|
||||
|
||||
$addon = new AddonsManager();
|
||||
//G::pr($addon);
|
||||
$addon->setAddonId($aPluginId);
|
||||
$addon->setStoreId($this->getStoreId());
|
||||
//Don't trust external data
|
||||
$addon->setAddonName($aPluginId);
|
||||
$addon->setAddonDescription($aPluginDescription);
|
||||
$addon->setAddonNick($aPluginTitle);
|
||||
$addon->setAddonVersion("");
|
||||
$addon->setAddonStatus($aPluginStatusA);
|
||||
$addon->setAddonType("plugin");
|
||||
$addon->setAddonPublisher("Colosa");
|
||||
$addon->setAddonDownloadUrl("");
|
||||
$addon->setAddonDownloadMd5("");
|
||||
$addon->setAddonReleaseDate(null);
|
||||
$addon->setAddonReleaseType('localRegistry');
|
||||
$addon->setAddonReleaseNotes("");
|
||||
$addon->setAddonState("");
|
||||
|
||||
$addon->save();
|
||||
|
||||
$localPlugins[$aPluginId] = $addon;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$list = unserialize($pmLicenseManagerO->fixturesList);
|
||||
foreach ($list['addons'] as $key => $fixture) {
|
||||
$addon = new AddonsManager();
|
||||
$addon->setAddonId($fixture['name']);
|
||||
$addon->setStoreId($fixture['guid']);
|
||||
$addon->setAddonName($fixture['name']);
|
||||
$addon->setAddonDescription($fixture['description']);
|
||||
$addon->setAddonNick($fixture['nick']);
|
||||
$addon->setAddonVersion("");
|
||||
$addon->setAddonStatus($fixture['status']);
|
||||
$addon->setAddonType("fixture");
|
||||
$addon->setAddonPublisher("Colosa");
|
||||
$addon->setAddonDownloadUrl("");
|
||||
$addon->setAddonDownloadMd5("");
|
||||
$addon->setAddonReleaseDate(null);
|
||||
$addon->setAddonReleaseType('localRegistry');
|
||||
$addon->setAddonReleaseNotes("");
|
||||
$addon->setAddonState("");
|
||||
|
||||
$addon->save();
|
||||
}
|
||||
}
|
||||
|
||||
$this->setStoreLastUpdated(time());
|
||||
@@ -359,6 +496,7 @@ class AddonsStore extends BaseAddonsStore
|
||||
$context = stream_context_create($option);
|
||||
|
||||
//This may block for a while, always use AJAX to call this method
|
||||
$url = $url . '&type=' . strtoupper($type);
|
||||
$data = file_get_contents($url, false, $context);
|
||||
|
||||
if ($data === false) {
|
||||
@@ -388,7 +526,7 @@ class AddonsStore extends BaseAddonsStore
|
||||
throw (new Exception("Addons not found on store data"));
|
||||
}
|
||||
|
||||
$this->clear();
|
||||
$this->clear($type);
|
||||
|
||||
try {
|
||||
//Add each item to this stores addons
|
||||
@@ -451,7 +589,7 @@ class AddonsStore extends BaseAddonsStore
|
||||
$this->save();
|
||||
} catch (Exception $e) {
|
||||
//If we had issues, don't keep only a part of the items
|
||||
$this->clear();
|
||||
$this->clear($type);
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user