Esempio n. 1
0
        private static bool DeleteUserRoleInternal(int portalId, int userId, int roleId)
        {
            var roleController = new RoleController();
            var user = UserController.GetUserById(portalId, userId);
            var userRole = roleController.GetUserRole(portalId, userId, roleId);
            var portalController = new PortalController();
            bool delete = true;
            var portal = portalController.GetPortal(portalId);
            if (portal != null && userRole != null)
            {
                if (CanRemoveUserFromRole(portal, userId, roleId))
                {
                    provider.RemoveUserFromRole(portalId, user, userRole);
                    var objEventLog = new EventLogController();
                    objEventLog.AddLog(userRole, PortalController.GetCurrentPortalSettings(), UserController.GetCurrentUserInfo().UserID, "", EventLogController.EventLogType.ROLE_UPDATED);

                    //Remove the UserInfo from the Cache, as it has been modified
                    DataCache.ClearUserCache(portalId, user.Username);
                    TestableRoleController.Instance.ClearRoleCache(portalId);
                }
                else
                {
                    delete = false;
                }
            }
            return delete;
        }
Esempio n. 2
0
        public IHttpHandler GetDnnHttpHandler(RequestContext requestContext, int portal, int tab, string[] passThrough)
        {
            PortalController pcontroller = new PortalController();
            PortalInfo pinfo = pcontroller.GetPortal(portal);
            PortalAliasController pacontroller = new PortalAliasController();
            PortalAliasCollection pacollection = pacontroller.GetPortalAliasByPortalID(portal);
            //pacollection.
            //PortalSettings psettings = new PortalSettings(pinfo);
            PortalSettings psettings = new PortalSettings(tab, portal);               // 64 is the stats tab. TODO: get by page name and not hardcoded id
            foreach (string key in pacollection.Keys)
            {
                psettings.PortalAlias = pacollection[key];
            }
            TabController tcontroller = new TabController();
            // psettings.ActiveTab = tcontroller.GetTab(57, 0, true);                  // 57 is the profile tab.
            requestContext.HttpContext.Items["PortalSettings"] = psettings;

            requestContext.HttpContext.Items["UrlRewrite:OriginalUrl"] = requestContext.HttpContext.Request.RawUrl;
            //UserInfo uinfo = requestContext.HttpContext.User == null ? new UserInfo() : UserController.GetUserByName(psettings.PortalId, requestContext.HttpContext.User.Identity.Name);
            UserInfo uinfo = requestContext.HttpContext.User == null ? new UserInfo() : UserController.GetCachedUser(psettings.PortalId, requestContext.HttpContext.User.Identity.Name);
            requestContext.HttpContext.Items["UserInfo"] = uinfo;
            foreach (string s in passThrough)
            {
                requestContext.HttpContext.Items[s] = requestContext.RouteData.Values[s];
            }
            IHttpHandler page = BuildManager.CreateInstanceFromVirtualPath(VirtualPath, typeof(DotNetNuke.Framework.PageBase)) as IHttpHandler;
            return page;
        }
 public void MustHaveSandboxedPaymentSettings()
 {
     var portalController = new PortalController();
     var site = portalController.GetPortal(0);
     if (site.ProcessorPassword == string.Empty)
     {
         PortalController.UpdatePortalSetting(0, "paypalsandbox", "true");
         //uses PayPal sandbox account.
         site.ProcessorUserId = "PayPal";
         site.ProcessorPassword = "******";
         site.ProcessorUserId = "*****@*****.**";
         portalController.UpdatePortalInfo(site);
     }
     WebConfigManager.TouchConfig(PhysicalPath);
 }
Esempio n. 4
0
        private Dictionary<string, string> GetSkins(string skinRoot)
        {
            // load host skins
            var skins = SkinController.GetSkins(null, skinRoot, SkinScope.Host).ToDictionary(skin => skin.Key, skin => skin.Value);

            if (IncludePortalSkins)
            {
                // load portal skins
                var portalController = new PortalController();
                var portal = portalController.GetPortal(PortalId);

                foreach (var skin in SkinController.GetSkins(portal, skinRoot, SkinScope.Site))
                {
                    skins.Add(skin.Key, skin.Value);
                }
            }
            return skins;
        }
Esempio n. 5
0
        /// <summary>
        /// GET Portals
        /// </summary>
        /// <returns></returns>
        public static List <PortalInfo> GetAllPortals()
        {
            var pList = new List <PortalInfo>();
            var objPC = new DotNetNuke.Entities.Portals.PortalController();

            var list = objPC.GetPortals();

            if (list == null || list.Count == 0)
            {
                //Problem with DNN6 GetPortals when ran from scheduler.
                PortalInfo objPInfo;
                var        flagdeleted = 0;

                for (var lp = 0; lp <= 500; lp++)
                {
                    objPInfo = objPC.GetPortal(lp);
                    if ((objPInfo != null))
                    {
                        pList.Add(objPInfo);
                    }
                    else
                    {
                        // some portals may be deleted, skip 3 to see if we've got to the end of the list.
                        // VERY weak!!! shame!! but issue with a DNN6 version only.
                        if (flagdeleted == 3)
                        {
                            break;
                        }
                        flagdeleted += 1;
                    }
                }
            }
            else
            {
                foreach (PortalInfo p in list)
                {
                    pList.Add(p);
                }
            }


            return(pList);
        }
Esempio n. 6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.ContentType = "application/json";
        object json = new { Status = "Login Failed" };

        if (!string.IsNullOrWhiteSpace(Request.Form["u"]))
        {
            aqufitEntities entities = new aqufitEntities();
            string         uname    = Request.Form["u"];
            string         password = Request.Form["p"];
            if (uname.Contains("@"))
            {   // this is an email login
                User user = entities.UserSettings.OfType <User>().FirstOrDefault(u => u.UserEmail == uname);
                if (user == null)
                {
                    json = new { Status = "Email ERROR" };
                    Response.Write(json);
                    Response.Flush();
                    Response.End();
                    return;
                }
                uname = user.UserName;
            }
            uname = uname.ToLower();
            DotNetNuke.Security.Membership.UserLoginStatus status = DotNetNuke.Security.Membership.UserLoginStatus.LOGIN_FAILURE;
            DotNetNuke.Entities.Portals.PortalController   pc     = new DotNetNuke.Entities.Portals.PortalController();
            DotNetNuke.Entities.Portals.PortalInfo         pi     = pc.GetPortal(0);
            UserInfo uinfo = UserController.UserLogin(0, uname, password, null, pi.PortalName, DotNetNuke.Services.Authentication.AuthenticationLoginBase.GetIPAddress(), ref status, true);
            if (status == DotNetNuke.Security.Membership.UserLoginStatus.LOGIN_SUCCESS || status == DotNetNuke.Security.Membership.UserLoginStatus.LOGIN_SUPERUSER)
            {
                UserSettings usersettings = entities.UserSettings.OfType <User>().FirstOrDefault(u => u.UserKey == uinfo.UserID && u.PortalKey == 0);
                if (!usersettings.Guid.HasValue)
                {   // we only add a UUID if there was none before.. this is so the "remember me" on the desktop site will still work.
                    usersettings.Guid = Guid.NewGuid();
                    entities.SaveChanges();
                }
                json = new { Status = "SUCCESS", Token = usersettings.Guid.ToString(), UserId = usersettings.Id, Username = usersettings.UserName };
            }
        }
        Response.Write(serializer.Serialize(json));
        Response.Flush();
        Response.End();
    }
Esempio n. 7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     Response.ContentType = "application/json";
     object json = new { Status = "Login Failed" };
     if (!string.IsNullOrWhiteSpace(Request.Form["u"]))
     {
         aqufitEntities entities = new aqufitEntities();
         string uname = Request.Form["u"];
         string password = Request.Form["p"];
         if (uname.Contains("@"))
         {   // this is an email login
             User user = entities.UserSettings.OfType<User>().FirstOrDefault(u => u.UserEmail == uname);
             if (user == null)
             {
                 json = new { Status = "Email ERROR" };
                 Response.Write(json);
                 Response.Flush();
                 Response.End();
                 return;
             }
             uname = user.UserName;
         }
         uname = uname.ToLower();
         DotNetNuke.Security.Membership.UserLoginStatus status = DotNetNuke.Security.Membership.UserLoginStatus.LOGIN_FAILURE;
         DotNetNuke.Entities.Portals.PortalController pc = new DotNetNuke.Entities.Portals.PortalController();
         DotNetNuke.Entities.Portals.PortalInfo pi = pc.GetPortal(0);
         UserInfo uinfo = UserController.UserLogin(0, uname, password, null, pi.PortalName, DotNetNuke.Services.Authentication.AuthenticationLoginBase.GetIPAddress(), ref status, true);
         if (status == DotNetNuke.Security.Membership.UserLoginStatus.LOGIN_SUCCESS || status == DotNetNuke.Security.Membership.UserLoginStatus.LOGIN_SUPERUSER)
         {
             UserSettings usersettings = entities.UserSettings.OfType<User>().FirstOrDefault(u => u.UserKey == uinfo.UserID && u.PortalKey == 0);
             if (!usersettings.Guid.HasValue)
             {   // we only add a UUID if there was none before.. this is so the "remember me" on the desktop site will still work.
                 usersettings.Guid = Guid.NewGuid();
                 entities.SaveChanges();
             }
             json = new { Status = "SUCCESS", Token = usersettings.Guid.ToString(), UserId = usersettings.Id, Username = usersettings.UserName };
         }
     }
     Response.Write(serializer.Serialize( json ));
     Response.Flush();
     Response.End();
 }
        /// <summary>
        /// LoadStyleSheet loads the stylesheet
        /// </summary>
        /// <history>
        /// 	[cnurse]	9/8/2004	Created
        /// </history>
        private void LoadStyleSheet()
        {
            string strUploadDirectory = "";

            PortalController objPortalController = new PortalController();
            PortalInfo objPortal = objPortalController.GetPortal( intPortalId );
            if( objPortal != null )
            {
                strUploadDirectory = objPortal.HomeDirectoryMapPath;
            }

            // read CSS file
            if( File.Exists( strUploadDirectory + "portal.css" ) )
            {
                StreamReader objStreamReader;
                objStreamReader = File.OpenText( strUploadDirectory + "portal.css" );
                txtStyleSheet.Text = objStreamReader.ReadToEnd();
                objStreamReader.Close();
            }
        }
Esempio n. 9
0
        //Get portal list to overcome problem with DNN6 GetPortals when ran from scheduler.
        public static List <PortalInfo> GetAllPortals()
        {
            var        pList = new List <PortalInfo>();
            var        objPC = new DotNetNuke.Entities.Portals.PortalController();
            PortalInfo objPInfo;

            for (var lp = 0; lp <= 500; lp++)
            {
                objPInfo = objPC.GetPortal(lp);
                if ((objPInfo != null))
                {
                    pList.Add(objPInfo);
                }
                else
                {
                    break;
                }
            }

            return(pList);
        }
Esempio n. 10
0
        /// <summary>
        /// Delete/Remove a User from a Role
        /// </summary>
        /// <param name="PortalId">The Id of the Portal</param>
        /// <param name="UserId">The Id of the User</param>
        /// <param name="RoleId">The Id of the Role</param>
        /// <returns></returns>
        public bool DeleteUserRole(int PortalId, int UserId, int RoleId)
        {
            UserInfo objUser = UserController.GetUser(PortalId, UserId, false);
            UserRoleInfo objUserRole = GetUserRole(PortalId, UserId, RoleId);

            PortalController objPortals = new PortalController();
            bool blnDelete = true;

            PortalInfo objPortal = objPortals.GetPortal(PortalId);
            if (objPortal != null)
            {
                if ((objPortal.AdministratorId != UserId || objPortal.AdministratorRoleId != RoleId) && objPortal.RegisteredRoleId != RoleId)
                {
                    provider.RemoveUserFromRole(PortalId, objUser, objUserRole);
                }
                else
                {
                    blnDelete = false;
                }
            }

            return blnDelete;
        }
Esempio n. 11
0
        private void BindSkinsAndContainers()
        {
            var portalController = new PortalController();
            var portal = portalController.GetPortal(PortalSettings.PortalId);

            var skins = SkinController.GetSkins(portal, SkinController.RootSkin, SkinScope.All)
                                         .ToDictionary(skin => skin.Key, skin => skin.Value);
            var containers = SkinController.GetSkins(portal, SkinController.RootContainer, SkinScope.All)
                                                    .ToDictionary(skin => skin.Key, skin => skin.Value);

            drpSkin.Items.Clear();
            drpSkin.DataSource = skins;
            drpSkin.DataBind();
            //drpSkin.Items.Insert(0, new ListItem(Localization.GetString("DefaultSkin", LocalResourceFile), ""));
            drpSkin.InsertItem(0, Localization.GetString("DefaultSkin", LocalResourceFile), "");

            drpContainer.Items.Clear();
            drpContainer.DataSource = containers;
            drpContainer.DataBind();
            //drpContainer.Items.Insert(0, new ListItem(Localization.GetString("DefaultContainer", LocalResourceFile), ""));
            drpContainer.InsertItem(0, Localization.GetString("DefaultContainer", LocalResourceFile), "");
        }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            try
            {
                UserInfo objUserInfo = null;
                int intUserID = -1;
                if (Request.IsAuthenticated)
                {
                    objUserInfo = UserController.GetCurrentUserInfo();
                    if (objUserInfo != null)
                    {
                        intUserID = objUserInfo.UserID;
                    }
                }
                int intRoleId = -1;
                if (Request.QueryString["roleid"] != null)
                {
                    intRoleId = int.Parse(Request.QueryString["roleid"]);
                }
                string strProcessorUserId = "";
                var objPortalController = new PortalController();
                PortalInfo objPortalInfo = objPortalController.GetPortal(PortalSettings.PortalId);
                if (objPortalInfo != null)
                {
                    strProcessorUserId = objPortalInfo.ProcessorUserId;
                }
                Dictionary<string, string> settings = PortalController.GetPortalSettingsDictionary(PortalSettings.PortalId);
                string strPayPalURL;
                if (intUserID != -1 && intRoleId != -1 && !String.IsNullOrEmpty(strProcessorUserId))
                {
                    // Sandbox mode
                    if (settings.ContainsKey("paypalsandbox") && !String.IsNullOrEmpty(settings["paypalsandbox"]) && settings["paypalsandbox"] == "true")
                    {
                        strPayPalURL = "https://www.sandbox.paypal.com/cgi-bin/webscr?";
                    }
                    else
                    {
                        strPayPalURL = "https://www.paypal.com/cgi-bin/webscr?";
                    }

                    if (Request.QueryString["cancel"] != null)
                    {
                        //build the cancellation PayPal URL
                        strPayPalURL += "cmd=_subscr-find&alias=" + Globals.HTTPPOSTEncode(strProcessorUserId);
                    }
                    else
                    {
                        strPayPalURL += "cmd=_ext-enter";
                        var objRoles = new RoleController();
                        RoleInfo objRole = objRoles.GetRole(intRoleId, PortalSettings.PortalId);
                        if (objRole.RoleID != -1)
                        {
                            int intTrialPeriod = 1;
                            if (objRole.TrialPeriod != 0)
                            {
                                intTrialPeriod = objRole.TrialPeriod;
                            }
                            int intBillingPeriod = 1;
                            if (objRole.BillingPeriod != 0)
                            {
                                intBillingPeriod = objRole.BillingPeriod;
                            }

                            //explicitely format numbers using en-US so numbers are correctly built
                            var enFormat = new CultureInfo("en-US");
                            string strService = string.Format(enFormat.NumberFormat, "{0:#####0.00}", objRole.ServiceFee);
                            string strTrial = string.Format(enFormat.NumberFormat, "{0:#####0.00}", objRole.TrialFee);
                            if (objRole.BillingFrequency == "O" || objRole.TrialFrequency == "O")
                            {
                                //build the payment PayPal URL
                                strPayPalURL += "&redirect_cmd=_xclick&business=" + Globals.HTTPPOSTEncode(strProcessorUserId);
                                strPayPalURL += "&item_name=" +
                                                Globals.HTTPPOSTEncode(PortalSettings.PortalName + " - " + objRole.RoleName + " ( " + objRole.ServiceFee.ToString("#.##") + " " +
                                                                       PortalSettings.Currency + " )");
                                strPayPalURL += "&item_number=" + Globals.HTTPPOSTEncode(intRoleId.ToString());
                                strPayPalURL += "&no_shipping=1&no_note=1";
                                strPayPalURL += "&quantity=1";
                                strPayPalURL += "&amount=" + Globals.HTTPPOSTEncode(strService);
                                strPayPalURL += "&currency_code=" + Globals.HTTPPOSTEncode(PortalSettings.Currency);
                            }
                            else //recurring payments
                            {
                                //build the subscription PayPal URL
                                strPayPalURL += "&redirect_cmd=_xclick-subscriptions&business=" + Globals.HTTPPOSTEncode(strProcessorUserId);
                                strPayPalURL += "&item_name=" +
                                                Globals.HTTPPOSTEncode(PortalSettings.PortalName + " - " + objRole.RoleName + " ( " + objRole.ServiceFee.ToString("#.##") + " " +
                                                                       PortalSettings.Currency + " every " + intBillingPeriod + " " + GetBillingFrequencyCode(objRole.BillingFrequency) + " )");
                                strPayPalURL += "&item_number=" + Globals.HTTPPOSTEncode(intRoleId.ToString());
                                strPayPalURL += "&no_shipping=1&no_note=1";
                                if (objRole.TrialFrequency != "N")
                                {
                                    strPayPalURL += "&a1=" + Globals.HTTPPOSTEncode(strTrial);
                                    strPayPalURL += "&p1=" + Globals.HTTPPOSTEncode(intTrialPeriod.ToString());
                                    strPayPalURL += "&t1=" + Globals.HTTPPOSTEncode(objRole.TrialFrequency);
                                }
                                strPayPalURL += "&a3=" + Globals.HTTPPOSTEncode(strService);
                                strPayPalURL += "&p3=" + Globals.HTTPPOSTEncode(intBillingPeriod.ToString());
                                strPayPalURL += "&t3=" + Globals.HTTPPOSTEncode(objRole.BillingFrequency);
                                strPayPalURL += "&src=1";
                                strPayPalURL += "&currency_code=" + Globals.HTTPPOSTEncode(PortalSettings.Currency);
                            }
                        }
                        var ctlList = new ListController();

                        strPayPalURL += "&custom=" + Globals.HTTPPOSTEncode(intUserID.ToString());
                        strPayPalURL += "&first_name=" + Globals.HTTPPOSTEncode(objUserInfo.Profile.FirstName);
                        strPayPalURL += "&last_name=" + Globals.HTTPPOSTEncode(objUserInfo.Profile.LastName);
                        try
                        {
                            if (objUserInfo.Profile.Country == "United States")
                            {
                                ListEntryInfo colList = ctlList.GetListEntryInfo("Region", objUserInfo.Profile.Region);
                                strPayPalURL += "&address1=" +
                                                Globals.HTTPPOSTEncode(Convert.ToString(!String.IsNullOrEmpty(objUserInfo.Profile.Unit) ? objUserInfo.Profile.Unit + " " : "") +
                                                                       objUserInfo.Profile.Street);
                                strPayPalURL += "&city=" + Globals.HTTPPOSTEncode(objUserInfo.Profile.City);
                                strPayPalURL += "&state=" + Globals.HTTPPOSTEncode(colList.Value);
                                strPayPalURL += "&zip=" + Globals.HTTPPOSTEncode(objUserInfo.Profile.PostalCode);
                            }
                        }
                        catch (Exception ex)
                        {
                            //issue getting user address
                            DnnLog.Error(ex);
                        }

                        //Return URL
                        if (settings.ContainsKey("paypalsubscriptionreturn") && !string.IsNullOrEmpty(settings["paypalsubscriptionreturn"]))
                        {
                            strPayPalURL += "&return=" + Globals.HTTPPOSTEncode(settings["paypalsubscriptionreturn"]);
                        }
                        else
                        {
                            strPayPalURL += "&return=" + Globals.HTTPPOSTEncode(Globals.AddHTTP(Globals.GetDomainName(Request)));
                        }

                        //Cancellation URL
                        if (settings.ContainsKey("paypalsubscriptioncancelreturn") && !string.IsNullOrEmpty(settings["paypalsubscriptioncancelreturn"]))
                        {
                            strPayPalURL += "&cancel_return=" + Globals.HTTPPOSTEncode(settings["paypalsubscriptioncancelreturn"]);
                        }
                        else
                        {
                            strPayPalURL += "&cancel_return=" + Globals.HTTPPOSTEncode(Globals.AddHTTP(Globals.GetDomainName(Request)));
                        }

                        //Instant Payment Notification URL
                        if (settings.ContainsKey("paypalsubscriptionnotifyurl") && !string.IsNullOrEmpty(settings["paypalsubscriptionnotifyurl"]))
                        {
                            strPayPalURL += "&notify_url=" + Globals.HTTPPOSTEncode(settings["paypalsubscriptionnotifyurl"]);
                        }
                        else
                        {
                            strPayPalURL += "&notify_url=" + Globals.HTTPPOSTEncode(Globals.AddHTTP(Globals.GetDomainName(Request)) + "/admin/Sales/PayPalIPN.aspx");
                        }
                        strPayPalURL += "&sra=1"; //reattempt on failure
                    }

                    //redirect to PayPal
                    Response.Redirect(strPayPalURL, true);
                }
                else
                {
                    if ((settings.ContainsKey("paypalsubscriptioncancelreturn") && !string.IsNullOrEmpty(settings["paypalsubscriptioncancelreturn"])))
                    {
                        strPayPalURL = settings["paypalsubscriptioncancelreturn"];
                    }
                    else
                    {
                        strPayPalURL = Globals.AddHTTP(Globals.GetDomainName(Request));
                    }

                    //redirect to PayPal
                    Response.Redirect(strPayPalURL, true);
                }
            }
            catch (Exception exc) //Page failed to load
            {
                Exceptions.ProcessPageLoadException(exc);
            }
        }
 protected string GetAboutTooltip(object dataItem)
 {
     string returnValue = string.Empty;
     try
     {
         if ((ModuleContext.PortalSettings.ActiveTab.IsSuperTab))
         {
             int portalID = Convert.ToInt32(DataBinder.Eval(dataItem, "PortalID"));
             if ((portalID != Null.NullInteger && portalID != int.MinValue))
             {
                 var controller = new PortalController();
                 PortalInfo portal = controller.GetPortal(portalID);
                 returnValue = string.Format(Localization.GetString("InstalledOnPortal.Tooltip", LocalResourceFile), portal.PortalName);
             }
             else
             {
                 returnValue = Localization.GetString("InstalledOnHost.Tooltip", LocalResourceFile);
             }
         }
     }
     catch (Exception ex)
     {
         Exceptions.ProcessModuleLoadException(this, ex);
     }
     return returnValue;
 }
Esempio n. 14
0
        private string TokeniseLinks(string content, int portalId)
        {
            //Replace any relative portal root reference by a token "{{PortalRoot}}"
            var portalController = new PortalController();
            var portal = portalController.GetPortal(portalId);
            var portalRoot = UrlUtils.Combine(Globals.ApplicationPath, portal.HomeDirectory);
            if (!portalRoot.StartsWith("/"))
            {
                portalRoot = "/" + portalRoot;
            }
            Regex exp = new Regex(portalRoot, RegexOptions.IgnoreCase);
            content = exp.Replace(content, PortalRootToken);

            return content;
        }
Esempio n. 15
0
        /// <summary>
        /// Exports the selected portal
        /// </summary>
        /// <remarks>
        /// Template will be saved in Portals\_default folder.
        /// An extension of .template will be added to filename if not entered
        /// </remarks>
        /// <history>
        /// 	[VMasanas]	23/09/2004	Created
        /// 	[cnurse]	11/08/2004	Addition of files to template
        /// </history>
        protected void cmdExport_Click( Object sender, EventArgs e )
        {
            try
            {
                if( ! Page.IsValid )
                {
                    return;
                }

                string filename = Globals.HostMapPath + txtTemplateName.Text;
                if( ! filename.EndsWith( ".template" ) )
                {
                    filename += ".template";
                }

                XmlDocument xmlTemplate = new XmlDocument();
                XmlNode nodePortal = xmlTemplate.AppendChild( xmlTemplate.CreateElement( "portal" ) );
                nodePortal.Attributes.Append( XmlUtils.CreateAttribute( xmlTemplate, "version", "3.0" ) );

                //Add template description
                XmlElement node = xmlTemplate.CreateElement( "description" );
                node.InnerXml = Server.HtmlEncode( txtDescription.Text );
                nodePortal.AppendChild( node );

                //Serialize portal settings
                PortalController objportals = new PortalController();
                PortalInfo objportal = objportals.GetPortal( Convert.ToInt32( cboPortals.SelectedValue ) );
                SerializeSettings(xmlTemplate, nodePortal, objportal);

                // Serialize Profile Definitions
                XmlNode nodeProfileDefinitions = nodePortal.AppendChild(xmlTemplate.CreateElement("profiledefinitions"));
                SerializeProfileDefinitions(xmlTemplate, nodeProfileDefinitions, objportal);

                SerializeSettings( xmlTemplate, nodePortal, objportal );

                //Serialize Roles
                XmlNode nodeRoles = nodePortal.AppendChild( xmlTemplate.CreateElement( "roles" ) );
                Hashtable hRoles = SerializeRoles( xmlTemplate, nodeRoles, objportal );

                // Serialize tabs
                XmlNode nodeTabs = nodePortal.AppendChild( xmlTemplate.CreateElement( "tabs" ) );
                SerializeTabs( xmlTemplate, nodeTabs, objportal, hRoles );

                if( chkContent.Checked )
                {
                    //Create Zip File to hold files
                    ZipOutputStream resourcesFile = new ZipOutputStream( File.Create( filename + ".resources" ) );
                    resourcesFile.SetLevel( 6 );

                    // Serialize folders (while adding files to zip file)
                    XmlNode nodeFolders;
                    nodeFolders = nodePortal.AppendChild( xmlTemplate.CreateElement( "folders" ) );
                    SerializeFolders( xmlTemplate, nodeFolders, objportal, ref resourcesFile );

                    //Finish and Close Zip file
                    resourcesFile.Finish();
                    resourcesFile.Close();
                }

                xmlTemplate.Save( filename );
                lblMessage.Text = string.Format( Localization.GetString( "ExportedMessage", this.LocalResourceFile ), filename, null );
            }
            catch( Exception exc )
            {
                Exceptions.ProcessModuleLoadException( this, exc );
            }
        }
Esempio n. 16
0
        private int UpdateHomeTab(int homeTabId)
        {
            var portalController = new PortalController();
            var portalInfo = portalController.GetPortal(PortalId);
            int oldHomeTabId = portalInfo.HomeTabId;
            portalInfo.HomeTabId = homeTabId;

            return oldHomeTabId;
        }
Esempio n. 17
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// cmdUpdate_Click runs when the Update LinkButton is clicked.
        /// It saves the current Site Settings
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// 	[cnurse]	9/9/2004	Modified
        /// 	[aprasad]	1/17/2011	New setting AutoAddPortalAlias
        /// </history>
        /// -----------------------------------------------------------------------------
        protected void UpdatePortal(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                try
                {
                    var portalController = new PortalController();
                    PortalInfo existingPortal = portalController.GetPortal(_portalId);

                    string logo = String.Format("FileID={0}", ctlLogo.FileID);
                    string background = String.Format("FileID={0}", ctlBackground.FileID);

                    //Refresh if Background or Logo file have changed
                    bool refreshPage = (background == existingPortal.BackgroundFile || logo == existingPortal.LogoFile);

                    float hostFee = existingPortal.HostFee;
                    if (!String.IsNullOrEmpty(txtHostFee.Text))
                    {
                        hostFee = float.Parse(txtHostFee.Text);
                    }

                    int hostSpace = existingPortal.HostSpace;
                    if (!String.IsNullOrEmpty(txtHostSpace.Text))
                    {
                        hostSpace = int.Parse(txtHostSpace.Text);
                    }

                    int pageQuota = existingPortal.PageQuota;
                    if (!String.IsNullOrEmpty(txtPageQuota.Text))
                    {
                        pageQuota = int.Parse(txtPageQuota.Text);
                    }

                    int userQuota = existingPortal.UserQuota;
                    if (!String.IsNullOrEmpty(txtUserQuota.Text))
                    {
                        userQuota = int.Parse(txtUserQuota.Text);
                    }

                    int siteLogHistory = existingPortal.SiteLogHistory;
                    if (!String.IsNullOrEmpty(txtSiteLogHistory.Text))
                    {
                        siteLogHistory = int.Parse(txtSiteLogHistory.Text);
                    }

                    DateTime expiryDate = existingPortal.ExpiryDate;
                    if (datepickerExpiryDate.SelectedDate.HasValue)
                    {
                        expiryDate = datepickerExpiryDate.SelectedDate.Value;
                    }

                    int intSplashTabId = Null.NullInteger;
                    if (cboSplashTabId.SelectedItem != null)
                    {
                        intSplashTabId = int.Parse(cboSplashTabId.SelectedItem.Value);
                    }

                    int intHomeTabId = Null.NullInteger;
                    if (cboHomeTabId.SelectedItem != null)
                    {
                        intHomeTabId = int.Parse(cboHomeTabId.SelectedItem.Value);
                    }

                    int intLoginTabId = Null.NullInteger;
                    if (cboLoginTabId.SelectedItem != null)
                    {
                        intLoginTabId = int.Parse(cboLoginTabId.SelectedItem.Value);
                    }
                    int intRegisterTabId = Null.NullInteger;
                    if (cboRegisterTabId.SelectedItem != null)
                    {
                        intRegisterTabId = int.Parse(cboRegisterTabId.SelectedItem.Value);
                    }

                    int intUserTabId = Null.NullInteger;
                    if (cboUserTabId.SelectedItem != null)
                    {
                        intUserTabId = int.Parse(cboUserTabId.SelectedItem.Value);
                    }

                    int intSearchTabId = Null.NullInteger;
                    if (cboSearchTabId.SelectedItem != null)
                    {
                        intSearchTabId = int.Parse(cboSearchTabId.SelectedItem.Value);
                    }

                    if (txtPassword.Attributes["value"] != null)
                    {
                        txtPassword.Attributes["value"] = txtPassword.Text;
                    }

                    var portal = new PortalInfo
                                            {
                                                PortalID = _portalId,
                                                PortalGroupID = existingPortal.PortalGroupID,
                                                PortalName = txtPortalName.Text,
                                                LogoFile = logo,
                                                FooterText = txtFooterText.Text,
                                                ExpiryDate = expiryDate,
                                                UserRegistration = optUserRegistration.SelectedIndex,
                                                BannerAdvertising = optBanners.SelectedIndex,
                                                Currency = currencyCombo.SelectedItem.Value,
                                                AdministratorId = Convert.ToInt32(cboAdministratorId.SelectedItem.Value),
                                                HostFee = hostFee,
                                                HostSpace = hostSpace,
                                                PageQuota = pageQuota,
                                                UserQuota = userQuota,
                                                PaymentProcessor =
                                                    String.IsNullOrEmpty(processorCombo.SelectedValue)
                                                        ? ""
                                                        : processorCombo.SelectedItem.Text,
                                                ProcessorUserId = txtUserId.Text,
                                                ProcessorPassword = txtPassword.Text,
                                                Description = txtDescription.Text,
                                                KeyWords = txtKeyWords.Text,
                                                BackgroundFile = background,
                                                SiteLogHistory = siteLogHistory,
                                                SplashTabId = intSplashTabId,
                                                HomeTabId = intHomeTabId,
                                                LoginTabId = intLoginTabId,
                                                RegisterTabId = intRegisterTabId,
                                                UserTabId = intUserTabId,
                                                SearchTabId = intSearchTabId,
                                                DefaultLanguage = existingPortal.DefaultLanguage,
                                                HomeDirectory = lblHomeDirectory.Text,
                                                CultureCode = SelectedCultureCode
                                            };
                    portalController.UpdatePortalInfo(portal);

                    if (!refreshPage)
                    {
                        refreshPage = (PortalSettings.DefaultAdminSkin == editSkinCombo.SelectedValue) ||
                                        (PortalSettings.DefaultAdminContainer == editContainerCombo.SelectedValue);
                    }

                    PortalController.UpdatePortalSetting(_portalId, ClientResourceSettings.OverrideDefaultSettingsKey, chkOverrideDefaultSettings.Checked.ToString(CultureInfo.InvariantCulture), false);
                    PortalController.UpdatePortalSetting(_portalId, ClientResourceSettings.EnableCompositeFilesKey, chkEnableCompositeFiles.Checked.ToString(CultureInfo.InvariantCulture), false);
                    PortalController.UpdatePortalSetting(_portalId, ClientResourceSettings.MinifyCssKey, chkMinifyCss.Checked.ToString(CultureInfo.InvariantCulture), false);
                    PortalController.UpdatePortalSetting(_portalId, ClientResourceSettings.MinifyJsKey, chkMinifyJs.Checked.ToString(CultureInfo.InvariantCulture), false);

                    PortalController.UpdatePortalSetting(_portalId, "EnableSkinWidgets", chkSkinWidgestEnabled.Checked.ToString(), false);
                    PortalController.UpdatePortalSetting(_portalId, "DefaultAdminSkin", editSkinCombo.SelectedValue, false);
                    PortalController.UpdatePortalSetting(_portalId, "DefaultPortalSkin", portalSkinCombo.SelectedValue, false);
                    PortalController.UpdatePortalSetting(_portalId, "DefaultAdminContainer", editContainerCombo.SelectedValue, false);
                    PortalController.UpdatePortalSetting(_portalId, "DefaultPortalContainer", portalContainerCombo.SelectedValue, false);
                    PortalController.UpdatePortalSetting(_portalId, "EnablePopups", enablePopUpsCheckBox.Checked.ToString(), false);
                    PortalController.UpdatePortalSetting(_portalId, "InlineEditorEnabled", chkInlineEditor.Checked.ToString(), false);
                    PortalController.UpdatePortalSetting(_portalId, "HideFoldersEnabled", chkHideSystemFolders.Checked.ToString(), false);
                    PortalController.UpdatePortalSetting(_portalId, "ControlPanelMode", optControlPanelMode.SelectedItem.Value, false);
                    PortalController.UpdatePortalSetting(_portalId, "ControlPanelVisibility", optControlPanelVisibility.SelectedItem.Value, false);
                    PortalController.UpdatePortalSetting(_portalId, "ControlPanelSecurity", optControlPanelSecurity.SelectedItem.Value, false);

                    PortalController.UpdatePortalSetting(_portalId, "MessagingThrottlingInterval", cboMsgThrottlingInterval.SelectedItem.Value, false);
                    PortalController.UpdatePortalSetting(_portalId, "MessagingRecipientLimit", cboMsgRecipientLimit.SelectedItem.Value, false);
                    PortalController.UpdatePortalSetting(_portalId, "MessagingAllowAttachments", optMsgAllowAttachments.SelectedItem.Value, false);
                    PortalController.UpdatePortalSetting(_portalId, "MessagingProfanityFilters", optMsgProfanityFilters.SelectedItem.Value, false);
                    PortalController.UpdatePortalSetting(_portalId, "MessagingSendEmail", optMsgSendEmail.SelectedItem.Value, false);

                    PortalController.UpdatePortalSetting(_portalId, "paypalsandbox", chkPayPalSandboxEnabled.Checked.ToString(), false);
                    PortalController.UpdatePortalSetting(_portalId, "paypalsubscriptionreturn", txtPayPalReturnURL.Text, false);
                    PortalController.UpdatePortalSetting(_portalId, "paypalsubscriptioncancelreturn", txtPayPalCancelURL.Text, false);
                    PortalController.UpdatePortalSetting(_portalId, "TimeZone", cboTimeZone.SelectedValue, false);

                    new FavIcon(_portalId).Update(ctlFavIcon.FileID);

                    if (IsSuperUser())
                    {
                        PortalController.UpdatePortalSetting(_portalId, "PortalAliasMapping", portalAliasModeButtonList.SelectedValue, false);
                        PortalController.UpdatePortalSetting(_portalId, "DefaultPortalAlias", defaultAliasDropDown.SelectedValue, false);
                        HostController.Instance.Update("AutoAddPortalAlias", chkAutoAddPortalAlias.Checked ? "Y" : "N", true);

                        PortalController.UpdatePortalSetting(_portalId, "SSLEnabled", chkSSLEnabled.Checked.ToString(), false);
                        PortalController.UpdatePortalSetting(_portalId, "SSLEnforced", chkSSLEnforced.Checked.ToString(), false);
                        PortalController.UpdatePortalSetting(_portalId, "SSLURL", AddPortalAlias(txtSSLURL.Text, _portalId), false);
                        PortalController.UpdatePortalSetting(_portalId, "STDURL", AddPortalAlias(txtSTDURL.Text, _portalId), false);
                    }

                    if(registrationFormType.SelectedValue == "1")
                    {
                        var setting = registrationFields.Text;
                        if (!setting.Contains("Email"))
                        {
                            UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("NoEmail", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                            return;
                        }

                        if (!setting.Contains("DisplayName") && Convert.ToBoolean(requireUniqueDisplayName.Value))
                        {
                            PortalController.UpdatePortalSetting(_portalId, "Registration_RegistrationFormType", "0", false);
                            UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("NoDisplayName", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                            return;
                        }

                        PortalController.UpdatePortalSetting(_portalId, "Registration_RegistrationFields", setting);
                    }

                    PortalController.UpdatePortalSetting(_portalId, "Registration_RegistrationFormType", registrationFormType.SelectedValue, false);

                    foreach (DnnFormItemBase item in basicRegistrationSettings.Items)
                    {
                        PortalController.UpdatePortalSetting(_portalId, item.DataField, item.Value.ToString());
                    }

                    foreach (DnnFormItemBase item in standardRegistrationSettings.Items)
                    {
                        PortalController.UpdatePortalSetting(_portalId, item.DataField, item.Value.ToString());
                    }

                    foreach (DnnFormItemBase item in validationRegistrationSettings.Items)
                    {
                        try
                        {
                            var regex = new Regex(item.Value.ToString());
                            PortalController.UpdatePortalSetting(_portalId, item.DataField, item.Value.ToString());
                        }
                        catch
                        {

                            string message = String.Format(Localization.GetString("InvalidRegularExpression", LocalResourceFile),
                                                           Localization.GetString(item.DataField, LocalResourceFile), item.Value);
                            UI.Skins.Skin.AddModuleMessage(this, message, ModuleMessage.ModuleMessageType.RedError);
                            return;
                        }
                    }

                    foreach (DnnFormItemBase item in passwordRegistrationSettings.Items)
                    {
                        PortalController.UpdatePortalSetting(_portalId, item.DataField, item.Value.ToString());
                    }

                    foreach (DnnFormItemBase item in otherRegistrationSettings.Items)
                    {
                        PortalController.UpdatePortalSetting(_portalId, item.DataField, item.Value.ToString());
                    }

                    foreach (DnnFormItemBase item in loginSettings.Items)
                    {
                        PortalController.UpdatePortalSetting(_portalId, item.DataField, item.Value.ToString());
                    }

                    foreach (DnnFormItemBase item in profileSettings.Items)
                    {
                        PortalController.UpdatePortalSetting(_portalId, item.DataField,
                                                                item.Value.GetType().IsEnum
                                                                    ? Convert.ToInt32(item.Value).ToString(CultureInfo.InvariantCulture)
                                                                    : item.Value.ToString()
                                                                );
                    }

                    profileDefinitions.Update();

                    DataCache.ClearPortalCache(PortalId, false);

                    //Redirect to this site to refresh only if admin skin changed or either of the images have changed
                    if (refreshPage)
                    {
                        Response.Redirect(Request.RawUrl, true);
                    }

                    BindPortal(_portalId, SelectedCultureCode);
                }
                catch (Exception exc)
                {
                    Exceptions.ProcessModuleLoadException(this, exc);
                }
                finally
                {
                    DataCache.ClearPortalCache(_portalId, false);
                }
            }
        }
Esempio n. 18
0
        /// <summary>
        /// The GetPortalSettings method builds the site Settings
        /// </summary>
        /// <remarks>
        /// </remarks>
        ///	<param name="TabId">The current tabs id</param>
        ///	<param name="objPortalAliasInfo">The Portal Alias object</param>
        private void GetPortalSettings(int TabId, PortalAliasInfo objPortalAliasInfo)
        {
            PortalController objPortals = new PortalController();
            PortalInfo       objPortal  = null;
            TabController    objTabs    = new TabController();
            ModuleController objModules = new ModuleController();
            ModuleInfo       objModule  = null;
            SkinInfo         objSkin    = null;

            PortalId = objPortalAliasInfo.PortalID;

            // get portal settings
            objPortal = objPortals.GetPortal(PortalId);
            if (objPortal != null)
            {
                this.PortalAlias           = objPortalAliasInfo;
                this.PortalId              = objPortal.PortalID;
                this.PortalName            = objPortal.PortalName;
                this.LogoFile              = objPortal.LogoFile;
                this.FooterText            = objPortal.FooterText;
                this.ExpiryDate            = objPortal.ExpiryDate;
                this.UserRegistration      = objPortal.UserRegistration;
                this.BannerAdvertising     = objPortal.BannerAdvertising;
                this.Currency              = objPortal.Currency;
                this.AdministratorId       = objPortal.AdministratorId;
                this.Email                 = objPortal.Email;
                this.HostFee               = objPortal.HostFee;
                this.HostSpace             = objPortal.HostSpace;
                this.PageQuota             = objPortal.PageQuota;
                this.UserQuota             = objPortal.UserQuota;
                this.AdministratorRoleId   = objPortal.AdministratorRoleId;
                this.AdministratorRoleName = objPortal.AdministratorRoleName;
                this.RegisteredRoleId      = objPortal.RegisteredRoleId;
                this.RegisteredRoleName    = objPortal.RegisteredRoleName;
                this.Description           = objPortal.Description;
                this.KeyWords              = objPortal.KeyWords;
                this.BackgroundFile        = objPortal.BackgroundFile;
                this.GUID            = objPortal.GUID;
                this.SiteLogHistory  = objPortal.SiteLogHistory;
                this.AdminTabId      = objPortal.AdminTabId;
                this.SuperTabId      = objPortal.SuperTabId;
                this.SplashTabId     = objPortal.SplashTabId;
                this.HomeTabId       = objPortal.HomeTabId;
                this.LoginTabId      = objPortal.LoginTabId;
                this.UserTabId       = objPortal.UserTabId;
                this.DefaultLanguage = objPortal.DefaultLanguage;
                this.TimeZoneOffset  = objPortal.TimeZoneOffset;
                this.HomeDirectory   = objPortal.HomeDirectory;
                this.Version         = objPortal.Version;
                this.AdminSkin       = SkinController.GetSkin(SkinInfo.RootSkin, PortalId, SkinType.Admin);
                this.PortalSkin      = SkinController.GetSkin(SkinInfo.RootSkin, PortalId, SkinType.Portal);
                this.AdminContainer  = SkinController.GetSkin(SkinInfo.RootContainer, PortalId, SkinType.Admin);
                this.PortalContainer = SkinController.GetSkin(SkinInfo.RootContainer, PortalId, SkinType.Portal);
                this.Pages           = objPortal.Pages;
                this.Users           = objPortal.Users;

                // set custom properties
                if (Null.IsNull(this.HostSpace))
                {
                    this.HostSpace = 0;
                }
                if (Null.IsNull(this.DefaultLanguage))
                {
                    this.DefaultLanguage = Localization.SystemLocale;
                }
                if (Null.IsNull(this.TimeZoneOffset))
                {
                    this.TimeZoneOffset = Localization.SystemTimeZoneOffset;
                }
                this.HomeDirectory = Globals.ApplicationPath + "/" + objPortal.HomeDirectory + "/";

                // get application version
                Array arrVersion = Globals.glbAppVersion.Split(Convert.ToChar("."));
                int   intMajor   = Convert.ToInt32(arrVersion.GetValue((0)));
                int   intMinor   = Convert.ToInt32(arrVersion.GetValue((1)));
                int   intBuild   = Convert.ToInt32(arrVersion.GetValue((2)));
                this.Version = string.Format("{0}.{1}.{2}", intMajor, intMinor, intBuild);
            }

            //Add each portal Tab to DekstopTabs
            TabInfo objPortalTab = null;

            foreach (KeyValuePair <int, TabInfo> tabPair in objTabs.GetTabsByPortal(this.PortalId))
            {
                // clone the tab object ( to avoid creating an object reference to the data cache )
                objPortalTab = tabPair.Value.Clone();

                // set custom properties
                if (objPortalTab.TabOrder == 0)
                {
                    objPortalTab.TabOrder = 999;
                }
                if (Null.IsNull(objPortalTab.StartDate))
                {
                    objPortalTab.StartDate = DateTime.MinValue;
                }
                if (Null.IsNull(objPortalTab.EndDate))
                {
                    objPortalTab.EndDate = DateTime.MaxValue;
                }
                objPortalTab.IsSuperTab = false;

                this.DesktopTabs.Add(objPortalTab);
            }

            //Add each host Tab to DesktopTabs
            TabInfo objHostTab = null;

            foreach (KeyValuePair <int, TabInfo> tabPair in objTabs.GetTabsByPortal(Null.NullInteger))
            {
                // clone the tab object ( to avoid creating an object reference to the data cache )
                objHostTab            = tabPair.Value.Clone();
                objHostTab.PortalID   = this.PortalId;
                objHostTab.StartDate  = DateTime.MinValue;
                objHostTab.EndDate    = DateTime.MaxValue;
                objHostTab.IsSuperTab = true;

                this.DesktopTabs.Add(objHostTab);
            }

            //At this point the DesktopTabs Collection contains all the Tabs for the current portal
            //verify tab for portal. This assigns the Active Tab based on the Tab Id/PortalId
            if (VerifyPortalTab(PortalId, TabId))
            {
                if (this.ActiveTab != null)
                {
                    // skin
                    if (this.ActiveTab.SkinSrc == "")
                    {
                        if (Globals.IsAdminSkin(this.ActiveTab.IsAdminTab))
                        {
                            objSkin = this.AdminSkin;
                        }
                        else
                        {
                            objSkin = this.PortalSkin;
                        }
                        if (objSkin != null)
                        {
                            this.ActiveTab.SkinSrc = objSkin.SkinSrc;
                        }
                    }
                    if (this.ActiveTab.SkinSrc == "")
                    {
                        if (Globals.IsAdminSkin(this.ActiveTab.IsAdminTab))
                        {
                            this.ActiveTab.SkinSrc = "[G]" + SkinInfo.RootSkin + Globals.glbDefaultSkinFolder + Globals.glbDefaultAdminSkin;
                        }
                        else
                        {
                            this.ActiveTab.SkinSrc = "[G]" + SkinInfo.RootSkin + Globals.glbDefaultSkinFolder + Globals.glbDefaultSkin;
                        }
                    }
                    this.ActiveTab.SkinSrc  = SkinController.FormatSkinSrc(this.ActiveTab.SkinSrc, this);
                    this.ActiveTab.SkinPath = SkinController.FormatSkinPath(this.ActiveTab.SkinSrc);
                    // container
                    if (this.ActiveTab.ContainerSrc == "")
                    {
                        if (Globals.IsAdminSkin(this.ActiveTab.IsAdminTab))
                        {
                            objSkin = this.AdminContainer;
                        }
                        else
                        {
                            objSkin = this.PortalContainer;
                        }
                        if (objSkin != null)
                        {
                            this.ActiveTab.ContainerSrc = objSkin.SkinSrc;
                        }
                    }
                    if (this.ActiveTab.ContainerSrc == "")
                    {
                        if (Globals.IsAdminSkin(this.ActiveTab.IsAdminTab))
                        {
                            this.ActiveTab.ContainerSrc = "[G]" + SkinInfo.RootContainer + Globals.glbDefaultContainerFolder + Globals.glbDefaultAdminContainer;
                        }
                        else
                        {
                            this.ActiveTab.ContainerSrc = "[G]" + SkinInfo.RootContainer + Globals.glbDefaultContainerFolder + Globals.glbDefaultContainer;
                        }
                    }
                    this.ActiveTab.ContainerSrc  = SkinController.FormatSkinSrc(this.ActiveTab.ContainerSrc, this);
                    this.ActiveTab.ContainerPath = SkinController.FormatSkinPath(this.ActiveTab.ContainerSrc);

                    // initialize collections
                    this.ActiveTab.BreadCrumbs = new ArrayList();
                    this.ActiveTab.Panes       = new ArrayList();
                    this.ActiveTab.Modules     = new ArrayList();

                    // get breadcrumbs for current tab
                    GetBreadCrumbsRecursively(this.ActiveTab.BreadCrumbs, this.ActiveTab.TabID);
                }
            }

            Hashtable objPaneModules = new Hashtable();

            // get current tab modules
            foreach (KeyValuePair <int, ModuleInfo> kvp in objModules.GetTabModules(this.ActiveTab.TabID))
            {
                objModule = kvp.Value;

                // clone the module object ( to avoid creating an object reference to the data cache )
                ModuleInfo cloneModule = objModule.Clone();

                // set custom properties
                if (Null.IsNull(cloneModule.StartDate))
                {
                    cloneModule.StartDate = DateTime.MinValue;
                }
                if (Null.IsNull(cloneModule.EndDate))
                {
                    cloneModule.EndDate = DateTime.MaxValue;
                }
                // container
                if (cloneModule.ContainerSrc == "")
                {
                    cloneModule.ContainerSrc = this.ActiveTab.ContainerSrc;
                }
                cloneModule.ContainerSrc  = SkinController.FormatSkinSrc(cloneModule.ContainerSrc, this);
                cloneModule.ContainerPath = SkinController.FormatSkinPath(cloneModule.ContainerSrc);

                // process tab panes
                if (objPaneModules.ContainsKey(cloneModule.PaneName) == false)
                {
                    objPaneModules.Add(cloneModule.PaneName, 0);
                }
                cloneModule.PaneModuleCount = 0;
                if (!cloneModule.IsDeleted)
                {
                    objPaneModules[cloneModule.PaneName] = Convert.ToInt32(objPaneModules[cloneModule.PaneName]) + 1;
                    cloneModule.PaneModuleIndex          = Convert.ToInt32(objPaneModules[cloneModule.PaneName]) - 1;
                }

                this.ActiveTab.Modules.Add(cloneModule);
            }

            // set pane module count
            foreach (ModuleInfo objModuleWithinLoop in this.ActiveTab.Modules)
            {
                objModule = objModuleWithinLoop;
                objModuleWithinLoop.PaneModuleCount = Convert.ToInt32(objPaneModules[objModuleWithinLoop.PaneName]);
            }
        }
Esempio n. 19
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Page_Load runs when the control is loaded
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// 	[cnurse]	9/10/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        /// -----------------------------------------------------------------------------
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            jQuery.RequestDnnPluginsRegistration();

            cboBillingFrequency.SelectedIndexChanged += OnBillingFrequencyIndexChanged;
            cboTrialFrequency.SelectedIndexChanged += OnTrialFrequencyIndexChanged;
            cmdDelete.Click += OnDeleteClick;
            cmdManage.Click += OnManageClick;
            cmdUpdate.Click += OnUpdateClick;
            txtRSVPCode.TextChanged += OnRsvpCodeChanged;

            try
            {
                if ((Request.QueryString["RoleID"] != null))
                {
                    _roleID = Int32.Parse(Request.QueryString["RoleID"]);
                }
                var objPortalController = new PortalController();
                var objPortalInfo = objPortalController.GetPortal(PortalSettings.PortalId);
                if ((objPortalInfo == null || string.IsNullOrEmpty(objPortalInfo.ProcessorUserId)))
                {
					//Warn users about fee based roles if we have a Processor Id
                    lblProcessorWarning.Visible = true;
                }
                else
                {
                    divServiceFee.Visible = true;
                    divBillingPeriod.Visible = true;
                    divTrialFee.Visible = true;
                    divTrialPeriod.Visible = true;
                }
                if (Page.IsPostBack == false)
                {
                    cmdCancel.NavigateUrl = Globals.NavigateURL();

                    var ctlList = new ListController();
                    var colFrequencies = ctlList.GetListEntryInfoItems("Frequency", "");

                    cboBillingFrequency.DataSource = colFrequencies;
                    cboBillingFrequency.DataBind();
                    cboBillingFrequency.Items.FindByValue("N").Selected = true;

                    cboTrialFrequency.DataSource = colFrequencies;
                    cboTrialFrequency.DataBind();
                    cboTrialFrequency.Items.FindByValue("N").Selected = true;

                    securityModeList.Items.Clear();
                    foreach(var enumValue in Enum.GetValues(typeof(SecurityMode)))
                    {
                        var enumName = Enum.GetName(typeof(SecurityMode), enumValue);
                        var enumItem = new ListItem(enumName, ((int)enumValue).ToString(CultureInfo.InvariantCulture));

                        securityModeList.Items.Add(enumItem);
                    }

                    statusList.Items.Clear();
                    foreach (var enumValue in Enum.GetValues(typeof(RoleStatus)))
                    {
                        var enumName = Enum.GetName(typeof(RoleStatus), enumValue);
                        var enumItem = new ListItem(enumName, ((int)enumValue).ToString(CultureInfo.InvariantCulture));

                        statusList.Items.Add(enumItem);
                    }

                    BindGroups();

                    ctlIcon.FileFilter = Globals.glbImageFileTypes;
                    if (_roleID != -1)
                    {
                        lblRoleName.Visible = true;
                        txtRoleName.Visible = false;
                        valRoleName.Enabled = false;

                        var role = TestableRoleController.Instance.GetRole(PortalSettings.PortalId, r => r.RoleID == _roleID);
                        if (role != null)
                        {
                            lblRoleName.Text = role.RoleName;
                            txtDescription.Text = role.Description;
                            if (cboRoleGroups.Items.FindByValue(role.RoleGroupID.ToString(CultureInfo.InvariantCulture)) != null)
                            {
                                cboRoleGroups.ClearSelection();
                                cboRoleGroups.Items.FindByValue(role.RoleGroupID.ToString(CultureInfo.InvariantCulture)).Selected = true;
                            }
                            if (!String.IsNullOrEmpty(role.BillingFrequency))
                            {
                                txtServiceFee.Text = role.ServiceFee.ToString("N2", CultureInfo.CurrentCulture);
                                txtBillingPeriod.Text = role.BillingPeriod.ToString(CultureInfo.InvariantCulture);
                                if (cboBillingFrequency.Items.FindByValue(role.BillingFrequency) != null)
                                {
                                    cboBillingFrequency.ClearSelection();
                                    cboBillingFrequency.Items.FindByValue(role.BillingFrequency).Selected = true;
                                }
                            }
                            if (!String.IsNullOrEmpty(role.TrialFrequency))
                            {
                                txtTrialFee.Text = role.TrialFee.ToString("N2", CultureInfo.CurrentCulture);
                                txtTrialPeriod.Text = role.TrialPeriod.ToString(CultureInfo.InvariantCulture);
                                if (cboTrialFrequency.Items.FindByValue(role.TrialFrequency) != null)
                                {
                                    cboTrialFrequency.ClearSelection();
                                    cboTrialFrequency.Items.FindByValue(role.TrialFrequency).Selected = true;
                                }
                            }

                            if (securityModeList.Items.FindByValue(Convert.ToString((int)role.SecurityMode)) != null)
                            {
                                securityModeList.ClearSelection();
                                securityModeList.Items.FindByValue(Convert.ToString((int)role.SecurityMode)).Selected = true;
                            }

                            if (statusList.Items.FindByValue(Convert.ToString((int)role.Status)) != null)
                            {
                                statusList.ClearSelection();
                                statusList.Items.FindByValue(Convert.ToString((int)role.Status)).Selected = true;
                            }

                            chkIsPublic.Checked = role.IsPublic;
                            chkAutoAssignment.Checked = role.AutoAssignment;
                            txtRSVPCode.Text = role.RSVPCode;
                            if (!String.IsNullOrEmpty(txtRSVPCode.Text))
                            {
                                lblRSVPLink.Text = Globals.AddHTTP(Globals.GetDomainName(Request)) + "/" + Globals.glbDefaultPage + "?rsvp=" + txtRSVPCode.Text + "&portalid=" + PortalId;
                            }
                            ctlIcon.Url = role.IconFile;

                            UpdateFeeTextBoxes();
                            cmdManage.Visible = role.Status == RoleStatus.Approved;
                        }
                        else //security violation attempt to access item not related to this Module
                        {
                            Response.Redirect(Globals.NavigateURL("Security Roles"));
                        }

                        if (_roleID == PortalSettings.AdministratorRoleId || _roleID == PortalSettings.RegisteredRoleId)
                        {
                            cmdDelete.Visible = false;
                            ActivateControls(false);
                        }
                        if (_roleID == PortalSettings.RegisteredRoleId)
                        {
                            cmdManage.Visible = false;
                        }
                    }
                    else
                    {
                        cmdDelete.Visible = false;
                        cmdManage.Visible = false;
                        lblRoleName.Visible = false;
                        txtRoleName.Visible = true;

                        statusList.SelectedIndex = 1;

						//select default role group id
						if(Request.QueryString["RoleGroupID"] != null)
						{
							var roleGroupID = Request.QueryString["RoleGroupID"];
							if (cboRoleGroups.Items.FindByValue(roleGroupID) != null)
							{
								cboRoleGroups.ClearSelection();
								cboRoleGroups.Items.FindByValue(roleGroupID).Selected = true;
							}
						}
                    }
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Esempio n. 20
0
        /// <summary>
		/// The Page_Load server event handler on this page is used
        /// to populate the role information for the page
		/// </summary>
		protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            #region Bind Handles

            optHost.CheckedChanged += optHost_CheckedChanged;
            optSite.CheckedChanged += optSite_CheckedChanged;
            cmdPreview.Click += cmdPreview_Click;

            #endregion

            try
            {
                var objPortals = new PortalController();
				if (Request.QueryString["pid"] != null && (Globals.IsHostTab(PortalSettings.ActiveTab.TabID) || UserController.GetCurrentUserInfo().IsSuperUser))
                {
                    _objPortal = objPortals.GetPortal(Int32.Parse(Request.QueryString["pid"]));
                }
                else
                {
                    _objPortal = objPortals.GetPortal(PortalSettings.PortalId);
                }
                if (!Page.IsPostBack)
                {
					//save persistent values
                    ViewState["SkinControlWidth"] = _Width;
                    ViewState["SkinRoot"] = _SkinRoot;
                    ViewState["SkinSrc"] = _SkinSrc;
					
					//set width of control
                    if (!String.IsNullOrEmpty(_Width))
                    {
                        cboSkin.Width = Unit.Parse(_Width);
                    }
					
					//set selected skin
                    if (!String.IsNullOrEmpty(_SkinSrc))
                    {
                        switch (_SkinSrc.Substring(0, 3))
                        {
                            case "[L]":
                                optHost.Checked = false;
                                optSite.Checked = true;
                                break;
                            case "[G]":
                                optSite.Checked = false;
                                optHost.Checked = true;
                                break;
                        }
                    }
                    else
                    {
						//no skin selected, initialized to site skin if any exists
                        string strRoot = _objPortal.HomeDirectoryMapPath + SkinRoot;
                        if (Directory.Exists(strRoot) && Directory.GetDirectories(strRoot).Length > 0)
                        {
                            optHost.Checked = false;
                            optSite.Checked = true;
                        }
                    }
                    LoadSkins();
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Esempio n. 21
0
        private void IdentifyPortalAlias(HttpContext context, 
                                            HttpRequest request, 
                                            Uri requestUri, UrlAction result,
                                            NameValueCollection queryStringCol, 
                                            FriendlyUrlSettings settings,
                                            Guid parentTraceId)
        {
            //get the domain name of the request, if it isn't already supplied
            if (request != null && string.IsNullOrEmpty(result.DomainName))
            {
                result.DomainName = Globals.GetDomainName(request); //parse the domain name out of the request
            }

            // get tabId from querystring ( this is mandatory for maintaining portal context for child portals ) 
            if (queryStringCol["tabid"] != null)
            {
                string raw = queryStringCol["tabid"];
                int tabId;
                if (Int32.TryParse(raw, out tabId))
                {
                    result.TabId = tabId;
                }
                else
                {
                    //couldn't parse tab id
                    //split in two?
                    string[] tabids = raw.Split(',');
                    if (tabids.GetUpperBound(0) > 0)
                    {
                        //hmm more than one tabid
                        if (Int32.TryParse(tabids[0], out tabId))
                        {
                            result.TabId = tabId;
                            //but we want to warn against this!
                            var ex =
                                new Exception(
                                    "Illegal request exception : Two TabId parameters provided in a single request: " +
                                    requestUri);
                            UrlRewriterUtils.LogExceptionInRequest(ex, "Not Set", result);

                            result.Ex = ex;
                        }
                        else
                        {
                            //yeah, nothing, divert to 404 
                            result.Action = ActionType.Output404;
                            var ex =
                                new Exception(
                                    "Illegal request exception : TabId parameters in query string, but invalid TabId requested : " +
                                    requestUri);
                            UrlRewriterUtils.LogExceptionInRequest(ex, "Not Set", result);
                            result.Ex = ex;
                        }
                    }
                }
            }
            // get PortalId from querystring ( this is used for host menu options as well as child portal navigation ) 
            if (queryStringCol["portalid"] != null)
            {
                string raw = queryStringCol["portalid"];
                int portalId;
                if (Int32.TryParse(raw, out portalId))
                {
                    //848 : if portal already found is different to portal id in querystring, then load up different alias
                    //this is so the portal settings will be loaded correctly.
                    if (result.PortalId != portalId)
                    {
                        //portal id different to what we expected
                        result.PortalId = portalId;
                        //check the loaded portal alias, because it might be wrong
                        if (result.PortalAlias != null && result.PortalAlias.PortalID != portalId)
                        {
                            //yes, the identified portal alias is wrong.  Find the correct alias for this portal
                            PortalAliasInfo pa = TabIndexController.GetPortalAliasByPortal(portalId, result.DomainName);
                            if (pa != null)
                            {
                                //note: sets portal id and portal alias
                                result.PortalAlias = pa;
                            }
                        }
                    }
                }
            }
            else
            {
                //check for a portal alias if there's no portal Id in the query string
                //check for absence of captcha value, because the captcha string re-uses the alias querystring value
                if (queryStringCol["alias"] != null && queryStringCol["captcha"] == null)
                {
                    string alias = queryStringCol["alias"];
                    PortalAliasInfo portalAlias = PortalAliasController.GetPortalAliasInfo(alias);
                    if (portalAlias != null)
                    {
                        //ok the portal alias was found by the alias name
                        // check if the alias contains the domain name
                        if (alias.Contains(result.DomainName) == false)
                        {
                            // replaced to the domain defined in the alias 
                            if (request != null)
                            {
                                string redirectDomain = Globals.GetPortalDomainName(alias, request, true);
                                //retVal.Url = redirectDomain;
                                result.FinalUrl = redirectDomain;
                                result.Action = ActionType.Redirect302Now;
                                result.Reason = RedirectReason.Alias_In_Url;
                            }
                        }
                        else
                        {
                            // the alias is the same as the current domain 
                            result.HttpAlias = portalAlias.HTTPAlias;
                            result.PortalAlias = portalAlias;
                            result.PortalId = portalAlias.PortalID;
                            //don't use this crap though - we don't want ?alias=portalAlias in our Url
                            if (result.RedirectAllowed)
                            {
                                string redirect = requestUri.Scheme + Uri.SchemeDelimiter + result.PortalAlias.HTTPAlias +
                                                  "/";
                                result.Action = ActionType.Redirect301;
                                result.FinalUrl = redirect;
                                result.Reason = RedirectReason.Unfriendly_Url_Child_Portal;
                            }
                        }
                    }
                }
            }
            //first try and identify the portal using the tabId, but only if we identified this tab by looking up the tabid
            //from the original url
            //668 : error in child portal redirects to child portal home page because of mismatch in tab/domain name
            if (result.TabId != -1 && result.FriendlyRewrite == false)
            {
                // get the alias from the tabid, but only if it is for a tab in that domain 
                // 2.0 : change to compare retrieved alias to the already-set httpAlias
                string httpAliasFromTab = PortalAliasController.GetPortalAliasByTab(result.TabId, result.DomainName);
                if (httpAliasFromTab != null)
                {
                    //882 : account for situation when portalAlias is null.
                    if (result.PortalAlias != null && String.Compare(result.PortalAlias.HTTPAlias, httpAliasFromTab, StringComparison.OrdinalIgnoreCase) != 0
                        || result.PortalAlias == null)
                    {
                        //691 : change logic to force change in portal alias context rather than force back.
                        //This is because the tabid in the query string should take precedence over the portal alias
                        //to handle parent.com/default.aspx?tabid=xx where xx lives in parent.com/child/ 
                        var tc = new TabController();
                        var tab = tc.GetTab(result.TabId, Null.NullInteger, false);
                        //when result alias is null or result alias is different from tab-identified portalAlias
                        if (tab != null && (result.PortalAlias == null || tab.PortalID != result.PortalAlias.PortalID))
                        {
                            //the tabid is different to the identified portalid from the original alias identified
                            //so get a new alias 
                            var pac = new PortalAliasController();
                            PortalAliasInfo tabPortalAlias = pac.GetPortalAlias(httpAliasFromTab, tab.PortalID);
                            if (tabPortalAlias != null)
                            {
                                result.PortalId = tabPortalAlias.PortalID;
                                result.PortalAlias = tabPortalAlias;
                                result.Action = ActionType.CheckFor301;
                                result.Reason = RedirectReason.Wrong_Portal;
                            }
                        }
                    }
                }
            }
            //if no alias, try and set by using the identified http alias or domain name
            if (result.PortalAlias == null)
            {
                if (!string.IsNullOrEmpty(result.HttpAlias))
                {
                    result.PortalAlias = PortalAliasController.GetPortalAliasInfo(result.HttpAlias);
                }
                else
                {
                    result.PortalAlias = PortalAliasController.GetPortalAliasInfo(result.DomainName);
                    if (result.PortalAlias == null && result.DomainName.EndsWith("/"))
                    {
                        result.DomainName = result.DomainName.TrimEnd('/');
                        result.PortalAlias = PortalAliasController.GetPortalAliasInfo(result.DomainName);
                    }
                }
            }

            if (result.PortalId == -1)
            {
                if (!requestUri.LocalPath.ToLower().EndsWith(Globals.glbDefaultPage.ToLower()))
                {
                    // allows requests for aspx pages in custom folder locations to be processed 
                    return;
                }
                //the domain name was not found so try using the host portal's first alias
                if (Host.Host.HostPortalID != -1)
                {
                    result.PortalId = Host.Host.HostPortalID;
                    // use the host portal, but replaced to the host portal home page
                    var aliases = TestablePortalAliasController.Instance.GetPortalAliasesByPortalId(result.PortalId).ToList();
                    if (aliases.Count > 0)
                    {
                        string alias = null;

                        //get the alias as the chosen portal alias for the host portal based on the result culture code
                        var cpa = aliases.GetAliasByPortalIdAndSettings(result.PortalId, result, result.CultureCode, settings);
                        if (cpa != null)
                        {
                            alias = cpa.HTTPAlias;
                        }

                        if (alias != null)
                        {
                            result.Action = ActionType.Redirect301;
                            result.Reason = RedirectReason.Host_Portal_Used;
                            string destUrl = MakeUrlWithAlias(requestUri, alias);
                            destUrl = CheckForSiteRootRedirect(alias, destUrl);
                            result.FinalUrl = destUrl;
                        }
                        else
                        {
                            //Get the first Alias for the host portal
                            result.PortalAlias = aliases[result.PortalId];
                            string url = MakeUrlWithAlias(requestUri, result.PortalAlias);
                            if (result.TabId != -1)
                            {
                                url += requestUri.Query;
                            }
                            result.FinalUrl = url;
                            result.Reason = RedirectReason.Host_Portal_Used;
                            result.Action = ActionType.Redirect302Now;
                        }
                    }
                }
            }

            //double check to make sure we still have the correct alias now that all other information is known (ie tab, portal, culture)
            //770 : redirect alias based on tab id when custom alias used
            if (result.TabId == -1 && result.Action == ActionType.CheckFor301 &&
                result.Reason == RedirectReason.Custom_Tab_Alias)
            {
                //here because the portal alias matched, but no tab was found, and because there are custom tab aliases used for this portal
                //need to redirect back to the chosen portal alias and keep the current path.
                string wrongAlias = result.HttpAlias; //it's a valid alias, but only for certain tabs
                var primaryAliases = TestablePortalAliasController.Instance.GetPortalAliasesByPortalId(result.PortalId).ToList();
                if (primaryAliases != null && result.PortalId > -1)
                {
                    //going to look for the correct alias based on the culture of the request
                    string requestCultureCode = result.CultureCode;
                    //if that didn't work use the default language of the portal
                    if (requestCultureCode == null)
                    {
                        //this might end up in a double redirect if the path of the Url is for a specific language as opposed
                        //to a path belonging to the default language domain
                        var pc = new PortalController();
                        PortalInfo portal = pc.GetPortal(result.PortalId);
                        if (portal != null)
                        {
                            requestCultureCode = portal.DefaultLanguage;
                        }
                    }
                    //now that the culture code is known, look up the correct portal alias for this portalid/culture code
                    var cpa = primaryAliases.GetAliasByPortalIdAndSettings(result.PortalId, result, requestCultureCode, settings);
                    if (cpa != null)
                    {
                        //if an alias was found that matches the request and the culture code, then run with that
                        string rightAlias = cpa.HTTPAlias;
                        //will cause a redirect to the primary portal alias - we know now that there was no custom alias tab
                        //found, so it's just a plain wrong alias
                        ConfigurePortalAliasRedirect(ref result, wrongAlias, rightAlias, true,
                                                     settings.InternalAliasList, settings);
                    }
                }
            }
            else
            {
                //then check to make sure it's the chosen portal alias for this portal
                //627 : don't do it if we're redirecting to the host portal 
                if (result.RedirectAllowed && result.Reason != RedirectReason.Host_Portal_Used)
                {
                    string primaryAlias;
                    //checking again in case the rewriting operation changed the values for the valid portal alias
                    bool incorrectAlias = IsPortalAliasIncorrect(context, request, requestUri, result, queryStringCol, settings, parentTraceId, out primaryAlias);
                    if (incorrectAlias) RedirectPortalAlias(primaryAlias, ref result, settings);
                }
            }

            //check to see if we have to avoid the core 302 redirect for the portal alias that is in the /defualt.aspx
            //for child portals
            //exception to that is when a custom alias is used but no rewrite has taken place
            if (result.DoRewrite == false && (result.Action == ActionType.Continue
                                              ||
                                              (result.Action == ActionType.CheckFor301 &&
                                               result.Reason == RedirectReason.Custom_Tab_Alias)))
            {
                string aliasQuerystring;
                bool isChildAliasRootUrl = CheckForChildPortalRootUrl(requestUri.AbsoluteUri, result, out aliasQuerystring);
                if (isChildAliasRootUrl)
                {
                    RewriteAsChildAliasRoot(context, result, aliasQuerystring, settings);
                }
            }
        }
Esempio n. 22
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Returns the folder path under the root for the portal 
 /// </summary>
 /// <param name="strFileNamePath">The folder the absolute path</param>
 /// <param name="portalId">Portal Id.</param>
 /// <remarks>
 /// </remarks>
 /// <history>
 ///   [cnurse] 16/9/2004  Updated for localization, Help and 508
 ///   [Philip Beadle] 6 October 2004 Moved to Globals from WebUpload.ascx.vb so can be accessed by URLControl.ascx
 /// </history>
 /// -----------------------------------------------------------------------------
 public static string GetSubFolderPath(string strFileNamePath, int portalId)
 {
     string ParentFolderName;
     if (portalId == Null.NullInteger)
     {
         ParentFolderName = HostMapPath.Replace("/", "\\");
     }
     else
     {
         var objPortals = new PortalController();
         PortalInfo objPortal = objPortals.GetPortal(portalId);
         ParentFolderName = objPortal.HomeDirectoryMapPath.Replace("/", "\\");
     }
     string strFolderpath = strFileNamePath.Substring(0, strFileNamePath.LastIndexOf("\\") + 1);
     return strFolderpath.Substring(ParentFolderName.Length).Replace("\\", "/");
 }
Esempio n. 23
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// GetSearchResults gets the search results for a passed in criteria string
        /// </summary>
        /// <remarks>
        /// </remarks>
		/// <param name="portalId">A Id of the Portal</param>
		/// <param name="criteria">The criteria string</param>
        /// <history>
        ///		[cnurse]	11/15/2004	documented
        /// </history>
        /// -----------------------------------------------------------------------------
        public override SearchResultsInfoCollection GetSearchResults(int portalId, string criteria)
        {
            bool hasExcluded = Null.NullBoolean;
            bool hasMandatory = Null.NullBoolean;

            var objPortalController = new PortalController();
            PortalInfo objPortal = objPortalController.GetPortal(portalId);

            //Get the Settings for this Portal
            var portalSettings = new PortalSettings(objPortal);

            //We will assume that the content is in the locale of the Portal
            Hashtable commonWords = GetCommonWords(portalSettings.DefaultLanguage);

            //clean criteria
            criteria = criteria.ToLower();

            //split search criteria into words
            var searchWords = new SearchCriteriaCollection(criteria);

            var searchResults = new Dictionary<string, SearchResultsInfoCollection>();

            //dicResults is a Dictionary(Of SearchItemID, Dictionary(Of TabID, SearchResultsInfo)
            var dicResults = new Dictionary<int, Dictionary<int, SearchResultsInfo>>();

            //iterate through search criteria words
            foreach (SearchCriteria criterion in searchWords)
            {
                if (commonWords.ContainsKey(criterion.Criteria) == false || portalSettings.SearchIncludeCommon)
                {
                    if (!searchResults.ContainsKey(criterion.Criteria))
                    {
                        searchResults.Add(criterion.Criteria, SearchDataStoreController.GetSearchResults(portalId, criterion.Criteria));
                    }
                    if (searchResults.ContainsKey(criterion.Criteria))
                    {
                        foreach (SearchResultsInfo result in searchResults[criterion.Criteria])
                        {
							//Add results to dicResults
                            if (!criterion.MustExclude)
                            {
                                if (dicResults.ContainsKey(result.SearchItemID))
                                {
                                    //The Dictionary exists for this SearchItemID already so look in the TabId keyed Sub-Dictionary
                                    Dictionary<int, SearchResultsInfo> dic = dicResults[result.SearchItemID];
                                    if (dic.ContainsKey(result.TabId))
                                    {
                                        //The sub-Dictionary contains the item already so update the relevance
                                        SearchResultsInfo searchResult = dic[result.TabId];
                                        searchResult.Relevance += result.Relevance;
                                    }
                                    else
                                    {
										//Add Entry to Sub-Dictionary
                                        dic.Add(result.TabId, result);
                                    }
                                }
                                else
                                {
									//Create new TabId keyed Dictionary
                                    var dic = new Dictionary<int, SearchResultsInfo>();
                                    dic.Add(result.TabId, result);

                                    //Add new Dictionary to SearchResults
                                    dicResults.Add(result.SearchItemID, dic);
                                }
                            }
                        }
                    }
                }
            }
            foreach (SearchCriteria criterion in searchWords)
            {
                var mandatoryResults = new Dictionary<int, bool>();
                var excludedResults = new Dictionary<int, bool>();
                if (searchResults.ContainsKey(criterion.Criteria))
                {
                    foreach (SearchResultsInfo result in searchResults[criterion.Criteria])
                    {
                        if (criterion.MustInclude)
                        {
							//Add to mandatory results lookup
                            mandatoryResults[result.SearchItemID] = true;
                            hasMandatory = true;
                        }
                        else if (criterion.MustExclude)
                        {
							//Add to exclude results lookup
                            excludedResults[result.SearchItemID] = true;
                            hasExcluded = true;
                        }
                    }
                }
                foreach (KeyValuePair<int, Dictionary<int, SearchResultsInfo>> kvpResults in dicResults)
                {
                    //The key of this collection is the SearchItemID,  Check if the value of this collection should be processed
                    if (hasMandatory && (!mandatoryResults.ContainsKey(kvpResults.Key)))
                    {
                        //1. If mandatoryResults exist then only process if in mandatoryResults Collection
                        foreach (SearchResultsInfo result in kvpResults.Value.Values)
                        {
                            result.Delete = true;
                        }
                    }
                    else if (hasExcluded && (excludedResults.ContainsKey(kvpResults.Key)))
                    {
                        //2. Do not process results in the excludedResults Collection
                        foreach (SearchResultsInfo result in kvpResults.Value.Values)
                        {
                            result.Delete = true;
                        }
                    }
                }
            }
			
            //Process results against permissions and mandatory and excluded results
            var results = new SearchResultsInfoCollection();
            var objTabController = new TabController();
            foreach (KeyValuePair<int, Dictionary<int, SearchResultsInfo>> kvpResults in dicResults)
            {
                foreach (SearchResultsInfo result in kvpResults.Value.Values)
                {
                    if (!result.Delete)
                    {
						//Check If authorised to View Tab
                        TabInfo objTab = objTabController.GetTab(result.TabId, portalId, false);
                        if (TabPermissionController.CanViewPage(objTab))
                        {
							//Check If authorised to View Module
                            ModuleInfo objModule = new ModuleController().GetModule(result.ModuleId, result.TabId, false);
                            if (ModulePermissionController.CanViewModule(objModule))
                            {
                                results.Add(result);
                            }
                        }
                    }
                }
            }
			
            //Return Search Results Collection
            return results;
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// cmdUpdate_Click runs when the Update button is clicked
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// 	[cnurse]	5/10/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        /// -----------------------------------------------------------------------------
        private void cmdUpdate_Click(Object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                try
                {
                    bool blnChild;
                    string strPortalAlias;
                    string strChildPath = string.Empty;
                    var closePopUpStr = string.Empty;

                    var objPortalController = new PortalController();

                    //check template validity
                    var messages = new ArrayList();
                    string schemaFilename = Server.MapPath(string.Concat(AppRelativeTemplateSourceDirectory, "portal.template.xsd"));
                    string xmlFilename = Globals.HostMapPath + cboTemplate.SelectedItem.Text + ".template";
                    var xval = new PortalTemplateValidator();
                    if (!xval.Validate(xmlFilename, schemaFilename))
                    {
                        UI.Skins.Skin.AddModuleMessage(this, "", String.Format(Localization.GetString("InvalidTemplate", LocalResourceFile), cboTemplate.SelectedItem.Text + ".template"), ModuleMessage.ModuleMessageType.RedError);
                        messages.AddRange(xval.Errors);
                        lstResults.Visible = true;
                        lstResults.DataSource = messages;
                        lstResults.DataBind();
                        return;
                    }

                    //Set Portal Name
                    txtPortalName.Text = txtPortalName.Text.ToLowerInvariant();
                    txtPortalName.Text = txtPortalName.Text.Replace("http://", "");

                    //Validate Portal Name
                    if (!Globals.IsHostTab(PortalSettings.ActiveTab.TabID))
                    {
                        blnChild = true;
                        strPortalAlias = txtPortalName.Text;
                    }
                    else
                    {
                        blnChild = (optType.SelectedValue == "C");

                        strPortalAlias = blnChild ? txtPortalName.Text.Substring(txtPortalName.Text.LastIndexOf("/") + 1) : txtPortalName.Text;
                    }

                    string message = String.Empty;
                    ModuleMessage.ModuleMessageType messageType = ModuleMessage.ModuleMessageType.RedError;
                    if (!PortalAliasController.ValidateAlias(strPortalAlias, blnChild))
                    {
                        message = Localization.GetString("InvalidName", LocalResourceFile);
                    }

                    //Validate Password
                    if (txtPassword.Text != txtConfirm.Text)
                    {
                        if (!String.IsNullOrEmpty(message)) message += "<br/>";
                        message += Localization.GetString("InvalidPassword", LocalResourceFile);
                    }
                    string strServerPath = Globals.GetAbsoluteServerPath(Request);

                    //Set Portal Alias for Child Portals
                    if (String.IsNullOrEmpty(message))
                    {
                        if (blnChild)
                        {
                            strChildPath = strServerPath + strPortalAlias;

                            if (Directory.Exists(strChildPath))
                            {
                                message = Localization.GetString("ChildExists", LocalResourceFile);
                            }
                            else
                            {
                                if (!Globals.IsHostTab(PortalSettings.ActiveTab.TabID))
                                {
                                    strPortalAlias = Globals.GetDomainName(Request, true) + "/" + strPortalAlias;
                                }
                                else
                                {
                                    strPortalAlias = txtPortalName.Text;
                                }
                            }
                        }
                    }

                    //Get Home Directory
                    string homeDir = txtHomeDirectory.Text != @"Portals/[PortalID]" ? txtHomeDirectory.Text : "";

                    //Validate Home Folder
                    if (!string.IsNullOrEmpty(homeDir))
                    {
                        if (string.IsNullOrEmpty(String.Format("{0}\\{1}\\", Globals.ApplicationMapPath, homeDir).Replace("/", "\\")))
                        {
                            message = Localization.GetString("InvalidHomeFolder", LocalResourceFile);
                        }
                        if (homeDir.Contains("admin") || homeDir.Contains("DesktopModules") || homeDir.ToLowerInvariant() == "portals/")
                        {
                            message = Localization.GetString("InvalidHomeFolder", LocalResourceFile);
                        }
                    }

                    //Validate Portal Alias
                    if (!string.IsNullOrEmpty(strPortalAlias))
                    {
                        PortalAliasInfo portalAlias = PortalAliasController.GetPortalAliasLookup(strPortalAlias.ToLower());
                        if (portalAlias != null)
                        {
                            message = Localization.GetString("DuplicatePortalAlias", LocalResourceFile);
                        }
                    }

                    //Create Portal
                    if (String.IsNullOrEmpty(message))
                    {
                        string strTemplateFile = cboTemplate.SelectedItem.Text + ".template";

                        //Attempt to create the portal
                        var objAdminUser = new UserInfo();
                        int intPortalId;
                        try
                        {
                            objAdminUser.FirstName = txtFirstName.Text;
                            objAdminUser.LastName = txtLastName.Text;
                            objAdminUser.Username = txtUsername.Text;
                            objAdminUser.DisplayName = txtFirstName.Text + " " + txtLastName.Text;
                            objAdminUser.Email = txtEmail.Text;
                            objAdminUser.IsSuperUser = false;

                            objAdminUser.Membership.Approved = true;
                            objAdminUser.Membership.Password = txtPassword.Text;
                            objAdminUser.Membership.PasswordQuestion = txtQuestion.Text;
                            objAdminUser.Membership.PasswordAnswer = txtAnswer.Text;

                            objAdminUser.Profile.FirstName = txtFirstName.Text;
                            objAdminUser.Profile.LastName = txtLastName.Text;
                            intPortalId = objPortalController.CreatePortal(txtTitle.Text,
                                                                           objAdminUser,
                                                                           txtDescription.Text,
                                                                           txtKeyWords.Text,
                                                                           Globals.HostMapPath,
                                                                           strTemplateFile,
                                                                           homeDir,
                                                                           strPortalAlias,
                                                                           strServerPath,
                                                                           strChildPath,
                                                                           blnChild);
                        }
                        catch (Exception ex)
                        {
                            intPortalId = Null.NullInteger;
                            message = ex.Message;
                        }
                        if (intPortalId != -1)
                        {
                            //Create a Portal Settings object for the new Portal
                            PortalInfo objPortal = objPortalController.GetPortal(intPortalId);
                            var newSettings = new PortalSettings { PortalAlias = new PortalAliasInfo { HTTPAlias = strPortalAlias }, PortalId = intPortalId, DefaultLanguage = objPortal.DefaultLanguage };
                            string webUrl = Globals.AddHTTP(strPortalAlias);
                            try
                            {
                                if (!Globals.IsHostTab(PortalSettings.ActiveTab.TabID))
                                {
                                    message = Mail.SendMail(PortalSettings.Email,
                                                               txtEmail.Text,
                                                               PortalSettings.Email + ";" + Host.HostEmail,
                                                               Localization.GetSystemMessage(newSettings, "EMAIL_PORTAL_SIGNUP_SUBJECT", objAdminUser),
                                                               Localization.GetSystemMessage(newSettings, "EMAIL_PORTAL_SIGNUP_BODY", objAdminUser),
                                                               "",
                                                               "",
                                                               "",
                                                               "",
                                                               "",
                                                               "");
                                }
                                else
                                {
                                    message = Mail.SendMail(Host.HostEmail,
                                                               txtEmail.Text,
                                                               Host.HostEmail,
                                                               Localization.GetSystemMessage(newSettings, "EMAIL_PORTAL_SIGNUP_SUBJECT", objAdminUser),
                                                               Localization.GetSystemMessage(newSettings, "EMAIL_PORTAL_SIGNUP_BODY", objAdminUser),
                                                               "",
                                                               "",
                                                               "",
                                                               "",
                                                               "",
                                                               "");
                                }
                            }
                            catch (Exception exc)
                            {
                                DnnLog.Error(exc);

                                closePopUpStr = (PortalSettings.EnablePopUps) ? "onclick=\"return " + UrlUtils.ClosePopUp(true,webUrl,true) + "\"" : "";
                                message = string.Format(Localization.GetString("UnknownSendMail.Error", LocalResourceFile), webUrl, closePopUpStr);
                            }
                            var objEventLog = new EventLogController();
                            objEventLog.AddLog(objPortalController.GetPortal(intPortalId), PortalSettings, UserId, "", EventLogController.EventLogType.PORTAL_CREATED);

                            //Redirect to this new site
                            if (message == Null.NullString)
                            {
                                webUrl = (PortalSettings.EnablePopUps) ? UrlUtils.ClosePopUp(true, webUrl, false) : webUrl;
                                Response.Redirect(webUrl,true);
                            }
                            else
                            {
                                closePopUpStr = (PortalSettings.EnablePopUps) ? "onclick=\"return " + UrlUtils.ClosePopUp(true, webUrl, true) + "\"" : "";
                                message = string.Format(Localization.GetString("SendMail.Error", LocalResourceFile), message, webUrl, closePopUpStr);
                                messageType = ModuleMessage.ModuleMessageType.YellowWarning;
                            }
                        }
                    }
                    UI.Skins.Skin.AddModuleMessage(this, "", message, messageType);
                }
                catch (Exception exc) //Module failed to load
                {
                    Exceptions.ProcessModuleLoadException(this, exc);
                }
            }
        }
Esempio n. 25
0
        private string DeTokeniseLinks(string content, int portalId)
        {

            var portalController = new PortalController();
            var portal = portalController.GetPortal(portalId);
            var portalRoot = UrlUtils.Combine(Globals.ApplicationPath, portal.HomeDirectory);
            if (!portalRoot.StartsWith("/"))
            {
                portalRoot = "/" + portalRoot;
            }
            content = content.Replace(PortalRootToken, portalRoot);

            return content;
        }
Esempio n. 26
0
        private static void GetModuleContent(XmlNode nodeModule, int ModuleId, int TabId, int PortalId)
        {
            var moduleController = new ModuleController();
            ModuleInfo module = moduleController.GetModule(ModuleId, TabId, true);
            if (nodeModule != null)
            {
                // ReSharper disable PossibleNullReferenceException
                string version = nodeModule.SelectSingleNode("content").Attributes["version"].Value;
                string content = nodeModule.SelectSingleNode("content").InnerXml;
                content = content.Substring(9, content.Length - 12);
                if (!String.IsNullOrEmpty(module.DesktopModule.BusinessControllerClass) && !String.IsNullOrEmpty(content))
                {
                    var portalController = new PortalController();
                    PortalInfo portal = portalController.GetPortal(PortalId);

                    content = HttpContext.Current.Server.HtmlDecode(content);

                    //Determine if the Module is copmpletely installed 
                    //(ie are we running in the same request that installed the module).
                    if (module.DesktopModule.SupportedFeatures == Null.NullInteger)
                    {
                        //save content in eventqueue for processing after an app restart,
                        //as modules Supported Features are not updated yet so we
                        //cannot determine if the module supports IsPortable								
                        EventMessageProcessor.CreateImportModuleMessage(module, content, version, portal.AdministratorId);
                    }
                    else
                    {
                        if (module.DesktopModule.IsPortable)
                        {
                            try
                            {
                                object businessController = Reflection.CreateObject(module.DesktopModule.BusinessControllerClass, module.DesktopModule.BusinessControllerClass);
                                var controller = businessController as IPortable;
                                if (controller != null)
                                {
                                    controller.ImportModule(module.ModuleID, content, version, portal.AdministratorId);
                                }
                            }
                            catch
                            {
                                //if there is an error then the type cannot be loaded at this time, so add to EventQueue
                                EventMessageProcessor.CreateImportModuleMessage(module, content, version, portal.AdministratorId);
                            }
                        }
                    }
                }
                // ReSharper restore PossibleNullReferenceException
            }
        }
        private void BindSkins()
        {
            var portalController = new PortalController();
            var portal = portalController.GetPortal(Tab.PortalID);
            var skins = SkinController.GetSkins(portal, SkinController.RootSkin, SkinScope.All)
                                                     .ToDictionary(skin => skin.Key, skin => skin.Value);
            var containers = SkinController.GetSkins(portal, SkinController.RootContainer, SkinScope.All)
                                                    .ToDictionary(skin => skin.Key, skin => skin.Value);
            pageSkinCombo.DataSource = skins;
            pageSkinCombo.DataBind(Tab.SkinSrc);
            pageSkinCombo.InsertItem(0, "<" + Localization.GetString("None_Specified") + ">", "");
            pageSkinCombo.Select(Tab.SkinSrc, false);

            pageContainerCombo.DataSource = containers;
            pageContainerCombo.DataBind();
            pageContainerCombo.InsertItem(0, "<" + Localization.GetString("None_Specified") + ">", "");
            pageContainerCombo.Select(Tab.ContainerSrc, false);
        }
Esempio n. 28
0
        private void BindPortal(int portalId, string activeLanguage)
        {
            //Ensure localization
            DataProvider.Instance().EnsureLocalizationExists(portalId, activeLanguage);

            var portalController = new PortalController();
            var portal = portalController.GetPortal(portalId, activeLanguage);

            BindDetails(portal);

            BindMarketing(portal);

            ctlLogo.FilePath = portal.LogoFile;
            ctlLogo.FileFilter = Globals.glbImageFileTypes;
            ctlBackground.FilePath = portal.BackgroundFile;
            ctlBackground.FileFilter = Globals.glbImageFileTypes;
            ctlFavIcon.FilePath = new FavIcon(portal.PortalID).GetSettingPath();
            chkSkinWidgestEnabled.Checked = PortalController.GetPortalSettingAsBoolean("EnableSkinWidgets", portalId, true);

            BindSkins(portal);

            BindPages(portal, activeLanguage);

            lblHomeDirectory.Text = portal.HomeDirectory;

            optUserRegistration.SelectedIndex = portal.UserRegistration;

            BindPaymentProcessor(portal);

            BindUsability(portal);

            BindMessaging(portal);

            var roleController = new RoleController();
            cboAdministratorId.DataSource = roleController.GetUserRoles(portalId, null, portal.AdministratorRoleName);
            cboAdministratorId.DataBind(portal.AdministratorId.ToString());

            //PortalSettings for portal being edited
            var portalSettings = new PortalSettings(portal);

            cboTimeZone.DataBind(portalSettings.TimeZone.Id);

            if (UserInfo.IsSuperUser)
            {
                BindAliases(portal);

                BindSSLSettings(portal);

                BindHostSettings(portal);
            }

            LoadStyleSheet(portal);

            ctlAudit.Entity = portal;

            var overrideDefaultSettings = Boolean.Parse(PortalController.GetPortalSetting(ClientResourceSettings.OverrideDefaultSettingsKey, portalId, "false"));
            chkOverrideDefaultSettings.Checked = overrideDefaultSettings;
            BindClientResourceManagementUi(portal.PortalID, overrideDefaultSettings);
            ManageMinificationUi();
        }
Esempio n. 29
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            cboFolders.SelectedIndexChanged += cboFolders_SelectedIndexChanged;
            optType.SelectedIndexChanged += optType_SelectedIndexChanged;
            cmdAdd.Click += cmdAdd_Click;
            cmdCancel.Click += cmdCancel_Click;
            cmdDelete.Click += cmdDelete_Click;
            cmdSave.Click += cmdSave_Click;
            cmdSelect.Click += cmdSelect_Click;
            cmdUpload.Click += cmdUpload_Click;

            try
            {
                var objPortals = new PortalController();
                if ((Request.QueryString["pid"] != null) && (Globals.IsHostTab(PortalSettings.ActiveTab.TabID) || UserController.GetCurrentUserInfo().IsSuperUser))
                {
                    _objPortal = objPortals.GetPortal(Int32.Parse(Request.QueryString["pid"]));
                }
                else
                {
                    _objPortal = objPortals.GetPortal(PortalSettings.PortalId);
                }
                if (ViewState["IsUrlControlLoaded"] == null)
                {
                    //If Not Page.IsPostBack Then
                    //let's make at least an initialization
                    //The type radio button must be initialized
                    //The url must be initialized no matter its value
                    _doRenderTypes = true;
                    _doChangeURL = true;
                    ClientAPI.AddButtonConfirm(cmdDelete, Localization.GetString("DeleteItem"));
                    //The following line was mover to the pre-render event to ensure render for the first time
                    //ViewState("IsUrlControlLoaded") = "Loaded"
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Esempio n. 30
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// cmdDelete_Click runs when the Delete LinkButton is clicked.
        /// It deletes the current portal form the Database.  It can only run in Host
        /// (SuperUser) mode
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// 	[cnurse]	9/9/2004	Modified
        ///     [VMasanas]  9/12/2004   Move skin deassignment to DeletePortalInfo.
        ///     [jmarino]  16/06/2011   Modify redirection after deletion of portal 
        /// </history>
        /// -----------------------------------------------------------------------------
        protected void DeletePortal(object sender, EventArgs e)
        {
            try
            {
                var objPortalController = new PortalController();
                PortalInfo objPortalInfo = objPortalController.GetPortal(_portalId);
                if (objPortalInfo != null)
                {
                    string strMessage = PortalController.DeletePortal(objPortalInfo, Globals.GetAbsoluteServerPath(Request));

                    if (string.IsNullOrEmpty(strMessage))
                    {
                        var objEventLog = new EventLogController();
                        objEventLog.AddLog("PortalName", objPortalInfo.PortalName, PortalSettings, UserId, EventLogController.EventLogType.PORTAL_DELETED);

                        //Redirect to another site
                        if (_portalId == PortalId)
                        {
                            if (!string.IsNullOrEmpty(Host.HostURL))
                            {
                                Response.Redirect(Globals.AddHTTP(Host.HostURL));
                            }
                            else
                            {
                                Response.End();
                            }
                        }
                        else
                        {
                            if (ViewState["UrlReferrer"] != null)
                            {
                                Response.Redirect(Convert.ToString(ViewState["UrlReferrer"]), true);
                            }
                            else
                            {
                                Response.Redirect(Globals.NavigateURL(), true);
                            }
                        }
                    }
                    else
                    {
                        UI.Skins.Skin.AddModuleMessage(this, strMessage, ModuleMessage.ModuleMessageType.RedError);
                    }
                }
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Esempio n. 31
0
        protected void CtlPagesContextMenuItemClick(object sender, RadTreeViewContextMenuEventArgs e)
        {
            SelectedNode = e.Node.Value;

            var tabController = new TabController();
            var portalId = rblMode.SelectedValue == "H" ? Null.NullInteger : PortalId;
            var objTab = tabController.GetTab(int.Parse(e.Node.Value), portalId, false);

            switch (e.MenuItem.Value.ToLower())
            {
                case "makehome":
                    if (PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName))
                    {
                        var portalController = new PortalController();
                        PortalInfo portalInfo = portalController.GetPortal(PortalId);
                        portalInfo.HomeTabId = objTab.TabID;
                        PortalSettings.HomeTabId = objTab.TabID;
                        portalController.UpdatePortalInfo(portalInfo);
                        DataCache.ClearPortalCache(PortalId, false);
                        BindTreeAndShowTab(objTab.TabID);
                        ShowSuccessMessage(string.Format(Localization.GetString("TabMadeHome", LocalResourceFile), objTab.TabName));
                    }
                    break;
                case "view":
                    Response.Redirect(objTab.FullUrl);
                    break;
                case "edit":
                    if (TabPermissionController.CanManagePage(objTab))
                    {
                        var editUrl = Globals.NavigateURL(objTab.TabID, "Tab", "action=edit", "returntabid=" + TabId);
                        // Prevent PageSettings of the current page in a popup if SSL is enabled and enforced, which causes redirection/javascript broswer security issues.
                        if (PortalSettings.EnablePopUps && !(objTab.TabID == TabId && (PortalSettings.SSLEnabled && PortalSettings.SSLEnforced)))
                        {
                            editUrl = UrlUtils.PopUpUrl(editUrl, this, PortalSettings, true, false);
                            var script = string.Format("<script type=\"text/javascript\">{0}</script>", editUrl);
                            ClientAPI.RegisterStartUpScript(Page, "EditInPopup", script);
                        }
                        else
                        {
                            Response.Redirect(editUrl, true);
                        }
                    }
                    break;
                case "delete":
                    if (TabPermissionController.CanDeletePage(objTab))
                    {
                        tabController.SoftDeleteTab(objTab.TabID, PortalSettings);
                        BindTree();
                        //keep the parent tab selected
                        if (objTab.ParentId != Null.NullInteger)
                        {
                            SelectedNode = objTab.ParentId.ToString(CultureInfo.InvariantCulture);
                            ctlPages.FindNodeByValue(SelectedNode).Selected = true;
                            ctlPages.FindNodeByValue(SelectedNode).ExpandParentNodes();
                            BindTab(objTab.ParentId);
                        }
                        else
                        {
                            pnlDetails.Visible = false;
                        }
                        ShowSuccessMessage(string.Format(Localization.GetString("TabDeleted", LocalResourceFile), objTab.TabName));
                    }
                    break;
                case "add":
                    if ((objTab!= null && TabPermissionController.CanAddPage(objTab)) || (PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName)))
                    {
                        pnlBulk.Visible = true;
                        btnBulkCreate.CommandArgument = e.Node.Value;
                        ctlPages.FindNodeByValue(e.Node.Value).Selected = true;
                        txtBulk.Focus();
                        pnlDetails.Visible = false;
                        //Response.Redirect(NavigateURL(objTab.TabID, "Tab", "action=add", "returntabid=" & TabId.ToString), True)
                    }
                    break;
                case "hide":
                    if (TabPermissionController.CanManagePage(objTab))
                    {
                        objTab.IsVisible = false;
                        tabController.UpdateTab(objTab);
                        BindTreeAndShowTab(objTab.TabID);
                        ShowSuccessMessage(string.Format(Localization.GetString("TabHidden", LocalResourceFile), objTab.TabName));
                    }
                    break;
                case "show":
                    if (TabPermissionController.CanManagePage(objTab))
                    {
                        objTab.IsVisible = true;
                        tabController.UpdateTab(objTab);
                        BindTreeAndShowTab(objTab.TabID);
                        ShowSuccessMessage(string.Format(Localization.GetString("TabShown", LocalResourceFile), objTab.TabName));
                    }
                    break;
                case "disable":
                    if (TabPermissionController.CanManagePage(objTab))
                    {
                        objTab.DisableLink = true;
                        tabController.UpdateTab(objTab);
                        BindTreeAndShowTab(objTab.TabID);
                        ShowSuccessMessage(string.Format(Localization.GetString("TabDisabled", LocalResourceFile), objTab.TabName));
                    }
                    break;
                case "enable":
                    if (TabPermissionController.CanManagePage(objTab))
                    {
                        objTab.DisableLink = false;
                        tabController.UpdateTab(objTab);
                        BindTreeAndShowTab(objTab.TabID);
                        ShowSuccessMessage(string.Format(Localization.GetString("TabEnabled", LocalResourceFile), objTab.TabName));
                    }
                    break;
            }
        }
Esempio n. 32
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// cmdRestore_Click runs when the Restore Default Stylesheet Linkbutton is clicked. 
        /// It reloads the default stylesheet (copies from _default Portal to current Portal)
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// 	[cnurse]	9/9/2004	Modified
        /// </history>
        /// -----------------------------------------------------------------------------
        protected void OnRestoreClick(object sender, EventArgs e)
        {
            try
            {
                var portalController = new PortalController();
                PortalInfo portal = portalController.GetPortal(_portalId);
                if (portal != null)
                {
                    if (File.Exists(portal.HomeDirectoryMapPath + "portal.css"))
                    {
                        //delete existing style sheet
                        File.Delete(portal.HomeDirectoryMapPath + "portal.css");
                    }

                    //copy file from Host
                    if (File.Exists(Globals.HostMapPath + "portal.css"))
                    {
                        File.Copy(Globals.HostMapPath + "portal.css", portal.HomeDirectoryMapPath + "portal.css");
                    }
                }
                LoadStyleSheet(portal);
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Esempio n. 33
0
        protected void grdPortals_DeleteCommand( object source, DataGridCommandEventArgs e )
        {
            try
            {
                PortalController objPortalController = new PortalController();
                PortalInfo portal = objPortalController.GetPortal( Int32.Parse( e.CommandArgument.ToString() ) );

                if( portal != null )
                {
                    string strMessage = PortalController.DeletePortal( portal, Globals.GetAbsoluteServerPath( Request ) );
                    if( string.IsNullOrEmpty( strMessage ) )
                    {
                        EventLogController objEventLog = new EventLogController();
                        objEventLog.AddLog( "PortalName", portal.PortalName, PortalSettings, UserId, EventLogController.EventLogType.PORTAL_DELETED );
                        UI.Skins.Skin.AddModuleMessage( this, Localization.GetString( "PortalDeleted", LocalResourceFile ), ModuleMessageType.GreenSuccess );
                    }
                    else
                    {
                        UI.Skins.Skin.AddModuleMessage( this, strMessage, ModuleMessageType.RedError );
                    }
                }

                BindData();
            }
            catch( Exception exc ) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException( this, exc );
            }
        }
Esempio n. 34
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// cmdSave_Click runs when the Save Stylesheet Linkbutton is clicked.  It saves
        /// the edited Stylesheet
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// 	[cnurse]	9/9/2004	Modified
        /// </history>
        /// -----------------------------------------------------------------------------
        protected void OnSaveClick(object sender, EventArgs e)
        {
            try
            {
                string strUploadDirectory = "";

                var objPortalController = new PortalController();
                PortalInfo objPortal = objPortalController.GetPortal(_portalId);
                if (objPortal != null)
                {
                    strUploadDirectory = objPortal.HomeDirectoryMapPath;
                }

                //reset attributes
                if (File.Exists(strUploadDirectory + "portal.css"))
                {
                    File.SetAttributes(strUploadDirectory + "portal.css", FileAttributes.Normal);
                }

                //write CSS file
                using (var writer = File.CreateText(strUploadDirectory + "portal.css"))
                {
                    writer.WriteLine(txtStyleSheet.Text);
                }

                //Clear client resource cache
                var overrideSetting = PortalController.GetPortalSetting(ClientResourceSettings.OverrideDefaultSettingsKey, _portalId, "False");
                bool overridePortal;
                if (bool.TryParse(overrideSetting, out overridePortal))
                {
                    if (overridePortal)
                    {
                        // increment this portal version only
                        PortalController.IncrementCrmVersion(_portalId);
                    }
                    else
                    {
                        // increment host version, do not increment other portal versions though.
                        HostController.Instance.IncrementCrmVersion(false);
                    }
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }