Adding groups to plugin package via the API

Discussions related to custom development with Select.
Post Reply
mlevi
Posts: 53
Joined: Mon Dec 01, 2014 2:33 pm

Adding groups to plugin package via the API

Post by mlevi »

I am trying to add this via the API.
I am using the following code:
IPluginInfo pluginInfo = pluginManager.Plugins.OrderByDescending(p => p.LastModifiedOn) .FirstOrDefault() as IPluginInfo;
var plugin = await pluginManager.GetPluginAsync(pluginInfo);
ISecurityManager securityManager = (ISecurityManager)server.GetService(typeof(ISecurityManager));
ISecurityIdentity mainUserGrp = securityManager.Identities
.Where(t => t.Enabled && !t.Deleted && t.FullName.Contains("SoftPro All Users"))
.FirstOrDefault();
if (mainUserGrp != null)
{
Console.WriteLine($"Adding User Group {mainUserGrp.Name}");
if (plugin != null)
{
Console.WriteLine($"plugin {plugin.Name}");
plugin.Members.Add(mainUserGrp);
}
}
Everything seems to be working well, code finds my group and plugin but the group just does not get added.
Do you know if this is working properly in the current 4.6.2 version?
yatin.t
Posts: 24
Joined: Tue Jan 07, 2014 9:40 am
Location: Raleigh, NC

Re: Adding groups to plugin package via the API

Post by yatin.t »

Code: Select all

if (plugin != null)
{
    Console.WriteLine($"plugin {plugin.Name}");
    plugin.Members.Add(mainUserGrp);
}
This code would add the group to the Members collection on the in-memory plugin object. Information will be persisted in the system only after you ask the pluginManager to save changes that were made to the plugin.

Code: Select all

pluginManager.ApplyChanges(plugin);
Yatin Tawde
Softpro
Software Engineer
mlevi
Posts: 53
Joined: Mon Dec 01, 2014 2:33 pm

Re: Adding groups to plugin package via the API

Post by mlevi »

I added that line
pluginManager.ApplyChanges(plugin);
and sure enough it adds the member group to the plugin.
But then for some reason Select does not load my custom code, it seems to mess up the plugin.
I tested to make sure I re-installed the plugin and i don't add the group via the API, rather i add it manually after the plugin is installed
then the code loads just fine.
Post Reply