예제 #1
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);
            }
        }
예제 #2
0
        /// <summary>
        /// Deletes all expired portals
        /// </summary>
        /// <history>
        ///     [cnurse]	11/17/2006	Created
        /// </history>
        private void DeleteExpiredPortals()
        {
            try
            {
                PortalController.DeleteExpiredPortals(Globals.GetAbsoluteServerPath(Request));

                BindData();
            }
            catch (Exception exc)  //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
        /// -----------------------------------------------------------------------------
        /// <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);
            }
        }
        private void BindMarketing(PortalInfo portal)
        {
            //Load DocTypes
            var searchEngines = new Dictionary <string, string>
            {
                { "Google", "http://www.google.com/addurl?q=" + Globals.HTTPPOSTEncode(Globals.AddHTTP(Globals.GetDomainName(Request))) },
                { "Yahoo", "http://siteexplorer.search.yahoo.com/submit" },
                { "Microsoft", "http://search.msn.com.sg/docs/submit.aspx" }
            };

            cboSearchEngine.DataSource = searchEngines;
            cboSearchEngine.DataBind();

            var portalAliasController = new PortalAliasController();
            var aliases = portalAliasController.GetPortalAliasArrayByPortalID(portal.PortalID);

            if (PortalController.IsChildPortal(portal, Globals.GetAbsoluteServerPath(Request)))
            {
                txtSiteMap.Text = Globals.AddHTTP(Globals.GetDomainName(Request)) + @"/SiteMap.aspx?portalid=" + portal.PortalID;
            }
            else
            {
                if (aliases.Count > 0)
                {
                    //Get the first Alias
                    var objPortalAliasInfo = (PortalAliasInfo)aliases[0];
                    txtSiteMap.Text = Globals.AddHTTP(objPortalAliasInfo.HTTPAlias) + @"/SiteMap.aspx";
                }
                else
                {
                    txtSiteMap.Text = Globals.AddHTTP(Globals.GetDomainName(Request)) + @"/SiteMap.aspx";
                }
            }
            optBanners.SelectedIndex = portal.BannerAdvertising;
            if (UserInfo.IsSuperUser)
            {
                lblBanners.Visible = false;
            }
            else
            {
                optBanners.Enabled = portal.BannerAdvertising != 2;
                lblBanners.Visible = portal.BannerAdvertising == 2;
            }
        }
        protected void DeleteAiasesGrid(object source, CommandEventArgs e)
        {
            //Get the index of the row to delete
            int index = Convert.ToInt32(e.CommandArgument);

            //Remove the alias from the aliases collection
            var portalAlias = Aliases[index];

            PortalAliasController.Instance.DeletePortalAlias(portalAlias);
            //should remove the portal's folder if exist
            var portalFolder = PortalController.GetPortalFolder(portalAlias.HTTPAlias);
            var serverPath   = Globals.GetAbsoluteServerPath(Request);

            if (!string.IsNullOrEmpty(portalFolder) && Directory.Exists(serverPath + portalFolder))
            {
                PortalController.DeletePortalFolder(serverPath, portalFolder);
            }

            //Rebind the collection
            _Aliases = null;
            BindAliases();
        }
예제 #6
0
        /// <summary>
        /// cmdUpdate_Click runs when the Update button is clicked
        /// </summary>
        /// <history>
        ///     [cnurse]	5/10/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        protected void cmdUpdate_Click(Object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                try
                {
                    bool   blnChild;
                    string strMessage = String.Empty;
                    string strPortalAlias;
                    int    intCounter;
                    string strServerPath;

                    string strChildPath = String.Empty;

                    PortalController objPortalController = new PortalController();
                    PortalSecurity   objSecurity         = new PortalSecurity();

                    // check template validity
                    ArrayList messages           = new ArrayList();
                    string    schemaFilename     = Server.MapPath("admin/Portal/portal.template.xsd");
                    string    xmlFilename        = Globals.HostMapPath + cboTemplate.SelectedItem.Text + ".template";
                    PortalTemplateValidator xval = new PortalTemplateValidator();
                    if (!xval.Validate(xmlFilename, schemaFilename))
                    {
                        strMessage      = Localization.GetString("InvalidTemplate", this.LocalResourceFile);
                        lblMessage.Text = string.Format(strMessage, cboTemplate.SelectedItem.Text + ".template");
                        messages.AddRange(xval.Errors);
                        lstResults.Visible    = true;
                        lstResults.DataSource = messages;
                        lstResults.DataBind();
                        return;
                    }

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

                    //Validate Portal Name
                    if (PortalSettings.ActiveTab.ParentId != PortalSettings.SuperTabId)
                    {
                        blnChild = true;

                        // child portal
                        for (intCounter = 1; intCounter <= txtPortalName.Text.Length; intCounter++)
                        {
                            if ("abcdefghijklmnopqrstuvwxyz0123456789-".IndexOf(txtPortalName.Text.Substring(intCounter, 1)) == 0)
                            {
                                strMessage += "<br>" + Localization.GetString("InvalidName", this.LocalResourceFile);
                            }
                        }

                        strPortalAlias = txtPortalName.Text;
                    }
                    else
                    {
                        blnChild = optType.SelectedValue == "C";

                        if (blnChild)
                        {
                            strPortalAlias = txtPortalName.Text.Substring(txtPortalName.Text.LastIndexOf("/") + 1);
                        }
                        else
                        {
                            strPortalAlias = txtPortalName.Text;
                        }

                        string strValidChars = "abcdefghijklmnopqrstuvwxyz0123456789-";
                        if (!blnChild)
                        {
                            strValidChars += "./:";
                        }

                        for (intCounter = 1; intCounter <= strPortalAlias.Length; intCounter++)
                        {
                            if (strValidChars.IndexOf(strPortalAlias.Substring(intCounter - 1, 1)) == 0)
                            {
                                strMessage += "<br>" + Localization.GetString("InvalidName", this.LocalResourceFile);
                            }
                        }
                    }

                    //Validate Password
                    if (txtPassword.Text != txtConfirm.Text)
                    {
                        strMessage += "<br>" + Localization.GetString("InvalidPassword", this.LocalResourceFile);
                    }

                    strServerPath = Globals.GetAbsoluteServerPath(Request);

                    //Set Portal Alias for Child Portals
                    if (strMessage == "")
                    {
                        if (blnChild)
                        {
                            strChildPath = strServerPath + strPortalAlias;

                            if (Directory.Exists(strChildPath))
                            {
                                strMessage = Localization.GetString("ChildExists", this.LocalResourceFile);
                            }
                            else
                            {
                                if (PortalSettings.ActiveTab.ParentId != PortalSettings.SuperTabId)
                                {
                                    strPortalAlias = Globals.GetDomainName(Request) + "/" + strPortalAlias;
                                }
                                else
                                {
                                    strPortalAlias = txtPortalName.Text;
                                }
                            }
                        }
                    }

                    //Get Home Directory
                    string HomeDir;
                    if (txtHomeDirectory.Text != "Portals/[PortalID]")
                    {
                        HomeDir = txtHomeDirectory.Text;
                    }
                    else
                    {
                        HomeDir = "";
                    }

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

                        //Attempt to create the portal
                        int intPortalId;
                        try
                        {
                            intPortalId = objPortalController.CreatePortal(txtTitle.Text, txtFirstName.Text, txtLastName.Text, txtUsername.Text, objSecurity.Encrypt(Convert.ToString(Globals.HostSettings["EncryptionKey"]), txtPassword.Text), txtEmail.Text, txtDescription.Text, txtKeyWords.Text, Globals.HostMapPath, strTemplateFile, HomeDir, strPortalAlias, strServerPath, strChildPath, blnChild);
                        }
                        catch (Exception ex)
                        {
                            intPortalId = Null.NullInteger;
                            strMessage  = ex.Message;
                        }

                        if (intPortalId != -1)
                        {
                            // notification
                            UserInfo objUser = UserController.GetUserByName(intPortalId, txtUsername.Text, false);

                            //Create a Portal Settings object for the new Portal
                            PortalSettings newSettings = new PortalSettings();
                            newSettings.PortalAlias           = new PortalAliasInfo();
                            newSettings.PortalAlias.HTTPAlias = strPortalAlias;
                            newSettings.PortalId = intPortalId;
                            string webUrl = Globals.AddHTTP(strPortalAlias);

                            try
                            {
                                if (PortalSettings.ActiveTab.ParentId != PortalSettings.SuperTabId)
                                {
                                    Mail.SendMail(PortalSettings.Email, txtEmail.Text, PortalSettings.Email + ";" + Convert.ToString(PortalSettings.HostSettings["HostEmail"]), Localization.GetSystemMessage(newSettings, "EMAIL_PORTAL_SIGNUP_SUBJECT", objUser), Localization.GetSystemMessage(newSettings, "EMAIL_PORTAL_SIGNUP_BODY", objUser), "", "", "", "", "", "");
                                }
                                else
                                {
                                    Mail.SendMail(Convert.ToString(PortalSettings.HostSettings["HostEmail"]), txtEmail.Text, Convert.ToString(PortalSettings.HostSettings["HostEmail"]), Localization.GetSystemMessage(newSettings, "EMAIL_PORTAL_SIGNUP_SUBJECT", objUser), Localization.GetSystemMessage(newSettings, "EMAIL_PORTAL_SIGNUP_BODY", objUser), "", "", "", "", "", "");
                                }
                            }
                            catch (Exception)
                            {
                                strMessage = string.Format(Localization.GetString("SendMail.Error", this.LocalResourceFile), webUrl, null);
                            }

                            EventLogController objEventLog = new EventLogController();
                            objEventLog.AddLog(objPortalController.GetPortal(intPortalId), PortalSettings, UserId, "", EventLogController.EventLogType.PORTAL_CREATED);

                            // Redirect to this new site
                            if (strMessage == Null.NullString)
                            {
                                Response.Redirect(webUrl, true);
                            }
                        }
                    }

                    lblMessage.Text = "<br>" + strMessage + "<br><br>";
                }
                catch (Exception exc)  //Module failed to load
                {
                    Exceptions.ProcessModuleLoadException(this, exc);
                }
            }
        }