Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update tables\code so that were not using Guid indexes unless neccessary

  • Loading branch information...
commit bf7a6d7c73f8efef60270855418dd7f4e6bd9743 1 parent 736f1ec
@azturner azturner authored
Showing with 415 additions and 387 deletions.
  1. +27 −0 ConvertAuth.sql
  2. +17 −9 Rock.DataTransferObjects/Cms/Auth.cs
  3. +1 −1  Rock/Attribute/Helper.cs
  4. +26 −0 Rock/CMS/Auth.Partial.cs
  5. +55 −14 Rock/CMS/Auth.cs
  6. +0 −10 Rock/CMS/AuthService.cs
  7. +0 −10 Rock/CMS/BlockService.cs
  8. +0 −24 Rock/CMS/FileService.partial.cs
  9. +0 −10 Rock/CMS/PageRouteService.cs
  10. +0 −10 Rock/CMS/PageService.cs
  11. +0 −10 Rock/CMS/SiteDomainService.cs
  12. +0 −10 Rock/CMS/SiteService.cs
  13. +1 −1  Rock/CMS/User.Partial.cs
  14. +0 −10 Rock/CMS/UserService.cs
  15. +2 −2 Rock/CMS/UserService.partial.cs
  16. +0 −10 Rock/CRM/AddressService.cs
  17. +0 −10 Rock/CRM/PersonService.cs
  18. +3 −3 Rock/CRM/PersonService.partial.cs
  19. +35 −0 Rock/CRM/PersonTrail.Partial.cs
  20. +0 −20 Rock/CRM/PersonTrailService.cs
  21. +6 −6 Rock/CRM/PersonTrailService.partial.cs
  22. +1 −0  Rock/Core/Attribute.cs
  23. +3 −10 Rock/Core/AttributeService.Partial.cs
  24. +8 −5 Rock/Core/AttributeService.cs
  25. +0 −10 Rock/Core/AttributeValueService.cs
  26. +10 −0 Rock/Core/DefinedTypeService.cs
  27. +10 −0 Rock/Core/DefinedValueService.cs
  28. +0 −10 Rock/Core/FieldTypeService.cs
  29. +18 −0 Rock/Data/Model.cs
  30. +32 −0 Rock/Data/Service.cs
  31. +0 −10 Rock/Groups/GroupRoleService.cs
  32. +10 −10 Rock/Groups/GroupService.cs
  33. +0 −10 Rock/Groups/GroupTypeService.cs
  34. +0 −10 Rock/Groups/MemberService.cs
  35. +1 −1  Rock/Jobs/JobPulse.cs
  36. +1 −2  Rock/Rock.csproj
  37. +91 −62 Rock/Security/Authorization.cs
  38. +12 −23 Rock/Security/Role.cs
  39. +0 −30 Rock/SystemGuid/Attribute.cs
  40. +0 −10 Rock/Util/JobService.cs
  41. BIN  RockChMS_Test.bak
  42. +1 −1  RockWeb/App_Code/Image.ashx.cs
  43. +43 −12 RockWeb/Blocks/Administration/Security.ascx.cs
  44. +1 −1  RockWeb/ImageUploader.ashx
View
27 ConvertAuth.sql
@@ -0,0 +1,27 @@
+WITH CTE
+AS
+(
+ SELECT
+ Id,
+ CASE UserOrRoleName
+ WHEN '*AU' THEN 1
+ WHEN '*AAU' THEN 2
+ WHEN '*AUU' THEN 3
+ ELSE 0 END as SpecialRole,
+ CASE WHEN UserOrRoleName not like '*%' AND UserOrRole = 'U' THEN UserOrRoleName ELSE null END as PersonGuid,
+ CASE WHEN UserOrRoleName not like '*%' AND UserOrRole = 'R' THEN UserOrRoleName ELSE null END as GroupGuid
+ from cmsAuth
+)
+
+UPDATE A SET
+ SpecialRole = CTE.SpecialRole,
+ PersonId = P.Id,
+ GroupId = G.Id
+FROM CTE
+INNER JOIN cmsAuth A
+ ON A.Id = CTE.Id
+LEFT OUTER JOIN crmPerson P
+ ON P.Guid = CTE.PersonGuid
+LEFT OUTER JOIN GroupsGroup G
+ ON G.Guid = CTE.GroupGuid
+
View
26 Rock.DataTransferObjects/Cms/Auth.cs
@@ -61,6 +61,14 @@ public partial class Auth
public int Order { get; set; }
/// <summary>
+ /// Gets or sets the Action.
+ /// </summary>
+ /// <value>
+ /// Action.
+ /// </value>
+ public string Action { get; set; }
+
+ /// <summary>
/// Gets or sets the Allow Or Deny.
/// </summary>
/// <value>
@@ -69,28 +77,28 @@ public partial class Auth
public string AllowOrDeny { get; set; }
/// <summary>
- /// Gets or sets the User Or Role.
+ /// Gets or sets the Special Role.
/// </summary>
/// <value>
- /// U = User, R = Role.
+ /// Enum[SpecialRole].
/// </value>
- public string UserOrRole { get; set; }
+ public int SpecialRole { get; set; }
/// <summary>
- /// Gets or sets the Action.
+ /// Gets or sets the Person Id.
/// </summary>
/// <value>
- /// Action.
+ /// Person Id.
/// </value>
- public string Action { get; set; }
+ public int? PersonId { get; set; }
/// <summary>
- /// Gets or sets the User Or Role Name.
+ /// Gets or sets the Group Id.
/// </summary>
/// <value>
- /// User Or Role Name.
+ /// Group Id.
/// </value>
- public string UserOrRoleName { get; set; }
+ public int? GroupId { get; set; }
/// <summary>
/// Gets or sets the Created Date Time.
View
2  Rock/Attribute/Helper.cs
@@ -83,7 +83,7 @@ private static bool UpdateAttribute( Rock.Attribute.PropertyAttribute property,
Core.FieldTypeService fieldTypeService = new Core.FieldTypeService();
// Look for an existing attribute record based on the entity, entityQualifierColumn and entityQualifierValue
- Core.Attribute attribute = attributeService.GetAttributeByEntityQualifierAndKey(
+ Core.Attribute attribute = attributeService.GetByEntityAndEntityQualifierColumnAndEntityQualifierValueAndKey(
entity, entityQualifierColumn, entityQualifierValue, property.Key );
if ( attribute == null )
View
26 Rock/CMS/Auth.Partial.cs
@@ -18,4 +18,30 @@ public override bool DefaultAuthorization( string action )
return false;
}
}
+
+ /// <summary>
+ /// Authorization for a special group of users not defined by a specific role or person
+ /// </summary>
+ public enum SpecialRole
+ {
+ /// <summary>
+ /// No special role
+ /// </summary>
+ None = 0,
+
+ /// <summary>
+ /// Authorize all users
+ /// </summary>
+ AllUsers = 1,
+
+ /// <summary>
+ /// Authorize all authenticated users
+ /// </summary>
+ AllAuthenticatedUsers = 2,
+
+ /// <summary>
+ /// Authorize all un-authenticated users
+ /// </summary>
+ AllUnAuthenticatedUsers = 3,
+ }
}
View
69 Rock/CMS/Auth.cs
@@ -55,6 +55,16 @@ public partial class Auth : ModelWithAttributes<Auth>, IAuditable, IOrdered
public int Order { get; set; }
/// <summary>
+ /// Gets or sets the Action.
+ /// </summary>
+ /// <value>
+ /// Action.
+ /// </value>
+ [MaxLength( 50 )]
+ [DataMember]
+ public string Action { get; set; }
+
+ /// <summary>
/// Gets or sets the Allow Or Deny.
/// </summary>
/// <value>
@@ -64,33 +74,44 @@ public partial class Auth : ModelWithAttributes<Auth>, IAuditable, IOrdered
public string AllowOrDeny { get; set; }
/// <summary>
- /// Gets or sets the User Or Role.
+ /// Gets or sets the Special Role.
/// </summary>
/// <value>
- /// U = User, R = Role.
+ /// Enum[SpecialRole].
/// </value>
[DataMember]
- public string UserOrRole { get; set; }
+ internal int SpecialRoleInternal { get; set; }
+
+ /// <summary>
+ /// Gets or sets the Special Role.
+ /// </summary>
+ /// <value>
+ /// Enum[SpecialRole].
+ /// </value>
+ [NotMapped]
+ public SpecialRole SpecialRole
+ {
+ get { return (SpecialRole)this.SpecialRoleInternal; }
+ set { this.SpecialRoleInternal = (int)value; }
+ }
/// <summary>
- /// Gets or sets the Action.
+ /// Gets or sets the Person Id.
/// </summary>
/// <value>
- /// Action.
+ /// Person Id.
/// </value>
- [MaxLength( 50 )]
[DataMember]
- public string Action { get; set; }
+ public int? PersonId { get; set; }
/// <summary>
- /// Gets or sets the User Or Role Name.
+ /// Gets or sets the Group Id.
/// </summary>
/// <value>
- /// User Or Role Name.
+ /// Group Id.
/// </value>
- [MaxLength( 100 )]
[DataMember]
- public string UserOrRoleName { get; set; }
+ public int? GroupId { get; set; }
/// <summary>
/// Gets or sets the Created Date Time.
@@ -144,10 +165,11 @@ public Rock.CMS.DTO.Auth DataTransferObject
dto.EntityType = this.EntityType;
dto.EntityId = this.EntityId;
dto.Order = this.Order;
- dto.AllowOrDeny = this.AllowOrDeny;
- dto.UserOrRole = this.UserOrRole;
dto.Action = this.Action;
- dto.UserOrRoleName = this.UserOrRoleName;
+ dto.AllowOrDeny = this.AllowOrDeny;
+ dto.SpecialRole = this.SpecialRoleInternal;
+ dto.PersonId = this.PersonId;
+ dto.GroupId = this.GroupId;
dto.CreatedDateTime = this.CreatedDateTime;
dto.ModifiedDateTime = this.ModifiedDateTime;
dto.CreatedByPersonId = this.CreatedByPersonId;
@@ -177,6 +199,22 @@ public Rock.CMS.DTO.Auth DataTransferObject
/// A <see cref="CRM.Person"/> object.
/// </value>
public virtual CRM.Person ModifiedByPerson { get; set; }
+
+ /// <summary>
+ /// Gets or sets the Group.
+ /// </summary>
+ /// <value>
+ /// A <see cref="Groups.Group"/> object.
+ /// </value>
+ public virtual Groups.Group Group { get; set; }
+
+ /// <summary>
+ /// Gets or sets the Person.
+ /// </summary>
+ /// <value>
+ /// A <see cref="CRM.Person"/> object.
+ /// </value>
+ public virtual CRM.Person Person { get; set; }
}
/// <summary>
@@ -189,8 +227,11 @@ public partial class AuthConfiguration : EntityTypeConfiguration<Auth>
/// </summary>
public AuthConfiguration()
{
+ this.Property( p => p.SpecialRoleInternal ).HasColumnName( "SpecialRole" );
this.HasOptional( p => p.CreatedByPerson ).WithMany().HasForeignKey( p => p.CreatedByPersonId ).WillCascadeOnDelete(false);
this.HasOptional( p => p.ModifiedByPerson ).WithMany().HasForeignKey( p => p.ModifiedByPersonId ).WillCascadeOnDelete(false);
+ this.HasOptional( p => p.Group ).WithMany().HasForeignKey( p => p.GroupId ).WillCascadeOnDelete(true);
+ this.HasOptional( p => p.Person ).WithMany().HasForeignKey( p => p.PersonId ).WillCascadeOnDelete(true);
}
}
}
View
10 Rock/CMS/AuthService.cs
@@ -34,15 +34,5 @@ public IEnumerable<Rock.CMS.Auth> GetByEntityTypeAndEntityId( string entityType,
return Repository.Find( t => t.EntityType == entityType && ( t.EntityId == entityId || ( entityId == null && t.EntityId == null ) ) ).OrderBy( t => t.Order );
}
- /// <summary>
- /// Gets Auths by Guid
- /// </summary>
- /// <param name="guid">Guid.</param>
- /// <returns>An enumerable list of Auth objects.</returns>
- public IEnumerable<Rock.CMS.Auth> GetByGuid( Guid guid )
- {
- return Repository.Find( t => t.Guid == guid ).OrderBy( t => t.Order );
- }
-
}
}
View
10 Rock/CMS/BlockService.cs
@@ -24,16 +24,6 @@ namespace Rock.CMS
public partial class BlockService : Service<Rock.CMS.Block>
{
/// <summary>
- /// Gets Blocks by Guid
- /// </summary>
- /// <param name="guid">Guid.</param>
- /// <returns>An enumerable list of Block objects.</returns>
- public IEnumerable<Rock.CMS.Block> GetByGuid( Guid guid )
- {
- return Repository.Find( t => t.Guid == guid );
- }
-
- /// <summary>
/// Gets Blocks by Name
/// </summary>
/// <param name="name">Name.</param>
View
24 Rock/CMS/FileService.partial.cs
@@ -1,24 +0,0 @@
-//
-// THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION-NONCOMMERCIAL-
-// SHAREALIKE 3.0 UNPORTED LICENSE:
-// http://creativecommons.org/licenses/by-nc-sa/3.0/
-//
-
-using System;
-
-namespace Rock.CMS
-{
- public partial class FileService
- {
- /// <summary>
- /// Gets the file by GUID.
- /// </summary>
- /// <param name="guidString">The GUID string.</param>
- /// <returns></returns>
- public Rock.CMS.File GetByGuid( string guidString )
- {
- Guid guid = new Guid( guidString );
- return Repository.FirstOrDefault( f => f.Guid == guid );
- }
- }
-}
View
10 Rock/CMS/PageRouteService.cs
@@ -24,16 +24,6 @@ namespace Rock.CMS
public partial class PageRouteService : Service<Rock.CMS.PageRoute>
{
/// <summary>
- /// Gets Page Routes by Guid
- /// </summary>
- /// <param name="guid">Guid.</param>
- /// <returns>An enumerable list of PageRoute objects.</returns>
- public IEnumerable<Rock.CMS.PageRoute> GetByGuid( Guid guid )
- {
- return Repository.Find( t => t.Guid == guid );
- }
-
- /// <summary>
/// Gets Page Routes by Page Id
/// </summary>
/// <param name="pageId">Page Id.</param>
View
10 Rock/CMS/PageService.cs
@@ -24,16 +24,6 @@ namespace Rock.CMS
public partial class PageService : Service<Rock.CMS.Page>
{
/// <summary>
- /// Gets Pages by Guid
- /// </summary>
- /// <param name="guid">Guid.</param>
- /// <returns>An enumerable list of Page objects.</returns>
- public IEnumerable<Rock.CMS.Page> GetByGuid( Guid guid )
- {
- return Repository.Find( t => t.Guid == guid ).OrderBy( t => t.Order );
- }
-
- /// <summary>
/// Gets Pages by Parent Page Id
/// </summary>
/// <param name="parentPageId">Parent Page Id.</param>
View
10 Rock/CMS/SiteDomainService.cs
@@ -34,16 +34,6 @@ public Rock.CMS.SiteDomain GetByDomain( string domain )
}
/// <summary>
- /// Gets Site Domains by Guid
- /// </summary>
- /// <param name="guid">Guid.</param>
- /// <returns>An enumerable list of SiteDomain objects.</returns>
- public IEnumerable<Rock.CMS.SiteDomain> GetByGuid( Guid guid )
- {
- return Repository.Find( t => t.Guid == guid );
- }
-
- /// <summary>
/// Gets Site Domains by Site Id And Domain
/// </summary>
/// <param name="siteId">Site Id.</param>
View
10 Rock/CMS/SiteService.cs
@@ -23,15 +23,5 @@ namespace Rock.CMS
/// </summary>
public partial class SiteService : Service<Rock.CMS.Site>
{
- /// <summary>
- /// Gets Sites by Guid
- /// </summary>
- /// <param name="guid">Guid.</param>
- /// <returns>An enumerable list of Site objects.</returns>
- public IEnumerable<Rock.CMS.Site> GetByGuid( Guid guid )
- {
- return Repository.Find( t => t.Guid == guid );
- }
-
}
}
View
2  Rock/CMS/User.Partial.cs
@@ -32,7 +32,7 @@ public string ConfirmationCode
{
get
{
- string identifier = string.Format( "ROCK|{0}|{1}|{2}", this.Guid.ToString(), this.UserName, DateTime.Now.Ticks );
+ string identifier = string.Format( "ROCK|{0}|{1}|{2}", this.PublicKey.ToString(), this.UserName, DateTime.Now.Ticks );
string encryptionPhrase = ConfigurationManager.AppSettings["EncryptionPhrase"];
if ( String.IsNullOrWhiteSpace( encryptionPhrase ) )
encryptionPhrase = "Rock Rocks!";
View
10 Rock/CMS/UserService.cs
@@ -34,16 +34,6 @@ public IEnumerable<Rock.CMS.User> GetByApiKey( string apiKey )
}
/// <summary>
- /// Gets User by Guid
- /// </summary>
- /// <param name="guid">Guid.</param>
- /// <returns>User object.</returns>
- public Rock.CMS.User GetByGuid( Guid guid )
- {
- return Repository.FirstOrDefault( t => t.Guid == guid );
- }
-
- /// <summary>
/// Gets Users by Person Id
/// </summary>
/// <param name="personId">Person Id.</param>
View
4 Rock/CMS/UserService.partial.cs
@@ -175,7 +175,7 @@ public Rock.CMS.User GetByConfirmationCode( string code )
string[] idParts = identifier.Split( '|' );
if ( idParts.Length == 4 )
{
- string guid = idParts[1];
+ string publicKey = idParts[1];
string username = idParts[2];
long ticks = 0;
if (!long.TryParse(idParts[3], out ticks))
@@ -186,7 +186,7 @@ public Rock.CMS.User GetByConfirmationCode( string code )
if (DateTime.Now.Subtract(dateTime).Hours > 1)
return null;
- User user = this.GetByGuid( new Guid( guid ) );
+ User user = this.GetByPublicKey ( publicKey );
if ( user.UserName == username )
return user;
}
View
10 Rock/CRM/AddressService.cs
@@ -38,16 +38,6 @@ public Rock.CRM.Address GetByStreet1AndStreet2AndCityAndStateAndZip( string stre
}
/// <summary>
- /// Gets Address by Guid
- /// </summary>
- /// <param name="guid">Guid.</param>
- /// <returns>Address object.</returns>
- public Rock.CRM.Address GetByGuid( Guid guid )
- {
- return Repository.FirstOrDefault( t => t.Guid == guid );
- }
-
- /// <summary>
/// Gets Address by Raw
/// </summary>
/// <param name="raw">Raw.</param>
View
10 Rock/CRM/PersonService.cs
@@ -24,16 +24,6 @@ namespace Rock.CRM
public partial class PersonService : Service<Rock.CRM.Person>
{
/// <summary>
- /// Gets Person by Guid
- /// </summary>
- /// <param name="guid">Guid.</param>
- /// <returns>Person object.</returns>
- public Rock.CRM.Person GetByGuid( Guid guid )
- {
- return Repository.FirstOrDefault( t => t.Guid == guid );
- }
-
- /// <summary>
/// Gets People by Email
/// </summary>
/// <param name="email">Email.</param>
View
6 Rock/CRM/PersonService.partial.cs
@@ -96,12 +96,12 @@ public Rock.CRM.Person Get( int id, bool followTrail )
/// <returns>
/// Person object.
/// </returns>
- public Rock.CRM.Person GetByGuid( Guid guid, bool followTrail )
+ public Rock.CRM.Person GetByPublicKey( string publicKey, bool followTrail )
{
if ( followTrail )
- guid = new PersonTrailService().Current( guid );
+ publicKey = new PersonTrailService().Current( publicKey );
- return GetByGuid( guid );
+ return GetByPublicKey( publicKey );
}
}
}
View
35 Rock/CRM/PersonTrail.Partial.cs
@@ -0,0 +1,35 @@
+//
+// THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION-NONCOMMERCIAL-
+// SHAREALIKE 3.0 UNPORTED LICENSE:
+// http://creativecommons.org/licenses/by-nc-sa/3.0/
+//
+
+using System;
+using System.Configuration;
+using System.ComponentModel.DataAnnotations;
+
+using Rock.Data;
+
+namespace Rock.CRM
+{
+ public partial class PersonTrail
+ {
+ /// <summary>
+ /// Gets a publicly viewable unique key for the model.
+ /// </summary>
+ [NotMapped]
+ public string CurrentPublicKey
+ {
+ get
+ {
+ string encryptionPhrase = ConfigurationManager.AppSettings["EncryptionPhrase"];
+ if ( String.IsNullOrWhiteSpace( encryptionPhrase ) )
+ encryptionPhrase = "Rock Rocks!";
+
+ string identifier = this.CurrentId.ToString() + ">" + this.CurrentGuid.ToString();
+ return Rock.Security.Encryption.EncryptString( identifier, encryptionPhrase );
+ }
+ }
+
+ }
+}
View
20 Rock/CRM/PersonTrailService.cs
@@ -24,16 +24,6 @@ namespace Rock.CRM
public partial class PersonTrailService : Service<Rock.CRM.PersonTrail>
{
/// <summary>
- /// Gets Person Trails by Current Guid
- /// </summary>
- /// <param name="currentGuid">Current Guid.</param>
- /// <returns>An enumerable list of PersonTrail objects.</returns>
- public IEnumerable<Rock.CRM.PersonTrail> GetByCurrentGuid( Guid currentGuid )
- {
- return Repository.Find( t => t.CurrentGuid == currentGuid );
- }
-
- /// <summary>
/// Gets Person Trails by Current Id
/// </summary>
/// <param name="currentId">Current Id.</param>
@@ -43,15 +33,5 @@ public IEnumerable<Rock.CRM.PersonTrail> GetByCurrentId( int currentId )
return Repository.Find( t => t.CurrentId == currentId );
}
- /// <summary>
- /// Gets Person Trail by Guid
- /// </summary>
- /// <param name="guid">Guid.</param>
- /// <returns>PersonTrail object.</returns>
- public Rock.CRM.PersonTrail GetByGuid( Guid guid )
- {
- return Repository.FirstOrDefault( t => t.Guid == guid );
- }
-
}
}
View
12 Rock/CRM/PersonTrailService.partial.cs
@@ -17,15 +17,15 @@ public partial class PersonTrailService
/// </summary>
/// <param name="guid">The GUID.</param>
/// <returns></returns>
- public Guid Current( Guid guid )
+ public string Current( string publicKey )
{
- PersonTrail personTrail = GetByGuid( guid );
+ PersonTrail personTrail = GetByPublicKey ( publicKey );
while ( personTrail != null )
{
- guid = personTrail.Guid;
- personTrail = GetByGuid( guid );
+ publicKey = personTrail.CurrentPublicKey;
+ personTrail = GetByPublicKey( publicKey );
}
- return guid;
+ return publicKey;
}
/// <summary>
@@ -38,7 +38,7 @@ public int Current( int id )
PersonTrail personTrail = Get( id );
while ( personTrail != null )
{
- id = personTrail.Id;
+ id = personTrail.CurrentId;
personTrail = Get( id );
}
return id;
View
1  Rock/Core/Attribute.cs
@@ -70,6 +70,7 @@ public partial class Attribute : Model<Attribute>, IAuditable, IOrdered
/// <value>
/// Entity Qualifier Value.
/// </value>
+ [MaxLength( 200 )]
[DataMember]
public string EntityQualifierValue { get; set; }
View
13 Rock/Core/AttributeService.Partial.cs
@@ -26,20 +26,13 @@ public IQueryable<Rock.Core.Attribute> GetAttributesByEntityQualifier( string en
}
/// <summary>
- /// Gets the attributes by entity qualifier and key.
+ /// Gets a global attribute.
/// </summary>
- /// <param name="entity">The entity.</param>
- /// <param name="entityQualifierColumn">The entity qualifier column.</param>
- /// <param name="entityQualifierValue">The entity qualifier value.</param>
/// <param name="key">The key.</param>
/// <returns></returns>
- public Rock.Core.Attribute GetAttributeByEntityQualifierAndKey( string entity, string entityQualifierColumn, string entityQualifierValue, string key )
+ public Rock.Core.Attribute GetGlobalAttribute( string key )
{
- return Repository.FirstOrDefault( t =>
- t.Entity == entity &&
- t.EntityQualifierColumn == entityQualifierColumn &&
- t.EntityQualifierValue == entityQualifierValue &&
- t.Key == key );
+ return this.GetByEntityAndEntityQualifierColumnAndEntityQualifierValueAndKey( string.Empty, string.Empty, string.Empty, key );
}
}
}
View
13 Rock/Core/AttributeService.cs
@@ -30,17 +30,20 @@ public partial class AttributeService : Service<Rock.Core.Attribute>
/// <returns>An enumerable list of Attribute objects.</returns>
public IEnumerable<Rock.Core.Attribute> GetByEntity( string entity )
{
- return Repository.Find( t => t.Entity == entity ).OrderBy( t => t.Order );
+ return Repository.Find( t => ( t.Entity == entity || ( entity == null && t.Entity == null ) ) ).OrderBy( t => t.Order );
}
/// <summary>
- /// Gets Attribute by Guid
+ /// Gets Attribute by Entity And Entity Qualifier Column And Entity Qualifier Value And Key
/// </summary>
- /// <param name="guid">Guid.</param>
+ /// <param name="entity">Entity.</param>
+ /// <param name="entityQualifierColumn">Entity Qualifier Column.</param>
+ /// <param name="entityQualifierValue">Entity Qualifier Value.</param>
+ /// <param name="key">Key.</param>
/// <returns>Attribute object.</returns>
- public Rock.Core.Attribute GetByGuid( Guid guid )
+ public Rock.Core.Attribute GetByEntityAndEntityQualifierColumnAndEntityQualifierValueAndKey( string entity, string entityQualifierColumn, string entityQualifierValue, string key )
{
- return Repository.FirstOrDefault( t => t.Guid == guid );
+ return Repository.FirstOrDefault( t => ( t.Entity == entity || ( entity == null && t.Entity == null ) ) && ( t.EntityQualifierColumn == entityQualifierColumn || ( entityQualifierColumn == null && t.EntityQualifierColumn == null ) ) && ( t.EntityQualifierValue == entityQualifierValue || ( entityQualifierValue == null && t.EntityQualifierValue == null ) ) && t.Key == key );
}
}
View
10 Rock/Core/AttributeValueService.cs
@@ -44,15 +44,5 @@ public IEnumerable<Rock.Core.AttributeValue> GetByEntityId( int? entityId )
return Repository.Find( t => ( t.EntityId == entityId || ( entityId == null && t.EntityId == null ) ) );
}
- /// <summary>
- /// Gets Attribute Values by Guid
- /// </summary>
- /// <param name="guid">Guid.</param>
- /// <returns>An enumerable list of AttributeValue objects.</returns>
- public IEnumerable<Rock.Core.AttributeValue> GetByGuid( Guid guid )
- {
- return Repository.Find( t => t.Guid == guid );
- }
-
}
}
View
10 Rock/Core/DefinedTypeService.cs
@@ -23,5 +23,15 @@ namespace Rock.Core
/// </summary>
public partial class DefinedTypeService : Service<Rock.Core.DefinedType>
{
+ /// <summary>
+ /// Gets Defined Type by Guid
+ /// </summary>
+ /// <param name="guid">Guid.</param>
+ /// <returns>DefinedType object.</returns>
+ public Rock.Core.DefinedType GetByGuid( Guid guid )
+ {
+ return Repository.FirstOrDefault( t => t.Guid == guid );
+ }
+
}
}
View
10 Rock/Core/DefinedValueService.cs
@@ -33,5 +33,15 @@ public IEnumerable<Rock.Core.DefinedValue> GetByDefinedTypeId( int definedTypeId
return Repository.Find( t => t.DefinedTypeId == definedTypeId ).OrderBy( t => t.Order );
}
+ /// <summary>
+ /// Gets Defined Value by Guid
+ /// </summary>
+ /// <param name="guid">Guid.</param>
+ /// <returns>DefinedValue object.</returns>
+ public Rock.Core.DefinedValue GetByGuid( Guid guid )
+ {
+ return Repository.FirstOrDefault( t => t.Guid == guid );
+ }
+
}
}
View
10 Rock/Core/FieldTypeService.cs
@@ -24,16 +24,6 @@ namespace Rock.Core
public partial class FieldTypeService : Service<Rock.Core.FieldType>
{
/// <summary>
- /// Gets Field Types by Guid
- /// </summary>
- /// <param name="guid">Guid.</param>
- /// <returns>An enumerable list of FieldType objects.</returns>
- public IEnumerable<Rock.Core.FieldType> GetByGuid( Guid guid )
- {
- return Repository.Find( t => t.Guid == guid );
- }
-
- /// <summary>
/// Gets Field Types by Name
/// </summary>
/// <param name="name">Name.</param>
View
18 Rock/Data/Model.cs
@@ -7,6 +7,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
+using System.Configuration;
using System.Data.Services;
using System.Data.Services.Common;
using System.Runtime.Serialization;
@@ -41,6 +42,23 @@ public abstract class Model<T> : IModel
public Guid Guid { get; set; }
/// <summary>
+ /// Gets a publicly viewable unique key for the model.
+ /// </summary>
+ [NotMapped]
+ public string PublicKey
+ {
+ get
+ {
+ string encryptionPhrase = ConfigurationManager.AppSettings["EncryptionPhrase"];
+ if ( String.IsNullOrWhiteSpace( encryptionPhrase ) )
+ encryptionPhrase = "Rock Rocks!";
+
+ string identifier = this.Id.ToString() + ">" + this.Guid.ToString();
+ return Rock.Security.Encryption.EncryptString( identifier, encryptionPhrase );
+ }
+ }
+
+ /// <summary>
/// Gets the validation results.
/// </summary>
[NotMapped]
View
32 Rock/Data/Service.cs
@@ -6,6 +6,7 @@
using System;
using System.Collections.Generic;
+using System.Configuration;
using System.Linq;
namespace Rock.Data
@@ -60,6 +61,37 @@ public T Get( int id )
return _repository.FirstOrDefault( t => t.Id == id );
}
+ public T GetByPublicKey( string publicKey )
+ {
+ try
+ {
+ string encryptionPhrase = ConfigurationManager.AppSettings["EncryptionPhrase"];
+ if ( String.IsNullOrWhiteSpace( encryptionPhrase ) )
+ encryptionPhrase = "Rock Rocks!";
+
+ string identifier = Rock.Security.Encryption.DecryptString( publicKey, encryptionPhrase );
+
+ string[] idParts = identifier.Split( '>' );
+ if ( idParts.Length == 2 )
+ {
+ int id = Int32.Parse( idParts[0] );
+ Guid guid = new Guid( idParts[1] );
+
+ T model = Get( id );
+
+ if ( model != null && model.Guid.CompareTo(guid) == 0 )
+ return model;
+ }
+
+ return null;
+ }
+ catch
+ {
+ return null;
+ }
+
+ }
+
/// <summary>
/// Adds the specified item.
/// </summary>
View
10 Rock/Groups/GroupRoleService.cs
@@ -24,16 +24,6 @@ namespace Rock.Groups
public partial class GroupRoleService : Service<Rock.Groups.GroupRole>
{
/// <summary>
- /// Gets Group Roles by Guid
- /// </summary>
- /// <param name="guid">Guid.</param>
- /// <returns>An enumerable list of GroupRole objects.</returns>
- public IEnumerable<Rock.Groups.GroupRole> GetByGuid( Guid guid )
- {
- return Repository.Find( t => t.Guid == guid );
- }
-
- /// <summary>
/// Gets Group Roles by Order
/// </summary>
/// <param name="order">Order.</param>
View
20 Rock/Groups/GroupService.cs
@@ -24,16 +24,6 @@ namespace Rock.Groups
public partial class GroupService : Service<Rock.Groups.Group>
{
/// <summary>
- /// Gets Groups by Group Type Id
- /// </summary>
- /// <param name="groupTypeId">Group Type Id.</param>
- /// <returns>An enumerable list of Group objects.</returns>
- public IEnumerable<Rock.Groups.Group> GetByGroupTypeId( int groupTypeId )
- {
- return Repository.Find( t => t.GroupTypeId == groupTypeId );
- }
-
- /// <summary>
/// Gets Group by Guid
/// </summary>
/// <param name="guid">Guid.</param>
@@ -44,6 +34,16 @@ public Rock.Groups.Group GetByGuid( Guid guid )
}
/// <summary>
+ /// Gets Groups by Group Type Id
+ /// </summary>
+ /// <param name="groupTypeId">Group Type Id.</param>
+ /// <returns>An enumerable list of Group objects.</returns>
+ public IEnumerable<Rock.Groups.Group> GetByGroupTypeId( int groupTypeId )
+ {
+ return Repository.Find( t => t.GroupTypeId == groupTypeId );
+ }
+
+ /// <summary>
/// Gets Groups by Is Security Role
/// </summary>
/// <param name="isSecurityRole">Is Security Role.</param>
View
10 Rock/Groups/GroupTypeService.cs
@@ -23,15 +23,5 @@ namespace Rock.Groups
/// </summary>
public partial class GroupTypeService : Service<Rock.Groups.GroupType>
{
- /// <summary>
- /// Gets Group Types by Guid
- /// </summary>
- /// <param name="guid">Guid.</param>
- /// <returns>An enumerable list of GroupType objects.</returns>
- public IEnumerable<Rock.Groups.GroupType> GetByGuid( Guid guid )
- {
- return Repository.Find( t => t.Guid == guid );
- }
-
}
}
View
10 Rock/Groups/MemberService.cs
@@ -46,16 +46,6 @@ public Rock.Groups.Member GetByGroupIdAndPersonIdAndGroupRoleId( int groupId, in
}
/// <summary>
- /// Gets Members by Guid
- /// </summary>
- /// <param name="guid">Guid.</param>
- /// <returns>An enumerable list of Member objects.</returns>
- public IEnumerable<Rock.Groups.Member> GetByGuid( Guid guid )
- {
- return Repository.Find( t => t.Guid == guid );
- }
-
- /// <summary>
/// Gets Members by Person Id
/// </summary>
/// <param name="personId">Person Id.</param>
View
2  Rock/Jobs/JobPulse.cs
@@ -61,7 +61,7 @@ public virtual void Execute(IJobExecutionContext context)
AttributeService attribService = new AttributeService();
AttributeValueService attributeValueService = new AttributeValueService();
- Rock.Core.Attribute jobPulseAttrib = attribService.GetByGuid( SystemGuid.Attribute.JOB_PULSE );
+ Rock.Core.Attribute jobPulseAttrib = attribService.GetGlobalAttribute( "JobPulse" );
Rock.Core.AttributeValue jobPulseAttribValue = jobPulseAttrib.AttributeValues.FirstOrDefault();
// create attribute value if one does not exist
View
3  Rock/Rock.csproj
@@ -78,6 +78,7 @@
<Compile Include="Core\ExceptionLog.cs" />
<Compile Include="Core\ExceptionLogService.cs" />
<Compile Include="Core\IExceptionLogRepository.cs" />
+ <Compile Include="CRM\PersonTrail.Partial.cs" />
<Compile Include="CRM\EntityPersonViewedRepository.cs" />
<Compile Include="CRM\IPersonViewedRepository.cs" />
<Compile Include="CRM\PersonTrailService.partial.cs" />
@@ -286,7 +287,6 @@
<Compile Include="Web\RockRouteHandler.cs" />
<Compile Include="Security\Authorization.cs" />
<Compile Include="Security\ISecured.cs" />
- <Compile Include="SystemGuid\Attribute.cs" />
<Compile Include="Web\UI\Controls\Data Fields\DataDropDownList.cs">
<SubType>Code</SubType>
</Compile>
@@ -452,7 +452,6 @@
<Compile Include="CMS\BlogService.Partial.cs" />
<Compile Include="CMS\AuthService.partial.cs" />
<Compile Include="CMS\BlockInstanceService.partial.cs" />
- <Compile Include="CMS\FileService.partial.cs" />
<Compile Include="CMS\HtmlContentService.Partial.cs" />
<Compile Include="CMS\ThemeService.partial.cs">
<SubType>Code</SubType>
View
153 Rock/Security/Authorization.cs
@@ -52,8 +52,9 @@ public static void Load()
actionPermissions.Add( new AuthRule(
auth.Id,
auth.AllowOrDeny,
- auth.UserOrRole,
- auth.UserOrRoleName,
+ auth.SpecialRole,
+ auth.PersonId,
+ auth.GroupId,
auth.Order) );
}
}
@@ -96,9 +97,10 @@ public static void ReloadAction( string entityType, int entityId, string action
actionPermissions.Add( new AuthRule(
auth.Id,
auth.AllowOrDeny,
- auth.UserOrRole,
- auth.UserOrRoleName,
- auth.Order) );
+ auth.SpecialRole,
+ auth.PersonId,
+ auth.GroupId,
+ auth.Order ) );
}
}
}
@@ -121,19 +123,19 @@ public static void Flush()
/// <returns></returns>
public static bool Authorized( ISecured entity, string action, Rock.CMS.User user )
{
- return Authorized( entity, action, user != null ? user.Person.Guid.ToString() : string.Empty );
- }
-
- /// <summary>
- /// Evaluates whether a selected user is allowed to perform the selected action on the selected
- /// entity.
- /// </summary>
- /// <param name="entity">The entity.</param>
- /// <param name="action">The action.</param>
- /// <param name="userName">Name of the user.</param>
- /// <returns></returns>
- private static bool Authorized( ISecured entity, string action, string userName )
- {
+ // return Authorized( entity, action, user != null ? user.Person.Guid.ToString() : string.Empty );
+ //}
+
+ ///// <summary>
+ ///// Evaluates whether a selected user is allowed to perform the selected action on the selected
+ ///// entity.
+ ///// </summary>
+ ///// <param name="entity">The entity.</param>
+ ///// <param name="action">The action.</param>
+ ///// <param name="userName">Name of the user.</param>
+ ///// <returns></returns>
+ //private static bool Authorized( ISecured entity, string action, string userName )
+ //{
// If there's no Authorizations object, create it
if ( Authorizations == null )
Load();
@@ -145,28 +147,35 @@ private static bool Authorized( ISecured entity, string action, string userName
Authorizations[entity.AuthEntity].Keys.Contains( entity.Id ) &&
Authorizations[entity.AuthEntity][entity.Id].Keys.Contains( action ) )
{
+
+ string userName = user != null ? user.Person.Guid.ToString() : string.Empty;
+
foreach ( AuthRule authRule in Authorizations[entity.AuthEntity][entity.Id][action] )
{
// All Users
- if ( authRule.UserOrRoleName == "*AU" )
+ if ( authRule.SpecialRole == SpecialRole.AllUsers )
return authRule.AllowOrDeny == "A";
// All Authenticated Users
- if (authRule.UserOrRoleName == "*AAU" && userName.Trim() != string.Empty)
+ if (authRule.SpecialRole == SpecialRole.AllAuthenticatedUsers && userName.Trim() != string.Empty)
return authRule.AllowOrDeny == "A";
// All Unauthenticated Users
- if ( authRule.UserOrRoleName == "*AUU" && userName.Trim() == string.Empty )
+ if ( authRule.SpecialRole == SpecialRole.AllUnAuthenticatedUsers && userName.Trim() == string.Empty )
return authRule.AllowOrDeny == "A";
- if ( !authRule.UserOrRoleName.StartsWith("*") && userName != string.Empty )
+ if ( authRule.SpecialRole == SpecialRole.None && userName != string.Empty )
{
- if ( authRule.UserOrRole == "U" && userName == authRule.UserOrRoleName )
+ // See if person has been authorized to entity
+ if ( authRule.PersonId.HasValue &&
+ user.PersonId.HasValue &&
+ authRule.PersonId.Value == user.PersonId.Value )
return authRule.AllowOrDeny == "A";
- if ( authRule.UserOrRole == "R" )
+ // See if person is in role authorized
+ if (authRule.GroupId.HasValue)
{
- Role role = Role.Read( authRule.UserOrRoleName );
+ Role role = Role.Read( authRule.GroupId.Value );
if ( role != null && role.UserInRole( userName ) )
return authRule.AllowOrDeny == "A";
}
@@ -178,7 +187,7 @@ private static bool Authorized( ISecured entity, string action, string userName
// has a parent authority defined and if so evaluate that entities authorization rules. If there is no
// parent authority return the defualt authorization
if ( entity.ParentAuthority != null )
- return Authorized( entity.ParentAuthority, action, userName );
+ return Authorized( entity.ParentAuthority, action, user );
else
return entity.DefaultAuthorization( action );
@@ -277,13 +286,14 @@ public static void CopyAuthorization( ISecured sourceEntity, ISecured targetEnti
auth.Order = order;
auth.Action = action.Key;
auth.AllowOrDeny = rule.AllowOrDeny;
- auth.UserOrRole = rule.UserOrRole;
- auth.UserOrRoleName = rule.UserOrRoleName;
+ auth.SpecialRole = rule.SpecialRole;
+ auth.PersonId = rule.PersonId;
+ auth.GroupId = rule.GroupId;
authService.Add( auth, personId );
authService.Save( auth, personId );
- newActions[action.Key].Add( new AuthRule( rule.Id, rule.AllowOrDeny, rule.UserOrRole, rule.UserOrRoleName, rule.Order ) );
+ newActions[action.Key].Add( new AuthRule( rule.Id, rule.AllowOrDeny, rule.SpecialRole, rule.PersonId, rule.GroupId, rule.Order ) );
order++;
}
@@ -324,20 +334,28 @@ public class AuthRule
public string AllowOrDeny { get; set; }
/// <summary>
- /// Gets or sets a value indicating if this is for a User or a Role. Acceptable values are "U" or "R"
+ /// Gets or sets the special role.
/// </summary>
/// <value>
- /// The user or role.
+ /// The special role.
/// </value>
- public string UserOrRole { get; set; }
+ public SpecialRole SpecialRole { get; set; }
/// <summary>
- /// Gets or sets the name of the user or role.
+ /// Gets or sets the person id.
/// </summary>
/// <value>
- /// The name of the user or role.
+ /// The person id.
/// </value>
- public string UserOrRoleName { get; set; }
+ public int? PersonId { get; set; }
+
+ /// <summary>
+ /// Gets or sets the group id.
+ /// </summary>
+ /// <value>
+ /// The group id.
+ /// </value>
+ public int? GroupId { get; set; }
/// <summary>
/// Gets or sets the order.
@@ -355,33 +373,43 @@ public string DisplayName
get
{
// All Users
- if ( UserOrRoleName == "*AU" )
- return "All Users";
+ switch (SpecialRole)
+ {
+ case CMS.SpecialRole.AllUsers:
+ return "All Users";
- // All Authenticated Users
- if ( UserOrRoleName == "*AAU" )
- return "All Authenticated Users";
+ case CMS.SpecialRole.AllAuthenticatedUsers:
+ return "All Authenticated Users";
- // All Unauthenticated Users
- if ( UserOrRoleName == "*AUU" )
- return "All Un-Authenticated Users";
+ case CMS.SpecialRole.AllUnAuthenticatedUsers:
+ return "All Un-Authenticated Users";
- if ( UserOrRole == "U" )
- {
- try
- {
- Rock.CRM.PersonService personService = new CRM.PersonService();
- Rock.CRM.Person person = personService.GetByGuid( new Guid( UserOrRoleName ) );
- return person.FullName + " (User)";
- }
- catch
- {
- return "*** Unknown User ***";
- }
- }
- else
- {
- return Role.Read( UserOrRoleName ).Name + " (Role)";
+ default:
+
+ if (PersonId.HasValue)
+ {
+ try
+ {
+ Rock.CRM.PersonService personService = new CRM.PersonService();
+ Rock.CRM.Person person = personService.Get( PersonId.Value );
+ if (person != null)
+ return person.FullName + " (User)";
+ }
+ catch {}
+ }
+
+ if (GroupId.HasValue)
+ {
+ try
+ {
+ var role = Role.Read(GroupId.Value);
+ if (role != null)
+ return role.Name + " (Role)";
+ }
+ catch {}
+ }
+
+ return "*** Unknown User/Role ***";
}
}
}
@@ -394,12 +422,13 @@ public string DisplayName
/// <param name="userOrRole">User or Role ("U" or "R").</param>
/// <param name="userOrRoleName">Name of the user or role.</param>
/// <param name="order">The order.</param>
- public AuthRule( int id, string allowOrDeny, string userOrRole, string userOrRoleName, int order )
+ public AuthRule( int id, string allowOrDeny, SpecialRole specialRole, int? personId, int? groupId, int order )
{
Id = id;
AllowOrDeny = allowOrDeny;
- UserOrRole = userOrRole;
- UserOrRoleName = userOrRoleName;
+ SpecialRole = specialRole;
+ PersonId = personId;
+ GroupId = groupId;
Order = order;
}
}
View
35 Rock/Security/Role.cs
@@ -28,11 +28,6 @@ public class Role
public int Id { get; private set; }
/// <summary>
- /// Gets the GUID.
- /// </summary>
- public Guid Guid { get; private set; }
-
- /// <summary>
/// Gets the name.
/// </summary>
public string Name { get; private set; }
@@ -54,9 +49,9 @@ public bool UserInRole( string user )
#region Static Methods
- private static string CacheKey( Guid guid )
+ private static string CacheKey( int id )
{
- return string.Format( "Rock:Role:{0}", guid );
+ return string.Format( "Rock:Role:{0}", id );
}
/// <summary>
@@ -65,13 +60,9 @@ private static string CacheKey( Guid guid )
/// </summary>
/// <param name="roleGuid"></param>
/// <returns></returns>
- public static Role Read( string roleGuid )
+ public static Role Read( int id )
{
- Guid guid;
- if ( !Guid.TryParse( roleGuid, out guid ) )
- throw new ArgumentOutOfRangeException( "roleGuid", "Not a valid Guid" );
-
- string cacheKey = Role.CacheKey( guid );
+ string cacheKey = Role.CacheKey( id );
ObjectCache cache = MemoryCache.Default;
Role role = cache[cacheKey] as Role;
@@ -81,14 +72,12 @@ public static Role Read( string roleGuid )
else
{
Rock.Groups.GroupService groupService = new Rock.Groups.GroupService();
- Rock.Groups.Group groupModel = groupService.
- Queryable().
- Where( g => g.Guid == guid && g.IsSecurityRole == true).FirstOrDefault();
- if ( groupModel != null )
+ Rock.Groups.Group groupModel = groupService.Get( id );
+
+ if ( groupModel != null && groupModel.IsSecurityRole == true )
{
role = new Role();
role.Id = groupModel.Id;
- role.Guid = groupModel.Guid;
role.Name = groupModel.Name;
role.Users = new List<string>();
@@ -114,10 +103,10 @@ public static List<Role> AllRoles()
List<Role> roles = new List<Role>();
Rock.Groups.GroupService groupService = new Rock.Groups.GroupService();
- foreach(Guid guid in groupService.
- Queryable().Where( g => g.IsSecurityRole == true).Select( g => g.Guid).ToList())
+ foreach(int id in groupService.
+ Queryable().Where( g => g.IsSecurityRole == true).Select( g => g.Id).ToList())
{
- roles.Add( Role.Read( guid.ToString() ) );
+ roles.Add( Role.Read( id ) );
}
return roles;
@@ -127,10 +116,10 @@ public static List<Role> AllRoles()
/// Removes role from cache
/// </summary>
/// <param name="guid"></param>
- public static void Flush( Guid guid )
+ public static void Flush( int id )
{
ObjectCache cache = MemoryCache.Default;
- cache.Remove( Role.CacheKey( guid ) );
+ cache.Remove( Role.CacheKey( id ) );
}
#endregion
View
30 Rock/SystemGuid/Attribute.cs
@@ -1,30 +0,0 @@
-//
-// THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION-NONCOMMERCIAL-
-// SHAREALIKE 3.0 UNPORTED LICENSE:
-// http://creativecommons.org/licenses/by-nc-sa/3.0/
-//
-
-using System;
-
-namespace Rock.SystemGuid
-{
- /// <summary>
- /// Static Guids used by the Rock ChMS application
- /// </summary>
- public static class Attribute
- {
- /* NAMING CONVENTION
- *
- * Type Prefix
- * -------- -------------------
- * Job JOB_
- * Page PAGE_
- *
- */
-
- /// <summary>
- /// Job Pulse Attribute Guid
- /// </summary>
- public static Guid JOB_PULSE { get { return new Guid( "254F45EE-071C-4337-A522-DFDC20B7966A" ); } }
- }
-}
View
10 Rock/Util/JobService.cs
@@ -23,15 +23,5 @@ namespace Rock.Util
/// </summary>
public partial class JobService : Service<Rock.Util.Job>
{
- /// <summary>
- /// Gets Jobs by Guid
- /// </summary>
- /// <param name="guid">Guid of the job..</param>
- /// <returns>An enumerable list of Job objects.</returns>
- public IEnumerable<Rock.Util.Job> GetByGuid( Guid guid )
- {
- return Repository.Find( t => t.Guid == guid );
- }
-
}
}
View
BIN  RockChMS_Test.bak
Binary file not shown
View
2  RockWeb/App_Code/Image.ashx.cs
@@ -39,7 +39,7 @@ public void ProcessRequest( HttpContext context )
try
{
// Fetch the file...
- Rock.CMS.File file = ( int.TryParse( anID, out id ) ) ? fileService.Get( id ) : fileService.GetByGuid( anID );
+ Rock.CMS.File file = ( int.TryParse( anID, out id ) ) ? fileService.Get( id ) : fileService.GetByPublicKey( anID );
// is it cached?
string cacheName = Uri.EscapeDataString( context.Request.Url.Query );
View
55 RockWeb/Blocks/Administration/Security.ascx.cs
@@ -224,10 +224,24 @@ protected void lbAddRole_Click( object sender, EventArgs e )
bool actionUpdated = false;
bool alreadyExists = false;
+ Rock.CMS.SpecialRole specialRole = Rock.CMS.SpecialRole.None;
+ int? groupId = Int32.Parse(ddlRoles.SelectedValue);
+
+ switch(groupId)
+ {
+ case -1: specialRole = Rock.CMS.SpecialRole.AllUsers; break;
+ case -2: specialRole = Rock.CMS.SpecialRole.AllAuthenticatedUsers; break;
+ case -3: specialRole = Rock.CMS.SpecialRole.AllUnAuthenticatedUsers; break;
+ default: specialRole = Rock.CMS.SpecialRole.None; break;
+ }
+
+ if (groupId < 0)
+ groupId = null;
+
foreach ( Rock.Security.AuthRule rule in
Rock.Security.Authorization.AuthRules( iSecured.AuthEntity, iSecured.Id, li.Text ) )
{
- if ( rule.UserOrRole == "R" && rule.UserOrRoleName == ddlRoles.SelectedValue )
+ if ( rule.SpecialRole == specialRole && rule.GroupId == groupId )
{
alreadyExists = true;
break;
@@ -241,8 +255,8 @@ protected void lbAddRole_Click( object sender, EventArgs e )
auth.EntityId = iSecured.Id;
auth.Action = li.Text;
auth.AllowOrDeny = "A";
- auth.UserOrRole = "R";
- auth.UserOrRoleName = ddlRoles.SelectedValue;
+ auth.SpecialRole = specialRole;
+ auth.GroupId = groupId;
auth.Order = ++maxOrder;
authService.Add( auth, CurrentPersonId );
authService.Save( auth, CurrentPersonId );
@@ -264,7 +278,7 @@ protected void lbAddRole_Click( object sender, EventArgs e )
protected void lbUserSearch_Click( object sender, EventArgs e )
{
cbUsers.DataTextField = "FullName";
- cbUsers.DataValueField = "Guid";
+ cbUsers.DataValueField = "Id";
cbUsers.DataSource = new Rock.CRM.PersonService().GetByFullName( tbUser.Text ).ToList();
cbUsers.DataBind();
}
@@ -284,8 +298,10 @@ protected void lbAddUser_Click( object sender, EventArgs e )
{
bool alreadyExists = false;
+ int personId = Int32.Parse( li.Value );
+
foreach ( Rock.Security.AuthRule auth in existingAuths )
- if ( auth.UserOrRole == "U" && auth.UserOrRoleName == li.Value )
+ if ( auth.PersonId.HasValue && auth.PersonId.Value == personId)
{
alreadyExists = true;
break;
@@ -298,8 +314,8 @@ protected void lbAddUser_Click( object sender, EventArgs e )
auth.EntityId = iSecured.Id;
auth.Action = CurrentAction;
auth.AllowOrDeny = "A";
- auth.UserOrRole = "U";
- auth.UserOrRoleName = li.Value;
+ auth.SpecialRole = Rock.CMS.SpecialRole.None;
+ auth.PersonId = personId;
auth.Order = ++maxOrder;
authService.Add( auth, CurrentPersonId );
authService.Save( auth, CurrentPersonId );
@@ -336,12 +352,12 @@ private void BindRoles()
{
ddlRoles.Items.Clear();
- ddlRoles.Items.Add(new ListItem("[All Users]", "*AU"));
- ddlRoles.Items.Add(new ListItem("[All Authenticated Users]", "*AAU"));
- ddlRoles.Items.Add(new ListItem("[All Un-Authenticated Users]", "*AUU"));
+ ddlRoles.Items.Add(new ListItem("[All Users]", "-1"));
+ ddlRoles.Items.Add(new ListItem("[All Authenticated Users]", "-2"));
+ ddlRoles.Items.Add(new ListItem("[All Un-Authenticated Users]", "-3"));
foreach(var role in Rock.Security.Role.AllRoles())
- ddlRoles.Items.Add(new ListItem(role.Name, role.Guid.ToString()));
+ ddlRoles.Items.Add(new ListItem(role.Name, role.Id.ToString()));
}
protected string GetTabClass( object action )
@@ -375,10 +391,25 @@ private void SetRoleActions()
else
{
bool alreadyAdded = false;
+
+ Rock.CMS.SpecialRole specialRole = Rock.CMS.SpecialRole.None;
+ int? groupId = Int32.Parse( ddlRoles.SelectedValue );
+
+ switch ( groupId )
+ {
+ case -1: specialRole = Rock.CMS.SpecialRole.AllUsers; break;
+ case -2: specialRole = Rock.CMS.SpecialRole.AllAuthenticatedUsers; break;
+ case -3: specialRole = Rock.CMS.SpecialRole.AllUnAuthenticatedUsers; break;
+ default: specialRole = Rock.CMS.SpecialRole.None; break;
+ }
+
+ if ( groupId < 0 )
+ groupId = null;
+
foreach ( Rock.Security.AuthRule rule in
Rock.Security.Authorization.AuthRules( iSecured.AuthEntity, iSecured.Id, action ) )
{
- if ( rule.UserOrRole == "R" && rule.UserOrRoleName == ddlRoles.SelectedValue )
+ if ( rule.SpecialRole == specialRole && rule.GroupId == groupId )
{
alreadyAdded = true;
break;
View
2  RockWeb/ImageUploader.ashx
@@ -58,7 +58,7 @@ public class ImageUploader : IHttpHandler, IRequiresSessionState
{
string anID = context.Request.QueryString[0];
int id;
- cmsFile = ( int.TryParse( anID, out id ) ) ? fileService.Get( id ) : fileService.GetByGuid( anID );
+ cmsFile = ( int.TryParse( anID, out id ) ) ? fileService.Get( id ) : fileService.GetByPublicKey( anID );
}
else
{
Please sign in to comment.
Something went wrong with that request. Please try again.