示例#1
0
        protected void OnDelete(object sender, EventArgs e)
        {
            if (_currentNode != null)
            {
                _eWeb.AllowUnsafeUpdates = true;
                _eWeb.Update();
                SPNavigationNode eNode = _eWeb.Navigation.GetNodeById(_currentNode.Id);

                // delete the ids from the
                // respective app items first
                switch (_nodeType)
                {
                case "topnav":
                    appHelper.DeleteAppTopNav(_appId, eNode.Id);
                    break;

                case "quiklnch":
                    appHelper.DeleteAppQuickLaunch(_appId, eNode.Id);
                    break;

                default:
                    break;
                }

                eNode.Delete();
                ClearCache();
            }

            Redirect();
        }
        internal static void UpdateNodeLink(string url, int appId, SPNavigationNode node, SPWeb spWeb,
                                            out string message,
                                            out MessageKind messageKind)
        {
            spWeb.AllowUnsafeUpdates = true;

            messageKind = MessageKind.SUCCESS;

            SPList spList = spWeb.Lists.TryGetList("Installed Applications");

            if (spList != null)
            {
                message = string.Format(@"Node: {0}, New URL: {1}, Old URL: {2}", node.Title, url, node.Url);

                var newNode = new SPNavigationNode(node.Title, url, node.IsExternal);

                SPNavigationNode prevNode = null;

                foreach (SPNavigationNode siblingNode in spWeb.Navigation.QuickLaunch.Cast <SPNavigationNode>()
                         .TakeWhile(siblingNode => siblingNode.Id != node.Id))
                {
                    prevNode = siblingNode;
                }

                if (prevNode == null)
                {
                    spWeb.Navigation.QuickLaunch.AddAsLast(newNode);
                }
                else
                {
                    spWeb.Navigation.QuickLaunch.Add(newNode, prevNode);
                }

                node.Delete();

                SPListItem spListItem = spList.GetItemById(appId);

                string nodes = (spListItem["QuickLaunch"] ?? string.Empty).ToString()
                               .Replace(node.Id.ToString(CultureInfo.InvariantCulture),
                                        newNode.Id.ToString(CultureInfo.InvariantCulture));

                if (!nodes.Contains("," + newNode.Id))
                {
                    nodes += "," + newNode.Id;
                }

                spListItem["QuickLaunch"] = nodes;
                spListItem.SystemUpdate();

                API.Applications.CreateQuickLaunchXML(spListItem.ID, spWeb);

                spWeb.AllowUnsafeUpdates = false;
                spWeb.Update();
            }
            else
            {
                throw new Exception("Cannot find the Installed Applications list.");
            }
        }
示例#3
0
 public void Delete()
 {
     m_navigationNode.Delete();
 }