Beispiel #1
0
        /// <summary>
        /// Given the protected modifier the CMSNode.MakeNew method can only be accessed by
        /// derived classes &gt; who by definition knows of its own objectType.
        /// </summary>
        /// <param name="parentId">The newParent CMSNode id</param>
        /// <param name="objectType">The objecttype identifier</param>
        /// <param name="userId">Creator</param>
        /// <param name="level">The level in the tree hieararchy</param>
        /// <param name="text">The name of the CMSNode</param>
        /// <param name="uniqueID">The unique identifier</param>
        /// <returns></returns>
        protected static CMSNode MakeNew(int parentId, Guid objectType, int userId, int level, string text, Guid uniqueID)
        {
            CMSNode parent    = null;
            string  path      = "";
            int     sortOrder = 0;

            if (level > 0)
            {
                parent    = new CMSNode(parentId);
                sortOrder = GetNewDocumentSortOrder(parentId);
                path      = parent.Path;
            }
            else
            {
                path = "-1";
            }

            Database.Execute(
                "INSERT INTO umbracoNode(trashed, parentID, nodeObjectType, nodeUser, level, path, sortOrder, uniqueID, text, createDate) VALUES(@trashed, @parentID, @nodeObjectType, @nodeUser, @level, @path, @sortOrder, @uniqueID, @text, @createDate)",
                new
            {
                trashed        = false,
                parentID       = parentId,
                nodeObjectType = objectType,
                nodeUser       = userId,
                level,
                path,
                sortOrder,
                uniqueID,
                text,
                createDate = DateTime.Now
            });

            CMSNode retVal = new CMSNode(uniqueID);

            retVal.Path = path + "," + retVal.Id;

            // NH 4.7.1 duplicate permissions because of refactor
            if (parent != null)
            {
                IEnumerable <Permission> permissions = Permission.GetNodePermissions(parent);
                foreach (Permission p in permissions)
                {
                    Permission.MakeNew(User.GetUser(p.UserId), retVal, p.PermissionId);
                }
            }

            //event
            NewEventArgs e = new NewEventArgs();

            retVal.FireAfterNew(e);

            return(retVal);
        }
Beispiel #2
0
        /// <summary>
        /// Given the protected modifier the CMSNode.MakeNew method can only be accessed by
        /// derived classes &gt; who by definition knows of its own objectType.
        /// </summary>
        /// <param name="parentId">The newParent CMSNode id</param>
        /// <param name="objectType">The objecttype identifier</param>
        /// <param name="userId">Creator</param>
        /// <param name="level">The level in the tree hieararchy</param>
        /// <param name="text">The name of the CMSNode</param>
        /// <param name="uniqueID">The unique identifier</param>
        /// <returns></returns>
        protected static CMSNode MakeNew(int parentId, Guid objectType, int userId, int level, string text, Guid uniqueID)
        {
            CMSNode parent    = null;
            string  path      = "";
            int     sortOrder = 0;

            if (level > 0)
            {
                parent    = new CMSNode(parentId);
                sortOrder = GetNewDocumentSortOrder(parentId);
                path      = parent.Path;
            }
            else
            {
                path = "-1";
            }

            // Ruben 8/1/2007: I replace this with a parameterized version.
            // But does anyone know what the 'level++' is supposed to be doing there?
            // Nothing obviously, since it's a postfix.

            SqlHelper.ExecuteNonQuery("INSERT INTO umbracoNode(trashed, parentID, nodeObjectType, nodeUser, level, path, sortOrder, uniqueID, text, createDate) VALUES(@trashed, @parentID, @nodeObjectType, @nodeUser, @level, @path, @sortOrder, @uniqueID, @text, @createDate)",
                                      SqlHelper.CreateParameter("@trashed", 0),
                                      SqlHelper.CreateParameter("@parentID", parentId),
                                      SqlHelper.CreateParameter("@nodeObjectType", objectType),
                                      SqlHelper.CreateParameter("@nodeUser", userId),
                                      SqlHelper.CreateParameter("@level", level++),
                                      SqlHelper.CreateParameter("@path", path),
                                      SqlHelper.CreateParameter("@sortOrder", sortOrder),
                                      SqlHelper.CreateParameter("@uniqueID", uniqueID),
                                      SqlHelper.CreateParameter("@text", text),
                                      SqlHelper.CreateParameter("@createDate", DateTime.Now));

            CMSNode retVal = new CMSNode(uniqueID);

            retVal.Path = path + "," + retVal.Id.ToString();

            // NH 4.7.1 duplicate permissions because of refactor
            if (parent != null)
            {
                IEnumerable <Permission> permissions = Permission.GetNodePermissions(parent);
                foreach (Permission p in permissions)
                {
                    Permission.MakeNew(User.GetUser(p.UserId), retVal, p.PermissionId);
                }
            }

            //event
            NewEventArgs e = new NewEventArgs();

            retVal.FireAfterNew(e);

            return(retVal);
        }
Beispiel #3
0
        /// <summary>
        /// Given the protected modifier the CMSNode.MakeNew method can only be accessed by
        /// derived classes &gt; who by definition knows of its own objectType.
        /// </summary>
        /// <param name="parentId">The parent CMSNode id</param>
        /// <param name="objectType">The objecttype identifier</param>
        /// <param name="userId">Creator</param>
        /// <param name="level">The level in the tree hieararchy</param>
        /// <param name="text">The name of the CMSNode</param>
        /// <param name="uniqueID">The unique identifier</param>
        /// <returns></returns>
        protected static CMSNode MakeNew(int parentId, Guid objectType, int userId, int level, string text, Guid uniqueID)
        {
            CMSNode parent;
            string  path      = "";
            int     sortOrder = 0;

            if (level > 0)
            {
                parent    = new CMSNode(parentId);
                sortOrder = parent.ChildCount + 1;
                path      = parent.Path;
            }
            else
            {
                path = "-1";
            }

            // Ruben 8/1/2007: I replace this with a parameterized version.
            // But does anyone know what the 'level++' is supposed to be doing there?
            // Nothing obviously, since it's a postfix.

            SqlHelper.ExecuteNonQuery("INSERT INTO umbracoNode(trashed, parentID, nodeObjectType, nodeUser, level, path, sortOrder, uniqueID, text, createDate) VALUES(@trashed, @parentID, @nodeObjectType, @nodeUser, @level, @path, @sortOrder, @uniqueID, @text, @createDate)",
                                      SqlHelper.CreateParameter("@trashed", 0),
                                      SqlHelper.CreateParameter("@parentID", parentId),
                                      SqlHelper.CreateParameter("@nodeObjectType", objectType),
                                      SqlHelper.CreateParameter("@nodeUser", userId),
                                      SqlHelper.CreateParameter("@level", level++),
                                      SqlHelper.CreateParameter("@path", path),
                                      SqlHelper.CreateParameter("@sortOrder", sortOrder),
                                      SqlHelper.CreateParameter("@uniqueID", uniqueID),
                                      SqlHelper.CreateParameter("@text", text),
                                      SqlHelper.CreateParameter("@createDate", DateTime.Now));

            CMSNode retVal = new CMSNode(uniqueID);

            retVal.Path = path + "," + retVal.Id.ToString();

            //event
            NewEventArgs e = new NewEventArgs();

            retVal.FireAfterNew(e);

            return(retVal);
        }