mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 06:56:05 +00:00
extension admin notifications
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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."
|
||||
|
||||
Reference in New Issue
Block a user