public override void ButtonNextClickAction()
    {
        // Standard action - Process payment
        base.ButtonNextClickAction();

        if (ShoppingCartControl.PaymentGatewayProvider.IsPaymentCompleted)
        {
            // Remove current shopping cart data from session and from database
            ShoppingCartControl.CleanUpShoppingCart();

            // Live site
            if (!ShoppingCartControl.IsInternalOrder)
            {
                string url = "";
                if (ShoppingCartControl.RedirectAfterPurchase != "")
                {
                    url = CMSContext.GetUrl(ShoppingCartControl.RedirectAfterPurchase);
                }
                else
                {
                    url = CMSContext.GetUrl("/");
                }

                URLHelper.Redirect(url);
            }
        }
    }
Exemple #2
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            // Do not process
        }
        else
        {
            // If paramater URL is empty, set URL of current document
            string url = Url;
            if (string.IsNullOrEmpty(url) && (CMSContext.CurrentDocument != null))
            {
                TreeNode node = CMSContext.CurrentDocument;
                url = CMSContext.GetUrl(node.NodeAliasPath, node.DocumentUrlPath, CMSContext.CurrentSiteName);
            }
            else
            {
                url = ResolveUrl(url);
            }

            // Register javascript SDK
            ScriptHelper.RegisterFacebookJavascriptSDK(Page, CMSContext.PreferredCultureCode);

            if (UseHTML5)
            {
                ltlComments.Text = "<div class=\"fb-comments\" data-href=\"" + URLHelper.GetAbsoluteUrl(url) + "\" data-num-posts=\"" + Posts + "\" data-width=\"" + Width + "\"" + (!string.IsNullOrEmpty(ColorScheme) ? " data-colorscheme=\"" + ColorScheme + "\"" : "") + "></div>";
            }
            else
            {
                ltlComments.Text = "<fb:comments href=\"" + URLHelper.GetAbsoluteUrl(url) + "\" num_posts=\"" + Posts + "\" width=\"" + Width + "\"" + (!string.IsNullOrEmpty(ColorScheme) ? " colorscheme=\"" + ColorScheme + "\"" : "") + "></fb:comments>";
            }
        }
    }
Exemple #3
0
 /// <summary>
 /// Redirect to group page.
 /// </summary>
 /// <param name="group">Group info</param>
 private static void RedirectToGroupPage(GroupInfo group)
 {
     if ((group != null) && (CMSContext.ViewMode == CMS.PortalEngine.ViewModeEnum.LiveSite))
     {
         URLHelper.Redirect(CMSContext.GetUrl(GroupInfoProvider.GetGroupProfilePath(group.GroupName, CMSContext.CurrentSiteName)));
     }
 }
Exemple #4
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (this.StopProcessing)
        {
            // Do not process
        }
        else
        {
            // If paramater URL is empty, set URL of current document
            string url = Url;
            if (string.IsNullOrEmpty(url) && (CMSContext.CurrentDocument != null))
            {
                TreeNode node = CMSContext.CurrentDocument;
                url = CMSContext.GetUrl(node.NodeAliasPath, node.DocumentUrlPath, CMSContext.CurrentSiteName);
            }
            else
            {
                url = ResolveUrl(url);
            }

            // Get culture code
            string culture = CultureHelper.GetFacebookCulture(CMSContext.PreferredCultureCode);

            ltlComments.Text = "<div id=\"fb-root\"></div><script src=\"http://connect.facebook.net/" + culture + "/all.js#xfbml=1\"></script><fb:comments href=" + URLHelper.GetAbsoluteUrl(url) + " num_posts=" + Posts.ToString() + " width=" + Width.ToString() + "></fb:comments>";
        }
    }
    /// <summary>
    /// Sets up the control.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            // Do nothing
        }
        else
        {
            // If paramater URL is empty, set URL of current document
            string url = Url;
            if (string.IsNullOrEmpty(url) && (CMSContext.CurrentDocument != null))
            {
                TreeNode node = CMSContext.CurrentDocument;
                url = CMSContext.GetUrl(node.NodeAliasPath, node.DocumentUrlPath, CMSContext.CurrentSiteName);
            }
            else
            {
                url = ResolveUrl(url);
            }

            // Get culture code
            string culture = CultureHelper.GetFacebookCulture(CMSContext.PreferredCultureCode);

            // Get FB code
            StringBuilder sb = new StringBuilder();
            sb.Append("<div id=\"fb-root\"></div><script src=\"http://connect.facebook.net/", culture, "/all.js#xfbml=1\"></script><fb:send");
            sb.Append(" href=\"", URLHelper.GetAbsoluteUrl(url), "\"");
            sb.Append(" font=\"", Font, "\"");
            sb.Append(" colorscheme=\"", ColorScheme, "\"");
            sb.Append("></fb:send>");
            ltlSendButtonCode.Text = sb.ToString();
        }
    }
    public override void ButtonBackClickAction()
    {
        // Clean current order payment result when editing existing order and payment was skipped
        //if (this.ShoppingCartControl.CheckoutProcessType == CheckoutProcessEnum.CMSDeskOrderItems)
        //{
        //    CleanUpOrderPaymentResult();
        //}

        // Payment was skipped
        ShoppingCartControl.RaisePaymentSkippedEvent();

        // Remove current shopping cart data from session and from database
        ShoppingCartControl.CleanUpShoppingCart();

        // Live site - skip payment
        if (!ShoppingCartControl.IsInternalOrder)
        {
            string url = "";
            if (ShoppingCartControl.RedirectAfterPurchase != "")
            {
                url = CMSContext.GetUrl(ShoppingCartControl.RedirectAfterPurchase);
            }
            else
            {
                url = CMSContext.GetUrl("/");
            }

            URLHelper.Redirect(url);
        }
    }
Exemple #7
0
    /// <summary>
    /// Creates HTML code for category link.
    /// </summary>
    /// <param name="category">Category object to create link for.</param>
    protected string CreateCategoryPartLink(CategoryInfo category)
    {
        string categoryDisplayName = category.CategoryDisplayName;
        int    categoryId          = category.CategoryID;

        // Get target url
        string url = (String.IsNullOrEmpty(DocumentListUrl) ? URLHelper.CurrentURL : CMSContext.GetUrl(DocumentListUrl));

        // Append category parameter
        if (UseCodeNameInQuery)
        {
            url = URLHelper.AddParameterToUrl(url, "categoryname", category.CategoryName);
        }
        else
        {
            url = URLHelper.AddParameterToUrl(url, "categoryid", categoryId.ToString());
        }

        StringBuilder attrs = new StringBuilder();

        // Append target attribute
        if (!string.IsNullOrEmpty(DocumentListTarget))
        {
            attrs.Append(" target=\"").Append(DocumentListTarget).Append("\"");
        }

        // Append title attribute
        if (RenderLinkTitle)
        {
            attrs.Append(" title=\"").Append(HTMLHelper.HTMLEncode(categoryDisplayName)).Append("\"");
        }

        return(string.Format("<a href=\"{0}\"{1}>{2}</a>", URLHelper.EncodeQueryString(url), attrs, FormatCategoryDisplayName(categoryDisplayName)));
    }
    /// <summary>
    /// Reload data.
    /// </summary>
    public override void ReloadData()
    {
        requestedGroupId = ValidationHelper.GetInteger(ContextMenu.Parameter, 0);

        DataTable table = new DataTable();

        table.Columns.Add("ActionIcon");
        table.Columns.Add("ActionDisplayName");
        table.Columns.Add("ActionScript");

        // Add only if community is present
        if (CommunityPresent)
        {
            // Get resource strings prefix
            string resourcePrefix = ContextMenu.ResourcePrefix;

            // View group profile
            string profileUrl = "";

            // Get group profile URL
            GeneralizedInfo infoObj = ModuleCommands.CommunityGetGroupInfo(requestedGroupId);
            if (infoObj != null)
            {
                profileUrl = ResolveUrl(CMSContext.GetUrl(ModuleCommands.CommunityGetGroupProfilePath(infoObj.ObjectCodeName, CMSContext.CurrentSiteName)));
            }

            table.Rows.Add(new object[] { "groupprofile.png", ResHelper.GetString(resourcePrefix + ".viewgroup|group.viewgroup"), "window.location.replace('" + profileUrl + "');" });
            if (!currentUser.IsGroupMember(requestedGroupId))
            {
                table.Rows.Add(new object[] { "jointhegroup.png", ResHelper.GetString(resourcePrefix + ".joingroup|group.joingroup"), !currentUser.IsPublic() ? "ContextJoinTheGroup(GetContextMenuParameter('" + ContextMenu.MenuID + "'))" : "ContextRedirectToSignInUrl()" });
            }
            else
            {
                table.Rows.Add(new object[] { "leavethegroup.png", ResHelper.GetString(resourcePrefix + ".leavegroup|group.leavegroup"), !currentUser.IsPublic() ? "ContextLeaveTheGroup(GetContextMenuParameter('" + ContextMenu.MenuID + "'))" : "ContextRedirectToSignInUrl()" });
            }

            if (infoObj != null)
            {
                // Display Manage the group link if user is logged as group administrator and user is visiting a group page
                if (currentUser.IsGroupAdministrator(requestedGroupId) || currentUser.IsGlobalAdministrator)
                {
                    string managementUrl = ResolveUrl(TreePathUtils.GetUrl(ModuleCommands.CommunityGetGroupManagementPath(infoObj.ObjectCodeName, CMSContext.CurrentSiteName)));

                    table.Rows.Add(new object[] { "managegroup.png", ResHelper.GetString(resourcePrefix + ".managegroup|group.managegroup"), !currentUser.IsPublic() ? " window.location.replace('" +
                                                  managementUrl + "');" : "ContextRedirectToSignInUrl()" });
                }
            }
        }

        // Add count column
        DataColumn countColumn = new DataColumn();

        countColumn.ColumnName   = "Count";
        countColumn.DefaultValue = table.Rows.Count;

        table.Columns.Add(countColumn);
        repItem.DataSource = table;
        repItem.DataBind();
    }
    /// <summary>
    /// Sets up the control.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            // Do nothing
        }
        else
        {
            // If paramater URL is empty, set URL of current document
            string url = Url;
            if (string.IsNullOrEmpty(url) && (CMSContext.CurrentDocument != null))
            {
                TreeNode node = CMSContext.CurrentDocument;
                url = CMSContext.GetUrl(node.NodeAliasPath, node.DocumentUrlPath, CMSContext.CurrentSiteName);
            }
            else
            {
                url = ResolveUrl(url);
            }
            url = URLHelper.GetAbsoluteUrl(url);

            // Register Facebook javascript SDK
            ScriptHelper.RegisterFacebookJavascriptSDK(Page, CMSContext.PreferredCultureCode);

            // Get FB code
            StringBuilder sb = new StringBuilder();
            if (UseHTML5)
            {
                sb.Append("<div class=\"fb-like\" data-href=\"", url, "\" data-width=\"", Width,
                          "\" data-send=\"", IncludeSendButton, "\" data-layout=\"", LayoutStyle,
                          "\" data-show-faces=\"", ShowFaces, "\" data-action=\"", VerbToDisplay,
                          "\" data-colorscheme=\"", ColorScheme, "\"");

                if (!string.IsNullOrEmpty(Font))
                {
                    sb.Append(" data-font=\"", Font, "\"");
                }
                sb.Append("></div>");
            }
            else
            {
                sb.Append("<fb:like href=\"", url, "\" layout=\"", LayoutStyle, "\" send=\"",
                          IncludeSendButton ? "true" : "false", "\" show_faces=\"", ShowFaces ? "true" : "false",
                          "\" width=\"", Width, "\" action=\"", VerbToDisplay, "\" font=\"",
                          Font, "\" colorscheme=\"", ColorScheme, "\"></fb:like>");
            }
            ltlLikeButtonCode.Text = sb.ToString();
        }
    }
Exemple #10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string defaultAliasPath = SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".CMSDefaultAliasPath");
        string defaultUrl       = CMSContext.GetUrl(defaultAliasPath);

        if (!String.IsNullOrEmpty(defaultUrl))
        {
            defaultUrl = ResolveUrl(defaultUrl);
        }

        RegistrationApproval.SuccessfulApprovalText = GetString("membership.userconfirmed") + " " + "<a href=\"" + defaultUrl + "\" title=\"" + ResHelper.GetString("General.ClickHereToContinue") + "\" >" + ResHelper.GetString("General.ClickHereToContinue") + "</a>";
        RegistrationApproval.WaitingForApprovalText = GetString("mem.reg.SuccessfulApprovalWaitingForAdministratorApproval");

        // Set administrator e-mail
        RegistrationApproval.AdministratorEmail = SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".CMSAdminEmailAddress");
        RegistrationApproval.FromAddress        = SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".CMSNoreplyEmailAddress");
    }
    /// <summary>
    /// CreateURL of current task from current document.
    /// </summary>
    private string CreateTaskURL()
    {
        String url = String.Empty;

        if (ProjectTaskObj != null)
        {
            if (ProjectTaskObj.ProjectTaskProjectID != 0)
            {
                // Find project node url
                ProjectInfo pi = ProjectInfoProvider.GetProjectInfo(ProjectTaskObj.ProjectTaskProjectID);
                if (pi != null)
                {
                    TreeProvider tree     = new TreeProvider(CMSContext.CurrentUser);
                    TreeNode     treeNode = tree.SelectSingleNode(pi.ProjectNodeID);
                    if (treeNode != null)
                    {
                        SiteInfo si = SiteInfoProvider.GetSiteInfo(pi.ProjectSiteID);
                        if (si != null)
                        {
                            // Create absolute URL of project's node
                            url = URLHelper.GetAbsoluteUrl(CMSContext.GetUrl(treeNode.NodeAliasPath, String.Empty, si.SiteName));

                            // Add projectID as parameter
                            url = URLHelper.UpdateParameterInUrl(url, "projectid", ProjectTaskObj.ProjectTaskProjectID.ToString());

                            // Add taskID as parameter
                            url = URLHelper.UpdateParameterInUrl(url, "taskid", ProjectTaskObj.ProjectTaskID.ToString());
                        }
                    }
                }
            }
            else
            {
                // If Ad hoc task create url to current node
                url = URLHelper.GetAbsoluteUrl(URLHelper.CurrentURL);

                // Remove query
                url = URLHelper.RemoveQuery(url);

                // Add task ID
                url = URLHelper.UpdateParameterInUrl(url, "taskid", ProjectTaskObj.ProjectTaskID.ToString());
            }
        }
        return(url);
    }
Exemple #12
0
    /// <summary>
    /// Redirects user to blog post page.
    /// </summary>
    private void RedirectToBlogPost()
    {
        TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);
        TreeNode     node = tree.SelectSingleNode(postGuid, culture, CMSContext.CurrentSiteName);
        string       path = null;

        // Check that requested blog post exists
        if (node != null)
        {
            path = CMSContext.GetUrl(node.NodeAliasPath);
            URLHelper.Redirect(path);
        }
        else
        {
            path = SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".CMSDefaultAliasPath");
            URLHelper.Redirect(CMSContext.GetUrl(path));
        }
    }
Exemple #13
0
 /// <summary>
 /// Item data bound handler.
 /// </summary>
 void gridElem_ItemDataBound(object sender, DataGridItemEventArgs e)
 {
     if (mGlobalNameID != null)
     {
         for (int i = mGlobalNameID.GetLowerBound(0); i <= mGlobalNameID.GetUpperBound(0); i++)
         {
             if (!string.IsNullOrEmpty(mGlobalNameID[i]))
             {
                 Control ctrl = e.Item.FindControl(mGlobalNameID[i]);
                 if (ctrl != null)
                 {
                     ((HyperLink)ctrl).Text        = ((DataRowView)e.Item.DataItem)[mGlobalNameID[i]].ToString();
                     ((HyperLink)ctrl).NavigateUrl = CMSContext.GetUrl(((DataRowView)e.Item.DataItem)["NodeAliasPath"].ToString(), ((DataRowView)e.Item.DataItem)["DocumentUrlPath"].ToString());
                 }
             }
         }
     }
 }
    /// <summary>
    /// Sets up the control.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            // Do nothing
        }
        else
        {
            // If paramater URL is empty, set URL of current document
            string url = Url;
            if (string.IsNullOrEmpty(url) && (CMSContext.CurrentDocument != null))
            {
                TreeNode node = CMSContext.CurrentDocument;
                url = CMSContext.GetUrl(node.NodeAliasPath, node.DocumentUrlPath, CMSContext.CurrentSiteName);
            }
            else
            {
                url = ResolveUrl(url);
            }
            url = URLHelper.GetAbsoluteUrl(url);

            // Register Facebook javascript SDK
            ScriptHelper.RegisterFacebookJavascriptSDK(Page, CMSContext.PreferredCultureCode);

            // Get FB code
            StringBuilder sb = new StringBuilder();
            if (UseHTML5)
            {
                sb.Append("<div class=\"fb-send\" data-href=\"", url, "\" data-colorscheme=\"", ColorScheme, "\"");
                if (!string.IsNullOrEmpty(Font))
                {
                    sb.Append(" data-font=\"", Font, "\"");
                }
                sb.Append("></div>");
            }
            else
            {
                sb.Append("<fb:send href=\"", url, "\" font=\"", Font, "\" colorscheme=\"", ColorScheme, "\"></fb:send>");
            }
            ltlSendButtonCode.Text = sb.ToString();
        }
    }
 /// <summary>
 /// Item data bound handler.
 /// </summary>
 protected void gridItems_ItemDataBound(object sender, DataGridItemEventArgs e)
 {
     if (mGlobalNameID != null)
     {
         for (int i = mGlobalNameID.GetLowerBound(0); i <= mGlobalNameID.GetUpperBound(0); i++)
         {
             if (!string.IsNullOrEmpty(mGlobalNameID[i]))
             {
                 Control ctrl = e.Item.FindControl(mGlobalNameID[i]);
                 if (ctrl != null)
                 {
                     ((HyperLink)ctrl).Text = ((DataRowView)e.Item.DataItem)[mGlobalNameID[i]].ToString();
                     string nodeAlias = (DataHelper.GetDataRowViewValue((DataRowView)e.Item.DataItem, "NodeAliasPath")).ToString();
                     string urlPath   = (DataHelper.GetDataRowViewValue((DataRowView)e.Item.DataItem, "DocumentUrlPath")).ToString();
                     ((HyperLink)ctrl).NavigateUrl = CMSContext.GetUrl(nodeAlias, urlPath);
                 }
             }
         }
     }
 }
Exemple #16
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Initialization
        productId   = QueryHelper.GetInteger("productId", 0);
        skuGuid     = QueryHelper.GetGuid("skuguid", Guid.Empty);
        currentSite = CMSContext.CurrentSite;

        string where = null;
        if (productId > 0)
        {
            where = "NodeSKUID = " + productId;
        }
        else if (skuGuid != Guid.Empty)
        {
            where = "SKUGUID = '" + skuGuid.ToString() + "'";
        }

        if ((where != null) && (currentSite != null))
        {
            TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);
            DataSet      ds   = tree.SelectNodes(currentSite.SiteName, "/%", TreeProvider.ALL_CULTURES, true, "", where);
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                // Ger specified product url
                url = CMSContext.GetUrl(Convert.ToString(ds.Tables[0].Rows[0]["NodeAliasPath"]));
            }
        }

        if (url != "")
        {
            // Redirect to specified product
            URLHelper.Redirect(url);
        }
        else
        {
            // Display error message
            lblInfo.Visible = true;
            lblInfo.Text    = GetString("GetProduct.NotFound");
        }
    }
    /// <summary>
    /// Creates HTML code for category link.
    /// </summary>
    protected string CreateRoot()
    {
        // Get target url
        string url = (String.IsNullOrEmpty(CategoriesPagePath) ? URLHelper.CurrentURL : CMSContext.GetUrl(CategoriesPagePath));

        StringBuilder attrs = new StringBuilder();

        // Append target attribute
        if (!string.IsNullOrEmpty(CategoriesPageTarget))
        {
            attrs.Append(" target=\"").Append(CategoriesPageTarget).Append("\"");
        }

        return(string.Format("<a href=\"{0}\"{1}>{2}</a>", URLHelper.EncodeQueryString(url), attrs, FormatCategoryDisplayName(BreadcrumbsRoot, true)));
    }
 /// <summary>
 /// Returns URL of the document specified by alias path or URL path.
 /// </summary>
 /// <param name="aliasPath">Alias path of the document</param>
 /// <param name="urlPath">Url path of the document</param>
 public static string GetUrl(object aliasPath, object urlPath)
 {
     return(CMSContext.GetUrl(Convert.ToString(aliasPath), Convert.ToString(urlPath)));
 }
    protected void shoppingCartItemSelector_OnAddToShoppingCart(object sender, CancelEventArgs e)
    {
        // If donations page path specified
        if (!String.IsNullOrEmpty(DonationsPagePath))
        {
            // Redirect to donations page
            URLHelper.Redirect(CMSContext.GetUrl(DonationsPagePath));

            // Cancel further processing
            e.Cancel = true;
            return;
        }

        // If donation not selected
        if (DonationGUID == Guid.Empty)
        {
            // Show alert
            ScriptHelper.Alert(Page, GetString("com.donate.donationnotspecified"));

            // Cancel further processing
            e.Cancel = true;
            return;
        }

        // If donate form should be opened in dialog and donation parameters are not fixed
        if (ShowInDialog && !DonationIsFixed)
        {
            // Get donation parameters from hidden fields
            double donationAmount    = ValidationHelper.GetDouble(hdnDonationAmount.Value, 0.0);
            bool   donationIsPrivate = ValidationHelper.GetBoolean(hdnDonationIsPrivate.Value, false);
            int    donationUnits     = ValidationHelper.GetInteger(hdnDonationUnits.Value, 1);

            // If donation parameters set
            if (donationAmount > 0.0)
            {
                // Set donation properties for item to be added
                shoppingCartItemSelector.SetDonationProperties(donationAmount, donationIsPrivate, donationUnits);

                // Clear hidden fields
                hdnDonationAmount.Value    = "";
                hdnDonationIsPrivate.Value = "";
                hdnDonationUnits.Value     = "";
            }
            else
            {
                // Set dialog parameters
                Hashtable dialogParameters = new Hashtable();

                dialogParameters["DonationGUID"]   = DonationGUID.ToString();
                dialogParameters["DonationAmount"] = DonationAmount;

                dialogParameters["DonationAmountElementID"]    = hdnDonationAmount.ClientID;
                dialogParameters["DonationIsPrivateElementID"] = hdnDonationIsPrivate.ClientID;
                dialogParameters["DonationUnitsElementID"]     = hdnDonationUnits.ClientID;

                dialogParameters["ShowDonationAmount"]    = ShowAmountTextbox.ToString();
                dialogParameters["ShowCurrencyCode"]      = ShowCurrencyCode.ToString();
                dialogParameters["ShowDonationUnits"]     = ShowUnitsTextbox.ToString();
                dialogParameters["ShowDonationIsPrivate"] = AllowPrivateDonation.ToString();

                dialogParameters["PostBackEventReference"] = ControlsHelper.GetPostBackEventReference(shoppingCartItemSelector.AddToCartControl, null);

                WindowHelper.Add(DialogIdentifier, dialogParameters);

                // Register startup script that opens donate dialog
                string url = URLHelper.ResolveUrl("~/CMSModules/Ecommerce/CMSPages/Donate.aspx");
                url = URLHelper.AddParameterToUrl(url, "params", DialogIdentifier);

                string startupScript = String.Format("openDonateDialog('{0}')", url);

                ScriptHelper.RegisterStartupScript(Page, typeof(string), "StartupDialogOpen", ScriptHelper.GetScript(startupScript));

                // Cancel further processing
                e.Cancel = true;
            }

            return;
        }

        // If donation properties form is valid
        if (String.IsNullOrEmpty(donationProperties.Validate()))
        {
            // Set donation properties for item to be added
            shoppingCartItemSelector.SetDonationProperties(donationProperties.DonationAmount, donationProperties.DonationIsPrivate, donationProperties.DonationUnits);
        }
        else
        {
            if (donationProperties.HasEditableFieldsVisible)
            {
                if (!donationProperties.ShowDonationAmount)
                {
                    // Display error messega on page
                    lblError.Text = donationProperties.ErrorMessage;
                }
            }
            else
            {
                // Display error message as alert
                ScriptHelper.Alert(Page, donationProperties.ErrorMessage);
            }

            // Cancel further processing
            e.Cancel = true;
        }
    }
    /// <summary>
    /// Creates department forum group.
    /// </summary>
    /// <param name="departmentNode">Department node</param>
    private void CreateDepartmentForumGroup(TreeNode departmentNode)
    {
        // Set general values
        string departmentName = departmentNode.GetDocumentName();
        string suffix         = "";


        #region "Create forum group"

        // Get forum group code name
        string groupCodeName = "Department_" + departmentNode.NodeGUID;

        // Check if forum group with given name already exists
        if (ForumGroupInfoProvider.GetForumGroupInfo(groupCodeName, CMSContext.CurrentSiteID) != null)
        {
            return;
        }

        // Create base URL for forums
        string baseUrl = CMSContext.GetUrl(departmentNode.NodeAliasPath + "/" + FORUM_DOCUMENT_ALIAS);

        ForumGroupInfo forumGroupObj = new ForumGroupInfo();
        forumGroupObj.GroupDescription = "Forum group for " + departmentName + " department.";
        suffix = " forum group";
        forumGroupObj.GroupDisplayName = TextHelper.LimitLength(departmentName, 200 - suffix.Length, "") + suffix;
        forumGroupObj.GroupName        = groupCodeName;
        forumGroupObj.GroupOrder       = 0;
        forumGroupObj.GroupEnableQuote = true;
        forumGroupObj.GroupSiteID      = CMSContext.CurrentSiteID;
        forumGroupObj.GroupBaseUrl     = baseUrl;

        // Additional settings
        forumGroupObj.GroupEnableCodeSnippet   = true;
        forumGroupObj.GroupEnableFontBold      = true;
        forumGroupObj.GroupEnableFontColor     = true;
        forumGroupObj.GroupEnableFontItalics   = true;
        forumGroupObj.GroupEnableFontStrike    = true;
        forumGroupObj.GroupEnableFontUnderline = true;
        forumGroupObj.GroupEnableQuote         = true;
        forumGroupObj.GroupEnableURL           = true;
        forumGroupObj.GroupEnableImage         = true;

        ForumGroupInfoProvider.SetForumGroupInfo(forumGroupObj);

        #endregion


        #region "Create forum"

        string codeName = "Default_department_" + departmentNode.NodeGUID;

        // Check if forum with given name already exists
        if (ForumInfoProvider.GetForumInfo(codeName, CMSContext.CurrentSite.SiteID) != null)
        {
            return;
        }

        ForumInfo forumObj = new ForumInfo();
        forumObj.ForumSiteID        = CMSContext.CurrentSiteID;
        forumObj.ForumIsLocked      = false;
        forumObj.ForumOpen          = true;
        forumObj.ForumDisplayEmails = false;
        forumObj.ForumDescription   = "Forum for " + departmentName + " department.";
        forumObj.ForumRequireEmail  = false;
        suffix = " forum";
        forumObj.ForumDisplayName     = TextHelper.LimitLength(departmentName, 200 - suffix.Length, "") + suffix;
        forumObj.ForumName            = codeName;
        forumObj.ForumGroupID         = forumGroupObj.GroupID;
        forumObj.ForumModerated       = false;
        forumObj.ForumAccess          = 40000;
        forumObj.ForumPosts           = 0;
        forumObj.ForumThreads         = 0;
        forumObj.ForumPostsAbsolute   = 0;
        forumObj.ForumThreadsAbsolute = 0;
        forumObj.ForumOrder           = 0;
        forumObj.ForumUseCAPTCHA      = false;
        forumObj.SetValue("ForumHTMLEditor", null);

        // Set security
        forumObj.AllowAccess       = SecurityAccessEnum.AuthorizedRoles;
        forumObj.AllowAttachFiles  = SecurityAccessEnum.AuthorizedRoles;
        forumObj.AllowMarkAsAnswer = SecurityAccessEnum.AuthorizedRoles;
        forumObj.AllowPost         = SecurityAccessEnum.AuthorizedRoles;
        forumObj.AllowReply        = SecurityAccessEnum.AuthorizedRoles;
        forumObj.AllowSubscribe    = SecurityAccessEnum.AuthorizedRoles;

        if (ForumInfoProvider.LicenseVersionCheck(URLHelper.GetCurrentDomain(), FeatureEnum.Forums, VersionActionEnum.Insert))
        {
            ForumInfoProvider.SetForumInfo(forumObj);
        }

        #endregion
    }
    /// <summary>
    /// SignOut handler.
    /// </summary>
    protected void btnSignOut_Click(object sender, EventArgs e)
    {
        if (StopProcessing)
        {
            // Do not process
        }
        else
        {
            if (CMSContext.CurrentUser.IsAuthenticated())
            {
                CMSContext.LogoutUser();
                string redirectUrl = RedirectToUrl;

                // If the user has registered Windows Live ID
                if (!String.IsNullOrEmpty(CMSContext.CurrentUser.UserSettings.WindowsLiveID))
                {
                    // Get data from auth cookie
                    string[] userData = AuthenticationHelper.GetUserDataFromAuthCookie();

                    // If user has logged in using Windows Live ID, then sign him out from Live too
                    if ((userData != null) && (Array.IndexOf(userData, "liveidlogin") >= 0))
                    {
                        string siteName = CMSContext.CurrentSiteName;

                        // Get LiveID settings
                        string appId  = SettingsKeyProvider.GetStringValue(siteName + ".CMSApplicationID");
                        string secret = SettingsKeyProvider.GetStringValue(siteName + ".CMSApplicationSecret");

                        // Check valid Windows LiveID parameters
                        if ((appId != string.Empty) && (secret != string.Empty))
                        {
                            WindowsLiveLogin wll = new WindowsLiveLogin(appId, secret);

                            // Store info about logout request, for validation logout request
                            SessionHelper.SetValue("liveidlogout", DateTime.Now);

                            // Redirect to Windows Live
                            redirectUrl = wll.GetLogoutUrl();
                        }
                    }
                }

                CMSContext.ViewMode    = ViewModeEnum.LiveSite;
                CMSContext.CurrentUser = null;

                Response.Cache.SetNoStore();
                URLHelper.Redirect(redirectUrl);
            }
            else
            {
                string returnUrl = null;
                string signInUrl = null;

                if (SignInUrl != "")
                {
                    signInUrl = ResolveUrl(CMSContext.GetUrl(CMSContext.ResolveCurrentPath(SignInUrl)));
                }
                else
                {
                    signInUrl = SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".CMSSecuredAreasLogonPage");
                }

                if (ReturnPath != "")
                {
                    returnUrl = ResolveUrl(CMSContext.GetUrl(CMSContext.ResolveCurrentPath(ReturnPath)));
                }
                else
                {
                    returnUrl = URLHelper.CurrentURL;
                }

                if (signInUrl != "")
                {
                    // Prevent multiple returnUrl parameter
                    returnUrl = URLHelper.RemoveParameterFromUrl(returnUrl, "returnUrl");
                    URLHelper.Redirect(URLHelper.UpdateParameterInUrl(signInUrl, "returnurl", returnUrl));
                }
            }
        }
    }
Exemple #22
0
    protected void Page_Load(object sender, EventArgs e)
    {
        CheckUserImpersonate();

        // Facebook Connect sign out
        if (CMSContext.CurrentUser.IsAuthenticated())
        {
            if (QueryHelper.GetInteger("logout", 0) > 0)
            {
                btnSignOut_Click(this, EventArgs.Empty);
                return;
            }
        }

        InitializeVersion();

        // Make 'Site manager' link visible for global administrators
        CurrentUserInfo ui = CMSContext.CurrentUser;

        if ((ui != null) && (ui.UserSettings != null))
        {
            lnkSiteManager.Visible = ui.UserSiteManagerAdmin;
        }

        // Site selector settings
        siteSelector.DropDownSingleSelect.CssClass = "HeaderSiteDrop";
        siteSelector.UpdatePanel.RenderMode        = UpdatePanelRenderMode.Inline;
        siteSelector.AllowAll = false;
        siteSelector.UniSelector.OnSelectionChanged   += SiteSelector_OnSelectionChanged;
        siteSelector.UniSelector.OnBeforeClientChanged = "if (!CheckChanges()) { this.value = this.originalValue; return false; }";
        siteSelector.DropDownSingleSelect.AutoPostBack = true;
        siteSelector.OnlyRunningSites = true;

        if (!RequestHelper.IsPostBack())
        {
            siteSelector.Value = CMSContext.CurrentSiteID;
        }

        // Show only assigned sites for not global admins
        if (!CMSContext.CurrentUser.IsGlobalAdministrator)
        {
            siteSelector.UserId = CMSContext.CurrentUser.UserID;
        }

        section = QueryHelper.GetString("section", string.Empty).ToLower();

        lblUser.Text     = GetString("Header.User");
        lblUserInfo.Text = HTMLHelper.HTMLEncode(CMSContext.CurrentUser.FullName);

        lnkLiveSite.Text = ResHelper.GetString("Header.LiveSite");

        lnkTestingMode.Text        = GetString("cmstesting.headerlink");
        lnkTestingMode.Visible     = SettingsKeyProvider.TestingMode;
        lnkTestingMode.NavigateUrl = "~/CMSPages/GetTestingModeReport.aspx";

        // Initialize variables from query string
        int    nodeId  = QueryHelper.GetInteger("nodeid", 0);
        string culture = QueryHelper.GetText("culture", null);
        string url     = "~";

        // Set url to node from which CMSDesk was opened
        if ((nodeId > 0) && !String.IsNullOrEmpty(culture))
        {
            TreeProvider treeProvider = new TreeProvider(CMSContext.CurrentUser);
            TreeNode     node         = treeProvider.SelectSingleNode(nodeId, culture, false, false);
            if (node != null)
            {
                url = CMSContext.GetUrl(node.NodeAliasPath, node.DocumentUrlPath);
            }
        }
        // Resolve Url and add live site view mode
        url = ResolveUrl(url);
        url = URLHelper.AddParameterToUrl(url, "viewmode", "livesite");

        lnkLiveSite.NavigateUrl = url;
        lnkLiveSite.Target      = "_parent";

        lnkSiteManager.Text        = GetString("Header.SiteManager");
        lnkSiteManager.NavigateUrl = "~/CMSSiteManager/default.aspx";
        lnkSiteManager.Target      = "_parent";

        lnkSiteManagerLogo.NavigateUrl = "~/CMSDesk/default.aspx";
        lnkSiteManagerLogo.Target      = "_parent";

        elemLinks.RedirectURL = URLHelper.CurrentURL;

        BasicTabControlHeader.OnTabCreated += tabElem_OnTabCreated;
        BasicTabControlHeader.UrlTarget     = "cmsdesktop";

        BasicTabControlHeader.QueryParameterName = "section";

        if (RequestHelper.IsWindowsAuthentication())
        {
            pnlSignOut.Visible = false;
            pnlRight.CssClass += " HeaderWithoutSignOut";
        }
        else
        {
            pnlSignOut.BackImageUrl = GetImageUrl("Design/Buttons/SignOutButton.png");
            lblSignOut.Text         = GetString("signoutbutton.signout");

            // Init Facebook Connect and join logout script to sign out button
            string logoutScript = FacebookConnectHelper.FacebookConnectInitForSignOut(CMSContext.CurrentSiteName, ltlFBConnectScript);
            if (!String.IsNullOrEmpty(logoutScript))
            {
                // If Facebook Connect initialized include 'CheckChanges()' to logout script
                logoutScript = "if (CheckChanges()) { " + logoutScript + " } return false; ";
            }
            else
            {
                // If Facebook Connect not initialized just return 'CheckChanges()' script
                logoutScript = "return CheckChanges();";
            }
            lnkSignOut.OnClientClick = logoutScript;
        }

        // Displays windows azure and EMS icons
        if (AzureHelper.IsRunningOnAzure && SettingsKeyProvider.GetBoolValue(CMSContext.CurrentSiteName + ".CMSShowAzureLogo"))
        {
            imgWindowsAzure.Visible  = true;
            imgWindowsAzure.ImageUrl = GetImageUrl("General/IconWindowsAzure.png");
            pnlExtraIcons.Visible    = true;
        }
        if (LicenseHelper.CurrentEdition == ProductEditionEnum.EnterpriseMarketingSolution)
        {
            imgEnterpriseSolution.Visible  = true;
            imgEnterpriseSolution.ImageUrl = GetImageUrl("General/IconEnterpriseSolution.png");
            pnlExtraIcons.Visible          = true;
        }
    }
Exemple #23
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            // Do nothing
        }
        else
        {
            try
            {
                // Prepare alias path
                aliasPath = AliasPath;
                if (String.IsNullOrEmpty(aliasPath))
                {
                    aliasPath = "/%";
                }
                aliasPath = CMSContext.ResolveCurrentPath(aliasPath);

                // Prepare site name
                siteName = SiteName;
                if (String.IsNullOrEmpty(siteName))
                {
                    siteName = CMSContext.CurrentSiteName;
                }

                // Prepare culture code
                cultureCode = CultureCode;
                if (String.IsNullOrEmpty(cultureCode))
                {
                    cultureCode = CMSContext.PreferredCultureCode;
                }

                string renderedTags = null;

                // Try to get data from cache
                using (CachedSection <string> cs = new CachedSection <string>(ref renderedTags, this.CacheMinutes, true, this.CacheItemName, "tagcloud", TagGroupName, OrderBy, SelectTopN, DocumentListPath, TagSeparator, QueryStringName, MaxTagSize, MinTagSize, "documents", siteName, aliasPath, CacheHelper.GetCultureCacheKey(cultureCode), CombineWithDefaultCulture, WhereCondition, SelectOnlyPublished, MaxRelativeLevel))
                {
                    if (cs.LoadData)
                    {
                        // Get the correct range
                        int maxSize = Math.Max(MaxTagSize, MinTagSize);
                        int minSize = Math.Min(MaxTagSize, MinTagSize);

                        // Get the tags
                        SiteInfo si     = SiteInfoProvider.GetSiteInfo(siteName);
                        int      siteId = 0;
                        if (si != null)
                        {
                            siteId = si.SiteID;
                        }

                        // Get tag group info
                        tgi = TagGroupInfoProvider.GetTagGroupInfo(TagGroupName, siteId);

                        // Get the data
                        DataSet ds = null;
                        if (!this.UseDocumentFilter)
                        {
                            // Get the tag group
                            if (tgi != null)
                            {
                                // Get the tags for group
                                ds = TagInfoProvider.GetTags("TagGroupID = " + tgi.TagGroupID, OrderBy, SelectTopN);
                            }
                        }
                        else
                        {
                            // Get the tags for documents
                            string comleteWhere = TreeProvider.GetCompleteWhereCondition(siteName, aliasPath, cultureCode, CombineWithDefaultCulture, WhereCondition, SelectOnlyPublished, MaxRelativeLevel);
                            ds = TagInfoProvider.GetTags(TagGroupName, siteId, comleteWhere, OrderBy, SelectTopN);
                        }

                        // DS must have at least three columns (fist for IDs, second for names, third for counts)
                        if (!DataHelper.DataSourceIsEmpty(ds))
                        {
                            // First we need to find the maximum and minimum
                            int max = Int32.MinValue;
                            int min = Int32.MaxValue;
                            foreach (DataRow dr in ds.Tables[0].Rows)
                            {
                                int tagCount = ValidationHelper.GetInteger(dr["TagCount"], 0);
                                max = Math.Max(tagCount, max);
                                min = Math.Min(tagCount, min);
                            }

                            // Base URL of the links
                            string url;
                            if (String.IsNullOrEmpty(DocumentListPath))
                            {
                                url = URLHelper.CurrentURL;
                            }
                            else
                            {
                                url = CMSContext.GetUrl(CMSContext.ResolveCurrentPath(DocumentListPath));
                            }
                            url = URLHelper.ResolveUrl(url);

                            // Now generate the tags
                            int count = ds.Tables[0].Rows.Count;

                            StringBuilder sb    = new StringBuilder(count * 100);
                            int           index = 0;

                            // Process the tags
                            foreach (DataRow dr in ds.Tables[0].Rows)
                            {
                                if (index > 0)
                                {
                                    sb.Append(TagSeparator + "\n");
                                }

                                // Count the percentage and get the final size of the tag
                                int tagCount  = ValidationHelper.GetInteger(dr["TagCount"], 0);
                                int val       = (min == max ? 100 : (((tagCount - min) * 100) / (max - min)));
                                int pixelSize = minSize + ((val * (maxSize - minSize)) / 100);

                                // Create the link with query string parameter
                                string paramUrl = URLHelper.AddParameterToUrl(url, QueryStringName, ValidationHelper.GetString(dr["TagID"], ""));
                                sb.Append("<span><a href=\"" + HTMLHelper.HTMLEncode(paramUrl) + "\" style=\"font-size:" + pixelSize.ToString() + "px;\" >" + HTMLHelper.HTMLEncode(dr["TagName"].ToString()) + "</a></span>");

                                index++;
                            }

                            renderedTags = sb.ToString();
                        }

                        // Save to cache
                        if (cs.Cached)
                        {
                            cs.CacheDependency = GetCacheDependency();
                            cs.Data            = renderedTags;
                        }
                    }
                }

                if (String.IsNullOrEmpty(renderedTags))
                {
                    // Ensure no data behaviour
                    if (HideControlForZeroRows)
                    {
                        Visible = false;
                    }
                    else
                    {
                        renderedTags = ZeroRowsText;
                    }
                }

                // Display the tags
                ltlTags.Text = renderedTags;
            }
            catch (Exception ex)
            {
                // Display the error
                ltlTags.Text = "<div style=\"color: red\">" + ex.Message + "</div>";
            }
        }
    }
Exemple #24
0
    private void ReloadData()
    {
        if (Node != null)
        {
            // Log activities checkboxes
            if (!RequestHelper.IsPostBack())
            {
                bool?logVisit = Node.DocumentLogVisitActivity;
                chkLogPageVisit.Checked = (logVisit == true);
                if (Node.NodeParentID > 0)  // Init "inherit" option for child nodes (and hide option for root)
                {
                    chkPageVisitInherit.Checked = (logVisit == null);
                    if (logVisit == null)
                    {
                        chkPageVisitInherit_CheckedChanged(null, EventArgs.Empty);
                    }
                }
                chkLogPageVisit.Enabled = !chkPageVisitInherit.Checked;
            }

            // Check modify permission
            canEdit = (CMSContext.CurrentUser.IsAuthorizedPerDocument(Node, NodePermissionsEnum.Modify) != AuthorizationResultEnum.Denied);

            // Show document group owner selector
            if (ModuleEntry.IsModuleLoaded(ModuleEntry.COMMUNITY) && canEditOwner && LicenseHelper.CheckFeature(URLHelper.GetCurrentDomain(), FeatureEnum.Groups))
            {
                plcOwnerGroup.Controls.Clear();
                // Initialize table
                TableRow  rowOwner     = new TableRow();
                TableCell cellTitle    = new TableCell();
                TableCell cellSelector = new TableCell();

                // Initialize caption
                LocalizedLabel lblOwnerGroup = new LocalizedLabel();
                lblOwnerGroup.EnableViewState = false;
                lblOwnerGroup.ResourceString  = "community.group.documentowner";
                lblOwnerGroup.ID = "lblOwnerGroup";
                cellTitle.Controls.Add(lblOwnerGroup);

                // Initialize selector
                fcDocumentGroupSelector                = (FormEngineUserControl)Page.LoadUserControl("~/CMSAdminControls/UI/Selectors/DocumentGroupSelector.ascx");
                fcDocumentGroupSelector.ID             = "fcDocumentGroupSelector";
                fcDocumentGroupSelector.StopProcessing = pnlUIOwner.IsHidden;
                cellSelector.Controls.Add(fcDocumentGroupSelector);
                fcDocumentGroupSelector.Value = ValidationHelper.GetInteger(Node.GetValue("NodeGroupID"), 0);
                fcDocumentGroupSelector.SetValue("siteid", CMSContext.CurrentSiteID);
                fcDocumentGroupSelector.SetValue("nodeid", Node.NodeID);

                // Add controls to containers
                rowOwner.Cells.Add(cellTitle);
                rowOwner.Cells.Add(cellSelector);
                plcOwnerGroup.Controls.Add(rowOwner);
                plcOwnerGroup.Visible = true;
            }

            // Show owner editing only when authorized to change the permissions
            if (canEditOwner)
            {
                lblOwner.Visible = false;
                usrOwner.Visible = true;
                usrOwner.SetValue("AdditionalUsers", new int[] { Node.NodeOwner });
            }
            else
            {
                usrOwner.Visible = false;
            }

            if (!RequestHelper.IsPostBack())
            {
                if (canEditOwner)
                {
                    usrOwner.Value = Node.GetValue("NodeOwner");
                }
            }

            // Load the data
            lblName.Text      = HttpUtility.HtmlEncode(Node.GetDocumentName());
            lblNamePath.Text  = HttpUtility.HtmlEncode(Convert.ToString(Node.GetValue("DocumentNamePath")));
            lblAliasPath.Text = Convert.ToString(Node.NodeAliasPath);
            string typeName = DataClassInfoProvider.GetDataClass(Node.NodeClassName).ClassDisplayName;
            lblType.Text   = HttpUtility.HtmlEncode(ResHelper.LocalizeString(typeName));
            lblNodeID.Text = Convert.ToString(Node.NodeID);

            // Modifier
            SetUserLabel(lblLastModifiedBy, "DocumentModifiedByUserId");

            // Get modified time
            TimeZoneInfo usedTimeZone = null;
            DateTime     lastModified = ValidationHelper.GetDateTime(Node.GetValue("DocumentModifiedWhen"), DateTimeHelper.ZERO_TIME);
            lblLastModified.Text = TimeZoneHelper.GetCurrentTimeZoneDateTimeString(lastModified, CMSContext.CurrentUser, CMSContext.CurrentSite, out usedTimeZone);
            ScriptHelper.AppendTooltip(lblLastModified, TimeZoneHelper.GetGMTLongStringOffset(usedTimeZone), "help");

            if (!canEditOwner)
            {
                // Owner
                SetUserLabel(lblOwner, "NodeOwner");
            }

            // Creator
            SetUserLabel(lblCreatedBy, "DocumentCreatedByUserId");
            DateTime createdWhen = ValidationHelper.GetDateTime(Node.GetValue("DocumentCreatedWhen"), DateTimeHelper.ZERO_TIME);
            lblCreated.Text = TimeZoneHelper.GetCurrentTimeZoneDateTimeString(createdWhen, CMSContext.CurrentUser, CMSContext.CurrentSite, out usedTimeZone);
            ScriptHelper.AppendTooltip(lblCreated, TimeZoneHelper.GetGMTLongStringOffset(usedTimeZone), "help");


            // URL
            string liveUrl = Node.IsLink ? CMSContext.GetUrl(Node.NodeAliasPath, null) : CMSContext.GetUrl(Node.NodeAliasPath, Node.DocumentUrlPath);
            lnkLiveURL.Text        = URLHelper.ResolveUrl(liveUrl, true, false);
            lnkLiveURL.NavigateUrl = URLHelper.ResolveUrl(liveUrl);

            bool isRoot = (Node.NodeClassName.ToLowerCSafe() == "cms.root");

            // Preview URL
            if (!isRoot)
            {
                plcPreview.Visible = true;
                string path = canEdit ? "/CMSModules/CMS_Content/Properties/resetlink.png" : "/CMSModules/CMS_Content/Properties/resetlinkdisabled.png";
                btnResetPreviewGuid.ImageUrl      = GetImageUrl(path);
                btnResetPreviewGuid.ToolTip       = GetString("GeneralProperties.InvalidatePreviewURL");
                btnResetPreviewGuid.ImageAlign    = ImageAlign.AbsBottom;
                btnResetPreviewGuid.Click        += btnResetPreviewGuid_Click;
                btnResetPreviewGuid.OnClientClick = "if(!confirm('" + GetString("GeneralProperties.GeneratePreviewURLConf") + "')){return false;}";

                InitPreviewUrl();
            }

            lblGUID.Text    = Convert.ToString(Node.NodeGUID);
            lblDocGUID.Text = (Node.DocumentGUID == Guid.Empty) ? ResHelper.Dash : Node.DocumentGUID.ToString();
            lblDocID.Text   = Convert.ToString(Node.DocumentID);

            // Culture
            CultureInfo ci = CultureInfoProvider.GetCultureInfo(Node.DocumentCulture);
            lblCulture.Text = ((ci != null) ? ResHelper.LocalizeString(ci.CultureName) : Node.DocumentCulture);

            lblPublished.Text = (Node.IsPublished ? "<span class=\"DocumentPublishedYes\">" + GetString("General.Yes") + "</span>" : "<span class=\"DocumentPublishedNo\">" + GetString("General.No") + "</span>");

            if (!RequestHelper.IsPostBack())
            {
                // Init radio buttons for cache settings
                if (isRoot)
                {
                    radInherit.Visible   = false;
                    radFSInherit.Visible = false;
                    chkCssStyle.Visible  = false;
                }

                string cacheMinutes = "";

                switch (Node.NodeCacheMinutes)
                {
                case -1:
                    // Cache is off
                {
                    radNo.Checked      = true;
                    radYes.Checked     = false;
                    radInherit.Checked = false;
                    if (!isRoot)
                    {
                        radInherit.Checked = true;
                        radNo.Checked      = false;
                    }
                }
                break;

                case 0:
                    // Cache is off
                    radNo.Checked      = true;
                    radYes.Checked     = false;
                    radInherit.Checked = false;
                    break;

                default:
                    // Cache is enabled
                    radNo.Checked      = false;
                    radYes.Checked     = true;
                    radInherit.Checked = false;
                    cacheMinutes       = Node.NodeCacheMinutes.ToString();
                    break;
                }

                // Set secured radio buttons
                switch (Node.NodeAllowCacheInFileSystem)
                {
                case 0:
                    radFSNo.Checked = true;
                    break;

                case 1:
                    radFSYes.Checked = true;
                    break;

                default:
                    if (!isRoot)
                    {
                        radFSInherit.Checked = true;
                    }
                    else
                    {
                        radFSYes.Checked = true;
                    }
                    break;
                }

                txtCacheMinutes.Text = cacheMinutes;

                if (!radYes.Checked)
                {
                    txtCacheMinutes.Enabled = false;
                }

                if (Node.GetValue("DocumentStylesheetID") == null)
                {
                    // If default site not exist edit is set to -1 - disabled
                    if (CMSContext.CurrentSiteStylesheet != null)
                    {
                        ctrlSiteSelectStyleSheet.Value = "default";
                    }
                    else
                    {
                        ctrlSiteSelectStyleSheet.Value = -1;
                    }
                }
                else
                {
                    // If stylesheet is inherited from parent document
                    if (ValidationHelper.GetInteger(Node.GetValue("DocumentStylesheetID"), 0) == -1)
                    {
                        if (!isRoot)
                        {
                            chkCssStyle.Checked = true;

                            // Get parent stylesheet
                            string value = PageInfoProvider.GetParentProperty(CMSContext.CurrentSite.SiteID, Node.NodeAliasPath, "(DocumentStylesheetID <> -1 OR DocumentStylesheetID IS NULL) AND DocumentCulture = N'" + SqlHelperClass.GetSafeQueryString(Node.DocumentCulture, false) + "'", "DocumentStylesheetID");

                            if (String.IsNullOrEmpty(value))
                            {
                                // If default site stylesheet not exist edit is set to -1 - disabled
                                if (CMSContext.CurrentSiteStylesheet != null)
                                {
                                    ctrlSiteSelectStyleSheet.Value = "default";
                                }
                                else
                                {
                                    ctrlSiteSelectStyleSheet.Value = -1;
                                }
                            }
                            else
                            {
                                // Set parent stylesheet to current document
                                ctrlSiteSelectStyleSheet.Value = value;
                            }
                        }
                    }
                    else
                    {
                        ctrlSiteSelectStyleSheet.Value = Node.GetValue("DocumentStylesheetID");
                    }
                }
            }

            // Disable new button if document inherit stylesheet
            bool disableCssSelector = (!isRoot && chkCssStyle.Checked);
            ctrlSiteSelectStyleSheet.Enabled          = !disableCssSelector;
            ctrlSiteSelectStyleSheet.ButtonNewEnabled = !disableCssSelector;

            // Initialize Rating control
            RefreshCntRatingResult();

            double rating = 0.0f;
            if (Node.DocumentRatings > 0)
            {
                rating = Node.DocumentRatingValue / Node.DocumentRatings;
            }
            ratingControl.MaxRating     = 10;
            ratingControl.CurrentRating = rating;
            ratingControl.Visible       = true;
            ratingControl.Enabled       = false;

            // Initialize Reset button for rating
            btnResetRating.Text          = GetString("general.reset");
            btnResetRating.OnClientClick = "if (!confirm(" + ScriptHelper.GetString(GetString("GeneralProperties.ResetRatingConfirmation")) + ")) return false;";

            object[] param = new object[1];
            param[0] = Node.DocumentID;

            plcAdHocForums.Visible = hasAdHocForum;
            plcAdHocBoards.Visible = hasAdHocBoard;

            if (!canEdit)
            {
                // Disable form editing
                DisableFormEditing();
            }
        }
        else
        {
            btnResetRating.Visible = false;
        }
    }
Exemple #25
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get the node ID
        int nodeId = QueryHelper.GetInteger("nodeid", 0);

        if (!RequestHelper.IsPostBack())
        {
            try
            {
                viewpage = "edit.aspx" + URLHelper.Url.Query;

                string action = QueryHelper.GetString("action", "").ToLower();

                switch (action)
                {
                default:
                    // Check if new document desired
                    bool          newdocument = (action == "new");
                    DataClassInfo classInfo   = null;
                    if (newdocument)
                    {
                        // Get the class ID
                        int classId = QueryHelper.GetInteger("classid", 0);
                        classInfo = DataClassInfoProvider.GetDataClass(classId);
                    }
                    else
                    {
                        // Get the document
                        TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);
                        node = tree.SelectSingleNode(nodeId);
                        if (node != null)
                        {
                            classInfo = DataClassInfoProvider.GetDataClass(node.NodeClassName);
                        }
                    }

                    // Check the editing page change
                    if (classInfo != null)
                    {
                        if (CMSContext.ViewMode == ViewModeEnum.EditForm || newdocument)
                        {
                            // If new document, check if new page URL is set
                            if (newdocument)
                            {
                                if (!string.IsNullOrEmpty(classInfo.ClassNewPageURL))
                                {
                                    viewpage = ResolveUrl(classInfo.ClassNewPageURL) + URLHelper.Url.Query;
                                }
                            }
                            // If existing document, check if editing page URL is set
                            else if (!string.IsNullOrEmpty(classInfo.ClassEditingPageURL))
                            {
                                viewpage = ResolveUrl(classInfo.ClassEditingPageURL) + URLHelper.Url.Query;
                            }
                        }
                        else if (CMSContext.ViewMode == ViewModeEnum.Edit)
                        {
                            // Check if view page URL is set
                            if (!string.IsNullOrEmpty(classInfo.ClassViewPageUrl))
                            {
                                viewpage = ResolveUrl(classInfo.ClassViewPageUrl) + URLHelper.Url.Query;
                            }
                            else
                            {
                                viewpage = ResolveUrl(CMSContext.GetUrl(node.NodeAliasPath, node.DocumentUrlPath));
                            }
                        }
                        else
                        {
                            viewpage = ResolveUrl(CMSContext.GetUrl(node.NodeAliasPath, node.DocumentUrlPath));
                        }
                    }
                    break;
                }

                ltlScript.Text += ScriptHelper.GetScript("parent.frames['" + controlFrame + "'].location.replace('" + viewpage + "');");
            }
            catch (Exception ex)
            {
                ltlScript.Text += ScriptHelper.GetAlertScript("[EditToolbar.aspx]: " + ex.Message);
            }
        }

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ControlFunctions", ScriptHelper.GetScript(
                                                   "function SaveDocument(nodeId, createAnother) { " + ClientScript.GetPostBackEventReference(btnSave, null) + "; }\n" +
                                                   "function Approve(nodeId) { " + ClientScript.GetPostBackEventReference(btnApprove, null) + "; }\n" +
                                                   "function CheckIn(nodeId) { " + ClientScript.GetPostBackEventReference(btnCheckIn, null) + "; }\n"
                                                   ));
    }
    /// <summary>
    /// Creates HTML code for category link.
    /// </summary>
    /// <param name="categoryDisplayName">Category display name.</param>
    /// <param name="categoryId">ID of the category.</param>
    protected string CreateCategoryPartLink(string categoryDisplayName, int categoryId, bool encode)
    {
        // Get target url
        string url = (String.IsNullOrEmpty(CategoriesPagePath) ? URLHelper.CurrentURL : CMSContext.GetUrl(CategoriesPagePath));

        if (categoryId > 0)
        {
            // Append category parameter
            url = URLHelper.AddParameterToUrl(url, "categoryId", categoryId.ToString());
        }

        StringBuilder attrs = new StringBuilder();

        // Append target attribute
        if (!string.IsNullOrEmpty(CategoriesPageTarget))
        {
            attrs.Append(" target=\"").Append(CategoriesPageTarget).Append("\"");
        }

        // Append title attribute
        if (RenderLinkTitle && encode)
        {
            // Encode category name
            attrs.Append(" title=\"").Append(HTMLHelper.HTMLEncode(categoryDisplayName)).Append("\"");
        }

        return(string.Format("<a href=\"{0}\"{1}>{2}</a>", url, attrs, FormatCategoryDisplayName(categoryDisplayName, encode)));
    }
Exemple #27
0
    protected object gridLanguages_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        TranslationStatusEnum status = TranslationStatusEnum.NotAvailable;
        DataRowView           drv    = null;

        sourceName = sourceName.ToLowerCSafe();

        if (currentUserInfo == null)
        {
            currentUserInfo = CMSContext.CurrentUser;
        }
        if (currentSiteInfo == null)
        {
            currentSiteInfo = CMSContext.CurrentSite;
        }

        switch (sourceName)
        {
        case "translate":
        case "action":
            ImageButton img = sender as CMSImageButton;
            if (img != null)
            {
                if ((sourceName == "translate") &&
                    (!CMS.TranslationServices.TranslationServiceHelper.AnyServiceAvailable(CurrentSiteName) ||
                     !CMS.TranslationServices.TranslationServiceHelper.IsTranslationAllowed(CurrentSiteName)))
                {
                    img.Visible = false;
                    return(img);
                }

                GridViewRow gvr = parameter as GridViewRow;
                if (gvr != null)
                {
                    // Get datarowview
                    drv = gvr.DataItem as DataRowView;

                    if ((drv != null) && (drv.Row["TranslationStatus"] != DBNull.Value))
                    {
                        // Get translation status
                        status = (TranslationStatusEnum)drv.Row["TranslationStatus"];
                    }
                    else
                    {
                        status = TranslationStatusEnum.NotAvailable;
                    }

                    string culture = (drv != null) ? ValidationHelper.GetString(drv.Row["DocumentCulture"], string.Empty) : string.Empty;

                    // Set appropriate icon
                    if (sourceName == "action")
                    {
                        switch (status)
                        {
                        case TranslationStatusEnum.NotAvailable:
                            img.ImageUrl = GetImageUrl("CMSModules/CMS_Content/Properties/addculture.png");
                            img.ToolTip  = GetString("transman.createnewculture");
                            break;

                        default:
                            img.ImageUrl = GetImageUrl("CMSModules/CMS_Content/Properties/editculture.png");
                            img.ToolTip  = GetString("transman.editculture");
                            break;
                        }

                        // Register redirect script
                        if (RequiresDialog)
                        {
                            if ((sourceName == "action") && (status == TranslationStatusEnum.NotAvailable))
                            {
                                // New culture version
                                img.OnClientClick = "parent.parent.parent.NewDocumentCulture(" + NodeID + ",'" + culture + "');";
                            }
                            else
                            {
                                // Existing culture version
                                ScriptHelper.RegisterWOpenerScript(Page);
                                string url = ResolveUrl(CMSContext.GetUrl(Node.NodeAliasPath, Node.DocumentUrlPath, currentSiteInfo.SiteName));
                                url = URLHelper.AppendQuery(url, "lang=" + culture);
                                img.OnClientClick = "window.refreshPageOnClose = true; window.reloadPageUrl = " + ScriptHelper.GetString(url) + "; if (wopener.RefreshWOpener) { wopener.RefreshWOpener(window); } CloseDialog();";
                            }
                        }
                        else
                        {
                            img.OnClientClick = "RedirectItem(" + NodeID + ", '" + culture + "');";
                        }

                        img.ID = "imgAction";
                    }
                    else
                    {
                        // Add parameters identifier and hash, encode query string
                        if (LicenseHelper.CheckFeature(URLHelper.GetCurrentDomain(), FeatureEnum.TranslationServices))
                        {
                            string returnUrl = CMSContext.ResolveDialogUrl("~/CMSModules/Translations/Pages/TranslateDocuments.aspx") + "?targetculture=" + culture + "&modal=1&nodeid=" + NodeID;
                            returnUrl = URLHelper.AddParameterToUrl(returnUrl, "hash", QueryHelper.GetHash(URLHelper.GetQuery(returnUrl)));

                            img.ImageUrl      = GetImageUrl("CMSModules/CMS_Content/Properties/translate.png");
                            img.ToolTip       = GetString("transman.translate");
                            img.OnClientClick = "modalDialog('" + returnUrl + "', 'TranslateDocument', 550, 440); ";
                        }
                        else
                        {
                            img.Visible = false;
                        }
                        break;
                    }
                }
            }
            return(img);

        case "translationstatus":
            if (parameter == DBNull.Value)
            {
                status = TranslationStatusEnum.NotAvailable;
            }
            else
            {
                status = (TranslationStatusEnum)parameter;
            }
            string statusName = GetString("transman." + status);
            string statusHtml = "<span class=\"" + status + "\">" + statusName + "</span>";
            // .Outdated
            return(statusHtml);

        case "documentculturedisplayname":
            drv = (DataRowView)parameter;
            // Add icon
            return(UniGridFunctions.DocumentCultureFlag(drv, Page));

        case "documentmodifiedwhen":
        case "documentmodifiedwhentooltip":
            if (string.IsNullOrEmpty(parameter.ToString()))
            {
                return("-");
            }
            else
            {
                DateTime modifiedWhen = ValidationHelper.GetDateTime(parameter, DateTimeHelper.ZERO_TIME);
                bool     displayGMT   = (sourceName == "documentmodifiedwhentooltip");
                return(TimeZoneHelper.ConvertToUserTimeZone(modifiedWhen, displayGMT, currentUserInfo, currentSiteInfo));
            }

        case "versionnumber":
            if (string.IsNullOrEmpty(parameter.ToString()))
            {
                return("-");
            }
            break;

        case "documentname":
            if (string.IsNullOrEmpty(parameter.ToString()))
            {
                parameter = "-";
            }
            return(HTMLHelper.HTMLEncode(parameter.ToString()));

        case "published":
            bool published = ValidationHelper.GetBoolean(parameter, false);
            if (published)
            {
                return("<span class=\"DocumentPublishedYes\">" + GetString("General.Yes") + "</span>");
            }
            else
            {
                return("<span class=\"DocumentPublishedNo\">" + GetString("General.No") + "</span>");
            }
        }
        return(parameter);
    }
Exemple #28
0
    /// <summary>
    /// Yes button click event handler.
    /// </summary>
    protected void btnYes_Click(object sender, EventArgs e)
    {
        if (IsBannedIP())
        {
            return;
        }

        // Prepare the where condition
        string where = "NodeID = " + NodeID;

        // Get the documents
        DataSet ds = null;

        if (chkAllCultures.Checked)
        {
            ds = TreeProvider.SelectNodes(SiteName, "/%", TreeProvider.ALL_CULTURES, true, null, where, null, -1, false);
        }
        else
        {
            ds = TreeProvider.SelectNodes(SiteName, "/%", CultureCode, false, null, where, null, -1, false);
        }

        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            // Get node alias
            string nodeAlias = ValidationHelper.GetString(DataHelper.GetDataRowValue(ds.Tables[0].Rows[0], "NodeAlias"), string.Empty);
            // Get parent alias path
            string parentAliasPath = TreePathUtils.GetParentPath(ValidationHelper.GetString(DataHelper.GetDataRowValue(ds.Tables[0].Rows[0], "NodeAliasPath"), string.Empty));

            string   aliasPath = null;
            string   culture   = null;
            string   className = null;
            bool     hasUserDeletePermission = false;
            TreeNode treeNode = null;

            // Delete the documents
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                aliasPath = ValidationHelper.GetString(dr["NodeAliasPath"], string.Empty);
                culture   = ValidationHelper.GetString(dr["DocumentCulture"], string.Empty);
                className = ValidationHelper.GetString(dr["ClassName"], string.Empty);

                // Get the node
                treeNode = TreeProvider.SelectSingleNode(SiteName, aliasPath, culture, false, className, false);

                if (treeNode != null)
                {
                    // Check delete permissions
                    hasUserDeletePermission = !CheckPermissions || IsUserAuthorizedToDeleteDocument(treeNode, chkDestroy.Checked);

                    if (hasUserDeletePermission)
                    {
                        // Delete the document
                        try
                        {
                            LogDeleteActivity(treeNode);
                            DocumentHelper.DeleteDocument(treeNode, TreeProvider, chkAllCultures.Checked, chkDestroy.Checked, true);
                        }
                        catch (Exception ex)
                        {
                            EventLogProvider log = new EventLogProvider();
                            log.LogEvent(EventLogProvider.EVENT_TYPE_ERROR, DateTime.Now, "Content", "DELETEDOC", CMSContext.CurrentUser.UserID, CMSContext.CurrentUser.UserName, treeNode.NodeID, treeNode.GetDocumentName(), HTTPHelper.UserHostAddress, EventLogProvider.GetExceptionLogMessage(ex), CMSContext.CurrentSite.SiteID, HTTPHelper.GetAbsoluteUri());
                            AddAlert(GetString("ContentRequest.DeleteFailed") + ": " + ex.Message);
                            return;
                        }
                    }
                    // Access denied - not authorized to delete the document
                    else
                    {
                        AddAlert(String.Format(GetString("cmsdesk.notauthorizedtodeletedocument"), treeNode.NodeAliasPath));
                        return;
                    }
                }
                else
                {
                    AddAlert(GetString("ContentRequest.ErrorMissingSource"));
                    return;
                }
            }

            RaiseOnAfterDelete();

            string rawUrl = URLRewriter.RawUrl.TrimEnd(new char[] { '/' });
            if ((!string.IsNullOrEmpty(nodeAlias)) && (rawUrl.Substring(rawUrl.LastIndexOfCSafe('/')).Contains(nodeAlias)))
            {
                // Redirect to the parent url when current url belongs to deleted document
                URLHelper.Redirect(CMSContext.GetUrl(parentAliasPath));
            }
            else
            {
                // Redirect to current url
                URLHelper.Redirect(rawUrl);
            }
        }
        else
        {
            AddAlert(GetString("DeleteDocument.CultureNotExists"));
            return;
        }
    }
    /// <summary>
    /// External data binding handler.
    /// </summary>
    protected object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        // Prepare variables
        int         nodeId  = 0;
        string      culture = string.Empty;
        DataRowView data    = null;

        sourceName = sourceName.ToLowerCSafe();
        SiteInfo site = null;

        switch (sourceName)
        {
        // Edit button
        case EXTERNALSOURCE_EDIT:
            if (sender is ImageButton)
            {
                ImageButton editButton = (ImageButton)sender;
                data    = UniGridFunctions.GetDataRowView(editButton.Parent as DataControlFieldCell);
                site    = GetSiteFromRow(data);
                nodeId  = ValidationHelper.GetInteger(data[SOURCE_NODEID], 0);
                culture = ValidationHelper.GetString(data[SOURCE_DOCUMENTCULTURE], string.Empty);
                string type = ValidationHelper.GetString(DataHelper.GetDataRowViewValue(data, SOURCE_TYPE), string.Empty);

                // Check permissions
                if ((site.Status != SiteStatusEnum.Running) || (!CMSMyDeskPage.IsUserAuthorizedPerContent(site.SiteName) || ((ListingType == ListingTypeEnum.All) && (type == LISTINGTYPE_RECYCLEBIN))))
                {
                    editButton.ImageUrl      = GetImageUrl("Design/Controls/UniGrid/Actions/Editdisabled.png");
                    editButton.OnClientClick = "return false";
                    editButton.Style.Add(HtmlTextWriterStyle.Cursor, "default");
                }
                else
                {
                    editButton.OnClientClick = "return SelectItem(" + nodeId + ", '" + culture + "','" + ResolveSiteUrl(site) + "');";
                }
                return(editButton);
            }
            return(sender);

        // Preview button
        case EXTERNALSOURCE_PREVIEW:
            if (sender is ImageButton)
            {
                ImageButton previewButton = (ImageButton)sender;
                data = UniGridFunctions.GetDataRowView(previewButton.Parent as DataControlFieldCell);
                site = GetSiteFromRow(data);
                string type = ValidationHelper.GetString(DataHelper.GetDataRowViewValue(data, SOURCE_TYPE), string.Empty);
                if ((site.Status != SiteStatusEnum.Running) || ((ListingType == ListingTypeEnum.All) && (type == LISTINGTYPE_RECYCLEBIN)))
                {
                    previewButton.ImageUrl      = GetImageUrl("Design/Controls/UniGrid/Actions/Viewdisabled.png");
                    previewButton.OnClientClick = "return false";
                    previewButton.Style.Add(HtmlTextWriterStyle.Cursor, "default");
                }
                else
                {
                    nodeId  = ValidationHelper.GetInteger(data[SOURCE_NODEID], 0);
                    culture = ValidationHelper.GetString(data[SOURCE_DOCUMENTCULTURE], string.Empty);
                    string nodeAliasPath = ValidationHelper.GetString(data[SOURCE_NODEALIASPATH], string.Empty);
                    // Generate preview URL
                    string url = CMSContext.GetUrl(nodeAliasPath, null, site.SiteName);
                    url = URLHelper.AddParameterToUrl(url, "viewmode", "2");
                    url = URLHelper.AddParameterToUrl(url, URLHelper.LanguageParameterName, culture);
                    previewButton.OnClientClick = "window.open('" + URLHelper.ResolveUrl(url) + "','LiveSite');return false;";
                }
                return(previewButton);
            }
            return(sender);

        // Document name column
        case EXTERNALSOURCE_DOCUMENTNAME:
            data = (DataRowView)parameter;

            string name = ValidationHelper.GetString(data[SOURCE_DOCUMENTNAME], string.Empty);
            nodeId  = ValidationHelper.GetInteger(data[SOURCE_NODEID], 0);
            culture = ValidationHelper.GetString(data[SOURCE_DOCUMENTCULTURE], string.Empty);
            string className = ValidationHelper.GetString(data[SOURCE_CLASSNAME], string.Empty);
            site = GetSiteFromRow(data);

            if (name == string.Empty)
            {
                name = GetString("general.notspecified");
            }
            // Add document type icon
            string result = string.Empty;
            switch (ListingType)
            {
            case ListingTypeEnum.DocTypeDocuments:
                break;

            default:
                result = "<img src=\"" + UIHelper.GetDocumentTypeIconUrl(Parent.Page, className, String.Empty, true) + "\" class=\"UnigridActionButton\" />";
                break;
            }

            result += "<span style=\"vertical-align: bottom;\">" + HTMLHelper.HTMLEncode(TextHelper.LimitLength(name, 50)) + "</span>";

            if (ListingType != ListingTypeEnum.All)
            {
                bool isLink = (data.Row.Table.Columns.Contains(SOURCE_NODELINKEDNODEID) && (data[SOURCE_NODELINKEDNODEID] != DBNull.Value));
                if (isLink)
                {
                    // Add link icon
                    result += UIHelper.GetDocumentMarkImage(Parent.Page, DocumentMarkEnum.Link);
                }
            }
            return(result);

        // Class name column
        case EXTERNALSOURCE_CLASSDISPLAYNAME:
            string displayName = ValidationHelper.GetString(parameter, string.Empty);
            if (sourceName.ToLowerCSafe() == EXTERNALSOURCE_CLASSDISPLAYNAMETOOLTIP)
            {
                displayName = TextHelper.LimitLength(displayName, 50);
            }
            if (displayName == string.Empty)
            {
                displayName = "-";
            }
            return(HTMLHelper.HTMLEncode(ResHelper.LocalizeString(displayName)));

        case EXTERNALSOURCE_DOCUMENTNAMETOOLTIP:
            data = (DataRowView)parameter;
            return(UniGridFunctions.DocumentNameTooltip(data));

        case EXTERNALSOURCE_STEPDISPLAYNAME:
            // Step display name
            string stepName = ValidationHelper.GetString(parameter, string.Empty);
            if (stepName == string.Empty)
            {
                stepName = "-";
            }
            return(HTMLHelper.HTMLEncode(ResHelper.LocalizeString(stepName)));

        case EXTERNALSOURCE_STEPNAME:
            // Step display name from ID
            int stepId = ValidationHelper.GetInteger(parameter, 0);
            if (stepId > 0)
            {
                WorkflowStepInfo wsi = WorkflowStepInfoProvider.GetWorkflowStepInfo(stepId);
                if (wsi != null)
                {
                    return(HTMLHelper.HTMLEncode(ResHelper.LocalizeString(wsi.StepDisplayName)));
                }
            }
            return("-");

        case EXTERNALSOURCE_CULTURE:
            data    = (DataRowView)parameter;
            culture = ValidationHelper.GetString(data[SOURCE_DOCUMENTCULTURE], string.Empty);
            // Add icon
            if (culture != String.Empty)
            {
                return(UniGridFunctions.DocumentCultureFlag(data, Page));
            }

            return("-");

        // Version column
        case EXTERNALSOURCE_VERSION:
            if (parameter == DBNull.Value)
            {
                parameter = "-";
            }
            parameter = HTMLHelper.HTMLEncode(parameter.ToString());
            return(parameter);

        // Site name column
        case EXTERNALSOURCE_SITENAME:
            string siteName = ValidationHelper.GetString(parameter, string.Empty);
            siteInfo = SiteInfoProvider.GetSiteInfo(siteName);
            return(HTMLHelper.HTMLEncode(siteInfo.DisplayName));

        case EXTERNALSOURCE_SITEID:
            int siteId = ValidationHelper.GetInteger(parameter, 0);
            siteInfo = SiteInfoProvider.GetSiteInfo(siteId);
            return(HTMLHelper.HTMLEncode(siteInfo.DisplayName));

        // Document timestamp column
        case EXTERNALSOURCE_MODIFIEDWHEN:
        case EXTERNALSOURCE_MODIFIEDWHENTOOLTIP:
            if (string.IsNullOrEmpty(parameter.ToString()))
            {
                return(string.Empty);
            }
            else
            {
                if (currentSiteInfo == null)
                {
                    currentSiteInfo = CMSContext.CurrentSite;
                }
                bool     displayGMT = (sourceName == EXTERNALSOURCE_MODIFIEDWHENTOOLTIP);
                DateTime time       = ValidationHelper.GetDateTime(parameter, DateTimeHelper.ZERO_TIME);
                return(TimeZoneHelper.ConvertToUserTimeZone(time, displayGMT, currentUserInfo, currentSiteInfo));
            }
        }

        return(parameter);
    }
Exemple #30
0
    private void btnOk_Click(object sender, EventArgs e)
    {
        // Validate all required data for new blog
        string errorMessage = ValidateData();

        if (!LicenseHelper.LicenseVersionCheck(URLHelper.GetCurrentDomain(), FeatureEnum.Blogs, VersionActionEnum.Insert))
        {
            errorMessage = GetString("cmsdesk.bloglicenselimits");
        }

        // Get current user
        CurrentUserInfo user = CMSContext.CurrentUser;

        if (errorMessage == "")
        {
            // Get parent node for new blog
            TreeProvider tree   = new TreeProvider(user);
            TreeNode     parent = tree.SelectSingleNode(CMSContext.CurrentSiteName, BlogParentPath.TrimEnd('%'), TreeProvider.ALL_CULTURES);
            if (parent != null)
            {
                if (!CheckPermissions || user.IsAuthorizedToCreateNewDocument(parent, "cms.blog"))
                {
                    bool     useParentNodeGroupID = tree.UseParentNodeGroupID;
                    TreeNode blogNode             = null;
                    try
                    {
                        // Reflect group document
                        tree.UseParentNodeGroupID = true;

                        // Initialize and create new blog node
                        blogNode = TreeNode.New("cms.blog", tree);
                        blogNode.SetValue("BlogName", txtName.Text.Trim());
                        blogNode.SetValue("BlogDescription", txtDescription.Text.Trim());
                        blogNode.SetValue("BlogAllowAnonymousComments", BlogAllowAnonymousComments);
                        blogNode.SetValue("BlogModerateComments", BlogModerateComments);
                        blogNode.SetValue("BlogOpenCommentsFor", BlogOpenCommentsFor);
                        blogNode.SetValue("BlogSendCommentsToEmail", BlogSendCommentsToEmail);
                        blogNode.SetValue("BlogSideColumnText", BlogSideColumnText);
                        blogNode.SetValue("BlogUseCAPTCHAForComments", BlogUseCAPTCHAForComments);
                        blogNode.SetValue("BlogModerators", BlogModerators);
                        if (BlogTeaser == Guid.Empty)
                        {
                            blogNode.SetValue("BlogTeaser", null);
                        }
                        else
                        {
                            blogNode.SetValue("BlogTeaser", BlogTeaser);
                        }

                        blogNode.SetValue("NodeOwner", user.UserID);

                        if (NewBlogTemplate != null)
                        {
                            // Get the BlogMonth class to set the default page template
                            if (NewBlogTemplate == "")
                            {
                                DataClassInfo blogClass = DataClassInfoProvider.GetDataClass("CMS.Blog");
                                if (blogClass != null)
                                {
                                    blogNode.SetDefaultPageTemplateID(blogClass.ClassDefaultPageTemplateID);
                                }
                            }
                            else
                            {
                                // Set the selected template
                                PageTemplateInfo pti = PageTemplateInfoProvider.GetPageTemplateInfo(NewBlogTemplate);
                                if (pti != null)
                                {
                                    blogNode.NodeTemplateForAllCultures = true;
                                    blogNode.NodeTemplateID             = pti.PageTemplateId;
                                }
                            }
                        }

                        // Trackbacks are denied by default
                        blogNode.SetValue("BlogEnableTrackbacks", false);

                        blogNode.DocumentName    = txtName.Text.Trim();
                        blogNode.DocumentCulture = CMSContext.CurrentUser.PreferredCultureCode;
                        DocumentHelper.InsertDocument(blogNode, parent, tree);
                    }
                    finally
                    {
                        tree.UseParentNodeGroupID = useParentNodeGroupID;
                    }

                    if (RedirectToNewBlog)
                    {
                        // Redirect to the new blog
                        URLHelper.Redirect(CMSContext.GetUrl(blogNode.NodeAliasPath));
                    }
                    else
                    {
                        // Display info message
                        lblInfo.Visible = true;
                        lblInfo.Text    = GetString("General.ChangesSaved");
                    }
                }
                else
                {
                    // Not authorized to create blog
                    errorMessage = GetString("blogs.notallowedtocreate");
                }
            }
            else
            {
                // Parent node was not found
                errorMessage = GetString("Blogs.NewBlog.PathNotFound");
            }
        }

        if (errorMessage != "")
        {
            // Display error message
            lblError.Visible = true;
            lblError.Text    = errorMessage;
        }
    }