Esempio n. 1
0
        protected override void OnInit(EventArgs e)
        {
            try
            {
                base.OnInit(e);

                jQuery.RequestDnnPluginsRegistration();

                var folderId = Convert.ToInt32(Request.Params["FolderId"]);
                Folder = FolderManager.Instance.GetFolder(folderId);
                if (string.IsNullOrEmpty(Folder.FolderPath))
                {
                    folderViewModel = controller.GetRootFolder();
                    isRootFolder    = true;
                }
                else
                {
                    folderViewModel = controller.GetFolder(folderId);
                }

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

                var mef = new ExtensionPointManager();
                var folderFieldsExtension = mef.GetUserControlExtensionPointFirstByPriority("DigitalAssets", "FolderFieldsControlExtensionPoint");
                if (folderFieldsExtension != null)
                {
                    folderFieldsControl    = Page.LoadControl(folderFieldsExtension.UserControlSrc);
                    folderFieldsControl.ID = folderFieldsControl.GetType().BaseType.Name;
                    FolderDynamicFieldsContainer.Controls.Add(folderFieldsControl);
                    var fieldsControl = folderFieldsControl as IFieldsControl;
                    if (fieldsControl != null)
                    {
                        fieldsControl.SetController(controller);
                        fieldsControl.SetItemViewModel(new ItemViewModel()
                        {
                            ItemID   = folderViewModel.FolderID,
                            IsFolder = true,
                            PortalID = folderViewModel.PortalID,
                            ItemName = folderViewModel.FolderName
                        });
                    }
                }
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
        protected override void OnInit(EventArgs e)
        {
            try
            {
                base.OnInit(e);

                JavaScript.RequestRegistration(CommonJs.DnnPlugins);

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

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

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

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

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

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

                var mef = new ExtensionPointManager();
                var folderFieldsExtension = mef.GetUserControlExtensionPointFirstByPriority("DigitalAssets", "FolderFieldsControlExtensionPoint");
                if (folderFieldsExtension != null)
                {
                    folderFieldsControl    = Page.LoadControl(folderFieldsExtension.UserControlSrc);
                    folderFieldsControl.ID = folderFieldsControl.GetType().BaseType.Name;
                    FolderDynamicFieldsContainer.Controls.Add(folderFieldsControl);
                    var fieldsControl = folderFieldsControl as IFieldsControl;
                    if (fieldsControl != null)
                    {
                        fieldsControl.SetController(controller);
                        fieldsControl.SetItemViewModel(new ItemViewModel
                        {
                            ItemID   = folderViewModel.FolderID,
                            IsFolder = true,
                            PortalID = folderViewModel.PortalID,
                            ItemName = folderViewModel.FolderName
                        });
                    }
                }
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }