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); } }
/// ----------------------------------------------------------------------------- /// <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 { //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"]); } if ((string)Settings["ModuleRootFolderID"] != null) { _moduleRootFolderID = (string)Settings["ModuleRootFolderID"]; } //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"]); } //help message DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, "Select the location to move the item. <br/>Folders can not be moved under themselves in the hierarchy and are hidden.", DotNetNuke.UI.Skins.Controls.ModuleMessage.ModuleMessageType.BlueInfo); FileController fileCtrl = new FileController(); File targetFile = fileCtrl.Get(_FileID); if (!Page.IsPostBack) { if (UserInfo.IsInRole(PortalSettings.AdministratorRoleName)) { PopulateTree("-1", _ParentID, targetFile); } else { PopulateTree(_moduleRootFolderID, _ParentID, targetFile); } } } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }
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); }
/// ----------------------------------------------------------------------------- /// <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 { //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"]); } //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 ((string)Settings["ModuleRootFolderID"] != null) //{ // _moduleRootFolderID = (string)Settings["ModuleRootFolderID"]; //} //help message //DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, "Select the location to move the item. <br/>Folders can not be moved under themselves in the hierarchy and are hidden.", DotNetNuke.UI.Skins.Controls.ModuleMessage.ModuleMessageType.BlueInfo); FileController fileCtrl = new FileController(); File sourceFile = fileCtrl.Get(_FileID); if (!Page.IsPostBack) { FileController ctrlFile = new FileController(); var imageFile = ctrlFile.Get(_FileID, _ParentID); if (!imageFile.CanSee(UserId, PortalId, PortalSettings.AdministratorRoleId, false)) { Response.Redirect(Globals.NavigateURL()); return; } string imageURL = Globals.NavigateURL(TabId, "", "Folder=" + _ParentID.ToString(), "Open=" + _FileID.ToString(), "UserId=" + _userIDParameter); radImageEditor.ImageUrl = imageURL; radImageEditor.CanvasMode = Telerik.Web.UI.ImageEditor.CanvasMode.Yes; } } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }
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; }
private void OpenFile(int fileID, int versionNumber, string strMode) { FileController ctrl = new FileController(); File file; File requestedFile = ctrl.Get(fileID); if (versionNumber == -1) { if (requestedFile.ItemType == 1) //file, don't need version of link { file = ctrl.GetCurrentVersion(fileID); } else { file = requestedFile; //set open to requested file } } else { file = ctrl.GetVersion(fileID, versionNumber); } FileConfigurationController configCtrl = new FileConfigurationController(); List<FileConfiguration> configs = configCtrl.GetItems(PortalId) as List<FileConfiguration>; if (file != null) { if (requestedFile.CanSee(UserId, PortalId, PortalSettings.AdministratorRoleId, true)) { if (file.ItemType == 2) //hyperlink { #region "Audit" //Audit: Create Item AuditController ctrlAudit = new AuditController(); Audit viewAudit = new Audit() { EventDate = System.DateTime.Now, EventDetails = "", EventName = "Opened Link", FileID = requestedFile.ID, UserID = UserId }; ctrlAudit.Create(viewAudit); #endregion Response.Redirect(file.LinkURL); } if (file.ItemType == 1) //file { #region "Audit" //Audit: Create Item AuditController ctrlAudit = new AuditController(); Audit viewAudit; if (versionNumber == -1) { viewAudit = new Audit() { EventDate = System.DateTime.Now, EventDetails = "", EventName = "Downloaded", FileID = requestedFile.ID, UserID = UserId }; } else { viewAudit = new Audit() { EventDate = System.DateTime.Now, EventDetails = "Version: " + file.VersionNumber, EventName = "Downloaded Version", FileID = requestedFile.ID, UserID = UserId }; } ctrlAudit.Create(viewAudit); #endregion bool canOpenFileType = false; switch (file.FileType.ToLower()) { case "text/plain": canOpenFileType = true; break; case "text/html": canOpenFileType = true; break; case "text/xml": canOpenFileType = true; break; case "image/gif": canOpenFileType = true; break; case "image/jpeg": canOpenFileType = true; break; case "image/tiff": canOpenFileType = true; break; case "image/bmp": canOpenFileType = true; break; case "image/png": canOpenFileType = true; break; } if (strMode == "Open" && canOpenFileType == true) { Response.Clear(); Response.ClearHeaders(); Response.ClearContent(); Response.ContentType = file.FileType; Response.AddHeader("Content-Length", file.FileLength.ToString()); //Response.Flush(); //Response.AppendHeader("content-disposition", String.Format("inline; filename={0}.{1}", requestedFile.Name, file.Extension)); //Set the appropriate ContentType. //Response.ContentType = file.FileType; //Get the physical path to the file. string FilePath = MapPath(configs[0].FilesLocation + file.AttachmentPath); //Write the file directly to the HTTP content output stream. Response.WriteFile(FilePath); } else { Response.Clear(); //Response.ClearHeaders(); //Response.ClearContent(); Response.ContentType = file.FileType; Response.AddHeader("Content-Length", file.FileLength.ToString()); //Response.Flush(); Response.AddHeader("Content-Disposition", String.Format("attachment; filename={0}.{1}", requestedFile.Name, file.Extension)); Response.Flush(); Response.TransmitFile(configs[0].FilesLocation + file.AttachmentPath); } //Response.Flush(); Response.End(); } } else { //Response.Redirect(Globals.NavigateURL("TabId", "", "WarningMessage=You do not have permission to the requested object.")); ShowUserErrorMessage("You do not have permission to the requested object.", ModuleId); } } else { //Response.Redirect(Globals.NavigateURL("TabId", "", "WarningMessage=The requested object does not exist.")); ShowUserErrorMessage("The requested object does not exist.", ModuleId); } }
/// ----------------------------------------------------------------------------- /// <summary> /// Page_Load runs when the control is loaded /// </summary> /// ----------------------------------------------------------------------------- protected void Page_Load(object sender, System.EventArgs e) { try { #region Check Registration and Trial Period string strProductName = "QuickDocs Pro"; //check registration try { switch (DNNQuickApps.Modules.RegistrationClient.API.IsRegistered(PortalAlias.HTTPAlias, strProductName, "QD_MODULESGALORE")) { case RegistrationClientAPIResult.Registered: break; case RegistrationClientAPIResult.Localhost: ModuleController ctrl1 = new ModuleController(); ModuleInfo info1 = ctrl1.GetModule(ModuleId); ShowMessage("<a href=\"http://www.dnnquickapps.com\">DNNQuickApps.com</a> QuickDocsPro - Using Developer License", ModuleId); break; case RegistrationClientAPIResult.NotRegistered: string strMessage; ModuleController ctrl = new ModuleController(); ModuleInfo info = ctrl.GetModule(ModuleId); if (info.CreatedOnDate < System.DateTime.Now.AddDays(-30)) { strMessage = String.Format("The trial period has expired for Product: <b>{1}</b> on Site Alias: <b>{0}</b> and the module is not registered. Visit <a href=\"http://www.DNNQuickApps.com\">DNNQuickApps.com</a> to purchase a license and register.", PortalAlias.HTTPAlias, strProductName); ShowUserErrorMessage(strMessage, ModuleId); HideAllFileControls(); return; } else { DateTime expirationDate = info.CreatedOnDate.AddDays(30); int daysRemaining = (expirationDate.DayOfYear + (expirationDate.Year * 365)) - (System.DateTime.Now.DayOfYear + (System.DateTime.Now.Year * 365)); strMessage = String.Format("{0} days remaining in trial for Product: <b>{2}</b> on Site Alias: <b>{1}</b>. Visit <a href=\"http://www.dnnquickapps.com\">DNNQuickApps.com</a> to purchase a license and register.", daysRemaining, PortalAlias.HTTPAlias, strProductName); ShowMessage(strMessage, ModuleId); } break; } } catch (Exception ex) { ShowUserErrorMessage("Problem loading registration codes from DNNQuickApps.com QuickRegistration Client.", ModuleId); HideAllFileControls(); return; } #endregion #region Verify module configuration and get module settings //check if files is configured FileConfigurationController configCtrl = new FileConfigurationController(); List<FileConfiguration> configs = configCtrl.GetItems(PortalId) as List<FileConfiguration>; if (configs.Count == 0) { ShowMessage(String.Format("The Files module has not been configured for this portal. Go to the <a href=\"{0}\">Portal Settings</a> to complete setup.", EditUrl("PortalSettings")), ModuleId); HideAllFileControls(); return; } //files mode if (Settings["FilesMode"] != null) { _strFilesMode = Settings["FilesMode"].ToString(); } else { ShowMessage(String.Format("This Files module has not been setup. Go to the <a href=\"{0}\">Module Settings</a> to complete setup.", EditUrl(TabId, "Module", false, "moduleId=" + ModuleId)), ModuleId); HideAllFileControls(); return; } //get module root folder ID _moduleRootFolderID = GetModuleRootFolderID(_strFilesMode); #endregion #region Get query string parameters //Determine ItemId of CustomerSelfService to Update if (this.Request.QueryString["Folder"] != null) //if none, then _parent = -1 { _parentID = Int32.Parse(this.Request.QueryString["Folder"]); } //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"]); } //check for trash view if (this.Request.QueryString["View"] != null) { _view = this.Request.QueryString["View"]; } //sort field if (this.Request.QueryString["Sort"] != null) { _sortType = this.Request.QueryString["sort"]; } //ModuleID param bool boolModuleIDMatched = false; //used to determine if query strings apply to this instance if (this.Request.QueryString["ModuleID"] != null) { _moduleID = Int32.Parse(this.Request.QueryString["ModuleID"]); if (_moduleID == ModuleId) { boolModuleIDMatched = true; } } else { _moduleID = ModuleId; boolModuleIDMatched = true; } //look for success message if (this.Request.QueryString["Success"] != null && boolModuleIDMatched == true) { _messageSuccess = this.Request.QueryString["Success"]; ShowUserSuccessMessage(_messageSuccess, ModuleId); } #endregion FileController objQuickFiles = new FileController(); #region Resolve the current parent ID //get parent folder //after this, _parentID has the correct folder if (_parentID != -1) //folder parameter found { objQuickFiles = new FileController(); //Verify permission to object File parentFolder = objQuickFiles.Get(_parentID); if (parentFolder == null)//folder does not exist { ShowUserErrorMessage("The requested object does not exist.", ModuleId); HideAllFileControls(); return; } //current user can't see the folder if (!parentFolder.CanSee(UserId, PortalId, PortalSettings.AdministratorRoleId, true)) { ShowUserErrorMessage("You do not have sufficient permission to view this object.", ModuleId); HideAllFileControls(); return; } //todo: verify parentID/folder exists under module folder or file ID when passed as a parameter } else //set to module root folder { _parentID = _moduleRootFolderID; } //show root folder if specifc module folder is selected and this module is not //specified moduleid, //supports multiple file modules on one page if (_moduleID != Null.NullInteger && !boolModuleIDMatched) { _parentID = _moduleRootFolderID; } #endregion #region Get Root Folder and Files Collection //declare files collection List<File> colQuickFiles; //check for alternate view and build files collection if (_view == "trash") { if (UserInfo.IsInRole(PortalSettings.AdministratorRoleName)) { colQuickFiles = objQuickFiles.GetItemsInTrash(UserId, PortalId, PortalSettings.AdministratorRoleId) as List<File>; _colQuickFiles = colQuickFiles; } else { ShowUserErrorMessage("You do not have sufficient permission to view this object.", ModuleId); HideAllFileControls(); return; } } else { //if parentid still -1, return null and hide controls if (_parentID != -1) { switch (_strFilesMode) { case "UserFiles": colQuickFiles = objQuickFiles.GetUserItemsByParent(_parentID, UserId, PortalId, PortalSettings.AdministratorRoleId, _sortType, _userIDParameter) as List<File>; break; case "GroupFiles": colQuickFiles = objQuickFiles.GetGroupItemsByParent(_parentID, UserId, PortalId, PortalSettings.AdministratorRoleId, _sortType, _roleIDParameter) as List<File>; break; default: colQuickFiles = objQuickFiles.GetItemsByParent(_parentID, UserId, PortalId, PortalSettings.AdministratorRoleId, _sortType) as List<File>; break; } _colQuickFiles = colQuickFiles; } else { HideAllFileControls(); ShowMessage(String.Format("This Files module is not configured correctly. Go to the <a href=\"{0}\">Module Settings</a> to fix setup.", EditUrl(TabId, "Module", false, "moduleId=" + ModuleId)), ModuleId); return; } } #endregion radLVFiles.DataSource = colQuickFiles; if (!Page.IsPostBack) { #region Set Theme //get theme string skinName = "Default"; if (Settings["Theme"] != null) { //skinManager.Skin = (String)Settings["Theme"]; skinName = (String)Settings["Theme"]; } radMenuBreadCrumbs.Skin = skinName; radLVFiles.Skin = skinName; radMenuNewItems.Skin = skinName; radExplorerSplitter.Skin = skinName; #endregion // bind the content to the repeater radLVFiles.DataBind(); #region Check for query string message and display if module id matches //check for message if (boolModuleIDMatched) { if (Session["SuccessMessage"] != null) { ShowUserSuccessMessage(Session["SuccessMessage"].ToString(), ModuleId); Session["SuccessMessage"] = null; } if (Session["WarningMessage"] != null) { ShowUserErrorMessage(Session["WarningMessage"].ToString(), ModuleId); Session["WarningMessage"] = null; } } #endregion #region Add Delete Confirmation to Delete button //delete confirmation if (_view == "trash") { //lbnDelete.Attributes.Add("onClick", "javascript:return confirm('Are you sure you want to permanently delete the selected item(s)?');"); lnkViewTrashOrFiles.Text = "View Files"; lnkViewTrashOrFiles.NavigateUrl = Globals.NavigateURL(TabId, "", "View=default", "UserId=" + _userIDParameter); imgTrashOrFiles.ImageUrl = "images/folder_16_hot.png"; } else { //lbnDelete.Attributes.Add("onClick", "javascript:return confirm('Are you sure you wish to delete the selected item(s)?');"); lnkViewTrashOrFiles.Text = "View Trash"; lnkViewTrashOrFiles.NavigateUrl = Globals.NavigateURL(TabId, "", "View=trash", "UserId=" + _userIDParameter); imgTrashOrFiles.ImageUrl = "images/trash_16_hot.png"; } #endregion #region Set New Action URLs switch (_strFilesMode) { case "UserFiles": SetNewFileURL(EditUrl("Type", "1", "New", "Parent=" + _parentID.ToString(), "UserID=" + _userIDParameter)); SetNewFolderURL(EditUrl("Type", "0", "New", "Parent=" + _parentID.ToString(), "UserID=" + _userIDParameter)); SetNewHyperlinkURL(EditUrl("Type", "2", "New", "Parent=" + _parentID.ToString(), "UserID=" + _userIDParameter)); break; case "GroupFiles": SetNewFileURL(EditUrl("Type", "1", "New", "Parent=" + _parentID.ToString(), "GroupID=" + _roleIDParameter)); SetNewFolderURL(EditUrl("Type", "0", "New", "Parent=" + _parentID.ToString(), "GroupID=" + _roleIDParameter)); SetNewHyperlinkURL(EditUrl("Type", "2", "New", "Parent=" + _parentID.ToString(), "GroupID=" + _roleIDParameter)); break; case "SharedFiles": SetNewFileURL(EditUrl("Type", "1", "New", "Parent=" + _parentID.ToString())); SetNewFolderURL(EditUrl("Type", "0", "New", "Parent=" + _parentID.ToString())); SetNewHyperlinkURL(EditUrl("Type", "2", "New", "Parent=" + _parentID.ToString())); break; } #endregion File currentFolder = objQuickFiles.Get(_parentID); ApplyPermissions(currentFolder, _view); //onlyl add breadcrumbs and folder detail if view is not trash if (_view == "trash") { return; } #region create breadcrumbs drop-down List<File> reorderedBreadcrumbs = new List<File>(); //get module root folder and current folder File topFolder = objQuickFiles.Get(_moduleRootFolderID); List<File> breadcrumbs = objQuickFiles.GetParentBreadcrumbs(_parentID, UserId, PortalId, PortalSettings.AdministratorRoleId, _moduleRootFolderID); int countBreadCrumbs = breadcrumbs.Count; int s = 0; for (int i = countBreadCrumbs - 1; i >= 0; i--) { reorderedBreadcrumbs.Add(breadcrumbs[i]); s++; } if (reorderedBreadcrumbs.Count > 1) { //Add up button RadMenuItem menuUp = new RadMenuItem(); menuUp.ImageUrl = "images/folder_up_16_hot.png"; menuUp.Value = reorderedBreadcrumbs[reorderedBreadcrumbs.Count - 2].ID.ToString(); menuUp.Text = ".."; //menuUp.Text = reorderedBreadcrumbs[reorderedBreadcrumbs.Count - 2].Name + " ›"; //› ► menuUp.ToolTip = "Go to the parent folder: " + reorderedBreadcrumbs[reorderedBreadcrumbs.Count - 2].Name; switch (_strFilesMode) { case "UserFiles": menuUp.NavigateUrl = Globals.NavigateURL(TabId, "", "Folder=" + menuUp.Value, "ModuleID=" + ModuleId.ToString(), "UserID=" + _userIDParameter); break; case "GroupFiles": menuUp.NavigateUrl = Globals.NavigateURL(TabId, "", "Folder=" + menuUp.Value, "ModuleID=" + ModuleId.ToString(), "GroupID=" + _roleIDParameter); break; default: menuUp.NavigateUrl = Globals.NavigateURL(TabId, "", "Folder=" + menuUp.Value, "ModuleID=" + ModuleId.ToString()); break; } //menuUp.PopOutImageUrl = "~/images/arrow-right.png"; if (menuUp.Text.Length > 30) { menuUp.Text = menuUp.Text.Substring(0, 29) + "..."; } radMenuBreadCrumbs.Items.Add(menuUp); } //Menu version RadMenuItem topLevel = new RadMenuItem(reorderedBreadcrumbs[reorderedBreadcrumbs.Count - 1].Name); topLevel.ImageUrl = "images/folder_16_hot.png"; topLevel.Value = "topLevel"; if (topLevel.Text.Length > 30) { topLevel.Text = topLevel.Text.Substring(0, 29) + "..."; } radMenuBreadCrumbs.Items.Add(topLevel); if (reorderedBreadcrumbs.Count > 1) { int intLevel = 1; foreach (File breadcrumb in reorderedBreadcrumbs) { RadMenuItem nextItem = new RadMenuItem(); nextItem.Text = breadcrumb.Name; nextItem.Value = breadcrumb.ID.ToString(); nextItem.ImageUrl = String.Format("images/breadcrumb{0}.gif", intLevel); switch (_strFilesMode) { case "UserFiles": nextItem.NavigateUrl = Globals.NavigateURL(TabId, "", "Folder=" + nextItem.Value, "ModuleID=" + ModuleId.ToString(), "UserID=" + _userIDParameter); break; case "GroupFiles": nextItem.NavigateUrl = Globals.NavigateURL(TabId, "", "Folder=" + nextItem.Value, "ModuleID=" + ModuleId.ToString(), "GroupID=" + _roleIDParameter); break; default: nextItem.NavigateUrl = Globals.NavigateURL(TabId, "", "Folder=" + nextItem.Value, "ModuleID=" + ModuleId.ToString()); break; } topLevel.Items.Add(nextItem); intLevel++; } //select last child item topLevel.Items[topLevel.Items.Count - 1].Selected = true; } else { topLevel.Enabled = false; } #endregion //ADD folder properties if not root folder if (_parentID != _moduleRootFolderID) { RadMenuItem folderProperties = new RadMenuItem(); folderProperties.ImageUrl = "images/info_16_hot.png"; switch (_strFilesMode) { case "UserFiles": folderProperties.NavigateUrl = EditUrl("ID", _parentID.ToString(), "Details", "Parent=" + _parentID.ToString(), "UserID=" + _userIDParameter); break; case "GroupFiles": folderProperties.NavigateUrl = EditUrl("ID", _parentID.ToString(), "Details", "Parent=" + _parentID.ToString(), "GroupID=" + _roleIDParameter); break; default: folderProperties.NavigateUrl = EditUrl("ID", _parentID.ToString(), "Details", "Parent=" + _parentID.ToString()); break; } folderProperties.ToolTip = "View folder details"; folderProperties.Text = ""; radMenuBreadCrumbs.Items.Add(folderProperties); //lnkFolderSettings.NavigateUrl = EditUrl("ID", _parentID.ToString(), "Details", "Parent=" + _parentID.ToString()); } #region Open File Action //check for file open action if (this.Request.QueryString["Open"] != null) { _openID = Int32.Parse(this.Request.QueryString["Open"]); if (this.Request.QueryString["Version"] != null) { OpenFile(_openID, Int32.Parse(this.Request.QueryString["Version"]), "Open"); } else { OpenFile(_openID, -1, "Open"); } } if (this.Request.QueryString["Download"] != null) { _openID = Int32.Parse(this.Request.QueryString["Download"]); if (this.Request.QueryString["Version"] != null) { OpenFile(_openID, Int32.Parse(this.Request.QueryString["Version"]), "Download"); } else { OpenFile(_openID, -1, "Download"); } } #endregion } } catch (Exception exc) { //Module failed to load Exceptions.ProcessModuleLoadException(this, exc); } }
protected void lbnDelete_Click(object sender, EventArgs e) { if (this.Request.QueryString["File"] != null) { _FileID = Int32.Parse(this.Request.QueryString["File"]); } FileConfigurationController ctrlConfig = new FileConfigurationController(); var configs = ctrlConfig.GetItems(PortalId) as List<FileConfiguration>; if (_FileID == configs[0].RootSharedFolderID || _FileID == configs[0].RootGroupsFolderID || _FileID == configs[0].RootUsersFolderID) { DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, "Error: Can not delete a protected folder", DotNetNuke.UI.Skins.Controls.ModuleMessage.ModuleMessageType.RedError); lbnDelete.Visible = false; lbnOK.Visible = false; lbnCancel.Visible = true; return; } FileController fileCtrl = new FileController(); File file = fileCtrl.Get(_FileID); _filesToDelete = new List<File>(); DeleteChildren(file); foreach (File toDelete in _filesToDelete) { fileCtrl.Delete(toDelete); } string strMessage; if (_permanentlyDeletedFilesCount > 0) { strMessage = String.Format("Permanently deleted {0} item(s).", _permanentlyDeletedFilesCount); } else { strMessage = String.Format("Successfully deleted {0} item(s) and skipped {1} item(s).", _deletedFilesCount, _notDeletedFilesCount); } DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, strMessage, DotNetNuke.UI.Skins.Controls.ModuleMessage.ModuleMessageType.GreenSuccess); lbnDelete.Visible = false; lbnOK.Visible = true; lbnCancel.Visible = false; }
/// ----------------------------------------------------------------------------- /// <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 { //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"]); } //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 (!Page.IsPostBack) { //get item FileController fileCtrl = new FileController(); File targetFile = fileCtrl.Get(_FileID); //check if user has delete permission if (!targetFile.CanDelete(UserId, PortalId, PortalSettings.AdministratorRoleId, true)) { this.Response.Redirect(Globals.NavigateURL(this.TabId, "", "Folder=" + _ParentID, "ModuleID=" + ModuleId, "Error=You do not have sufficient permissions to delete this item."), true); } //build delete message string strDeleteMessage = "Are you sure? Click the Delete button to remove the '" + targetFile.Name; if (targetFile.ItemType == 0) //is folder { strDeleteMessage = strDeleteMessage + "' folder and all child items?"; } else if (targetFile.ItemType == 1) //file { strDeleteMessage = strDeleteMessage + "' file?"; } else if (targetFile.ItemType == 2) //link { strDeleteMessage = strDeleteMessage + "' hyperlink?"; } //help message DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, strDeleteMessage, DotNetNuke.UI.Skins.Controls.ModuleMessage.ModuleMessageType.YellowWarning); } } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }
/// ----------------------------------------------------------------------------- /// <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 { //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"]); } //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 (FileID == Null.NullInteger) { Response.Redirect(Globals.NavigateURL()); } //get file name FileController objFiles = new FileController(); File objFile = objFiles.Get(FileID); lblName.Text = objFile.Name; //async uploader string strAllowedFiles = DotNetNuke.Entities.Controllers.HostController.Instance.GetString("FileExtensions"); string[] strSearchPatterns = strAllowedFiles.Split(','); asyncFileUpload.AllowedFileExtensions = strSearchPatterns; asyncFileUpload.EnableInlineProgress = true; asyncFileUpload.MaxFileInputsCount = 1; //TODO check if user has permission to add versions } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }
protected void lbnDeleteVersions_Click(object sender, EventArgs e) { FileController fileCtrl = new FileController(); foreach (GridViewRow row in gridVersions.Rows) { CheckBox chkSelect = (CheckBox)row.FindControl("chkSelect"); if (chkSelect.Checked == false) continue; File file = fileCtrl.Get(Int32.Parse(row.Cells[0].Text)); if (file != null) { //check if at least one version exists FileController ctrl = new FileController(); List<File> parentFileVersions = ctrl.GetVersions(file.ParentID, UserId, PortalId, PortalSettings.AdministratorRoleId, ""); if (parentFileVersions.Count > 1) { //2 or more versions exist, delete version FileConfigurationController configCtrl = new FileConfigurationController(); List<FileConfiguration> configs = configCtrl.GetItems(PortalId) as List<FileConfiguration>; fileCtrl.DeleteVersion(file, configs[0].FilesLocation); } else { //1 or fewer versions exist, do not delete and show error message ShowUserErrorMessage("Can't delete last version. At least one version of the file must exist."); } } } BindVersions(fileCtrl.Get(Int32.Parse(this.Request.QueryString["ID"]))); }
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); } }