public static void ExecuteMethod_UpdateGroupContainerMembership(TBRGroupRoot groupRoot, AccountRootAndContainer[] accountRootsAndContainers, GroupContainer groupContainer) { string groupID = groupRoot.Group.ID; var collaborators = accountRootsAndContainers. Select(acctR => new { Account = acctR.AccountRoot.Account, AccountContainer = acctR.AccountContainer, Profile = acctR.AccountContainer.AccountModule.Profile, GroupRole = acctR.AccountRoot.Account.GroupRoleCollection.CollectionContent.First( role => role.GroupID == groupID) }); var moderators = collaborators.Where(coll => TBCollaboratorRole.HasModeratorRights(coll.GroupRole.GroupRole)).ToArray(); var pendingCollaborators = collaborators.Where( coll => TBCollaboratorRole.IsRoleStatusValidMember(coll.GroupRole.RoleStatus) == false); var fullCollaborators = collaborators.Where( coll => TBCollaboratorRole.IsRoleStatusValidMember(coll.GroupRole.RoleStatus) == true); groupContainer.GroupProfile.Moderators.CollectionContent.Clear(); groupContainer.GroupProfile.Moderators.CollectionContent. AddRange(moderators. Select(mod => { var moderator = Moderator.CreateDefault(); moderator.ModeratorName = mod.Profile.FirstName + " " + mod.Profile.LastName; return(moderator); }).OrderBy(mod => mod.ModeratorName)); groupContainer.Collaborators.CollectionContent.Clear(); groupContainer.Collaborators.CollectionContent.AddRange( fullCollaborators.Select(coll => { Collaborator collaborator = Collaborator.CreateDefault(); collaborator.AccountID = coll.Account.ID; collaborator.CollaboratorName = coll.Profile.FirstName + " " + coll.Profile.LastName; collaborator.Role = coll.GroupRole.GroupRole; return(collaborator); }) ); groupContainer.PendingCollaborators.CollectionContent.Clear(); groupContainer.PendingCollaborators.CollectionContent.AddRange( pendingCollaborators.Select(coll => { Collaborator collaborator = Collaborator.CreateDefault(); collaborator.AccountID = coll.Account.ID; collaborator.CollaboratorName = coll.Profile.FirstName + " " + coll.Profile.LastName; collaborator.Role = coll.GroupRole.GroupRole; return(collaborator); }) ); }
public void JoinGroup(TBCollaboratingGroup collaboratingGroup, TBCollaboratorRole role) { if (this.GroupRoleCollection.CollectionContent.Find(member => member.GroupID == collaboratingGroup.ID) != null) return; this.GroupRoleCollection.CollectionContent.Add(new TBAccountCollaborationGroup() { GroupID = collaboratingGroup.ID, GroupRole = role.Role, RoleStatus = role.RoleStatus }); }
//public bool InviteToGroup(string invitedEmailAddress, string invitedAsRole) //{ // string role = InformationContext.Current.CurrentGroupRole; // if (TBCollaboratorRole.HasModeratorRights(role) == false) // { // throw new UnauthorizedAccessException("Current role " + role + " does not have authorization to invite members to the group"); // } // TBAccount account = TBAccount.GetAccountFromEmail(invitedEmailAddress); // TBCollaboratorRole invited = TBCollaboratorRole.CreateDefault(); // invited.Email.EmailAddress = invitedEmailAddress; // invited.Role = invitedAsRole; // invited.SetRoleAsInvited(); // account.JoinGroup(this, invited); // account.StoreAndPropagate(); // this.Roles.CollectionContent.Add(invited); // return true; //} //public void ConfirmJoining(string invitedEmailAddress) //{ // var role = GetRoleFromEmailAddress(invitedEmailAddress); // role.SetRoleAsMember(); // TBAccount account = TBAccount.GetAccountFromEmail(invitedEmailAddress); // var acctGroupRole = account.GroupRoleCollection.CollectionContent.First(grpRole => grpRole.GroupID == ID); // acctGroupRole.GroupRole = role.Role; // acctGroupRole.RoleStatus = TBCollaboratorRole.RoleStatusMemberValue; // account.StoreAndPropagate(); //} //public TBCollaboratorRole GetRoleFromAccount(TBAccount account) //{ // var accountRole = Roles.CollectionContent.FirstOrDefault( // role => account.Emails.CollectionContent.Exists(email => email.EmailAddress == role.Email.EmailAddress)); // if (accountRole == null) // throw new InvalidDataException(String.Format("No role in group {0} found for requested account {1}", // Title, account.ID)); // return accountRole; //} //public TBCollaboratorRole GetRoleFromEmailAddress(string emailAddress) //{ // var member = Roles.CollectionContent.FirstOrDefault(role => role.Email.EmailAddress == emailAddress); // if (member == null) // throw new InvalidDataException(String.Format("Role in group {0} not found for email address {1}", this.Title, emailAddress)); // return member; //} //public bool AssignRole(string memberEmailAddress, string memberRole) //{ // string role = InformationContext.Current.CurrentGroupRole; // if (TBCollaboratorRole.HasInitiatorRights(role) == false) // { // throw new UnauthorizedAccessException("Current role " + role + // " is not allowed to assign/change the roles of group members"); // } // TBCollaboratorRole member = GetRoleFromEmailAddress(memberEmailAddress); // member.Role = memberRole; // member.SetRoleAsMember(); // TBAccount account = TBAccount.GetAccountFromEmail(memberEmailAddress); // var accountRole = account.GroupRoleCollection.CollectionContent.FirstOrDefault(candidate => candidate.GroupID == ID); // accountRole.GroupRole = member.Role; // account.StoreAndPropagate(); // return true; //} //public void LeaveGroup(TBCollaboratorRole actionInitiator, bool lastPersonLeaving = false) //{ // string role = InformationContext.Current.CurrentGroupRole; // if (TBCollaboratorRole.HasInitiatorRights(role) && lastPersonLeaving == false) // return; // TBAccount account = TBAccount.GetAccountFromEmail(actionInitiator.Email.EmailAddress); // account.GroupRoleCollection.CollectionContent.RemoveAll(candidate => candidate.GroupID == ID); // account.StoreAndPropagate(); // this.Roles.CollectionContent.RemoveAll(candidate => candidate.Email.EmailAddress == actionInitiator.Email.EmailAddress); //} public void DestroyGroup(TBCollaboratorRole actionInitiator) { string role = InformationContext.Current.CurrentGroupRole; if (TBCollaboratorRole.HasInitiatorRights(role) == false) { return; } //LeaveGroup(actionInitiator, lastPersonLeaving: true); StorageSupport.DeleteEntireOwner(this); }
public void JoinGroup(TBCollaboratingGroup collaboratingGroup, TBCollaboratorRole role) { if (this.GroupRoleCollection.CollectionContent.Find(member => member.GroupID == collaboratingGroup.ID) != null) { return; } this.GroupRoleCollection.CollectionContent.Add(new TBAccountCollaborationGroup() { GroupID = collaboratingGroup.ID, GroupRole = role.Role, RoleStatus = role.RoleStatus }); }
public static void ExecuteMethod_RemoveMemberFromGroup(string memberEmailAddress, TBRGroupRoot groupRoot) { groupRoot.Group.Roles.CollectionContent. RemoveAll(role => { bool toRemove = role.Email.EmailAddress == memberEmailAddress; if (toRemove && TBCollaboratorRole.HasInitiatorRights(role.Role)) { throw new InvalidOperationException("Cannot remove initiator from group"); } return(toRemove); }); }
public static void ExecuteMethod_AddAsPendingInvitationToGroupRoot(string memberEmailAddress, TBRGroupRoot groupRoot) { TBCollaboratorRole role = groupRoot.Group.Roles.CollectionContent.FirstOrDefault( candidate => candidate.Email.EmailAddress == memberEmailAddress); if (role != null) { throw new InvalidDataException("Person to be invited is already member (or pending) of the group"); } role = TBCollaboratorRole.CreateDefault(); role.Email.EmailAddress = memberEmailAddress; role.Role = TBCollaboratorRole.CollaboratorRoleValue; role.SetRoleAsInvited(); groupRoot.Group.Roles.CollectionContent.Add(role); }
public static void ExecuteMethod_AddAsInitiatorToGroupRoot(TBRGroupRoot groupRoot, TBEmail[] accountEmails) { var group = groupRoot.Group; foreach(TBEmail email in accountEmails) { var groupRole = new TBCollaboratorRole() { Email = email, Role = TBCollaboratorRole.InitiatorRoleValue, RoleStatus = TBCollaboratorRole.RoleStatusMemberValue, }; //account.JoinGroup(this, groupRole); //account.StoreAndPropagate(); group.Roles.CollectionContent.Add(groupRole); } }
public static void ExecuteMethod_AddAsInitiatorToGroupRoot(TBRGroupRoot groupRoot, TBEmail[] accountEmails) { var group = groupRoot.Group; foreach (TBEmail email in accountEmails) { var groupRole = new TBCollaboratorRole() { Email = email, Role = TBCollaboratorRole.InitiatorRoleValue, RoleStatus = TBCollaboratorRole.RoleStatusMemberValue, }; //account.JoinGroup(this, groupRole); //account.StoreAndPropagate(); group.Roles.CollectionContent.Add(groupRole); } }
public static void Execute(AssignCollaboratorRoleParameters parameters) { PrepareParameters(parameters); TBRGroupRoot GroupRoot = AssignCollaboratorRoleImplementation.GetTarget_GroupRoot(parameters.GroupID); Collaborator Collaborator = AssignCollaboratorRoleImplementation.GetTarget_Collaborator(parameters.GroupContainer, parameters.CollaboratorID); string AccountID = AssignCollaboratorRoleImplementation.GetTarget_AccountID(Collaborator); TBRAccountRoot AccountRoot = AssignCollaboratorRoleImplementation.GetTarget_AccountRoot(AccountID); string EmailAddress = AssignCollaboratorRoleImplementation.GetTarget_EmailAddress(GroupRoot, AccountRoot); TBCollaboratorRole TBCollaboratorRole = AssignCollaboratorRoleImplementation.GetTarget_TBCollaboratorRole(GroupRoot, EmailAddress); AssignCollaboratorRoleImplementation.ExecuteMethod_AssignCollaboratorRole(parameters.RoleToAssign, TBCollaboratorRole); AssignCollaboratorRoleImplementation.ExecuteMethod_StoreObjects(GroupRoot); { // Local block to allow local naming RefreshAccountGroupMembershipsParameters operationParameters = AssignCollaboratorRoleImplementation.RefreshAccountAndGroupContainers_GetParameters(GroupRoot, AccountID); RefreshAccountGroupMemberships.Execute(operationParameters); } // Local block closing }
public void JoinToGroup(string emailAddress, string joinAsRole) { if (this.Roles.CollectionContent.Find(member => member.Email.EmailAddress == emailAddress) != null) { return; } TBAccount account = TBAccount.GetAccountFromEmail(emailAddress); TBEmail email = account.GetAccountEmail(emailAddress); var groupRole = new TBCollaboratorRole() { Email = email, Role = joinAsRole, RoleStatus = TBCollaboratorRole.RoleStatusMemberValue, }; //account.JoinGroup(this, groupRole); //account.StoreAndPropagate(); this.Roles.CollectionContent.Add(groupRole); }
public static void ExecuteMethod_SynchronizeLoginGroupRoots(TBRAccountRoot accountRoot, TBRLoginGroupRoot[] loginGroupRoots) { //throw new NotImplementedException(); //TBRLoginGroupRoot loginGroupRoot = TBRLoginGroupRoot.CreateDefault(); //string loginGroupID = TBRLoginGroupRoot.GetLoginGroupID(groupRoleItem.GroupID, loginRootID); var accountLogins = accountRoot.Account.Logins.CollectionContent; var accountGroupRoles = accountRoot.Account.GroupRoleCollection.CollectionContent; List <TBRLoginGroupRoot> currentLoginGroupRoots = new List <TBRLoginGroupRoot>(); foreach (var groupRoleItem in accountGroupRoles.Where(agr => TBCollaboratorRole.IsRoleStatusValidMember(agr.RoleStatus))) { foreach (var loginItem in accountLogins) { string loginRootID = TBLoginInfo.GetLoginIDFromLoginURL(loginItem.OpenIDUrl); string loginGroupID = TBRLoginGroupRoot.GetLoginGroupID(groupRoleItem.GroupID, loginRootID); TBRLoginGroupRoot loginGroupRoot = loginGroupRoots.FirstOrDefault(lgr => lgr.ID == loginGroupID); if (loginGroupRoot == null) { loginGroupRoot = TBRLoginGroupRoot.CreateDefault(); loginGroupRoot.ID = loginGroupID; loginGroupRoot.UpdateRelativeLocationFromID(); } loginGroupRoot.GroupID = groupRoleItem.GroupID; loginGroupRoot.Role = groupRoleItem.GroupRole; currentLoginGroupRoots.Add(loginGroupRoot); } } var loginRootsToDelete = loginGroupRoots. Where(lgr => currentLoginGroupRoots.Exists(currLgr => currLgr.ID == lgr.ID) == false); foreach (var loginRootToDelete in loginRootsToDelete) { loginRootToDelete.DeleteInformationObject(); } foreach (var currLoginRoot in currentLoginGroupRoots) { currLoginRoot.StoreInformation(); } }
public static void ExecuteMethod_AddNewInitiatorToGroup(string groupId, string newInitiatorAccountId) { TBRGroupRoot groupRoot = TBRGroupRoot.RetrieveFromDefaultLocation(groupId); TBRAccountRoot accountRoot = TBRAccountRoot.RetrieveFromDefaultLocation(newInitiatorAccountId); var accountEmails = accountRoot.Account.Emails.CollectionContent; var group = groupRoot.Group; foreach(TBEmail email in accountEmails) { var groupRole = new TBCollaboratorRole() { Email = email, Role = TBCollaboratorRole.InitiatorRoleValue, RoleStatus = TBCollaboratorRole.RoleStatusMemberValue, }; group.Roles.CollectionContent.Add(groupRole); } groupRoot.StoreInformation(); RefreshAccountGroupMemberships.Execute(new RefreshAccountGroupMembershipsParameters { GroupRoot = groupRoot, AccountID = newInitiatorAccountId }); }
public void JoinToGroup(string emailAddress, string joinAsRole) { if (this.Roles.CollectionContent.Find(member => member.Email.EmailAddress == emailAddress) != null) return; TBAccount account = TBAccount.GetAccountFromEmail(emailAddress); TBEmail email = account.GetAccountEmail(emailAddress); var groupRole = new TBCollaboratorRole() { Email = email, Role = joinAsRole, RoleStatus = TBCollaboratorRole.RoleStatusMemberValue, }; //account.JoinGroup(this, groupRole); //account.StoreAndPropagate(); this.Roles.CollectionContent.Add(groupRole); }
public static void ExecuteMethod_AssignCollaboratorRole(string roleToAssign, TBCollaboratorRole tbCollaboratorRole) { tbCollaboratorRole.Role = roleToAssign; }
public void StoreAccountToRoot() { TBRAccountRoot accountRoot = TBRAccountRoot.RetrieveFromDefaultLocation(this.ID); accountRoot.Account = this; StorageSupport.StoreInformation(accountRoot); return; AccountContainer accountContainer = AccountContainer.RetrieveFromOwnerContent(this, "default"); if (accountContainer == null) { accountContainer = AccountContainer.CreateDefault(); accountContainer.SetLocationAsOwnerContent(this, "default"); } accountContainer.AccountModule.Security.LoginInfoCollection = this.Logins; foreach (var loginItem in this.Logins.CollectionContent) { string loginRootID = TBLoginInfo.GetLoginIDFromLoginURL(loginItem.OpenIDUrl); TBRLoginRoot loginRoot = TBRLoginRoot.RetrieveFromDefaultLocation(loginRootID); loginRoot.Account = this; StorageSupport.StoreInformation(loginRoot); // TODO: Remove invalid group role logins at this stage foreach (var groupRoleItem in this.GroupRoleCollection.CollectionContent.Where(grpRole => TBCollaboratorRole.IsRoleStatusValidMember(grpRole.RoleStatus))) { string loginGroupID = TBRLoginGroupRoot.GetLoginGroupID(groupRoleItem.GroupID, loginRootID); TBRLoginGroupRoot loginGroupRoot = TBRLoginGroupRoot.RetrieveFromDefaultLocation(loginGroupID); if (loginGroupRoot == null) { loginGroupRoot = TBRLoginGroupRoot.CreateDefault(); loginGroupRoot.ID = loginGroupID; loginGroupRoot.UpdateRelativeLocationFromID(); } loginGroupRoot.GroupID = groupRoleItem.GroupID; loginGroupRoot.Role = groupRoleItem.GroupRole; StorageSupport.StoreInformation(loginGroupRoot); } } //accountContainer.AccountModule.Security.EmailCollection = this.Emails; foreach (var emailItem in this.Emails.CollectionContent) { string emailRootID = TBREmailRoot.GetIDFromEmailAddress(emailItem.EmailAddress); TBREmailRoot emailRoot = TBREmailRoot.RetrieveFromDefaultLocation(emailRootID); if (emailRoot == null) { emailRoot = TBREmailRoot.CreateDefault(); emailRoot.ID = emailRootID; emailRoot.UpdateRelativeLocationFromID(); } emailRoot.Account = this; StorageSupport.StoreInformation(emailRoot); } var roles = accountContainer.AccountModule.Roles; roles.MemberInGroups.CollectionContent.Clear(); roles.ModeratorInGroups.CollectionContent.Clear(); foreach (var groupRoleItem in this.GroupRoleCollection.CollectionContent) { var groupRoot = TBRGroupRoot.RetrieveFromDefaultLocation(groupRoleItem.GroupID); if (groupRoot == null) { continue; } var grp = groupRoot.Group; ReferenceToInformation reference = ReferenceToInformation.CreateDefault(); reference.URL = string.Format("/auth/grp/{0}/website/oip-group/oip-layout-groups-edit.phtml", groupRoot.ID); reference.Title = grp.Title + " - " + groupRoleItem.GroupRole; switch (groupRoleItem.GroupRole.ToLower()) { case "initiator": case "moderator": roles.ModeratorInGroups.CollectionContent.Add(reference); break; case "collaborator": case "viewer": roles.MemberInGroups.CollectionContent.Add(reference); break; } } StorageSupport.StoreInformation(accountContainer); }