Exemplo n.º 1
0
    private static void RegisterAttachments(Page page, ObjectEditMenu menu, EmailTemplateInfo emailTemplate)
    {
        const string ATTACHMENTS_ACTION_CLASS = "attachments-header-action";

        // Register attachments count update module
        ScriptHelper.RegisterModule(page, "CMS/AttachmentsCountUpdater", new
        {
            Selector = "." + ATTACHMENTS_ACTION_CLASS,
            Text     = ResHelper.GetString("general.attachments")
        });

        // Prepare metafile dialog URL
        var metaFileDialogUrl = UrlResolver.ResolveUrl(@"~/CMSModules/AdminControls/Controls/MetaFiles/MetaFileDialog.aspx");
        var query             = string.Format("?objectid={0}&objecttype={1}&siteid={2}", emailTemplate.TemplateID, EmailTemplateInfo.OBJECT_TYPE, emailTemplate.TemplateSiteID);

        metaFileDialogUrl += string.Format("{0}&category={1}&hash={2}", query, ObjectAttachmentsCategories.TEMPLATE, QueryHelper.GetHash(query));

        var attachCount        = GetAttachmentsCount(emailTemplate);
        var attachmentsCaption = ResHelper.GetString("general.attachments");

        // Add attachments action
        menu.AddExtraAction(new HeaderAction
        {
            Text          = attachmentsCaption + (attachCount > 0 ? " (" + attachCount + ")" : string.Empty),
            Tooltip       = attachmentsCaption,
            OnClientClick = string.Format(@"if (modalDialog) {{modalDialog('{0}', 'Attachments', '700', '500');}}", metaFileDialogUrl) + " return false;",
            Enabled       = !SynchronizationHelper.UseCheckinCheckout || emailTemplate.Generalized.IsCheckedOutByUser(MembershipContext.AuthenticatedUser),
            CssClass      = ATTACHMENTS_ACTION_CLASS,
            ButtonStyle   = ButtonStyle.Default
        });
    }
Exemplo n.º 2
0
 /// <summary>
 /// Adds extra action to the object edit menu.
 /// </summary>
 /// <param name="action">Header action</param>
 public void AddExtraHeaderAction(HeaderAction action)
 {
     if ((action != null) && (ObjectEditMenu != null))
     {
         // Add extra action to object menu
         ObjectEditMenu.AddExtraAction(action);
     }
 }
Exemplo n.º 3
0
    protected void InitActions()
    {
        EmailTemplateInfo emailTemplate = (EmailTemplateInfo)EditedObject;

        if ((emailTemplate != null) && (emailTemplate.TemplateID > 0))
        {
            ObjectEditMenu menu = (ObjectEditMenu)ControlsHelper.GetChildControl(Page, typeof(ObjectEditMenu));
            if (menu != null)
            {
                EmailTemplateEditExtender.RegisterEditPageHeaderActions(Page, menu, emailTemplate);
            }
        }
    }
Exemplo n.º 4
0
    private void InitHeaderActions()
    {
        EmailTemplateInfo emailTemplate = Control.EditedObject as EmailTemplateInfo;

        if ((emailTemplate != null) && (emailTemplate.TemplateID > 0))
        {
            Page page = Control.Page;

            ObjectEditMenu menu = (ObjectEditMenu)ControlsHelper.GetChildControl(page, typeof(ObjectEditMenu));
            if (menu != null)
            {
                RegisterEditPageHeaderActions(page, menu, emailTemplate);
            }
        }
    }
Exemplo n.º 5
0
    /// <summary>
    /// Initializes header actions.
    /// </summary>
    /// <param name="templateId">Email template ID</param>
    /// <param name="siteId">Site ID</param>
    protected void InitHeaderActions(int templateId, int siteId)
    {
        if (templateId > 0)
        {
            // Get number of attachments
            InfoDataSet <MetaFileInfo> ds = MetaFileInfoProvider.GetMetaFiles(templateId, PredefinedObjectType.EMAILTEMPLATE, MetaFileInfoProvider.OBJECT_CATEGORY_TEMPLATE,
                                                                              siteId > 0 ? "MetaFileSiteID=" + siteId : "MetaFileSiteID IS NULL", null, "MetafileID", -1);
            int attachCount = ds.Items.Count;

            string script = @"
function UpdateAttachmentCount(count) {
    var counter = document.getElementById('attachmentCount');
    if (counter != null) {
        if (count > 0) { counter.innerHTML = ' (' + count + ')'; }
        else { counter.innerHTML = ''; }
    }
}";
            ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "UpdateAttachmentScript_" + this.ClientID, script, true);

            // Register dialog scripts
            ScriptHelper.RegisterDialogScript(Page);

            // Prepare metafile dialog URL
            string metaFileDialogUrl = ResolveUrl(@"~/CMSModules/AdminControls/Controls/MetaFiles/MetaFileDialog.aspx");
            string query             = string.Format("?objectid={0}&objecttype={1}&siteid={2}", templateId, PredefinedObjectType.EMAILTEMPLATE, siteId);
            metaFileDialogUrl += string.Format("{0}&category={1}&hash={2}", query, MetaFileInfoProvider.OBJECT_CATEGORY_TEMPLATE, QueryHelper.GetHash(query));

            // Init attachment button
            ObjectEditMenu menu = ControlsHelper.GetChildControl(Page, typeof(ObjectEditMenu)) as ObjectEditMenu;
            if (menu != null)
            {
                attachmentsAction = new HeaderAction()
                {
                    ControlType   = HeaderActionTypeEnum.LinkButton,
                    Text          = GetString("general.attachments") + string.Format("<span id='attachmentCount'>{0}</span>", (attachCount > 0) ? " (" + attachCount.ToString() + ")" : string.Empty),
                    Tooltip       = GetString("general.attachments"),
                    OnClientClick = string.Format(@"if (modalDialog) {{modalDialog('{0}', 'Attachments', '700', '500');}}", metaFileDialogUrl) + " return false;",
                    ImageUrl      = GetImageUrl("Objects/CMS_MetaFile/attachment.png"),
                    Visible       = !pnlObjectLocking.IsObjectLocked()
                };

                menu.AddExtraAction(attachmentsAction);
            }
        }
    }
Exemplo n.º 6
0
    /// <summary>
    /// Setup control.
    /// </summary>
    public void SetupControl()
    {
        ObjectEditMenu menu = ControlsHelper.GetChildControl(Page, typeof(ObjectEditMenu)) as ObjectEditMenu;

        if (menu != null)
        {
            menu.ShowSave = false;
        }

        var abstractMenu = ControlsHelper.GetChildControl(Page, typeof(IObjectEditMenu)) as IObjectEditMenu;

        if (abstractMenu != null)
        {
            abstractMenu.AbstractObjectManager.OnAfterAction += (sender, args) =>
            {
                if (DialogMode)
                {
                    ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), "parentWOpenerRefresh", ScriptHelper.GetScript("if (parent && parent.wopener && parent.wopener.refresh) { parent.wopener.refresh(); }"));
                }
            };
        }

        gridHistory.ZeroRowsText = GetString("objectversioning.objecthasnohistory");
        if (Object != null)
        {
            // Set buttons confirmation
            btnDestroy.OnClientClick   = "return confirm(" + ScriptHelper.GetString(ResHelper.GetString("VersionProperties.ConfirmDestroy")) + ");";
            btnMakeMajor.OnClientClick = "return confirm(" + ScriptHelper.GetString(ResHelper.GetString("VersionProperties.ConfirmMakeMajor")) + ");";

            gridHistory.OnExternalDataBound += gridHistory_OnExternalDataBound;
            gridHistory.OnAction            += gridHistory_OnAction;
            gridHistory.WhereCondition       = "VersionObjectType = '" + SqlHelper.GetSafeQueryString(Object.TypeInfo.ObjectType, false) + "' AND VersionObjectID = " + Object.Generalized.ObjectID;
            gridHistory.Columns              = "VersionID, UserName, FullName, VersionModifiedWhen, VersionNumber";
        }
        else
        {
            gridHistory.StopProcessing = true;
            headTitle.Visible          = false;
            btnDestroy.Visible         = false;

            ShowError(GetString("objectversioning.uknownobject"));
        }
    }
Exemplo n.º 7
0
    private static void RegisterSendDraft(ObjectEditMenu menu, EmailTemplateInfo emailTemplate)
    {
        // Prepare draft dialog URL
        var draftDialogUrl = UrlResolver.ResolveUrl("~/CMSModules/EmailTemplates/Pages/SendDraft.aspx");

        draftDialogUrl = URLHelper.AddParameterToUrl(draftDialogUrl, "objectid", emailTemplate.TemplateID.ToString());

        var draftCaption = ResHelper.GetString("emailtemplates.senddraft");

        // Add send draft action
        menu.AddExtraAction(new HeaderAction
        {
            Text          = draftCaption,
            Tooltip       = draftCaption,
            OnClientClick = string.Format(@"if (modalDialog) {{modalDialog('{0}', 'SendDraft', '700', '325');}}", draftDialogUrl) + " return false;",
            Enabled       = true,
            ButtonStyle   = ButtonStyle.Default
        });
    }
Exemplo n.º 8
0
    /// <summary>
    /// Registers email template actions headers to given page and menu item
    /// </summary>
    /// <param name="page">Page where the action is registered</param>
    /// <param name="menu">Menu where the action is registered</param>
    /// <param name="emailTemplate">Email template for which actions are registered</param>
    public static void RegisterEditPageHeaderActions(Page page, ObjectEditMenu menu, EmailTemplateInfo emailTemplate)
    {
        if (page == null)
        {
            throw new ArgumentNullException("page");
        }

        if (menu == null)
        {
            throw new ArgumentNullException("menu");
        }

        if (emailTemplate == null)
        {
            throw new ArgumentNullException("emailTemplate");
        }

        ScriptHelper.RegisterDialogScript(page);

        RegisterSendDraft(menu, emailTemplate);
        RegisterAttachments(page, menu, emailTemplate);
    }
Exemplo n.º 9
0
    protected void InitAttachmentAction()
    {
        EmailTemplateInfo emailTemplate = Control.EditedObject as EmailTemplateInfo;

        if ((emailTemplate != null) && (emailTemplate.TemplateID > 0))
        {
            int  siteId = emailTemplate.TemplateSiteID;
            Page page   = Control.Page;

            // Get number of attachments
            InfoDataSet <MetaFileInfo> ds = MetaFileInfoProvider.GetMetaFiles(emailTemplate.TemplateID, EmailTemplateInfo.OBJECT_TYPE, ObjectAttachmentsCategories.TEMPLATE,
                                                                              siteId > 0 ? "MetaFileSiteID=" + siteId : "MetaFileSiteID IS NULL", null, "MetafileID", -1);
            int attachCount = ds.Items.Count;

            // Register attachments count update module
            ScriptHelper.RegisterModule(page, "CMS/AttachmentsCountUpdater", new { Selector = "." + mAttachmentsActionClass, Text = ResHelper.GetString("general.attachments") });

            // Register dialog scripts
            ScriptHelper.RegisterDialogScript(page);

            // Prepare metafile dialog URL
            string metaFileDialogUrl = URLHelper.ResolveUrl(@"~/CMSModules/AdminControls/Controls/MetaFiles/MetaFileDialog.aspx");
            string query             = String.Format("?objectid={0}&objecttype={1}&siteid={2}", emailTemplate.TemplateID, EmailTemplateInfo.OBJECT_TYPE, siteId);
            metaFileDialogUrl += String.Format("{0}&category={1}&hash={2}", query, ObjectAttachmentsCategories.TEMPLATE, QueryHelper.GetHash(query));

            ObjectEditMenu menu = (ObjectEditMenu)ControlsHelper.GetChildControl(page, typeof(ObjectEditMenu));
            if (menu != null)
            {
                menu.AddExtraAction(new HeaderAction()
                {
                    Text          = ResHelper.GetString("general.attachments") + ((attachCount > 0) ? " (" + attachCount.ToString() + ")" : String.Empty),
                    OnClientClick = String.Format(@"if (modalDialog) {{modalDialog('{0}', 'Attachments', '700', '500');}}", metaFileDialogUrl) + " return false;",
                    Enabled       = !SynchronizationHelper.UseCheckinCheckout || emailTemplate.Generalized.IsCheckedOutByUser(MembershipContext.AuthenticatedUser),
                    CssClass      = mAttachmentsActionClass
                });
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (AlternativeFormInfo == null || BizFormInfo == null)
        {
            RedirectToAccessDenied(GetString("general.invalidparameters"));
        }

        CurrentMaster.BodyClass += " FieldEditorBody";

        altFormFieldEditor.AlternativeFormID = AlternativeFormInfo.FormID;
        altFormFieldEditor.Mode = FieldEditorModeEnum.AlternativeBizFormDefinition;
        altFormFieldEditor.DisplayedControls = FieldEditorControlsEnum.Bizforms;
        altFormFieldEditor.OnBeforeSave     += altFormFieldEditor_OnBeforeSave;

        ObjectEditMenu menu = (ObjectEditMenu)ControlsHelper.GetChildControl(Page, typeof(ObjectEditMenu));

        if (menu != null)
        {
            menu.AllowSave = MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.form", "EditForm", SiteInfoProvider.GetSiteName(BizFormInfo.FormSiteID));
        }

        ScriptHelper.HideVerticalTabs(this);
    }