コード例 #1
0
 private void SetRoles()
 {
     _activeSection.SectionPermissions.Clear();
     foreach (RepeaterItem ri in rptRoles.Items)
     {
         // HACK: RoleId is stored in the ViewState because the repeater doesn't have a DataKeys property.
         CheckBox chkView          = (CheckBox)ri.FindControl("chkViewAllowed");
         CheckBox chkEdit          = (CheckBox)ri.FindControl("chkEditAllowed");
         CheckBox chkInsertAllowed = (CheckBox)ri.FindControl("chkInsertAllowed");
         CheckBox chkModifyAllowed = (CheckBox)ri.FindControl("chkModifyAllowed");
         CheckBox chkDeleteAllowed = (CheckBox)ri.FindControl("chkDeleteAllowed");
         if (chkView.Checked || chkEdit.Checked)
         {
             SectionPermission sp = new SectionPermission();
             sp.Section       = _activeSection;
             sp.Role          = (Role)base.CoreRepository.GetObjectById(typeof(Role), (int)ViewState[ri.ClientID]);
             sp.ViewAllowed   = chkView.Checked;
             sp.EditAllowed   = chkEdit.Checked;
             sp.ModifyAllowed = chkModifyAllowed.Checked;
             sp.InsertAllowed = chkInsertAllowed.Checked;
             sp.DeleteAllowed = chkDeleteAllowed.Checked;
             _activeSection.SectionPermissions.Add(sp);
         }
     }
 }
コード例 #2
0
 private void PropagatePermissionsToSections(Node node)
 {
     foreach (Section section in node.Sections)
     {
         section.SectionPermissions.Clear();
         foreach (NodePermission np in node.NodePermissions)
         {
             SectionPermission sp = new SectionPermission();
             sp.Section     = section;
             sp.Role        = np.Role;
             sp.ViewAllowed = np.ViewAllowed;
             sp.EditAllowed = np.EditAllowed;
             section.SectionPermissions.Add(sp);
         }
     }
     UpdateObject(node);
 }