Exemplo n.º 1
0
 public JsonResult CutCopyPage(int pageId, string name, int parentId, bool isCopy)
 {
     if ((UserProfile.isCurrentUserAdmin) || UserProfile.CurrentUser.HasPermission(AccessPermissions.PAGE_CREATION))
     {
         PagesDB db = new PagesDB();
         if (isCopy)
         {
             IPortalTemplateServices services = PortalTemplateFactory.GetPortalTemplateServices(new PortalTemplateRepository());
             int newpageid = services.CopyPage(pageId, name + "- Copy");
             db.UpdatePageParent(newpageid, parentId, this.PortalSettings.PortalID);
             return(Json(new { pageId = newpageid }));
         }
         else
         {
             db.UpdatePageParent(pageId, parentId, this.PortalSettings.PortalID);
             return(Json(new { pageId = pageId }));
         }
     }
     else
     {
         string errorMessage = General.GetString("ACCESS_DENIED", "You don't have permissin to cut page", this);
         if (isCopy)
         {
             errorMessage = General.GetString("ACCESS_DENIED", "You don't have permissin to copy page", this);
         }
         return(Json(new { error = true, errorMess = errorMessage }));
     }
 }
Exemplo n.º 2
0
        public JsonResult moveNode(int pageID, int newParent, int idOldNode, int selectedposition)
        {
            //Cache clearing
            Appleseed.Framework.Web.SqlUrlBuilderProvider.ClearCachePageUrl(pageID);
            Appleseed.Framework.Web.UrlBuilderHelper.ClearUrlElements(pageID);
            CurrentCache.RemoveAll("_PageNavigationSettings_");
            PortalSettings.RemovePortalSettingsCache(pageID, PortalSettings.PortalAlias);
            Appleseed.Framework.Providers.AppleseedSiteMapProvider.AppleseedSiteMapProvider.ClearAllAppleseedSiteMapCaches();
            PortalSettings.UpdatePortalSettingParentPageCache(newParent, pageID);

            if (UserProfile.isCurrentUserAdmin || UserProfile.CurrentUser.HasPermission(AccessPermissions.PAGE_EDITING))
            {
                PagesDB db = new PagesDB();
                this.PortalPages = db.GetPagesFlat(this.PortalSettings.PortalID);
                db.UpdatePageParent(Convert.ToInt32(pageID), Convert.ToInt32(newParent), this.PortalSettings.PortalID);
                int order;
                if (Convert.ToInt32(idOldNode) == -1)
                {
                    order = 9999;
                }
                else
                {
                    List <PageStripDetails> childPages = new PagesDB().GetPagesinPage(this.PortalSettings.PortalID, newParent).Where(pg => pg.PageID != pageID).ToList();
                    if (childPages.Count == 0)
                    {
                        order = 0;
                    }
                    else
                    {
                        if (selectedposition < childPages.Count)
                        {
                            order = childPages[selectedposition].PageOrder - 1;
                        }
                        else
                        {
                            order = childPages[childPages.Count - 1].PageOrder + 1;
                        }
                    }
                }
                db.UpdatePageOrder(Convert.ToInt32(pageID), order);
                this.OrderPages();
                return(Json(""));
            }
            else
            {
                this.OrderPages();
                string errorMessage = General.GetString("ACCESS_DENIED", "You don't have permissin to move page", this);
                return(Json(new { error = true, errorMess = errorMessage }));
            }
        }
        public void moveNode(int pageID, int newParent, int idOldNode)
        {
            PagesDB db = new PagesDB();

            this.PortalPages = db.GetPagesFlat(this.PortalSettings.PortalID);

            db.UpdatePageParent(pageID, newParent, this.PortalSettings.PortalID);
            int order;

            if (idOldNode == -1)
            {
                order = 9999;
            }
            else
            {
                order = this.getPageOrder(idOldNode) - 1;
            }

            db.UpdatePageOrder(pageID, order);
            this.OrderPages();
        }
Exemplo n.º 4
0
 public JsonResult create(string pageid, string pagename)
 {
     try
     {
         if ((UserProfile.isCurrentUserAdmin) || UserProfile.CurrentUser.HasPermission(AccessPermissions.PAGE_CREATION))
         {
             pageid = pageid.Trim('"');
             PagesDB db = new PagesDB();
             this.PortalPages = db.GetPagesFlat(this.PortalSettings.PortalID);
             var t = new PageItem
             {
                 Name  = General.GetString("TAB_NAME", "New Page Name"),
                 ID    = -1,
                 Order = 990000
             };
             if (!string.IsNullOrEmpty(pagename))
             {
                 t.Name = pagename;
             }
             this.PortalPages.Add(t);
             var tabs = new PagesDB();
             t.ID = tabs.AddPage(this.PortalSettings.PortalID, t.Name, t.Order);
             db.UpdatePageParent(t.ID, Convert.ToInt32(pageid), this.PortalSettings.PortalID);
             this.OrderPages();
             return(Json(""));
         }
         else
         {
             string errorMessage = General.GetString("ACCESS_DENIED", "You don't have permissin to add new page", this);
             return(Json(new { error = true, errorMess = errorMessage }));
         }
     }
     catch (Exception)
     {
         string errorMessage = General.GetString("ADD_NEW_PAGE_FAILED", "Failed to add new Page", this);
         return(Json(new { error = true, errorMess = errorMessage }));
     }
 }
        public JsonResult create(int id)
        {
            PagesDB db = new PagesDB();

            this.PortalPages = db.GetPagesFlat(this.PortalSettings.PortalID);
            var t = new PageItem
            {
                Name  = General.GetString("TAB_NAME", "New Page Name"),
                ID    = -1,
                Order = 990000
            };

            this.PortalPages.Add(t);

            var tabs = new PagesDB();

            t.ID = tabs.AddPage(this.PortalSettings.PortalID, t.Name, t.Order);

            db.UpdatePageParent(t.ID, id, this.PortalSettings.PortalID);

            this.OrderPages();
            //JsonResult treeData = GetTreeData();
            return(Json(""));
        }
        public JsonResult Clone(int id, int parentId)
        {
            try
            {
                var      generalModuleDef = Guid.Parse("F9F9C3A4-6E16-43B4-B540-984DDB5F1CD2");
                object[] queryargs        = { generalModuleDef, PortalSettings.PortalID };

                int moduleDefinition;

                try
                {
                    moduleDefinition =
                        new rb_ModuleDefinitions().All(where : "GeneralModDefID = @0 and PortalID = @1", args: queryargs).Single().ModuleDefID;
                }
                catch (Exception e)
                {
                    // Shortcut module doesn't exist in current Portal

                    var modules = new ModulesDB();

                    modules.UpdateModuleDefinitions(
                        generalModuleDef,
                        PortalSettings.PortalID,
                        true);

                    moduleDefinition =
                        new rb_ModuleSettings().All(where : "GeneralModDefID = @0 and PortalID = @1", args: queryargs).Single().ModuleDefID;
                }

                var db = new PagesDB();

                PortalPages = db.GetPagesFlat(PortalSettings.PortalID);
                var t = new PageItem
                {
                    Name  = General.GetString("TAB_NAME", "New Page Name"),
                    ID    = -1,
                    Order = 990000
                };

                PortalPages.Add(t);

                var tabs = new PagesDB();
                t.ID = tabs.AddPage(PortalSettings.PortalID, t.Name, t.Order);

                db.UpdatePageParent(t.ID, parentId, PortalSettings.PortalID);

                OrderPages();
                //JsonResult treeData = GetTreeData();

                // Coping Modules



                var pagesModules = new rb_Modules().All(where : "TabID = @0", args: id);

                foreach (var module in pagesModules)
                {
                    var m = new ModuleItem();
                    m.Title       = module.ModuleTitle;
                    m.ModuleDefID = moduleDefinition;
                    m.Order       = module.ModuleOrder;

                    // save to database
                    var mod = new ModulesDB();

                    m.ID = mod.AddModule(
                        t.ID,
                        m.Order,
                        module.PaneName,
                        module.ModuleTitle,
                        m.ModuleDefID,
                        0,
                        module.AuthorizedEditRoles,
                        module.AuthorizedViewRoles,
                        module.AuthorizedAddRoles,
                        module.AuthorizedDeleteRoles,
                        module.AuthorizedPropertiesRoles,
                        module.AuthorizedMoveModuleRoles,
                        module.AuthorizedDeleteModuleRoles,
                        false,
                        PortalSecurity.GetDeleteModulePermissions(module.ModuleID),
                        false,
                        false,
                        false);

                    var settings = new rb_ModuleSettings();
                    settings.Insert(new { ModuleID = m.ID, SettingName = "LinkedModule", SettingValue = module.ModuleID });
                }



                return(Json(new { pageId = t.ID }));
            }
            catch (Exception e)
            {
                ErrorHandler.Publish(LogLevel.Error, e);
                Response.StatusCode = 500;
                return(Json(""));
            }
        }