public dynamic MoveFiles(string fileids, int destinationFolderID, bool overWrite)
 {
     try
     {
         List <int> ExistingIds = new List <int>();
         foreach (int fileID in fileids.Split(',').Select(s => int.Parse(s)).Distinct().ToList())
         {
             string result = BrowseUploadFactory.MoveFile(fileID, destinationFolderID, overWrite);
             if (!string.IsNullOrEmpty(result) && result.ToLower() == "exist")
             {
                 ExistingIds.Add(fileID);
             }
         }
         if (ExistingIds.Count > 0)
         {
             dynamic result = new ExpandoObject();
             result.Error         = "Exist";
             result.ExistingFiles = new List <object>();
             foreach (int id in ExistingIds)
             {
                 result.ExistingFiles.Add(BrowseUploadFactory.GetFile(PortalSettings, id));
             }
             return(result);
         }
         else
         {
             return("Success");
         }
     }
     catch (Exception ex)
     {
         DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
         return(ex.Message.ToString());
     }
 }
        public ActionResult UpdatePortalSettings(string FileId, string HomeIcon, UpdateSiteSettingsRequest request)
        {
            ActionResult actionResult = new ActionResult();

            try
            {
                int      pid      = request.PortalId ?? (PortalController.Instance.GetCurrentSettings() as PortalSettings).PortalId;
                UserInfo userInfo = UserController.Instance.GetCurrentUserInfo();
                if (!userInfo.IsSuperUser && pid != (PortalController.Instance.GetCurrentSettings() as PortalSettings).PortalId)
                {
                    actionResult.AddError("InvalidUser.Error", DotNetNuke.Services.Localization.Localization.GetString("InvalidUser.Error", Components.Constants.LocalResourcesFile));
                }

                string cultureCode = string.IsNullOrEmpty(request.CultureCode) ? LocaleController.Instance.GetCurrentLocale(pid).Code : request.CultureCode;

                Locale language = LocaleController.Instance.GetLocale(pid, cultureCode);
                if (language == null)
                {
                    actionResult.AddError("HttpStatusCode.BadRequest" + HttpStatusCode.BadRequest, Localization.GetString("InvalidLocale.ErrorMessage", Components.Constants.LocalResourcesFile));
                }

                PortalInfo portalInfo = PortalController.Instance.GetPortal(pid, cultureCode);
                //portalInfo.PortalName = request.PortalName;

                if (request.LogoFile != null && request.LogoFile.fileId > 0)
                {
                    portalInfo.LogoFile = FileManager.Instance.GetFile(request.LogoFile.fileId).RelativePath;
                }

                //portalInfo.FooterText = request.FooterText;

                PortalController.Instance.UpdatePortalInfo(portalInfo);
                PortalController.UpdatePortalSetting(pid, "TimeZone", request.TimeZone, false);

                if (request.FavIcon != null && request.FavIcon.fileId > 0)
                {
                    new FavIcon(pid).Update(request.FavIcon.fileId);
                }

                PortalController.UpdatePortalSetting(pid, "DefaultIconLocation", "icons/" + request.IconSet, false, cultureCode);

                //update social sharing logo
                if (!string.IsNullOrEmpty(FileId) && Convert.ToInt32(FileId) > 0)
                {
                    PortalController.UpdatePortalSetting(pid, "SocialSharingLogo", "FileID=" + FileId, true, cultureCode);
                }

                if (!string.IsNullOrEmpty(HomeIcon) && Convert.ToInt32(HomeIcon) > 0)
                {
                    PortalController.UpdatePortalSetting(pid, "HomeScreenIcon", "Fileid=" + HomeIcon, true, cultureCode);
                }

                actionResult.Data = BrowseUploadFactory.GetFile(PortalSettings, request.LogoFile.fileId);
            }
            catch (Exception ex)
            {
                actionResult.AddError("HttpStatusCode.InternalServerError" + HttpStatusCode.InternalServerError, ex.Message);
            }
            return(actionResult);
        }
        public dynamic GetMultipleFileDetails(string fileids)
        {
            List <dynamic> fileDetails = new List <dynamic>();

            foreach (string fileid in fileids.Split(','))
            {
                dynamic file = BrowseUploadFactory.GetFile(PortalSettings, int.Parse(fileid));
                if (file != null)
                {
                    fileDetails.Add(file);
                }
            }
            return(fileDetails);
        }
 public dynamic GetFile(int fileid)
 {
     return(BrowseUploadFactory.GetFile(PortalSettings, fileid));
 }
Exemplo n.º 5
0
        public static List <IUIData> GetData(string Identifier, Dictionary <string, string> UIEngineInfo, UserInfo userInfo, Dictionary <string, string> parameters)
        {
            int uid = 0;

            if (parameters.Count > 0)
            {
                int.TryParse(parameters["uid"], out uid);
            }

            PortalSettings ps = PortalController.Instance.GetCurrentSettings() as PortalSettings;
            Dictionary <string, IUIData> Settings = new Dictionary <string, IUIData>();

            switch (Identifier)
            {
            case "setting_updateprofile":
            {
                if (uid > 0)
                {
                    Settings.Add("BrowseUrl", new UIData {
                            Name = "BrowseUrl", Value = Common.Utilities.Utils.BrowseUrl(-1, "Manage")
                        });
                    Settings.Add("AllowedAttachmentFileExtensions", new UIData {
                            Name = "AllowedAttachmentFileExtensions", Value = FileSetting.FileType
                        });
                    Settings.Add("MaxFileSize", new UIData {
                            Name = "MaxFileSize", Value = FileSetting.FileSize.ToString()
                        });

                    if (!(parameters.ContainsKey("username") && parameters.ContainsKey("password")))
                    {
                        return(Settings.Values.ToList());
                    }

                    int    UserID  = uid;
                    string keyword = string.Empty;

                    UserInfo     user        = DotNetNuke.Entities.Users.UserController.GetUserById(ps.PortalId, UserID);
                    UserBasicDto userDetails = UsersController.Instance.GetUserDetail(ps.PortalId, UserID);
                    ProfileController.GetUserProfile(ref user);
                    Settings.Add("UserDetails", new UIData {
                            Name = "UserDetails", Options = UserManager.MapUserBasicDto(user, userDetails)
                        });
                    Settings.Add("UserRoles", new UIData {
                            Name = "UserRoles", Options = UsersController.Instance.GetUserRoles(user, keyword, out int totalRoles).Select(r => UserRoleDto.FromRoleInfo(ps, r))
                        });
                    Settings.Add("IsAdmin", new UIData {
                            Name = "IsAdmin", Value = userInfo.IsInRole("Administrators").ToString()
                        });
                    Settings.Add("ProfilePropertiesByCategories", new UIData {
                            Name = "ProfilePropertiesByCategories", Options = Managers.UserManager.GetLocalizedCategories(user.Profile.ProfileProperties, user, true).Select(x => new { x.Key, x.Value })
                        });

                    if (string.IsNullOrEmpty(user.Profile.PreferredLocale))
                    {
                        if (string.IsNullOrEmpty(DotNetNuke.Entities.Users.UserController.GetUserById(ps.PortalId, ps.AdministratorId).Profile.PreferredLocale))
                        {
                            user.Profile.SetProfileProperty("PreferredLocale", !string.IsNullOrEmpty(ps.DefaultLanguage) ? ps.DefaultLanguage : Thread.CurrentThread.CurrentCulture.Name);
                        }
                        else
                        {
                            user.Profile.SetProfileProperty("PreferredLocale", DotNetNuke.Entities.Users.UserController.GetUserById(ps.PortalId, ps.AdministratorId).Profile.PreferredLocale);
                        }
                    }

                    List <Entities.ProfileProperties> profileProperties = new List <Entities.ProfileProperties>();
                    ListController listController = new ListController();
                    foreach (ProfilePropertyDefinition d in user.Profile.ProfileProperties)
                    {
                        string ControlType = UserManager.GetControlType(d.DataType);
                        if (ControlType == "Country" || ControlType == "Region" || ControlType == "List")
                        {
                            d.PropertyValue = string.IsNullOrEmpty(d.PropertyValue) ? "-1" : d.PropertyValue;
                        }
                        List <ListEntryInfo> data = listController.GetListEntryInfoItems(d.PropertyName, "", PortalSettings.Current.PortalId).ToList();
                        data.Insert(0, new ListEntryInfo {
                                Text = Localization.GetString("NotSpecified", Components.Constants.LocalResourcesFile), Value = d.PropertyValue
                            });
                        profileProperties.Add(new Entities.ProfileProperties {
                                ProfilePropertyDefinition = d, ListEntries = data
                            });
                    }
                    Settings.Add("ProfileProperties", new UIData {
                            Name = "ProfileProperties", Options = profileProperties
                        });

                    //Profile URL
                    dynamic Profile = null;
                    if (!string.IsNullOrEmpty(user.Profile.Photo))
                    {
                        Profile = BrowseUploadFactory.GetFile(ps, Convert.ToInt32(user.Profile.Photo));
                    }

                    Settings.Add("PhotoURL", new UIData {
                            Name = "PhotoURL", Options = Profile ?? user.Profile, Value = Vanjaro.Common.Utilities.UserUtils.GetProfileImage(PortalSettings.Current.PortalId, user.UserID, user.Email)
                        });
                    var countries = GetCountryList(Thread.CurrentThread.CurrentCulture.Name).Values.OrderBy(x => x.NormalizedFullName).Select(x => new
                        {
                            Id = x.Id.ToString(),
                            x.FullName,
                            x.Name
                        }).ToList();
                    countries.Insert(0, new { Id = "-1", FullName = Localization.GetString("NotSpecified", Components.Constants.LocalResourcesFile), Name = Localization.GetString("NotSpecified", Components.Constants.LocalResourcesFile) });
                    Settings.Add("Countries", new UIData {
                            Name = "Countries", OptionsText = "Key", OptionsValue = "Value", Options = countries
                        });
                    ReadOnlyCollection <TimeZoneInfo> timeZones = TimeZoneInfo.GetSystemTimeZones();
                    var Timezones = timeZones.Cast <TimeZoneInfo>().Select(x => new
                        {
                            Id = x.Id.ToString(),
                            x.DisplayName
                        });

                    Settings.Add("Time_Zones", new UIData {
                            Name = "Time_Zones", OptionsText = "Key", OptionsValue = "Value", Options = Timezones
                        });
                    Dictionary <string, Locale> ActiveLocales = new LocaleController().GetLocales(ps.PortalId);
                    var activeLocales = ActiveLocales.Values.Cast <Locale>().Select(x => new
                        {
                            x.Code,
                            x.Culture,
                            x.EnglishName,
                            x.NativeName,
                            KeyID = x.KeyID.ToString(),
                            x.Text
                        }).ToList();
                    Settings.Add("Active_Locales", new UIData {
                            Name = "Active_Locales", OptionsText = "Key", OptionsValue = "Value", Options = activeLocales
                        });
                }