コード例 #1
0
        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);
        }
コード例 #2
0
 public dynamic GetFiles(int folderid, string uid, int skip, int pagesize, string keyword)
 {
     return(BrowseUploadFactory.GetPagedFiles(0, new TreeView()
     {
         Value = folderid
     }, null, Host.AllowedExtensionWhitelist.ToStorageString(), skip, pagesize, keyword));
 }
コード例 #3
0
        internal static List <IUIData> GetData(int PortalID, Dictionary <string, string> Parameters, string Identifier)
        {
            Dictionary <string, IUIData> Settings = new Dictionary <string, IUIData>();

            if (Identifier == "settings_image")
            {
                List <Common.Components.TreeView> folders = BrowseUploadFactory.GetFoldersTree(PortalID, "image");
                Settings.Add("AllowedAttachmentFileExtensions", new UIData {
                    Name = "AllowedAttachmentFileExtensions", Value = FileSetting.FileType
                });
                Settings.Add("MaxFileSize", new UIData {
                    Name = "MaxFileSize", Value = FileSetting.FileSize.ToString()
                });
                Settings.Add("Files", new UIData {
                    Name = "Files", Options = null
                });
                Settings.Add("Folders", new UIData {
                    Name = "Folders", Options = folders, Value = folders.Count > 0 ? folders.FirstOrDefault().Value.ToString() : "0",
                });
            }
            List <ImageEntity> ImageProviders = ImageManager.GetImageProviders();

            Settings.Add("ImageProviders", new UIData {
                Name = "ImageProviders", Options = ImageProviders, OptionsText = "Text", OptionsValue = "Value", Value = ImageProviders.Count > 0 ? ImageProviders.FirstOrDefault().Value : ""
            });
            return(Settings.Values.ToList());
        }
コード例 #4
0
 public dynamic GetFiles(int folderid, string uid, int skip, int pagesize, string keyword)
 {
     return(BrowseUploadFactory.GetPagedFiles(0, new TreeView()
     {
         Value = folderid
     }, null, FileSetting.FileType, skip, pagesize, keyword));
 }
コード例 #5
0
 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());
     }
 }
コード例 #6
0
        public string Files(string Identifier, string uid)
        {
            string result      = string.Empty;
            string ControlName = string.Empty;

            if (!string.IsNullOrEmpty(Identifier) && PortalSettings != null && UserInfo != null)
            {
                List <IUIData> settings = new List <IUIData>
                {
                    new UIData {
                        Name = "AllowedAttachmentFileExtensions", Value = Entities.FileSetting.FileType
                    },
                    new UIData {
                        Name = "MaxFileSize", Value = Entities.FileSetting.FileSize.ToString()
                    }
                };

                if (HttpContext.Current.Request.Form.AllKeys.Contains("logotype"))
                {
                    ControlName = HttpContext.Current.Request.Form.Get("logotype");
                }

                if (ControlName == "FavIcon")
                {
                    result = BrowseUploadFactory.UploadFile(Identifier, HttpContext.Current, PortalSettings, new ModuleInfo(), UserInfo, isUploadAllowed(ActiveModule, UserInfo), "ico", 100, AppFactory.GetAppInformation().Name, uid);
                }

                else
                {
                    result = BrowseUploadFactory.UploadFile(Identifier, HttpContext.Current, PortalSettings, new ModuleInfo(), UserInfo, isUploadAllowed(ActiveModule, UserInfo), getFileTypes(settings), getMaxSize(Identifier, settings), AppFactory.GetAppInformation().Name, uid);
                }
            }
            return(result);
        }
コード例 #7
0
 public void ExtractFiles(string fileids)
 {
     if (!string.IsNullOrEmpty(fileids))
     {
         foreach (string fileid in fileids.Split(','))
         {
             BrowseUploadFactory.ExtractFiles(int.Parse(fileid));
         }
     }
 }
コード例 #8
0
 public dynamic GetFolderAndFiles(bool IsGlobal)
 {
     if (IsGlobal)
     {
         return(BrowseUploadFactory.GetFoldersTree(-1));
     }
     else
     {
         return(BrowseUploadFactory.GetFoldersTree(PortalSettings.ActiveTab.PortalID));
     }
 }
コード例 #9
0
 public string MoveFolder(int folderId, int destinationFolderId)
 {
     try
     {
         return(BrowseUploadFactory.MoveFolder(folderId, destinationFolderId));
     }
     catch (Exception ex)
     {
         DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
         return(ex.Message.ToString());
     }
 }
コード例 #10
0
        public dynamic GetFiles(int folderid, string uid, int skip, int pagesize, string keyword)
        {
            if (!string.IsNullOrEmpty(uid) && uid == "null")
            {
                uid = null;
            }

            return(BrowseUploadFactory.GetPagedFiles(0, new TreeView()
            {
                Value = folderid
            }, uid, null, skip, pagesize, keyword));
        }
コード例 #11
0
 public dynamic DeleteFile(int fileID)
 {
     try
     {
         return(BrowseUploadFactory.DeleteFile(fileID));
     }
     catch (Exception ex)
     {
         DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
         return(ex.Message.ToString());
     }
 }
コード例 #12
0
 public string MoveFile(int fileID, int destinationFolderID, bool overWrite)
 {
     try
     {
         return(BrowseUploadFactory.MoveFile(fileID, destinationFolderID, overWrite));
     }
     catch (Exception ex)
     {
         DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
         return(ex.Message.ToString());
     }
 }
コード例 #13
0
 public string RenameFile(int fileID, string newFileName)
 {
     try
     {
         return(BrowseUploadFactory.RenameFile(fileID, newFileName));
     }
     catch (Exception ex)
     {
         DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
         return(ex.Message.ToString());
     }
 }
コード例 #14
0
 public dynamic RenameFolder(int folderID, string newFolderName)
 {
     try
     {
         return(BrowseUploadFactory.RenameFolder(folderID, newFolderName));
     }
     catch (Exception ex)
     {
         DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
         return(ex.Message.ToString());
     }
 }
コード例 #15
0
        internal static List <IUIData> GetData(int PortalID, UserInfo UserInfo)
        {
            Dictionary <string, IUIData> Settings = new Dictionary <string, IUIData>
            {
                { "AllowedAttachmentFileExtensions", new UIData {
                      Name = "AllowedAttachmentFileExtensions", Value = Host.AllowedExtensionWhitelist.ToStorageString()
                  } },
                { "MaxFileSize", new UIData {
                      Name = "MaxFileSize", Value = Config.GetMaxUploadSize().ToString()
                  } },
                { "Files", new UIData {
                      Name = "Files", Options = null
                  } }
            };

            List <TreeView> folders = BrowseUploadFactory.GetFoldersTree(PortalID);

            Settings.Add("Folders", new UIData {
                Name = "Folders", Options = folders, Value = folders.Count > 0 ? folders.FirstOrDefault().Value.ToString() : "0",
            });
            Settings.Add("AssetType", new UIData {
                Name = "AssetType", Value = "true"
            });
            List <StringText> FolderType = new List <StringText>();

            foreach (FolderMappingInfo item in FolderMappingController.Instance.GetFolderMappings(PortalID))
            {
                FolderType.Add(new StringText()
                {
                    Text = item.MappingName, Value = item.FolderMappingID.ToString(), PortalID = item.PortalID
                });
            }

            foreach (FolderMappingInfo item in FolderMappingController.Instance.GetFolderMappings(-1))
            {
                FolderType.Add(new StringText()
                {
                    Text = item.MappingName, Value = item.FolderMappingID.ToString(), PortalID = item.PortalID
                });
            }

            Settings.Add("FolderType", new UIData {
                Name = "FolderType", Options = FolderType, OptionsText = "Text", OptionsValue = "Value"
            });
            Settings.Add("IsFileManager", new UIData {
                Name = "IsFileManager", Value = "true"
            });
            Settings.Add("IsList", new UIData {
                Name = "IsList", Value = "true"
            });
            return(Settings.Values.ToList());
        }
コード例 #16
0
 public string CreateNewFolder(int folderparentID, string folderName, int FolderType)
 {
     try
     {
         IFolderInfo folderinfo = null;
         return(BrowseUploadFactory.CreateNewFolder(folderparentID, folderName, FolderType, ref folderinfo));
     }
     catch (Exception ex)
     {
         DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
         return(ex.Message.ToString());
     }
 }
コード例 #17
0
        public HttpResponseMessage Download(int fileID, bool forceDownload)
        {
            HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);

            System.IO.Stream streamContent = BrowseUploadFactory.GetFileContent(fileID, out string fileName, out string contentType);
            result.Content = new StreamContent(streamContent);
            result.Content.Headers.Add("x-filename", fileName);
            result.Content.Headers.ContentType        = new MediaTypeHeaderValue(contentType);
            result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue(forceDownload ? "attachment" : "inline")
            {
                FileName = fileName
            };
            return(result);
        }
コード例 #18
0
        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);
        }
コード例 #19
0
        public dynamic DeleteFiles(string fileIDs)
        {
            try
            {
                foreach (int fileID in fileIDs.Split(',').Select(s => int.Parse(s)).Distinct().ToList())
                {
                    BrowseUploadFactory.DeleteFile(fileID);
                }

                return("Success");
            }
            catch (Exception ex)
            {
                DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
                return(ex.Message.ToString());
            }
        }
コード例 #20
0
 public dynamic GetFiles(int folderid, string uid, int skip, int pagesize, string keyword)
 {
     if (!string.IsNullOrEmpty(uid) && uid == "FavIcon")
     {
         return(BrowseUploadFactory.GetPagedFiles(0, new TreeView()
         {
             Value = folderid
         }, uid, "ico", skip, pagesize, keyword));
     }
     else
     {
         return(BrowseUploadFactory.GetPagedFiles(0, new TreeView()
         {
             Value = folderid
         }, uid, Entities.FileSetting.FileType, skip, pagesize, keyword));
     }
 }
コード例 #21
0
        public string Files(string Identifier, string uid)
        {
            string result      = string.Empty;
            string ControlName = string.Empty;

            if (!string.IsNullOrEmpty(Identifier) && PortalSettings != null && UserInfo != null)
            {
                if (HttpContext.Current.Request.Form.AllKeys.Contains("ControlName"))
                {
                    ControlName = HttpContext.Current.Request.Form.Get("ControlName");
                }

                int FolderID = BrowseUploadFactory.GetRootFolder(PortalSettings.Current.PortalId).FolderID;
                if (string.IsNullOrEmpty(uid))
                {
                    result = BrowseUploadFactory.UploadFile(Identifier, HttpContext.Current, PortalSettings, new ModuleInfo(), UserInfo, isUploadAllowed(ActiveModule, UserInfo, ControlName), "jpg,jpeg,png,gif,pdf,zip,rar,xls,xlsx,css,xml,doc,docx,webp", 100, AppFactory.GetAppInformation().Name, uid, FolderID);
                }
            }
            return(result);
        }
コード例 #22
0
 public string DeleteItems(int folderID)
 {
     try
     {
         int count = BrowseUploadFactory.DeleteFolders(folderID);
         if (count == 0)
         {
             return("Success");
         }
         else
         {
             return(Localization.Get("DeleteFolderFailed", "Text", Constants.LocalResourcesFile, Library.Extension.ShowMissingKeysStatic, Localization.SharedMissingPrefix));
         }
     }
     catch (Exception ex)
     {
         DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
         return(ex.Message.ToString());
     }
 }
コード例 #23
0
        public virtual List <IUIData> GetData(string Identifier, Dictionary <string, string> parameters)
        {
            if (!string.IsNullOrEmpty(Identifier))
            {
                switch (Identifier)
                {
                case "common_controls_editorconfig":
                    return(EditorConfigFactory.GetData(PortalSettings, ActiveModule, parameters));

                case "common_controls_url":
                    return(BrowseUploadFactory.GetData(PortalSettings, ActiveModule, parameters));

                default:
                    return(new List <IUIData>());
                }
            }
            else
            {
                return(new List <IUIData>());
            }
        }
コード例 #24
0
        public string Files(string Identifier, string uid)
        {
            string result = string.Empty;

            if (!string.IsNullOrEmpty(Identifier) && PortalSettings != null && UserInfo != null)
            {
                List <IUIData> settings = new List <IUIData>
                {
                    new UIData {
                        Name = "AllowedAttachmentFileExtensions", Value = FileSetting.FileType
                    },
                    new UIData {
                        Name = "MaxFileSize", Value = FileSetting.FileSize.ToString()
                    }
                };
                if (settings != null && settings.Count > 0)
                {
                    result = BrowseUploadFactory.UploadFile(Identifier, HttpContext.Current, PortalSettings, new ModuleInfo(), UserInfo, isUploadAllowed(UserInfo), getFileTypes(settings), getMaxSize(Identifier, settings), AppFactory.GetAppInformation().Name, null);
                }
            }
            return(result);
        }
コード例 #25
0
        public string Files(string Identifier, string uid)
        {
            string result      = string.Empty;
            string ControlName = string.Empty;
            int?   UserID      = null;

            if (!string.IsNullOrEmpty(Identifier) && PortalSettings != null && UserInfo != null)
            {
                List <IUIData> settings = new List <IUIData>
                {
                    new UIData {
                        Name = "AllowedAttachmentFileExtensions", Value = FileSetting.FileType
                    },
                    new UIData {
                        Name = "MaxFileSize", Value = FileSetting.FileSize.ToString()
                    }
                };

                if (HttpContext.Current.Request.Form.AllKeys.Contains("ControlName"))
                {
                    ControlName = HttpContext.Current.Request.Form.Get("ControlName");
                }

                if (HttpContext.Current.Request.Form.AllKeys.Contains("UserID"))
                {
                    UserID = Convert.ToInt32(HttpContext.Current.Request.Form.Get("UserID"));
                    if (UserID.HasValue)
                    {
                        UserInfo User     = DotNetNuke.Entities.Users.UserController.Instance.GetUser(PortalSettings.Current.PortalId, UserID.Value);
                        int      folderid = FolderManager.Instance.GetUserFolder(User).FolderID;
                        if (string.IsNullOrEmpty(uid))
                        {
                            result = BrowseUploadFactory.UploadFile(Identifier, HttpContext.Current, PortalSettings, new ModuleInfo(), UserInfo, isUploadAllowed(ActiveModule, UserInfo, ControlName), getFileTypes(settings), getMaxSize(Identifier, settings), AppFactory.GetAppInformation().Name, uid, folderid);
                        }
                    }
                }
            }
            return(result);
        }
コード例 #26
0
            public static List <PageItem> GetPages(int PortalId)
            {
                List <PageItem> result = new List <PageItem>
                {
                    new PageItem()
                    {
                        Text = "Select Page", Value = 0
                    }
                };

                foreach (TreeView page in BrowseUploadFactory.GetDnnPages(PortalId))
                {
                    result.Add(new PageItem()
                    {
                        Text = page.Text, Value = page.Value
                    });
                    if (page.children != null && page.children.Count > 0)
                    {
                        BindChildPages(result, page.children, "-");
                    }
                }
                return(result);
            }
コード例 #27
0
 public dynamic GetFile(int fileid)
 {
     return(BrowseUploadFactory.GetFile(PortalSettings, fileid));
 }
コード例 #28
0
 public List <TreeView> GetSubFolders(int folderid)
 {
     return(BrowseUploadFactory.GetFoldersChildrensTree(PortalSettings.PortalId, folderid, UserInfo, "image"));
 }
コード例 #29
0
 public string GetLink(string fileurl, int urltype)
 {
     return(BrowseUploadFactory.GetLink(PortalSettings, ActiveModule, fileurl, urltype));
 }
コード例 #30
0
 public dynamic GetUrl(int fileid)
 {
     return(BrowseUploadFactory.GetUrl(fileid));
 }