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(); } }
private void renderPage() { // OK, so now we're finally in a position to load up the values of the page fields: SourceDocIcon.AlternateText = "Icon of document being publishing out."; SourceDocIcon.ImageUrl = WBUtils.DocumentIcon32(sourceDocAsItem.Url); TitleField.Text = sourceFile.Title; ReadOnlyNameField.Text = sourceDocAsItem.Name; NameField.Text = sourceDocAsItem.Name; OriginalFileName.Text = sourceDocAsItem.WBxGetColumnAsString(WorkBox.COLUMN_NAME__ORIGINAL_FILENAME); DocumentFileNamingConvention.Text = documentRecordsType.DocumentNamingConvention.Replace("<", "<").Replace(">", ">"); RecordsTypeUIControlValue.Value = documentRecordsType.UIControlValue; PickRecordsTypeButton.OnClientClick = "WorkBoxFramework_pickANewRecordsType(WorkBoxFramework_PublishDoc_pickedANewRecordsType, '" + documentRecordsType.UIControlValue + "'); return false;"; RecordsType.Text = documentRecordsType.FullPath.Replace("/", " / "); WBTermCollection <WBTerm> functionalAreas = sourceDocAsItem.WBxGetMultiTermColumn <WBTerm>(functionalAreasTaxonomy, WorkBox.COLUMN_NAME__FUNCTIONAL_AREA); functionalAreaFieldIsEditable = documentRecordsType.IsFunctionalAreaEditable; if (functionalAreaFieldIsEditable) { functionalAreasTaxonomy.InitialiseTaxonomyControl(FunctionalAreaField, WorkBox.COLUMN_NAME__FUNCTIONAL_AREA, false, false, this); String functionalAreaValue = functionalAreas.UIControlValue; if (functionalAreaValue.Contains(";")) { string[] allFunctionalValues = functionalAreaValue.Split(';'); functionalAreaValue = allFunctionalValues[0]; } FunctionalAreaField.Text = functionalAreaValue; } else { ReadOnlyFunctionalAreaField.Text = functionalAreas.Names(); } bool userCanPublishToPublic = false; SPGroup publishersGroup = WorkBox.OwningTeam.PublishersGroup(SPContext.Current.Site); if (publishersGroup != null) { if (publishersGroup.ContainsCurrentUser) { userCanPublishToPublic = true; } } String selectedZone = WBRecordsType.PROTECTIVE_ZONE__PROTECTED; if (userCanPublishToPublic) { if (destinationType.Equals(WorkBox.PUBLISHING_OUT_DESTINATION_TYPE__PUBLIC_WEB_SITE)) { WBLogging.Generic.Verbose("In PUBLIC: The destination type was: " + destinationType); selectedZone = WBRecordsType.PROTECTIVE_ZONE__PUBLIC; } else if (destinationType.Equals(WorkBox.PUBLISHING_OUT_DESTINATION_TYPE__PUBLIC_EXTRANET)) { WBLogging.Generic.Verbose("In PUBLIC EXTRANET: The destination type was: " + destinationType); selectedZone = WBRecordsType.PROTECTIVE_ZONE__PUBLIC_EXTRANET; } else { WBLogging.Generic.Verbose("The destination type was: " + destinationType); selectedZone = WBRecordsType.PROTECTIVE_ZONE__PROTECTED; } } else { selectedZone = WBRecordsType.PROTECTIVE_ZONE__PROTECTED; } List <String> protectiveZoneList = new List <String>(); protectiveZoneList.Add(selectedZone); ProtectiveZone.DataSource = protectiveZoneList; ProtectiveZone.DataBind(); ProtectiveZone.SelectedValue = selectedZone; if (showSubjectTags) { if (documentRecordsType.IsDocumentSubjectTagsRequired) { SubjectTagsTitle.Text = "Subject Tags" + WBConstant.REQUIRED_ASTERISK; } else { SubjectTagsTitle.Text = "Subject Tags (optional)"; } SubjectTagsDescription.Text = documentRecordsType.DocumentSubjectTagsDescription; subjectTagsTaxonomy.InitialiseTaxonomyControl(SubjectTagsField, WorkBox.COLUMN_NAME__SUBJECT_TAGS, true, true, this); WBTermCollection <WBTerm> subjectTags = sourceDocAsItem.WBxGetMultiTermColumn <WBTerm>(subjectTagsTaxonomy, WorkBox.COLUMN_NAME__SUBJECT_TAGS); SubjectTagsField.Text = subjectTags.WBxToString(); } if (showReferenceID) { if (documentRecordsType.IsDocumentReferenceIDRequired) { ReferenceIDTitle.Text = "Reference ID" + WBConstant.REQUIRED_ASTERISK; } else { ReferenceIDTitle.Text = "Reference ID (optional)"; } ReferenceIDDescription.Text = documentRecordsType.DocumentReferenceIDDescription; ReferenceID.Text = sourceDocAsItem.WBxGetColumnAsString(WorkBox.COLUMN_NAME__REFERENCE_ID); } if (showReferenceDate) { if (documentRecordsType.IsDocumentReferenceDateRequired) { ReferenceDateTitle.Text = "Reference Date" + WBConstant.REQUIRED_ASTERISK; } else { ReferenceDateTitle.Text = "Reference Date (optional)"; } ReferenceDateDescription.Text = documentRecordsType.DocumentReferenceDateDescription; if (sourceDocAsItem.WBxColumnHasValue(WorkBox.COLUMN_NAME__REFERENCE_DATE)) { ReferenceDate.SelectedDate = (DateTime)sourceDocAsItem[WorkBox.COLUMN_NAME__REFERENCE_DATE]; } else { ReferenceDate.SelectedDate = DateTime.Now; } } if (showSeriesTag) { if (documentRecordsType.IsDocumentSeriesTagRequired) { SeriesTagTitle.Text = "Series Tag" + WBConstant.REQUIRED_ASTERISK; } else { SeriesTagTitle.Text = "Series Tag (optional)"; } SeriesTagDescription.Text = documentRecordsType.DocumentSeriesTagDescription; SeriesTagDropDownList.DataSource = GetSeriesTagDataSource(documentRecordsType.DocumentSeriesTagParentTerm(seriesTagsTaxonomy)); SeriesTagDropDownList.DataTextField = "SeriesTagTermName"; SeriesTagDropDownList.DataValueField = "SeriesTagTermUIControlValue"; SeriesTagDropDownList.DataBind(); if (sourceDocAsItem.WBxColumnHasValue(WorkBox.COLUMN_NAME__SERIES_TAG)) { SeriesTagDropDownList.SelectedValue = sourceDocAsItem.WBxGetSingleTermColumn <WBTerm>(seriesTagsTaxonomy, WorkBox.COLUMN_NAME__SERIES_TAG).UIControlValue; } } if (showScanDate) { if (documentRecordsType.IsDocumentScanDateRequired) { ScanDateTitle.Text = "Scan Date" + WBConstant.REQUIRED_ASTERISK; } else { ScanDateTitle.Text = "Scan Date (optional)"; } ScanDateDescription.Text = documentRecordsType.DocumentScanDateDescription; if (sourceDocAsItem.WBxColumnHasValue(WorkBox.COLUMN_NAME__SCAN_DATE)) { ScanDate.SelectedDate = (DateTime)sourceDocAsItem[WorkBox.COLUMN_NAME__SCAN_DATE]; } } teamsTaxonomy.InitialiseTaxonomyControl(OwningTeamField, WorkBox.COLUMN_NAME__OWNING_TEAM, false); TaxonomyFieldValue owningTeamValue = sourceDocAsItem[WorkBox.COLUMN_NAME__OWNING_TEAM] as TaxonomyFieldValue; OwningTeamField.Text = owningTeamValue.WBxUIControlValue(); teamsTaxonomy.InitialiseTaxonomyControl(InvolvedTeamsField, WorkBox.COLUMN_NAME__INVOLVED_TEAMS, true); TaxonomyFieldValueCollection involvedTeamsValues = sourceDocAsItem[WorkBox.COLUMN_NAME__INVOLVED_TEAMS] as TaxonomyFieldValueCollection; InvolvedTeamsField.Text = involvedTeamsValues.WBxUIControlValue(); if (functionalAreaFieldIsEditable) { FunctionalAreaField.Focus(); } else { PickRecordsTypeButton.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; } } }