/* public void AddDocument(DocumentInfo objDocument) { DataProvider.Instance().AddDocument(objDocument.ModuleId, objDocument.Title, objDocument.Url, objDocument.CreatedByUserId, objDocument.OwnedByUserId, objDocument.Category, objDocument.SortOrderIndex, objDocument.Description, objDocument.ForceDownload); } public void DeleteDocument(int ModuleId, int ItemID) { DataProvider.Instance().DeleteDocument(ModuleId, ItemID); } public DocumentInfo GetDocument(int ItemId, int ModuleId) { return (DocumentInfo)CBO.FillObject(DataProvider.Instance().GetDocument(ItemId, ModuleId), typeof(DocumentInfo)); } public ArrayList GetDocuments(int ModuleId, int PortalId) { return CBO.FillCollection(DataProvider.Instance().GetDocuments(ModuleId, PortalId), typeof(DocumentInfo)); } public void UpdateDocument(DocumentInfo objDocument) { DataProvider.Instance().UpdateDocument(objDocument.ModuleId, objDocument.ItemId, objDocument.Title, objDocument.Url, objDocument.CreatedByUserId, objDocument.OwnedByUserId, objDocument.Category, objDocument.SortOrderIndex, objDocument.Description, objDocument.ForceDownload); } */ #endregion #region IPortable implementation /// ----------------------------------------------------------------------------- /// <summary> /// ExportModule implements the IPortable ExportModule Interface /// </summary> /// <remarks> /// </remarks> /// <param name="ModuleID">The Id of the module to be exported</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 exporting documents Url tracking options /// </history> /// ----------------------------------------------------------------------------- public string ExportModule (int moduleId) { var mCtrl = new ModuleController (); var module = mCtrl.GetModule (moduleId, Null.NullInteger); var strXml = new StringBuilder ("<documents>"); try { var documents = GetDocuments (moduleId, module.PortalID); if (documents.Any ()) { foreach (var document in documents) { strXml.Append ("<document>"); strXml.AppendFormat ("<title>{0}</title>", XmlUtils.XMLEncode (document.Title)); strXml.AppendFormat ("<url>{0}</url>", XmlUtils.XMLEncode (document.Url)); strXml.AppendFormat ("<category>{0}</category>", XmlUtils.XMLEncode (document.Category)); strXml.AppendFormat ("<description>{0}</description>", XmlUtils.XMLEncode (document.Description)); strXml.AppendFormat ("<forcedownload>{0}</forcedownload>", XmlUtils.XMLEncode (document.ForceDownload.ToString ())); strXml.AppendFormat ("<ispublished>{0}</ispublished>", XmlUtils.XMLEncode (document.IsPublished.ToString ())); strXml.AppendFormat ("<ownedbyuserid>{0}</ownedbyuserid>", XmlUtils.XMLEncode (document.OwnedByUserId.ToString ())); strXml.AppendFormat ("<sortorderindex>{0}</sortorderindex>", XmlUtils.XMLEncode (document.SortOrderIndex.ToString ())); strXml.AppendFormat ("<linkattributes>{0}</linkattributes>", XmlUtils.XMLEncode (document.LinkAttributes)); // Export Url Tracking options too var urlCtrl = new UrlController (); var urlTrackingInfo = urlCtrl.GetUrlTracking (module.PortalID, document.Url, moduleId); if ((urlTrackingInfo != null)) { strXml.AppendFormat ("<logactivity>{0}</logactivity>", XmlUtils.XMLEncode (urlTrackingInfo.LogActivity.ToString ())); strXml.AppendFormat ("<trackclicks>{0}</trackclicks>", XmlUtils.XMLEncode (urlTrackingInfo.TrackClicks.ToString ())); strXml.AppendFormat ("<newwindow>{0}</newwindow>", XmlUtils.XMLEncode (urlTrackingInfo.NewWindow.ToString ())); } strXml.Append ("</document>"); } } var settings = new DocumentsSettings (module); strXml.Append ("<settings>"); strXml.AppendFormat ("<allowusersort>{0}</allowusersort>", XmlUtils.XMLEncode (settings.AllowUserSort.ToString ())); strXml.AppendFormat ("<showtitlelink>{0}</showtitlelink>", XmlUtils.XMLEncode (settings.ShowTitleLink.ToString ())); strXml.AppendFormat ("<usecategorieslist>{0}</usecategorieslist>", XmlUtils.XMLEncode (settings.UseCategoriesList.ToString ())); strXml.AppendFormat ("<categorieslistname>{0}</categorieslistname>", XmlUtils.XMLEncode (settings.CategoriesListName)); strXml.AppendFormat ("<defaultfolder>{0}</defaultfolder>", XmlUtils.XMLEncode (settings.DefaultFolder.ToString())); strXml.AppendFormat ("<displaycolumns>{0}</displaycolumns>", XmlUtils.XMLEncode (settings.DisplayColumns)); strXml.AppendFormat ("<sortorder>{0}</sortorder>", XmlUtils.XMLEncode (settings.SortOrder)); strXml.Append ("</settings>"); } catch { // catch errors } finally { // make sure XML is valid strXml.Append ("</documents>"); } return strXml.ToString (); }
private void DoChangeURL() { string _Url = Convert.ToString(ViewState["Url"]); string _Urltype = Convert.ToString(ViewState["UrlType"]); if (!String.IsNullOrEmpty(_Url)) { var objUrls = new UrlController(); string TrackingUrl = _Url; _Urltype = Globals.GetURLType(_Url).ToString("g").Substring(0, 1); if (_Urltype == "U" && (_Url.StartsWith("~/" + IconController.DefaultIconLocation, StringComparison.InvariantCultureIgnoreCase))) { _Urltype = "I"; } ViewState["UrlType"] = _Urltype; if (_Urltype == "F") { if (_Url.ToLower().StartsWith("fileid=")) { TrackingUrl = _Url; var objFile = FileManager.Instance.GetFile(int.Parse(_Url.Substring(7))); if (objFile != null) { _Url = objFile.Folder + objFile.FileName; } } else { //to handle legacy scenarios before the introduction of the FileServerHandler var fileName = Path.GetFileName(_Url); var folderPath = _Url.Substring(0, _Url.LastIndexOf(fileName)); var folder = FolderManager.Instance.GetFolder(_objPortal.PortalID, folderPath); var fileId = -1; if (folder != null) { var file = FileManager.Instance.GetFile(folder, fileName); if (file != null) { fileId = file.FileId; } } TrackingUrl = "FileID=" + fileId.ToString(); } } if (_Urltype == "M") { if (_Url.ToLower().StartsWith("userid=")) { UserInfo objUser = UserController.GetUserById(_objPortal.PortalID, int.Parse(_Url.Substring(7))); if (objUser != null) { _Url = objUser.Username; } } } UrlTrackingInfo objUrlTracking = objUrls.GetUrlTracking(_objPortal.PortalID, TrackingUrl, ModuleID); if (objUrlTracking != null) { chkNewWindow.Checked = objUrlTracking.NewWindow; chkTrack.Checked = objUrlTracking.TrackClicks; chkLog.Checked = objUrlTracking.LogActivity; } else //the url does not exist in the tracking table { chkTrack.Checked = false; chkLog.Checked = false; } ViewState["Url"] = _Url; } else { if (!String.IsNullOrEmpty(_Urltype)) { optType.ClearSelection(); if (optType.Items.FindByValue(_Urltype) != null) { optType.Items.FindByValue(_Urltype).Selected = true; } else { optType.Items[0].Selected = true; } } else { if (optType.Items.Count > 0) { optType.ClearSelection(); optType.Items[0].Selected = true; } } chkTrack.Checked = false; //Need check chkLog.Checked = false; //Need check } //Url type changed, then we must draw the controlos for that type _doRenderTypeControls = true; }
public void UpdateDocumentUrl (DocumentInfo document, string oldUrl, int PortalId, int ModuleId) { if (document.Url != oldUrl) { var ctrlUrl = new UrlController (); // get tracking data for the old URL var url = ctrlUrl.GetUrlTracking (PortalId, oldUrl, ModuleId); // delete old URL tracking data DataProvider.Instance ().DeleteUrlTracking (PortalId, oldUrl, ModuleId); // create new URL tracking data ctrlUrl.UpdateUrl (PortalId, document.Url, url.UrlType, url.LogActivity, url.TrackClicks, ModuleId, url.NewWindow); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); cmdDisplay.Click += cmdDisplay_Click; try { //this needs to execute always to the client script code is registred in InvokePopupCal cmdStartCalendar.NavigateUrl = Calendar.InvokePopupCal(txtStartDate); cmdEndCalendar.NavigateUrl = Calendar.InvokePopupCal(txtEndDate); if (!Page.IsPostBack) { if (!String.IsNullOrEmpty(_URL)) { lblLogURL.Text = URL; //saved for loading Log grid TabType URLType = Globals.GetURLType(_URL); if (URLType == TabType.File && _URL.ToLower().StartsWith("fileid=") == false) { //to handle legacy scenarios before the introduction of the FileServerHandler var fileName = Path.GetFileName(_URL); var folderPath = _URL.Substring(0, _URL.LastIndexOf(fileName)); var folder = FolderManager.Instance.GetFolder(PortalSettings.PortalId, folderPath); var file = FileManager.Instance.GetFile(folder, fileName); lblLogURL.Text = "FileID=" + file.FileId; } var objUrls = new UrlController(); UrlTrackingInfo objUrlTracking = objUrls.GetUrlTracking(PortalSettings.PortalId, lblLogURL.Text, ModuleID); if (objUrlTracking != null) { if (String.IsNullOrEmpty(_FormattedURL)) { lblURL.Text = Globals.LinkClick(URL, PortalSettings.ActiveTab.TabID, ModuleID, false); if (!lblURL.Text.StartsWith("http") && !lblURL.Text.StartsWith("mailto")) { lblURL.Text = Globals.AddHTTP(Request.Url.Host) + lblURL.Text; } } else { lblURL.Text = _FormattedURL; } lblCreatedDate.Text = objUrlTracking.CreatedDate.ToString(); if (objUrlTracking.TrackClicks) { pnlTrack.Visible = true; if (String.IsNullOrEmpty(_TrackingURL)) { if (!URL.StartsWith("http")) { lblTrackingURL.Text = Globals.AddHTTP(Request.Url.Host); } lblTrackingURL.Text += Globals.LinkClick(URL, PortalSettings.ActiveTab.TabID, ModuleID, objUrlTracking.TrackClicks); } else { lblTrackingURL.Text = _TrackingURL; } lblClicks.Text = objUrlTracking.Clicks.ToString(); if (!Null.IsNull(objUrlTracking.LastClick)) { lblLastClick.Text = objUrlTracking.LastClick.ToString(); } } if (objUrlTracking.LogActivity) { pnlLog.Visible = true; txtStartDate.Text = DateTime.Today.AddDays(-6).ToShortDateString(); txtEndDate.Text = DateTime.Today.AddDays(1).ToShortDateString(); } } } else { Visible = false; } } } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }
/* protected override void OnLoad (EventArgs e) { base.OnLoad (e); try { if (!IsPostBack) { } else { } } catch (Exception ex) { // module failed to load Exceptions.ProcessModuleLoadException (this, ex); } }*/ protected void buttonImport_Click (object sender, EventArgs e) { try { var mctrl = new ModuleController (); var module = mctrl.GetModule (int.Parse (comboModule.SelectedValue), TabId); var mdef = module.ModuleDefinition.DefinitionName.ToLowerInvariant (); foreach (ListItem item in listDocuments.Items) { if (item.Selected) { DocumentInfo document = null; if (mdef == "r7.documents") document = DocumentsController.GetDocument (int.Parse (item.Value), module.ModuleID); else if (mdef == "documents") document = DocumentsController.GetDNNDocument (int.Parse (item.Value), module.ModuleID); if (document != null) { var ctrlUrl = new UrlController (); // get original document tracking data var url = ctrlUrl.GetUrlTracking (PortalId, document.Url, document.ModuleId); document.ItemId = Null.NullInteger; document.ModuleId = ModuleId; document.IsPublished = true; // add new document DocumentsController.Add (document); // add new url tracking data ctrlUrl.UpdateUrl (PortalId, document.Url, url.UrlType, url.LogActivity, url.TrackClicks, ModuleId, url.NewWindow); // NOTE: using url.Clicks, url.LastClick, url.CreatedDate not working } } } Synchronize (); // redirect back to the portal home page Response.Redirect (Globals.NavigateURL (), true); } catch (Exception ex) { // module failed to load Exceptions.ProcessModuleLoadException (this, ex); } }
private void ShowControls() { UrlController objUrls = new UrlController(); // set url type if (optType.SelectedItem == null) { if (!String.IsNullOrEmpty(_Url)) { string TrackingUrl = _Url; _UrlType = Globals.GetURLType(_Url).ToString("g").Substring(0, 1); if (_UrlType == "F") { FileController objFiles = new FileController(); if (_Url.ToLower().StartsWith("fileid=")) { TrackingUrl = _Url; FileInfo objFile = objFiles.GetFileById(int.Parse(_Url.Substring(7)), _objPortal.PortalID); if (objFile != null) { _Url = objFile.Folder + objFile.FileName; } } else { // to handle legacy scenarios before the introduction of the FileServerHandler TrackingUrl = "FileID=" + objFiles.ConvertFilePathToFileId(_Url, _objPortal.PortalID); } } if (_UrlType == "M") { if (_Url.ToLower().StartsWith("userid=")) { UserInfo objUser = UserController.GetUser(_objPortal.PortalID, int.Parse(_Url.Substring(7)), false); if (objUser != null) { _Url = objUser.Username; } } } UrlTrackingInfo objUrlTracking = objUrls.GetUrlTracking(_objPortal.PortalID, TrackingUrl, ModuleID); if (objUrlTracking != null) { optType.Items.FindByValue(objUrlTracking.UrlType).Selected = true; chkNewWindow.Checked = objUrlTracking.NewWindow; chkTrack.Checked = objUrlTracking.TrackClicks; chkLog.Checked = objUrlTracking.LogActivity; } else // the url does not exist in the tracking table { optType.Items.FindByValue(_UrlType).Selected = true; chkNewWindow.Checked = false; chkTrack.Checked = true; chkLog.Checked = false; } } else { if (!String.IsNullOrEmpty(_UrlType)) { if (optType.Items.FindByValue(_UrlType) != null) { optType.Items.FindByValue(_UrlType).Selected = true; } else { optType.Items[0].Selected = true; } } else { optType.Items[0].Selected = true; } chkNewWindow.Checked = false; chkTrack.Checked = true; chkLog.Checked = false; } } // load listitems switch (optType.SelectedItem.Value) { case "N": // None URLRow.Visible = false; TabRow.Visible = false; FileRow.Visible = false; UserRow.Visible = false; break; case "U": // Url URLRow.Visible = true; TabRow.Visible = false; FileRow.Visible = false; UserRow.Visible = false; if (txtUrl.Text == "") { txtUrl.Text = _Url; } if (txtUrl.Text == "") { txtUrl.Text = "http://"; } txtUrl.Visible = true; cmdSelect.Visible = true; cboUrls.Items.Clear(); cboUrls.DataSource = objUrls.GetUrls(_objPortal.PortalID); cboUrls.DataBind(); if (cboUrls.Items.FindByValue(_Url) != null) { cboUrls.Items.FindByValue(_Url).Selected = true; } cboUrls.Visible = false; cmdAdd.Visible = false; cmdDelete.Visible = false; break; case "T": // tab URLRow.Visible = false; TabRow.Visible = true; FileRow.Visible = false; UserRow.Visible = false; cboTabs.Items.Clear(); cboTabs.DataSource = Globals.GetPortalTabs(_objPortal.PortalID, !_Required, true, false, false, false); cboTabs.DataBind(); if (cboTabs.Items.FindByValue(_Url) != null) { cboTabs.Items.FindByValue(_Url).Selected = true; } break; case "F": // file URLRow.Visible = false; TabRow.Visible = false; FileRow.Visible = true; UserRow.Visible = false; LoadFolders(); if (cboFolders.Items.Count == 0) { lblMessage.Text = Localization.GetString("NoPermission", this.LocalResourceFile); FileRow.Visible = false; return; } // select folder string FileName; string FolderPath; if (_Url != string.Empty) { FileName = _Url.Substring(_Url.LastIndexOf("/") + 1); FolderPath = _Url.Replace(FileName, ""); } else { FileName = _Url; FolderPath = string.Empty; } if (cboFolders.Items.FindByValue(FolderPath) != null) { cboFolders.Items.FindByValue(FolderPath).Selected = true; } else { cboFolders.Items[0].Selected = true; FolderPath = cboFolders.SelectedValue; } //cboFiles.DataSource = GetFileList(FileFilter, !_Required, cboFolders.SelectedItem.Value); cboFiles.DataSource = GetFileList(!_Required); cboFiles.DataBind(); if (cboFiles.Items.FindByText(FileName) != null) { cboFiles.Items.FindByText(FileName).Selected = true; } cboFiles.Visible = true; txtFile.Visible = false; string strWriteRoles = GetWriteRoles(FolderPath); cmdUpload.Visible = PortalSecurity.IsInRoles(strWriteRoles) && _ShowUpLoad; SetStorageLocationType(); txtUrl.Visible = false; cmdSave.Visible = false; cmdCancel.Visible = false; break; case "M": // membership users URLRow.Visible = false; TabRow.Visible = false; FileRow.Visible = false; UserRow.Visible = true; if (txtUser.Text == "") { txtUser.Text = _Url; } break; } }
/// <summary> /// The Page_Load server event handler on this page is used to populate the role information for the page /// </summary> protected void Page_Load( object sender, EventArgs e ) { try { //this needs to execute always to the client script code is registred in InvokePopupCal cmdStartCalendar.NavigateUrl = Calendar.InvokePopupCal( txtStartDate ); cmdEndCalendar.NavigateUrl = Calendar.InvokePopupCal( txtEndDate ); if( !Page.IsPostBack ) { if( !String.IsNullOrEmpty(_URL) ) { lblLogURL.Text = URL; // saved for loading Log grid TabType URLType = Globals.GetURLType( _URL ); if( URLType == TabType.File && _URL.ToLower().StartsWith( "fileid=" ) == false ) { // to handle legacy scenarios before the introduction of the FileServerHandler FileController objFiles = new FileController(); lblLogURL.Text = "FileID=" + objFiles.ConvertFilePathToFileId( _URL, PortalSettings.PortalId ); } UrlController objUrls = new UrlController(); UrlTrackingInfo objUrlTracking = objUrls.GetUrlTracking( PortalSettings.PortalId, lblLogURL.Text, ModuleID ); if( objUrlTracking != null ) { if( _FormattedURL == "" ) { if( !URL.StartsWith( "http" ) && !URL.StartsWith( "mailto" ) ) { lblURL.Text = Globals.AddHTTP( Request.Url.Host ); } lblURL.Text += Globals.LinkClick( URL, PortalSettings.ActiveTab.TabID, ModuleID, false ); } else { lblURL.Text = _FormattedURL; } lblCreatedDate.Text = objUrlTracking.CreatedDate.ToString(); if( objUrlTracking.TrackClicks ) { pnlTrack.Visible = true; if( _TrackingURL == "" ) { if( !URL.StartsWith( "http" ) ) { lblTrackingURL.Text = Globals.AddHTTP( Request.Url.Host ); } lblTrackingURL.Text += Globals.LinkClick( URL, PortalSettings.ActiveTab.TabID, ModuleID, objUrlTracking.TrackClicks ); } else { lblTrackingURL.Text = _TrackingURL; } lblClicks.Text = objUrlTracking.Clicks.ToString(); if( !Null.IsNull( objUrlTracking.LastClick ) ) { lblLastClick.Text = objUrlTracking.LastClick.ToString(); } } if( objUrlTracking.LogActivity ) { pnlLog.Visible = true; txtStartDate.Text = DateAndTime.DateAdd( DateInterval.Day, -6, DateTime.Today ).ToShortDateString(); txtEndDate.Text = DateAndTime.DateAdd( DateInterval.Day, 1, DateTime.Today ).ToShortDateString(); } } } else { this.Visible = false; } } } catch( Exception exc ) //Module failed to load { Exceptions.ProcessModuleLoadException( this, exc ); } }