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 }));
     }
 }
        public JsonResult CopyPage(int pageId, string name)
        {
            IPortalTemplateServices services = PortalTemplateFactory.GetPortalTemplateServices(new PortalTemplateRepository());
            int newpageid = services.CopyPage(pageId, name + "- Copy");

            return(Json(new { pageId = newpageid }));
        }
        protected void SerializeBtn_Click(object sender, EventArgs e)
        {
            if (portalList.SelectedIndex != -1)
            {
                IPortalTemplateServices services = PortalTemplateFactory.GetPortalTemplateServices(new PortalTemplateRepository());
                PortalItem p  = (PortalItem)portals[portalList.SelectedIndex];
                bool       ok = services.SerializePortal(p.ID, PortalSettings.PortalAlias, PortalSettings.PortalFullPath);

                if (!ok)
                {
                    DisplayMessage(ErrorMessage, "Export failed (full error logged) <br>");
                }
                else
                {
                    DisplayMessage(SuccessMessage, "Export succeeded! <br>");
                }
            }
            else
            {
                DisplayMessage(ErrorMessage, "You must select a portal <br>");
            }

            LoadTemplatesList();
            templatesList.DataBind();
        }
Exemple #4
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        private void Page_Load(object sender, EventArgs e)
        {
            string editPortal = Request.Params["selectedTemplate"];

            if (editPortal != null)
            {
                if (Page.IsPostBack == false)
                {
                    List <String> lstPortal = new List <string>();
                    lstPortal.Add(editPortal);
                    ddlXMLTemplates.DataSource = lstPortal;
                    ddlXMLTemplates.DataBind();
                }
            }
            else
            {
                // Verify that the current user has access to access this page
                // Removed by Mario Endara <*****@*****.**> (2004/11/04)
                //            if (PortalSecurity.IsInRoles("Admins") == false)
                //                PortalSecurity.AccessDeniedEdit();
                // If this is the first visit to the page, populate the site data
                if (Page.IsPostBack == false)
                {
                    var templateServices = PortalTemplateFactory.GetPortalTemplateServices(new PortalTemplateRepository());


                    ddlXMLTemplates.DataSource = templateServices.GetTemplates(PortalSettings.PortalAlias, PortalSettings.PortalFullPath);
                    ddlXMLTemplates.DataBind();
                    if (ddlXMLTemplates.Items.Count != 0)
                    {
                        ddlXMLTemplates.SelectedIndex = 0;
                    }
                    else
                    {
                        chkUseXMLTemplate.Enabled = false;
                    }
                }
            }
            var chkbox = Request.Params["chkUseXMLTemplate"];

            if (chkbox != null)
            {
                chkUseXMLTemplate.Checked = bool.Parse(Request.Params["chkUseXMLTemplate"]);
            }
            if (chkUseXMLTemplate.Checked == false)
            {
                // Don't use a template portal, so show the EditTable
                // Remove the cache that can be setted by the new Portal, to get a "clean" PortalBaseSetting
                CurrentCache.Remove(Key.PortalBaseSettings());
                EditTable.DataSource = new SortedList(PortalSettings.GetPortalBaseSettings(null));
                EditTable.DataBind();
                EditTable.Visible       = true;
                ddlXMLTemplates.Enabled = false;
            }
            else
            {
                EditTable.Visible       = false;
                ddlXMLTemplates.Enabled = true;
            }
        }
Exemple #5
0
        private int CreatePortal(out bool createdOk)
        {
            string fileName    = ddlXMLTemplates.Text;
            string portalAlias = AliasField.Text;
            string portalName  = TitleField.Text;
            string portalPath  = "/" + PathField.Text;
            IPortalTemplateRepository repository = new PortalTemplateRepository();
            IPortalTemplateServices   services   = PortalTemplateFactory.GetPortalTemplateServices(repository);
            int newPortalID = 1;

            createdOk = services.DeserializePortal(fileName, portalName, portalAlias, portalPath, PortalSettings.PortalFullPath, out newPortalID);
            if (createdOk && !Config.UseSingleUserBase)
            {
                string AdminEmail = "*****@*****.**";

                // Create the stradmin User for the new portal
                UsersDB User = new UsersDB();
                // Create the "Admins" role for the new portal
                Guid roleID = User.AddRole(portalAlias, "Admins");
                Guid userID = User.AddUser("admin", AdminEmail, "admin", portalAlias);
                // Create a new row in a many to many table (userroles)
                // giving the "admins" role to the stradmin user
                User.AddUserRole(roleID, userID, portalAlias);
                PortalsDB portals = new PortalsDB();

                portals.CreatePortalPath(portalPath);
            }
            return(newPortalID);
        }
Exemple #6
0
 public bool SetContentData(int moduleId, HtmlTextDTO content)
 {
     if (content == null || content.DesktopHtml.Equals(string.Empty))
     {
         //si el contenido es nullo es porque no existe ningun registro en htmltext para el modulo
         return(true);
     }
     else
     {
         IPortalTemplateServices services = PortalTemplateFactory.GetPortalTemplateServices(new PortalTemplateRepository());
         return(services.SaveHtmlText(moduleId, content));
     }
 }
Exemple #7
0
        public string GetContentData(int moduleId)
        {
            IPortalTemplateServices services = PortalTemplateFactory.GetPortalTemplateServices(new PortalTemplateRepository());
            HtmlTextDTO             _html    = services.GetHtmlTextDTO(moduleId);

            if (_html == null)
            {
                return(string.Empty);
            }
            else
            {
                System.IO.StringWriter xout = new System.IO.StringWriter();
                XmlSerializer          xs   = new XmlSerializer(typeof(HtmlTextDTO));
                xs.Serialize(xout, _html);
                return(xout.ToString());
            }
        }
Exemple #8
0
        public bool SetContentData(int moduleId, string content)
        {
            if (content == null || content.Equals(string.Empty))
            {
                //si el contenido es nullo es porque no existe ningun registro en htmltext para el modulo
                return(true);
            }
            else
            {
                IPortalTemplateServices services = PortalTemplateFactory.GetPortalTemplateServices(new PortalTemplateRepository());
                HtmlTextDTO             _html    = new HtmlTextDTO();
                System.IO.StringReader  xin      = new System.IO.StringReader(content);
                XmlSerializer           xs       = new XmlSerializer(typeof(HtmlTextDTO));
                _html = (HtmlTextDTO)xs.Deserialize(xin);

                return(services.SaveHtmlText(moduleId, _html));
            }
        }
 public Portals()
 {
     templateServices = PortalTemplateFactory.GetPortalTemplateServices(new PortalTemplateRepository());
 }