public HttpResponseMessage Search(string q)
        {
            var portalId = PortalController.GetEffectivePortalId(PortalSettings.PortalId);

            var controller = new ListController();

			ListEntryInfo imageType = controller.GetListEntryInfo("DataType", "Image");

            IList<SearchResult> results = new List<SearchResult>();
            foreach (var definition in ProfileController.GetPropertyDefinitionsByPortal(portalId)
                                        .Cast<ProfilePropertyDefinition>()
										.Where(definition => definition.DataType != imageType.EntryID))
            {
                AddProperty(results, definition.PropertyName, q);
            }

            AddProperty(results, "Email", q);
            AddProperty(results, "DisplayName", q);
            AddProperty(results, "Username", q);
            AddProperty(results, "Password", q);
            AddProperty(results, "PasswordConfirm", q);
            AddProperty(results, "PasswordQuestion", q);
            AddProperty(results, "PasswordAnswer", q);

            return Request.CreateResponse(HttpStatusCode.OK, results.OrderBy(sr => sr.id));
        }
 private static string DisplayDataType(ProfilePropertyDefinition definition)
 {
     string cacheKey = string.Format("DisplayDataType:{0}", definition.DataType);
     string strDataType = Convert.ToString(DataCache.GetCache(cacheKey)) + "";
     if (strDataType == string.Empty)
     {
         var objListController = new ListController();
         strDataType = objListController.GetListEntryInfo(definition.DataType).Value;
         DataCache.SetCache(cacheKey, strDataType);
     }
     return strDataType;
 }
Example #3
0
        public ActionResult Search(string q)
        {
            try
            {
                var portalId = PortalController.GetEffectivePortalId(PortalSettings.PortalId);

                var controller = new ListController();

                var textType = controller.GetListEntryInfo("DataType", "Text");
                var regionType = controller.GetListEntryInfo("DataType", "Region");
                var countryType = controller.GetListEntryInfo("DataType", "Country");

                IList<SearchResult> results = new List<SearchResult>();
                foreach (var definition in ProfileController.GetPropertyDefinitionsByPortal(portalId)
                                            .Cast<ProfilePropertyDefinition>()
                                            .Where(definition => definition.DataType == textType.EntryID
                                                    || definition.DataType == regionType.EntryID
                                                    || definition.DataType == countryType.EntryID))
                {
                    AddProperty(results, definition.PropertyName, q);
                }

                AddProperty(results, "Email", q);
                AddProperty(results, "DisplayName", q);
                AddProperty(results, "Username", q);
                AddProperty(results, "Password", q);
                AddProperty(results, "PasswordConfirm", q);
                AddProperty(results, "PasswordQuestion", q);
                AddProperty(results, "PasswordAnswer", q);

                return Json(results.OrderBy(sr => sr.id), JsonRequestBehavior.AllowGet);
            }
            catch (Exception exc)
            {
                DnnLog.Error(exc);
                return Json(null, JsonRequestBehavior.AllowGet);
            }
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// The GetDependency method instantiates (and returns) the relevant Dependency
        /// </summary>
        /// <param name="dependencyNav">The manifest (XPathNavigator) for the dependency</param>
        /// -----------------------------------------------------------------------------
        public static IDependency GetDependency(XPathNavigator dependencyNav)
        {
            IDependency dependency = null;
            string dependencyType = Util.ReadAttribute(dependencyNav, "type");
            switch (dependencyType.ToLowerInvariant())
            {
                case "coreversion":
                    dependency = new CoreVersionDependency();
                    break;
                case "package":
                    dependency = new PackageDependency();
                    break;
                case "managedpackage":
                    dependency = new ManagedPackageDependency();
                    break;
                case "permission":
                    dependency = new PermissionsDependency();
                    break;
                case "type":
                    dependency = new TypeDependency();
                    break;
                default:
                    //Dependency type is defined in the List
                    var listController = new ListController();
                    ListEntryInfo entry = listController.GetListEntryInfo("Dependency", dependencyType);
                    if (entry != null && !string.IsNullOrEmpty(entry.Text))
                    {
                        //The class for the Installer is specified in the Text property
                        dependency = (DependencyBase)Reflection.CreateObject(entry.Text, "Dependency_" + entry.Value);
                    }
                    break;
            }
            if (dependency == null)
            {
                //Could not create dependency, show generic error message
                dependency = new InvalidDependency(Util.INSTALL_Dependencies);
            }
            //Read Manifest
            dependency.ReadManifest(dependencyNav);

            return dependency;
        }
        public string DisplayDataType( ProfilePropertyDefinition definition )
        {
            string retValue = Null.NullString;
            ListController objListController = new ListController();
            ListEntryInfo definitionEntry = objListController.GetListEntryInfo( definition.DataType );

            if( definitionEntry != null )
            {
                retValue = definitionEntry.Value;
            }

            return retValue;
        }
        /// <summary>
        ///     Handles cmdSaveEntry.Click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks>
        ///     Using "CommandName" property of cmdSaveEntry to determine action to take (ListUpdate/AddEntry/AddList)
        /// </remarks>
        protected void OnSaveEntryClick(object sender, EventArgs e)
        {
            String entryValue;
            String entryText;
            if (UserInfo.IsSuperUser)
            {
                entryValue = txtEntryValue.Text;
                entryText = txtEntryText.Text;
            }
            else
            {
                var ps = new PortalSecurity();

                entryValue = ps.InputFilter(txtEntryValue.Text, PortalSecurity.FilterFlag.NoScripting);
                entryText = ps.InputFilter(txtEntryText.Text, PortalSecurity.FilterFlag.NoScripting);
            }
            var listController = new ListController();
            var entry = new ListEntryInfo();
            {
                entry.DefinitionID = Null.NullInteger;
                entry.PortalID = ListPortalID;
                entry.ListName = txtEntryName.Text;
                entry.Value = entryValue;
                entry.Text = entryText;
            }
            if (Page.IsValid)
            {
                Mode = "ListEntries";
                switch (cmdSaveEntry.CommandName.ToLower())
                {
                    case "update":
                        entry.ParentKey = SelectedList.ParentKey;
                        entry.EntryID = Int16.Parse(txtEntryID.Text);
                        bool canUpdate = true;
                        foreach (var curEntry in listController.GetListEntryInfoItems(SelectedList.Name, entry.ParentKey, entry.PortalID))
                        {
                            if (entry.EntryID != curEntry.EntryID) //not the same item we are trying to update
                            {
                                if (entry.Value == curEntry.Value && entry.Text == curEntry.Text)
                                {
                                    UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("ItemAlreadyPresent", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                                    canUpdate = false;
                                    break;
                                }

                            }
                        }

                        if (canUpdate)
                        {
                            listController.UpdateListEntry(entry);
                            DataBind();
                        }
                        break;
                    case "saveentry":
                        if (SelectedList != null)
                        {
                            entry.ParentKey = SelectedList.ParentKey;
                            entry.ParentID = SelectedList.ParentID;
                            entry.Level = SelectedList.Level;
                        }
                        if (chkEnableSortOrder.Checked)
                        {
                            entry.SortOrder = 1;
                        }
                        else
                        {
                            entry.SortOrder = 0;
                        }

                        if (listController.AddListEntry(entry) == Null.NullInteger) //entry already found in database
                        {
                            UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("ItemAlreadyPresent", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                        }

                        DataBind();
                        break;
                    case "savelist":
                        if (ddlSelectParent.SelectedIndex != -1)
                        {
                            int parentID = Int32.Parse(ddlSelectParent.SelectedItem.Value);
                            ListEntryInfo parentEntry = listController.GetListEntryInfo(parentID);
                            entry.ParentID = parentID;
                            entry.DefinitionID = parentEntry.DefinitionID;
                            entry.Level = parentEntry.Level + 1;
                            entry.ParentKey = parentEntry.Key;
                        }
                        if (chkEnableSortOrder.Checked)
                        {
                            entry.SortOrder = 1;
                        }
                        else
                        {
                            entry.SortOrder = 0;
                        }

                        if (listController.AddListEntry(entry) == Null.NullInteger) //entry already found in database
                        {
                            UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("ItemAlreadyPresent", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                        }
                        else
                        {
                            SelectedKey = entry.ParentKey.Replace(":", ".") + ":" + entry.ListName;
                            Response.Redirect(Globals.NavigateURL(TabId, "", "Key=" + SelectedKey));
                        }
                        break;
                }
            }
        }
Example #7
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        ///     Handles cmdSaveEntry.Click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks>
        ///     Using "CommandName" property of cmdSaveEntry to determine action to take (ListUpdate/AddEntry/AddList)
        /// </remarks>
        /// <history>
        ///     [tamttt] 20/10/2004	Created
        ///     [cnurse]  01/30/2007	Extracted to separte user control
        /// </history>
        /// -----------------------------------------------------------------------------
        protected void OnSaveEntryClick(object sender, EventArgs e)
        {
            var ctlLists = new ListController();
            var entry = new ListEntryInfo();
            {
                entry.DefinitionID = Null.NullInteger;
                entry.PortalID = ListPortalID;
                entry.ListName = txtEntryName.Text;
                entry.Value = txtEntryValue.Text;
                entry.Text = txtEntryText.Text;
            }
            if (Page.IsValid)
            {
                Mode = "ListEntries";
                switch (cmdSaveEntry.CommandName.ToLower())
                {
                    case "update":
                        entry.ParentKey = SelectedList.ParentKey;
                        entry.EntryID = Int16.Parse(txtEntryID.Text);

                        ctlLists.UpdateListEntry(entry);

                        DataBind();
                        break;
                    case "saveentry":
                        if (SelectedList != null)
                        {
                            entry.ParentKey = SelectedList.ParentKey;
                            entry.ParentID = SelectedList.ParentID;
                            entry.Level = SelectedList.Level;
                        }
                        if (chkEnableSortOrder.Checked)
                        {
                            entry.SortOrder = 1;
                        }
                        else
                        {
                            entry.SortOrder = 0;
                        }
                        ctlLists.AddListEntry(entry);

                        DataBind();
                        break;
                    case "savelist":
                        if (ddlSelectParent.SelectedIndex != -1)
                        {
                            int parentID = Int32.Parse(ddlSelectParent.SelectedItem.Value);
                            ListEntryInfo parentEntry = ctlLists.GetListEntryInfo(parentID);
                            entry.ParentID = parentID;
                            entry.DefinitionID = parentEntry.DefinitionID;
                            entry.Level = parentEntry.Level + 1;
                            entry.ParentKey = parentEntry.Key;
                        }
                        if (chkEnableSortOrder.Checked)
                        {
                            entry.SortOrder = 1;
                        }
                        else
                        {
                            entry.SortOrder = 0;
                        }
                        ctlLists.AddListEntry(entry);

                        SelectedKey = entry.ParentKey.Replace(":", ".") + ":" + entry.ListName;

                        Response.Redirect(Globals.NavigateURL(TabId, "", "Key=" + SelectedKey));
                        break;
                }
            }
        }
Example #8
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// The GetInstaller method instantiates the relevant Component Installer
        /// </summary>
        /// <param name="installerType">The type of Installer</param>
        /// <history>
        /// 	[cnurse]	07/25/2007  created
        /// </history>
        /// -----------------------------------------------------------------------------
        public static ComponentInstallerBase GetInstaller(string installerType)
        {
            ComponentInstallerBase installer = null;
            switch (installerType)
            {
                case "File":
                    installer = new FileInstaller();
                    break;
                case "Assembly":
                    installer = new AssemblyInstaller();
                    break;
                case "ResourceFile":
                    installer = new ResourceFileInstaller();
                    break;
                case "AuthenticationSystem":
                case "Auth_System":
                    installer = new AuthenticationInstaller();
                    break;
                case "DashboardControl":
                    installer = new DashboardInstaller();
                    break;
                case "Script":
                    installer = new ScriptInstaller();
                    break;
                case "Config":
                    installer = new ConfigInstaller();
                    break;
                case "Cleanup":
                    installer = new CleanupInstaller();
                    break;
                case "Skin":
                    installer = new SkinInstaller();
                    break;
                case "Container":
                    installer = new ContainerInstaller();
                    break;
                case "Module":
                    installer = new ModuleInstaller();
                    break;
                case "CoreLanguage":
                    installer = new LanguageInstaller(LanguagePackType.Core);
                    break;
                case "ExtensionLanguage":
                    installer = new LanguageInstaller(LanguagePackType.Extension);
                    break;
                case "Provider":
                    installer = new ProviderInstaller();
                    break;
                case "SkinObject":
                    installer = new SkinControlInstaller();
                    break;
                case "UrlProvider":
                    installer = new UrlProviderInstaller();
                    break;
                case "Widget":
                    installer = new WidgetInstaller();
                    break;
                default:
                    //Installer type is defined in the List
                    var listController = new ListController();
                    ListEntryInfo entry = listController.GetListEntryInfo("Installer", installerType);

                    if (entry != null && !string.IsNullOrEmpty(entry.Text))
                    {
						//The class for the Installer is specified in the Text property
                        installer = (ComponentInstallerBase) Reflection.CreateObject(entry.Text, "Installer_" + entry.Value);
                    }
                    break;
            }
            return installer;
        }
        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);
            }
        }
Example #10
0
        /// <summary>
        /// InitialiseUser initialises a "new" user
        /// </summary>
        private UserInfo InitialiseUser()
        {
            var newUser = new UserInfo();
            if (IsHostMenu && !IsRegister)
            {
                newUser.IsSuperUser = true;
            }
            else
            {
                newUser.PortalID = PortalId;
            }

            //Initialise the ProfileProperties Collection
            string lc = new Localization().CurrentUICulture;

            newUser.Profile.InitialiseProfile(PortalId);
            newUser.Profile.PreferredTimeZone = PortalSettings.TimeZone;

            newUser.Profile.PreferredLocale = lc;

            //Set default countr
            string country = Null.NullString;
            country = LookupCountry();
            if (!String.IsNullOrEmpty(country))
            {
                ListController listController = new ListController();
                var listitem = listController.GetListEntryInfo("Country", country);
                if (listitem != null)
                {
                    country = listitem.EntryID.ToString();
                }

                newUser.Profile.Country = country;
            }
            //Set AffiliateId
            int AffiliateId = Null.NullInteger;
            if (Request.Cookies["AffiliateId"] != null)
            {
                AffiliateId = int.Parse(Request.Cookies["AffiliateId"].Value);
            }
            newUser.AffiliateID = AffiliateId;
            return newUser;
        }
Example #11
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Returns the collection of SearchDocuments populated with Tab MetaData for the given portal.
        /// </summary>
        /// <param name="portalId"></param>
        /// <param name="startDateLocal"></param>
        /// <returns></returns>
        /// <history>
        ///     [vnguyen]   04/16/2013  created
        /// </history>
        /// -----------------------------------------------------------------------------
        public override IEnumerable<SearchDocument> GetSearchDocuments(int portalId, DateTime startDateLocal)
        {
            var searchDocuments = new Dictionary<string, SearchDocument>();

            var needReindex = PortalController.GetPortalSettingAsBoolean(UserIndexResetFlag, portalId, false);
            if (needReindex)
            {
                startDateLocal = SqlDateTime.MinValue.Value.AddDays(1);
            }

            var controller = new ListController();
            var textDataType = controller.GetListEntryInfo("DataType", "Text");
            var richTextDataType = controller.GetListEntryInfo("DataType", "RichText");

            var profileDefinitions = ProfileController.GetPropertyDefinitionsByPortal(portalId, false, false)
                .Cast<ProfilePropertyDefinition>()
                .Where(d => (textDataType != null && d.DataType == textDataType.EntryID)
                            || (richTextDataType != null && d.DataType == richTextDataType.EntryID)).ToList();

            try
            {
                var startUserId = Null.NullInteger;
                while (true)
                {
                    var reader = DataProvider.Instance()
                        .GetAvailableUsersForIndex(portalId, startDateLocal, startUserId, BatchSize);
                    int rowsAffected = 0;
                    var indexedUsers = new List<int>();

                    while (reader.Read())
                    {
                        var userSearch = GetUserSearch(reader);
                        AddBasicInformation(searchDocuments, indexedUsers, userSearch, portalId);
                        
                        //log the userid so that it can get the correct user collection next time.
                        if (userSearch.UserId > startUserId)
                        {
                            startUserId = userSearch.UserId;
                        }

                        foreach (var definition in profileDefinitions)
                        {
                            var propertyName = definition.PropertyName;

                            if (!ContainsColumn(propertyName, reader))
                            {
                                continue;
                            }

                            var propertyValue = reader[propertyName].ToString();

                            if (string.IsNullOrEmpty(propertyValue) || !propertyValue.Contains(ValueSplitFlag))
                            {
                                continue;
                            }

                            var splitValues = Regex.Split(propertyValue, Regex.Escape(ValueSplitFlag));

                            propertyValue = splitValues[0];
                            var visibilityMode = ((UserVisibilityMode) Convert.ToInt32(splitValues[1]));
                            var extendedVisibility = splitValues[2];
                            var modifiedTime = Convert.ToDateTime(splitValues[3]).ToUniversalTime();

                            if (string.IsNullOrEmpty(propertyValue))
                            {
                                continue;
                            }

                            var uniqueKey = string.Format("{0}_{1}", userSearch.UserId, visibilityMode).ToLowerInvariant();
                            if (visibilityMode == UserVisibilityMode.FriendsAndGroups)
                            {
                                uniqueKey = string.Format("{0}_{1}", uniqueKey, extendedVisibility);
                            }

                            if (searchDocuments.ContainsKey(uniqueKey))
                            {
                                var document = searchDocuments[uniqueKey];
                                document.Keywords.Add(propertyName, propertyValue);

                                if (modifiedTime > document.ModifiedTimeUtc)
                                {
                                    document.ModifiedTimeUtc = modifiedTime;
                                }
                            }
                            else
                            {
                                //Need remove use exists index for all visibilities.
                                if (!indexedUsers.Contains(userSearch.UserId))
                                {
                                    indexedUsers.Add(userSearch.UserId);
                                }

                                if (!string.IsNullOrEmpty(propertyValue))
                                {
                                    var searchDoc = new SearchDocument
                                    {
                                        SearchTypeId = UserSearchTypeId,
                                        UniqueKey = uniqueKey,
                                        PortalId = portalId,
                                        ModifiedTimeUtc = modifiedTime,
                                        Description = userSearch.FirstName,
                                        Title = userSearch.DisplayName
                                    };
                                    searchDoc.Keywords.Add(propertyName, propertyValue);
                                    searchDoc.NumericKeys.Add("superuser", Convert.ToInt32(userSearch.SuperUser));
                                    searchDocuments.Add(uniqueKey, searchDoc);
                                }
                            }
                        }

                        rowsAffected++;
                    }

                    //close the data reader
                    reader.Close();

                    //remov exists indexes
                    DeleteDocuments(portalId, indexedUsers);

                    if (rowsAffected == 0)
                    {
                        break;
                    }
                }

                if (needReindex)
                {
                    PortalController.DeletePortalSetting(portalId, UserIndexResetFlag);
                }
            }
            catch (Exception ex)
            {
                Exceptions.Exceptions.LogException(ex);
            }

            return searchDocuments.Values;
        }
 private void AddProperty(ProfilePropertyDefinition property)
 {
     var controller = new ListController();
     ListEntryInfo imageType = controller.GetListEntryInfo("DataType", "Image");
     if (property.DataType != imageType.EntryID)
     {
         DnnFormEditControlItem formItem = new DnnFormEditControlItem
                                                 {
                                                     ID = property.PropertyName,
                                                     ResourceKey = String.Format("ProfileProperties_{0}", property.PropertyName),
                                                     LocalResourceFile = "~/DesktopModules/Admin/Security/App_LocalResources/Profile.ascx.resx",
                                                     ControlType = EditorInfo.GetEditor(property.DataType),
                                                     DataMember = "Profile",
                                                     DataField = property.PropertyName,
                                                     Visible = property.Visible,
                                                     Required = property.Required
                                                 };
         //To check if the property has a deafult value
         if (!String.IsNullOrEmpty(property.DefaultValue))
         {
             formItem.Value = property.DefaultValue;
         }
         userForm.Items.Add(formItem);
     }
 }
        private bool ValidateProperty(ProfilePropertyDefinition definition)
        {
            bool isValid = true;

            var objListController = new ListController();
            string strDataType = objListController.GetListEntryInfo(definition.DataType).Value;

            switch (strDataType)
            {
                case "Text":
                    if (definition.Required && definition.Length == 0)
                    {
                        _Message = "RequiredTextBox";
                        isValid = Null.NullBoolean;
                    }
                    break;
            }
            return isValid;
        }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            cmdPurchase.Click += cmdPurchase_Click;
            cmdCancel.Click += cmdCancel_Click;

            try
            {
                double dblTotal;
                string strCurrency;

                if ((Request.QueryString["RoleID"] != null))
                {
                    RoleID = Int32.Parse(Request.QueryString["RoleID"]);
                }
                if (Page.IsPostBack == false)
                {
                    if (RoleID != -1)
                    {
                        RoleInfo objRole = TestableRoleController.Instance.GetRole(PortalSettings.PortalId, r => r.RoleID == RoleID);

                        if (objRole.RoleID != -1)
                        {
                            lblServiceName.Text = objRole.RoleName;
                            if (!Null.IsNull(objRole.Description))
                            {
                                lblDescription.Text = objRole.Description;
                            }
                            if (RoleID == PortalSettings.AdministratorRoleId)
                            {
                                if (!Null.IsNull(PortalSettings.HostFee))
                                {
                                    lblFee.Text = PortalSettings.HostFee.ToString("#,##0.00");
                                }
                            }
                            else
                            {
                                if (!Null.IsNull(objRole.ServiceFee))
                                {
                                    lblFee.Text = objRole.ServiceFee.ToString("#,##0.00");
                                }
                            }
                            if (!Null.IsNull(objRole.BillingFrequency))
                            {
                                var ctlEntry = new ListController();
                                ListEntryInfo entry = ctlEntry.GetListEntryInfo("Frequency", objRole.BillingFrequency);
                                lblFrequency.Text = entry.Text;
                            }
                            txtUnits.Text = "1";
                            if (objRole.BillingFrequency == "1") //one-time fee
                            {
                                txtUnits.Enabled = false;
                            }
                        }
                        else //security violation attempt to access item not related to this Module
                        {
                            Response.Redirect(Globals.NavigateURL(), true);
                        }
                    }

                    //Store URL Referrer to return to portal
                    if (Request.UrlReferrer != null)
                    {
                        ViewState["UrlReferrer"] = Convert.ToString(Request.UrlReferrer);
                    }
                    else
                    {
                        ViewState["UrlReferrer"] = "";
                    }
                }
                if (RoleID == PortalSettings.AdministratorRoleId)
                {
                    strCurrency = Host.HostCurrency;
                }
                else
                {
                    strCurrency = PortalSettings.Currency;
                }
                dblTotal = Convert.ToDouble(lblFee.Text)*Convert.ToDouble(txtUnits.Text);
                lblTotal.Text = dblTotal.ToString("#.##");

                lblFeeCurrency.Text = strCurrency;
                lblTotalCurrency.Text = strCurrency;
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Example #15
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        ///     Handles cmdSaveEntry.Click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks>
        ///     Using "CommandName" property of cmdSaveEntry to determine action to take (ListUpdate/AddEntry/AddList)
        /// </remarks>
        /// <history>
        ///     [tamttt] 20/10/2004	Created
        ///     [cnurse]  01/30/2007	Extracted to separte user control
        /// </history>
        /// -----------------------------------------------------------------------------
        protected void OnSaveEntryClick(object sender, EventArgs e)
        {
            var listController = new ListController();
            var entry          = new ListEntryInfo();

            {
                entry.DefinitionID = Null.NullInteger;
                entry.PortalID     = ListPortalID;
                entry.ListName     = txtEntryName.Text;
                entry.Value        = txtEntryValue.Text;
                entry.Text         = txtEntryText.Text;
            }
            if (Page.IsValid)
            {
                Mode = "ListEntries";
                switch (cmdSaveEntry.CommandName.ToLower())
                {
                case "update":
                    entry.ParentKey = SelectedList.ParentKey;
                    entry.EntryID   = Int16.Parse(txtEntryID.Text);
                    bool canUpdate = true;
                    foreach (var curEntry in listController.GetListEntryInfoItems(SelectedList.Name, entry.ParentKey, entry.PortalID))
                    {
                        if (entry.EntryID != curEntry.EntryID)                                 //not the same item we are trying to update
                        {
                            if (entry.Value == curEntry.Value && entry.Text == curEntry.Text)
                            {
                                UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("ItemAlreadyPresent", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                                canUpdate = false;
                                break;
                            }
                        }
                    }

                    if (canUpdate)
                    {
                        listController.UpdateListEntry(entry);
                        DataBind();
                    }
                    break;

                case "saveentry":
                    if (SelectedList != null)
                    {
                        entry.ParentKey = SelectedList.ParentKey;
                        entry.ParentID  = SelectedList.ParentID;
                        entry.Level     = SelectedList.Level;
                    }
                    if (chkEnableSortOrder.Checked)
                    {
                        entry.SortOrder = 1;
                    }
                    else
                    {
                        entry.SortOrder = 0;
                    }

                    if (listController.AddListEntry(entry) == Null.NullInteger)                             //entry already found in database
                    {
                        UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("ItemAlreadyPresent", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                    }


                    DataBind();
                    break;

                case "savelist":
                    if (ddlSelectParent.SelectedIndex != -1)
                    {
                        int           parentID    = Int32.Parse(ddlSelectParent.SelectedItem.Value);
                        ListEntryInfo parentEntry = listController.GetListEntryInfo(parentID);
                        entry.ParentID     = parentID;
                        entry.DefinitionID = parentEntry.DefinitionID;
                        entry.Level        = parentEntry.Level + 1;
                        entry.ParentKey    = parentEntry.Key;
                    }
                    if (chkEnableSortOrder.Checked)
                    {
                        entry.SortOrder = 1;
                    }
                    else
                    {
                        entry.SortOrder = 0;
                    }

                    if (listController.AddListEntry(entry) == Null.NullInteger)                             //entry already found in database
                    {
                        UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("ItemAlreadyPresent", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                    }
                    else
                    {
                        SelectedKey = entry.ParentKey.Replace(":", ".") + ":" + entry.ListName;
                        Response.Redirect(Globals.NavigateURL(TabId, "", "Key=" + SelectedKey));
                    }
                    break;
                }
            }
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// The GetWriter method instantiates the relevant PackageWriter Installer
        /// </summary>
        /// <param name="package">The associated PackageInfo instance</param>
        /// <history>
        /// 	[cnurse]	01/31/2008  created
        /// </history>
        /// -----------------------------------------------------------------------------
        public static PackageWriterBase GetWriter(PackageInfo package)
        {
            PackageWriterBase writer = null;
            switch (package.PackageType)
            {
                case "Auth_System":
                    writer = new AuthenticationPackageWriter(package);
                    break;
                case "Module":
                    writer = new ModulePackageWriter(package);
                    break;
                case "Container":
                    writer = new ContainerPackageWriter(package);
                    break;
                case "Skin":
                    writer = new SkinPackageWriter(package);
                    break;
                case "CoreLanguagePack":
                case "ExtensionLanguagePack":
                    writer = new LanguagePackWriter(package);
                    break;
                case "SkinObject":
                    writer = new SkinControlPackageWriter(package);
                    break;
                case "Provider":
                    writer = new ProviderPackageWriter(package);
                    break;
                case "Library":
                    writer = new LibraryPackageWriter(package);
                    break;
                case "Widget":
                    writer = new WidgetPackageWriter(package);
                    break;
                default:
                    //PackageType is defined in the List
                    var listController = new ListController();
                    ListEntryInfo entry = listController.GetListEntryInfo("PackageWriter", package.PackageType);

                    if (entry != null && !string.IsNullOrEmpty(entry.Text))
                    {
						//The class for the Installer is specified in the Text property
                        writer = (PackageWriterBase) Reflection.CreateObject(entry.Text, "PackageWriter_" + entry.Value);
                    }
                    break;
            }
            return writer;
        }
        /// <summary>Handles the <see cref="GridView.RowCommand"/> event of the <see cref="LeadItemsGridView"/> control.</summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="CommandEventArgs"/> instance containing the event data.</param>
        private void LeadItemsGridView_RowCommand(object sender, CommandEventArgs e)
        {
            if (!this.Page.IsValid || e == null)
            {
                return;
            }

            int rowIndex;
            if (!int.TryParse(e.CommandArgument.ToString(), NumberStyles.Integer, CultureInfo.InvariantCulture, out rowIndex))
            {
                return;
            }

            if (!string.Equals("Save", e.CommandName, StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            var leadId = this.GetLeadItemId(rowIndex);
            if (!leadId.HasValue)
            {
                return;
            }

            var lists = new ListController();
            var leadItem = lists.GetListEntryInfo(leadId.Value);
            var newLeadText = this.GetLeadItemText(rowIndex);
            var oldLeadText = leadItem.Text;

            if (string.Equals(newLeadText, oldLeadText, StringComparison.CurrentCultureIgnoreCase) || lists.GetListEntryInfo(Utility.LeadListName, newLeadText) == null)
            {
                leadItem.Value = newLeadText;
                leadItem.Text = newLeadText;
                lists.UpdateListEntry(leadItem);
                this.LeadItemsGridView.EditIndex = -1;
                this.BindLeadItems();
            }
            else
            {
                this.cvLeadEdit.IsValid = false;
            }
        }
        /// -----------------------------------------------------------------------------
        /// <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);

            cmdSearch.Click += OnSearchClick;
            grdUsers.ItemDataBound += grdUsers_ItemDataBound;
            grdUsers.ItemCommand += grdUsers_ItemCommand;

            try
            {
                //Add an Action Event Handler to the Skin
                AddActionHandler(ModuleAction_Click);

                if (!Page.IsPostBack)
                {
                    ClientAPI.RegisterKeyCapture(txtSearch, cmdSearch, 13);
                    //Load the Search Combo
                    ddlSearchType.Items.Add(AddSearchItem("Username"));
                    ddlSearchType.Items.Add(AddSearchItem("Email"));
                    ProfilePropertyDefinitionCollection profileProperties = ProfileController.GetPropertyDefinitionsByPortal(PortalId, false, false);
                    foreach (ProfilePropertyDefinition definition in profileProperties)
                    {
                        var controller = new ListController();
                        ListEntryInfo imageDataType = controller.GetListEntryInfo("DataType", "Image");
                        if (imageDataType == null || definition.DataType == imageDataType.EntryID)
                        {
                            break;
                        }
                        ddlSearchType.Items.Add(AddSearchItem(definition.PropertyName));
                    }
                    //Localize the Headers
                    Localization.LocalizeDataGrid(ref grdUsers, LocalResourceFile);
                    BindData(Filter, ddlSearchType.SelectedItem.Value);

                    //Sent controls to current Filter
                    if ((!String.IsNullOrEmpty(Filter) && Filter.ToUpper() != "NONE") && !String.IsNullOrEmpty(FilterProperty))
                    {
                        txtSearch.Text = Filter;
                        ddlSearchType.SelectedValue = FilterProperty;
                    }
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Example #19
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Serializes all Profile Definitions
        /// </summary>
        /// <param name="objportal">Portal to serialize</param>
        /// <remarks>
        /// The serialization uses the xml attributes defined in ProfilePropertyDefinition class.
        /// </remarks>
        /// <history>
        /// </history>
        /// -----------------------------------------------------------------------------
        private void SerializeProfileDefinitions(XmlWriter writer, PortalInfo objportal)
        {
            var objListController = new ListController();
            ListEntryInfo objList;

            writer.WriteStartElement("profiledefinitions");
            foreach (ProfilePropertyDefinition objProfileProperty in
                ProfileController.GetPropertyDefinitionsByPortal(objportal.PortalID, false, false))
            {
                writer.WriteStartElement("profiledefinition");

                writer.WriteElementString("propertycategory", objProfileProperty.PropertyCategory);
                writer.WriteElementString("propertyname", objProfileProperty.PropertyName);

                objList = objListController.GetListEntryInfo("DataType", objProfileProperty.DataType);
                if (objList == null)
                {
                    writer.WriteElementString("datatype", "Unknown");
                }
                else
                {
                    writer.WriteElementString("datatype", objList.Value);
                }
                writer.WriteElementString("length", objProfileProperty.Length.ToString());
                writer.WriteElementString("defaultvisibility", Convert.ToInt32(objProfileProperty.DefaultVisibility).ToString());
                writer.WriteEndElement();
            }
            writer.WriteEndElement();
        }
Example #20
0
        /// <Summary>
        /// GetEditor gets the appropriate Editor based on ID properties
        /// </Summary>
        public static string GetEditor( string editorValue )
        {
            string editor = "UseSystemType";

            ListController objListController = new ListController();
            ListEntryInfo definitionEntry = objListController.GetListEntryInfo("DataType", editorValue);

            if (definitionEntry != null)
            {
                editor = definitionEntry.Text;
            }

            return editor;
        }
Example #21
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// RenderViewMode renders the View (readonly) mode of the control
        /// </summary>
        /// <param name="writer">A HtmlTextWriter.</param>
        /// <history>
        ///     [cnurse]	05/04/2006	created
        /// </history>
        /// -----------------------------------------------------------------------------
        protected override void RenderViewMode(HtmlTextWriter writer)
        {
            var objListController = new ListController();
            ListEntryInfo entry = null;
            string entryText = Null.NullString;
            switch (ValueField)
            {
                case ListBoundField.Id:
                    entry = objListController.GetListEntryInfo(Convert.ToInt32(Value));
                    break;
                case ListBoundField.Text:
                    entryText = StringValue;
                    break;
                case ListBoundField.Value:
                    entry = objListController.GetListEntryInfo(ListName, StringValue);
                    break;
            }
            ControlStyle.AddAttributesToRender(writer);
            writer.RenderBeginTag(HtmlTextWriterTag.Span);
            if (entry != null)
            {
                switch (TextField)
                {
                    case ListBoundField.Id:
                        writer.Write(entry.EntryID.ToString());
                        break;
                    case ListBoundField.Text:
                        writer.Write(entry.Text);
                        break;
                    case ListBoundField.Value:
                        writer.Write(entry.Value);
                        break;
                }
            }
            else
            {
                writer.Write(entryText);
            }
			
			//Close Select Tag
            writer.RenderEndTag();
        }
Example #22
0
        /// <Summary>
        /// GetEditor gets the appropriate Editor based on ID properties
        /// </Summary>
        /// <Param name="editorType">The Id of the Editor</Param>
        public static string GetEditor(int editorType)
        {
            string editor = "UseSystemType";

            if (editorType != Null.NullInteger)
            {
                ListController objListController = new ListController();
                ListEntryInfo definitionEntry = objListController.GetListEntryInfo(editorType);

                if ((definitionEntry != null) && (definitionEntry.ListName == "DataType"))
                {
                    editor = definitionEntry.Text;
                }
            }

            return editor;

        }
Example #23
0
        /// <summary>
        /// Serializes all Profile Definitions
        /// </summary>
        /// <param name="xmlTemplate">Reference to XmlDocument context</param>
        /// <param name="nodeProfileDefinitions">Node to add the serialized objects</param>
        /// <param name="objportal">Portal to serialize</param>
        /// <remarks>
        /// The serialization uses the xml attributes defined in ProfilePropertyDefinition class.
        /// </remarks>
        /// <history>
        /// </history>
        public void SerializeProfileDefinitions(XmlDocument xmlTemplate, XmlNode nodeProfileDefinitions, PortalInfo objportal)
        {
            ListController objListController = new ListController();

            XmlSerializer xser = new XmlSerializer(typeof(ProfilePropertyDefinition));
            foreach (ProfilePropertyDefinition objProfileProperty in ProfileController.GetPropertyDefinitionsByPortal(objportal.PortalID))
            {
                StringWriter sw = new StringWriter();
                xser.Serialize(sw, objProfileProperty);

                XmlDocument xmlPropertyDefinition = new XmlDocument();
                xmlPropertyDefinition.LoadXml(sw.GetStringBuilder().ToString());
                XmlNode nodeProfileDefinition = xmlPropertyDefinition.SelectSingleNode("profiledefinition");
                nodeProfileDefinition.Attributes.Remove(nodeProfileDefinition.Attributes["xmlns:xsd"]);
                nodeProfileDefinition.Attributes.Remove(nodeProfileDefinition.Attributes["xmlns:xsi"]);
                ListEntryInfo objList = objListController.GetListEntryInfo(objProfileProperty.DataType);
                XmlNode newnode = xmlPropertyDefinition.CreateElement("datatype");
                if (objList == null)
                {
                    newnode.InnerXml = "Unknown";
                }
                else
                {
                    newnode.InnerXml = objList.Value;
                }
                nodeProfileDefinition.AppendChild(newnode);
                nodeProfileDefinitions.AppendChild(xmlTemplate.ImportNode(nodeProfileDefinition, true));
            }

        }
Example #24
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Gets a Profile Property Value from the Profile
        /// </summary>
        /// <remarks></remarks>
        /// <param name="propName">The name of the propoerty to retrieve.</param>
        /// <history>
        /// 	[cnurse]	02/10/2006	Created
        /// </history>
        /// -----------------------------------------------------------------------------
        public string GetPropertyValue(string propName)
        {
            string propValue = Null.NullString;
            ProfilePropertyDefinition profileProp = GetProperty(propName);
            if (profileProp != null)
            {
                propValue = profileProp.PropertyValue;

                if (profileProp.DataType > -1)
                {
                    var controller = new ListController();
                    var dataType = controller.GetListEntryInfo("DataType", profileProp.DataType);
                    if (dataType.Value == "Country" || dataType.Value == "Region")
                    {
                        propValue = GetListValue(dataType.Value, propValue);
                    }
                }
            }
            return propValue;
        }
Example #25
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            try
            {
                if (!Page.IsPostBack)
                {
					ClientAPI.RegisterKeyCapture(txtSearch, cmdSearch, 13);
					//Load the Search Combo
                    ddlSearchType.Items.Add(AddSearchItem("Username"));
                    ddlSearchType.Items.Add(AddSearchItem("Email"));
					ddlSearchType.Items.Add(AddSearchItem("DisplayName"));
					var controller = new ListController();
					ListEntryInfo imageDataType = controller.GetListEntryInfo("DataType", "Image");
                    ProfilePropertyDefinitionCollection profileProperties = ProfileController.GetPropertyDefinitionsByPortal(PortalId, false, false);
                    foreach (ProfilePropertyDefinition definition in profileProperties)
                    {
                        if (imageDataType != null && definition.DataType != imageDataType.EntryID)
                        {
							ddlSearchType.Items.Add(AddSearchItem(definition.PropertyName));
                        }
                    }
                    
					//Sent controls to current Filter
					if ((!String.IsNullOrEmpty(Filter) && Filter.ToUpper() != "NONE") && !String.IsNullOrEmpty(FilterProperty))
                    {
                        txtSearch.Text = Filter;
                        var findedItem = ddlSearchType.Items.FindItemByValue(FilterProperty, true);
                        if (findedItem != null)
                        {
                            findedItem.Selected = true;
                        }
                    }
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Example #26
0
 private string GetListValue(string listName, string value)
 {
     ListController lc = new ListController();
     int entryId;
     if (int.TryParse(value, out entryId))
     {
         ListEntryInfo item = lc.GetListEntryInfo(listName, entryId);
         if (item != null)
         {
             return item.Text;
         }
     }
     return value;
 }
 private string GetBillingFrequencyCode(string Value)
 {
     var ctlEntry = new ListController();
     ListEntryInfo entry = ctlEntry.GetListEntryInfo("Frequency", Value);
     return entry.Value;
 }
 /// <summary>
 /// This methods return the text description of the Frequency value
 /// </summary>
 /// <param name="value">value of the Frequency</param>
 /// <returns>text of the Frequency</returns>
 private string GetBillingFrequencyText(string value)
 {
     var ctlEntry = new ListController();
     ListEntryInfo entry = ctlEntry.GetListEntryInfo("Frequency", value);
     return entry.Text;
 }
        /// <summary>
        ///     Handles events when clicking image button in the grid (Edit/Up/Down)
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        protected void EntriesGridItemCommand(object source, GridCommandEventArgs e)
        {
            try
            {
                var ctlLists = new ListController();
                int entryID = Convert.ToInt32(((GridDataItem) e.Item).GetDataKeyValue("EntryID"));

                switch (e.CommandName.ToLower())
                {
                    case "delete":
                        Mode = "ListEntries";
                        DeleteItem(entryID);
                        break;
                    case "edit":
                        Mode = "EditEntry";

                        ListEntryInfo entry = ctlLists.GetListEntryInfo(entryID);
                        txtEntryID.Text = entryID.ToString(CultureInfo.InvariantCulture);
                        txtParentKey.Text = entry.ParentKey;
                        txtEntryValue.Text = entry.Value;
                        txtEntryText.Text = entry.Text;
                        rowListName.Visible = false;
                        cmdSaveEntry.CommandName = "Update";

                        if (!SystemList)
                        {
                            cmdDelete.Visible = true;
                            ClientAPI.AddButtonConfirm(cmdDelete, Localization.GetString("DeleteItem"));
                        }
                        else
                        {
                            cmdDelete.Visible = false;
                        }
                        e.Canceled = true;  //stop the grid from providing inline editing
                        DataBind();
                        break;
                    case "up":
                        ctlLists.UpdateListSortOrder(entryID, true);
                        DataBind();
                        break;
                    case "down":
                        ctlLists.UpdateListSortOrder(entryID, false);
                        DataBind();
                        break;
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Example #30
0
        /// <summary>
        /// Get text description of Frequency Value
        /// </summary>
        protected string FormatFrequency(string frequency)
        {
            if (frequency == "N") return string.Empty;

            var ctlEntry = new ListController();
            ListEntryInfo entry = ctlEntry.GetListEntryInfo("Frequency", frequency);
            return entry.Text;
        }
Example #31
0
        private static void UpgradeToVersion550()
        {
            //update languages module
            int moduleDefId = GetModuleDefinition("Languages", "Languages");
            AddModuleControl(moduleDefId, "TranslationStatus", "", "DesktopModules/Admin/Languages/TranslationStatus.ascx", "~/images/icon_language_32px.gif", SecurityAccessLevel.Edit, 0);

            //due to an error in 5.3.0 we need to recheck and readd Application_Start_FirstRequest
            AddEventQueueApplicationStartFirstRequest();

            // check if UserProfile page template exists in Host folder and if not, copy it from Install folder
            string installTemplateFile = string.Format("{0}Templates\\UserProfile.page.template", Globals.InstallMapPath);
            if (File.Exists(installTemplateFile))
            {
                string hostTemplateFile = string.Format("{0}Templates\\UserProfile.page.template", Globals.HostMapPath);
                if (!File.Exists(hostTemplateFile))
                {
                    File.Copy(installTemplateFile, hostTemplateFile);
                }
            }

            //Fix the permission for User Folders
            foreach (PortalInfo portal in PortalController.Instance.GetPortals())
            {
                foreach (FolderInfo folder in FolderManager.Instance.GetFolders(portal.PortalID))
                {
                    if (folder.FolderPath.StartsWith("Users/"))
                    {
                        foreach (PermissionInfo permission in PermissionController.GetPermissionsByFolder())
                        {
                            if (permission.PermissionKey.ToUpper() == "READ")
                            {
                                //Add All Users Read Access to the folder
                                int roleId = Int32.Parse(Globals.glbRoleAllUsers);
                                if (!folder.FolderPermissions.Contains(permission.PermissionKey, folder.FolderID, roleId, Null.NullInteger))
                                {
                                    var folderPermission = new FolderPermissionInfo(permission) { FolderID = folder.FolderID, UserID = Null.NullInteger, RoleID = roleId, AllowAccess = true };

                                    folder.FolderPermissions.Add(folderPermission);
                                }
                            }
                        }

                        FolderPermissionController.SaveFolderPermissions(folder);
                    }
                }
                //Remove user page template from portal if it exists (from 5.3)
                if (File.Exists(string.Format("{0}Templates\\UserProfile.page.template", portal.HomeDirectoryMapPath)))
                {
                    File.Delete(string.Format("{0}Templates\\UserProfile.page.template", portal.HomeDirectoryMapPath));
                }
            }

            //DNN-12894 -   Country Code for "United Kingdom" is incorrect
            var listController = new ListController();
            var listItem = listController.GetListEntryInfo("Country", "UK");
            if (listItem != null)
            {
                listItem.Value = "GB";
                listController.UpdateListEntry(listItem);
            }


            foreach (PortalInfo portal in PortalController.Instance.GetPortals())
            {
                //fix issue where portal default language may be disabled
                string defaultLanguage = portal.DefaultLanguage;
                if (!IsLanguageEnabled(portal.PortalID, defaultLanguage))
                {
                    Locale language = LocaleController.Instance.GetLocale(defaultLanguage);
                    Localization.Localization.AddLanguageToPortal(portal.PortalID, language.LanguageId, true);
                }
                //preemptively create any missing localization records rather than relying on dynamic creation
                foreach (Locale locale in LocaleController.Instance.GetLocales(portal.PortalID).Values)
                {
                    DataProvider.Instance().EnsureLocalizationExists(portal.PortalID, locale.Code);
                }
            }
        }
Example #32
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        ///     Handles cmdSaveEntry.Click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks>
        ///     Using "CommandName" property of cmdSaveEntry to determine action to take (ListUpdate/AddEntry/AddList)
        /// </remarks>
        /// <history>
        ///     [tamttt] 20/10/2004	Created
        ///     [cnurse]  01/30/2007	Extracted to separte user control
        /// </history>
        /// -----------------------------------------------------------------------------
        protected void OnSaveEntryClick(object sender, EventArgs e)
        {
            var ctlLists = new ListController();
            var entry    = new ListEntryInfo();

            {
                entry.DefinitionID = Null.NullInteger;
                entry.PortalID     = ListPortalID;
                entry.ListName     = txtEntryName.Text;
                entry.Value        = txtEntryValue.Text;
                entry.Text         = txtEntryText.Text;
            }
            if (Page.IsValid)
            {
                Mode = "ListEntries";
                switch (cmdSaveEntry.CommandName.ToLower())
                {
                case "update":
                    entry.ParentKey = SelectedList.ParentKey;
                    entry.EntryID   = Int16.Parse(txtEntryID.Text);

                    ctlLists.UpdateListEntry(entry);

                    DataBind();
                    break;

                case "saveentry":
                    if (SelectedList != null)
                    {
                        entry.ParentKey = SelectedList.ParentKey;
                        entry.ParentID  = SelectedList.ParentID;
                        entry.Level     = SelectedList.Level;
                    }
                    if (chkEnableSortOrder.Checked)
                    {
                        entry.SortOrder = 1;
                    }
                    else
                    {
                        entry.SortOrder = 0;
                    }
                    //save the list as system list when its edit by host user.
                    entry.SystemList = ListPortalID == Null.NullInteger;

                    ctlLists.AddListEntry(entry);

                    DataBind();
                    break;

                case "savelist":
                    if (ddlSelectParent.SelectedIndex != -1)
                    {
                        int           parentID    = Int32.Parse(ddlSelectParent.SelectedItem.Value);
                        ListEntryInfo parentEntry = ctlLists.GetListEntryInfo(parentID);
                        entry.ParentID     = parentID;
                        entry.DefinitionID = parentEntry.DefinitionID;
                        entry.Level        = parentEntry.Level + 1;
                        entry.ParentKey    = parentEntry.Key;
                    }
                    if (chkEnableSortOrder.Checked)
                    {
                        entry.SortOrder = 1;
                    }
                    else
                    {
                        entry.SortOrder = 0;
                    }
                    //save the list as system list when its edit by host user.
                    entry.SystemList = ListPortalID == Null.NullInteger;
                    ctlLists.AddListEntry(entry);

                    SelectedKey = entry.ParentKey.Replace(":", ".") + ":" + entry.ListName;

                    Response.Redirect(Globals.NavigateURL(TabId, "", "Key=" + SelectedKey));
                    break;
                }
            }
        }