/// <summary>
        ///   SaveTabData saves the Tab to the Database
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name = "strAction">The action to perform "edit" or "add"</param>
        /// <history>
        ///   [cnurse]	9/10/2004	Updated to reflect design changes for Help, 508 support
        ///   and localisation
        ///   [jlucarino]	2/26/2009	Added CreatedByUserID and LastModifiedByUserID
        /// </history>
        private int SaveTabData(string strAction)
        {
            string strIcon;
            string strIconLarge;
            strIcon = ctlIcon.Url;
            strIconLarge = ctlIconLarge.Url;

            var objTabs = new TabController();

            Tab.TabName = txtTabName.Text;
            Tab.Title = txtTitle.Text;
            Tab.Description = txtDescription.Text;
            Tab.KeyWords = txtKeyWords.Text;
            Tab.IsVisible = chkMenu.Checked;
            Tab.DisableLink = chkDisableLink.Checked;

            TabInfo parentTab = null;
            if (cboParentTab.SelectedItem != null)
            {
                var parentTabID = Int32.Parse(cboParentTab.SelectedItem.Value);
                var controller = new TabController();
                parentTab = controller.GetTab(parentTabID, -1, false);
            }

            if (parentTab != null)
            {
                Tab.PortalID = parentTab.PortalID;
                Tab.ParentId = parentTab.TabID;
            }
            else
            {
                Tab.ParentId = Null.NullInteger;
            }
            Tab.IconFile = strIcon;
            Tab.IconFileLarge = strIconLarge;
            Tab.IsDeleted = false;
            Tab.Url = ctlURL.Url;

            Tab.TabPermissions.Clear();
            if (Tab.PortalID != Null.NullInteger)
            {
                Tab.TabPermissions.AddRange(dgPermissions.Permissions);
            }

            Tab.Terms.Clear();
            Tab.Terms.AddRange(termsSelector.Terms);

            Tab.SkinSrc = pageSkinCombo.SelectedValue;
            Tab.ContainerSrc = pageContainerCombo.SelectedValue;
            Tab.TabPath = Globals.GenerateTabPath(Tab.ParentId, Tab.TabName);

            //Check for invalid
            if (!IsValidTabName(Tab.TabName))
            {
                return Null.NullInteger;
            }

            //Validate Tab Path
            if (!IsValidTabPath(Tab, Tab.TabPath))
            {
                return Null.NullInteger;
            }

            //Set Culture Code
            var positionTabID = Null.NullInteger;
            if (cboPositionTab.SelectedItem != null)
            {
                positionTabID = Int32.Parse(cboPositionTab.SelectedItem.Value);
            }

            if (strAction != "edit")
            {
                if (PortalSettings.ContentLocalizationEnabled)
                {
                    switch (cultureTypeList.SelectedValue)
                    {
                        case "Localized":
                            var defaultLocale = LocaleController.Instance.GetDefaultLocale(PortalId);
                            Tab.CultureCode = defaultLocale.Code;
                            break;
                        case "Culture":
                            Tab.CultureCode = PortalSettings.CultureCode;
                            break;
                        default:
                            Tab.CultureCode = Null.NullString;
                            break;
                    }

                    var tabLocale = LocaleController.Instance.GetLocale(Tab.CultureCode) ?? LocaleController.Instance.GetDefaultLocale(PortalId);

                    //Fix parent
                    if (Tab.ParentId > Null.NullInteger)
                    {
                        parentTab = objTabs.GetTab(Tab.ParentId, PortalId, false);
                        if (parentTab.CultureCode != Tab.CultureCode)
                        {
                            parentTab = objTabs.GetTabByCulture(Tab.ParentId, PortalId, tabLocale);
                        }
                        Tab.ParentId = parentTab.TabID;
                    }

                    //Fix position TabId
                    if (positionTabID > Null.NullInteger)
                    {
                        var positionTab = objTabs.GetTab(positionTabID, PortalId, false);
                        if (positionTab.CultureCode != Tab.CultureCode)
                        {
                            positionTab = objTabs.GetTabByCulture(positionTabID, PortalId, tabLocale);
                        }
                        positionTabID = positionTab.TabID;
                    }
                }
                else
                {
                    Tab.CultureCode = Null.NullString;
                }
            }

            //Validate Tab Path
            if (string.IsNullOrEmpty(strAction))
            {
                var tabID = TabController.GetTabByTabPath(Tab.PortalID, Tab.TabPath, Tab.CultureCode);

                if (tabID != Null.NullInteger)
                {
                    var existingTab = objTabs.GetTab(tabID, PortalId, false);
                    if (existingTab != null && existingTab.IsDeleted)
                    {
                        UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("TabRecycled", LocalResourceFile), ModuleMessage.ModuleMessageType.YellowWarning);
                    }
                    else
                    {
                        UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("TabExists", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                    }
                    return Null.NullInteger;
                }
            }

            Tab.StartDate = datepickerStartDate.SelectedDate != null ? datepickerStartDate.SelectedDate.Value : Null.NullDate;
            Tab.EndDate = datepickerEndDate.SelectedDate != null ? datepickerEndDate.SelectedDate.Value : Null.NullDate;

            if (Tab.StartDate > Null.NullDate && Tab.EndDate > Null.NullDate && Tab.StartDate.AddDays(1) >= Tab.EndDate)
            {
                UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("InvalidTabDates", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                return Null.NullInteger;
            }
            if (txtRefreshInterval.Text.Length > 0 && Regex.IsMatch(txtRefreshInterval.Text, "^\\d+$"))
            {
                Tab.RefreshInterval = Convert.ToInt32(txtRefreshInterval.Text);
            }

            Tab.SiteMapPriority = float.Parse(txtPriority.Text);
            Tab.PageHeadText = txtPageHeadText.Text;
            Tab.IsSecure = chkSecure.Checked;
            Tab.PermanentRedirect = chkPermanentRedirect.Checked;

            if (strAction == "edit")
            {
                // trap circular tab reference
                if (cboParentTab.SelectedItem != null && Tab.TabID != Int32.Parse(cboParentTab.SelectedItem.Value) && !IsCircularReference(Int32.Parse(cboParentTab.SelectedItem.Value), Tab.PortalID))
                {
                    objTabs.UpdateTab(Tab);
                    if (IsHostMenu && Tab.PortalID != Null.NullInteger)
                    {
                        //Host Tab moved to Portal so clear Host cache
                        objTabs.ClearCache(Null.NullInteger);
                    }
                    if (!IsHostMenu && Tab.PortalID == Null.NullInteger)
                    {
                        //Portal Tab moved to Host so clear portal cache
                        objTabs.ClearCache(PortalId);
                    }
                    UpdateTabSettings(Tab.TabID);
                }
                // add or copy
            }
            else
            {
                if (positionTabID == Null.NullInteger)
                {
                    Tab.TabID = objTabs.AddTab(Tab);
                }
                else
                {
                    if (rbInsertPosition.SelectedValue == "After" && positionTabID > Null.NullInteger)
                    {
                        Tab.TabID = objTabs.AddTabAfter(Tab, positionTabID);
                    }
                    else if (rbInsertPosition.SelectedValue == "Before" && positionTabID > Null.NullInteger)
                    {
                        Tab.TabID = objTabs.AddTabBefore(Tab, positionTabID);
                    }
                    else
                    {
                        Tab.TabID = objTabs.AddTab(Tab);
                    }
                }

                UpdateTabSettings(Tab.TabID);

                //Create Localized versions
                if (PortalSettings.ContentLocalizationEnabled && cultureTypeList.SelectedValue == "Localized")
                {
                    objTabs.CreateLocalizedCopies(Tab);
                    //Refresh tab
                    _tab = objTabs.GetTab(Tab.TabID, Tab.PortalID, true);
                }

                var copyTabId = Int32.Parse(cboCopyPage.SelectedItem.Value);
                if (copyTabId != -1)
                {
                    var objModules = new ModuleController();
                    ModuleInfo objModule;
                    CheckBox chkModule;
                    RadioButton optCopy;
                    RadioButton optReference;
                    TextBox txtCopyTitle;

                    foreach (DataGridItem objDataGridItem in grdModules.Items)
                    {
                        chkModule = (CheckBox)objDataGridItem.FindControl("chkModule");
                        if (chkModule.Checked)
                        {
                            var intModuleID = Convert.ToInt32(grdModules.DataKeys[objDataGridItem.ItemIndex]);
                            optCopy = (RadioButton)objDataGridItem.FindControl("optCopy");
                            optReference = (RadioButton)objDataGridItem.FindControl("optReference");
                            txtCopyTitle = (TextBox)objDataGridItem.FindControl("txtCopyTitle");

                            objModule = objModules.GetModule(intModuleID, copyTabId, false);
                            ModuleInfo newModule = null;
                            if ((objModule != null))
                            {
                                //Clone module as it exists in the cache and changes we make will update the cached object
                                newModule = objModule.Clone();

                                if (!optReference.Checked)
                                {
                                    newModule.ModuleID = Null.NullInteger;
                                }

                                newModule.TabID = Tab.TabID;
                                newModule.DefaultLanguageGuid = Null.NullGuid;
                                newModule.CultureCode = Tab.CultureCode;
                                newModule.ModuleTitle = txtCopyTitle.Text;
                                newModule.ModuleID = objModules.AddModule(newModule);

                                if (optCopy.Checked)
                                {
                                    if (!string.IsNullOrEmpty(newModule.DesktopModule.BusinessControllerClass))
                                    {
                                        var objObject = Reflection.CreateObject(newModule.DesktopModule.BusinessControllerClass, newModule.DesktopModule.BusinessControllerClass);
                                        if (objObject is IPortable)
                                        {
                                            var content = Convert.ToString(((IPortable)objObject).ExportModule(intModuleID));
                                            if (!string.IsNullOrEmpty(content))
                                            {
                                                ((IPortable)objObject).ImportModule(newModule.ModuleID, content, newModule.DesktopModule.Version, UserInfo.UserID);
                                            }
                                        }
                                    }
                                }
                            }

                            if (optReference.Checked)
                            {
                                //Make reference copies on secondary language
                                foreach (var m in objModule.LocalizedModules.Values)
                                {
                                    var newLocalizedModule = m.Clone();
                                    var localizedTab = Tab.LocalizedTabs[m.CultureCode];
                                    newLocalizedModule.TabID = localizedTab.TabID;
                                    newLocalizedModule.CultureCode = localizedTab.CultureCode;
                                    newLocalizedModule.ModuleTitle = txtCopyTitle.Text;
                                    newLocalizedModule.DefaultLanguageGuid = newModule.UniqueId;
                                    newLocalizedModule.ModuleID = objModules.AddModule(newLocalizedModule);
                                }
                            }
                        }
                    }
                }
                else
                {
                    // create the page from a template
                    if (cboTemplate.SelectedItem != null && cboTemplate.SelectedItem.Value != Null.NullInteger.ToString())
                    {
                        var xmlDoc = new XmlDocument();
                        try
                        {
                            // open the XML file
                            xmlDoc.Load(PortalSettings.HomeDirectoryMapPath + cboFolders.SelectedValue + cboTemplate.SelectedValue);
                        }
                        catch (Exception ex)
                        {
                            Exceptions.LogException(ex);

                            UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("BadTemplate", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                            return Null.NullInteger;
                        }
                        TabController.DeserializePanes(xmlDoc.SelectSingleNode("//portal/tabs/tab/panes"), Tab.PortalID, Tab.TabID, PortalTemplateModuleAction.Ignore, new Hashtable());
                        //save tab permissions
                        RibbonBarManager.DeserializeTabPermissions(xmlDoc.SelectNodes("//portal/tabs/tab/tabpermissions/permission"), Tab);

                        var tabIndex = 0;
                        var exceptions = string.Empty;
                        foreach (XmlNode tabNode in xmlDoc.SelectSingleNode("//portal/tabs").ChildNodes)
                        {
                            //Create second tab onward tabs. Note first tab is already created above.
                            if(tabIndex > 0)
                            {
                                try
                                {
                                    TabController.DeserializeTab(tabNode, null, PortalId, PortalTemplateModuleAction.Replace);
                                }
                                catch (Exception ex)
                                {
                                    Exceptions.LogException(ex);
                                    exceptions += string.Format("Template Tab # {0}. Error {1}<br/>", tabIndex + 1, ex.Message);
                                }
                            }
                            tabIndex++;
                        }

                        if (!string.IsNullOrEmpty(exceptions))
                        {
                            UI.Skins.Skin.AddModuleMessage(this, exceptions, ModuleMessage.ModuleMessageType.RedError);
                            return Null.NullInteger;
                        }
                    }
                }
            }

            // url tracking
            var objUrls = new UrlController();
            objUrls.UpdateUrl(PortalId, ctlURL.Url, ctlURL.UrlType, 0, Null.NullDate, Null.NullDate, ctlURL.Log, ctlURL.Track, Null.NullInteger, ctlURL.NewWindow);

            //Clear the Tab's Cached modules
            DataCache.ClearModuleCache(TabId);

            //Update Cached Tabs as TabPath may be needed before cache is cleared
            TabInfo tempTab;
            if (new TabController().GetTabsByPortal(PortalId).TryGetValue(Tab.TabID, out tempTab))
            {
                tempTab.TabPath = Tab.TabPath;
            }

            //Update Translation Status
            objTabs.UpdateTranslationStatus(Tab, translatedCheckbox.Checked);

            return Tab.TabID;
        }
        private void DoRenderTypeControls()
        {
            string _Url = Convert.ToString(ViewState["Url"]);
            string _Urltype = Convert.ToString(ViewState["UrlType"]);
            var objUrls = new UrlController();
            if (!String.IsNullOrEmpty(_Urltype))
            {
                //load listitems
                switch (optType.SelectedItem.Value)
                {
                    case "N": //None
                        URLRow.Visible = false;
                        TabRow.Visible = false;
                        FileRow.Visible = false;
                        UserRow.Visible = false;
                        ImagesRow.Visible = false;
                        break;
                    case "I": //System Image
                        URLRow.Visible = false;
                        TabRow.Visible = false;
                        FileRow.Visible = false;
                        UserRow.Visible = false;
                        ImagesRow.Visible = true;

                        cboImages.Items.Clear();

                        string strImagesFolder = Path.Combine(Globals.ApplicationMapPath, PortalSettings.DefaultIconLocation.Replace('/', '\\'));
                        foreach (string strImage in Directory.GetFiles(strImagesFolder))
                        {
                            string img = strImage.Replace(strImagesFolder, "").Trim('/').Trim('\\');
                            cboImages.Items.Add(new ListItem(img, string.Format("~/{0}/{1}", PortalSettings.DefaultIconLocation, img).ToLower()));
                        }

                        ListItem selecteItem = cboImages.Items.FindByValue(_Url.ToLower());
                        if (selecteItem != null)
                        {
                            selecteItem.Selected = true;
                        }
                        break;

                    case "U": //Url
                        URLRow.Visible = true;
                        TabRow.Visible = false;
                        FileRow.Visible = false;
                        UserRow.Visible = false;
                        ImagesRow.Visible = false;
                        if (String.IsNullOrEmpty(txtUrl.Text))
                        {
                            txtUrl.Text = _Url;
                        }
                        if (String.IsNullOrEmpty(txtUrl.Text))
                        {
                            txtUrl.Text = "http://";
                        }
                        txtUrl.Visible = true;

                        cmdSelect.Visible = 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;
                        ImagesRow.Visible = false;

                        cboTabs.IncludeAllTabTypes = false;
                        cboTabs.IncludeActiveTab = IncludeActiveTab;
                        cboTabs.UndefinedItem = new ListItem(SharedConstants.Unspecified, string.Empty);

                        PortalSettings _settings = PortalController.Instance.GetCurrentPortalSettings();
                        var tabId = Int32.Parse(_Url);
                        var page = TabController.Instance.GetTab(tabId, _settings.PortalId);
                        cboTabs.SelectedPage = page;
                        break;
                    case "F": //file
                        URLRow.Visible = false;
                        TabRow.Visible = false;
                        FileRow.Visible = true;
                        UserRow.Visible = false;
                        ImagesRow.Visible = false;

                        //select folder
                        //We Must check if selected folder has changed because of a property change (Secure, Database)
                        string FileName = string.Empty;
                        string FolderPath = string.Empty;
                        string LastFileName = string.Empty;
                        string LastFolderPath = string.Empty;
                        //Let's try to remember last selection
                        if (ViewState["LastFolderPath"] != null)
                        {
                            LastFolderPath = Convert.ToString(ViewState["LastFolderPath"]);
                        }
                        if (ViewState["LastFileName"] != null)
                        {
                            LastFileName = Convert.ToString(ViewState["LastFileName"]);
                        }
                        if (_Url != string.Empty)
                        {
                            //Let's use the new URL
                            FileName = _Url.Substring(_Url.LastIndexOf("/") + 1);
                            FolderPath = _Url.Replace(FileName, "");
                        }
                        else
                        {
                            //Use last settings
                            FileName = LastFileName;
                            FolderPath = LastFolderPath;
                        }

                        ctlFile.FilePath = FolderPath + FileName;

                        txtUrl.Visible = false;
                        break;
                    case "M": //membership users
                        URLRow.Visible = false;
                        TabRow.Visible = false;
                        FileRow.Visible = false;
                        UserRow.Visible = true;
                        ImagesRow.Visible = false;
                        if (String.IsNullOrEmpty(txtUser.Text))
                        {
                            txtUser.Text = _Url;
                        }
                        break;
                }
            }
            else
            {
                URLRow.Visible = false;
                ImagesRow.Visible = false;
                TabRow.Visible = false;
                FileRow.Visible = false;
                UserRow.Visible = false;
            }
        }
Exemple #3
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// This handler handles requests for LinkClick.aspx, but only those specifc
        /// to file serving
        /// </summary>
        /// <param name="context">System.Web.HttpContext)</param>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// 	[cpaterra]	4/19/2006	Created
        /// </history>
        /// -----------------------------------------------------------------------------
        public void ProcessRequest(HttpContext context)
        {
            PortalSettings _portalSettings = PortalController.GetCurrentPortalSettings();
            int TabId = -1;
            int ModuleId = -1;
            try
            {
                //get TabId
                if (context.Request.QueryString["tabid"] != null)
                {
                    Int32.TryParse(context.Request.QueryString["tabid"], out TabId);
                }

                //get ModuleId
                if (context.Request.QueryString["mid"] != null)
                {
                    Int32.TryParse(context.Request.QueryString["mid"], out ModuleId);
                }
            }
            catch (Exception)
            {
                //The TabId or ModuleId are incorrectly formatted (potential DOS)
                Exceptions.Exceptions.ProcessHttpException(context.Request);
            }

            //get Language
            string Language = _portalSettings.DefaultLanguage;
            if (context.Request.QueryString["language"] != null)
            {
                Language = context.Request.QueryString["language"];
            }
            else
            {
                if (context.Request.Cookies["language"] != null)
                {
                    Language = context.Request.Cookies["language"].Value;
                }
            }
            if (LocaleController.Instance.IsEnabled(ref Language, _portalSettings.PortalId))
            {
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(Language);
                Localization.Localization.SetLanguage(Language);
            }

            //get the URL
            string URL = "";
            bool blnClientCache = true;
            bool blnForceDownload = false;
            if (context.Request.QueryString["fileticket"] != null)
            {
                URL = "FileID=" + UrlUtils.DecryptParameter(context.Request.QueryString["fileticket"]);
            }
            if (context.Request.QueryString["userticket"] != null)
            {
                URL = "UserId=" + UrlUtils.DecryptParameter(context.Request.QueryString["userticket"]);
            }
            if (context.Request.QueryString["link"] != null)
            {
                URL = context.Request.QueryString["link"];
                if (URL.ToLowerInvariant().StartsWith("fileid="))
                {
                    URL = ""; //restrict direct access by FileID
                }
            }
            if (!String.IsNullOrEmpty(URL))
            {
                //update clicks, this must be done first, because the url tracker works with unmodified urls, like tabid, fileid etc
                var objUrls = new UrlController();
                objUrls.UpdateUrlTracking(_portalSettings.PortalId, URL, ModuleId, -1);
                TabType UrlType = Globals.GetURLType(URL);
                if(UrlType == TabType.Tab)
                {
                    //verify whether the tab is exist, otherwise throw out 404.
                    if(new TabController().GetTab(int.Parse(URL), _portalSettings.PortalId, false) == null)
                    {
                        Exceptions.Exceptions.ProcessHttpException();
                    }
                }
                if (UrlType != TabType.File)
                {
                    URL = Globals.LinkClick(URL, TabId, ModuleId, false);
                }

                if (UrlType == TabType.File && URL.ToLowerInvariant().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);

                    URL = "FileID=" + file.FileId;
                }

                //get optional parameters
                if (context.Request.QueryString["clientcache"] != null)
                {
                    blnClientCache = bool.Parse(context.Request.QueryString["clientcache"]);
                }
                if ((context.Request.QueryString["forcedownload"] != null) || (context.Request.QueryString["contenttype"] != null))
                {
                    blnForceDownload = bool.Parse(context.Request.QueryString["forcedownload"]);
                }
                var contentDisposition = blnForceDownload ? ContentDisposition.Attachment : ContentDisposition.Inline;

                //clear the current response
                context.Response.Clear();
                var fileManager = FileManager.Instance;
                try
                {
                    switch (UrlType)
                    {
                        case TabType.File:
                            var download = false;
                            var file = fileManager.GetFile(int.Parse(UrlUtils.GetParameterValue(URL)));
                            if (file != null)
                            {
                                try
                                {
                                    var folderMapping = FolderMappingController.Instance.GetFolderMapping(file.PortalId, file.FolderMappingID);
                                    var directUrl = fileManager.GetUrl(file);
                                    if (directUrl.Contains("LinkClick") || (blnForceDownload && folderMapping.FolderProviderType == "StandardFolderProvider"))
                                    {
                                        fileManager.WriteFileToResponse(file, contentDisposition);
                                        download = true;
                                    }
                                    else
                                    {
                                        context.Response.Redirect(directUrl, /*endResponse*/ true);
                                    }
                                }
                                catch (PermissionsNotMetException)
                                {
                                    if (context.Request.IsAuthenticated)
                                    {
                                        context.Response.Redirect(Globals.AccessDeniedURL(Localization.Localization.GetString("FileAccess.Error")), true);
                                    }
                                    else
                                    {
                                        context.Response.Redirect(Globals.AccessDeniedURL(), true);
                                    }
                                }
                                catch (Exception ex)
                                {
                                    DnnLog.Error(ex);
                                }
                            }

                            if (!download)
                            {
                                Exceptions.Exceptions.ProcessHttpException(URL);
                            }
                            break;
                        case TabType.Url:
                            //prevent phishing by verifying that URL exists in URLs table for Portal
                            if (objUrls.GetUrl(_portalSettings.PortalId, URL) != null)
                            {
                                context.Response.Redirect(URL, true);
                            }
                            break;
                        default:
                            //redirect to URL
                            context.Response.Redirect(URL, true);
                            break;
                    }
                }
                catch (ThreadAbortException exc)
                {
                    DnnLog.Error(exc);
                }
                catch (Exception)
                {
                    Exceptions.Exceptions.ProcessHttpException(URL);
                }
            }
            else
            {
                Exceptions.Exceptions.ProcessHttpException(URL);
            }
        }
        protected void cmdDelete_Click(object sender, EventArgs e)
        {
            if (cboUrls.SelectedItem != null)
            {
                UrlController objUrls = new UrlController();
                objUrls.DeleteUrl(_objPortal.PortalID, cboUrls.SelectedItem.Value);

                ShowControls();
            }
        }
		/// -----------------------------------------------------------------------------
		/// <summary>
		/// ImportModule implements the IPortable ImportModule Interface
		/// </summary>
		/// <remarks>
		/// </remarks>
		/// <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");

            foreach (XmlNode documentNode in documentNodes)
			{
                var document = new DocumentInfo ();
				document.ModuleId = moduleId;
				document.Title = documentNode ["title"].InnerText;
				
                var strUrl = documentNode ["url"].InnerText;
                document.Url = strUrl.StartsWith ("fileid=", StringComparison.InvariantCultureIgnoreCase) ?
                    strUrl : Globals.ImportUrl (moduleId, strUrl);

				document.Category = documentNode ["category"].InnerText;
				document.Description = XmlUtils.GetNodeValue (documentNode, "description");
				document.OwnedByUserId = XmlUtils.GetNodeValueInt (documentNode, "ownedbyuserid");
				document.SortOrderIndex = XmlUtils.GetNodeValueInt (documentNode, "sortorderindex");
                document.LinkAttributes = XmlUtils.GetNodeValue (documentNode, "linkattributes");
                document.ForceDownload = XmlUtils.GetNodeValueBoolean (documentNode, "forcedownload");
                document.IsPublished = XmlUtils.GetNodeValueBoolean (documentNode, "ispublished");

				document.CreatedByUserId = userId;
				document.ModifiedByUserId = userId;
				
				var now = DateTime.Now;
				document.CreatedDate = now;
				document.ModifiedDate = now;

				Add<DocumentInfo> (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"));
			}

            var xmlSettings = Globals.GetContent (content, "documents/settings");
			if (xmlSettings != null)
			{
				var settings = new DocumentsSettings (module);
			
				settings.AllowUserSort = XmlUtils.GetNodeValueBoolean (xmlSettings, "allowusersort");
				settings.ShowTitleLink = XmlUtils.GetNodeValueBoolean (xmlSettings, "showtitlelink");
				settings.UseCategoriesList = XmlUtils.GetNodeValueBoolean (xmlSettings, "usecategorieslist");
				settings.CategoriesListName = XmlUtils.GetNodeValue (xmlSettings, "categorieslistname");
				settings.DefaultFolder = Utils.ParseToNullableInt (XmlUtils.GetNodeValue (xmlSettings, "defaultfolder"));
				settings.DisplayColumns = XmlUtils.GetNodeValue (xmlSettings, "displaycolumns");
				settings.SortOrder = XmlUtils.GetNodeValue (xmlSettings, "sortorder");

				// Need Utils.SynchronizeModule() call
			}
		}
Exemple #6
0
 protected void cmdDelete_Click(object sender, EventArgs e)
 {
     if (cboUrls.SelectedItem != null)
     {
         var objUrls = new UrlController();
         objUrls.DeleteUrl(_objPortal.PortalID, cboUrls.SelectedItem.Value);
         LoadUrls(); //we must reload the url list
     }
     _doRenderTypeControls = false; //Must not render on this postback
     _doRenderTypes = false;
     _doChangeURL = false;
     _doReloadFolders = false;
     _doReloadFiles = false;
 }
Exemple #7
0
        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 string GetProperty(string strPropertyName, string strFormat, CultureInfo formatProvider,
                                  UserInfo accessingUser, Scope accessLevel, ref bool propertyNotFound)
        {
            string outputFormat = strFormat == string.Empty ? "g" : strFormat;

            strPropertyName = strPropertyName.ToLowerInvariant();

            if (File != null)
            {
                switch (strPropertyName)
                {
                    case "name":
                        return PropertyAccess.FormatString(File.FileName, strFormat);
                    case "folder":
                        return
                            PropertyAccess.FormatString(
                                FolderManager.Instance.GetFolder( File.FolderId).FolderName ,
                                strFormat);
                    case "path":
                        return
                            PropertyAccess.FormatString(
                                FolderManager.Instance.GetFolder(File.FolderId).FolderPath,
                                strFormat);
                    case "size":
                        return File.Size.ToString(outputFormat, formatProvider);
                    case "sizemb":
                        return (File.Size/1024 ^ 2).ToString(outputFormat, formatProvider);
                    case "extension":
                        return PropertyAccess.FormatString(File.Extension, strFormat);
                }
            }
            if (strPropertyName == "clicks")
            {
                var tracking = new UrlController().GetUrlTracking(_portalId, _fileIdentifier, _moduleId);
                return tracking != null ? tracking.Clicks.ToString(outputFormat, formatProvider) : "";
            }
            propertyNotFound = true;
            return string.Empty;
        }
        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);
            }
        }
        /// <summary>
        /// SaveTabData saves the Tab to the Database
        /// </summary>
        /// <param name="action">The action to perform "edit" or "add"</param>
        /// <history>
        /// 	[cnurse]	9/10/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        public int SaveTabData( string action )
        {
            EventLogController objEventLog = new EventLogController();

            string strIcon = ctlIcon.Url;

            TabController objTabs = new TabController();

            TabInfo objTab = new TabInfo();

            objTab.TabID = TabId;
            objTab.PortalID = PortalId;
            objTab.TabName = txtTabName.Text;
            objTab.Title = txtTitle.Text;
            objTab.Description = txtDescription.Text;
            objTab.KeyWords = txtKeyWords.Text;
            objTab.IsVisible = ! chkHidden.Checked;
            objTab.DisableLink = chkDisableLink.Checked;
            objTab.ParentId = int.Parse( cboTab.SelectedItem.Value );
            objTab.IconFile = strIcon;
            objTab.IsDeleted = false;
            objTab.Url = ctlURL.Url;
            objTab.TabPermissions = dgPermissions.Permissions;
            objTab.SkinSrc = ctlSkin.SkinSrc;
            objTab.ContainerSrc = ctlContainer.SkinSrc;
            objTab.TabPath = Globals.GenerateTabPath(objTab.ParentId, objTab.TabName);
            if( !String.IsNullOrEmpty(txtStartDate.Text) )
            {
                objTab.StartDate = Convert.ToDateTime( txtStartDate.Text );
            }
            else
            {
                objTab.StartDate = Null.NullDate;
            }
            if( !String.IsNullOrEmpty(txtEndDate.Text) )
            {
                objTab.EndDate = Convert.ToDateTime( txtEndDate.Text );
            }
            else
            {
                objTab.EndDate = Null.NullDate;
            }
            int refreshInt;
            if( txtRefreshInterval.Text.Length > 0 && Int32.TryParse(txtRefreshInterval.Text, out refreshInt ) )
            {
                objTab.RefreshInterval = Convert.ToInt32( txtRefreshInterval.Text );
            }
            objTab.PageHeadText = txtPageHeadText.Text;

            if( action == "edit" )
            {
                // trap circular tab reference
                if( objTab.TabID != int.Parse( cboTab.SelectedItem.Value ) && ! IsCircularReference( int.Parse( cboTab.SelectedItem.Value ) ) )
                {
                    objTabs.UpdateTab( objTab );
                    objEventLog.AddLog( objTab, PortalSettings, UserId, "", EventLogController.EventLogType.TAB_UPDATED );
                }
            }
            else // add or copy
            {
                objTab.TabID = objTabs.AddTab( objTab );
                objEventLog.AddLog( objTab, PortalSettings, UserId, "", EventLogController.EventLogType.TAB_CREATED );

                if( int.Parse( cboCopyPage.SelectedItem.Value ) != - 1 )
                {
                    ModuleController objModules = new ModuleController();

                    foreach( DataGridItem objDataGridItem in grdModules.Items )
                    {
                        CheckBox chkModule = (CheckBox)objDataGridItem.FindControl( "chkModule" );
                        if( chkModule.Checked )
                        {
                            int intModuleID = Convert.ToInt32( grdModules.DataKeys[ objDataGridItem.ItemIndex ] );
                            //RadioButton optNew = (RadioButton)objDataGridItem.FindControl( "optNew" );
                            RadioButton optCopy = (RadioButton)objDataGridItem.FindControl( "optCopy" );
                            RadioButton optReference = (RadioButton)objDataGridItem.FindControl( "optReference" );
                            TextBox txtCopyTitle = (TextBox)objDataGridItem.FindControl( "txtCopyTitle" );
                            
                            ModuleInfo objModule = objModules.GetModule( intModuleID, Int32.Parse( cboCopyPage.SelectedItem.Value ), false );
                            if( objModule != null )
                            {
                                if( ! optReference.Checked )
                                {
                                    objModule.ModuleID = Null.NullInteger;
                                }

                                objModule.TabID = objTab.TabID;
                                objModule.ModuleTitle = txtCopyTitle.Text;
                                objModule.ModuleID = objModules.AddModule( objModule );

                                if( optCopy.Checked )
                                {
                                    if( !String.IsNullOrEmpty(objModule.BusinessControllerClass) )
                                    {
                                        object objObject = Reflection.CreateObject( objModule.BusinessControllerClass, objModule.BusinessControllerClass );
                                        if( objObject is IPortable )
                                        {
                                            try
                                            {
                                                string Content = Convert.ToString( ( (IPortable)objObject ).ExportModule( intModuleID ) );
                                                if( !String.IsNullOrEmpty(Content) )
                                                {
                                                    ( (IPortable)objObject ).ImportModule( objModule.ModuleID, Content, objModule.Version, UserInfo.UserID );
                                                }
                                            }
                                            catch( Exception exc )
                                            {
                                                // the export/import operation failed
                                                Exceptions.ProcessModuleLoadException( this, exc );
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    // create the page from a template
                    if( cboTemplate.SelectedItem != null )
                    {
                        if( !String.IsNullOrEmpty(cboTemplate.SelectedItem.Value) )
                        {
                            // open the XML file
                            try
                            {
                                XmlDocument xmlDoc = new XmlDocument();
                                xmlDoc.Load( cboTemplate.SelectedItem.Value );
                                PortalController objPortals = new PortalController();
                                objPortals.ParsePanes( xmlDoc.SelectSingleNode( "//portal/tabs/tab/panes" ), objTab.PortalID, objTab.TabID, PortalTemplateModuleAction.Ignore, new Hashtable() );
                            }
                            catch
                            {
                                // error opening page template
                            }
                        }
                    }
                }
            }

            // url tracking
            UrlController objUrls = new UrlController();
            objUrls.UpdateUrl( PortalId, ctlURL.Url, ctlURL.UrlType, 0, Null.NullDate, Null.NullDate, ctlURL.Log, ctlURL.Track, Null.NullInteger, ctlURL.NewWindow );

            return objTab.TabID;
        }
		private void Update (bool Override)
		{
			try
			{
				// Only Update if Input Data is Valid

				if (Page.IsValid == true)
				{
					if (!Override)
					{
						// Test file exists, security
						if (!CheckFileExists (ctlUrl.Url) || !CheckFileSecurity (ctlUrl.Url))
						{
							this.cmdUpdateOverride.Visible = true;
							this.cmdUpdate.Visible = false;

							// '' Display page-level warning instructing users to click update again if they want to ignore the warning
							DotNetNuke.UI.Skins.Skin.AddPageMessage (this.Page, Localization.GetString ("msgFileWarningHeading.Text", this.LocalResourceFile), DotNetNuke.Services.Localization.Localization.GetString ("msgFileWarning.Text", this.LocalResourceFile), DotNetNuke.UI.Skins.Controls.ModuleMessage.ModuleMessageType.YellowWarning);
							return;
						}
					}

					// Get existing document record
					var objDocument = DocumentsController.GetDocument (ItemID, ModuleId);

					if (objDocument == null)
					{
						// New record
						objDocument = new DocumentInfo ();
						objDocument.ItemId = ItemID;
						objDocument.ModuleId = ModuleId;
						
						objDocument.CreatedByUserId = UserInfo.UserID;
						
						// Default ownerid value for new documents is current user, may be changed
						// by the value of the dropdown list (below)
						objDocument.OwnedByUserId = UserId;
					}
				
					objDocument.IsPublished = checkIsPublished.Checked;
					objDocument.ModifiedByUserId = UserInfo.UserID;

					objDocument.Title = txtName.Text;
					objDocument.Description = txtDescription.Text;
					objDocument.ForceDownload = chkForceDownload.Checked;

					var oldUrl = objDocument.Url;
					objDocument.Url = ctlUrl.Url;
                    objDocument.LinkAttributes = textLinkAttributes.Text;
					
					if (lstOwner.Visible)
					{
						if (lstOwner.SelectedValue != string.Empty)
						{
							objDocument.OwnedByUserId = Convert.ToInt32 (lstOwner.SelectedValue);
						}
						else
						{
							objDocument.OwnedByUserId = -1;
						}
					}
					else
					{
						// User never clicked "change", leave ownedbyuserid as is
					}

					if (txtCategory.Visible)
					{
						objDocument.Category = txtCategory.Text;
					}
					else
					{
						if (lstCategory.SelectedItem.Text == Localization.GetString ("None_Specified"))
						{
							objDocument.Category = "";
						}
						else
						{
							objDocument.Category = lstCategory.SelectedItem.Value;
						}
					}

					// getting sort index
					int sortIndex;
					objDocument.SortOrderIndex = int.TryParse (txtSortIndex.Text, out sortIndex) ? sortIndex : 0;

					#region Update date & time

					var now = DateTime.Now;
					
					if (pickerCreatedDate.SelectedDate != null)
					{
						if (Null.IsNull (ItemID) || objDocument.CreatedDate != pickerCreatedDate.SelectedDate.Value)
							objDocument.CreatedDate = pickerCreatedDate.SelectedDate.Value;
						// else leave CreatedDate as is
					}
					else
					{
						objDocument.CreatedDate = now;
					}

					if (pickerLastModifiedDate.SelectedDate != null)
					{
                        if (!checkDontUpdateLastModifiedDate.Checked)
                        {
                            if (Null.IsNull (ItemID) || objDocument.ModifiedDate != pickerLastModifiedDate.SelectedDate.Value)
    							objDocument.ModifiedDate = pickerLastModifiedDate.SelectedDate.Value;
                            else 
    							// update ModifiedDate
    							objDocument.ModifiedDate = now;
                        }
					}
					else
					{
						objDocument.ModifiedDate = now;
					}

					#endregion

					if (Null.IsNull (ItemID))
					{
						DocumentsController.Add (objDocument);
					}
					else
					{
						DocumentsController.Update (objDocument);
						if (objDocument.Url != oldUrl)
						{
							// delete old URL tracking data
							DocumentsController.DeleteDocumentUrl (oldUrl, 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);

                    Synchronize ();
					
					// Redirect back to the portal home page
					Response.Redirect (Globals.NavigateURL (), true);

				}
				//Module failed to load
			}
			catch (Exception exc)
			{
				Exceptions.ProcessModuleLoadException (this, exc);
			}
		}
        /// <Summary>
        /// This handler handles requests for LinkClick.aspx, but only those specifc
        /// to file serving
        /// </Summary>
        /// <Param name="context">System.Web.HttpContext)</Param>
        public virtual void ProcessRequest( HttpContext context )
        {
            PortalSettings portalSettings = PortalController.GetCurrentPortalSettings();

            // get TabId
            int tabId = -1;
            if (context.Request.QueryString["tabid"] != null)
            {
                tabId = int.Parse(context.Request.QueryString["tabid"]);
            }

            // get ModuleId
            int moduleId = -1;
            if (context.Request.QueryString["mid"] != null)
            {
                moduleId = int.Parse(context.Request.QueryString["mid"]);
            }

            

            // get the URL
            string URL = "";
            bool blnClientCache = true;
            bool blnForceDownload = false;

            if (context.Request.QueryString["fileticket"] != null)
            {
                URL = "FileID=" + UrlUtils.DecryptParameter(context.Request.QueryString["fileticket"]);
            }
            if (context.Request.QueryString["userticket"] != null)
            {
                URL = "UserId=" + UrlUtils.DecryptParameter(context.Request.QueryString["userticket"]);
            }
            if (context.Request.QueryString["link"] != null)
            {
                URL = context.Request.QueryString["link"];
                if (URL.ToLower().StartsWith("fileid="))
                {
                    URL = ""; // restrict direct access by FileID
                }
            }

            if (!String.IsNullOrEmpty(URL))
            {
                TabType UrlType = Globals.GetURLType(URL);

                if (UrlType != TabType.File)
                {
                    URL = Globals.LinkClick(URL, tabId, moduleId, false);
                }

                if (UrlType == TabType.File && URL.ToLower().StartsWith("fileid=") == false)
                {
                    // to handle legacy scenarios before the introduction of the FileServerHandler
                    FileController objFiles = new FileController();
                    URL = "FileID=" + objFiles.ConvertFilePathToFileId(URL, portalSettings.PortalId);
                }

                // get optional parameters
                if (context.Request.QueryString["clientcache"] != null)
                {
                    blnClientCache = bool.Parse(context.Request.QueryString["clientcache"]);
                }

                if ((context.Request.QueryString["forcedownload"] != null) || (context.Request.QueryString["contenttype"] != null))
                {
                    blnForceDownload = bool.Parse(context.Request.QueryString["forcedownload"]);
                }

                // update clicks
                UrlController objUrls = new UrlController();
                objUrls.UpdateUrlTracking(portalSettings.PortalId, URL, moduleId, -1);

                // clear the current response
                context.Response.Clear();

                if (UrlType == TabType.File)
{
                    // serve the file
                    if (tabId == Null.NullInteger)
                    {
                        if (! (FileSystemUtils.DownloadFile(portalSettings.PortalId, int.Parse(UrlUtils.GetParameterValue(URL)), blnClientCache, blnForceDownload)))
                        {
                            context.Response.Write(Services.Localization.Localization.GetString("FilePermission.Error"));
                        }
                    }
                    else
                    {
                        if (! (FileSystemUtils.DownloadFile(portalSettings, int.Parse(UrlUtils.GetParameterValue(URL)), blnClientCache, blnForceDownload)))
                        {
                            context.Response.Write(Services.Localization.Localization.GetString("FilePermission.Error"));
                        }
                    }
                }
                else
                {
                    // redirect to URL
                    context.Response.Redirect(URL, true);
                }
            }
        }
		/*
		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;
            }
        }
		public override void HandleRequest()
		{
			string output = null;
			DialogParams dialogParams = Content.FromJson<DialogParams>(); // This uses the new JSON Extensions in DotNetNuke.Common.Utilities.JsonExtensionsWeb

			string link = dialogParams.LinkUrl;
			dialogParams.LinkClickUrl = link;

			if (dialogParams != null)
			{

				if (! (dialogParams.LinkAction == "GetLinkInfo"))
				{
					if (dialogParams.Track)
					{
						string tempVar = dialogParams.LinkUrl;
						dialogParams.LinkClickUrl = GetLinkClickURL(ref dialogParams, ref tempVar);
						dialogParams.LinkUrl = tempVar;
						UrlTrackingInfo linkTrackingInfo = _urlController.GetUrlTracking(dialogParams.PortalId, dialogParams.LinkUrl, dialogParams.ModuleId);

						if (linkTrackingInfo != null)
						{
							dialogParams.Track = linkTrackingInfo.TrackClicks;
							dialogParams.TrackUser = linkTrackingInfo.LogActivity;
							dialogParams.DateCreated = linkTrackingInfo.CreatedDate.ToString();
							dialogParams.LastClick = linkTrackingInfo.LastClick.ToString();
							dialogParams.Clicks = linkTrackingInfo.Clicks.ToString();
						}
						else
						{
							dialogParams.Track = false;
							dialogParams.TrackUser = false;
						}
						dialogParams.LinkUrl = link;

					}
				}

				switch (dialogParams.LinkAction)
				{
					case "GetLoggingInfo": //also meant for the tracking tab but this is to retrieve the user information
						DateTime logStartDate = DateTime.MinValue;
						DateTime logEndDate = DateTime.MinValue;
						string logText = "<table><tr><th>Date</th><th>User</th></tr><tr><td colspan='2'>The selected date-range did<br /> not return any results.</td></tr>";

						if (DateTime.TryParse(dialogParams.LogStartDate, out logStartDate))
						{
							if (! (DateTime.TryParse(dialogParams.LogEndDate, out logEndDate)))
							{
								logEndDate = logStartDate.AddDays(1);
							}

							UrlController _urlController = new UrlController();
							ArrayList urlLog = _urlController.GetUrlLog(dialogParams.PortalId, GetLinkUrl(ref dialogParams, dialogParams.LinkUrl), dialogParams.ModuleId, logStartDate, logEndDate);

							if (urlLog != null)
							{
								logText = GetUrlLoggingInfo(urlLog);
							}

						}

						dialogParams.TrackingLog = logText;

						break;
					case "GetLinkInfo":
						if (dialogParams.Track)
						{
                            link = link.Replace(@"\", @"/");

							//this section is for when the user clicks ok in the dialog box, we actually create a record for the linkclick urls.
							if (! (dialogParams.LinkUrl.ToLower().Contains("linkclick.aspx")))
							{
								dialogParams.LinkClickUrl = GetLinkClickURL(ref dialogParams, ref link);
							}

							_urlController.UpdateUrl(dialogParams.PortalId, link, GetURLType(Globals.GetURLType(link)), dialogParams.TrackUser, true, dialogParams.ModuleId, false);

						}
						else
						{
							//this section is meant for retrieving/displaying the original links and determining if the links are being tracked(making sure the track checkbox properly checked)
							UrlTrackingInfo linkTrackingInfo = null;

							if (dialogParams.LinkUrl.Contains("fileticket"))
							{
								var queryString = dialogParams.LinkUrl.Split('=');
								var encryptedFileId = queryString[1].Split('&')[0];

								string fileID = UrlUtils.DecryptParameter(encryptedFileId, dialogParams.PortalGuid);
								FileInfo savedFile = _fileController.GetFileById(Int32.Parse(fileID), dialogParams.PortalId);

								linkTrackingInfo = _urlController.GetUrlTracking(dialogParams.PortalId, string.Format("fileID={0}", fileID), dialogParams.ModuleId);
								
							}
                            else if (dialogParams.LinkUrl.ToLowerInvariant().Contains("linkclick.aspx"))
							{
								try
								{
									if (dialogParams.LinkUrl.Contains("?"))
									{
										link = dialogParams.LinkUrl.Split('?')[1].Split('&')[0];
										if(link.Contains("="))
										{
											link = link.Split('=')[1];
										}
									}

									int tabId = 0;
									if (int.TryParse(link, out tabId)) //if it's a tabid get the tab path
									{
										var tabController = new TabController();
										dialogParams.LinkClickUrl = tabController.GetTab(tabId, dialogParams.PortalId, true).FullUrl;
										linkTrackingInfo = _urlController.GetUrlTracking(dialogParams.PortalId, tabId.ToString(), dialogParams.ModuleId);
									}
									else
									{
										dialogParams.LinkClickUrl = HttpContext.Current.Server.UrlDecode(link); //get the actual link
										linkTrackingInfo = _urlController.GetUrlTracking(dialogParams.PortalId, dialogParams.LinkClickUrl, dialogParams.ModuleId);
									}

								}
								catch (Exception ex)
								{
								    Logger.Error(ex);
									dialogParams.LinkClickUrl = dialogParams.LinkUrl;
								}
							}

							if (linkTrackingInfo == null)
							{
								dialogParams.Track = false;
								dialogParams.TrackUser = false;
							}
							else
							{
								dialogParams.Track = linkTrackingInfo.TrackClicks;
								dialogParams.TrackUser = linkTrackingInfo.LogActivity;
							}

						}
						break;
				}
				output = dialogParams.ToJson();
			}

			Response.Write(output);
		}
 private void cmdDisplay_Click(object sender, EventArgs e)
 {
     try
     {
         string strStartDate = txtStartDate.Text;
         if (!String.IsNullOrEmpty(strStartDate))
         {
             strStartDate = strStartDate + " 00:00";
         }
         string strEndDate = txtEndDate.Text;
         if (!String.IsNullOrEmpty(strEndDate))
         {
             strEndDate = strEndDate + " 23:59";
         }
         var objUrls = new UrlController();
         //localize datagrid
         Localization.LocalizeDataGrid(ref grdLog, LocalResourceFile);
         grdLog.DataSource = objUrls.GetUrlLog(PortalSettings.PortalId, lblLogURL.Text, ModuleID, Convert.ToDateTime(strStartDate), Convert.ToDateTime(strEndDate));
         grdLog.DataBind();
     }
     catch (Exception exc) //Module failed to load
     {
         Exceptions.ProcessModuleLoadException(this, exc);
     }
 }
        /// <summary>
        ///   SaveTabData saves the Tab to the Database
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name = "strAction">The action to perform "edit" or "add"</param>
        /// <history>
        ///   [cnurse]	9/10/2004	Updated to reflect design changes for Help, 508 support
        ///   and localisation
        ///   [jlucarino]	2/26/2009	Added CreatedByUserID and LastModifiedByUserID
        /// </history>
        private int SaveTabData(string strAction)
        {
            string strIcon = ctlIcon.Url;
            string strIconLarge = ctlIconLarge.Url;

            var objTabs = new TabController();

            Tab.TabName = txtTabName.Text;
            Tab.Title = txtTitle.Text;
            Tab.Description = txtDescription.Text;
            Tab.KeyWords = txtKeyWords.Text;
            Tab.IsVisible = chkMenu.Checked;
            Tab.DisableLink = chkDisableLink.Checked;

            TabInfo parentTab = null;
            if (cboParentTab.SelectedItem != null)
            {
                var parentTabId = cboParentTab.SelectedItemValueAsInt;
                var controller = new TabController();
                parentTab = controller.GetTab(parentTabId, -1, false);
            }

            if (parentTab != null)
            {
                Tab.PortalID = parentTab.PortalID;
                Tab.ParentId = parentTab.TabID;
            }
            else
            {
                Tab.ParentId = Null.NullInteger;
            }
            Tab.IconFile = strIcon;
            Tab.IconFileLarge = strIconLarge;
            Tab.IsDeleted = false;
            Tab.Url = ctlURL.Url;

            Tab.TabPermissions.Clear();
            if (Tab.PortalID != Null.NullInteger)
            {
                Tab.TabPermissions.AddRange(dgPermissions.Permissions);
            }

            Tab.Terms.Clear();
            Tab.Terms.AddRange(termsSelector.Terms);

            Tab.SkinSrc = pageSkinCombo.SelectedValue;
            Tab.ContainerSrc = pageContainerCombo.SelectedValue;
            Tab.TabPath = Globals.GenerateTabPath(Tab.ParentId, Tab.TabName);

            //Check for invalid
            string invalidType;
            if (!TabController.IsValidTabName(Tab.TabName, out invalidType))
            {
                ShowWarningMessage(string.Format(Localization.GetString(invalidType, LocalResourceFile), Tab.TabName));
                return Null.NullInteger;
            }

            //Validate Tab Path
            if (!IsValidTabPath(Tab, Tab.TabPath))
            {
                return Null.NullInteger;
            }

            //Set Culture Code
            var positionTabId = Null.NullInteger;
            if (cboPositionTab.SelectedItem != null)
            {
                positionTabId = Int32.Parse(cboPositionTab.SelectedItem.Value);
            }

            if (strAction != "edit")
            {
                if (PortalSettings.ContentLocalizationEnabled)
                {
                    switch (cultureTypeList.SelectedValue)
                    {
                        case "Localized":
                            var defaultLocale = LocaleController.Instance.GetDefaultLocale(PortalId);
                            Tab.CultureCode = defaultLocale.Code;
                            break;
                        case "Culture":
                            Tab.CultureCode = PortalSettings.CultureCode;
                            break;
                        default:
                            Tab.CultureCode = Null.NullString;
                            break;
                    }

                    var tabLocale = LocaleController.Instance.GetLocale(Tab.CultureCode) ?? LocaleController.Instance.GetDefaultLocale(PortalId);

                    //Fix parent 
                    if (Tab.ParentId > Null.NullInteger)
                    {
                        parentTab = objTabs.GetTab(Tab.ParentId, PortalId, false);
                        if (parentTab.CultureCode != Tab.CultureCode)
                        {
                            parentTab = objTabs.GetTabByCulture(Tab.ParentId, PortalId, tabLocale);
                        }
                        if (parentTab != null)
                        {
                            Tab.ParentId = parentTab.TabID;
                        }
                    }

                    //Fix position TabId
                    if (positionTabId > Null.NullInteger)
                    {
                        var positionTab = objTabs.GetTab(positionTabId, PortalId, false);
                        if (positionTab.CultureCode != Tab.CultureCode)
                        {
                            positionTab = objTabs.GetTabByCulture(positionTabId, PortalId, tabLocale);
                        }
                        if (positionTab != null)
                        {
                            positionTabId = positionTab.TabID;
                        }
                    }
                }
                else
                {
                    Tab.CultureCode = Null.NullString;
                }
            }

            //Validate Tab Path
            if (string.IsNullOrEmpty(strAction))
            {
                var tabID = TabController.GetTabByTabPath(Tab.PortalID, Tab.TabPath, Tab.CultureCode);

                if (tabID != Null.NullInteger)
                {
                    var existingTab = objTabs.GetTab(tabID, PortalId, false);
                    if (existingTab != null && existingTab.IsDeleted)
                    {
                        UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("TabRecycled", LocalResourceFile), ModuleMessage.ModuleMessageType.YellowWarning);
                    }
                    else
                    {
                        UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("TabExists", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                    }
                    return Null.NullInteger;
                }
            }

            Tab.StartDate = datepickerStartDate.SelectedDate != null ? datepickerStartDate.SelectedDate.Value : Null.NullDate;
            Tab.EndDate = datepickerEndDate.SelectedDate != null ? datepickerEndDate.SelectedDate.Value : Null.NullDate;

            if (Tab.StartDate > Null.NullDate && Tab.EndDate > Null.NullDate && Tab.StartDate.AddDays(1) >= Tab.EndDate)
            {
                UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("InvalidTabDates", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                return Null.NullInteger;
            }

            if (!valRefreshInterval.IsValid)
            {
                return Null.NullInteger;
            }
            Tab.RefreshInterval = txtRefreshInterval.Text == "" ? Null.NullInteger : Convert.ToInt32(txtRefreshInterval.Text);

            if (!valPriorityRequired.IsValid || !valPriority.IsValid)
            {
                return Null.NullInteger;
            }
            Tab.SiteMapPriority = float.Parse(txtPriority.Text);
            Tab.PageHeadText = txtPageHeadText.Text;
            Tab.IsSecure = chkSecure.Checked;
            Tab.PermanentRedirect = chkPermanentRedirect.Checked;

            UpdateTabSettings(Tab);
            if (strAction == "edit")
            {
                // trap circular tab reference
                if (cboParentTab.SelectedItem != null && Tab.TabID != cboParentTab.SelectedItemValueAsInt && !IsCircularReference(cboParentTab.SelectedItemValueAsInt, Tab.PortalID))
                {
                    objTabs.UpdateTab(Tab);
                    if (IsHostMenu && Tab.PortalID != Null.NullInteger)
                    {
                        //Host Tab moved to Portal so clear Host cache
                        objTabs.ClearCache(Null.NullInteger);
                    }
                    if (!IsHostMenu && Tab.PortalID == Null.NullInteger)
                    {
                        //Portal Tab moved to Host so clear portal cache
                        objTabs.ClearCache(PortalId);
                    }
                }
            }
            else
            {
                if (positionTabId == Null.NullInteger)
                {
                    Tab.TabID = objTabs.AddTab(Tab);
                }
                else
                {
                    if (rbInsertPosition.SelectedValue == "After" && positionTabId > Null.NullInteger)
                    {
                        Tab.TabID = objTabs.AddTabAfter(Tab, positionTabId);
                    }
                    else if (rbInsertPosition.SelectedValue == "Before" && positionTabId > Null.NullInteger)
                    {
                        Tab.TabID = objTabs.AddTabBefore(Tab, positionTabId);
                    }
                    else
                    {
                        Tab.TabID = objTabs.AddTab(Tab);
                    }
                }

                //Create Localized versions
                if (PortalSettings.ContentLocalizationEnabled && cultureTypeList.SelectedValue == "Localized")
                {
                    objTabs.CreateLocalizedCopies(Tab);
                    //Refresh tab
                    _tab = objTabs.GetTab(Tab.TabID, Tab.PortalID, true);
                }

                var copyTabId = cboCopyPage.Visible && cboCopyPage.SelectedItem != null ? cboCopyPage.SelectedItemValueAsInt : Null.NullInteger;

                if (copyTabId != Null.NullInteger)
                {
                    var objModules = new ModuleController();
                    ModuleInfo objModule;
                    CheckBox chkModule;
                    RadioButton optCopy;
                    RadioButton optReference;
                    TextBox txtCopyTitle;

                    foreach (DataGridItem objDataGridItem in grdModules.Items)
                    {
                        chkModule = (CheckBox)objDataGridItem.FindControl("chkModule");
                        if (chkModule.Checked)
                        {
                            var intModuleID = Convert.ToInt32(grdModules.DataKeys[objDataGridItem.ItemIndex]);
                            optCopy = (RadioButton)objDataGridItem.FindControl("optCopy");
                            optReference = (RadioButton)objDataGridItem.FindControl("optReference");
                            txtCopyTitle = (TextBox)objDataGridItem.FindControl("txtCopyTitle");

                            objModule = objModules.GetModule(intModuleID, copyTabId, false);
                            ModuleInfo newModule = null;
                            if ((objModule != null))
                            {
                                //Clone module as it exists in the cache and changes we make will update the cached object
                                newModule = objModule.Clone();

                                newModule.TabID = Tab.TabID;
                                newModule.DefaultLanguageGuid = Null.NullGuid;
                                newModule.CultureCode = Tab.CultureCode;
                                newModule.ModuleTitle = txtCopyTitle.Text;

                                if (!optReference.Checked)
                                {
                                    newModule.ModuleID = Null.NullInteger;
                                    objModules.InitialModulePermission(newModule, newModule.TabID, 0);
                                }

                                newModule.ModuleID = objModules.AddModule(newModule);

                                if (optCopy.Checked)
                                {
                                    if (!string.IsNullOrEmpty(newModule.DesktopModule.BusinessControllerClass))
                                    {
                                        var objObject = Reflection.CreateObject(newModule.DesktopModule.BusinessControllerClass, newModule.DesktopModule.BusinessControllerClass);
                                        if (objObject is IPortable)
                                        {
                                            var content = Convert.ToString(((IPortable)objObject).ExportModule(intModuleID));
                                            if (!string.IsNullOrEmpty(content))
                                            {
                                                ((IPortable)objObject).ImportModule(newModule.ModuleID, content, newModule.DesktopModule.Version, UserInfo.UserID);
                                            }
                                        }
                                    }
                                }
                            }

                            if (optReference.Checked)
                            {
                                //Make reference copies on secondary language
                                foreach (var m in objModule.LocalizedModules.Values)
                                {
                                    var newLocalizedModule = m.Clone();
                                    var localizedTab = Tab.LocalizedTabs[m.CultureCode];
                                    newLocalizedModule.TabID = localizedTab.TabID;
                                    newLocalizedModule.CultureCode = localizedTab.CultureCode;
                                    newLocalizedModule.ModuleTitle = txtCopyTitle.Text;
                                    newLocalizedModule.DefaultLanguageGuid = newModule.UniqueId;
                                    newLocalizedModule.ModuleID = objModules.AddModule(newLocalizedModule);
                                }
                            }
                        }
                    }
                }
                else
                {
                    // create the page from a template
                    if (cboTemplate.SelectedItem != null && cboTemplate.SelectedItem.Value != Null.NullInteger.ToString())
                    {
                        var xmlDoc = new XmlDocument();
                        try
                        {
                            // open the XML file
                            var folder = FolderManager.Instance.GetFolder(cboFolders.SelectedItemValueAsInt);
                            if (folder != null)
                                xmlDoc.Load(PortalSettings.HomeDirectoryMapPath + folder.FolderPath + cboTemplate.SelectedValue);
                        }
                        catch (Exception ex)
                        {
                            Exceptions.LogException(ex);

                            Skin.AddModuleMessage(this, Localization.GetString("BadTemplate", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
                            return Null.NullInteger;
                        }
                        TabController.DeserializePanes(xmlDoc.SelectSingleNode("//portal/tabs/tab/panes"), Tab.PortalID, Tab.TabID, PortalTemplateModuleAction.Ignore, new Hashtable());
                        //save tab permissions
                        RibbonBarManager.DeserializeTabPermissions(xmlDoc.SelectNodes("//portal/tabs/tab/tabpermissions/permission"), Tab);

                        var tabIndex = 0;
                        var exceptions = string.Empty;
                        foreach (XmlNode tabNode in xmlDoc.SelectSingleNode("//portal/tabs").ChildNodes)
                        {
                            //Create second tab onward tabs. Note first tab is already created above.
                            if (tabIndex > 0)
                            {
                                try
                                {
                                    TabController.DeserializeTab(tabNode, null, PortalId, PortalTemplateModuleAction.Replace);
                                }
                                catch (Exception ex)
                                {
                                    Exceptions.LogException(ex);
                                    exceptions += string.Format("Template Tab # {0}. Error {1}<br/>", tabIndex + 1, ex.Message);
                                }
                            }
                            else
                            {
                                if (string.IsNullOrEmpty(Tab.SkinSrc) && !String.IsNullOrEmpty(XmlUtils.GetNodeValue(tabNode, "skinsrc", "")))
                                {
                                    Tab.SkinSrc = XmlUtils.GetNodeValue(tabNode, "skinsrc", "");
                                }
                                if (string.IsNullOrEmpty(Tab.ContainerSrc) && !String.IsNullOrEmpty(XmlUtils.GetNodeValue(tabNode, "containersrc", "")))
                                {
                                    Tab.ContainerSrc = XmlUtils.GetNodeValue(tabNode, "containersrc", "");
                                }
                                objTabs.UpdateTab(Tab);
                            }
                            tabIndex++;
                        }

                        if (!string.IsNullOrEmpty(exceptions))
                        {
                            Skin.AddModuleMessage(this, exceptions, ModuleMessage.ModuleMessageType.RedError);
                            return Null.NullInteger;
                        }
                    }
                }
            }

            // url tracking
            var objUrls = new UrlController();
            objUrls.UpdateUrl(PortalId, ctlURL.Url, ctlURL.UrlType, 0, Null.NullDate, Null.NullDate, ctlURL.Log, ctlURL.Track, Null.NullInteger, ctlURL.NewWindow);

            //Clear the Tab's Cached modules
            DataCache.ClearModuleCache(TabId);

            //Update Cached Tabs as TabPath may be needed before cache is cleared
            TabInfo tempTab;
            if (new TabController().GetTabsByPortal(PortalId).TryGetValue(Tab.TabID, out tempTab))
            {
                tempTab.TabPath = Tab.TabPath;
            }

            //Update Custom Url
            if (!Tab.IsSuperTab)
            {
                var tabUrl = Tab.TabUrls.SingleOrDefault(t => t.IsSystem
                                                                && t.HttpStatus == "200"
                                                                && t.SeqNum == 0);
                var url = urlTextBox.Text;


                if (!String.IsNullOrEmpty(url))
                {
                    if (!url.StartsWith("/"))
                    {
                        url = "/" + url;
                    }

                    string currentUrl = String.Empty;
                    var friendlyUrlSettings = new FriendlyUrlSettings(PortalId);
                    if (Tab.TabID > -1 && !Tab.IsSuperTab)
                    {
                        var baseUrl = Globals.AddHTTP(PortalAlias.HTTPAlias) + "/Default.aspx?TabId=" + Tab.TabID;
                        var path = AdvancedFriendlyUrlProvider.ImprovedFriendlyUrl(Tab,
                                                                                    baseUrl,
                                                                                    Globals.glbDefaultPage,
                                                                                    PortalAlias.HTTPAlias,
                                                                                    false, //dnndev-27493 :we want any custom Urls that apply
                                                                                    friendlyUrlSettings,
                                                                                    Guid.Empty);

                        currentUrl = path.Replace(Globals.AddHTTP(PortalAlias.HTTPAlias), "");
                    }

                    if (url != currentUrl)
                    {
                        if (tabUrl == null)
                        {
                            tabUrl = new TabUrlInfo()
                            {
                                TabId = Tab.TabID,
                                SeqNum = 0,
                                PortalAliasId = -1,
                                PortalAliasUsage = PortalAliasUsageType.Default,
                                QueryString = String.Empty,
                                Url = url,
                                HttpStatus = "200",
                                IsSystem = true
                            };
                        }
                        else
                        {
                            tabUrl.Url = url;
                        }

                        //Delete any redirects to the same url
                        foreach (var redirecturl in TestableTabController.Instance.GetTabUrls(Tab.TabID, Tab.PortalID))
                        {
                            if (redirecturl.Url == url && redirecturl.HttpStatus != "200")
                            {
                                TestableTabController.Instance.DeleteTabUrl(redirecturl, Tab.PortalID, false);
                            }
                        }
                        //Save url
                        TestableTabController.Instance.SaveTabUrl(tabUrl, PortalId, true);
                    }
                }
                else
                {
                    if (tabUrl != null)
                    {
                        TestableTabController.Instance.DeleteTabUrl(tabUrl, PortalId, true);
                    }
                }
            }

            return Tab.TabID;
        }
		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);
			}
		}
Exemple #19
0
 private void LoadUrls()
 {
     var objUrls = new UrlController();
     cboUrls.Items.Clear();
     cboUrls.DataSource = objUrls.GetUrls(_objPortal.PortalID);
     cboUrls.DataBind();
 }
		/*
		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 ();
		}
Exemple #21
0
        private void DoRenderTypeControls()
        {
            string _Url = Convert.ToString(ViewState["Url"]);
            string _Urltype = Convert.ToString(ViewState["UrlType"]);
            var objUrls = new UrlController();
            if (!String.IsNullOrEmpty(_Urltype))
            {
                //load listitems
                switch (optType.SelectedItem.Value)
                {
                    case "N": //None
                        URLRow.Visible = false;
                        TabRow.Visible = false;
                        FileRow.Visible = false;
                        UserRow.Visible = false;
                        ImagesRow.Visible = false;
                        break;
                    case "I": //System Image
                        URLRow.Visible = false;
                        TabRow.Visible = false;
                        FileRow.Visible = false;
                        UserRow.Visible = false;
                        ImagesRow.Visible = true;

                        cboImages.Items.Clear();

                        string strImagesFolder = Path.Combine(Globals.ApplicationMapPath, IconController.DefaultIconLocation.Replace('/', '\\'));
                        foreach (string strImage in Directory.GetFiles(strImagesFolder))
                        {
                            string img = strImage.Replace(strImagesFolder, "").Trim('/').Trim('\\');
                            cboImages.Items.Add(new ListItem(img, string.Format("~/{0}/{1}", IconController.DefaultIconLocation, img).ToLower()));
                        }

                        ListItem selecteItem = cboImages.Items.FindByValue(_Url.ToLower());
                        if (selecteItem != null)
                        {
                            selecteItem.Selected = true;
                        }
                        break;

                    case "U": //Url
                        URLRow.Visible = true;
                        TabRow.Visible = false;
                        FileRow.Visible = false;
                        UserRow.Visible = false;
                        ImagesRow.Visible = false;
                        if (String.IsNullOrEmpty(txtUrl.Text))
                        {
                            txtUrl.Text = _Url;
                        }
                        if (String.IsNullOrEmpty(txtUrl.Text))
                        {
                            txtUrl.Text = "http://";
                        }
                        txtUrl.Visible = true;

                        cmdSelect.Visible = 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;
                        ImagesRow.Visible = false;

                        cboTabs.Items.Clear();

                        PortalSettings _settings = PortalController.GetCurrentPortalSettings();
                        cboTabs.DataSource = TabController.GetPortalTabs(_settings.PortalId, Null.NullInteger, !Required, "none available", true, false, false, true, false);
                        cboTabs.DataBind();
                        if (cboTabs.Items.FindByValue(_Url) != null)
                        {
                            cboTabs.Items.FindByValue(_Url).Selected = true;
                        }

                        if (!IncludeActiveTab && cboTabs.Items.FindByValue(_settings.ActiveTab.TabID.ToString()) != null)
                        {
                            cboTabs.Items.FindByValue(_settings.ActiveTab.TabID.ToString()).Attributes.Add("disabled", "disabled");
                        }
                        break;
                    case "F": //file
                        URLRow.Visible = false;
                        TabRow.Visible = false;
                        FileRow.Visible = true;
                        UserRow.Visible = false;
                        ImagesRow.Visible = false;

                        if (ViewState["FoldersLoaded"] == null || _doReloadFolders)
                        {
                            LoadFolders("BROWSE,ADD");
                            ViewState["FoldersLoaded"] = "Y";
                        }
                        if (cboFolders.Items.Count == 0)
                        {
                            lblMessage.Text = Localization.GetString("NoPermission", LocalResourceFile);
                            FileRow.Visible = false;
                            return;
                        }

                        //select folder
                        //We Must check if selected folder has changed because of a property change (Secure, Database)
                        string FileName = string.Empty;
                        string FolderPath = string.Empty;
                        string LastFileName = string.Empty;
                        string LastFolderPath = string.Empty;
                        bool _MustRedrawFiles = false;
                        //Let's try to remember last selection
                        if (ViewState["LastFolderPath"] != null)
                        {
                            LastFolderPath = Convert.ToString(ViewState["LastFolderPath"]);
                        }
                        if (ViewState["LastFileName"] != null)
                        {
                            LastFileName = Convert.ToString(ViewState["LastFileName"]);
                        }
                        if (_Url != string.Empty)
                        {
                            //Let's use the new URL
                            FileName = _Url.Substring(_Url.LastIndexOf("/") + 1);
                            FolderPath = _Url.Replace(FileName, "");
                        }
                        else
                        {
                            //Use last settings
                            FileName = LastFileName;
                            FolderPath = LastFolderPath;
                        }
                        if (cboFolders.Items.FindByValue(FolderPath) != null)
                        {
                            cboFolders.ClearSelection();
                            cboFolders.Items.FindByValue(FolderPath).Selected = true;
                        }
                        else if (cboFolders.Items.Count > 0)
                        {
                            cboFolders.ClearSelection();
                            cboFolders.Items[0].Selected = true;
                            FolderPath = cboFolders.Items[0].Value;
                        }
                        if (ViewState["FilesLoaded"] == null || FolderPath != LastFolderPath || _doReloadFiles)
                        {
                            //Reload files only if property change or not same folder
                            _MustRedrawFiles = true;
                            ViewState["FilesLoaded"] = "Y";
                        }
                        else
                        {
                            if (cboFiles.Items.Count > 0)
                            {
                                if ((Required && String.IsNullOrEmpty(cboFiles.Items[0].Value)) || (!Required && !String.IsNullOrEmpty(cboFiles.Items[0].Value)))
                                {
                                    //Required state has changed, so we need to reload files
                                    _MustRedrawFiles = true;
                                }
                            }
                            else if (!Required)
                            {
                                //Required state has changed, so we need to reload files
                                _MustRedrawFiles = true;
                            }
                        }
                        if (_MustRedrawFiles)
                        {
                            cboFiles.DataSource = GetFileList(!Required);
                            cboFiles.DataBind();
                            if (cboFiles.Items.FindByText(FileName) != null)
                            {
                                cboFiles.ClearSelection();
                                cboFiles.Items.FindByText(FileName).Selected = true;
                            }
                        }
                        cboFiles.Visible = true;
                        txtFile.Visible = false;

                        FolderInfo objFolder = (FolderInfo)FolderManager.Instance.GetFolder(_objPortal.PortalID, FolderPath);
                        cmdUpload.Visible = ShowUpLoad && FolderPermissionController.CanAddFolder(objFolder);

                        SetStorageLocationType();
                        txtUrl.Visible = false;
                        cmdSave.Visible = false;
                        cmdCancel.Visible = false;

                        if (cboFolders.SelectedIndex >= 0)
                        {
                            ViewState["LastFolderPath"] = cboFolders.SelectedValue;
                        }
                        else
                        {
                            ViewState["LastFolderPath"] = "";
                        }
                        if (cboFiles.SelectedIndex >= 0)
                        {
                            ViewState["LastFileName"] = cboFiles.SelectedValue;
                        }
                        else
                        {
                            ViewState["LastFileName"] = "";
                        }
                        break;
                    case "M": //membership users
                        URLRow.Visible = false;
                        TabRow.Visible = false;
                        FileRow.Visible = false;
                        UserRow.Visible = true;
                        ImagesRow.Visible = false;
                        if (String.IsNullOrEmpty(txtUser.Text))
                        {
                            txtUser.Text = _Url;
                        }
                        break;
                }
            }
            else
            {
                URLRow.Visible = false;
                ImagesRow.Visible = false;
                TabRow.Visible = false;
                FileRow.Visible = false;
                UserRow.Visible = false;
            }
        }
        /// <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 );
            }
        }