public static string BuildPeoplePickerSearchUrlSuffix(AddressBook.Mode mode, string itemId, RecipientItemType recipientWell) { StringBuilder stringBuilder = new StringBuilder('&' + "ctx" + '='); stringBuilder.Append((int)mode); stringBuilder.Append('&' + "id" + '='); stringBuilder.Append(Utilities.UrlEncode(itemId)); stringBuilder.Append('&' + "rw" + '='); stringBuilder.Append((int)recipientWell); return(stringBuilder.ToString()); }
public AddressBookSearchViewState(ClientViewState lastClientViewState, AddressBook.Mode mode, string addressBookToSearch, string searchString, int pageNumber, StoreObjectId itemId, string itemChangeKey, RecipientItemType recipientWell, ColumnId sortColumnId, SortOrder sortOrder) : base(lastClientViewState, mode, pageNumber, itemId, itemChangeKey, recipientWell, sortColumnId, sortOrder) { this.searchLocation = addressBookToSearch; this.searchString = searchString; ISearchViewState searchViewState = lastClientViewState as ISearchViewState; if (searchViewState != null) { this.lastClientViewStateBeforeSearch = searchViewState.ClientViewStateBeforeSearch(); return; } this.lastClientViewStateBeforeSearch = lastClientViewState; }
public static AddressBook.Mode TryReadAddressBookMode(HttpRequest request, AddressBook.Mode defaultValue) { string queryStringParameter = Utilities.GetQueryStringParameter(request, "ctx", false); if (string.IsNullOrEmpty(queryStringParameter)) { return(defaultValue); } int num; if (!int.TryParse(queryStringParameter, out num) || num < 0 || num > 4) { throw new OwaInvalidRequestException("Invalid context value in the query string parameter"); } return((AddressBook.Mode)num); }
// Token: 0x0600007A RID: 122 RVA: 0x00004F20 File Offset: 0x00003120 public AddressBookViewState(ClientViewState lastClientViewState, AddressBook.Mode mode, int pageNumber, StoreObjectId itemId, string itemChangeKey, RecipientItemType recipientWell, ColumnId sortColumnId, SortOrder sortOrder) { this.mode = mode; this.pageNumber = pageNumber; this.itemId = itemId; this.itemChangeKey = itemChangeKey; this.recipientWell = recipientWell; this.sortColumnId = sortColumnId; this.sortOrder = sortOrder; AddressBookViewState addressBookViewState = lastClientViewState as AddressBookViewState; if (addressBookViewState != null) { this.previousViewState = addressBookViewState.PreviousViewState; return; } this.previousViewState = lastClientViewState; }
public static Item GetItem(UserContext userContext, AddressBook.Mode viewMode, StoreObjectId itemId, string changeKey) { Item result = null; if (viewMode == AddressBook.Mode.EditMessage || viewMode == AddressBook.Mode.EditMeetingResponse) { if (!string.IsNullOrEmpty(changeKey)) { result = Utilities.GetItem <MessageItem>(userContext, itemId, changeKey, new PropertyDefinition[0]); } else { result = Utilities.GetItem <MessageItem>(userContext, itemId, new PropertyDefinition[0]); } } else if (viewMode == AddressBook.Mode.EditCalendar) { CalendarItemBase calendarItemBase; EditCalendarItemHelper.GetCalendarItem(userContext, itemId, null, changeKey, true, out calendarItemBase); result = calendarItemBase; } return(result); }
internal static bool IsEditingMode(AddressBook.Mode addressBookMode) { return(addressBookMode == AddressBook.Mode.EditMessage || addressBookMode == AddressBook.Mode.EditCalendar || addressBookMode == AddressBook.Mode.EditMeetingResponse); }
public PreFormActionResponse Execute(OwaContext owaContext, out ApplicationElement applicationElement, out string type, out string state, out string action) { if (owaContext == null) { throw new ArgumentNullException("owaContext"); } UserContext userContext = owaContext.UserContext; HttpRequest request = owaContext.HttpContext.Request; string[] array = null; applicationElement = ApplicationElement.Item; type = string.Empty; action = string.Empty; state = string.Empty; if (!Utilities.IsPostRequest(request)) { return(userContext.LastClientViewState.ToPreFormActionResponse()); } PreFormActionResponse preFormActionResponse = new PreFormActionResponse(); string formParameter = Utilities.GetFormParameter(request, "hidAB"); int num = 0; StoreObjectId storeObjectId = null; string changeKey = null; string[] array2 = formParameter.Split(new char[] { ';' }); if (array2 != null && array2.Length > 0) { if (string.CompareOrdinal(array2[0], "Ad") == 0) { num = 1; } else { if (string.CompareOrdinal(array2[0], "Con") != 0) { throw new OwaInvalidRequestException("Invalid search location for addressbook"); } num = 2; } } string action2 = owaContext.FormsRegistryContext.Action; if (action2 == null) { throw new OwaInvalidRequestException("Action query string parameter is missing"); } object obj = AddressBookPreFormAction.actionParser.Parse(action2); AddressBookPreFormAction.Action action3 = (AddressBookPreFormAction.Action)obj; string text = request.Form["chkRcpt"]; if (!string.IsNullOrEmpty(text)) { array = text.Split(new char[] { ',' }); } AddressBook.Mode mode = AddressBookHelper.TryReadAddressBookMode(request, AddressBook.Mode.None); if (AddressBook.IsEditingMode(mode)) { string formParameter2 = Utilities.GetFormParameter(request, "hidid", false); changeKey = Utilities.GetFormParameter(request, "hidchk", false); if (!string.IsNullOrEmpty(formParameter2)) { storeObjectId = Utilities.CreateStoreObjectId(userContext.MailboxSession, formParameter2); if (storeObjectId == null) { throw new OwaInvalidRequestException("ItemId cannot be null"); } } } switch (action3) { case AddressBookPreFormAction.Action.Done: if (AddressBook.IsEditingMode(mode)) { using (Item item = AddressBookHelper.GetItem(userContext, mode, storeObjectId, changeKey)) { if (array != null && array.Length > 0) { RecipientItemType type2 = RecipientItemType.To; string formParameter3 = Utilities.GetFormParameter(request, "hidrw"); if (!string.IsNullOrEmpty(formParameter3)) { int num2; if (!int.TryParse(formParameter3, out num2) || num2 < 1 || num2 > 3) { type2 = RecipientItemType.To; } else { type2 = (RecipientItemType)num2; } } if (num == 1) { AddressBookHelper.AddRecipientsToDraft(array, item, type2, userContext); } else if (num == 2) { AddressBookHelper.AddContactsToDraft(item, type2, userContext, array); } } preFormActionResponse = AddressBookHelper.RedirectToEdit(userContext, item, mode); break; } } throw new OwaInvalidRequestException("This action must be in editing mode"); case AddressBookPreFormAction.Action.Mail: if (array != null && array.Length > 0) { using (Item item2 = MessageItem.Create(userContext.MailboxSession, userContext.DraftsFolderId)) { item2[ItemSchema.ConversationIndexTracking] = true; if (num == 1) { AddressBookHelper.AddRecipientsToDraft(array, item2, RecipientItemType.To, userContext); } else if (num == 2) { AddressBookHelper.AddContactsToDraft(item2, RecipientItemType.To, userContext, array); } preFormActionResponse.ApplicationElement = ApplicationElement.Item; preFormActionResponse.Type = "IPM.Note"; preFormActionResponse.Action = "Open"; preFormActionResponse.State = "Draft"; preFormActionResponse.AddParameter("id", item2.Id.ObjectId.ToBase64String()); break; } } preFormActionResponse.ApplicationElement = ApplicationElement.Item; preFormActionResponse.Type = "IPM.Note"; preFormActionResponse.Action = "New"; break; case AddressBookPreFormAction.Action.MeetingRequest: preFormActionResponse.ApplicationElement = ApplicationElement.Item; preFormActionResponse.Type = "IPM.Appointment"; if (array != null && array.Length > 0) { using (CalendarItemBase calendarItemBase = EditCalendarItemHelper.CreateDraft(userContext, userContext.CalendarFolderId)) { calendarItemBase.IsMeeting = true; if (num == 1) { AddressBookHelper.AddRecipientsToDraft(array, calendarItemBase, RecipientItemType.To, userContext); } else if (num == 2) { AddressBookHelper.AddContactsToDraft(calendarItemBase, RecipientItemType.To, userContext, array); } preFormActionResponse.Action = "Open"; EditCalendarItemHelper.CreateUserContextData(userContext, calendarItemBase); break; } } preFormActionResponse.AddParameter("mr", "1"); preFormActionResponse.Action = "New"; break; case AddressBookPreFormAction.Action.Close: if (AddressBook.IsEditingMode(mode)) { using (Item item3 = AddressBookHelper.GetItem(userContext, mode, storeObjectId, changeKey)) { preFormActionResponse = AddressBookHelper.RedirectToEdit(userContext, item3, mode); break; } } throw new OwaInvalidRequestException("This action must be in editing mode"); case AddressBookPreFormAction.Action.AddToContacts: { string type3 = "IPM.Contact"; string text2 = null; if (array == null || array.Length != 1) { throw new OwaInvalidRequestException("User must select some recipient to add and can only add one recipient to contacts at one time"); } ADObjectId adobjectId = DirectoryAssistance.ParseADObjectId(array[0]); if (adobjectId == null) { throw new OwaADObjectNotFoundException(); } IRecipientSession recipientSession = Utilities.CreateADRecipientSession(Culture.GetUserCulture().LCID, true, ConsistencyMode.FullyConsistent, true, userContext); ADRecipient adrecipient = recipientSession.Read(adobjectId); if (adrecipient == null) { throw new OwaADObjectNotFoundException(); } using (ContactBase contactBase = ContactUtilities.AddADRecipientToContacts(userContext, adrecipient)) { if (contactBase != null) { contactBase.Load(); text2 = contactBase.Id.ObjectId.ToBase64String(); type3 = contactBase.ClassName; } } preFormActionResponse.ApplicationElement = ApplicationElement.Item; preFormActionResponse.Type = type3; if (text2 != null) { preFormActionResponse.Action = "Open"; preFormActionResponse.State = "Draft"; preFormActionResponse.AddParameter("id", text2); } else { preFormActionResponse.Action = "New"; } break; } default: throw new OwaInvalidRequestException("Invalid request for addressbook preformaction"); } return(preFormActionResponse); }
public PreFormActionResponse Execute(OwaContext owaContext, out ApplicationElement applicationElement, out string type, out string state, out string action) { if (owaContext == null) { throw new ArgumentNullException("owaContext"); } HttpContext httpContext = owaContext.HttpContext; UserContext userContext = owaContext.UserContext; HttpRequest request = httpContext.Request; applicationElement = ApplicationElement.Item; type = string.Empty; action = string.Empty; state = string.Empty; if (!Utilities.IsPostRequest(request)) { return(userContext.LastClientViewState.ToPreFormActionResponse()); } PreFormActionResponse preFormActionResponse = new PreFormActionResponse(); if (owaContext.FormsRegistryContext.Action == null) { throw new OwaInvalidRequestException("Action is missing"); } string formParameter = Utilities.GetFormParameter(request, "hidid", true); StoreObjectId storeObjectId = Utilities.CreateStoreObjectId(userContext.MailboxSession, formParameter); string action2; if ((action2 = owaContext.FormsRegistryContext.Action) != null) { if (!(action2 == "Mail")) { if (!(action2 == "MeetingRequest")) { if (action2 == "Delete") { goto IL_1E9; } if (!(action2 == "AddRcpt")) { goto IL_33E; } AddressBook.Mode mode = AddressBookHelper.TryReadAddressBookMode(request, AddressBook.Mode.None); if (mode != AddressBook.Mode.EditMessage && mode != AddressBook.Mode.EditMeetingResponse && mode != AddressBook.Mode.EditCalendar) { throw new OwaInvalidRequestException("Not in edit mode"); } string queryStringParameter = Utilities.GetQueryStringParameter(request, "id", false); StoreObjectId itemId = null; if (!string.IsNullOrEmpty(queryStringParameter)) { itemId = Utilities.CreateStoreObjectId(userContext.MailboxSession, queryStringParameter); } string queryStringParameter2 = Utilities.GetQueryStringParameter(request, "chk", false); RecipientItemType type2 = (RecipientItemType)RequestParser.TryGetIntValueFromQueryString(request, "rw", 1); using (Item item = AddressBookHelper.GetItem(userContext, mode, itemId, queryStringParameter2)) { Participant participant = Utilities.CreateParticipantFromQueryString(userContext, request); if (participant != null) { AddressBookHelper.AddParticipantToItem(item, type2, participant); CalendarItemBase calendarItemBase = item as CalendarItemBase; if (calendarItemBase != null) { EditCalendarItemHelper.CreateUserContextData(userContext, calendarItemBase); } else if (item is MessageItem) { AddressBookHelper.SaveItem(item); } } return(AddressBookHelper.RedirectToEdit(userContext, item, mode)); } goto IL_33E; } } else { using (MessageItem messageItem = MessageItem.Create(userContext.MailboxSession, userContext.DraftsFolderId)) { messageItem[ItemSchema.ConversationIndexTracking] = true; AddressBookHelper.AddContactsToDraft(messageItem, RecipientItemType.To, userContext, new string[] { storeObjectId.ToBase64String() }); preFormActionResponse.AddParameter("id", messageItem.Id.ObjectId.ToBase64String()); preFormActionResponse.ApplicationElement = ApplicationElement.Item; preFormActionResponse.Type = "IPM.Note"; preFormActionResponse.Action = "Open"; preFormActionResponse.State = "Draft"; return(preFormActionResponse); } } using (CalendarItemBase calendarItemBase2 = EditCalendarItemHelper.CreateDraft(userContext, userContext.CalendarFolderId)) { calendarItemBase2.IsMeeting = true; AddressBookHelper.AddContactsToDraft(calendarItemBase2, RecipientItemType.To, userContext, new string[] { storeObjectId.ToBase64String() }); preFormActionResponse.Action = "Open"; preFormActionResponse.ApplicationElement = ApplicationElement.Item; preFormActionResponse.Type = calendarItemBase2.ClassName; EditCalendarItemHelper.CreateUserContextData(userContext, calendarItemBase2); return(preFormActionResponse); } IL_1E9: string formParameter2 = Utilities.GetFormParameter(request, "hidcmdpst", true); if (formParameter2 == "d") { Utilities.DeleteItems(userContext, DeleteItemFlags.SoftDelete, new StoreId[] { storeObjectId }); } else { if (!(formParameter2 == "m")) { throw new OwaInvalidRequestException("Unknown delete command"); } Utilities.DeleteItems(userContext, DeleteItemFlags.MoveToDeletedItems, new StoreId[] { storeObjectId }); } userContext.ForceNewSearch = true; preFormActionResponse = userContext.LastClientViewState.ToPreFormActionResponse(); return(preFormActionResponse); } IL_33E: throw new OwaInvalidRequestException("Invalid action for readcontact preformaction"); }
public static PreFormActionResponse RedirectToEdit(UserContext userContext, Item item, AddressBook.Mode viewMode) { AddressBookViewState addressBookViewState = userContext.LastClientViewState as AddressBookViewState; if (addressBookViewState != null) { userContext.LastClientViewState = addressBookViewState.PreviousViewState; } PreFormActionResponse preFormActionResponse = new PreFormActionResponse(); preFormActionResponse.ApplicationElement = ApplicationElement.Item; if (item.Id != null) { preFormActionResponse.AddParameter("id", item.Id.ObjectId.ToBase64String()); } preFormActionResponse.Action = "Open"; if (viewMode == AddressBook.Mode.EditMessage || viewMode == AddressBook.Mode.EditMeetingResponse) { preFormActionResponse.State = "Draft"; } preFormActionResponse.Type = item.ClassName; return(preFormActionResponse); }