Skip to content

Commit 9dbc3ca

Browse files
Group with default entity right in settings file done and close #85
1 parent d022adb commit 9dbc3ca

3 files changed

Lines changed: 24 additions & 15 deletions

File tree

BExIS.Modules.EMM.UI.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@
159159
<Compile Include="Helper\EmailHelper.cs" />
160160
<Compile Include="Helper\EMMSeedDataGenerator.cs" />
161161
<Compile Include="Helper\FormHelper.cs" />
162+
<Compile Include="Helper\Settings.cs" />
162163
<Compile Include="Models\AbstractMetadataStepModel.cs" />
163164
<Compile Include="Models\AbstractStepModel.cs" />
164165
<Compile Include="Models\EventModel.cs" />
@@ -174,6 +175,7 @@
174175
<ItemGroup>
175176
<Content Include="Content\main.css" />
176177
<Content Include="EMM.Manifest.xml" />
178+
<Content Include="Emm.Settings.xml" />
177179
<Content Include="packages.config" />
178180
<Content Include="Scripts\Form.js" />
179181
<Content Include="Views\Web.config" />

Controllers/EventController.cs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -145,22 +145,20 @@ public ActionResult Save(EventModel model, HttpPostedFileBase file)
145145
using (EntityPermissionManager pManager = new EntityPermissionManager())
146146
{
147147
Entity entityType = entityTypeManager.FindByName("Event");
148-
149-
var adminGroup = groupManager.FindByNameAsync("administrator").Result;
150-
//temp hartcoded until the new settings implementation is available
151-
var beoGroup = groupManager.FindByNameAsync("beo").Result;
152-
153-
int fullRights = (int)RightType.Read + (int)RightType.Write + (int)RightType.Delete + (int)RightType.Grant;
154-
155-
if (adminGroup != null)
156-
{
157-
if (pManager.GetRights(adminGroup.Id, entityType.Id, newEvent.Id) == 0)
158-
pManager.Create(adminGroup.Id, entityType.Id, newEvent.Id, fullRights);
159-
}
160-
if (beoGroup != null)
148+
string[] eventAdminGroups = Helper.Settings.get("EventAdminGroups").ToString().Split(',');
149+
if (eventAdminGroups != null && eventAdminGroups.Length > 0)
161150
{
162-
if (pManager.GetRights(beoGroup.Id, entityType.Id, newEvent.Id) == 0)
163-
pManager.Create(beoGroup.Id, entityType.Id, newEvent.Id, fullRights);
151+
foreach(var g in eventAdminGroups)
152+
{
153+
int fullRights = (int)RightType.Read + (int)RightType.Write + (int)RightType.Delete + (int)RightType.Grant;
154+
var group = groupManager.FindByNameAsync(g).Result;
155+
if (group != null)
156+
{
157+
if (pManager.GetRights(group.Id, entityType.Id, newEvent.Id) == 0)
158+
pManager.Create(group.Id, entityType.Id, newEvent.Id, fullRights);
159+
}
160+
161+
}
164162
}
165163
}
166164
}

Emm.Settings.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<settings>
3+
<entry key="key1" value="value1" type="String"/>
4+
<entry key="key2" value="value2" type="String"/>
5+
<entry key="key3" value="21" type="Int16"/>
6+
7+
<entry key="EventAdminGroups" value="beo, administrator" type="string"/>
8+
9+
</settings>

0 commit comments

Comments
 (0)