Пример #1
0
        private void cmdUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid == true)
                {
                    BTBRandomImageInfo objBTBRandomImage = new BTBRandomImageInfo();
                    objBTBRandomImage = ((BTBRandomImageInfo)CBO.InitializeObject(objBTBRandomImage, typeof(BTBRandomImageInfo)));

                    int fileId = Int32.Parse(ctlURL.Url.Substring(7));

                    FileController fileController = new FileController();
                    FileInfo       fi             = fileController.GetFileById(fileId, this.PortalId);
                    objBTBRandomImage.imageSrc = fi.Folder + fi.FileName;
                    objBTBRandomImage.imageAlt = txtAlt.Text;
                    objBTBRandomImage.moduleID = this.ModuleId;
                    objBTBRandomImage.Url      = ctlLink.Url;

                    BTBRandomImageController objCtlBTBRandomImage = new BTBRandomImageController();
                    objCtlBTBRandomImage.Add(objBTBRandomImage);

                    //update the url DNN table with the URL parameters
                    UrlController urlController = new UrlController();
                    urlController.UpdateUrl(this.PortalId, ctlLink.Url, ctlLink.UrlType, false, false,
                                            this.ModuleId, ctlLink.NewWindow);

                    DataBindList();
                }
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
        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 urlTracking = ctrlUrl.GetUrlTracking(portalId, oldUrl, moduleId);
                if (urlTracking != null)
                {
                    // delete old URL tracking data
                    DataProvider.Instance().DeleteUrlTracking(portalId, oldUrl, moduleId);

                    // create new URL tracking data
                    ctrlUrl.UpdateUrl(
                        portalId,
                        document.Url,
                        urlTracking.UrlType,
                        urlTracking.LogActivity,
                        urlTracking.TrackClicks,
                        moduleId,
                        urlTracking.NewWindow);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Imports xml to fill the module data
        /// </summary>
        /// <param name="moduleID">The module ID importing</param>
        /// <param name="content">The data representation to import in an XML string</param>
        /// <param name="version">The version of the export</param>
        /// <param name="userId">The user ID of the user importing the data</param>
        public void ImportModule(int moduleID, string content, string version, int userId)
        {
            var module   = ModuleController.Instance.GetModule(moduleID, DotNetNuke.Common.Utilities.Null.NullInteger, false);
            var portalId = module?.PortalID ?? Null.NullInteger;

            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(content);
            var xmlLinks = xmlDoc.SelectNodes("links/link");

            foreach (XmlNode xmlLink in xmlLinks)
            {
                int  viewOrder = int.TryParse(GetXmlNodeValue(xmlLink, "vieworder"), out viewOrder) ? viewOrder : 0;
                bool newWindow = bool.TryParse(GetXmlNodeValue(xmlLink, "newwindow"), out newWindow) ? newWindow : false;
                Link link      = new Link
                {
                    ModuleId    = moduleID,
                    Title       = GetXmlNodeValue(xmlLink, "title"),
                    Url         = DotNetNuke.Common.Globals.ImportUrl(moduleID, GetXmlNodeValue(xmlLink, "url")),
                    ViewOrder   = viewOrder,
                    Description = GetXmlNodeValue(xmlLink, "description"),
                    GrantRoles  = ConvertToRoleIds(portalId, GetXmlNodeValue(xmlLink, "grantroles")),
                };

                link.NewWindow = newWindow;

                if (bool.TryParse(GetXmlNodeValue(xmlLink, "trackclicks"), out bool trackClicks))
                {
                    link.TrackClicks = trackClicks;
                }
                if (bool.TryParse(GetXmlNodeValue(xmlLink, "logactivity"), out bool logActivity))
                {
                    link.LogActivity = logActivity;
                }

                if (int.TryParse(GetXmlNodeValue(xmlLink, "refreshinterval"), out int refreshInterval))
                {
                    link.RefreshInterval = refreshInterval;
                }

                link.CreatedDate   = DateTime.Now;
                link.CreatedByUser = userId;
                LinkController.DeleteLinkIfItExistsForModule(moduleID, link);
                LinkController.AddLink(link);

                // url tracking
                UrlController objUrls    = new UrlController();
                var           moduleInfo = ModuleController.Instance.GetModule(moduleID, Null.NullInteger, false);
                objUrls.UpdateUrl(
                    moduleInfo.PortalID,
                    link.Url,
                    LinkController.ConvertUrlType(DotNetNuke.Common.Globals.GetURLType(link.Url)),
                    link.LogActivity,
                    link.TrackClicks,
                    moduleID,
                    link.NewWindow);
            }
        }
        /// <summary>
        /// cmdUpdate_Click runs when the update button is clicked
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks></remarks>
        private void CmdUpdateClick(object sender, EventArgs e)
        {
            try
            {
                // verify data
                if (Page.IsValid)
                {
                    AnnouncementInfo announcement;
                    if (Model.IsAddMode)
                    {
                        // new item, create new announcement
                        announcement = new AnnouncementInfo
                        {
                            ItemID          = Model.ItemId,
                            ModuleID        = ModuleContext.ModuleId,
                            PortalID        = ModuleContext.PortalId,
                            CreatedByUserID = ModuleContext.PortalSettings.UserId,
                            CreatedOnDate   = DateTime.Now
                        };
                    }
                    else
                    {
                        // updating existing item, load it
                        announcement = Model.AnnouncementInfo;
                    }

                    announcement.Title                = txtTitle.Text;
                    announcement.ImageSource          = urlImage.FilePath;
                    announcement.Description          = teDescription.Text;
                    announcement.URL                  = ctlURL.Url;
                    announcement.PublishDate          = GetDateTimeValue(publishDate, publishTime, DateTime.Now);
                    announcement.ExpireDate           = GetDateTimeValue(expireDate, expireTime);
                    announcement.LastModifiedByUserID = ModuleContext.PortalSettings.UserId;
                    announcement.LastModifiedOnDate   = DateTime.Now;
                    if (txtViewOrder.Text != "")
                    {
                        announcement.ViewOrder = Convert.ToInt32(txtViewOrder.Text);
                    }

                    UpdateAnnouncement(this, new EditItemEventArgs(announcement));

                    // url tracking
                    var objUrls = new UrlController();
                    objUrls.UpdateUrl(ModuleContext.PortalId, ctlURL.Url, ctlURL.UrlType, ctlURL.Log, ctlURL.Track, ModuleContext.ModuleId, ctlURL.NewWindow);

                    // redirect back to page
                    Response.Redirect(ReturnURL, true);
                }
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Пример #5
0
        /// <summary>
        /// ImportModule implements the IPortable ImportModule Interface
        /// </summary>
        /// <param name="moduleId">The Id of the module to be imported</param>
        /// <history>
        ///		[cnurse]	    17 Nov 2004	documented
        ///		[aglenwright]	18 Feb 2006	Added new fields: Createddate, description,
        ///                             modifiedbyuser, modifieddate, OwnedbyUser, SortorderIndex
        ///                             Added DocumentsSettings
        ///   [togrean]     10 Jul 2007 Fixed issues with importing documet settings since new fileds
        ///                             were added: AllowSorting, default folder, list name
        ///   [togrean]     13 Jul 2007 Added support for importing documents Url tracking options
        /// </history>
        public void ImportModule(int moduleId, string content, string version, int userId)
        {
            var mCtrl  = new ModuleController();
            var module = mCtrl.GetModule(moduleId, Null.NullInteger);

            var xmlDocuments  = Globals.GetContent(content, "documents");
            var documentNodes = xmlDocuments.SelectNodes("document");
            var now           = DateTime.Now;

            foreach (XmlNode documentNode in documentNodes)
            {
                var strUrl   = documentNode ["url"].InnerText;
                var document = new DocumentInfo {
                    ModuleId         = moduleId,
                    Title            = documentNode ["title"].InnerText,
                    Category         = documentNode ["category"].InnerText,
                    Description      = XmlUtils.GetNodeValue(documentNode, "description"),
                    OwnedByUserId    = XmlUtils.GetNodeValueInt(documentNode, "ownedbyuserid"),
                    SortOrderIndex   = XmlUtils.GetNodeValueInt(documentNode, "sortorderindex"),
                    LinkAttributes   = XmlUtils.GetNodeValue(documentNode, "linkattributes"),
                    ForceDownload    = XmlUtils.GetNodeValueBoolean(documentNode, "forcedownload"),
                    StartDate        = GetNodeValueDateNullable(documentNode, "startDate"),
                    EndDate          = GetNodeValueDateNullable(documentNode, "endDate"),
                    CreatedByUserId  = userId,
                    ModifiedByUserId = userId,
                    CreatedDate      = now,
                    ModifiedDate     = now,
                    Url = strUrl.StartsWith("fileid=", StringComparison.InvariantCultureIgnoreCase) ?
                          strUrl : Globals.ImportUrl(moduleId, strUrl)
                };

                DocumentsDataProvider.Instance.Add(document);

                // Update Tracking options
                var urlType = document.Url.StartsWith("fileid=", StringComparison.InvariantCultureIgnoreCase) ? "F" : "U";

                var urlCtrl = new UrlController();
                // If nodes not found, all values will be false
                urlCtrl.UpdateUrl(
                    module.PortalID,
                    document.Url,
                    urlType,
                    XmlUtils.GetNodeValueBoolean(documentNode, "logactivity"),
                    XmlUtils.GetNodeValueBoolean(documentNode, "trackclicks", true),
                    moduleId,
                    XmlUtils.GetNodeValueBoolean(documentNode, "newwindow"));
            }

            ImportSettings(module, content);

            ModuleSynchronizer.Synchronize(module.ModuleID, module.TabModuleID);
        }
Пример #6
0
        /// <summary>
        /// Imports xml to fill the module data
        /// </summary>
        /// <param name="moduleID">The module ID importing</param>
        /// <param name="content">The data representation to import in an XML string</param>
        /// <param name="version">The version of the export</param>
        /// <param name="userId">The user ID of the user importing the data</param>
        public void ImportModule(int moduleID, string content, string version, int userId)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(content);
            var xmlLinks = xmlDoc.SelectNodes("links");

            foreach (XmlNode xmlLink in xmlLinks)
            {
                int  viewOrder = int.TryParse(xmlLink.SelectSingleNode("vieworder").Value, out viewOrder) ? viewOrder : 0;
                bool newWindow = bool.TryParse(xmlLink.SelectSingleNode("newwindow").Value, out newWindow) ? newWindow : false;
                Link link      = new Link
                {
                    ModuleId    = moduleID,
                    Title       = xmlLink.SelectSingleNode("title").Value,
                    Url         = DotNetNuke.Common.Globals.ImportUrl(moduleID, xmlLink.SelectSingleNode("url").Value),
                    ViewOrder   = viewOrder,
                    Description = xmlLink.SelectSingleNode("description").Value
                };

                link.NewWindow = newWindow;

                try
                {
                    link.TrackClicks = bool.Parse(xmlLink.SelectSingleNode("trackclicks").Value);
                }
                catch
                {
                    link.TrackClicks = false;
                }

                link.CreatedDate   = DateTime.Now;
                link.CreatedByUser = userId;
                LinkController.DeleteLinkIfItExistsForModule(moduleID, link);
                LinkController.AddLink(link);

                // url tracking
                UrlController objUrls    = new UrlController();
                var           moduleInfo = ModuleController.Instance.GetModule(moduleID, Null.NullInteger, false);
                objUrls.UpdateUrl(
                    moduleInfo.PortalID,
                    link.Url,
                    LinkController.ConvertUrlType(DotNetNuke.Common.Globals.GetURLType(link.Url)),
                    false,
                    link.TrackClicks,
                    moduleID,
                    link.NewWindow);
            }
        }
Пример #7
0
        protected void buttonImport_Click(object sender, EventArgs e)
        {
            try {
                var fromModule = ModuleController.Instance.GetModule(int.Parse(comboModule.SelectedValue), TabId, false);
                foreach (ListItem item in listDocuments.Items)
                {
                    if (item.Selected)
                    {
                        var document = GetDocument(int.Parse(item.Value), fromModule);
                        if (document != null)
                        {
                            // get original document tracking data
                            var ctrlUrl     = new UrlController();
                            var urlTracking = ctrlUrl.GetUrlTracking(PortalId, document.Url, document.ModuleId);

                            // import document
                            document.ItemId   = Null.NullInteger;
                            document.ModuleId = ModuleId;
                            DocumentsDataProvider.Instance.Add(document);

                            // add new url tracking data
                            if (urlTracking != null)
                            {
                                // WTF: using url.Clicks, url.LastClick, url.CreatedDate overload not working?
                                ctrlUrl.UpdateUrl(PortalId, document.Url, urlTracking.UrlType,
                                                  urlTracking.LogActivity, urlTracking.TrackClicks,
                                                  ModuleId, urlTracking.NewWindow);
                            }
                        }
                    }
                }

                ModuleSynchronizer.Synchronize(ModuleId, TabModuleId);
                Response.Redirect(Globals.NavigateURL(), true);
            }
            catch (Exception ex) {
                Exceptions.ProcessModuleLoadException(this, ex);
            }
        }
Пример #8
0
        private void SaveMedia()
        {
            var objMediaController = new MediaController();
            var objMedia           = new MediaInfo();

            try
            {
                // Update settings in the database
                if (this.radMediaType.SelectedIndex == 0) // standard file system
                {
                    if (string.Equals(ctlURL.UrlType, "F"))
                    {
                        IFileInfo objFile = FileManager.Instance.GetFile(int.Parse(Regex.Match(this.ctlURL.Url, "\\d+").Value, System.Globalization.NumberStyles.Integer));
                        if (objFile != null)
                        {
                            if (string.IsNullOrEmpty(this.txtWidth.Text))
                            {
                                this.txtWidth.Text = objFile.Width.ToString();
                            }
                            if (string.IsNullOrEmpty(this.txtHeight.Text))
                            {
                                this.txtHeight.Text = objFile.Height.ToString();
                            }
                        }
                    }
                }

                var sec = new PortalSecurity();

                objMedia.ModuleID  = ModuleId;
                objMedia.MediaType = this.radMediaType.SelectedIndex;
                switch (this.radMediaType.SelectedIndex)
                {
                case 0:     // standard file system
                    objMedia.Src = this.ctlURL.Url;
                    break;

                case 1:     // embed code
                    objMedia.Src = this.txtEmbed.Text;
                    break;

                case 2:     // oembed url
                    objMedia.Src = this.txtOEmbed.Text;
                    break;
                }

                // ensure that youtube gets formatted correctly
                objMedia.Src = ReformatForYouTube(objMedia.Src);

                objMedia.Alt = sec.InputFilter(this.txtAlt.Text, PortalSecurity.FilterFlag.NoMarkup);
                if (!(string.IsNullOrEmpty(this.txtWidth.Text)))
                {
                    objMedia.Width = int.Parse(sec.InputFilter(this.txtWidth.Text, PortalSecurity.FilterFlag.NoMarkup), System.Globalization.NumberStyles.Integer);
                }
                if (!(string.IsNullOrEmpty(this.txtHeight.Text)))
                {
                    objMedia.Height = int.Parse(sec.InputFilter(this.txtHeight.Text, PortalSecurity.FilterFlag.NoMarkup), System.Globalization.NumberStyles.Integer);
                }
                objMedia.NavigateUrl    = sec.InputFilter(this.ctlNavigateUrl.Url, PortalSecurity.FilterFlag.NoMarkup);
                objMedia.MediaAlignment = int.Parse(sec.InputFilter(this.ddlImageAlignment.SelectedValue, PortalSecurity.FilterFlag.NoMarkup), System.Globalization.NumberStyles.Integer);
                objMedia.AutoStart      = this.chkAutoStart.Checked;
                objMedia.MediaLoop      = this.chkLoop.Checked;
                objMedia.LastUpdatedBy  = this.UserId;
                objMedia.MediaMessage   = sec.InputFilter(this.txtMessage.Text, PortalSecurity.FilterFlag.NoScripting);

                // url tracking
                var objUrls = new UrlController();
                objUrls.UpdateUrl(PortalId, this.ctlNavigateUrl.Url, this.ctlNavigateUrl.UrlType, this.ctlNavigateUrl.Log, this.ctlNavigateUrl.Track, ModuleId, this.ctlNavigateUrl.NewWindow);

                // update settings/preferences
                SaveMediaSettings();

                // add/update
                if (p_isNew)
                {
                    // add new media
                    objMediaController.AddMedia(objMedia);
                }
                else
                {
                    // update existing media
                    objMediaController.UpdateMedia(objMedia);
                }

                // save the update into the journal
                if (PostToJournal)
                {
                    AddMediaUpdateToJournal(objMedia);
                }

                // notify the site administrators
                if (NotifyOnUpdate)
                {
                    SendNotificationToMessageCenter(objMedia);
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.LogException(exc);
                //ProcessModuleLoadException(Me, exc)
            }
        }
        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;
                                if (int.TryParse(link, out tabId))                                     //if it's a tabid get the tab path
                                {
                                    dialogParams.LinkClickUrl = TabController.Instance.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);
        }
        void Update(bool ignoreWarnings)
        {
            try {
                if (Page.IsValid)
                {
                    if (!ignoreWarnings)
                    {
                        if (!CheckFileExists(ctlUrl.Url) || !CheckFileSecurity(ctlUrl.Url))
                        {
                            cmdUpdateOverride.Visible = true;
                            cmdUpdate.Visible         = false;
                            // display warning instructing users to click update again if they want to ignore the warning
                            this.Message("msgFileWarningHeading.Text", "msgFileWarning.Text", MessageType.Warning, true);
                            return;
                        }
                    }

                    // get existing document record
                    var document = DocumentsDataProvider.Instance.GetDocument(itemId, ModuleId);
                    if (document == null)
                    {
                        document = new DocumentInfo {
                            ItemId          = itemId,
                            ModuleId        = ModuleId,
                            CreatedByUserId = UserInfo.UserID,
                            OwnedByUserId   = UserId
                        };
                    }

                    var oldDocument = document.Clone();

                    document.Title            = txtName.Text;
                    document.Description      = txtDescription.Text;
                    document.ForceDownload    = chkForceDownload.Checked;
                    document.Url              = ctlUrl.Url;
                    document.LinkAttributes   = textLinkAttributes.Text;
                    document.ModifiedByUserId = UserInfo.UserID;

                    UpdateDateTime(document, oldDocument);
                    UpdateOwner(document);
                    UpdateCategory(document);

                    int sortIndex;
                    document.SortOrderIndex = int.TryParse(txtSortIndex.Text, out sortIndex) ? sortIndex : 0;

                    if (Null.IsNull(itemId))
                    {
                        DocumentsDataProvider.Instance.Add(document);
                    }
                    else
                    {
                        DocumentsDataProvider.Instance.Update(document);
                        if (document.Url != oldDocument.Url)
                        {
                            // delete old URL tracking data
                            DocumentsDataProvider.Instance.DeleteDocumentUrl(oldDocument.Url, PortalId, ModuleId);
                        }
                    }

                    // add or update URL tracking
                    var ctrlUrl = new UrlController();
                    ctrlUrl.UpdateUrl(PortalId, ctlUrl.Url, ctlUrl.UrlType, ctlUrl.Log, ctlUrl.Track, ModuleId, ctlUrl.NewWindow);

                    var urlHistory = new UrlHistory(Session);
                    urlHistory.StoreUrl(document.Url);

                    ModuleSynchronizer.Synchronize(ModuleId, TabModuleId);

                    if (Null.IsNull(itemId))
                    {
                        this.Message(string.Format(LocalizeString("DocumentAdded.Format"), document.Title), MessageType.Success);
                        multiView.ActiveViewIndex = 1;
                        BindUrlHistory();
                    }
                    else
                    {
                        Response.Redirect(Globals.NavigateURL(), true);
                    }
                }
            } catch (Exception exc) {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Пример #11
0
        /// -----------------------------------------------------------------------------
        ///         ''' <summary>
        ///         ''' cmdUpdate_Click runs when the update button is clicked
        ///         ''' </summary>
        ///         ''' <remarks>
        ///         ''' </remarks>
        ///         ''' <history>
        ///         '''     [cnurse]	9/23/2004	Updated to reflect design changes for Help, 508 support
        ///         '''                       and localisation
        ///         ''' </history>
        ///         ''' -----------------------------------------------------------------------------
        public void cmdUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid == true & ctlURL.Url != "")
                {
                    Link objLink = new Link();

                    // bind text values to object
                    objLink.ItemId        = itemId;
                    objLink.ModuleId      = ModuleId;
                    objLink.CreatedByUser = UserInfo.UserID;
                    objLink.CreatedDate   = DateTime.Now;
                    objLink.Title         = txtTitle.Text;
                    objLink.Url           = ctlURL.Url;

                    int refreshInterval = 0;

                    if (ctlURL.UrlType == "U")
                    {
                        refreshInterval = System.Convert.ToInt32(ddlGetContentInterval.SelectedValue);
                    }

                    objLink.RefreshInterval = refreshInterval;

                    if ((ddlViewOrderLinks.Items.Count > 0))
                    {
                        switch (ddlViewOrder.SelectedValue)
                        {
                        case "B":
                        {
                            objLink.ViewOrder = Convert.ToInt32(ddlViewOrderLinks.SelectedValue) - 1;
                            LinkController.UpdateViewOrder(objLink, -1, this.ModuleId);
                            break;
                        }

                        case "A":
                        {
                            objLink.ViewOrder = Convert.ToInt32(ddlViewOrderLinks.SelectedValue) + 1;
                            LinkController.UpdateViewOrder(objLink, 1, this.ModuleId);
                            break;
                        }

                        default:
                        {
                            objLink.ViewOrder = Null.NullInteger;
                            break;
                        }
                        }
                    }
                    else
                    {
                        objLink.ViewOrder = Null.NullInteger;
                    }

                    objLink.Description = txtDescription.Text;
                    objLink.GrantRoles  = ";";

                    foreach (ListItem cb in cblGrantRoles.Items)
                    {
                        if (cb.Selected)
                        {
                            objLink.GrantRoles += cb.Value + ";";
                        }
                    }

                    if (objLink.GrantRoles.Equals(";"))
                    {
                        objLink.GrantRoles += "0;";
                    }

                    // Create an instance of the Link DB component

                    if (Common.Utilities.Null.IsNull(itemId))
                    {
                        LinkController.AddLink(objLink);
                    }
                    else
                    {
                        LinkController.UpdateLink(objLink);
                    }

                    ModuleController.SynchronizeModule(ModuleId);

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

                    // Redirect back to the portal home page
                    Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(), true);
                }
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Пример #12
0
        /// <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);
        }