/// <summary> /// cmdDelete_Click runs when the delete button is clicked /// </summary> /// <history> /// [cnurse] 9/22/2004 Updated to reflect design changes for Help, 508 support /// and localisation /// </history> protected void cmdDelete_Click(object sender, EventArgs e) { try { if (!Null.IsNull(itemId)) { var document = DocumentsDataProvider.Instance.GetDocument(itemId, ModuleId); if (document != null) { DocumentsDataProvider.Instance.Delete(document); DocumentsDataProvider.Instance.DeleteDocumentUrl(document.Url, PortalId, ModuleId); if (sender == buttonDeleteWithResource) { DocumentsDataProvider.Instance.DeleteDocumentResource(document, PortalId); } } } ModuleSynchronizer.Synchronize(ModuleId, TabModuleId); Response.Redirect(Globals.NavigateURL(), true); } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
protected void buttonApply_Click(object sender, EventArgs e) { try { var folder = ddlFolder.SelectedFolder; if (folder != null) { var documents = DocumentsDataProvider.Instance.GetDocuments(ModuleId, PortalId); var files = FolderManager.Instance.GetFiles(folder); foreach (var document in documents) { // only for files if (Globals.GetURLType(document.Url) == TabType.File) { var docFileId = Utils.GetResourceId(document.Url); var docFile = FileManager.Instance.GetFile(docFileId); if (docFile != null) { var updated = false; var oldDocument = document.Clone(); var matchedFile = FindMatchedFile(docFile, files); if (matchedFile != null) { document.Url = "FileID=" + matchedFile.FileId; document.CreatedDate = DateTime.Now; document.ModifiedDate = document.CreatedDate; document.CreatedByUserId = UserId; document.ModifiedByUserId = UserId; updated = true; } PostUpdateDocument(document, oldDocument, updated); } } } // update module's default folder setting if (checkUpdateDefaultFolder.Checked) { Settings.DefaultFolder = ddlFolder.SelectedFolder.FolderID; SettingsRepository.SaveSettings(ModuleConfiguration, Settings); } ModuleSynchronizer.Synchronize(ModuleId, TabModuleId); } Response.Redirect(Globals.NavigateURL(), true); } catch (Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } }
/// <summary> /// ImportModule implements the IPortable ImportModule Interface /// </summary> /// <param name="moduleId">The Id of the module to be imported</param> /// <history> /// [cnurse] 17 Nov 2004 documented /// [aglenwright] 18 Feb 2006 Added new fields: Createddate, description, /// modifiedbyuser, modifieddate, OwnedbyUser, SortorderIndex /// Added DocumentsSettings /// [togrean] 10 Jul 2007 Fixed issues with importing documet settings since new fileds /// were added: AllowSorting, default folder, list name /// [togrean] 13 Jul 2007 Added support for importing documents Url tracking options /// </history> public void ImportModule(int moduleId, string content, string version, int userId) { var mCtrl = new ModuleController(); var module = mCtrl.GetModule(moduleId, Null.NullInteger); var xmlDocuments = Globals.GetContent(content, "documents"); var documentNodes = xmlDocuments.SelectNodes("document"); var now = DateTime.Now; foreach (XmlNode documentNode in documentNodes) { var strUrl = documentNode ["url"].InnerText; var document = new DocumentInfo { ModuleId = moduleId, Title = documentNode ["title"].InnerText, Category = documentNode ["category"].InnerText, Description = XmlUtils.GetNodeValue(documentNode, "description"), OwnedByUserId = XmlUtils.GetNodeValueInt(documentNode, "ownedbyuserid"), SortOrderIndex = XmlUtils.GetNodeValueInt(documentNode, "sortorderindex"), LinkAttributes = XmlUtils.GetNodeValue(documentNode, "linkattributes"), ForceDownload = XmlUtils.GetNodeValueBoolean(documentNode, "forcedownload"), StartDate = GetNodeValueDateNullable(documentNode, "startDate"), EndDate = GetNodeValueDateNullable(documentNode, "endDate"), CreatedByUserId = userId, ModifiedByUserId = userId, CreatedDate = now, ModifiedDate = now, Url = strUrl.StartsWith("fileid=", StringComparison.InvariantCultureIgnoreCase) ? strUrl : Globals.ImportUrl(moduleId, strUrl) }; DocumentsDataProvider.Instance.Add(document); // Update Tracking options var urlType = document.Url.StartsWith("fileid=", StringComparison.InvariantCultureIgnoreCase) ? "F" : "U"; var urlCtrl = new UrlController(); // If nodes not found, all values will be false urlCtrl.UpdateUrl( module.PortalID, document.Url, urlType, XmlUtils.GetNodeValueBoolean(documentNode, "logactivity"), XmlUtils.GetNodeValueBoolean(documentNode, "trackclicks", true), moduleId, XmlUtils.GetNodeValueBoolean(documentNode, "newwindow")); } ImportSettings(module, content); ModuleSynchronizer.Synchronize(module.ModuleID, module.TabModuleID); }
/// <summary> /// UpdateSettings saves the modified settings to the Database /// </summary> public override void UpdateSettings() { try { if (Page.IsValid) { FillSettings(); SettingsRepository.SaveSettings(ModuleConfiguration, Settings); ModuleSynchronizer.Synchronize(ModuleId, TabModuleId); } } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
protected void buttonImport_Click(object sender, EventArgs e) { try { var fromModule = ModuleController.Instance.GetModule(int.Parse(comboModule.SelectedValue), TabId, false); foreach (ListItem item in listDocuments.Items) { if (item.Selected) { var document = GetDocument(int.Parse(item.Value), fromModule); if (document != null) { // get original document tracking data var ctrlUrl = new UrlController(); var urlTracking = ctrlUrl.GetUrlTracking(PortalId, document.Url, document.ModuleId); // import document document.ItemId = Null.NullInteger; document.ModuleId = ModuleId; DocumentsDataProvider.Instance.Add(document); // add new url tracking data if (urlTracking != null) { // WTF: using url.Clicks, url.LastClick, url.CreatedDate overload not working? ctrlUrl.UpdateUrl(PortalId, document.Url, urlTracking.UrlType, urlTracking.LogActivity, urlTracking.TrackClicks, ModuleId, urlTracking.NewWindow); } } } } ModuleSynchronizer.Synchronize(ModuleId, TabModuleId); Response.Redirect(Globals.NavigateURL(), true); } catch (Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } }
List <DocumentViewModel> LoadDocuments() { var isAdmin = UserInfo.IsSuperUser || UserInfo.IsInRole("Administrators"); var cacheKey = ModuleSynchronizer.GetDataCacheKey(ModuleId, TabModuleId); var documents = DataCache.GetCachedData <IEnumerable <DocumentViewModel> > ( new CacheItemArgs(cacheKey, 1200, CacheItemPriority.Normal), c => LoadDocuments_Internal() ); // remove unpublished and inaccessible documents from the list // TODO: Add test to check filtering logic var filteredDocuments = documents .Where(d => (IsEditable || d.IsPublished(HttpContext.Current.Timestamp)) && (isAdmin || CanView(d.Url))) .ToList(); // sort documents var docComparer = new DocumentViewModelComparer(Settings.GetSortColumnList()); filteredDocuments.Sort(docComparer.Compare); return(filteredDocuments); }
void Update(bool ignoreWarnings) { try { if (Page.IsValid) { if (!ignoreWarnings) { if (!CheckFileExists(ctlUrl.Url) || !CheckFileSecurity(ctlUrl.Url)) { cmdUpdateOverride.Visible = true; cmdUpdate.Visible = false; // display warning instructing users to click update again if they want to ignore the warning this.Message("msgFileWarningHeading.Text", "msgFileWarning.Text", MessageType.Warning, true); return; } } // get existing document record var document = DocumentsDataProvider.Instance.GetDocument(itemId, ModuleId); if (document == null) { document = new DocumentInfo { ItemId = itemId, ModuleId = ModuleId, CreatedByUserId = UserInfo.UserID, OwnedByUserId = UserId }; } var oldDocument = document.Clone(); document.Title = txtName.Text; document.Description = txtDescription.Text; document.ForceDownload = chkForceDownload.Checked; document.Url = ctlUrl.Url; document.LinkAttributes = textLinkAttributes.Text; document.ModifiedByUserId = UserInfo.UserID; UpdateDateTime(document, oldDocument); UpdateOwner(document); UpdateCategory(document); int sortIndex; document.SortOrderIndex = int.TryParse(txtSortIndex.Text, out sortIndex) ? sortIndex : 0; if (Null.IsNull(itemId)) { DocumentsDataProvider.Instance.Add(document); } else { DocumentsDataProvider.Instance.Update(document); if (document.Url != oldDocument.Url) { // delete old URL tracking data DocumentsDataProvider.Instance.DeleteDocumentUrl(oldDocument.Url, PortalId, ModuleId); } } // add or update URL tracking var ctrlUrl = new UrlController(); ctrlUrl.UpdateUrl(PortalId, ctlUrl.Url, ctlUrl.UrlType, ctlUrl.Log, ctlUrl.Track, ModuleId, ctlUrl.NewWindow); var urlHistory = new UrlHistory(Session); urlHistory.StoreUrl(document.Url); ModuleSynchronizer.Synchronize(ModuleId, TabModuleId); if (Null.IsNull(itemId)) { this.Message(string.Format(LocalizeString("DocumentAdded.Format"), document.Title), MessageType.Success); multiView.ActiveViewIndex = 1; BindUrlHistory(); } else { Response.Redirect(Globals.NavigateURL(), true); } } } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }