protected void Page_Load(object sender, EventArgs e) { if (!WorkBox.CurrentUserIsOwner() && !WorkBox.CurrentUserIsBusinessAdmin() && !WorkBox.CurrentUserIsSystemAdmin()) { ErrorText.Text = "Only owners or admin can invite teams to have access to a work box."; return; } teamsTaxonomy = WBTaxonomy.GetTeams(SPContext.Current.Site); if (!IsPostBack) { WorkBoxTitle.Text = WorkBox.Title; InviteType.SelectedValue = "Involved"; CurrentlySelectedValue.Value = "Involved"; SendInviteEmail.Checked = true; SendAsOne.Checked = true; CCToYou.Checked = true; EmailSubject.Text = WorkBox.Template.InviteInvolvedUserEmailSubject; EmailBody.Text = WorkBox.Template.InviteInvolvedUserEmailBody; OtherEmailSubject.Value = WorkBox.Template.InviteVisitingUserEmailSubject; OtherEmailBody.Value = WorkBox.Template.InviteVisitingUserEmailBody; teamsTaxonomy.InitialiseTaxonomyControl(TeamsToInviteControl, "Teams to invite", true); TeamsToInviteControl.Focus(); DisposeWorkBox(); } }
private String makeScriptForSettingWorkBoxVariables(WorkBox workBox, WBUser user, UserProfile profile) { string htmlForScript = "<script type=\"text/javascript\">\n"; Dictionary <String, WBAction> allActions = workBox.GetAllActions(); Dictionary <String, bool> allEnableFlags = new Dictionary <String, Boolean>(); foreach (WBAction action in allActions.Values) { allEnableFlags.Add(action.ActionKey, action.IsEnabled); } htmlForScript += makeVarDeclaration("wbf_json__all_actions_details", JsonConvert.SerializeObject(allActions)); htmlForScript += makeVarDeclaration("wbf_json__all_actions_enable_flags", JsonConvert.SerializeObject(allEnableFlags)); htmlForScript += makeVarDeclaration("wbf__clipboard_action", user.GetClipboardAction(profile)); htmlForScript += makeVarDeclaration("wbf__enable_tasks_button", false); htmlForScript += makeVarDeclaration("wbf__enable_document_templates_button", (workBox.DocumentTemplates != null)); htmlForScript += makeVarDeclaration("wbf__document_library_root_folder_url", workBox.Web.Url + "/" + workBox.DocumentLibrary.RootFolder.Url); htmlForScript += makeVarDeclaration("wbf__spweb_url", workBox.Web.Url); htmlForScript += "</script>\n"; return(htmlForScript); }
protected void refreshTeams_OnClick(object sender, EventArgs e) { WorkBox.RefreshTeams(); generateTableOfAllInvolved(); DisposeWorkBox(); }
protected void Page_Load(object sender, EventArgs e) { webPart = this.Parent as RelatedMeetings; if (webPart.MeetingsWorkBoxCollectionURL == null || webPart.MeetingsWorkBoxCollectionURL == "") { CreateNewMeetingLink.Text = "(Web part not configured yet)"; return; } using (WorkBox workBox = new WorkBox(SPContext.Current)) { if (workBox.LinkedWorkBoxesList == null) { CreateNewMeetingLink.Text = "(Work Box doesn't have a related items list)"; return; } DataTable dataTable = createDataTable(); addRelatedWorkBoxesToDataTable(workBox.LinkedWorkBoxesList, dataTable); RelatedMeetings.DataSource = dataTable; RelatedMeetings.DataBind(); using (WBCollection collection = new WBCollection(webPart.MeetingsWorkBoxCollectionURL)) { string createNewURL = collection.GetUrlForNewDialog(workBox, WorkBox.RELATION_TYPE__CHILD); string createNewText = "Create New Meeting"; // collection.CreateNewWorkBoxText; CreateNewMeetingLink.Text = "<a href=\"#\" onclick=\"javascript: WorkBoxFramework_commandAction('" + createNewURL + "', 600, 500);\">" + createNewText + "</a>"; } } }
public WBDocument(WorkBox workBox) : base() { RecordsLibrary = null; WorkBox = workBox; DebugName = "<WBDocument>"; }
protected void Page_Load(object sender, EventArgs e) { if (!WorkBox.CurrentUserIsOwner() && !WorkBox.CurrentUserIsBusinessAdmin() && !WorkBox.CurrentUserIsSystemAdmin()) { ErrorText.Text = "Only owners or admin can invite individuals to have access to a work box."; return; } if (!IsPostBack) { WorkBoxTitle.Text = WorkBox.Title; InviteType.SelectedValue = "Involved"; CurrentlySelectedValue.Value = "Involved"; SendInviteEmail.Checked = true; SendAsOne.Checked = true; CCToYou.Checked = true; EmailSubject.Text = WorkBox.Template.InviteInvolvedUserEmailSubject; EmailBody.Text = WorkBox.Template.InviteInvolvedUserEmailBody; OtherEmailSubject.Value = WorkBox.Template.InviteVisitingUserEmailSubject; OtherEmailBody.Value = WorkBox.Template.InviteVisitingUserEmailBody; IndividualsToInviteControl.Focus(); DisposeWorkBox(); } }
/// <summary> /// An item was updated. /// </summary> public override void ItemUpdated(SPItemEventProperties properties) { String workBoxURL = properties.ListItem.WBxGetAsString(WBColumn.WorkBoxURL); if (!String.IsNullOrEmpty(workBoxURL)) { using (WorkBox workBox = new WorkBox(workBoxURL)) { workBox.ReferenceDate = (DateTime)properties.ListItem["EventDate"]; if (workBox.Item.WBxColumnExists("EventDate")) { workBox.Item["EventDate"] = properties.ListItem["EventDate"]; } if (workBox.Item.WBxColumnExists("EndDate")) { workBox.Item["EndDate"] = properties.ListItem["EndDate"]; } workBox.JustUpdate(); workBox.UpdateCachedDetails(); } } base.ItemUpdated(properties); }
protected void Page_Load(object sender, EventArgs e) { WorkBox workBox = WorkBox.GetIfWorkBox(SPContext.Current); if (workBox != null) { WBTeam owningTeam = workBox.OwningTeam; if (owningTeam == null) { LinkToOwner = "#"; } else { LinkToOwner = owningTeam.TeamSiteUrl; // Only need to set the text to the owning team's name if the text hasn't been set already: if (TextForLink == "") { TextForLink = owningTeam.Name; } WBUtils.logMessage("Found URL: " + LinkToOwner); } // This wont do anything because the web and site come from context, but still: workBox.Dispose(); } }
protected void Page_Load(object sender, EventArgs e) { manager = new WBRecordsManager(SPContext.Current.Web.CurrentUser.LoginName); masterLibraryHasVersions = manager.Libraries.ProtectedMasterLibrary.List.EnableVersioning; if (WorkBox.IsWebAWorkBox(SPContext.Current.Web)) { workBox = new WorkBox(SPContext.Current); team = workBox.OwningTeam; } else { team = WBTeam.GetFromTeamSite(SPContext.Current); } if (!IsPostBack && team != null) { WBQuery query = manager.GetQueryForTeamsPublicRecordsToReview(team); WBLogging.Debug("The query is: " + query.JustCAMLQuery(manager.Libraries.ProtectedMasterLibrary.Site)); SPListItemCollection items = manager.Libraries.ProtectedMasterLibrary.List.WBxGetItems(manager.Libraries.ProtectedMasterLibrary.Site, query); RenderFoundRecords(items); } }
public WBDocument(WorkBox workBox, SPListItemVersion item) : base(item) { RecordsLibrary = null; WorkBox = workBox; DebugName = "<WBDocument>"; }
protected void reopenWorkBoxButton_OnClick(object sender, EventArgs e) { WorkBox.Open(ReOpenComment.Text); DisposeWorkBox(); CloseDialogAndRefresh(); }
protected void closeWorkBoxButton_OnClick(object sender, EventArgs e) { WorkBox.Close(CloseComment.Text); DisposeWorkBox(); CloseDialogAndRefresh(); }
public WBUser(WorkBox workBox) { Site = workBox.Site; Web = workBox.Web; User = Web.CurrentUser; IsCurrentUser = true; }
public String AddToClipboard(String action, WorkBox workBox, String[] itemIDs, bool clearExistingItems) { String errorString = ""; Dictionary <String, List <int> > clipboardItems = new Dictionary <String, List <int> >(); String clipboardAction = ""; if (clearExistingItems) { // If we are clearing the clipboard then we don't have to match the new action with the existing action: clipboardAction = action; } else { clipboardAction = GetClipboard(Profile, clipboardItems); if (String.IsNullOrEmpty(clipboardAction)) { clipboardAction = action; } } if (clipboardAction != action) { return("You can't mix CUT and COPY actions!"); //"The action for the current items is: " + clipboardAction + " so you can't add items with the action: " + action + " without first clearing the clipboard"; } List <int> currentIDsForWorkBox = null; if (clipboardItems.ContainsKey(workBox.Url)) { currentIDsForWorkBox = clipboardItems[workBox.Url]; } else { currentIDsForWorkBox = new List <int>(); } foreach (string idString in itemIDs) { if (!String.IsNullOrEmpty(idString)) { int id = Int32.Parse(idString); if (!currentIDsForWorkBox.Contains(id)) { currentIDsForWorkBox.Add(id); } } } if (String.IsNullOrEmpty(errorString)) { clipboardItems[workBox.Url] = currentIDsForWorkBox; return(SetClipboard(Profile, clipboardAction, clipboardItems)); } return(errorString); }
protected void DisposeWorkBox() { if (_workBox != null && !hasBeenDisposed) { _workBox.Dispose(); _workBox = null; hasBeenDisposed = true; } }
protected override void CreateChildControls() { Literal literal = new Literal(); string html = ""; WorkBox workBox = WorkBox.GetIfWorkBox(SPContext.Current); if (workBox == null) { return; } WBTermCollection <WBTeam> involvedTeams = workBox.InvolvedTeams; if (involvedTeams == null) { addErrorMessage("Couldn't find a involvedTeams for the field"); } else { if (involvedTeams.Count > 0) { if (TeamsRootSiteURL == null || TeamsRootSiteURL == "") { TeamsRootSiteURL = WBFarm.Local.TeamSitesSiteCollectionUrl; } try { using (SPSite teamsSite = new SPSite(TeamsRootSiteURL)) { html += "<table cellpadding='5'>"; foreach (WBTeam team in involvedTeams) { html += "<tr><td><a href='" + team.TeamSiteUrl + "'>" + team.Name + "</a></td></tr>"; } html += "</table>"; } } catch (Exception e) { html = "Exception was thrown " + e.StackTrace; } } else { html += "<i>(none)</i>"; } } literal.Text = html; this.Controls.Add(literal); }
protected void removeButton_OnClick(object sender, EventArgs e) { AreYouSureText.Text = "Something went wrong when trying to remove the indiviual or team."; if (TeamOrIndividual.Value == "Team" && team != null) { if (InvolvedOrVisiting.Value == "Involved") { WBTermCollection <WBTeam> involvedTeams = WorkBox.InvolvedTeams; involvedTeams.Remove(team); WorkBox.InvolvedTeams = involvedTeams; WorkBox.AuditLogEntry("Removed team", "No longer involved: " + team.Name); WorkBox.Update(); } else { WBTermCollection <WBTeam> visitingTeams = WorkBox.VisitingTeams; visitingTeams.Remove(team); WorkBox.VisitingTeams = visitingTeams; WorkBox.AuditLogEntry("Removed team", "No longer visiting: " + team.Name); WorkBox.Update(); } CloseDialogAndRefresh(); } if (TeamOrIndividual.Value == "Individual" && user != null) { if (InvolvedOrVisiting.Value == "Involved") { List <SPUser> involvedUsers = WorkBox.InvolvedIndividuals; involvedUsers = WBUtils.RemoveUser(involvedUsers, user); WorkBox.InvolvedIndividuals = involvedUsers; WorkBox.AuditLogEntry("Removed individual", "No longer involved: " + user.Name); WorkBox.Update(); } else { List <SPUser> visitingUsers = WorkBox.VisitingIndividuals; visitingUsers = WBUtils.RemoveUser(visitingUsers, user); WorkBox.VisitingIndividuals = visitingUsers; WorkBox.AuditLogEntry("Removed individual", "No longer visiting: " + user.Name); WorkBox.Update(); } CloseDialogAndRefresh(); } DisposeWorkBox(); }
protected void saveButton_OnClick(object sender, EventArgs e) { WorkBox.InvolvedIndividuals = InvolvedIndividualsControl.WBxGetMultiResolvedUsers(SPContext.Current.Web); WorkBox.VisitingIndividuals = VisitingIndividualsControl.WBxGetMultiResolvedUsers(SPContext.Current.Web); WorkBox.Update(); DisposeWorkBox(); CloseDialogAndRefresh(); }
public override void ItemAdded(SPItemEventProperties properties) { WBLogging.Generic.HighLevel("WorkBoxMetaDataItemChangeEventReceiver.ItemAdded()"); WBCollection collection = new WBCollection(properties.ListItem); using (WorkBox workBox = new WorkBox(collection, properties.ListItem)) { processChangeRequest(workBox); } base.ItemAdded(properties); }
private bool enableLogic(WorkBox workBox) { switch (ActionKey) { case ACTION_KEY__EDIT_PROPERTIES: case ACTION_KEY__INVITE_TEAMS: case ACTION_KEY__INVITE_INDIVIDUALS: case ACTION_KEY__CHANGE_OWNER: case ACTION_KEY__CLOSE: { if (!workBox.IsOpen) { return(false); } break; } case ACTION_KEY__REOPEN: { if (!workBox.IsClosed) { return(false); } break; } } if (workBox.Web.CurrentUser == null) { return(false); } if (workBox.CurrentUserIsBusinessAdmin() || workBox.CurrentUserIsSystemAdmin()) { return(true); } if (workBox.CurrentUserIsOwner() && AllowOwnersToUse) { return(true); } if (workBox.CurrentUserIsInvolved() && AllowInvolvedToUse) { return(true); } if (workBox.CurrentUserCanVisit() && AllowVisitorsToUse) { return(true); } return(false); }
public WBLink(WorkBox workbox, bool visitingNow) { Title = workbox.Title; URL = workbox.Url; UniqueID = workbox.UniqueID; SPWebGUID = workbox.Web.ID.ToString(); if (visitingNow) { TicksWhenVisitedString = DateTime.Now.Ticks.ToString(); } UsingTicksWhenVisited = visitingNow; }
/// <summary> /// Performs any necessary work to change the default values of the WBAction as set in /// the WBCollection to be appropriate for the current user within the context of a specific WorkBox. /// </summary> /// <param name="workBox"></param> public void SpecialiseForCurrentContext(WorkBox workBox) { ActionUrl = ActionUrl.WBxReplaceTokens(workBox); if (IsEnabled) { // The button might be enabled in general, but maybe we should disable // the button in the current context. // // Unfortunately the logic for some buttons is slightly different: IsEnabled = enableLogic(workBox); } }
protected override void CreateChildControls() { Label timeRemaining = new Label(); this.Controls.Add(timeRemaining); timeRemaining.CssClass = "wbf-time-to-auto-close"; try { WorkBox workBox = WorkBox.GetIfWorkBox(SPContext.Current); if (workBox != null) { DateTime endTime = workBox.calculateAutoCloseDate(); if (endTime.Year == WBRecordsType.YEAR_REPRESENTING_A_PERMANENT_DATE) { timeRemaining.Text = "This work box will not auto close."; } else { if (endTime < DateTime.Now) { timeRemaining.Text = "No time remaining before auto close."; } else { TimeSpan timeSpan = endTime - DateTime.Now; timeRemaining.Text = String.Format("{0} Days {1} Hours {2} Minutes", timeSpan.Days, timeSpan.Hours, timeSpan.Minutes); } } workBox.Dispose(); } else { timeRemaining.Text = "You can only use this web part on a work box."; } } catch (Exception e) { WBLogging.Generic.Unexpected("Error: " + e.Message); timeRemaining.Text = "An error occurred"; } }
protected void Page_Unload(object sender, EventArgs e) { if (manager != null) { manager.Dispose(); manager = null; } if (workBox != null) { workBox.Dispose(); workBox = null; } }
protected void editButton_OnClick(object sender, EventArgs e) { WBAction editAction = WorkBox.GetAction(WBAction.ACTION_KEY__EDIT_PROPERTIES); if (editAction.IsEnabled) { SPUtility.Redirect(editAction.ActionUrl, SPRedirectFlags.Trusted, Context); } else { ErrorMessageLabel.Text = "You don't have permission to edit the work box properties"; } //WBLogging.Debug("Got an action URL for edit page as being: " + editAction.ActionUrl); }
protected void WorkBoxButton_onClick(object sender, EventArgs e) { WorkBox caseFileWorkBox = WorkBox.Collection.FindByLocalID(LocalID.Text.Trim()); if (caseFileWorkBox != null) { GoToNextPage( WorkBox.PUBLISHING_OUT_DESTINATION_TYPE__WORK_BOX, caseFileWorkBox.Title, caseFileWorkBox.Url); } else { GoToGenericOKPage("Counldn't find case file work box", "It was not possible to find the case file work box with local ID = " + LocalID.Text); } }
/// <summary> /// An item was deleted. /// </summary> public override void ItemDeleting(SPItemEventProperties properties) { String workBoxURL = properties.ListItem.WBxGetAsString(WBColumn.WorkBoxURL); if (!String.IsNullOrEmpty(workBoxURL)) { using (WorkBox workBox = new WorkBox(workBoxURL)) { // We're doing this like this in order trigger an asynchronous closure of the work box: workBox.Item.WBxSet(WBColumn.WorkBoxStatusChangeRequest, "Close"); workBox.JustUpdate(); } } base.ItemDeleted(properties); }
protected void Page_Load(object sender, EventArgs e) { WorkBox workBox = WorkBox.GetIfWorkBox(SPContext.Current); if (workBox != null) { LinkToHome = workBox.Web.Url; if (TextForLink == "") { TextForLink = workBox.Web.Title; } // This wont do anything because the web and site come from context, but still: workBox.Dispose(); } }
private String addWorkBoxResults(WBCollection collection, SPListItemCollection workBoxResults) { if (workBoxResults == null || workBoxResults.Count == 0) { return(""); } // String html = "<table cellpadding=\"2\">\n"; String html = ""; foreach (SPListItem item in workBoxResults) { using (WorkBox workBox = new WorkBox(collection, item)) { bool include = false; if (ShowAllUserCanVisit && workBox.CurrentUserCanVisit()) { include = true; } else if (ShowAllUserInvolved && workBox.CurrentUserIsInvolved()) { include = true; } else if (workBox.CurrentUserIsOwner()) { include = true; } if (include) { html += string.Format("<tr class=\"wbf-work-box\"><td><img src=\"{0}\"/></td><td><a href=\"{1}\">{2}</a></td><td><a href=\"{3}\">{4}</a></td><td>{5}</td></tr>\n", "/_layouts/images/WorkBoxFramework/work-box-16.png", workBox.Url, workBox.Title, workBox.OwningTeam.TeamSiteUrl, workBox.OwningTeam.Name, workBox.DateCreated.ToString("d")); } } } // html += "</table>\n"; return(html); }
protected void changeOwnerButton_OnClick(object sender, EventArgs e) { // The event should only be processed if there is no other need to render the page again if (!pageRenderingRequired) { // Now to save the current value of the Involved Teams field: WorkBox.OwningTeam = new WBTeam(WorkBox.Teams, OwningTeamField.Text); WorkBox.AuditLogEntry("Changed owner", "Owning team: " + WorkBox.OwningTeam.Name); WorkBox.Update(); DisposeWorkBox(); CloseDialogAndRefresh(); } }