extension admin notifications

This commit is contained in:
Yuri Kuznetsov
2022-10-21 16:25:19 +03:00
parent 937f28b52f
commit f4a3a3fbd3
2 changed files with 62 additions and 1 deletions

View File

@@ -29,6 +29,7 @@
namespace Espo\Core\Utils;
use Espo\Entities\Extension;
use Espo\ORM\EntityManager;
/**
@@ -109,6 +110,13 @@ class AdminNotificationManager
}
}
if (!$this->config->get('adminNotificationsExtensionLicenseDisabled')) {
$notificationList = array_merge(
$notificationList,
$this->getExtensionLicenseNotificationList()
);
}
return $notificationList;
}
@@ -203,4 +211,56 @@ class AdminNotificationManager
return $message;
}
/**
* @return array<int, array{id: string, type: string, message: string}>
*/
private function getExtensionLicenseNotificationList(): array
{
$extensionList = $this->entityManager
->getRDBRepositoryByClass(Extension::class)
->where([
'licenseStatus' => [
Extension::LICENSE_STATUS_INVALID,
Extension::LICENSE_STATUS_EXPIRED,
Extension::LICENSE_STATUS_SOFT_EXPIRED,
],
])
->find();
$list = [];
foreach ($extensionList as $extension) {
$message =
$extension->getLicenseStatusMessage() ??
$this->getExtensionLicenseMessageLabel($extension);
if (!$message) {
continue;
}
$message = $this->language->translateLabel($message, 'messages');
$name = $extension->getName();
$list[] = [
'id' => 'newExtensionVersionIsAvailable' . Util::toCamelCase($name, ' ', true),
'type' => 'newExtensionVersionIsAvailable',
'message' => $this->prepareMessage($message, ['name' => $name]),
];
}
return $list;
}
private function getExtensionLicenseMessageLabel(Extension $extension): ?string
{
$status = $extension->getLicenseStatus();
if (!$status) {
return null;
}
return 'extensionLicense' . ucfirst(Util::hyphenToCamelCase($status));
}
}

View File

@@ -361,7 +361,8 @@
"massActionProcessed": "Mass action has been processed.",
"validationFailure": "Backend validation failure.\n\nField: `{field}`\nValidation: `{type}`",
"extensionLicenseInvalid": "Invalid '{name}' extension license.",
"extensionLicenseExpired": "Expired '{name}' extension license.",
"extensionLicenseExpired": "The '{name}' extension license subscription has expired.",
"extensionLicenseSoftExpired": "The '{name}' extension license subscription has expired.",
"confirmAppRefresh": "The application has been updated. It is recommended to refresh the page to ensure the proper functioning.",
"error404": "The url you requested can't be handled.",
"error403": "You don't have an access to this area."