Esempio n. 1
0
        protected bool HasPermission(IFolderInfo folder, string permissionKey)
        {
            var hasPermision = PortalSettings.Current.UserInfo.IsSuperUser;

            if (!hasPermision && folder != null)
            {
                hasPermision = FolderPermissionController.HasFolderPermission(folder.FolderPermissions, permissionKey);
            }

            return(hasPermision);
        }
Esempio n. 2
0
        /// <summary>
        /// Checks if user has write access to the folder.
        /// </summary>
        /// <param name="folderId">The folder id.</param>
        /// <param name="portalSettings">The portal settings.</param>
        /// <returns>
        /// Returns if the user has write access to the folder.
        /// </returns>
        public static bool CheckIfUserHasFolderWriteAccess(int folderId, PortalSettings portalSettings)
        {
            try
            {
                var checkFolder = folderId.Equals(-1)
                                      ? ConvertFilePathToFolderInfo(portalSettings.HomeDirectoryMapPath, portalSettings)
                                      : FolderManager.Instance.GetFolder(folderId);

                return(FolderPermissionController.HasFolderPermission(checkFolder.FolderPermissions, "WRITE"));
            }
            catch (Exception)
            {
                return(false);
            }
        }
Esempio n. 3
0
        protected override void OnInit(EventArgs e)
        {
            try
            {
                base.OnInit(e);

                JavaScript.RequestRegistration(CommonJs.DnnPlugins);

                var folderId = Convert.ToInt32(this.Request.Params["FolderId"]);
                this.Folder         = FolderManager.Instance.GetFolder(folderId);
                this.HasFullControl = this.UserInfo.IsSuperUser || FolderPermissionController.HasFolderPermission(this.Folder.FolderPermissions, "FULLCONTROL");

                FolderViewModel rootFolder;
                switch (SettingsRepository.GetMode(this.ModuleId))
                {
                case DigitalAssestsMode.Group:
                    var groupId = Convert.ToInt32(this.Request.Params["GroupId"]);
                    rootFolder = this.controller.GetGroupFolder(groupId, this.PortalSettings);
                    if (rootFolder == null)
                    {
                        throw new Exception("Invalid group folder");
                    }

                    break;

                case DigitalAssestsMode.User:
                    rootFolder = this.controller.GetUserFolder(this.PortalSettings.UserInfo);
                    break;

                default:
                    rootFolder = this.controller.GetRootFolder(this.ModuleId);
                    break;
                }

                this.isRootFolder    = rootFolder.FolderID == folderId;
                this.folderViewModel = this.isRootFolder ? rootFolder : this.controller.GetFolder(folderId);

                // Setup controls
                this.CancelButton.Click += this.OnCancelClick;
                this.SaveButton.Click   += this.OnSaveClick;
                this.PrepareFolderPreviewInfo();
                this.cmdCopyPerm.Click += this.cmdCopyPerm_Click;

                var mef = new ExtensionPointManager();
                var folderFieldsExtension = mef.GetUserControlExtensionPointFirstByPriority("DigitalAssets", "FolderFieldsControlExtensionPoint");
                if (folderFieldsExtension != null)
                {
                    this.folderFieldsControl    = this.Page.LoadControl(folderFieldsExtension.UserControlSrc);
                    this.folderFieldsControl.ID = this.folderFieldsControl.GetType().BaseType.Name;
                    this.FolderDynamicFieldsContainer.Controls.Add(this.folderFieldsControl);
                    var fieldsControl = this.folderFieldsControl as IFieldsControl;
                    if (fieldsControl != null)
                    {
                        fieldsControl.SetController(this.controller);
                        fieldsControl.SetItemViewModel(new ItemViewModel
                        {
                            ItemID   = this.folderViewModel.FolderID,
                            IsFolder = true,
                            PortalID = this.folderViewModel.PortalID,
                            ItemName = this.folderViewModel.FolderName,
                        });
                    }
                }
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Determines whether [has write permission] [the specified relative path].
        /// </summary>
        /// <param name="relativePath">The relative path.</param>
        /// <returns>
        ///   <c>true</c> if [has write permission] [the specified relative path]; otherwise, <c>false</c>.
        /// </returns>
        private bool HasWritePermission(string relativePath)
        {
            var portalId = PortalSettings.Current.PortalId;

            return(FolderPermissionController.HasFolderPermission(portalId, relativePath, "WRITE"));
        }
        private static FileUploadDto UploadFile(
            Stream stream,
            PortalSettings portalSettings,
            UserInfo userInfo,
            string folder,
            string filter,
            string fileName,
            bool overwrite,
            bool isHostPortal,
            bool extract)
        {
            var          result      = new FileUploadDto();
            BinaryReader reader      = null;
            Stream       fileContent = null;

            try
            {
                var extension = Path.GetExtension(fileName).TextOrEmpty().Replace(".", "");
                result.FileIconUrl = IconController.GetFileIconUrl(extension);

                if (!string.IsNullOrEmpty(filter) && !filter.ToLower().Contains(extension.ToLower()))
                {
                    result.Message = GetLocalizedString("ExtensionNotAllowed");
                    return(result);
                }

                if (!IsAllowedExtension(extension))
                {
                    result.Message = GetLocalizedString("ExtensionNotAllowed");
                    return(result);
                }

                var folderManager = FolderManager.Instance;

                var effectivePortalId = isHostPortal ? Null.NullInteger : portalSettings.PortalId;

                // Check if this is a User Folder
                int userId;
                var folderInfo = folderManager.GetFolder(effectivePortalId, folder);
                if (IsUserFolder(folder, out userId))
                {
                    var user = UserController.GetUserById(effectivePortalId, userId);
                    if (user != null)
                    {
                        folderInfo = folderManager.GetUserFolder(user);
                    }
                }

                if (!FolderPermissionController.HasFolderPermission(portalSettings.PortalId, folder, "WRITE") &&
                    !FolderPermissionController.HasFolderPermission(portalSettings.PortalId, folder, "ADD"))
                {
                    result.Message = GetLocalizedString("NoPermission");
                    return(result);
                }

                IFileInfo file;

                // FIX DNN-5917
                fileName = SanitizeFileName(fileName);
                // END FIX

                if (!overwrite && FileManager.Instance.FileExists(folderInfo, fileName, true))
                {
                    result.Message       = GetLocalizedString("AlreadyExists");
                    result.AlreadyExists = true;
                    file          = FileManager.Instance.GetFile(folderInfo, fileName, true);
                    result.FileId = file.FileId;
                }
                else
                {
                    file = FileManager.Instance.AddFile(folderInfo, fileName, stream, true, false,
                                                        FileManager.Instance.GetContentType(Path.GetExtension(fileName)),
                                                        userInfo.UserID);
                    if (extract && extension.ToLower() == "zip")
                    {
                        var destinationFolder = FolderManager.Instance.GetFolder(file.FolderId);
                        var invalidFiles      = new List <string>();
                        var filesCount        = FileManager.Instance.UnzipFile(file, destinationFolder, invalidFiles);

                        var invalidFilesJson = invalidFiles.Count > 0
                            ? string.Format("\"{0}\"", string.Join("\",\"", invalidFiles))
                            : string.Empty;
                        result.Prompt = string.Format("{{\"invalidFiles\":[{0}], \"totalCount\": {1}}}", invalidFilesJson, filesCount);
                    }
                    result.FileId = file.FileId;
                }

                fileContent = FileManager.Instance.GetFileContent(file);

                var path = GetUrl(result.FileId);
                using (reader = new BinaryReader(fileContent))
                {
                    Size size;
                    if (IsImage(fileName))
                    {
                        try
                        {
                            size = ImageHeader.GetDimensions(reader);
                        }
                        catch (ArgumentException exc)
                        {
                            Logger.Warn("Unable to get image dimensions for image file", exc);
                            size = new Size(32, 32);
                        }
                    }
                    else
                    {
                        size = new Size(32, 32);
                    }

                    result.Orientation = size.Orientation();
                }

                result.Path     = result.FileId > 0 ? path : string.Empty;
                result.FileName = fileName;

                if (extract && extension.ToLower() == "zip")
                {
                    FileManager.Instance.DeleteFile(file);
                }

                return(result);
            }
            catch (Exception exe)
            {
                Logger.Error(exe.Message);
                result.Message = exe.Message;
                return(result);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                    reader.Dispose();
                }
                if (fileContent != null)
                {
                    fileContent.Close();
                    fileContent.Dispose();
                }
            }
        }
Esempio n. 6
0
        protected override void OnInit(EventArgs e)
        {
            try
            {
                base.OnInit(e);

                JavaScript.RequestRegistration(CommonJs.DnnPlugins);

                var fileId = Convert.ToInt32(Request.Params["FileId"]);
                file     = FileManager.Instance.GetFile(fileId, true);
                fileItem = controller.GetFile(fileId);
                folder   = FolderManager.Instance.GetFolder(file.FolderId);

                SaveButton.Click   += OnSaveClick;
                CancelButton.Click += OnCancelClick;

                if (FolderPermissionController.CanViewFolder((FolderInfo)folder))
                {
                    var mef = new ExtensionPointManager();
                    var preViewPanelExtension = mef.GetUserControlExtensionPointFirstByPriority("DigitalAssets", "PreviewInfoPanelExtensionPoint");
                    previewPanelControl = Page.LoadControl(preViewPanelExtension.UserControlSrc);
                    PreviewPanelContainer.Controls.Add(previewPanelControl);

                    var fileFieldsExtension = mef.GetUserControlExtensionPointFirstByPriority("DigitalAssets", "FileFieldsControlExtensionPoint");
                    fileFieldsControl    = Page.LoadControl(fileFieldsExtension.UserControlSrc);
                    fileFieldsControl.ID = fileFieldsControl.GetType().BaseType.Name;
                    FileFieldsContainer.Controls.Add(fileFieldsControl);

                    PrepareFilePreviewInfoControl();
                    PrepareFileFieldsControl();

                    // Tab Extension Point
                    var tabContentControlsInstances = new List <PropertiesTabContentControl>();
                    foreach (var extension in mef.GetEditPageTabExtensionPoints("DigitalAssets", "FilePropertiesTab"))
                    {
                        if (FolderPermissionController.HasFolderPermission(folder.FolderPermissions, extension.Permission))
                        {
                            var liElement = new HtmlGenericControl("li")
                            {
                                InnerHtml = "<a href=\"#" + extension.EditPageTabId + "\">" + extension.Text + "</a>",
                            };
                            liElement.Attributes.Add("class", extension.CssClass);
                            liElement.Attributes.Add("id", extension.EditPageTabId + "_tab");
                            Tabs.Controls.Add(liElement);

                            var container = new PanelTabExtensionControl {
                                PanelId = extension.EditPageTabId
                            };
                            var control = (PortalModuleBase)Page.LoadControl(extension.UserControlSrc);
                            control.ID = Path.GetFileNameWithoutExtension(extension.UserControlSrc);
                            control.ModuleConfiguration = ModuleConfiguration;
                            var contentControl = control as PropertiesTabContentControl;
                            if (contentControl != null)
                            {
                                contentControl.OnItemUpdated += OnItemUpdated;
                                tabContentControlsInstances.Add(contentControl);
                            }
                            container.Controls.Add(control);
                            TabsPanel.Controls.Add(container);
                        }
                    }
                    tabContentControls = tabContentControlsInstances.ToList();
                }
            }
            catch (Exception ex)
            {
                Exceptions.ProcessModuleLoadException(this, ex);
            }
        }
Esempio n. 7
0
        /// <summary>
        ///   OnPreRender runs just before the control is rendered
        /// </summary>
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            if (_cboFolders.Items.Count > 0)
            {
                //Configure Labels
                _lblFolder.Text     = Utilities.GetLocalizedString("Folder");
                _lblFolder.CssClass = LabelCssClass;
                _lblFile.Text       = Utilities.GetLocalizedString("File");
                _lblFile.CssClass   = LabelCssClass;

                //select folder
                string fileName;
                string folderPath;
                if (!string.IsNullOrEmpty(FilePath))
                {
                    fileName   = FilePath.Substring(FilePath.LastIndexOf("/") + 1);
                    folderPath = string.IsNullOrEmpty(fileName) ? FilePath : FilePath.Replace(fileName, "");
                }
                else
                {
                    fileName   = FilePath;
                    folderPath = string.Empty;
                }

                if (_cboFolders.Items.FindByValue(folderPath) != null)
                {
                    _cboFolders.SelectedIndex = -1;
                    _cboFolders.Items.FindByValue(folderPath).Selected = true;
                }

                //Get Files
                LoadFiles();
                if (_cboFiles.Items.FindByText(fileName) != null)
                {
                    _cboFiles.Items.FindByText(fileName).Selected = true;
                }
                if (_cboFiles.SelectedItem == null || string.IsNullOrEmpty(_cboFiles.SelectedItem.Value))
                {
                    FileID = -1;
                }
                else
                {
                    FileID = Int32.Parse(_cboFiles.SelectedItem.Value);
                }

                if (_cboFolders.Items.Count > 1 && ShowFolders)
                {
                    _pnlFolder.Visible = true;
                }
                else
                {
                    _pnlFolder.Visible = false;
                }
                //Configure Mode
                switch (Mode)
                {
                case FileControlMode.Normal:
                    _pnlFile.Visible     = true;
                    _pnlUpload.Visible   = false;
                    _pnlRightDiv.Visible = true;
                    ShowImage();

                    if ((FolderPermissionController.HasFolderPermission(PortalId, _cboFolders.SelectedItem.Value, "ADD") || IsUserFolder(_cboFolders.SelectedItem.Value)) && ShowUpLoad)
                    {
                        ShowButton(_cmdUpload, "Upload");
                    }
                    break;

                case FileControlMode.UpLoadFile:
                    _pnlFile.Visible     = false;
                    _pnlUpload.Visible   = true;
                    _pnlRightDiv.Visible = false;
                    ShowButton(_cmdSave, "Save");
                    ShowButton(_cmdCancel, "Cancel");
                    break;
                }
            }
            else
            {
                _lblMessage.Text = Utilities.GetLocalizedString("NoPermission");
            }

            //Show message Row
            _pnlMessage.Visible = (!string.IsNullOrEmpty(_lblMessage.Text));
        }
Esempio n. 8
0
 /// <summary>
 /// Checks if the current user have READ permission on a given folder.
 /// </summary>
 /// <param name="folder">Folder info object.</param>
 /// <returns>True if the user has READ permission, false otherwise.</returns>
 public bool DoesHaveReadFolderPermission(IFolderInfo folder)
 {
     return(FolderPermissionController.HasFolderPermission(folder.FolderPermissions, "Read"));
 }
 public bool HasFolderPermission(IFolderInfo folder, string permissionKey)
 {
     return(UserController.Instance.GetCurrentUserInfo().IsSuperUser ||
            FolderPermissionController.HasFolderPermission(folder.FolderPermissions, permissionKey));
 }
        /// <summary>
        /// OnPreRender handler.
        /// </summary>
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            _lblFolder.Text = Utilities.GetLocalizedString("Folder");
            _lblFile.Text   = Utilities.GetLocalizedString("File");

            _lblFolder.CssClass = LabelCssClass;
            _lblFile.CssClass   = LabelCssClass;

            string fileName = null; string folderPath = null;

            if (!String.IsNullOrEmpty(FilePath))
            {
                fileName = FilePath.Substring(FilePath.LastIndexOf("/") + 1);
                {
                    folderPath = String.IsNullOrEmpty(fileName) ? FilePath : FilePath.Replace(fileName, String.Empty);
                }
            }
            else
            {
                fileName = FilePath; folderPath = String.Empty;
            }

            if (_cboFolders.Items.FindItemByValue(folderPath) != null)
            {
                _cboFolders.SelectedIndex = -1;
                {
                    _cboFolders.Items.FindItemByValue(folderPath).Selected = true;
                }
            }

            LoadFiles(); _pnlFolder.Visible = (_cboFolders.Items.Count > 1 && ShowFolders);

            if (_cboFiles.Items.FindItemByText(fileName) != null)
            {
                _cboFiles.Items.FindItemByText(fileName).Selected = true;
            }

            if (_cboFiles.SelectedItem == null || String.IsNullOrEmpty(_cboFiles.SelectedItem.Value))
            {
                FileId = -1;
            }
            else
            {
                FileId = Int32.Parse(_cboFiles.SelectedItem.Value);
            }

            _hfFileId.Value = FileId.ToString();

            switch (Mode)
            {
            case FileControlMode.Normal:
            {
                _pnlFile.Visible = true; _pnlUpload.Visible = false; _pnlRightDiv.Visible = true;
                {
                    ShowImage();         // show file selector preview
                }

                if ((FolderPermissionController.HasFolderPermission(PortalId, _cboFolders.SelectedItem.Value, "ADD")) && ShowUpload)
                {
                    ShowButton(_cmdUpload, "Upload");
                }

                break;
            }

            case FileControlMode.UploadFile:
            {
                ShowButton(_cmdSave, "Save"); ShowButton(_cmdCancel, "Cancel");
                {
                    _pnlFile.Visible = false; _pnlRightDiv.Visible = false; _pnlUpload.Visible = true;
                }

                RadAjaxPanel panel = (Parent as RadAjaxPanel);
                {
                    panel.ClientEvents.OnRequestStart = @"utils.postback";
                }

                break;
            }
            }
        }
Esempio n. 11
0
        private static FileUploadDto UploadFile(
            Stream stream,
            int portalId,
            UserInfo userInfo,
            string folder,
            string filter,
            string fileName,
            bool overwrite,
            bool isHostPortal,
            bool extract,
            string validationCode)
        {
            var          result      = new FileUploadDto();
            BinaryReader reader      = null;
            Stream       fileContent = null;

            try
            {
                var extensionList = new List <string>();
                if (!string.IsNullOrWhiteSpace(filter))
                {
                    extensionList = filter.Split(',').Select(i => i.Trim()).ToList();
                }

                var validateParams = new List <object> {
                    extensionList, userInfo.UserID
                };
                if (!userInfo.IsSuperUser)
                {
                    validateParams.Add(portalId);
                }

                if (!ValidationUtils.ValidationCodeMatched(validateParams, validationCode))
                {
                    throw new InvalidOperationException("Bad Request");
                }

                var extension = Path.GetExtension(fileName).ValueOrEmpty().Replace(".", string.Empty);
                result.FileIconUrl = IconController.GetFileIconUrl(extension);

                if (!string.IsNullOrEmpty(filter) && !filter.ToLowerInvariant().Contains(extension.ToLowerInvariant()))
                {
                    result.Message = GetLocalizedString("ExtensionNotAllowed");
                    return(result);
                }

                var folderManager     = FolderManager.Instance;
                var effectivePortalId = isHostPortal ? Null.NullInteger : portalId;
                var folderInfo        = folderManager.GetFolder(effectivePortalId, folder);

                int userId;

                if (folderInfo == null && IsUserFolder(folder, out userId))
                {
                    var user = UserController.GetUserById(effectivePortalId, userId);
                    if (user != null)
                    {
                        folderInfo = folderManager.GetUserFolder(user);
                    }
                }

                if (!FolderPermissionController.HasFolderPermission(portalId, folder, "WRITE") &&
                    !FolderPermissionController.HasFolderPermission(portalId, folder, "ADD"))
                {
                    result.Message = GetLocalizedString("NoPermission");
                    return(result);
                }

                IFileInfo file;

                if (!overwrite && FileManager.Instance.FileExists(folderInfo, fileName, true))
                {
                    result.Message       = GetLocalizedString("AlreadyExists");
                    result.AlreadyExists = true;
                    file          = FileManager.Instance.GetFile(folderInfo, fileName, true);
                    result.FileId = file.FileId;
                }
                else
                {
                    file = FileManager.Instance.AddFile(folderInfo, fileName, stream, true, false,
                                                        FileContentTypeManager.Instance.GetContentType(Path.GetExtension(fileName)),
                                                        userInfo.UserID);
                    if (extract && extension.ToLowerInvariant() == "zip")
                    {
                        var destinationFolder = FolderManager.Instance.GetFolder(file.FolderId);
                        var invalidFiles      = new List <string>();
                        var filesCount        = FileManager.Instance.UnzipFile(file, destinationFolder, invalidFiles);

                        var invalidFilesJson = invalidFiles.Count > 0
                            ? string.Format("\"{0}\"", string.Join("\",\"", invalidFiles))
                            : string.Empty;
                        result.Prompt = string.Format("{{\"invalidFiles\":[{0}], \"totalCount\": {1}}}", invalidFilesJson, filesCount);
                    }

                    result.FileId = file.FileId;
                }

                fileContent = FileManager.Instance.GetFileContent(file);

                var path = GetUrl(result.FileId);
                using (reader = new BinaryReader(fileContent))
                {
                    Size size;
                    if (IsImage(fileName))
                    {
                        try
                        {
                            size = ImageHeader.GetDimensions(reader);
                        }
                        catch (ArgumentException exc)
                        {
                            Logger.Warn("Unable to get image dimensions for image file", exc);
                            size = new Size(32, 32);
                        }
                    }
                    else
                    {
                        size = new Size(32, 32);
                    }

                    result.Orientation = size.Orientation();
                }

                result.Path     = result.FileId > 0 ? path : string.Empty;
                result.FileName = fileName;

                if (extract && extension.ToLowerInvariant() == "zip")
                {
                    FileManager.Instance.DeleteFile(file);
                }

                return(result);
            }
            catch (InvalidFileExtensionException)
            {
                result.Message = GetLocalizedString("ExtensionNotAllowed");
                return(result);
            }
            catch (Exception exe)
            {
                Logger.Error(exe);
                result.Message = exe.Message;
                return(result);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                    reader.Dispose();
                }

                if (fileContent != null)
                {
                    fileContent.Close();
                    fileContent.Dispose();
                }
            }
        }
Esempio n. 12
0
        public void LoadContentData(string pContentType)
        {
            // optTypeContentSelection.Visible = True
            plControl.Visible         = true;
            optControl.Visible        = true;
            ploptView.Visible         = true;
            optView.Visible           = true;
            plInfo.Visible            = true;
            optInfo.Visible           = true;
            plNoWrap.Visible          = true;
            optNoWrap.Visible         = true;
            plUsePermissions.Visible  = true;
            optUsePermissions.Visible = true;
            plIcon.Visible            = true;
            ctlIcon.Visible           = true;

            plDisplayAttribute.Visible  = false;
            optDisplayAttribute.Visible = false;
            optDisplayOrder.Visible     = false;
            // 2014 TODO: Menu
            plMenuAllUsers.Visible  = false;
            optMenuAllUsers.Visible = false;
            switch ((Enums.ModuleContentTypes) int.Parse(pContentType))
            {
            case Enums.ModuleContentTypes.Links:
            {
                optUsePermissions.Visible       = true;
                plUsePermissions.Visible        = true;
                optTypeContentSelection.Visible = false;
                break;
            }

            case Enums.ModuleContentTypes.Menu:
            {
                optTypeContentSelection.Visible = true;

                TabController dnnTabController = new TabController();
                TabCollection portalTabs       = dnnTabController.GetTabsByPortal(PortalId);
                TabCollection hostTabs         = dnnTabController.GetTabsByPortal(-1);

                TabCollection tabs = new TabCollection();
                AddTabsToCollection(portalTabs, tabs);
                AddTabsToCollection(hostTabs, tabs);

                List <DotNetNuke.Entities.Tabs.TabInfo> listTabs = new List <DotNetNuke.Entities.Tabs.TabInfo>();
                foreach (System.Collections.Generic.KeyValuePair <int, DotNetNuke.Entities.Tabs.TabInfo> kvp in tabs)
                {
                    listTabs.Add(kvp.Value);
                }

                optTypeContentSelection.DataSource     = listTabs;
                optTypeContentSelection.DataValueField = "TabID";
                optTypeContentSelection.DataTextField  = "TabPath";
                optTypeContentSelection.DataBind();

                if (System.Convert.ToString(ModuleSettings[Consts.ModuleContentItem]) != string.Empty)
                {
                    ListItem item = optTypeContentSelection.Items.FindByValue(System.Convert.ToString(ModuleSettings[Consts.ModuleContentItem]));

                    if (item != null)
                    {
                        item.Selected = true;
                    }
                }

                optUsePermissions.Visible = false;
                plUsePermissions.Visible  = false;
                // 2014 TODO: Menu
                plMenuAllUsers.Visible  = true;
                optMenuAllUsers.Visible = true;
                break;
            }

            case Enums.ModuleContentTypes.Folder:
            {
                var dic = FolderManager.Instance.GetFolders(PortalId);

                var folders = new List <FolderInfo>();

                FolderPermissionController folderPermissionsController = new FolderPermissionController();

                foreach (var item in dic)
                {
                    if (FolderPermissionController.HasFolderPermission(this.PortalId, item.FolderPath, "READ"))
                    {
                        folders.Add(item as FolderInfo);
                    }
                }

                optTypeContentSelection.DataSource     = folders;
                optTypeContentSelection.DataValueField = "FolderID";
                optTypeContentSelection.DataTextField  = "FolderPath";
                optTypeContentSelection.DataBind();

                foreach (ListItem item in optTypeContentSelection.Items)
                {
                    if (string.IsNullOrEmpty(item.Text))
                    {
                        item.Text = "Root";
                    }
                }

                optTypeContentSelection.Visible = true;
                optUsePermissions.Visible       = false;
                plUsePermissions.Visible        = false;

                if (!string.IsNullOrEmpty(ModuleSettings[Consts.ModuleContentItem].ToString()))
                {
                    string moduleContentItem = ModuleSettings[Consts.ModuleContentItem].ToString();

                    bool hasItem = false;
                    foreach (ListItem item in optTypeContentSelection.Items)
                    {
                        if (item.Value == moduleContentItem)
                        {
                            hasItem = true;
                            break;
                        }
                    }

                    if (hasItem)
                    {
                        optTypeContentSelection.SelectedValue = ModuleSettings[Consts.ModuleContentItem].ToString();
                    }
                }

                break;
            }

            case Enums.ModuleContentTypes.Friends:
            {
                optTypeContentSelection.Visible = true;
                plControl.Visible           = true;
                optControl.Visible          = true;
                ploptView.Visible           = true;
                optView.Visible             = true;
                plInfo.Visible              = true;
                optInfo.Visible             = true;
                plNoWrap.Visible            = true;
                optNoWrap.Visible           = true;
                plDisplayAttribute.Visible  = true;
                optDisplayAttribute.Visible = true;
                optDisplayOrder.Visible     = true;
                plUsePermissions.Visible    = false;
                optUsePermissions.Visible   = false;
                plIcon.Visible              = false;
                ctlIcon.Visible             = false;

                optTypeContentSelection.Items.Clear();
                optTypeContentSelection.ClearSelection();
                optDisplayAttribute.ClearSelection();
                optDisplayOrder.ClearSelection();
                // normal und business card
                ArrayList modeList         = new ArrayList();
                object    modeNormal       = new { ModeID = "NormalMode", Mode = "Normal" };
                object    modeBusinessCard = new { ModeID = "BusinessCardMode", Mode = "Business Card" };
                modeList.Add(modeNormal);
                modeList.Add(modeBusinessCard);
                optTypeContentSelection.DataSource     = modeList;
                optTypeContentSelection.DataValueField = "ModeID";
                optTypeContentSelection.DataTextField  = "Mode";
                optTypeContentSelection.DataBind();

                if (System.Convert.ToString(ModuleSettings[Consts.ModuleContentItem]) != string.Empty)
                {
                    ListItem item = optTypeContentSelection.Items.FindByValue(System.Convert.ToString(ModuleSettings[Consts.ModuleContentItem]));
                    if (item != null)
                    {
                        item.Selected = true;
                        if (item.Value.Equals(BUSINESSCARDMODE))
                        {
                            plControl.Visible           = false;
                            optControl.Visible          = false;
                            ploptView.Visible           = false;
                            optView.Visible             = false;
                            plInfo.Visible              = false;
                            optInfo.Visible             = false;
                            plNoWrap.Visible            = false;
                            optNoWrap.Visible           = false;
                            plDisplayAttribute.Visible  = false;
                            optDisplayAttribute.Visible = false;
                            optDisplayOrder.Visible     = false;
                        }
                    }
                }

                if (System.Convert.ToString(ModuleSettings[SettingName.DisplayAttribute]) != string.Empty)
                {
                    ListItem item = optDisplayAttribute.Items.FindByValue(System.Convert.ToString(ModuleSettings[SettingName.DisplayAttribute]));

                    if (item != null)
                    {
                        item.Selected = true;
                    }
                }
                if (System.Convert.ToString(ModuleSettings[SettingName.DisplayAttribute]) != string.Empty)
                {
                    ListItem item = optDisplayOrder.Items.FindByValue(System.Convert.ToString(ModuleSettings[SettingName.DisplayOrder]));

                    if (item != null)
                    {
                        item.Selected = true;
                    }
                }

                break;
            }
            }
        }