private bool IsSelectedUserTeamMember(WBTeam team) { if (selectedUser == null) { return(team.IsCurrentUserTeamMember()); } else { return(team.IsUserTeamMember(selectedUser)); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { String currentUserLoginName = SPContext.Current.Web.CurrentUser.LoginName; WBTaxonomy teams = WBTaxonomy.GetTeams(SPContext.Current.Site); WBTaxonomy functionalAreas = WBTaxonomy.GetFunctionalAreas(teams); WBTeam team = WBTeam.GetFromTeamSite(teams, SPContext.Current.Web); if (team == null) { WorkBox workBox = WorkBox.GetIfWorkBox(SPContext.Current); if (workBox != null) { team = workBox.OwningTeam; } } // Check if this user has permission - checking basic team membership: if (team == null || !team.IsCurrentUserTeamMember()) { AccessDeniedPanel.Visible = true; UpdateRecordsMetadataPanel.Visible = false; AccessDeniedReason.Text = "You are not a member of this team"; return; } RecordID.Text = Request.QueryString["RecordID"]; WBLogging.Debug("Record ID is found to be: " + RecordID.Text); using (WBRecordsManager manager = new WBRecordsManager(currentUserLoginName)) { WBRecord record = manager.Libraries.GetRecordByID(RecordID.Text); record.CheckMetadata(); Filename.Text = record.Name; RecordTitle.Text = record.Title; String location = "<unknown>"; if (record.FunctionalArea != null && record.FunctionalArea.Count > 0) { WBLogging.Debug("Found functional area = " + record.FunctionalArea); WBTerm functionalArea = record.FunctionalArea[0]; location = functionalArea.FullPath; WBLogging.Debug("location = " + location); WBTermCollection <WBTerm> teamsFunctionalAreas = team.FunctionalArea(functionalAreas); if (!teamsFunctionalAreas.Contains(functionalArea)) { WBLogging.Debug("Team functional areas UIControlValue: " + teamsFunctionalAreas.UIControlValue); WBLogging.Debug("Record's functional area UIControlValue: " + functionalArea); AccessDeniedPanel.Visible = true; UpdateRecordsMetadataPanel.Visible = false; AccessDeniedReason.Text = "The team " + team.Name + " does not have permission to edit this functional area: " + functionalArea.Name; return; } } location += "/" + record.RecordsType.FullPath; String folders = record.ProtectedMasterRecord.LibraryRelativePath.Replace(record.Name, "").Replace(location, ""); RecordsLocation.Text = "<b>" + location + "</b> " + folders; String status = record.RecordSeriesStatus; RecordSeriesStatus.Text = status; String explainStatus = ""; if (status == "Latest") { if (record.ProtectiveZone == WBRecordsType.PROTECTIVE_ZONE__PUBLIC) { explainStatus = "(live on the public website)"; } else if (record.ProtectiveZone == WBRecordsType.PROTECTIVE_ZONE__PUBLIC_EXTRANET) { explainStatus = "(live on a public extranet website)"; } else { explainStatus = "(live on izzi intranet)"; } } else if (status == "Retired") { explainStatus = "(visible on izzi intranet searches)"; } else if (status == "Archived") { explainStatus = "(archived in the protected, master records library)"; } ExplainStatus.Text = explainStatus; RecordSeriesStatusChange.DataSource = new String[] { "", "Retire", "Archive" }; RecordSeriesStatusChange.DataBind(); RecordSeriesStatusChange.SelectedValue = ""; ProtectiveZone.DataSource = new String[] { WBRecordsType.PROTECTIVE_ZONE__PROTECTED, WBRecordsType.PROTECTIVE_ZONE__PUBLIC }; ProtectiveZone.DataBind(); ProtectiveZone.SelectedValue = record.ProtectiveZone; manager.SubjectTagsTaxonomy.InitialiseTaxonomyControl(SubjectTags, WBColumn.SubjectTags.DisplayName, true); SubjectTags.Text = record.SubjectTagsUIControlValue; manager.TeamsTaxonomy.InitialiseTaxonomyControl(OwningTeam, WBColumn.OwningTeam.DisplayName, false); OwningTeam.Text = record.OwningTeam.UIControlValue; manager.TeamsTaxonomy.InitialiseTaxonomyControl(InvolvedTeams, WBColumn.InvolvedTeams.DisplayName, true); InvolvedTeams.Text = record.InvolvedTeamsWithoutOwningTeamAsUIControlValue; } } }