Ejemplo n.º 1
0
 private static void AddEnableRelations(MenuRenderingEventArgs eventArgs, UmbracoObjectTypes objectType, UrlHelper urlHelper)
 {
     if (objectType == UmbracoObjectTypes.DocumentType || objectType == UmbracoObjectTypes.MediaType)
     {
         var menuItem = new MenuItem("enableRelations", "Enable relations");
         menuItem.LaunchDialogView(urlHelper.Content("~/App_Plugins/RelationEditor/enablerelations.html"), "Enable relations");
         eventArgs.Menu.Items.Add(menuItem);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Adds the "Create Folder" action to the folder's menu.
 /// </summary>
 /// <param name="menu">
 /// The menu items.
 /// </param>
 public void AddCreateFolderAction(MenuItemCollection menu)
 {
     var path = "/App_Plugins/formulate/menu-actions/createFolder.html";
     var menuItem = new MenuItem()
     {
         Alias = "createFolder",
         Icon = "formulate-create-folder",
         Name = LocalizationHelper.GetMenuItemName("Create Folder")
     };
     menuItem.LaunchDialogView(path, "Create Folder");
     menu.Items.Add(menuItem);
 }
Ejemplo n.º 3
0
        private static void AddEditRelations(MenuRenderingEventArgs eventArgs, UmbracoObjectTypes type, string alias, UrlHelper urlHelper)
        {
            var typeConfig = Configuration.Get(type, alias);

            if (!typeConfig.Enabled || !typeConfig.EnabledRelations.Any())
            {
                return;
            }
            var menuItem = new MenuItem("editRelations", "Edit relations");

            menuItem.LaunchDialogView(urlHelper.Content("~/App_Plugins/RelationEditor/editrelations.html"), "Edit relations");
            eventArgs.Menu.Items.Add(menuItem);
        }
Ejemplo n.º 4
0
 void TreeControllerBase_MenuRendering(TreeControllerBase sender, MenuRenderingEventArgs e)
 {
     if (sender.TreeAlias == "content"
         && sender.Security.CurrentUser.UserType.Alias == "admin"
         && e.NodeId != "-1" && e.NodeId != "-20")
     {
         var mi = new MenuItem("pageNotFound", "404 page");
         mi.Icon = "document";
         mi.LaunchDialogView("/App_Plugins/PageNotFoundManager/Backoffice/Dialogs/dialog.html", "404 Page");
         mi.SeperatorBefore = true;
         e.Menu.Items.Insert(e.Menu.Items.Count - 1, mi);
     }
 }
 void TreeControllerBase_MenuRendering(TreeControllerBase sender, MenuRenderingEventArgs e)
 {
     var user = sender.Security.CurrentUser;
     var path = "/App_Plugins/UserGroupPermissions/Views/ApplyUserGroupPermissions.html";
     var title = "Apply User Group Permissions";
     var treeType = e.QueryStrings.Get("treeType");
     var section = e.QueryStrings.Get("section");
     var validTree = "users".InvariantEquals(treeType) && "users".InvariantEquals(section);
     var strUserId = e.NodeId ?? "";
     var userId = default(int);
     var validUserId = int.TryParse(strUserId, out userId) ? userId > 0 : false;
     var validUser = user.IsAdmin();
     if (validTree && validUserId && validUser)
     {
         var menuItem = new MenuItem("ApplyUserGroupPermissions", "Apply Group Permissions")
         {
             Icon = "vcard"
         };
         menuItem.LaunchDialogView(path, title);
         e.Menu.Items.Add(menuItem);
     }
 }
        private void AddMenuItem(MenuItemCollection menu, string name, string alias = null, string icon = null, string view = null)
        {
            var menuItem = new MenuItem { Name = name };

            if (alias != null)
            {
                menuItem.Alias = alias;
            }

            if (icon != null)
            {
                menuItem.Icon = icon;
            }

            if (view != null)
            {
                menuItem.LaunchDialogView(VIEWS_ROOT + view + ".html", name);
            }

            menu.Items.Add(menuItem);
        }
Ejemplo n.º 7
0
        private void AddPurgeCacheForContentMenu(TreeControllerBase sender, MenuRenderingEventArgs args)
        {
            if(sender.TreeAlias != "content")
            {
                //We aren't dealing with the content menu
                return;
            }

            MenuItem menuItem = new MenuItem("purgeCache", "Purge Cloudflare Cache");

            menuItem.Icon = "umbracoflare-tiny";

            menuItem.LaunchDialogView("/App_Plugins/UmbracoFlare/backoffice/treeViews/PurgeCacheDialog.html", "Purge Cloudflare Cache");

            args.Menu.Items.Insert(args.Menu.Items.Count - 1, menuItem);
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Adds the "Create Validation" action with the specified ID used
 /// as the parent for the validation that is created.
 /// </summary>
 /// <param name="menu">
 /// The menu to add the action to.
 /// </param>
 /// <param name="entityId">
 /// The ID of the entity to create the validation under.
 /// If null, the validation will be created at the root.
 /// </param>
 public void AddCreateValidationAction(MenuItemCollection menu,
     Guid? entityId = null)
 {
     var path = "/App_Plugins/formulate/menu-actions/createValidation.html";
     var menuItem = new MenuItem()
     {
         Alias = "createValidation",
         Icon = "folder",
         Name = "Create Validation"
     };
     if (entityId.HasValue)
     {
         path = path + "?under=" + GuidHelper.GetString(entityId.Value);
     }
     menuItem.LaunchDialogView(path, "Create Validation");
     menu.Items.Add(menuItem);
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Adds the "Delete Validation" action to the validation node.
 /// </summary>
 /// <param name="menu">
 /// The menu to add the action to.
 /// </param>
 public void AddDeleteValidationAction(MenuItemCollection menu)
 {
     var path = "/App_Plugins/formulate/menu-actions/deleteValidation.html";
     var menuItem = new MenuItem()
     {
         Alias = "deleteValidation",
         Icon = "folder",
         Name = "Delete Validation"
     };
     menuItem.LaunchDialogView(path, "Delete Validation");
     menu.Items.Add(menuItem);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Adds the "Move" action to the menu.
 /// </summary>
 /// <param name="menu">
 /// The menu items to add the action to.
 /// </param>
 /// <param name="folder">
 /// The folder.
 /// </param>
 public void AddMoveFolderAction(MenuItemCollection menu, Folder folder)
 {
     var path = "/App_Plugins/formulate/menu-actions/moveFolder.html";
     var menuItem = new MenuItem()
     {
         Alias = "moveFolder",
         Icon = "formulate-move",
         Name = LocalizationHelper.GetMenuItemName("Move")
     };
     var titleFormat = @"Move ""{0}"" Folder";
     var title = string.Format(titleFormat, folder.Name);
     menuItem.LaunchDialogView(path, title);
     menu.Items.Add(menuItem);
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Adds the "Delete Configured Form" action to the configured form node.
 /// </summary>
 /// <param name="menu">
 /// The menu to add the action to.
 /// </param>
 public void AddDeleteAction(MenuItemCollection menu)
 {
     var path = "/App_Plugins/formulate/menu-actions/deleteConfiguredForm.html";
     var menuItem = new MenuItem()
     {
         Alias = "deleteConfiguredForm",
         Icon = "formulate-delete",
         Name = LocalizationHelper.GetMenuItemName("Delete Configuration")
     };
     menuItem.LaunchDialogView(path, "Delete Configuration");
     menu.Items.Add(menuItem);
 }
Ejemplo n.º 12
0
        protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings)
        {
            //check if we're rendering the local tree
            if (id == "local")
            {
                var menu = new MenuItemCollection();

                //Default Route = /App_Plugins/NuGet/backoffice/Packages/create-package.html
                //Overwriten Route = /App_Plugins/NuGet/BackOffice/Packages/partials/dialogs/create-package.html
                var createPackageMenu   = new MenuItem("create-package", "Create Package");
                createPackageMenu.Icon  = "brick"; //CSS class name without the icon- prefix - icon-brick
                createPackageMenu.NavigateToRoute("nuget/Packages/create/package");
                menu.Items.Add(createPackageMenu);

                //Default Route = /App_Plugins/NuGet/backoffice/Packages/convert-package.html
                //Overwritten Route =
                var convertPackageMenu  = new MenuItem("convert-package", "Convert Package");
                convertPackageMenu.Icon = "cloud-upload"; //CSS class name without the icon- prefix - icon-cloud-upload
                convertPackageMenu.LaunchDialogView("/App_Plugins/NuGet/BackOffice/Packages/partials/dialogs/convert-package.html", "Convert Package");
                menu.Items.Add(convertPackageMenu);

                return menu;
            }

            //if not the local-packages node (aka Local Packages node) do nothing
            return null;
        }
        // A context menu is rendering.
        void TreeControllerBase_MenuRendering(TreeControllerBase sender, MenuRenderingEventArgs e)
        {

            // Variables.
            var path = "/App_Plugins/UserGroupPermissions/Views/SetUserGroupPermissions.html";
            var title = "User Group Permissions";

            // Initial check (in content tree and on a node).
            IUser currentUser = sender.Security.CurrentUser;
            var showMenuItem = sender.TreeAlias == "content";
            var strNodeId = e.NodeId;
            var nodeId = default(int);
            if (showMenuItem && int.TryParse(strNodeId, out nodeId))
            {
                showMenuItem = nodeId >= 0;
            }
            else
            {
                showMenuItem = false;
            }

            // Check permissions for non-admin users.
            if (showMenuItem && !currentUser.IsAdmin())
            {
                showMenuItem = false;
                var userService = ApplicationContext.Current.Services.UserService;
                var permissions = userService.GetPermissions(currentUser, nodeId);
                var letter = MenuActions.UserGroupPermissions.Instance.Letter.ToString();
                if(permissions.Any(x => x.AssignedPermissions.InvariantContains(letter)))
                {
                    showMenuItem = true;
                }
            }

            // Add a custom menu item in the content tree.
            if (showMenuItem)
            {

                var menuItem = new MenuItem("UserGroupPermissions", "User Group Permissions")
                {
                    Icon = "vcard"
                };

                menuItem.LaunchDialogView(path, title);

                var permissionsIndex = e.Menu.Items.FindIndex(x =>
                    "Permissions".InvariantEquals(x.Name) ||
                    "Permissions".InvariantEquals(x.Alias));

                // Attempt to insert after the existing "Permissions" menu item.
                if (permissionsIndex >= 0)
                {
                    e.Menu.Items.Insert(permissionsIndex + 1, menuItem);
                }
                else
                {
                    e.Menu.Items.Add(menuItem);
                }

            }

        }