Beispiel #1
0
        public void AddNewGroup()
        {
            base.ThrowIfCannotActAsOwner();
            string text = ((string)base.GetParameter("SB")).Trim();

            if (text.Length == 0)
            {
                throw new OwaEventHandlerException("User did not provide name for new group", LocalizedStrings.GetNonEncoded(-1749891264), true);
            }
            NavigationNodeGroupSection navigationNodeGroupSection = (NavigationNodeGroupSection)base.GetParameter("GS");
            NavigationNodeCollection   navigationNodeCollection   = NavigationNodeCollection.TryCreateNavigationNodeCollection(base.UserContext, base.UserContext.MailboxSession, navigationNodeGroupSection);
            NavigationNodeGroup        navigationNodeGroup        = NavigationNodeCollection.CreateCustomizedGroup(navigationNodeGroupSection, text);
            Guid navigationNodeGroupClassId = navigationNodeGroup.NavigationNodeGroupClassId;

            navigationNodeCollection.Add(navigationNodeGroup);
            navigationNodeCollection.Save(base.UserContext.MailboxSession);
            navigationNodeCollection = NavigationNodeCollection.TryCreateNavigationNodeCollection(base.UserContext, base.UserContext.MailboxSession, navigationNodeGroupSection);
            navigationNodeGroup      = navigationNodeCollection[navigationNodeCollection.FindGroupById(navigationNodeGroupClassId)];
            NavigationGroupHeaderTreeNode navigationGroupHeaderTreeNode  = new NavigationGroupHeaderTreeNode(base.UserContext, navigationNodeGroup);
            NavigationGroupHeaderTreeNode navigationGroupHeaderTreeNode2 = navigationGroupHeaderTreeNode;

            navigationGroupHeaderTreeNode2.CustomAttributes += " _NF=1";
            this.Writer.Write("<div id=ntn>");
            navigationGroupHeaderTreeNode.RenderUndecoratedNode(this.Writer);
            this.Writer.Write("</div>");
        }
Beispiel #2
0
 internal NavigationGroupHeaderTreeNode(UserContext userContext, NavigationNodeGroup group) : base(userContext)
 {
     this.group = group;
     if (group.NavigationNodeId != null)
     {
         this.id = "f" + group.NavigationNodeId.ObjectId.ToString();
     }
     else
     {
         this.id = "f" + Convert.ToBase64String(Guid.NewGuid().ToByteArray());
     }
     base.IsExpanded          = group.IsExpanded;
     base.HighlightClassName += " trNdGpHdHl";
     base.NodeClassName      += " trNdGpHd";
     base.IsRootNode          = true;
     if (group.NavigationNodeGroupSection != NavigationNodeGroupSection.First)
     {
         base.ChildIndent = 0;
     }
 }
Beispiel #3
0
        public void Remove()
        {
            base.ThrowIfCannotActAsOwner();
            StoreObjectId nodeId = (StoreObjectId)base.GetParameter("srcNId");
            NavigationNodeGroupSection navigationNodeGroupSection = (NavigationNodeGroupSection)base.GetParameter("GS");
            NavigationNodeCollection   navigationNodeCollection   = NavigationNodeCollection.TryCreateNavigationNodeCollection(base.UserContext, base.UserContext.MailboxSession, navigationNodeGroupSection);
            List <OwaStoreObjectId>    list           = new List <OwaStoreObjectId>();
            NavigationNode             navigationNode = navigationNodeCollection.FindNavigationNodeByNodeId(nodeId);

            if (navigationNode == null)
            {
                base.RenderPartialFailure(-289549140, OwaEventHandlerErrorCode.NotSet);
            }
            else
            {
                OperationResult operationResult = (OperationResult)0;
                if (navigationNodeGroupSection != NavigationNodeGroupSection.First)
                {
                    List <NavigationNodeFolder> list2 = new List <NavigationNodeFolder>();
                    if (navigationNode is NavigationNodeFolder)
                    {
                        list2.Add(navigationNode as NavigationNodeFolder);
                    }
                    else if (navigationNode is NavigationNodeGroup)
                    {
                        NavigationNodeGroup navigationNodeGroup = navigationNode as NavigationNodeGroup;
                        foreach (NavigationNodeFolder item in navigationNodeGroup.Children)
                        {
                            list2.Add(item);
                        }
                    }
                    foreach (NavigationNodeFolder navigationNodeFolder in list2)
                    {
                        if (navigationNodeFolder.IsValid)
                        {
                            OwaStoreObjectId owaStoreObjectId = OwaStoreObjectId.CreateFromNavigationNodeFolder(base.UserContext, navigationNodeFolder);
                            MailboxSession   mailboxSession   = owaStoreObjectId.IsArchive ? ((MailboxSession)owaStoreObjectId.GetSession(base.UserContext)) : base.UserContext.MailboxSession;
                            if (navigationNodeFolder.IsFolderInSpecificMailboxSession(mailboxSession))
                            {
                                if (Utilities.IsSpecialFolderForSession(mailboxSession, navigationNodeFolder.FolderId))
                                {
                                    throw new OwaEventHandlerException("Cannot delete default folders.", LocalizedStrings.GetNonEncoded(-1164567320), true);
                                }
                                if (operationResult == (OperationResult)0)
                                {
                                    operationResult = OperationResult.Succeeded;
                                }
                                AggregateOperationResult aggregateOperationResult = mailboxSession.Delete(DeleteItemFlags.MoveToDeletedItems, new StoreId[]
                                {
                                    navigationNodeFolder.FolderId
                                });
                                if (aggregateOperationResult.OperationResult == OperationResult.Succeeded)
                                {
                                    list.Add(OwaStoreObjectId.CreateFromNavigationNodeFolder(base.UserContext, navigationNodeFolder));
                                }
                                else
                                {
                                    operationResult = OperationResult.PartiallySucceeded;
                                }
                            }
                        }
                    }
                    if (operationResult != (OperationResult)0 && list.Count == 0)
                    {
                        operationResult = OperationResult.Failed;
                    }
                    if (operationResult == OperationResult.Failed)
                    {
                        base.RenderPartialFailure(1041829989, OwaEventHandlerErrorCode.NotSet);
                    }
                    else if (operationResult == OperationResult.PartiallySucceeded)
                    {
                        base.RenderPartialFailure(995407892, OwaEventHandlerErrorCode.NotSet);
                    }
                }
                else
                {
                    NavigationNodeFolder navigationNodeFolder2 = navigationNode as NavigationNodeFolder;
                    if (navigationNodeFolder2 != null && navigationNodeFolder2.IsFilteredView)
                    {
                        OwaStoreObjectId owaStoreObjectId2 = OwaStoreObjectId.CreateFromNavigationNodeFolder(base.UserContext, navigationNodeFolder2);
                        using (SearchFolder searchFolder = SearchFolder.Bind(owaStoreObjectId2.GetSession(base.UserContext), owaStoreObjectId2.StoreObjectId, FolderList.FolderTreeQueryProperties))
                        {
                            searchFolder[FolderSchema.SearchFolderAllowAgeout] = true;
                            searchFolder.DisplayName = Utilities.GetRandomNameForTempFilteredView(base.UserContext);
                            searchFolder.Save();
                        }
                    }
                }
                if (operationResult == (OperationResult)0 || operationResult == OperationResult.Succeeded)
                {
                    if (navigationNodeCollection.RemoveFolderOrGroupByNodeId(nodeId) != null)
                    {
                        navigationNodeCollection.Save(base.UserContext.MailboxSession);
                    }
                }
                else if (operationResult == OperationResult.PartiallySucceeded)
                {
                    foreach (OwaStoreObjectId owaStoreObjectId3 in list)
                    {
                        navigationNodeCollection.RemoveFolderByLegacyDNandId(owaStoreObjectId3.MailboxOwnerLegacyDN ?? base.UserContext.MailboxOwnerLegacyDN, owaStoreObjectId3.StoreObjectId);
                    }
                    navigationNodeCollection.Save(base.UserContext.MailboxSession);
                }
            }
            NavigationTreeDirtyFlag navigationTreeDirtyFlag = NavigationTreeDirtyFlag.None;

            if (navigationNodeGroupSection == NavigationNodeGroupSection.First)
            {
                navigationTreeDirtyFlag = NavigationTreeDirtyFlag.Favorites;
            }
            else
            {
                if (list.Count > 0)
                {
                    List <FolderTreeNode> list3 = FolderTreeNode.CreateDeletedNodesWithDirtyCheck(base.UserContext, list, out navigationTreeDirtyFlag);
                    this.Writer.Write("<div id=tn>");
                    foreach (FolderTreeNode folderTreeNode in list3)
                    {
                        folderTreeNode.RenderUndecoratedNode(this.Writer);
                    }
                    this.Writer.Write("</div>");
                }
                switch (navigationNodeGroupSection)
                {
                case NavigationNodeGroupSection.Calendar:
                    navigationTreeDirtyFlag |= NavigationTreeDirtyFlag.Calendar;
                    break;

                case NavigationNodeGroupSection.Contacts:
                    navigationTreeDirtyFlag |= NavigationTreeDirtyFlag.Contact;
                    break;

                case NavigationNodeGroupSection.Tasks:
                    navigationTreeDirtyFlag |= NavigationTreeDirtyFlag.Task;
                    break;
                }
            }
            RenderingUtilities.RenderNavigationTreeDirtyFlag(this.Writer, base.UserContext, navigationTreeDirtyFlag, (NavigationModule[])base.GetParameter("cms"));
        }
        private static NavigationTree CreateFavoriteTreeByFolderLists(UserContext userContext, NavigationNodeCollection navigationCollection, NavigationTree.NormalAndSearchFolderList[] normalAndSearchFolderLists)
        {
            if (navigationCollection.GroupSection != NavigationNodeGroupSection.First)
            {
                throw new ArgumentException("Should pass a collection represents favorites.");
            }
            NavigationTree navigationTree    = new NavigationTree(userContext, new InvisibleRootTreeNode(userContext), NavigationNodeGroupSection.First);
            List <NavigationNodeFolder> list = new List <NavigationNodeFolder>();

            List <StoreObjectId>[] array = new List <StoreObjectId> [normalAndSearchFolderLists.Length];
            for (int i = 0; i < normalAndSearchFolderLists.Length; i++)
            {
                array[i] = new List <StoreObjectId>();
            }
            NavigationNodeGroup           navigationNodeGroup           = navigationCollection[0];
            NavigationGroupHeaderTreeNode navigationGroupHeaderTreeNode = new NavigationGroupHeaderTreeNode(userContext, navigationNodeGroup);

            foreach (NavigationNodeFolder navigationNodeFolder in navigationNodeGroup.Children)
            {
                for (int j = 0; j < normalAndSearchFolderLists.Length; j++)
                {
                    MailboxSession mailboxSession          = normalAndSearchFolderLists[j].MailboxSession;
                    FolderList     deepHierarchyFolderList = normalAndSearchFolderLists[j].DeepHierarchyFolderList;
                    FolderList     searchFolderList        = normalAndSearchFolderLists[j].SearchFolderList;
                    Dictionary <Guid, StoreObjectId> searchFolderGuidToIdMapping = normalAndSearchFolderLists[j].SearchFolderGuidToIdMapping;
                    if (navigationNodeFolder.IsValid && navigationNodeFolder.IsFolderInSpecificMailboxSession(mailboxSession) && navigationNodeFolder.FolderId != null && !navigationNodeFolder.IsFlagSet(NavigationNodeFlags.PublicFolderFavorite))
                    {
                        bool flag = navigationNodeFolder.NavigationNodeType == NavigationNodeType.SmartFolder;
                        if (!flag || (searchFolderList != null && userContext.IsFeatureEnabled(Feature.SearchFolders)))
                        {
                            StoreObjectId folderId;
                            if (flag && !navigationNodeFolder.AssociatedSearchFolderId.Equals(Guid.Empty))
                            {
                                searchFolderGuidToIdMapping.TryGetValue(navigationNodeFolder.AssociatedSearchFolderId, out folderId);
                            }
                            else
                            {
                                folderId = navigationNodeFolder.FolderId;
                            }
                            if (folderId != null)
                            {
                                object[] array2 = flag ? searchFolderList.GetFolderProperties(folderId) : deepHierarchyFolderList.GetFolderProperties(folderId);
                                if (array2 != null)
                                {
                                    string text = (flag ? searchFolderList.GetFolderProperty(folderId, StoreObjectSchema.ContainerClass) : deepHierarchyFolderList.GetFolderProperty(folderId, StoreObjectSchema.ContainerClass)) as string;
                                    if (string.IsNullOrEmpty(text) || ObjectClass.IsOfClass(text, "IPF.Note"))
                                    {
                                        if (navigationNodeFolder.IsFilteredView && !deepHierarchyFolderList.ContainsFolder(navigationNodeFolder.FilterSourceFolder) && !searchFolderList.ContainsFolder(navigationNodeFolder.FilterSourceFolder))
                                        {
                                            list.Add(navigationNodeFolder);
                                            array[j].Add(folderId);
                                        }
                                        else
                                        {
                                            StoreObjectId storeObjectId = null;
                                            if (!flag)
                                            {
                                                StoreObjectId storeObjectId2 = folderId;
                                                while (storeObjectId == null && storeObjectId2 != null)
                                                {
                                                    object folderProperty = deepHierarchyFolderList.GetFolderProperty(storeObjectId2, FolderSchema.Id);
                                                    if (folderProperty == null)
                                                    {
                                                        break;
                                                    }
                                                    storeObjectId2 = ((VersionedId)folderProperty).ObjectId;
                                                    DefaultFolderType defaultFolderType = Utilities.GetDefaultFolderType(mailboxSession, storeObjectId2);
                                                    if (defaultFolderType == DefaultFolderType.Root)
                                                    {
                                                        break;
                                                    }
                                                    object folderProperty2 = deepHierarchyFolderList.GetFolderProperty(storeObjectId2, FolderSchema.AdminFolderFlags);
                                                    if (folderProperty2 is int && (int)folderProperty2 != 0)
                                                    {
                                                        storeObjectId = storeObjectId2;
                                                    }
                                                    else if (Utilities.IsSpecialFolderType(defaultFolderType) && !string.IsNullOrEmpty(deepHierarchyFolderList.GetFolderProperty(storeObjectId2, FolderSchema.ELCPolicyIds) as string))
                                                    {
                                                        storeObjectId = storeObjectId2;
                                                    }
                                                    else
                                                    {
                                                        object folderProperty3 = deepHierarchyFolderList.GetFolderProperty(storeObjectId2, StoreObjectSchema.ParentEntryId);
                                                        if (folderProperty3 is byte[])
                                                        {
                                                            storeObjectId2 = StoreObjectId.FromProviderSpecificId(folderProperty3 as byte[], StoreObjectType.Folder);
                                                        }
                                                        else
                                                        {
                                                            storeObjectId2 = null;
                                                        }
                                                    }
                                                }
                                            }
                                            Dictionary <PropertyDefinition, int> propertyMap = flag ? searchFolderList.QueryPropertyMap : deepHierarchyFolderList.QueryPropertyMap;
                                            navigationGroupHeaderTreeNode.AddChild(new NavigationFolderTreeNode(userContext, navigationNodeFolder, storeObjectId, array2, propertyMap));
                                        }
                                    }
                                    else if (!flag)
                                    {
                                        list.Add(navigationNodeFolder);
                                    }
                                }
                                else if (navigationNodeFolder.IsFilteredView || !flag)
                                {
                                    list.Add(navigationNodeFolder);
                                }
                            }
                        }
                    }
                }
            }
            object folderProperty4 = normalAndSearchFolderLists[0].DeepHierarchyFolderList.GetFolderProperty(userContext.GetRootFolderId(userContext.MailboxSession), ViewStateProperties.TreeNodeCollapseStatus);

            if (folderProperty4 is int)
            {
                navigationGroupHeaderTreeNode.IsExpanded = !Utilities.IsFlagSet((int)folderProperty4, 2);
            }
            else
            {
                navigationGroupHeaderTreeNode.IsExpanded = true;
            }
            navigationTree.RootNode.AddChild(navigationGroupHeaderTreeNode);
            if (list.Count > 0)
            {
                foreach (NavigationNodeFolder navigationNodeFolder2 in list)
                {
                    if (navigationNodeFolder2.NavigationNodeId != null)
                    {
                        navigationCollection.RemoveFolderOrGroupByNodeId(navigationNodeFolder2.NavigationNodeId.ObjectId);
                    }
                }
                navigationCollection.Save(userContext.MailboxSession);
            }
            for (int k = 0; k < array.Length; k++)
            {
                List <StoreObjectId> list2 = array[k];
                if (list2.Count > 0)
                {
                    Utilities.DeleteFolders(normalAndSearchFolderLists[k].MailboxSession, DeleteItemFlags.SoftDelete, list2.ToArray());
                }
            }
            return(navigationTree);
        }