protected void RadImageEditor1_ImageSaving(object sender, ImageEditorSavingEventArgs e)
        {
            System.Drawing.Image modifiedImage = e.Image.Image;
            string strName = e.FileName;
            string strFormat = "image/unknown";
            long imageLength;

            var imgguid = modifiedImage.RawFormat.Guid;
            foreach (ImageCodecInfo codec in ImageCodecInfo.GetImageDecoders())
            {
                if (codec.FormatID == imgguid)
                {
                    strFormat = codec.MimeType;
                    break;
                }
            }

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

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

            //get current/root file
            DNNQuickApps.Modules.QuickDocsPro.FileController objQuickFiles = new DNNQuickApps.Modules.QuickDocsPro.FileController();
            File objOriginalFile = objQuickFiles.Get(_FileID);
            objOriginalFile.LastModifiedDate = System.DateTime.Now;
            objOriginalFile.LastModifiedByUserID = UserId;

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

            //increment version number
            objOriginalFile.VersionNumber = objOriginalFile.VersionNumber + 1;
            //objOriginalFile.AttachmentName = fileUpload.FileName;

            //create file version and copy attributes from current version
            DNNQuickApps.Modules.QuickDocsPro.File objFile = new DNNQuickApps.Modules.QuickDocsPro.File();
            if ((string)Settings["IsSearchable"] != null)
            {
                if (!Convert.ToBoolean(Settings["IsSearchable"].ToString()))
                {
                    objFile.ModuleID = ModuleId;
                }
            }
            objFile.PortalID = PortalId;
            objFile.Name = strName;
            objFile.CreatedByUserID = objOriginalFile.LastModifiedByUserID;
            objFile.CreatedDate = objOriginalFile.LastModifiedDate;
            objFile.CreatedByUserName = objOriginalFile.LastModifiedByUserName;
            objFile.LastModifiedDate = objOriginalFile.LastModifiedDate;
            objFile.LastModifiedByUserID = objOriginalFile.LastModifiedByUserID;
            objFile.LastModifiedByUserName = objOriginalFile.LastModifiedByUserName;
            objFile.VersionsToKeep = -1;
            objFile.VersionNumber = objOriginalFile.VersionNumber;
            objFile.ItemType = objOriginalFile.ItemType;
            objFile.HomeFolderUserID = objOriginalFile.HomeFolderUserID;
            objFile.RoleID = objOriginalFile.RoleID;

            //Set parent to root/current file
            objFile.ParentID = _FileID;

            objQuickFiles.Update(objOriginalFile);
            objQuickFiles.Create(objFile);

            //upload file version
            FileConfigurationController configCtrl = new FileConfigurationController();
            List<FileConfiguration> configs = configCtrl.GetItems(PortalId) as List<FileConfiguration>;

            if (configs[0].StorageType == "UNC")
            {
                objFile.CreatePath(configs[0].FilesLocation);
                string strPath = configs[0].FilesLocation + objFile.GetFullPath();
                e.Image.Image.Save(strPath);
                //fileUpload.SaveAs(configs[0].FilesLocation + objFile.GetFullPath());
                imageLength = new System.IO.FileInfo(strPath).Length;
            }
            else
            {
                objFile.CreatePath(Server.MapPath(configs[0].FilesLocation));
                string strPath = configs[0].FilesLocation + objFile.GetFullPath();
                e.Image.Image.Save(Server.MapPath(strPath));
                //fileUpload.SaveAs(Server.MapPath(configs[0].FilesLocation) + objFile.GetFullPath());
                imageLength = new System.IO.FileInfo(Server.MapPath(strPath)).Length;

            }

            List<string> fileNameAndExtension = objFile.GetFileNameAndExtension(objOriginalFile.Name);//fileUpload.FileName);

            objFile.AttachmentPath = objFile.GetFullPath();
            objFile.FileType = strFormat; // fileUpload.PostedFile.ContentType;
            objFile.FileLength = (int)imageLength; //fileUpload.PostedFile.ContentLength;
            objFile.Name = strName;//fileNameAndExtension[0];
            objFile.Extension = objOriginalFile.Extension;// fileNameAndExtension[1];
            objFile.AttachmentName = String.Format("{0}.{1}", objFile.Name, objFile.Extension); //.AttachmentName; // fileUpload.FileName;

            objOriginalFile.AttachmentPath = objFile.GetFullPath();
            objOriginalFile.FileType = strFormat; //fileUpload.PostedFile.ContentType;
            objOriginalFile.FileLength = (int)imageLength;//fileUpload.PostedFile.ContentLength;

            //Don't change file name or extension when uploading new image version, only version gets new file name
            //objOriginalFile.Name = fileNameAndExtension[0];
            //objOriginalFile.Extension = fileNameAndExtension[1];

            objQuickFiles.Update(objOriginalFile);
            objQuickFiles.Update(objFile);

            //this.Response.RedirectLocation = Globals.NavigateURL(this.TabId, "", "Folder=" + _ParentID.ToString(), "ModuleID=" + ModuleId, "View=" + _view, "UserID=" + _userIDParameter, "GroupID=" + _roleIDParameter);

            DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, "New version saved successfully.", DotNetNuke.UI.Skins.Controls.ModuleMessage.ModuleMessageType.GreenSuccess);

            e.Cancel = true;
        }
        protected void lbnOK_Click(object sender, EventArgs e)
        {
            try
            {
                //check file exists
                if (asyncFileUpload.UploadedFiles.Count == 0)
                {
                    DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, "Please select a valid file to upload", DotNetNuke.UI.Skins.Controls.ModuleMessage.ModuleMessageType.RedError);
                    return;
                }

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

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

                //get current/root file
                DNNQuickApps.Modules.QuickDocsPro.FileController objQuickFiles = new DNNQuickApps.Modules.QuickDocsPro.FileController();
                File objOriginalFile = objQuickFiles.Get(FileID);
                objOriginalFile.LastModifiedDate = System.DateTime.Now;
                objOriginalFile.LastModifiedByUserID = UserId;

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

                //increment version number
                objOriginalFile.VersionNumber = objOriginalFile.VersionNumber + 1;
                objOriginalFile.AttachmentName = asyncFileUpload.UploadedFiles[0].FileName;// fileUpload.FileName;

                //create file version and copy attributes from current version
                DNNQuickApps.Modules.QuickDocsPro.File objFile = new DNNQuickApps.Modules.QuickDocsPro.File();
                //if (!Convert.ToBoolean(Settings["IsSearchable"].ToString()))
                //{
                //    objFile.ModuleID = ModuleId;
                //}
                objFile.PortalID = PortalId;
                objFile.Name = objOriginalFile.Name;
                objFile.CreatedByUserID = objOriginalFile.LastModifiedByUserID;
                objFile.CreatedDate = objOriginalFile.LastModifiedDate;
                objFile.CreatedByUserName = objOriginalFile.LastModifiedByUserName;
                objFile.LastModifiedDate = objOriginalFile.LastModifiedDate;
                objFile.LastModifiedByUserID = objOriginalFile.LastModifiedByUserID;
                objFile.LastModifiedByUserName = objOriginalFile.LastModifiedByUserName;
                objFile.VersionsToKeep = -1;
                objFile.VersionNumber = objOriginalFile.VersionNumber;
                objFile.ItemType = objOriginalFile.ItemType;
                objFile.HomeFolderUserID = objOriginalFile.HomeFolderUserID;
                objFile.RoleID = objOriginalFile.RoleID;

                //Set parent to root/current file
                objFile.ParentID = FileID;

                objQuickFiles.Update(objOriginalFile);
                objQuickFiles.Create(objFile);

                //upload file version
                FileConfigurationController configCtrl = new FileConfigurationController();
                List<FileConfiguration> configs = configCtrl.GetItems(PortalId) as List<FileConfiguration>;

                if (configs[0].StorageType == "UNC")
                {
                    objFile.CreatePath(configs[0].FilesLocation);
                    //fileUpload.SaveAs(configs[0].FilesLocation + objFile.GetFullPath());
                    asyncFileUpload.UploadedFiles[0].SaveAs(configs[0].FilesLocation + objFile.GetFullPath());
                }
                else
                {
                    objFile.CreatePath(Server.MapPath(configs[0].FilesLocation));
                    //fileUpload.SaveAs(Server.MapPath(configs[0].FilesLocation) + objFile.GetFullPath());
                    asyncFileUpload.UploadedFiles[0].SaveAs(Server.MapPath(configs[0].FilesLocation) + objFile.GetFullPath());
                }

                //List<string> fileNameAndExtension = objFile.GetFileNameAndExtension(fileUpload.FileName);
                List<string> fileNameAndExtension = objFile.GetFileNameAndExtension(asyncFileUpload.UploadedFiles[0].FileName);

                objFile.AttachmentName = asyncFileUpload.UploadedFiles[0].FileName;// fileUpload.FileName;
                objFile.AttachmentPath = objFile.GetFullPath();
                objFile.FileType = asyncFileUpload.UploadedFiles[0].ContentType;// fileUpload.PostedFile.ContentType;
                objFile.FileLength = (int)asyncFileUpload.UploadedFiles[0].ContentLength;// fileUpload.PostedFile.ContentLength;
                objFile.Name = fileNameAndExtension[0];
                objFile.Extension = fileNameAndExtension[1];

                objOriginalFile.AttachmentPath = objFile.GetFullPath();
                objOriginalFile.FileType = asyncFileUpload.UploadedFiles[0].ContentType; //fileUpload.PostedFile.ContentType;
                objOriginalFile.FileLength = (int)asyncFileUpload.UploadedFiles[0].ContentLength; //fileUpload.PostedFile.ContentLength;
                //Don't change file name when uploading new version, only version gets new file name
                //objOriginalFile.Name = fileNameAndExtension[0];
                objOriginalFile.Extension = fileNameAndExtension[1];

                objQuickFiles.Update(objOriginalFile);
                objQuickFiles.Update(objFile);

                #region "Audit"
                //Audit: New Version Item
                AuditController ctrlAudit = new AuditController();
                Audit versionAudit = new Audit() { EventDate = objOriginalFile.LastModifiedDate, EventDetails = "File name: " + objFile.Name, EventName = "Added Version", FileID = objOriginalFile.ID, UserID = UserId };
                ctrlAudit.Create(versionAudit);
                #endregion

                //refresh cac
                SynchronizeModule();

                //Redirect back to the portal home page
                this.Response.Redirect(Globals.NavigateURL(this.TabId, "", "Folder=" + ParentID, "ModuleID=" + ModuleId.ToString(), "UserID=" + _userIDParameter, "GroupID=" + _roleIDParameter, "Success=New version uploaded for file: " + objOriginalFile.Name), true);
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Пример #3
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);
            }
        }
Пример #4
0
        protected void permissionCheck_Changed(object sender, EventArgs e)
        {
            ItemID = Int32.Parse(this.Request.QueryString["ID"]);

            DNNQuickApps.Modules.QuickDocsPro.FileController objQuickFiles = new DNNQuickApps.Modules.QuickDocsPro.FileController();
            DNNQuickApps.Modules.QuickDocsPro.File objFile = objQuickFiles.Get(ItemID);

            aryPermissions = Session["aryPermissions"] as ArrayList;

            foreach (GridViewRow row in gridPermissions.Rows)
            {
                int i = row.DataItemIndex;

                CheckBox chkCanSee = (CheckBox)row.FindControl("chkCanSee");
                CheckBox chkCanModify = (CheckBox)row.FindControl("chkCanModify");
                CheckBox chkCanDelete = (CheckBox)row.FindControl("chkCanDelete");
                CheckBox chkCanModifyPermission = (CheckBox)row.FindControl("chkCanModifyPermission");
                CheckBox chkCanAddItems = (CheckBox)row.FindControl("chkCanAddItems");
                CheckBox chkCanAddFolders = (CheckBox)row.FindControl("chkCanAddFolders");

                //check for unchecks first
                if (chkCanSee.Checked == false && ((Permission)aryPermissions[i]).CanSee)
                {
                    chkCanModify.Checked = false;
                    chkCanDelete.Checked = false;
                    chkCanModifyPermission.Checked = false;
                    chkCanAddFolders.Checked = false;
                    chkCanAddItems.Checked = false;
                }
                else if (ItemType == 0 && chkCanAddItems.Checked == false && ((Permission)aryPermissions[i]).CanAddFiles)
                {
                    chkCanModify.Checked = false;
                    chkCanDelete.Checked = false;
                    chkCanModifyPermission.Checked = false;
                    chkCanAddFolders.Checked = false;
                }
                else if (ItemType == 0 && chkCanAddFolders.Checked == false && ((Permission)aryPermissions[i]).CanAddFolders)
                {
                    chkCanModify.Checked = false;
                    chkCanDelete.Checked = false;
                    chkCanModifyPermission.Checked = false;
                }
                else if (chkCanModify.Checked == false && ((Permission)aryPermissions[i]).CanModify)
                {
                    chkCanDelete.Checked = false;
                    chkCanModifyPermission.Checked = false;
                }
                else if (chkCanDelete.Checked == false && ((Permission)aryPermissions[i]).CanDelete)
                {
                    chkCanModifyPermission.Checked = false;
                }

                //check new checks
                else if (chkCanModifyPermission.Checked)
                {
                    chkCanSee.Checked = true;
                    chkCanModify.Checked = true;
                    chkCanDelete.Checked = true;
                    chkCanAddFolders.Checked = true;
                    chkCanAddItems.Checked = true;
                }
                else if (chkCanDelete.Checked)
                {
                    chkCanSee.Checked = true;
                    chkCanModify.Checked = true;
                    chkCanAddFolders.Checked = true;
                    chkCanAddItems.Checked = true;
                }
                else if (chkCanModify.Checked)
                {
                    chkCanSee.Checked = true;
                    chkCanAddFolders.Checked = true;
                    chkCanAddItems.Checked = true;
                }
                else if (ItemType == 0 && chkCanAddFolders.Checked)
                {
                    chkCanSee.Checked = true;
                    chkCanAddItems.Checked = true;
                }
                else if (ItemType == 0 && chkCanAddItems.Checked)
                {
                    chkCanSee.Checked = true;
                }

                ((Permission)aryPermissions[row.DataItemIndex]).CanSee = chkCanSee.Checked;
                ((Permission)aryPermissions[row.DataItemIndex]).CanModify = chkCanModify.Checked;
                ((Permission)aryPermissions[row.DataItemIndex]).CanDelete = chkCanDelete.Checked;
                ((Permission)aryPermissions[row.DataItemIndex]).CanModifyPermission = chkCanModifyPermission.Checked;
                ((Permission)aryPermissions[row.DataItemIndex]).CanAddFiles = chkCanAddItems.Checked;
                ((Permission)aryPermissions[row.DataItemIndex]).CanAddFolders = chkCanAddFolders.Checked;
            }

            Session["aryPermission"] = aryPermissions;

            gridPermissions.DataSource = aryPermissions;
            gridPermissions.DataBind();
        }
Пример #5
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);
            }
        }