/// <summary> /// Page_Load runs when the control is loaded /// </summary> /// <remarks> /// </remarks> /// <history> /// [cnurse] 11/16/2004 created /// [cnurse] 01/10/2005 added UrlReferrer code so Cancel returns to previous page /// </history> protected void Page_Load(Object sender, EventArgs e) { if (!Page.IsPostBack) { //Get Host Settings (used as default) _defaultSettings = Globals.HostSettings; //Get Search Settings (HostSettings if on Host Tab, Module Settings Otherwise) // ModuleController objModules = new ModuleController(); if (PortalSettings.ActiveTab.ParentId == PortalSettings.SuperTabId) { _settings = Globals.HostSettings; } else { _settings = PortalSettings.GetModuleSettings(ModuleId); } txtMaxWordLength.Text = GetSetting("MaxSearchWordLength"); txtMinWordLength.Text = GetSetting("MinSearchWordLength"); if (GetSetting("SearchIncludeCommon") == "Y") { chkIncludeCommon.Checked = true; } if (GetSetting("SearchIncludeNumeric") == "Y") { chkIncludeNumeric.Checked = true; } // Store URL Referrer to return to portal if (Request.UrlReferrer != null) { if (Request.UrlReferrer.AbsoluteUri == Request.Url.AbsoluteUri) { ViewState["UrlReferrer"] = ""; } else { ViewState["UrlReferrer"] = Convert.ToString(Request.UrlReferrer); } } else { ViewState["UrlReferrer"] = ""; } } if (Convert.ToString(ViewState["UrlReferrer"]) == "") { cmdCancel.Visible = false; } else { cmdCancel.Visible = true; } }
/// <summary> /// Obtain Authentication settings from database /// </summary> /// <remarks> /// Setting records are stored in ModuleSettings table, separately for each portal, /// this method allows each portal could have different accessing method to Windows Active Directory /// </remarks> public Configuration() { PortalSettings _portalSettings = PortalController.GetCurrentPortalSettings(); ProviderConfiguration _providerConfiguration = ProviderConfiguration.GetProviderConfiguration(AUTHENTICATION_KEY); mPortalId = _portalSettings.PortalId; PortalSecurity objSecurity = new PortalSecurity(); try { if (_providerConfiguration.DefaultProvider == null) { // No provider specified, so disable authentication feature return; } else { ModuleController objModules = new ModuleController(); ModuleInfo objModuleInfo = objModules.GetModuleByDefinition(mPortalId, "Site Settings"); Hashtable settings = PortalSettings.GetModuleSettings(objModuleInfo.ModuleID); mWindowsAuthentication = Convert.ToBoolean(Null.GetNull(settings["WindowsAuthentication"], mWindowsAuthentication)); mSynchronizeRole = Convert.ToBoolean(Null.GetNull(settings["SynchronizeRole"], mSynchronizeRole)); mSynchronizePassword = Convert.ToBoolean(Null.GetNull(settings["SynchronizePassword"], mSynchronizePassword)); mRootDomain = Convert.ToString(Null.GetNull(settings["RootDomain"], mRootDomain)); mEmailDomain = Convert.ToString(Null.GetNull(settings["EmailDomain"], mEmailDomain)); mUserName = Convert.ToString(Null.GetNull(settings["UserName"], mUserName)); mProviderTypeName = Convert.ToString(Null.GetNull(settings["ProviderTypeName"], mProviderTypeName)); mAuthenticationType = Convert.ToString(Null.GetNull(settings["AuthenticationType"], mAuthenticationType)); // Since DNN 3.0, HostSettings("EncryptionKey") is empty string, so we handle by AUTHENTICATION_KEY mPassword = objSecurity.Decrypt(AUTHENTICATION_KEY, Convert.ToString(Null.GetNull(settings["AuthenticationPassword"], mPassword.ToString()))); //mPassword = objSecurity.Decrypt(CStr(_portalSettings.HostSettings("EncryptionKey")), CType(GetValue(settings("AuthenticationPassword"), mPassword.ToString), String)) } } catch (Exception) { } }
// The Page_Load event handler on this User Control is used to // obtain a DataReader of banner information from the Banners // table, and then databind the results to a templated DataList // server control. It uses the DotNetNuke.BannerDB() // data component to encapsulate all data functionality. protected void Page_Load(Object sender, EventArgs e) { try { if (!Page.IsPostBack) { // Obtain banner information from the Banners table and bind to the list control BannerTypeController objBannerTypes = new BannerTypeController(); cboType.DataSource = objBannerTypes.GetBannerTypes(); cboType.DataBind(); cboType.Items.Insert(0, new ListItem(Localization.GetString("AllTypes", LocalResourceFile), "-1")); if (ModuleId > 0) { // Get settings from the database Hashtable settings = PortalSettings.GetModuleSettings(ModuleId); if (optSource.Items.FindByValue(Convert.ToString(settings["bannersource"])) != null) { optSource.Items.FindByValue(Convert.ToString(settings["bannersource"])).Selected = true; } else { optSource.Items.FindByValue("L").Selected = true; } if (cboType.Items.FindByValue(Convert.ToString(settings["bannertype"])) != null) { cboType.Items.FindByValue(Convert.ToString(settings["bannertype"])).Selected = true; } DNNTxtBannerGroup.Text = Convert.ToString(Settings["bannergroup"]); if (optOrientation.Items.FindByValue(Convert.ToString(settings["orientation"])) != null) { optOrientation.Items.FindByValue(Convert.ToString(settings["orientation"])).Selected = true; } else { optOrientation.Items.FindByValue("V").Selected = true; } if (Convert.ToString(settings["bannercount"]) != "") { txtCount.Text = Convert.ToString(settings["bannercount"]); } else { txtCount.Text = "1"; } if (Convert.ToString(settings["border"]) != "") { txtBorder.Text = Convert.ToString(settings["border"]); } else { txtBorder.Text = "0"; } if (Convert.ToString(settings["padding"]) != "") { txtPadding.Text = Convert.ToString(settings["padding"]); } else { txtPadding.Text = "4"; } txtBorderColor.Text = Convert.ToString(settings["bordercolor"]); txtRowHeight.Text = Convert.ToString(settings["rowheight"]); txtColWidth.Text = Convert.ToString(settings["colwidth"]); } } } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }
/// <summary> /// GetSearchResults gets the search results for a passed in criteria string /// </summary> /// <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) { //We will assume that the content is in the locale of the Portal PortalController objPortalController = new PortalController(); PortalInfo objPortal = objPortalController.GetPortal(PortalID); string locale = objPortal.DefaultLanguage; Hashtable CommonWords = GetCommonWords(locale); string setting = null; //Get the default Search Settings _defaultSettings = Globals.HostSettings; //Get the Settings for this Portal ModuleController objModuleController = new ModuleController(); ModuleInfo objModule = objModuleController.GetModuleByDefinition(-1, "Search Admin"); if (objModule != null) { _settings = PortalSettings.GetModuleSettings(objModule.ModuleID); } setting = GetSetting("SearchIncludeCommon"); if (setting == "Y") { includeCommon = true; } // clean criteria Criteria = Criteria.ToLower(); // split search criteria into words SearchCriteriaCollection SearchWords = new SearchCriteriaCollection(Criteria); Hashtable SearchResults = new Hashtable(); // iterate through search criteria words SearchCriteria Criterion = null; foreach (SearchCriteria CriterionWithinLoop in SearchWords) { Criterion = CriterionWithinLoop; if (CommonWords.ContainsKey(CriterionWithinLoop.Criteria) == false || includeCommon) { SearchResultsInfoCollection ResultsCollection = SearchDataStoreController.GetSearchResults(PortalID, Criterion.Criteria); if (CriterionWithinLoop.MustExclude == false) { // Add all these to the results foreach (SearchResultsInfo Result in ResultsCollection) { if (SearchResults.ContainsKey(Result.SearchItemID)) { ((SearchResultsInfo)(SearchResults[Result.SearchItemID])).Relevance += Result.Relevance; } else { SearchResults.Add(Result.SearchItemID, Result); } } } } } // Validate MustInclude and MustExclude foreach (SearchCriteria CriterionWithinLoop in SearchWords) { Criterion = CriterionWithinLoop; SearchResultsInfoCollection ResultsCollection = SearchDataStoreController.GetSearchResults(PortalID, Criterion.Criteria); if (CriterionWithinLoop.MustInclude) { // We need to remove items which do not include this term Hashtable MandatoryResults = new Hashtable(); foreach (SearchResultsInfo Result in ResultsCollection) { MandatoryResults.Add(Result.SearchItemID, 0); } foreach (SearchResultsInfo Result in SearchResults.Values) { if (MandatoryResults.ContainsKey(Result.SearchItemID) == false) { Result.Delete = true; } } } if (CriterionWithinLoop.MustExclude) { // We need to remove items which do include this term Hashtable ExcludedResults = new Hashtable(); foreach (SearchResultsInfo Result in ResultsCollection) { ExcludedResults.Add(Result.SearchItemID, 0); } foreach (SearchResultsInfo Result in SearchResults.Values) { if (ExcludedResults.ContainsKey(Result.SearchItemID) == true) { Result.Delete = true; } } } } //Only include results we have permission to see SearchResultsInfoCollection Results = new SearchResultsInfoCollection(); TabController objTabController = new TabController(); Hashtable hashTabsAllowed = new Hashtable(); foreach (SearchResultsInfo SearchResult in SearchResults.Values) { if (!SearchResult.Delete) { //Check If authorised to View Tab Hashtable hashModulesAllowed = null; object tabAllowed = hashTabsAllowed[SearchResult.TabId]; if (tabAllowed == null) { TabInfo objTab = objTabController.GetTab(SearchResult.TabId, PortalID, false); if (PortalSecurity.IsInRoles(objTab.AuthorizedRoles)) { hashModulesAllowed = new Hashtable(); tabAllowed = hashModulesAllowed; } else { tabAllowed = 0; hashModulesAllowed = null; } hashTabsAllowed.Add(SearchResult.TabId, tabAllowed); } else { if (tabAllowed is Hashtable) { hashModulesAllowed = (Hashtable)tabAllowed; } else { hashModulesAllowed = null; } } if (hashModulesAllowed != null) { bool addResult = false; if (!(hashModulesAllowed.ContainsKey(SearchResult.ModuleId))) { //Now check if authorized to view module objModule = objModuleController.GetModule(SearchResult.ModuleId, SearchResult.TabId, false); addResult = (objModule.IsDeleted == false && PortalSecurity.IsInRoles(objModule.AuthorizedViewRoles)); hashModulesAllowed.Add(SearchResult.ModuleId, addResult); } else { addResult = Convert.ToBoolean(hashModulesAllowed[SearchResult.ModuleId]); } if (addResult) { Results.Add(SearchResult); } } } } //Return Search Results Collection return(Results); }