text: CodePlexProject Hosting for Open Source Software
  I have implemented a new permission. I copied some code from an existing IPermissionProvider. There are a couple things I'm unsure of, though.
  Here is my code.
  public class Permissions : IPermissionProvider
  {
  public static readonly Permission DownloadLessonPlans = new Permission { Description = "Download Lesson Plans", Name = "DownloadLessonPlans" };
  public virtual Feature Feature { get; set; }
  public IEnumerable<Permission> GetPermissions()
  {
  return new[] {
  DownloadLessonPlans
  };
  }
  public IEnumerable<PermissionStereotype> GetDefaultStereotypes()
  {
  return new[] {
  new PermissionStereotype {
  Name = "Administrator",
  Permissions = new[] {DownloadLessonPlans}
  },
  new PermissionStereotype {
  Name = "Editor",
  Permissions = new[] {DownloadLessonPlans}
  },
  new PermissionStereotype {
  Name = "Author",
  Permissions = new[] {DownloadLessonPlans}
  }
  };
  }
  }
  1. I kind of cargo-culted the virtual Feature Feature property in there, as I see it in all IPermissionProviders...is this used to basically "namespace" permissions? That is my theory based on a comment in Orchard.Roles.DefaultRoleUpdater that
  reads "when another module is being enabled, locate matching permission providers."
  2. More importantly, what does GetDefaultStereotypes do? I would think that for each of those three roles that I've specified, the "allow" and "effective" checkboxes should show as checked for my new permission. Administrator indeed shows
  these boxes checked, but Editor and Author do not. The code also doesn't indicate whether the permission should be AVAILABLE for setting, as I can set my permission for all other roles in the dashboard. So..if neither of these are what that code is supposed
  to do, what IS it supposed do?
  1. Yes, it's there for us to be able to classify permissions under the relevant feature, and to only check permissions for enabled features.
  2. This should be applied to those roles if they exist, when the feature is enabled. If that is not happening, it is a bug.
  Are you sure you want to delete this post? You will not be able to recover it later.
  Are you sure you want to delete this thread? You will not be able to recover it later.