protected void lbnOK_Click(object sender, EventArgs e)
        {
            try
            {
                int intSelectedNodeValue = Convert.ToInt32(treeFolders.SelectedNode.Value);
                //get parameters
                if (this.Request.QueryString["Parent"] != null)
                {
                    _ParentID = Int32.Parse(this.Request.QueryString["Parent"]);
                }
                if (this.Request.QueryString["File"] != null)
                {
                    _FileID = Int32.Parse(this.Request.QueryString["File"]);
                }

                FileController fileCtrl = new FileController();
                File targetFile = fileCtrl.Get(_FileID);
                File destinationFolder = fileCtrl.Get(intSelectedNodeValue);
                if (destinationFolder == null)
                {
                    destinationFolder = new File();
                    destinationFolder.ID = -1;
                    destinationFolder.Name = "Portal Root Folder";
                }

                targetFile.ParentID = intSelectedNodeValue;
                targetFile.IsInTrash = false;
                if (UserId != -1)
                {
                    targetFile.LastModifiedByUserName = UserInfo.DisplayName;
                }
                else
                {
                    targetFile.LastModifiedByUserName = "******";
                }
                targetFile.LastModifiedByUserID = -1;
                targetFile.LastModifiedDate = System.DateTime.Now;
                fileCtrl.Update(targetFile);

                //refresh cac
                SynchronizeModule();

                //Redirect back to the portal home page
                this.Response.Redirect(Globals.NavigateURL(this.TabId, "", "Folder=" + _ParentID, "ModuleID=" + ModuleId, "UserID=" + _userIDParameter, "GroupID=" + _roleIDParameter, String.Format("Success={0} moved to: {1}", targetFile.Name, destinationFolder.Name)), true);
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
        private void populateChildren(System.Web.UI.WebControls.TreeNode parentNode, int searchValue, File targetFile)
        {
            if (parentNode == null)
                return;

            //if (this.Request.QueryString["File"] != null)
            //{
            //    _FileID = Int32.Parse(this.Request.QueryString["File"]);
            //}

            //get folders
            FileController fileCtrl = new FileController();
            List<File> listFiles = fileCtrl.GetItemsByParent(Convert.ToInt32(parentNode.Value), UserId, PortalId, PortalSettings.AdministratorRoleId, "Asc") as List<File>;

            foreach (File file in listFiles)
            {
                //Skip getting child items if:
                //item is not folder || item is a folder and matches target item || item can't be modified
                //if (file.ItemType != 0 || file.ID == _FileID|| !file.CanModify(UserId, PortalId, PortalSettings.AdministratorRoleId))
                if (file.ItemType != 0 || !file.CanModify(UserId, PortalId, PortalSettings.AdministratorRoleId, true))
                {
                    continue;
                }
                System.Web.UI.WebControls.TreeNode fileChild = new System.Web.UI.WebControls.TreeNode(file.Name, file.ID.ToString(), "images/folder_16_hot.png");
                if (parentNode != null)
                {
                    //fileChild.PopulateOnDemand = true;
                    fileChild.Expanded = false;
                    //don't get child folder for target
                    if (targetFile.ID != file.ID)
                    {
                        parentNode.ChildNodes.Add(fileChild);
                        populateChildren(fileChild, searchValue, targetFile);
                    }

                    if (fileChild.Value == searchValue.ToString())
                    {
                        fileChild.Selected = true;
                        ExpandParentNode(fileChild);
                    }

                }
            }
        }
        private void PopulateTree(string strParentID, int searchValue, File targetFile)
        {
            FileController fileCtrl = new FileController();
            File rootFile;
            if (strParentID != "-1")
            {
                rootFile = fileCtrl.Get(Convert.ToInt32(strParentID));
            }
            else
            {
                rootFile = new File();
                rootFile.ID = -1;
                rootFile.Name = "Portal Root Folder";
            }

            List<File> listFiles = fileCtrl.GetItemsByParent(rootFile.ID, UserId, PortalId, PortalSettings.AdministratorRoleId, "Asc") as List<File>;
            System.Web.UI.WebControls.TreeNode rootNode = new System.Web.UI.WebControls.TreeNode(rootFile.Name, rootFile.ID.ToString(), "images/folder_16_hot.png");
            rootNode.Expanded = false;
            treeFolders.Nodes.Add(rootNode);
            populateChildren(rootNode, searchValue, targetFile);
        }
 private void CreateFileVersion(File objFile, int uploadIndex)
 {
 }
 private void CreatePermissions(File objFile)
 {
 }
Esempio n. 6
0
        private void PopulateTree(int searchValue)
        {
            FileController fileCtrl = new FileController();
            FileConfigurationController ctrlConfig = new FileConfigurationController();
            var configs = ctrlConfig.GetItems(PortalId) as List<FileConfiguration>;
            if (configs.Count > 0)
            {
                //check for root shared folder
                var rootFolder = fileCtrl.GetRootPortalFolder(PortalId, UserId);

                //if none exists, create
                if (rootFolder == null)
                {
                    rootFolder = fileCtrl.CreateRootSharedFolder(UserId, PortalId);
                }
                configs[0].RootSharedFolderID = rootFolder.ID;

                //check root users folder
                if (configs[0].RootUsersFolderID == 0)
                {
                    //if none exists, create
                    configs[0].RootUsersFolderID = fileCtrl.CreateRootUsersFolder(UserId, PortalId).ID;
                }

                //check root groups folder
                if (configs[0].RootGroupsFolderID == 0)
                {
                    //if none exists, create
                    configs[0].RootGroupsFolderID = fileCtrl.CreateRootGroupsFolder(UserId, PortalId).ID;
                }

                //update config
                ctrlConfig.Update(configs[0]);
            }

            File rootFile = new File();
            rootFile.ID = -1;
            rootFile.Name = "QuickDocsPro";

            List<File> listFiles = fileCtrl.GetItemsByParent(rootFile.ID, UserId, PortalId, PortalSettings.AdministratorRoleId, "Asc") as List<File>;
            System.Web.UI.WebControls.TreeNode rootNode = new System.Web.UI.WebControls.TreeNode(rootFile.Name, rootFile.ID.ToString(), "images/window_16_hot.png");
            rootNode.Expanded = false;

            treeFolders.Nodes.Add(rootNode);
            populateChildren(rootNode, searchValue, configs[0]);

            if (rootNode.Value == searchValue.ToString())
            {
                rootNode.Selected = true;
            }
        }
        private void DeleteChildren(File file)
        {
            //delete ALL children items where user has delete permission

            FileController fileCtrl = new FileController();
            List<File> files = fileCtrl.GetItems(file.ID) as List<File>;
            foreach (File childFile in files)
            {
                if (file.ItemType == 0)
                {
                    DeleteChildren(childFile);
                }
            }
                //send to trash if not folder
                if (file.ItemType != 0 && file.CanDelete(UserId, PortalId, PortalSettings.AdministratorRoleId, false))
                {
                    //send to trash if not there already
                    if (!file.IsInTrash)
                    {
                        file.IsInTrash = true;
                        fileCtrl.Update(file);
                        #region "Audit"
                        //Audit: Create Item
                        AuditController ctrlAudit = new AuditController();
                        Audit deleteAudit = new Audit() { EventDate = file.LastModifiedDate, EventDetails = "", EventName = "Deleted", FileID = file.ID, UserID = UserId };
                        ctrlAudit.Create(deleteAudit);
                        #endregion
                        _deletedFilesCount++;
                        return;
                    }

                    //if file is in trash, delete permissions and file
                    if (file.IsInTrash)
                    {
                        PermissionController permCtrl = new PermissionController();

                        //delete versions and version permissions
                        List<File> versions = fileCtrl.GetItems(file.ID) as List<File>;
                        foreach (File version in versions)
                        {
                            List<Permission> versionPermissions = permCtrl.GetItems(version.ID) as List<Permission>;
                            for (int i = 0; versionPermissions.Count - 1 > i; i++)
                            {
                                permCtrl.Delete(versionPermissions[i]);
                            }
                            fileCtrl.Delete(version);
                        }

                        //delete file permissions
                        List<Permission> folderPermissions = permCtrl.GetItems(file.ID) as List<Permission>;
                        for (int i = 0; folderPermissions.Count - 1 >= i; i++)
                        {
                            permCtrl.Delete(folderPermissions[i]);
                        }

                        //delete file instead of sending to trash
                        _filesToDelete.Add(file);
                        //fileCtrl.Delete(file);

                        _permanentlyDeletedFilesCount++;
                        return;
                    }
                }

                //check if any items exist under folder and delete permission before deleting
                if (file.ItemType == 0 && file.CanDelete(UserId, PortalId, PortalSettings.AdministratorRoleId, false))
                {
                    //get current child count
                    List<File> childFiles = fileCtrl.GetItems(file.ID) as List<File>;
                    int childFilesCount = 0;

                    //count child items not in trash
                    foreach (File childFileCount in childFiles)
                    {
                        if (!childFileCount.IsInTrash)
                        {
                            childFilesCount++;
                        }
                    }

                    //no child items, permanently delete folder
                    if (childFilesCount == 0)
                    {
                        //delete folder permissions
                        PermissionController permCtrl = new PermissionController();
                        List<Permission> folderPermissions = permCtrl.GetItems(file.ID) as List<Permission>;
                        for (int i = 0; folderPermissions.Count - 1 >=  i; i++)
                        {
                            permCtrl.Delete(folderPermissions[i]);
                        }

                        //delete folder instead of sending to trash
                        _filesToDelete.Add(file);
                        //fileCtrl.Delete(file);

                        _deletedFilesCount++;
                        return;
                    }
                    else
                    {
                        _notDeletedFilesCount++;
                        return;
                    }
                }
                _notDeletedFilesCount++;
        }
        private void ApplyPermissionsToDirectChildren(File file, List<Permission> filePermissions)
        {
            FileController fileCtrl = new FileController();
            PermissionController permCtrl = new PermissionController();
            //List<File> childFiles = fileCtrl.GetItemsByParent(file.ID, UserId, PortalId, PortalSettings.AdministratorRoleId, "");
            List<File> childFiles = fileCtrl.GetItems(file.ID) as List<File>;
            foreach (File childFile in childFiles)
            {
                //check edit permission
                if (childFile.CanEditPermissions(UserId, PortalId, PortalSettings.AdministratorRoleId, false))
                {
                    //delete existing permissions
                    List<Permission> deletePermissions = permCtrl.GetItems(childFile.ID) as List<Permission>;
                    foreach (Permission deletePermission in deletePermissions)
                    {
                        Permission permissionToDelete = permCtrl.Get(deletePermission.ID, childFile.ID);
                        permCtrl.Delete(permissionToDelete);
                    }

                    //add file permissions
                    foreach (Permission filePermission in filePermissions)
                    {
                        Permission newPermission = new Permission();
                        newPermission.ID = filePermission.ID;
                        newPermission.ModuleID = filePermission.ModuleID;
                        newPermission.PortalID = filePermission.PortalID;
                        newPermission.CanSee = filePermission.CanSee;
                        newPermission.CanModify = filePermission.CanModify;
                        newPermission.CanAddFiles = filePermission.CanAddFiles;
                        newPermission.CanAddFolders = filePermission.CanAddFolders;
                        newPermission.CanDelete = filePermission.CanDelete;
                        newPermission.CanModifyPermission = filePermission.CanModifyPermission;
                        newPermission.IsOwner = filePermission.IsOwner;
                        newPermission.RoleID = filePermission.RoleID;
                        newPermission.RoleName = filePermission.RoleName;
                        newPermission.UserID = filePermission.UserID;
                        newPermission.UserName = filePermission.UserName;

                        //assign new permission to child item
                        newPermission.FileID = childFile.ID;
                        permCtrl.Create(newPermission);
                    }

                    //report updated file
                    _updatedPermissionFiles.Add(childFile);
                }
                else
                {
                    //report non-updated file
                    _notUpdatedPermissionFiles.Add(childFile);
                }

                //do child files
                ApplyPermissionsToDirectChildren(childFile, filePermissions);
            }
        }
        private void ApplyPermissions(File file)
        {
            string strMyPermission = "";

            //check if in trash, lock down changes
            if (file.IsInTrash)
            {
                //disable edit controls
                txtDescription.Enabled = false;
                txtName.Enabled = false;
                txtVersionsToKeep.Enabled = false;
                lbnDeleteVersions.Visible = false;
                linkAddVersion.Visible = false;
                lbnOK.Visible = false;

                //disable permission controls
                lbnAddUser.Visible = false;
                txtUser.Visible = false;
                lblUser.Visible = false;
                gridPermissions.Enabled = false;
            }

            //see
            if (!file.CanSee(UserId, PortalId, PortalSettings.AdministratorRoleId, true))
            {
                Response.Redirect(Globals.NavigateURL());
            }
            else
            {
                strMyPermission = "See, ";
            }

            //add items
            if (file.CanAddFile(UserId, PortalId, PortalSettings.AdministratorRoleId, true))
            {
                strMyPermission = strMyPermission + "Add Items, ";
            }

            //add folders
            if (file.CanAddFolder(UserId, PortalId, PortalSettings.AdministratorRoleId, true))
            {
                strMyPermission = strMyPermission + "Add Folders, ";
            }

            //modify
            if (!file.CanModify(UserId, PortalId, PortalSettings.AdministratorRoleId, true))
            {
                //disable edit controls
                txtDescription.Enabled = false;
                txtName.Enabled = false;
                txtVersionsToKeep.Enabled = false;
                txtHyperlink.Enabled = false;
                lbnDeleteVersions.Visible = false;
                linkAddVersion.Visible = false;
                lbnOK.Visible = false;
            }
            else
            {
                strMyPermission = strMyPermission + "Modify, ";
            }

            //delete
            if (!file.CanDelete(UserId, PortalId, PortalSettings.AdministratorRoleId, true))
            {
                this.linkDelete.Visible = false;
            }
            else
            {
                strMyPermission = strMyPermission + "Delete, ";
            }

            //edit permission
            if (!file.CanEditPermissions(UserId, PortalId, PortalSettings.AdministratorRoleId, true))
            {
                gridPermissions.Visible = false;
                txtUser.Visible = false;
                lblPermissionsGrid.Visible = false;
                lblUser.Visible = false;
                lbnAddUser.Visible = false;
                ApplyPermissionToSubItems.Visible = false;
            }
            else
            {
                strMyPermission = strMyPermission + "Edit Permissions, ";
                if (file.ItemType != 0)
                {
                    ApplyPermissionToSubItems.Visible = false;
                }
            }

            lblMyPermissions.Text = strMyPermission.Substring(0, strMyPermission.Length - 2);

            //remove versions for folder and hyperlink regardless
            if (file.ItemType == 0 || file.ItemType == 2)
            {
                lbnDeleteVersions.Visible = false;
                linkAddVersion.Visible = false;
                txtVersionsToKeep.Visible = false;
                lblVersionCount.Visible = false;
                liVersions.Visible = false;
                lblVersionToKeepLabel.Visible = false;
                lblVersionCountLabel.Visible = false;
                gridVersions.Visible = false;
            }
        }
Esempio n. 10
0
 private void BindVersions(File objFile)
 {
     //load file versions
     FileController objQuickFiles = new FileController();
     listVersions = objQuickFiles.GetVersions(objFile.ID, UserId, PortalId, PortalSettings.AdministratorRoleId, "") as List<File>;
     gridVersions.DataSource = listVersions;
     gridVersions.DataBind();
     lblVersionCount.Text = listVersions.Count.ToString();
 }
Esempio n. 11
0
        private void ApplyPermissionsToSubItems(File file)
        {
            PermissionController permCtrl = new PermissionController();
            List<Permission> filePermissions = permCtrl.GetItems(file.ID) as List<Permission>;
            _updatedPermissionFiles = new List<File>();
            _notUpdatedPermissionFiles = new List<File>();

            ApplyPermissionsToDirectChildren(file, filePermissions);

            string strResultsMessage = String.Format("Permissions updated for {0} child item(s).  {1} item(s) were not updated.", _updatedPermissionFiles.Count, _notUpdatedPermissionFiles.Count);

            chkApplyToSubItems.Checked = false;

            this.Response.Redirect(Globals.NavigateURL(this.TabId, "", "Folder=" + ParentID.ToString(), "View=" + _sourceView, "Success=" + strResultsMessage), true);
        }
        protected void lbnOK_Click(object sender, EventArgs e)
        {
            try
            {
                //check for trash view
                if (this.Request.QueryString["View"] != null)
                {
                    _view = this.Request.QueryString["View"];
                }

                //can not select portal root or no selection
                if (treeFolders.SelectedNode == null || Convert.ToInt32(treeFolders.SelectedNode.Value) == -1)
                {
                    DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, "Error: The item can not be moved to the selected location.  Select a different folder.", DotNetNuke.UI.Skins.Controls.ModuleMessage.ModuleMessageType.RedError);
                    return;
                }
                int intSelectedNodeValue = Convert.ToInt32(treeFolders.SelectedNode.Value);

                //get parameters
                if (this.Request.QueryString["Parent"] != null)
                {
                    _ParentID = Int32.Parse(this.Request.QueryString["Parent"]);
                }
                if (this.Request.QueryString["File"] != null)
                {
                    _FileID = Int32.Parse(this.Request.QueryString["File"]);
                }

                FileController fileCtrl = new FileController();
                File targetFile = fileCtrl.Get(_FileID);
                File destinationFolder = fileCtrl.Get(intSelectedNodeValue);
                if (destinationFolder == null)
                {
                    destinationFolder = new File();
                    destinationFolder.ID = -1;
                    destinationFolder.Name = "Portal Root Folder";
                }

                var orginalLocation = fileCtrl.Get(targetFile.ParentID);

                targetFile.ParentID = intSelectedNodeValue;
                string strEventType = "Moved";
                if (targetFile.IsInTrash)
                {
                    strEventType = "Restored";
                }
                targetFile.IsInTrash = false;
                if (UserId != -1)
                {
                    targetFile.LastModifiedByUserName = UserInfo.DisplayName;
                }
                else
                {
                    targetFile.LastModifiedByUserName = "******";
                }
                targetFile.LastModifiedByUserID = -1;
                targetFile.LastModifiedDate = System.DateTime.Now;
                fileCtrl.Update(targetFile);

                #region "Audit"
                //Audit: Create Item
                AuditController ctrlAudit = new AuditController();
                Audit moveAudit;
                if (strEventType == "Moved")
                {
                    moveAudit = new Audit() { EventDate = targetFile.LastModifiedDate, EventDetails = String.Format("From: {0}(ID:{1}) to: {2}(ID:{3})", orginalLocation.Name, orginalLocation.ID.ToString(), destinationFolder.Name, destinationFolder.ID.ToString()), EventName = strEventType, FileID = targetFile.ID, UserID = UserId };
                }
                else
                {
                    moveAudit = new Audit() { EventDate = targetFile.LastModifiedDate, EventDetails = String.Format("To: {0}(ID:{1})", destinationFolder.Name, destinationFolder.ID.ToString()), EventName = strEventType, FileID = targetFile.ID, UserID = UserId };
                }
                ctrlAudit.Create(moveAudit);
                #endregion

                //refresh cac
                SynchronizeModule();

                //Redirect back to the portal home page
                this.Response.Redirect(Globals.NavigateURL(this.TabId, "", "Folder=" + _ParentID, "ModuleID=" + ModuleId, "UserID=" + _userIDParameter, "GroupID=" + _roleIDParameter, String.Format("Success={0} moved to: {1}", targetFile.Name, destinationFolder.Name), "View=" + _view), true);
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }