protected void Page_Load(object sender, EventArgs e) { // First we're going to check membership of the records management group: String rmGroupName = WBFarm.Local.RecordsManagersGroupName; SPGroup rmGroup = null; if (!String.IsNullOrEmpty(rmGroupName)) { try { rmGroup = SPContext.Current.Web.SiteGroups[rmGroupName]; } catch (Exception exception) { // Probably the group hasn't been created or setup here yet } } if (rmGroup == null || !rmGroup.ContainsCurrentUser) { AccessDeniedPanel.Visible = true; UpdateRecordsMetadataPanel.Visible = false; return; } currentUserLoginName = SPContext.Current.Web.CurrentUser.LoginName; String listIDString = ""; String itemIDString = ""; String recordIDString = ""; recordsTypesTaxonomy = WBTaxonomy.GetRecordsTypes(SPContext.Current.Site); subjectTagsTaxonomy = WBTaxonomy.GetSubjectTags(recordsTypesTaxonomy); librarySite = new SPSite(WBFarm.Local.ProtectedRecordsLibraryUrl); libraryWeb = librarySite.OpenWeb(); libraryList = libraryWeb.GetList(WBFarm.Local.ProtectedRecordsLibraryUrl); if (!IsPostBack) { recordIDString = Request.QueryString["RecordID"]; if (String.IsNullOrEmpty(recordIDString)) { listIDString = Request.QueryString["ListID"]; itemIDString = Request.QueryString["ItemID"]; } else { listIDString = libraryList.ID.ToString(); } ListID.Value = listIDString; ItemID.Value = itemIDString; } else { recordIDString = RecordID.Text; listIDString = ListID.Value; itemIDString = ItemID.Value; } if (!String.IsNullOrEmpty(itemIDString)) { int itemID = Convert.ToInt32(itemIDString); recordItem = libraryList.GetItemById(itemID); } else { recordItem = WBUtils.FindItemByColumn(SPContext.Current.Site, libraryList, WBColumn.RecordID, recordIDString); if (recordItem != null) { itemIDString = recordItem.ID.ToString(); ItemID.Value = itemIDString; } } if (recordItem != null) { record = new WBDocument(recordItem); FunctionalArea.Text = record.FunctionalArea.Names(); WBRecordsType recordsType = record.RecordsType; recordsType.Taxonomy = recordsTypesTaxonomy; RecordsType.Text = recordsType.FullPath.Replace("/", " / "); if (!IsPostBack) { Filename.Text = recordItem.Name; Title.Text = recordItem.Title; RecordID.Text = record[WBColumn.RecordID].WBxToString(); LiveOrArchived.DataSource = new String[] { "Live", "Archived" }; LiveOrArchived.DataBind(); LiveOrArchived.SelectedValue = record[WBColumn.LiveOrArchived].WBxToString(); ProtectiveZone.DataSource = WBRecordsType.getProtectiveZones(); ProtectiveZone.DataBind(); ProtectiveZone.SelectedValue = record.ProtectiveZone; subjectTagsTaxonomy.InitialiseTaxonomyControl(SubjectTags, WBColumn.SubjectTags.DisplayName, true); SubjectTags.Text = record.SubjectTags.UIControlValue; } } if (!IsPostBack) { libraryWeb.Dispose(); librarySite.Dispose(); LiveOrArchived.Focus(); } }
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; } } }