public void AddLog(LogInfo logInfo) { if (Globals.Status == Globals.UpgradeStatus.Install) { AddLogToFile(logInfo); } else { try { logInfo.LogCreateDate = DateTime.Now; logInfo.LogServerName = Globals.ServerName; if (string.IsNullOrEmpty(logInfo.LogServerName)) { logInfo.LogServerName = "NA"; } if (String.IsNullOrEmpty(logInfo.LogUserName)) { if (HttpContext.Current != null) { if (HttpContext.Current.Request.IsAuthenticated) { logInfo.LogUserName = UserController.GetCurrentUserInfo().Username; } } } //Get portal name if name isn't set if (logInfo.LogPortalID != Null.NullInteger && String.IsNullOrEmpty(logInfo.LogPortalName)) { logInfo.LogPortalName = portalController.GetPortal(logInfo.LogPortalID).PortalName; } if (LoggingProvider.Instance() != null) { LoggingProvider.Instance().AddLog(logInfo); } } catch (Exception exc) { Instrumentation.DnnLog.Error(exc); AddLogToFile(logInfo); } } }
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); }
/// ----------------------------------------------------------------------------- /// <summary> /// Wizard_FinishButtonClick runs when the Finish Button on the Wizard is clicked. /// </summary> /// <remarks> /// </remarks> /// <history> /// [cnurse] 10/12/2004 created /// </history> /// ----------------------------------------------------------------------------- protected void OnWizardFinishedClick(object sender, WizardNavigationEventArgs e) { var objPortalController = new PortalController(); //use Portal Template to update portal content pages if (lstTemplate.SelectedIndex != -1) { string strTemplateFile = lstTemplate.SelectedItem.Text + ".template"; //process zip resource file if present objPortalController.ProcessResourceFile(PortalSettings.HomeDirectoryMapPath, Globals.HostMapPath + strTemplateFile); //Process Template switch (optMerge.SelectedValue) { case "Ignore": objPortalController.ParseTemplate(PortalId, Globals.HostMapPath, strTemplateFile, PortalSettings.AdministratorId, PortalTemplateModuleAction.Ignore, false); break; case "Replace": objPortalController.ParseTemplate(PortalId, Globals.HostMapPath, strTemplateFile, PortalSettings.AdministratorId, PortalTemplateModuleAction.Replace, false); break; case "Merge": objPortalController.ParseTemplate(PortalId, Globals.HostMapPath, strTemplateFile, PortalSettings.AdministratorId, PortalTemplateModuleAction.Merge, false); break; } } //update Portal info in the database PortalInfo objPortal = objPortalController.GetPortal(PortalId); objPortal.Description = txtDescription.Text; objPortal.KeyWords = txtKeyWords.Text; objPortal.PortalName = txtPortalName.Text; objPortal.LogoFile = urlLogo.Url; objPortalController.UpdatePortalInfo(objPortal); //Set Portal Skin SkinController.SetSkin(SkinController.RootSkin, PortalId, SkinType.Portal, ctlPortalSkin.SkinSrc); SkinController.SetSkin(SkinController.RootSkin, PortalId, SkinType.Admin, ctlPortalSkin.SkinSrc); //Set Portal Container SkinController.SetSkin(SkinController.RootContainer, PortalId, SkinType.Portal, ctlPortalContainer.SkinSrc); SkinController.SetSkin(SkinController.RootContainer, PortalId, SkinType.Admin, ctlPortalContainer.SkinSrc); }
private void cmdPurchase_Click(Object sender, EventArgs e) { try { string strPaymentProcessor = ""; string strProcessorUserId = ""; string strProcessorPassword = ""; if (Page.IsValid) { var objPortalController = new PortalController(); PortalInfo objPortalInfo = objPortalController.GetPortal(PortalSettings.PortalId); if (objPortalInfo != null) { strPaymentProcessor = objPortalInfo.PaymentProcessor; strProcessorUserId = objPortalInfo.ProcessorUserId; strProcessorPassword = objPortalInfo.ProcessorPassword; } if (strPaymentProcessor == "PayPal") { //build secure PayPal URL string strPayPalURL = ""; strPayPalURL = "https://www.paypal.com/xclick/business=" + Globals.HTTPPOSTEncode(strProcessorUserId); strPayPalURL = strPayPalURL + "&item_name=" + Globals.HTTPPOSTEncode(PortalSettings.PortalName + " - " + lblDescription.Text + " ( " + txtUnits.Text + " units @ " + lblFee.Text + " " + lblFeeCurrency.Text + " per " + lblFrequency.Text + " )"); strPayPalURL = strPayPalURL + "&item_number=" + Globals.HTTPPOSTEncode(Convert.ToString(RoleID)); strPayPalURL = strPayPalURL + "&quantity=1"; strPayPalURL = strPayPalURL + "&custom=" + Globals.HTTPPOSTEncode(UserInfo.UserID.ToString()); strPayPalURL = strPayPalURL + "&amount=" + Globals.HTTPPOSTEncode(lblTotal.Text); strPayPalURL = strPayPalURL + "¤cy_code=" + Globals.HTTPPOSTEncode(lblTotalCurrency.Text); strPayPalURL = strPayPalURL + "&return=" + Globals.HTTPPOSTEncode("http://" + Globals.GetDomainName(Request)); strPayPalURL = strPayPalURL + "&cancel_return=" + Globals.HTTPPOSTEncode("http://" + Globals.GetDomainName(Request)); strPayPalURL = strPayPalURL + "¬ify_url=" + Globals.HTTPPOSTEncode("http://" + Globals.GetDomainName(Request) + "/admin/Sales/PayPalIPN.aspx"); strPayPalURL = strPayPalURL + "&undefined_quantity=&no_note=1&no_shipping=1"; //redirect to PayPal Response.Redirect(strPayPalURL, true); } } } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }
public override ConsoleResultModel Run() { var pc = new PortalController(); var lst = new List <PortalModel>(); var portal = pc.GetPortal((int)PortalIdFlagValue); if (portal == null) { return(new ConsoleErrorResultModel(string.Format(LocalizeString("Prompt_GetPortal_NotFound"), PortalIdFlagValue))); } lst.Add(new PortalModel(portal)); return(new ConsoleResultModel(string.Empty) { Data = lst, Records = lst.Count, Output = string.Format(LocalizeString("Prompt_GetPortal_Found"), PortalIdFlagValue) }); }
protected void Page_Load(object sender, EventArgs e) { try { PortalController pctrl = new PortalController(); _currentPortal = pctrl.GetPortal(PortalId); var tc = new RestaurantMenuItemRepository(); IEnumerable <RestaurantMenuItem> items = tc.GetItems(ModuleId); _hasItems = items.Any(); rptItemList.DataSource = items; rptItemList.DataBind(); } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }
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); }
/// <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> /// <history> /// [cnurse] 9/9/2004 Modified /// [VMasanas] 9/12/2004 Move skin deassignment to DeletePortalInfo. /// </history> protected void cmdDelete_Click(object sender, EventArgs e) { try { PortalController objPortalController = new PortalController(); PortalInfo objPortalInfo = objPortalController.GetPortal(intPortalId); if (objPortalInfo != null) { string strMessage = PortalController.DeletePortal(objPortalInfo, Globals.GetAbsoluteServerPath(Request)); if (string.IsNullOrEmpty(strMessage)) { EventLogController objEventLog = new EventLogController(); objEventLog.AddLog("PortalName", objPortalInfo.PortalName, PortalSettings, UserId, EventLogController.EventLogType.PORTAL_DELETED); // Redirect to another site if (intPortalId == PortalId) { if (PortalSettings.HostSettings["HostURL"].ToString() != "") { Response.Redirect(Globals.AddHTTP(PortalSettings.HostSettings["HostURL"].ToString())); } else { Response.End(); } } else { Response.Redirect(Convert.ToString(ViewState["UrlReferrer"]), true); } } else { UI.Skins.Skin.AddModuleMessage(this, strMessage, ModuleMessageType.RedError); } } } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }
/// ----------------------------------------------------------------------------- /// <summary> /// Page_Load runs when the control is loaded /// </summary> /// <remarks> /// </remarks> /// <history> /// [cnurse] 10/11/2004 created /// </history> /// ----------------------------------------------------------------------------- protected override void OnLoad(EventArgs e) { base.OnLoad(e); chkIncludeAll.CheckedChanged += OnIncludeAllCheckChanged; chkTemplate.CheckedChanged += OnTemplateCheckChanged; lstTemplate.SelectedIndexChanged += OnTemplateSelectedIndexChanged; Wizard.ActiveStepChanged += OnWizardActiveStepChanged; Wizard.FinishButtonClick += OnWizardFinishedClick; Wizard.NextButtonClick += OnWizardNextClick; try { if (!Page.IsPostBack) { //Get Templates for Page 1 GetTemplates(); chkTemplate.Checked = false; lstTemplate.Enabled = false; //Get Skins for Pages 2 GetSkins(); //Get Details for Page 4 var objPortalController = new PortalController(); var objPortal = objPortalController.GetPortal(PortalId); txtPortalName.Text = objPortal.PortalName; txtDescription.Text = objPortal.Description; txtKeyWords.Text = objPortal.KeyWords; //Get Details for Page 5 ctlLogo.FilePath = objPortal.LogoFile; ctlLogo.FileFilter = Globals.glbImageFileTypes; UseTemplate(); } } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }
protected bool ShowSubscribe(int roleID) { bool showSubscribe = Null.NullBoolean; RoleInfo objRole = TestableRoleController.Instance.GetRole(PortalSettings.PortalId, r => r.RoleID == roleID);; if (objRole.IsPublic) { var objPortals = new PortalController(); PortalInfo objPortal = objPortals.GetPortal(PortalSettings.PortalId); if (objRole.ServiceFee == 0.0) { showSubscribe = true; } else if (objPortal != null && !string.IsNullOrEmpty(objPortal.ProcessorUserId)) { showSubscribe = true; } } return(showSubscribe); }
private static IEnumerable <PortalInfo> GetCurrentPortalsGroup() { var groups = PortalGroupController.Instance.GetPortalGroups().ToArray(); var result = (from @group in groups select PortalGroupController.Instance.GetPortalsByGroup(@group.PortalGroupId) into portals where portals.Any(x => x.PortalID == PortalSettings.Current.PortalId) select portals.ToArray()).FirstOrDefault(); // Are we in a group of one? if (result == null || result.Length == 0) { var portalController = new PortalController(); result = new[] { portalController.GetPortal(PortalSettings.Current.PortalId) }; } return(result); }
public ConsoleResultModel Run() { PortalController pc = new PortalController(); List <PortalModel> lst = new List <PortalModel>(); if (PortalIdFlagValue.HasValue) { PortalInfo portal = pc.GetPortal((int)PortalIdFlagValue); if (portal == null) { return(new ConsoleErrorResultModel($"Could not find a portal with ID of '{PortalIdFlagValue}'")); } lst.Add(new PortalModel(portal)); } return(new ConsoleResultModel(string.Empty) { data = lst }); }
/// <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(); } }
//111113 custom code end #endregion #region Action //131113 custom code protected void UpdateClones(object sender, EventArgs e) { List <int> tabslist = null; ModuleController objmodules = new ModuleController(); TabController objTabs = new TabController(); string sv = string.Empty; int ftabId = -1; int fmoduleId = -1; if (!string.IsNullOrEmpty(cbModulesList.SelectedValue)) { sv = cbModulesList.SelectedValue; string svmid = sv.Split('|')[0]; string svtid = sv.Split('|')[1]; fmoduleId = Convert.ToInt32(svmid); ftabId = Convert.ToInt32(svtid); var tabsbymodule = objTabs.GetTabsByModuleID(fmoduleId); // get all tabs by moduleId tabslist = tabsbymodule.Keys.ToList(); } StringBuilder actionBuilder = new StringBuilder(); actionBuilder.Append("<div class=\"dnnFormMessage dnnFormSuccess\">"); // clone or delete tabs modules CloneOrDeleteTabModules(tabslist, objmodules, objTabs, ftabId, fmoduleId, actionBuilder); lblActions.Text = actionBuilder.ToString(); // refresh RadTree var portalController = new PortalController(); var portalInfo = portalController.GetPortal(PortalId); BindTree(tabslist, portalInfo); BindFilters(objmodules, sv); }
private static ISet <string> GetStopWords() { int portalId; string cultureCode; var searchDoc = Thread.GetData(Thread.GetNamedDataSlot(Constants.TlsSearchInfo)) as SearchDocument; if (searchDoc == null) { portalId = 0; // default cultureCode = Thread.CurrentThread.CurrentCulture.Name; } else { portalId = searchDoc.PortalId; cultureCode = searchDoc.CultureCode; if (string.IsNullOrEmpty(cultureCode)) { var portalInfo = PortalController.GetPortal(portalId); if (portalInfo != null) { cultureCode = portalInfo.DefaultLanguage; } } } var stops = StopAnalyzer.ENGLISH_STOP_WORDS_SET; var searchStopWords = SearchHelper.Instance.GetSearchStopWords(portalId, cultureCode); if (searchStopWords != null && !string.IsNullOrEmpty(searchStopWords.StopWords)) { //TODO Use cache from InternalSearchController var strArray = searchStopWords.StopWords.Split(','); var set = new CharArraySet(strArray.Length, false); set.AddAll(strArray); stops = CharArraySet.UnmodifiableSet(set); } return(stops); }
protected void updateButton_Click(object sender, EventArgs e) { PortalController.UpdatePortalSetting(ModuleContext.PortalId, "EnableBrowserLanguage", chkBrowser.Checked.ToString()); PortalController.UpdatePortalSetting(ModuleContext.PortalId, "AllowUserUICulture", chkUserCulture.Checked.ToString()); // if contentlocalization is enabled, default language cannot be changed if (!PortalSettings.ContentLocalizationEnabled) { // first check whether or not portal default language has changed string newDefaultLanguage = languagesComboBox.SelectedValue; if (newDefaultLanguage != PortalSettings.DefaultLanguage) { var needToRemoveOldDefaultLanguage = LocaleController.Instance.GetLocales(PortalId).Count == 1; var OldDefaultLanguage = LocaleController.Instance.GetLocale(PortalDefault); if (!IsLanguageEnabled(newDefaultLanguage)) { var language = LocaleController.Instance.GetLocale(newDefaultLanguage); Localization.AddLanguageToPortal(ModuleContext.PortalId, language.LanguageId, true); } // update portal default language var objPortalController = new PortalController(); PortalInfo objPortal = objPortalController.GetPortal(PortalId); objPortal.DefaultLanguage = newDefaultLanguage; objPortalController.UpdatePortalInfo(objPortal); _PortalDefault = newDefaultLanguage; if (needToRemoveOldDefaultLanguage) { Localization.RemoveLanguageFromPortal(PortalId, OldDefaultLanguage.LanguageId); } } PortalController.UpdatePortalSetting(ModuleContext.PortalId, "EnableUrlLanguage", chkUrl.Checked.ToString()); } BindDefaultLanguageSelector(); BindGrid(); }
/// <summary> /// Page_Load runs when the control is loaded /// </summary> /// <history> /// [cnurse] 10/11/2004 created /// </history> protected void Page_Load(Object sender, EventArgs e) { try { Wizard.StartNextButtonText = "<img src=\"" + Globals.ApplicationPath + "/images/rt.gif\" border=\"0\" /> " + Localization.GetString("Next", this.LocalResourceFile); Wizard.StepNextButtonText = "<img src=\"" + Globals.ApplicationPath + "/images/rt.gif\" border=\"0\" /> " + Localization.GetString("Next", this.LocalResourceFile); Wizard.StepPreviousButtonText = "<img src=\"" + Globals.ApplicationPath + "/images/lt.gif\" border=\"0\" /> " + Localization.GetString("Previous", this.LocalResourceFile); Wizard.FinishPreviousButtonText = "<img src=\"" + Globals.ApplicationPath + "/images/lt.gif\" border=\"0\" /> " + Localization.GetString("Previous", this.LocalResourceFile); Wizard.FinishCompleteButtonText = "<img src=\"" + Globals.ApplicationPath + "/images/save.gif\" border=\"0\" /> " + Localization.GetString("Finish", this.LocalResourceFile); if (!Page.IsPostBack) { //Get Templates for Page 1 GetTemplates(); chkTemplate.Checked = false; lstTemplate.Enabled = false; //Get Skins for Pages 2 GetSkins(); //Get Details for Page 4 PortalController objPortalController = new PortalController(); PortalInfo objPortal = objPortalController.GetPortal(PortalId); txtPortalName.Text = objPortal.PortalName; txtDescription.Text = objPortal.Description; txtKeyWords.Text = objPortal.KeyWords; //Get Details for Page 5 urlLogo.Url = objPortal.LogoFile; urlLogo.FileFilter = Globals.glbImageFileTypes; UseTemplate(); } } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }
public bool DeleteUserRole(int PortalId, int UserId, int RoleId) { UserInfo objUser = UserController.GetUserById(PortalId, UserId); UserRoleInfo objUserRole = GetUserRole(PortalId, UserId, RoleId); PortalController objPortals = new PortalController(); bool blnDelete = true; PortalInfo objPortal = objPortals.GetPortal(PortalId); if (objPortal != null && objUserRole != null) { if (CanRemoveUserFromRole(objPortal, UserId, RoleId)) { provider.RemoveUserFromRole(PortalId, objUser, objUserRole); Services.Log.EventLog.EventLogController objEventLog = new Services.Log.EventLog.EventLogController(); objEventLog.AddLog(objUserRole, PortalController.GetCurrentPortalSettings(), UserController.GetCurrentUserInfo().UserID, "", Services.Log.EventLog.EventLogController.EventLogType.ROLE_UPDATED); } else { blnDelete = false; } } return(blnDelete); }
/// <summary> /// [jmarino] 2011-06-16 Check for ContainsKey for a write added /// </summary> /// <param name="portalId"></param> /// <returns></returns> private static string GetCacheFolder(int portalId) { string cacheFolder; using (var readerLock = CacheFolderPath.GetReadLock()) { if (CacheFolderPath.TryGetValue(portalId, out cacheFolder)) { return(cacheFolder); } } var portalController = new PortalController(); PortalInfo portalInfo = portalController.GetPortal(portalId); string homeDirectoryMapPath = portalInfo.HomeDirectoryMapPath; if (!(string.IsNullOrEmpty(homeDirectoryMapPath))) { cacheFolder = string.Concat(homeDirectoryMapPath, "Cache\\Pages\\"); if (!(Directory.Exists(cacheFolder))) { Directory.CreateDirectory(cacheFolder); } } using (var writerLock = CacheFolderPath.GetWriteLock()) { if (!CacheFolderPath.ContainsKey(portalId)) { CacheFolderPath.Add(portalId, cacheFolder); } } return(cacheFolder); }
/// <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); }
/// <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> /// <history> /// [cnurse] 9/9/2004 Modified /// </history> protected void cmdRestore_Click(object sender, EventArgs e) { try { PortalController objPortalController = new PortalController(); PortalInfo objPortal = objPortalController.GetPortal(intPortalId); if (objPortal != null) { if (File.Exists(objPortal.HomeDirectoryMapPath + "portal.css")) { // delete existing style sheet File.Delete(objPortal.HomeDirectoryMapPath + "portal.css"); } // copy the default style sheet to the upload directory File.Copy(Globals.HostMapPath + "portal.css", objPortal.HomeDirectoryMapPath + "portal.css"); } LoadStyleSheet(); } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }
/// ----------------------------------------------------------------------------- /// <summary> /// Exports the selected portal /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <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 /// [aprasad] 1/17/2011 New setting AutoAddPortalAlias /// </history> /// ----------------------------------------------------------------------------- private void cmdExport_Click(Object sender, EventArgs e) { try { ZipOutputStream resourcesFile; var sb = new StringBuilder(); var settings = new XmlWriterSettings(); settings.ConformanceLevel = ConformanceLevel.Fragment; settings.OmitXmlDeclaration = true; settings.Indent = true; if (!Page.IsValid) { return; } string filename; filename = Globals.HostMapPath + txtTemplateName.Text; if (!filename.EndsWith(".template")) { filename += ".template"; } XmlWriter writer = XmlWriter.Create(filename, settings); writer.WriteStartElement("portal"); writer.WriteAttributeString("version", "5.0"); //Add template description writer.WriteElementString("description", Server.HtmlEncode(txtDescription.Text)); //Serialize portal settings PortalInfo objportal; var objportals = new PortalController(); objportal = objportals.GetPortal(Convert.ToInt32(cboPortals.SelectedValue)); writer.WriteStartElement("settings"); writer.WriteElementString("logofile", objportal.LogoFile); writer.WriteElementString("footertext", objportal.FooterText); writer.WriteElementString("userregistration", objportal.UserRegistration.ToString()); writer.WriteElementString("banneradvertising", objportal.BannerAdvertising.ToString()); writer.WriteElementString("defaultlanguage", objportal.DefaultLanguage); Dictionary <string, string> settingsDictionary = PortalController.GetPortalSettingsDictionary(objportal.PortalID); string setting = ""; settingsDictionary.TryGetValue("DefaultPortalSkin", out setting); if (!string.IsNullOrEmpty(setting)) { writer.WriteElementString("skinsrc", setting); } settingsDictionary.TryGetValue("DefaultAdminSkin", out setting); if (!string.IsNullOrEmpty(setting)) { writer.WriteElementString("skinsrcadmin", setting); } settingsDictionary.TryGetValue("DefaultPortalContainer", out setting); if (!string.IsNullOrEmpty(setting)) { writer.WriteElementString("containersrc", setting); } settingsDictionary.TryGetValue("DefaultAdminContainer", out setting); if (!string.IsNullOrEmpty(setting)) { writer.WriteElementString("containersrcadmin", setting); } settingsDictionary.TryGetValue("EnableSkinWidgets", out setting); if (!string.IsNullOrEmpty(setting)) { writer.WriteElementString("enableskinwidgets", setting); } settingsDictionary.TryGetValue("portalaliasmapping", out setting); if (!String.IsNullOrEmpty(setting)) { writer.WriteElementString("portalaliasmapping", setting); } settingsDictionary.TryGetValue("ContentLocalizationEnabled", out setting); if (!String.IsNullOrEmpty(setting)) { writer.WriteElementString("contentlocalizationenabled", setting); } settingsDictionary.TryGetValue("TimeZone", out setting); if (!string.IsNullOrEmpty(setting)) { writer.WriteElementString("timezone", setting); } writer.WriteElementString("hostspace", objportal.HostSpace.ToString()); writer.WriteElementString("userquota", objportal.UserQuota.ToString()); writer.WriteElementString("pagequota", objportal.PageQuota.ToString()); //End Portal Settings writer.WriteEndElement(); //Serialize Profile Definitions SerializeProfileDefinitions(writer, objportal); //Serialize Portal Desktop Modules DesktopModuleController.SerializePortalDesktopModules(writer, objportal.PortalID); //Serialize Roles RoleController.SerializeRoleGroups(writer, objportal.PortalID); //Serialize tabs SerializeTabs(writer, objportal); if (chkContent.Checked) { //Create Zip File to hold files resourcesFile = new ZipOutputStream(File.Create(filename + ".resources")); resourcesFile.SetLevel(6); //Serialize folders (while adding files to zip file) SerializeFolders(writer, objportal, ref resourcesFile); //Finish and Close Zip file resourcesFile.Finish(); resourcesFile.Close(); } writer.WriteEndElement(); writer.Close(); DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, "", string.Format(Localization.GetString("ExportedMessage", LocalResourceFile), filename), ModuleMessage.ModuleMessageType.GreenSuccess); } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
/// ----------------------------------------------------------------------------- /// <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.FindItemByValue("N").Selected = true; cboTrialFrequency.DataSource = colFrequencies; cboTrialFrequency.DataBind(); cboTrialFrequency.FindItemByValue("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.AddItem(enumItem.Text, enumItem.Value); } 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.AddItem(enumItem.Text, enumItem.Value); } BindGroups(); ctlIcon.FileFilter = Globals.glbImageFileTypes; if (_roleID != -1) { var role = TestableRoleController.Instance.GetRole(PortalSettings.PortalId, r => r.RoleID == _roleID); if (role != null) { lblRoleName.Visible = role.IsSystemRole; txtRoleName.Visible = !role.IsSystemRole; valRoleName.Enabled = !role.IsSystemRole; lblRoleName.Text = role.RoleName; txtRoleName.Text = role.RoleName; txtDescription.Text = role.Description; if (cboRoleGroups.FindItemByValue(role.RoleGroupID.ToString(CultureInfo.InvariantCulture)) != null) { cboRoleGroups.ClearSelection(); cboRoleGroups.FindItemByValue(role.RoleGroupID.ToString(CultureInfo.InvariantCulture)).Selected = true; } if (!String.IsNullOrEmpty(role.BillingFrequency)) { if (role.ServiceFee > 0) { txtServiceFee.Text = role.ServiceFee.ToString("N2", CultureInfo.CurrentCulture); txtBillingPeriod.Text = role.BillingPeriod.ToString(CultureInfo.InvariantCulture); if (cboBillingFrequency.FindItemByValue(role.BillingFrequency) != null) { cboBillingFrequency.ClearSelection(); cboBillingFrequency.FindItemByValue(role.BillingFrequency).Selected = true; } } } if (!String.IsNullOrEmpty(role.TrialFrequency)) { if (role.TrialFee > 0) { txtTrialFee.Text = role.TrialFee.ToString("N2", CultureInfo.CurrentCulture); txtTrialPeriod.Text = role.TrialPeriod.ToString(CultureInfo.InvariantCulture); if (cboTrialFrequency.FindItemByValue(role.TrialFrequency) != null) { cboTrialFrequency.ClearSelection(); cboTrialFrequency.FindItemByValue(role.TrialFrequency).Selected = true; } } } if (securityModeList.FindItemByValue(Convert.ToString((int)role.SecurityMode)) != null) { securityModeList.ClearSelection(); securityModeList.FindItemByValue(Convert.ToString((int)role.SecurityMode)).Selected = true; } if (statusList.FindItemByValue(Convert.ToString((int)role.Status)) != null) { statusList.ClearSelection(); statusList.FindItemByValue(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 (role.IsSystemRole) //disable controls if it's a system role { UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("SystemRoleWarning.Text", LocalResourceFile), ModuleMessage.ModuleMessageType.BlueInfo); 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.FindItemByValue(roleGroupID) != null) { cboRoleGroups.ClearSelection(); cboRoleGroups.FindItemByValue(roleGroupID).Selected = true; } } } } } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); try { bool blnValid = true; // string strTransactionID; int intRoleID = 0; int intPortalID = PortalSettings.PortalId; int intUserID = 0; // string strDescription; double dblAmount = 0; // string strEmail; bool blnCancel = false; string strPayPalID = Null.NullString; var objRoles = new RoleController(); var objPortalController = new PortalController(); string strPost = "cmd=_notify-validate"; foreach (string strName in Request.Form) { string strValue = Request.Form[strName]; switch (strName) { case "txn_type": //get the transaction type string strTransactionType = strValue; switch (strTransactionType) { case "subscr_signup": case "subscr_payment": case "web_accept": break; case "subscr_cancel": blnCancel = true; break; default: blnValid = false; break; } break; case "payment_status": //verify the status if (strValue != "Completed") { blnValid = false; } break; case "txn_id": //verify the transaction id for duplicates // strTransactionID = strValue; break; case "receiver_email": //verify the PayPalId strPayPalID = strValue; break; case "mc_gross": // verify the price dblAmount = double.Parse(strValue); break; case "item_number": //get the RoleID intRoleID = Int32.Parse(strValue); //RoleInfo objRole = objRoles.GetRole(intRoleID, intPortalID); break; case "item_name": //get the product description // strDescription = strValue; break; case "custom": //get the UserID intUserID = Int32.Parse(strValue); break; case "email": //get the email // strEmail = strValue; break; } //reconstruct post for postback validation strPost += string.Format("&{0}={1}", Globals.HTTPPOSTEncode(strName), Globals.HTTPPOSTEncode(strValue)); } //postback to verify the source if (blnValid) { Dictionary <string, string> settings = PortalController.GetPortalSettingsDictionary(PortalSettings.PortalId); string strPayPalURL; // 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?"; } var objRequest = (HttpWebRequest)WebRequest.Create(strPayPalURL); objRequest.Method = "POST"; objRequest.ContentLength = strPost.Length; objRequest.ContentType = "application/x-www-form-urlencoded"; using (var objStream = new StreamWriter(objRequest.GetRequestStream())) { objStream.Write(strPost); } string strResponse; using (var objResponse = (HttpWebResponse)objRequest.GetResponse()) { using (var sr = new StreamReader(objResponse.GetResponseStream())) { strResponse = sr.ReadToEnd(); } } switch (strResponse) { case "VERIFIED": break; default: //possible fraud blnValid = false; break; } } if (blnValid) { int intAdministratorRoleId = 0; string strProcessorID = Null.NullString; PortalInfo objPortalInfo = objPortalController.GetPortal(intPortalID); if (objPortalInfo != null) { intAdministratorRoleId = objPortalInfo.AdministratorRoleId; strProcessorID = objPortalInfo.ProcessorUserId.ToLower(); } if (intRoleID == intAdministratorRoleId) { //admin portal renewal strProcessorID = Host.ProcessorUserId.ToLower(); float portalPrice = objPortalInfo.HostFee; if ((portalPrice.ToString() == dblAmount.ToString()) && (HttpUtility.UrlDecode(strPayPalID.ToLower()) == strProcessorID)) { objPortalController.UpdatePortalExpiry(intPortalID); } else { var objEventLog = new EventLogController(); var objEventLogInfo = new LogInfo(); objEventLogInfo.LogPortalID = intPortalID; objEventLogInfo.LogPortalName = PortalSettings.PortalName; objEventLogInfo.LogUserID = intUserID; objEventLogInfo.LogTypeKey = "POTENTIAL PAYPAL PAYMENT FRAUD"; objEventLog.AddLog(objEventLogInfo); } } else { //user subscription RoleInfo objRoleInfo = TestableRoleController.Instance.GetRole(intPortalID, r => r.RoleID == intRoleID); float rolePrice = objRoleInfo.ServiceFee; float trialPrice = objRoleInfo.TrialFee; if ((rolePrice.ToString() == dblAmount.ToString() || trialPrice.ToString() == dblAmount.ToString()) && (HttpUtility.UrlDecode(strPayPalID.ToLower()) == strProcessorID)) { objRoles.UpdateUserRole(intPortalID, intUserID, intRoleID, blnCancel); } else { var objEventLog = new EventLogController(); var objEventLogInfo = new LogInfo(); objEventLogInfo.LogPortalID = intPortalID; objEventLogInfo.LogPortalName = PortalSettings.PortalName; objEventLogInfo.LogUserID = intUserID; objEventLogInfo.LogTypeKey = "POTENTIAL PAYPAL PAYMENT FRAUD"; objEventLog.AddLog(objEventLogInfo); } } } } catch (Exception exc) //Page failed to load { Exceptions.ProcessPageLoadException(exc); } }
/// ----------------------------------------------------------------------------- /// <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) { PortalController.PortalTemplateInfo template = LoadPortalTemplateInfoForSelectedItem(); 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 = template.TemplateFilePath; var xval = new PortalTemplateValidator(); if (!xval.Validate(xmlFilename, schemaFilename)) { UI.Skins.Skin.AddModuleMessage(this, "", String.Format(Localization.GetString("InvalidTemplate", LocalResourceFile), Path.GetFileName(template.TemplateFilePath)), ModuleMessage.ModuleMessageType.RedError); messages.AddRange(xval.Errors); lstResults.Visible = true; lstResults.DataSource = messages; lstResults.DataBind(); validationPanel.Visible = true; return; } //Set Portal Name txtPortalAlias.Text = txtPortalAlias.Text.ToLowerInvariant(); txtPortalAlias.Text = txtPortalAlias.Text.Replace("http://", ""); //Validate Portal Name if (!Globals.IsHostTab(PortalSettings.ActiveTab.TabID)) { blnChild = true; strPortalAlias = txtPortalAlias.Text; } else { blnChild = (optType.SelectedValue == "C"); strPortalAlias = blnChild ? PortalController.GetPortalFolder(txtPortalAlias.Text) : txtPortalAlias.Text; } string message = String.Empty; ModuleMessage.ModuleMessageType messageType = ModuleMessage.ModuleMessageType.RedError; if (!PortalAliasController.ValidateAlias(strPortalAlias, blnChild)) { message = Localization.GetString("InvalidName", LocalResourceFile); } //check whether have conflict between tab path and portal alias. var checkTabPath = string.Format("//{0}", strPortalAlias); if (TabController.GetTabByTabPath(PortalSettings.PortalId, checkTabPath, string.Empty) != Null.NullInteger || TabController.GetTabByTabPath(Null.NullInteger, checkTabPath, string.Empty) != Null.NullInteger) { message = Localization.GetString("DuplicateWithTab", 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 = txtPortalAlias.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)) { //Attempt to create the portal UserInfo adminUser = new UserInfo(); int intPortalId; try { if (useCurrent.Checked) { adminUser = UserInfo; intPortalId = objPortalController.CreatePortal(txtPortalName.Text, adminUser.UserID, txtDescription.Text, txtKeyWords.Text, template, homeDir, strPortalAlias, strServerPath, strChildPath, blnChild); } else { adminUser = new UserInfo { FirstName = txtFirstName.Text, LastName = txtLastName.Text, Username = txtUsername.Text, DisplayName = txtFirstName.Text + " " + txtLastName.Text, Email = txtEmail.Text, IsSuperUser = false, Membership = { Approved = true, Password = txtPassword.Text, PasswordQuestion = txtQuestion.Text, PasswordAnswer = txtAnswer.Text }, Profile = { FirstName = txtFirstName.Text, LastName = txtLastName.Text } }; intPortalId = objPortalController.CreatePortal(txtPortalName.Text, adminUser, txtDescription.Text, txtKeyWords.Text, template, 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", adminUser), Localization.GetSystemMessage(newSettings, "EMAIL_PORTAL_SIGNUP_BODY", adminUser), "", "", "", "", "", ""); } else { message = Mail.SendMail(Host.HostEmail, txtEmail.Text, Host.HostEmail, Localization.GetSystemMessage(newSettings, "EMAIL_PORTAL_SIGNUP_SUBJECT", adminUser), Localization.GetSystemMessage(newSettings, "EMAIL_PORTAL_SIGNUP_BODY", adminUser), "", "", "", "", "", ""); } } catch (Exception exc) { Logger.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); // mark default language as published if content localization is enabled bool ContentLocalizationEnabled = PortalController.GetPortalSettingAsBoolean("ContentLocalizationEnabled", PortalId, false); if (ContentLocalizationEnabled) { LocaleController lc = new LocaleController(); lc.PublishLanguage(intPortalId, objPortal.DefaultLanguage, true); } //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); } } }
/// ----------------------------------------------------------------------------- /// <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); }
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"].ToLower() == "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"; RoleInfo objRole = TestableRoleController.Instance.GetRole(PortalSettings.PortalId, r => r.RoleID == intRoleId); 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 += "¤cy_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 + " " + GetBillingFrequencyText(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 += "¤cy_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 Logger.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 += "¬ify_url=" + Globals.HTTPPOSTEncode(settings["paypalsubscriptionnotifyurl"]); } else { strPayPalURL += "¬ify_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); } }
/// <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); } } }
/// <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); } }
protected void Page_Load(object sender, EventArgs e) { try { PortalController objPortals = new PortalController(); if (Request.QueryString["pid"] != null && (PortalSettings.ActiveTab.ParentId == PortalSettings.SuperTabId || UserController.GetCurrentUserInfo().IsSuperUser)) { _objPortal = objPortals.GetPortal(int.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); } }