コード例 #1
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Page_Load runs when the control is loaded
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// </history>
        /// -----------------------------------------------------------------------------
        protected void Page_Load(System.Object sender, System.EventArgs e)
        {
            try
            {
                //Determine ItemId of CustomerSelfService to Update
                if(this.Request.QueryString["Type"] !=null)
                {
                    ItemType = Convert.ToInt32(this.Request.QueryString["Type"]);
                }
                if (this.Request.QueryString["Parent"] != null)
                {
                    ParentID = Int32.Parse(this.Request.QueryString["Parent"]);
                }
                //check for userID
                if (this.Request.QueryString["UserID"] != null) //if none, then _userIDParam = -1
                {
                    _userIDParameter = Int32.Parse(this.Request.QueryString["UserID"]);
                }
                //check for groupID
                if (this.Request.QueryString["GroupID"] != null) //if none, then _roleIDParam = -1
                {
                    _roleIDParameter = Int32.Parse(this.Request.QueryString["GroupID"]);
                }

                //If this is the first visit to the page, bind the role data to the datalist
                //get parent permissions by default
                if (!Page.IsPostBack)
                {

                    if(ItemType != Null.NullInteger)
                    {
                        if (ItemType == 0) //Folder
                        {
                            lblName.Text = "Folder Name";
                            lblName.HelpText = "Type the name of the folder";
                            FileFormItem.Visible = false;
                            HyperlinkFormItem.Visible = false;
                            gridPermissions.Columns[3].Visible = true;
                            gridPermissions.Columns[4].Visible = true;
                        }
                        else if (ItemType == 1) //File
                        {
                            NameFormItem.Visible = false;
                            HyperlinkFormItem.Visible = false;

                            //async uploader
                            string strAllowedFiles = DotNetNuke.Entities.Controllers.HostController.Instance.GetString("FileExtensions");
                            string[] strSearchPatterns = strAllowedFiles.Split(',');
                            asyncFileUpload.AllowedFileExtensions = strSearchPatterns;
                            asyncFileUpload.EnableInlineProgress = true;
                            asyncFileUpload.MaxFileInputsCount = 1;

                            //asyncFileUpload.MultipleFileSelection = Telerik.Web.UI.AsyncUpload.MultipleFileSelection.Disabled;
                        }
                        else if (ItemType == 2) //Hyperlink
                        {
                            lblName.Text = "Hyperlink Caption";
                            lblName.HelpText = "Type the caption of the hyperlink";
                            txtHyperlink.Text = "http://";
                            FileFormItem.Visible = false;
                        }
                        else
                        {
                            Response.Redirect(Globals.NavigateURL(), true);
                        }
                    }
                    else
                    {
                        Response.Redirect(Globals.NavigateURL(), true);
                    }

                    //create permissions grid and add parent permissions
                    //get permissions grid array
                    aryPermissions = new ArrayList();

                    //add roles to permissions grid
                    List<RoleInfo> roles = new List<RoleInfo>();
                    foreach (RoleInfo role in TestableRoleController.Instance.GetRoles(PortalId))
                    {
                        roles.Add(role);
                    }

                    //add 'all users, unauthenticated users, registered users'
                    RoleInfo allUsers = new RoleInfo();
                    allUsers.RoleName = "All Users";
                    allUsers.RoleID = 1000000;
                    allUsers.PortalID = PortalId;
                    roles.Add(allUsers);
                    RoleInfo unauthenticatedUsers = new RoleInfo();
                    unauthenticatedUsers.RoleID = 1000001;
                    unauthenticatedUsers.RoleName = "Unauthenticated Users";
                    unauthenticatedUsers.PortalID = PortalId;
                    roles.Add(unauthenticatedUsers);

                    //Add arraylist items to list
                    List<RoleInfo> listRoles = new List<RoleInfo>();
                    foreach (RoleInfo role in roles)
                    {
                        listRoles.Add(role);
                    }

                    //sort the roles
                    listRoles.Sort((a1, a2) => a1.RoleName.CompareTo(a2.RoleName));

                    foreach (RoleInfo role in listRoles)
                    {
                        if (role.PortalID == PortalId)
                        {
                            Permission perm = new Permission();
                            perm.RoleName = role.RoleName;
                            perm.RoleID = role.RoleID;
                            aryPermissions.Add(perm);
                        }
                    }

                    //Check for parent permissions and add if found
                    if (this.Request.QueryString["Parent"] != null)
                    {
                        ParentID = Int32.Parse(this.Request.QueryString["Parent"]);
                        if (ParentID > 0)
                        {
                            //get parent file permissions
                            PermissionController permCtrl = new PermissionController();
                            List<Permission> existingPermissions = permCtrl.GetItems(ParentID) as List<Permission>;
                            //loop parent permissions and find matching permissions
                            //add permissions to list
                            foreach (Permission existingPermission in existingPermissions)
                            {
                                //loop permissions and set if role id matches
                                if (existingPermission.RoleID > 0)
                                {
                                    foreach (Permission permission in aryPermissions)
                                    {
                                        if (permission.RoleID == existingPermission.RoleID)
                                        {
                                            permission.CanAddFiles = existingPermission.CanAddFiles;
                                            permission.CanAddFolders = existingPermission.CanAddFolders;
                                            permission.CanDelete = existingPermission.CanDelete;
                                            permission.CanModify = existingPermission.CanModify;
                                            permission.CanModifyPermission = existingPermission.CanModifyPermission;
                                            permission.CanSee = existingPermission.CanSee;
                                            permission.RoleID = existingPermission.RoleID;
                                            permission.RoleName = existingPermission.RoleName;
                                        }
                                    }
                                    continue;
                                }

                                //add user permission
                                if (existingPermission.UserID > 0)
                                {
                                    aryPermissions.Add(existingPermission);
                                }
                            }
                        }
                    }

                    //get current user permission
                    if (UserId != -1)
                    {
                        Permission userPermission = new Permission();
                        userPermission.CanSee = true;
                        userPermission.CanModify = true;
                        userPermission.CanDelete = true;
                        userPermission.CanModifyPermission = true;
                        userPermission.CanAddFiles = true;
                        userPermission.CanAddFolders = true;
                        userPermission.PortalID = PortalId;
                        userPermission.UserID = UserId;
                        userPermission.UserName = UserInfo.Username;

                        bool permExists = false;
                        foreach (Permission existPerm in aryPermissions)
                        {
                            if (existPerm.UserID == UserId)
                            {
                                existPerm.CanSee = true;
                                existPerm.CanModify = true;
                                existPerm.CanDelete = true;
                                existPerm.CanModifyPermission = true;
                                existPerm.CanAddFiles = true;
                                existPerm.CanAddFolders = true;
                                permExists = true;
                            }
                        }
                        if (permExists == false)
                        {
                            aryPermissions.Add(userPermission);
                        }
                    }

                    //bind permissions to grid
                    gridPermissions.DataSource = aryPermissions;
                    gridPermissions.DataBind();

                    Session["aryPermissions"] = aryPermissions;
                }

            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
コード例 #2
0
ファイル: File.cs プロジェクト: heitkea/DNN_DEV_7_2
        public int UserPermissionValue(int userID, int userPortalID, int adminRoleID, bool boolUseCache)
        {
            //check if hydrated
            if (_permissionValue != -1 && boolUseCache == true)
            {
                return _permissionValue;
            }

            _permissionValue = 0;
            RoleController roleCtrl = new RoleController();
            UserController userCtrl = new UserController();
            UserInfo user = userCtrl.GetUser(userPortalID, userID);
            DotNetNuke.Entities.Portals.PortalController portalCtrl = new DotNetNuke.Entities.Portals.PortalController();

            if (user != null)
            {
                if (user.IsSuperUser || user.IsInRole(roleCtrl.GetRole(adminRoleID, userPortalID).RoleName))
                {
                    _permissionValue = 63;
                    return _permissionValue;
                }
            }

            PermissionController permCtrl = new PermissionController();
            List<Permission> listPermissions = permCtrl.GetItems(ID) as List<Permission>;

            foreach (Permission perm in listPermissions)
            {
                int permValue = 0;

                //check group permission
                if (perm.RoleID > 0)
                {
                    RoleInfo role = roleCtrl.GetRole(perm.RoleID, PortalID);

                    //TODO check for all users, unauthenticated
                    if (role == null)
                    {
                        //check for all users
                        if (perm.RoleName == "All Users")
                        {
                            permValue = GetPermissionValue(perm);
                            if (permValue > _permissionValue)
                            {
                                _permissionValue = permValue;
                            }
                        }

                        //check for unauthenticated and null user
                        if (perm.RoleName == "Unauthenticated Users" && user == null)
                        {
                            permValue = GetPermissionValue(perm);
                            if (permValue > _permissionValue)
                            {
                                _permissionValue = permValue;
                            }
                        }
                        continue;
                    }

                    if (user != null)
                    {
                        if (user.IsInRole(role.RoleName))
                        {
                            permValue = GetPermissionValue(perm);
                            if (permValue > _permissionValue)
                            {
                                _permissionValue = permValue;
                            }
                        }
                    }
                    //continue looking for permissions, highest perm wins
                    continue;
                }

                //check user permission, user perm overrides role perm
                if (perm.UserID > 0)
                {
                    if (perm.UserID == userID)
                    {
                        permValue = GetPermissionValue(perm);
                        _permissionValue = permValue;
                        break;
                    }
                }
            }

            //hydrate permission value
            return _permissionValue;
        }
コード例 #3
0
        public override IList<DotNetNuke.Services.Search.Entities.SearchDocument> GetModifiedSearchDocuments(ModuleInfo moduleInfo, DateTime beginDate)
        {
            //create search item collection
            var searchItemColl = new List<SearchDocument>();// SearchItemInfoCollection();

            //get list of items by moduleID
            FileController ctrlFiles = new FileController();
            foreach (File file in ctrlFiles.GetSearchableItems(beginDate))
            {
                //SearchItemInfo sii = new SearchItemInfo();
                SearchDocument sii = new SearchDocument();

                string strContent;
                string strGUID;
                string strDescription;
                switch (file.ItemType)
                {
                    case 1: //file
                        strContent = String.Format("{0} {1} {2} {3} {4}", file.Name, file.Description, file.CreatedByUserName, file.LastModifiedByUserName, file.FileType);
                        strGUID = "Open=" + file.ID.ToString();

                        var parentFile = ctrlFiles.Get(file.ParentID);
                        int parentID = parentFile.ID;
                        if (parentFile.ItemType != 0)
                        {
                            parentID = parentFile.ParentID;
                        }
                        strDescription = file.Description;// String.Format("<a href=\"{0}\">[Open Containing Folder]</a> {1}", Globals.NavigateURL(moduleInfo.TabID, "", "Folder=" + parentID.ToString()), file.Description);

                        break;
                    case 2: //hyperlink
                        strContent = String.Format("{0} {1} {2} {3} {4}", file.Name, file.Description, file.CreatedByUserName, file.LastModifiedByUserName, file.FileType);
                        strGUID = "Open=" + file.ID.ToString();
                        strDescription = file.Description;// String.Format("<a href=\"{0}\">[Open Containing Folder]</a> {1}", Globals.NavigateURL(moduleInfo.TabID, "", "Folder=" + file.ParentID.ToString()), file.Description);

                        break;

                    default: //folder
                        strContent = String.Format("{0} {1} {2} {3} {4}", file.Name, file.Description, file.CreatedByUserName, file.LastModifiedByUserName, file.FileType);
                        strGUID = "Folder=" + file.ID.ToString();
                        strDescription = file.Description;

                        break;
                }

                //get see permissions
                PermissionController ctrlPerm = new PermissionController();
                var perms = ctrlPerm.GetItems(file.ID);
                string strPerms = "";
                foreach (Permission perm in perms)
                {
                    if (perm.CanSee)
                    {
                        if (perm.UserID != 0)
                        {
                            //user perm
                            strPerms += String.Format("[{0}];", perm.UserID);
                        }
                        else
                        {
                            //role perm
                            if (perm.RoleName == "All Users")
                            {
                                strPerms = "";
                                break;
                            }
                            strPerms += perm.RoleName;
                        }
                    }
                }
                if (strPerms.Length > 0)
                {
                    strPerms = strPerms.Substring(0, strPerms.Length - 1);
                }

                sii.AuthorUserId = file.LastModifiedByUserID;
                sii.ModuleId = file.ModuleID;
                sii.Body = strContent;
                //sii.CultureCode = "";
                sii.Description = strDescription;
                sii.IsActive = true;
                //sii.Keywords = strContent;
                sii.ModifiedTimeUtc = file.LastModifiedDate;
                sii.ModuleDefId = moduleInfo.ModuleDefID;
                sii.ModuleId = file.ModuleID;
                //sii.NumericKeys = "";
                sii.Permissions = strPerms;
                sii.PortalId = file.PortalID;
                sii.QueryString = strGUID;
                //sii.RoleId = -1;
                //sii.SearchTypeId = -1;
                sii.TabId = moduleInfo.TabID;
                //sii.Tags = "";
                sii.Title = file.Name;
                sii.UniqueKey = file.ID.ToString();
                //sii.Url = "";

                /*
                sii.PubDate = file.CreatedDate;
                sii.Description = strDescription;
                sii.SearchItemId = file.ID;
                sii.Content = strContent;
                sii.SearchKey = file.ID.ToString();
                sii.GUID = strGUID;
                sii.TabId = ModInfo.TabID;
                sii.Title = file.Name;
                */
                searchItemColl.Add(sii);
            }

            return searchItemColl;
        }
コード例 #4
0
        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++;
        }
コード例 #5
0
        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);
            }
        }
コード例 #6
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Page_Load runs when the control is loaded
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// </history>
        /// -----------------------------------------------------------------------------
        protected void Page_Load(System.Object sender, System.EventArgs e)
        {
            try
            {
                if (this.Request.QueryString["ID"] != null)
                {
                    ItemID = Int32.Parse(this.Request.QueryString["ID"]);
                }
                //check for userID
                if (this.Request.QueryString["UserID"] != null) //if none, then _userIDParam = -1
                {
                    _userIDParameter = Int32.Parse(this.Request.QueryString["UserID"]);
                }
                //check for groupID
                if (this.Request.QueryString["GroupID"] != null) //if none, then _roleIDParam = -1
                {
                    _roleIDParameter = Int32.Parse(this.Request.QueryString["GroupID"]);
                }
                if (this.Request.QueryString["View"] != null)
                {
                    _sourceView = this.Request.QueryString["View"];
                }

                //If this is the first visit to the page, bind the role data to the datalist
                if (!Page.IsPostBack)
                {
                    DNNQuickApps.Modules.QuickDocsPro.FileController objQuickFiles = new DNNQuickApps.Modules.QuickDocsPro.FileController();
                    DNNQuickApps.Modules.QuickDocsPro.File objFile = objQuickFiles.Get(ItemID);

                    //legacy, now sending to delete form
                    //set confirmation messages
                    //if (objFile.IsInTrash)
                    //{
                    //    lbnDelete.Attributes.Add("onClick", "javascript:return confirm('Are you sure you wish to permanently delete this item?');");
                    //}
                    //else
                    //{
                    //    lbnDelete.Attributes.Add("onClick", "javascript:return confirm('" + Localization.GetString("DeleteItem") + "');");
                    //}

                    //delete confirmation for delete versions
                    lbnDeleteVersions.Attributes.Add("onClick", "javascript:return confirm('Are you sure you wish to delete the selected version(s)?');");

                    //verify permissions
                    ApplyPermissions(objFile);

                    txtName.Text = objFile.Name;
                    lblCreatedBy.Text = "<b>" + objFile.CreatedByUserName + "</b> " + objFile.CreatedDate.ToString();
                    //lblCreatedDate.Text = objFile.CreatedDate.ToString();
                    if (objFile.CreatedByUserID != -1)
                    {
                        imgCreatedByProfile.ImageUrl = UserController.GetUserById(PortalId, objFile.CreatedByUserID).Profile.PhotoURL;
                    }
                    imgCreatedByProfile.Height = 24;
                    lblModifiedBy.Text = "<b>" + objFile.LastModifiedByUserName + "</b> " + objFile.LastModifiedDate.ToString();
                    //lblModifiedDate.Text = objFile.LastModifiedDate.ToString();
                    if (objFile.LastModifiedByUserID != -1)
                    {
                        imgLastModifiedByProfile.ImageUrl = UserController.GetUserById(PortalId, objFile.LastModifiedByUserID).Profile.PhotoURL;
                    }
                    imgLastModifiedByProfile.Height = 24;
                    txtDescription.Text = objFile.Description;
                    txtVersionsToKeep.Text = objFile.VersionsToKeep.ToString();

                    #region "Load Audit"

                    if (Settings["ShowAuditHistory"] != null)
                    {
                        if (Convert.ToBoolean(Settings["ShowAuditHistory"].ToString()) == true)
                        {
                            AuditController ctrlAudit = new AuditController();
                            var auditData = ctrlAudit.Get10ItemAuditHistory(ItemID);
                            Session["AuditData"] = auditData;
                            gridAudit.DataSource = Session["AuditData"];
                            gridAudit.DataBind();

                            if (gridAudit.Rows.Count == 10)
                            {
                                lbnLoadFullAudit.Visible = true;
                            }
                            else
                            {
                                lbnLoadFullAudit.Visible = false;
                            }
                        }
                        else
                        {
                            liAudit.Visible = false;
                            lbnLoadFullAudit.Visible = false;
                        }
                    }
                    else
                    {
                        liAudit.Visible = false;
                        lbnLoadFullAudit.Visible = false;
                    }
                    #endregion

                    if (objFile.ItemType == 0) //folder
                    {
                        if (_userIDParameter != -1)
                        {
                            _directLink = Globals.NavigateURL(TabId, "", "Folder=" + objFile.ID.ToString(), "UserID=" + _userIDParameter.ToString());
                        }
                        else
                        {
                            _directLink = Globals.NavigateURL(TabId, "", "Folder=" + objFile.ID.ToString());
                        }
                        lblDirectLink.Text = _directLink;
                        lblNameLabel.Text = "Folder Name";
                        liVersions.Visible = false;

                        formItemVersionCount.Visible = false;
                        formItemVersions.Visible = false;
                        formItemVersionsToKeep.Visible = false;
                        lbnDeleteVersions.Visible = false;
                        FormItemHyperlink.Visible = false;

                        gridPermissions.Columns[3].Visible = true;
                        gridPermissions.Columns[4].Visible = true;

                    }

                    if (objFile.ItemType == 1) //file
                    {
                        if (_userIDParameter != -1)
                        {
                            _directLink = Globals.NavigateURL(TabId, "", "Open=" + objFile.ID.ToString(), "UserID=" + _userIDParameter.ToString());
                        }
                        else
                        {
                            _directLink = Globals.NavigateURL(TabId, "", "Open=" + objFile.ID.ToString());
                        }
                        lblDirectLink.Text = _directLink;
                        lblNameLabel.Text = "File Name";
                        liVersions.Visible = true;
                        FormItemHyperlink.Visible = false;

                        BindVersions(objFile);
                    }

                    if (objFile.ItemType == 2) //Link
                    {
                        if (_userIDParameter != -1)
                        {
                            _directLink = Globals.NavigateURL(TabId, "", "Open=" + objFile.ID.ToString(), "UserID=" + _userIDParameter.ToString());
                        }
                        else
                        {
                            _directLink = Globals.NavigateURL(TabId, "", "Open=" + objFile.ID.ToString());
                        }
                        lblDirectLink.Text = _directLink;
                        lblNameLabel.Text = "Hyperlink Caption";
                        txtHyperlink.Text = objFile.LinkURL;
                        liVersions.Visible = false;

                        formItemVersionCount.Visible = false;
                        formItemVersions.Visible = false;
                        formItemVersionsToKeep.Visible = false;
                        lbnDeleteVersions.Visible = false;
                        linkAddVersion.Visible = false;
                    }

                    //Social Share
                    socialShare.TitleToShare = objFile.Name;
                    socialShare.UrlToShare = lblDirectLink.Text;

                    socialEmail.TitleToShare = objFile.Name;
                    socialEmail.UrlToShare = lblDirectLink.Text;

                    //get permissions grid array
                    aryPermissions = new ArrayList();

                    //add roles to permissions grid
                    List<RoleInfo> roles = new List<RoleInfo>();
                    foreach (RoleInfo role in TestableRoleController.Instance.GetRoles(PortalId))
                    {
                        roles.Add(role);
                    }

                    //add 'all users, unauthenticated users, registered users'
                    RoleInfo allUsers = new RoleInfo();
                    allUsers.RoleName = "All Users";
                    allUsers.RoleID = 1000000;
                    allUsers.PortalID = PortalId;
                    roles.Add(allUsers);
                    RoleInfo unauthenticatedUsers = new RoleInfo();
                    unauthenticatedUsers.RoleID = 1000001;
                    unauthenticatedUsers.PortalID = PortalId;
                    unauthenticatedUsers.RoleName = "Unauthenticated Users";
                    roles.Add(unauthenticatedUsers);

                    //Add arraylist items to list
                    List<RoleInfo> listRoles = new List<RoleInfo>();
                    foreach (RoleInfo role in roles)
                    {
                        listRoles.Add(role);
                    }

                    //sort the roles
                    listRoles.Sort((a1, a2) => a1.RoleName.CompareTo(a2.RoleName));

                    foreach (RoleInfo role in listRoles)
                    {
                        if (role.PortalID == PortalId)
                        {
                            Permission perm = new Permission();
                            perm.RoleName = role.RoleName;
                            perm.RoleID = role.RoleID;
                            aryPermissions.Add(perm);
                        }
                    }

                    //get existing file permissions
                    PermissionController permCtrl = new PermissionController();
                    List<Permission> existingPermissions = permCtrl.GetItems(ItemID) as List<Permission>;
                    //loop existing permissions and find matching permissions
                    //add user permissions to list
                    foreach (Permission existingPermission in existingPermissions)
                    {
                        //loop permissions and set if role id matches
                        if (existingPermission.RoleID > 0)
                        {
                            foreach (Permission permission in aryPermissions)
                            {
                                if (permission.RoleID == existingPermission.RoleID)
                                {
                                    permission.CanAddFiles = existingPermission.CanAddFiles;
                                    permission.CanAddFolders = existingPermission.CanAddFolders;
                                    permission.CanDelete = existingPermission.CanDelete;
                                    permission.CanModify = existingPermission.CanModify;
                                    permission.CanModifyPermission = existingPermission.CanModifyPermission;
                                    permission.CanSee = existingPermission.CanSee;
                                    permission.RoleID = existingPermission.RoleID;
                                    permission.RoleName = existingPermission.RoleName;
                                }
                            }
                            continue;
                        }

                        //add user permission
                        if (existingPermission.UserID > 0)
                        {
                            aryPermissions.Add(existingPermission);
                        }
                    }

                    //bind permissions to grid
                    gridPermissions.DataSource = aryPermissions;
                    gridPermissions.DataBind();

                    Session["aryPermissions"] = aryPermissions;

                    //set add version url and delete
                    linkAddVersion.NavigateUrl = EditUrl("File", objFile.ID.ToString(), "AddVersion", "Parent=" + objFile.ParentID.ToString(), "UserID=" + _userIDParameter, "GroupID=" + _roleIDParameter);
                    linkDelete.NavigateUrl = EditUrl("File", objFile.ID.ToString(), "Delete", "Parent=" + objFile.ParentID.ToString(), "View=" + _sourceView, "UserID=" + _userIDParameter, "GroupID=" + _roleIDParameter);

                }

               }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
コード例 #7
0
        protected void lbnOK_Click(object sender, EventArgs e)
        {
            try
            {

                ParentID = -1;
                if (this.Request.QueryString["Parent"] != null)
                {
                    ParentID = Int32.Parse(this.Request.QueryString["Parent"]);
                }

                if (this.Request.QueryString["View"] != null)
                {
                    _sourceView = this.Request.QueryString["View"];
                }

                if (this.Request.QueryString["ID"] != null)
                {
                    this.ItemID = Int32.Parse(this.Request.QueryString["ID"]);
                }
                else
                {
                    this.Response.Redirect(Globals.NavigateURL(this.TabId, "", "Folder=" + ParentID.ToString(), "UserID=" + _userIDParameter, "GroupID=" + _roleIDParameter, "Warning=Could not save updates.  File not found."), true);
                }

                //get file
                DNNQuickApps.Modules.QuickDocsPro.FileController objQuickFiles = new DNNQuickApps.Modules.QuickDocsPro.FileController();
                DNNQuickApps.Modules.QuickDocsPro.File objFile = objQuickFiles.Get(ItemID);
                objFile.ModuleID = ModuleId;
                objFile.LastModifiedDate = System.DateTime.Now;
                objFile.Name = txtName.Text;
                objFile.Description = txtDescription.Text;
                objFile.LastModifiedByUserID = UserId;

                //update link url
                if (objFile.ItemType == 2) //link
                {
                    objFile.LinkURL = txtHyperlink.Text;
                }

                if (UserId != -1)
                {
                    objFile.LastModifiedByUserName = UserInfo.DisplayName;
                }
                else
                {
                    objFile.LastModifiedByUserName = "******";
                }

                try
                {
                    objFile.VersionsToKeep = Int32.Parse(txtVersionsToKeep.Text);
                }
                catch
                {

                }

                if (objFile.CanEditPermissions(UserId, PortalId, PortalSettings.AdministratorRoleId, true))
                {
                    //delete existing permissions
                    PermissionController permCtrl = new PermissionController();
                    List<Permission> permissionsToDelete = permCtrl.GetItems(objFile.ID) as List<Permission>;
                    for (int i = 0; i < permissionsToDelete.Count; i++)
                    {
                        permCtrl.Delete(permissionsToDelete[i]);
                    }

                    //create updated permissions
                    PermissionController objQuickPermissions = new PermissionController();
                    foreach (GridViewRow row in gridPermissions.Rows)
                    {
                        if ((((CheckBox)row.FindControl("chkCanSee")).Checked))
                        {
                            Permission perm = new Permission();
                            perm.CanSee = true;
                            perm.CanAddFiles = ((CheckBox)row.FindControl("chkCanAddItems")).Checked;
                            perm.CanAddFolders = ((CheckBox)row.FindControl("chkCanAddFolders")).Checked;
                            perm.CanModify = ((CheckBox)row.FindControl("chkCanModify")).Checked;
                            perm.CanDelete = ((CheckBox)row.FindControl("chkCanDelete")).Checked;
                            perm.CanModifyPermission = ((CheckBox)row.FindControl("chkCanModifyPermission")).Checked;
                            perm.FileID = objFile.ID;

                            int userID = Int32.Parse(row.Cells[8].Text);
                            int roleID = Int32.Parse(row.Cells[10].Text);
                            string userName = row.Cells[9].Text;
                            string roleName = row.Cells[11].Text;

                            if (userID > 0)
                            {
                                perm.UserID = userID;
                                perm.UserName = userName;
                            }

                            if (roleID > 0)
                            {
                                perm.RoleID = roleID;
                                perm.RoleName = roleName;
                            }

                            objQuickPermissions.Create(perm);
                        }
                    }
                }

                objQuickFiles.Update(objFile);

                #region "Audit"
                //Audit: Updated Item
                AuditController ctrlAudit = new AuditController();
                Audit updatedAudit = new Audit() { EventDate = objFile.LastModifiedDate, EventDetails = "", EventName = "Updated", FileID = objFile.ID, UserID = UserId };
                ctrlAudit.Create(updatedAudit);
                #endregion

                //refresh cache
                SynchronizeModule();

                if (chkApplyToSubItems.Checked)
                {
                    //apply permissions to sub-items
                    ApplyPermissionsToSubItems(objFile);
                    return;
                }

                //Redirect back to the portal home page
                this.Response.Redirect(Globals.NavigateURL(this.TabId, "", "Folder=" + ParentID.ToString(), "View=" + _sourceView, "UserID=" + _userIDParameter, "GroupID=" + _roleIDParameter, "Success=Changes saved."), true);
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
コード例 #8
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);
        }