Skip to content

Commit

Permalink
Merge branch 'bugs/560051-AddMissingPermissionsToAllowedLanguages' of h…
Browse files Browse the repository at this point in the history
…ttps://github.com/microsoft/BCApps into bugs/560051-AddMissingPermissionsToAllowedLanguages
  • Loading branch information
JesperSchulz committed Dec 9, 2024
2 parents 71a7a2d + a9b5591 commit f0305bf
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .github/AL-Go-Settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"runs-on": "windows-latest",
"cacheImageName": "",
"UsePsSession": false,
"artifact": "https://bcinsider-fvh2ekdjecfjd6gk.b02.azurefd.net/sandbox/26.0.27706.0/base",
"artifact": "https://bcinsider-fvh2ekdjecfjd6gk.b02.azurefd.net/sandbox/26.0.27750.0/base",
"country": "base",
"useProjectDependencies": true,
"repoVersion": "26.0",
Expand Down
41 changes: 1 addition & 40 deletions src/System Application/App/Email/src/EmailInstaller.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ codeunit 1596 "Email Installer"
procedure AddRetentionPolicyAllowedTables()
begin
AddRetentionPolicyAllowedTables(false);
CreateRetentionPolicySetup(false);
end;

procedure AddRetentionPolicyAllowedTables(ForceUpdate: Boolean)
Expand All @@ -47,59 +46,21 @@ codeunit 1596 "Email Installer"

RetenPolAllowedTables.AddAllowedTable(Database::"Email Outbox", Field.FieldNo(SystemCreatedAt), 7);
RetenPolAllowedTables.AddAllowedTable(Database::"Sent Email", Field.FieldNo(SystemCreatedAt), 7);
RetenPolAllowedTables.AddAllowedTable(Database::"Email Inbox", Field.FieldNo(SystemCreatedAt), 2);

if IsInitialSetup then
UpgradeTag.SetUpgradeTag(GetEmailTablesAddedToAllowedListUpgradeTag());
end;

procedure CreateRetentionPolicySetup(ForceUpdate: Boolean)
var
Field: Record Field;
RetentionPolicySetup: Record "Retention Policy Setup";
RetenPolAllowedTables: Codeunit "Reten. Pol. Allowed Tables";
RetentionPolicySetupCU: Codeunit "Retention Policy Setup";
UpgradeTag: Codeunit "Upgrade Tag";
DateFormula: DateFormula;
IsInitialSetup: Boolean;
begin
IsInitialSetup := not UpgradeTag.HasUpgradeTag(GetEmailInboxPolicyAddedToAllowedListUpgradeTag());
if not (IsInitialSetup or ForceUpdate) then
exit;

if not RetenPolAllowedTables.AddAllowedTable(Database::"Email Inbox", Field.FieldNo(SystemCreatedAt), 2) then
exit;

RetentionPolicySetup.SetRange("Table Id", Database::"Email Inbox");
if not RetentionPolicySetup.IsEmpty() then
exit;

Evaluate(DateFormula, '<-2D>');

RetentionPolicySetup.Validate("Table Id", Database::"Email Inbox");
RetentionPolicySetup.Validate("Apply to all records", true);
RetentionPolicySetup.Validate("Retention Period", RetentionPolicySetupCU.FindOrCreateRetentionPeriod('2 DAYS', "Retention Period Enum"::"Custom", DateFormula));
RetentionPolicySetup.Validate(Enabled, true);
RetentionPolicySetup.Insert(true);

if IsInitialSetup then
UpgradeTag.SetUpgradeTag(GetEmailInboxPolicyAddedToAllowedListUpgradeTag());
end;

local procedure GetEmailTablesAddedToAllowedListUpgradeTag(): Code[250]
begin
exit('MS-373161-EmailLogEntryAdded-20201005');
end;

local procedure GetEmailInboxPolicyAddedToAllowedListUpgradeTag(): Code[250]
begin
exit('MS-539754-EmailInboxPolicyAdded-20240827');
end;

[EventSubscriber(ObjectType::Codeunit, Codeunit::"Reten. Pol. Allowed Tables", OnRefreshAllowedTables, '', false, false)]
local procedure AddAllowedTablesOnRefreshAllowedTables()
begin
AddRetentionPolicyAllowedTables(true);
CreateRetentionPolicySetup(true);
end;

[EventSubscriber(ObjectType::Codeunit, Codeunit::"System Initialization", OnAfterLogin, '', false, false)]
Expand Down
11 changes: 11 additions & 0 deletions src/System Application/App/Language/src/Language.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,17 @@ codeunit 43 Language
exit(LanguageImpl.GetCultureName(LanguageID));
end;

/// <summary>
/// Retrieves the current culture name for the session.
/// </summary>
/// <returns>The culture name. For example, 'en-US'.</returns>
procedure GetCurrentCultureName(): Text
var
LanguageImpl: Codeunit "Language Impl.";
begin
exit(LanguageImpl.GetCurrentCultureName());
end;

/// <summary>
/// Integration event, emitted from <see cref="GetUserLanguageCode"/>.
/// Subscribe to this event to change the default behavior by changing the provided parameter(s).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,13 @@ codeunit 54 "Language Impl."
exit(CultureInfo.Name);
end;

procedure GetCurrentCultureName(): Text
var
CultureInfo: DotNet CultureInfo;
begin
exit(CultureInfo.CurrentCulture.Name);
end;

procedure ShowAllowedLanguagesNotification()
var
AllowedLanguage: Record "Allowed Language";
Expand Down

0 comments on commit f0305bf

Please sign in to comment.