public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->addFieldToTab("Root", $subscriptionTab = new Tab(_t('Newsletter.SUBSCRIPTIONFORM', 'SubscriptionForm')));
     Requirements::javascript('newsletter/javascript/SubscriptionPage.js');
     Requirements::css('newsletter/css/SubscriptionPage.css');
     $subscriptionTab->push(new HeaderField("SubscriptionFormConfig", _t('Newsletter.SUBSCRIPTIONFORMCONFIGURATION', "Subscription Form Configuration")));
     $subscriptionTab->push(new TextField('CustomisedHeading', 'Heading at the top of the form'));
     //Fields selction
     $frontFields = singleton('Recipient')->getFrontEndFields()->dataFields();
     $fieldCandidates = array();
     if (count($frontFields)) {
         foreach ($frontFields as $fieldName => $dataField) {
             $fieldCandidates[$fieldName] = $dataField->Title() ? $dataField->Title() : $dataField->Name();
         }
     }
     //Since Email field is the Recipient's identifier,
     //and newsletters subscription is non-sence if no email is given by the user,
     //we should force that email to be checked and required.
     //FisrtName should be checked as default, though it might not be required
     $defaults = array("Email", "FirstName");
     $extra = array('CustomLabel' => "Varchar", "ValidationMessage" => "Varchar", "Required" => "Boolean");
     $extraValue = array('CustomLabel' => $this->CustomLabel, "ValidationMessage" => $this->ValidationMessage, "Required" => $this->Required);
     $subscriptionTab->push($fieldsSelection = new CheckboxSetWithExtraField("Fields", _t('Newsletter.SelectFields', "Select the fields to display on the subscription form"), $fieldCandidates, $extra, $defaults, $extraValue));
     $fieldsSelection->setCellDisabled(array("Email" => array("Value", "Required")));
     //Mailing Lists selection
     $mailinglists = MailingList::get();
     $newsletterSelection = $mailinglists && $mailinglists->count() ? new CheckboxSetField("MailingLists", _t("Newsletter.SubscribeTo", "Newsletters to subscribe to"), $mailinglists->map('ID', 'FullTitle'), $mailinglists) : new LiteralField("NoMailingList", sprintf('<p>%s</p>', sprintf('You haven\'t defined any mailing list yet, please go to ' . '<a href=\\"%s\\">the newsletter administration area</a> ' . 'to define a mailing list.', singleton('NewsletterAdmin')->Link())));
     $subscriptionTab->push($newsletterSelection);
     $subscriptionTab->push(new TextField("SubmissionButtonText", "Submit Button Text"));
     $subscriptionTab->push(new LiteralField('BottomTaskSelection', sprintf('<div id="SendNotificationControlls" class="field actions">' . '<label class="left">%s</label>' . '<ul><li class="ss-ui-button no" data-panel="no">%s</li>' . '<li class="ss-ui-button yes" data-panel="yes">%s</li>' . '</ul></div>', _t('Newsletter.SendNotif', 'Send notification email to the subscriber'), _t('Newsletter.No', 'No'), _t('Newsletter.Yes', 'Yes'))));
     $subscriptionTab->push(CompositeField::create(new HiddenField("SendNotification", "Send Notification"), new TextField("NotificationEmailSubject", _t('Newsletter.NotifSubject', "Notification Email Subject Line")), new TextField("NotificationEmailFrom", _t('Newsletter.FromNotif', "From Email Address for Notification Email")))->addExtraClass('SendNotificationControlledPanel'));
     $subscriptionTab->push(new HtmlEditorField('OnCompleteMessage', _t('Newsletter.OnCompletion', 'Message shown on subscription completion')));
     return $fields;
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->addFieldToTab("Root.Main", new HeaderField("InformAdminAboutNewsletter", _t("OrderStep.EMAILDETAILSTO", "Email details to"), 3), "SendMessageToAdmin");
     $fields->replaceField("SendCopyTo", new EmailField("SendCopyTo", _t("OrderStep.SENDCOPYTO", "Send a copy (another e-mail) to ...")));
     $mailingLists = MailingList::get()->map();
     $fields->addFieldToTab("Root.MailingLists", new CheckboxSetField("MailingLists", _t("OrderForm.SIGNUPTONEWSLETTER", "Sign up"), $mailingLists));
     return $fields;
 }
예제 #3
0
 /**
  * Set the subject line, from email, and from name, and reply
  * email according to the passed settings and the list defaults.
  * @return array Revised settings
  */
 protected function getCampaignSettings()
 {
     // get list defaults
     $list = new MailingList($this->api, $this->settings["list_id"]);
     $listInfo = $list->get();
     $listDefaults = $listInfo->campaign_defaults;
     // compile settings based on passed settings and list defaults
     $settings = array("title" => $this->settings["title"], "subject_line" => isset($this->settings["subject"]) ? $this->settings["subject"] : $listDefaults->subject, "from_email" => isset($this->settings["from_email"]) ? $this->settings["from_email"] : $listDefaults->from_email, "from_name" => isset($this->settings["from_name"]) ? $this->settings["from_name"] : $listDefaults->from_name);
     $settings["reply_to"] = $settings["from_email"];
     return $settings;
 }
 /**
  * @Given /^I add the "([^"]*)" mailinglist to the "([^"]*)" page$/
  */
 public function iAddTheMailinglistToThePage($mailinglistTitle, $pageUrl)
 {
     $mailinglist = \MailingList::get()->filter('Title', $mailinglistTitle)->First();
     assertNotNull($mailinglist, 'Could not find MailingList with ' . $mailinglistTitle);
     $page = \SubscriptionPage::get()->filter('URLSegment', $pageUrl)->First();
     assertNotNull($page);
     $lists = $page->MailingLists ? explode(',', $page->MailingLists) : array();
     $lists[] = $mailinglist->ID;
     $page->MailingLists = implode(',', $lists);
     $page->write();
     $page->publish('Stage', 'Live');
 }
 public function getCMSFields()
 {
     $fields = new FieldList();
     $fields->push(new TabSet("Root", $mainTab = new Tab("Main")));
     $mainTab->setTitle(_t('SiteTree.TABMAIN', "Main"));
     $fields->addFieldToTab('Root.Main', new TextField('Email', $this->fieldLabel('Email')));
     $fields->addFieldsToTab('Root.Main', array(Object::create('TextField', 'Salutation', $this->fieldLabel('Salutation')), Object::create('TextField', 'FirstName', $this->fieldLabel('First Name')), Object::create('TextField', 'MiddleName', $this->fieldLabel('Middle Name')), Object::create('TextField', 'Surname', $this->fieldLabel('Surname'))));
     if (!empty($this->ID)) {
         $fields->addFieldToTab('Root.Main', Object::create('CheckboxSetField', 'MailingLists', $this->fieldLabel('MailingLists'), MailingList::get()->map('ID', 'FullTitle')));
     }
     $fields->addFieldsToTab('Root.Main', array(Object::create('ReadonlyField', 'BouncedCount', $this->fieldLabel('BouncedCount')), Object::create('CheckboxField', 'Verified', $this->fieldLabel('Verified'))->setDescription(_t('Newsletter.VerifiedDesc', 'Has this user verified his subscription?')), Object::create('CheckboxField', 'Blacklisted', $this->fieldLabel('Blacklisted'))->setDescription(_t('Newsletter.BlacklistedDesc', 'Excluded from emails, either by automated process or manually. ' . 'An invalid address or undeliverable email will eventually result in blacklisting.')), Object::create('ReadonlyField', 'ReceivedCount', $this->fieldLabel('ReceivedCount'))->setDescription(_t('Newsletter.ReceivedCountDesc', 'Number of emails sent without undeliverable errors. ' . 'Only one indication that an email has actually been received and read.'))));
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
 function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->addFieldToTab("Root.Newsletter", new CheckboxSetField("MailingLists", "Show Mailing Lists", MailingList::get()->map()));
     return $fields;
 }
 /**
  * Returns a FieldSet with which to create the CMS editing form.
  * You can use the extend() method of FieldSet to create customised forms for your other
  * data objects.
  *
  * @param Controller
  * @return FieldSet
  */
 function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeByName('Status');
     $fields->addFieldToTab('Root.Main', new ReadonlyField('Status', $this->fieldLabel('Status')), 'Subject');
     $fields->removeByName("SentDate");
     if ($this->Status == "Sent") {
         $fields->addFieldToTab('Root.Main', new ReadonlyField('SentDate', $this->fieldLabel('SentDate')), 'Subject');
     }
     $fields->dataFieldByName('SendFrom')->setValue(Email::getAdminEmail())->setAttribute('placeholder', 'My Name <*****@*****.**>');
     $fields->dataFieldByName('ReplyTo')->setValue(Email::getAdminEmail())->setAttribute('placeholder', '*****@*****.**')->setDescription(_t('Newsletter.ReplyToDesc', 'Any undeliverable emails will be collected in this mailbox'));
     $fields->removeFieldFromTab('Root.SendRecipientQueue', "SendRecipientQueue");
     $fields->removeByName('SendRecipientQueue');
     $fields->removeByName('TrackedLinks');
     if ($this->Status != 'Sent') {
         $contentHelp = '<strong>' . _t('Newsletter.FormattingHelp', 'Formatting Help') . '</strong><br />';
         $contentHelp .= '<ul>';
         foreach ($this->getAvailablePlaceholders() as $title => $description) {
             $contentHelp .= sprintf('<li><em>$%s</em>: %s</li>', $title, $description);
         }
         $contentHelp .= '</ul>';
         $contentField = $fields->dataFieldByName('Content');
         if ($contentField) {
             $contentField->setDescription($contentHelp);
         }
     }
     // Only show template selection if there's more than one template set
     $templateSource = $this->templateSource();
     if (count($templateSource) > 1) {
         $fields->replaceField("RenderTemplate", new DropdownField("RenderTemplate", _t('NewsletterAdmin.RENDERTEMPLATE', 'Template the newsletter render to'), $templateSource));
         $explanationTitle = _t("Newletter.TemplateExplanationTitle", "Select a styled template (.ss template) that this newsletter renders with");
         $fields->insertBefore(LiteralField::create("TemplateExplanationTitle", "<h5>{$explanationTitle}</h5>"), "RenderTemplate");
         if (!$this->ID) {
             $explanation1 = _t("Newletter.TemplateExplanation1", 'You should make your own styled SilverStripe templates	make sure your templates have a' . '$Body coded so the newletter\'s content could be clearly located in your templates');
             $explanation2 = _t("Newletter.TemplateExplanation2", "Make sure your newsletter templates could be looked up in the dropdown list below by\n\t\t\t\t\teither placing them under your theme directory,\te.g. themes/mytheme/templates/email/\n\t\t\t\t\t");
             $explanation3 = _t("Newletter.TemplateExplanation3", "or under your project directory e.g. mysite/templates/email/\n\t\t\t\t\t");
             $fields->insertBefore(LiteralField::create("TemplateExplanation1", "<p class='help'>{$explanation1}</p>"), "RenderTemplate");
             $fields->insertBefore(LiteralField::create("TemplateExplanation2", "<p class='help'>{$explanation2}<br />{$explanation3}</p>"), "RenderTemplate");
         }
     } else {
         $fields->replaceField("RenderTemplate", new HiddenField('RenderTemplate', false, key($templateSource)));
     }
     if ($this && $this->exists()) {
         $fields->removeByName("MailingLists");
         $mailinglists = MailingList::get();
         $fields->addFieldToTab("Root.Main", new CheckboxSetField("MailingLists", _t('Newsletter.SendTo', "Send To", 'Selects mailing lists from set of checkboxes'), $mailinglists->map('ID', 'FullTitle')));
     }
     if ($this->Status === 'Sending' || $this->Status === 'Sent') {
         //make the whole field read-only
         $fields = $fields->transform(new ReadonlyTransformation());
         $fields->push(new HiddenField("NEWSLETTER_ORIGINAL_ID", "", $this->ID));
         $gridFieldConfig = GridFieldConfig::create()->addComponents(new GridFieldNewsletterSummaryHeader(), new GridFieldSortableHeader(), new GridFieldDataColumns(), new GridFieldFilterHeader(), new GridFieldPageCount(), new GridFieldPaginator(30));
         //Create the Sent To Queue grid
         if (class_exists("GridFieldAjaxRefresh") && $this->SendRecipientQueue()->exists()) {
             //only use auto-refresh if there is a send out currently in-progress, otherwise no-point
             if ($this->SendRecipientQueue()->filter(array('Status' => array('Scheduled', 'InProgress')))->count() > 0) {
                 $gridFieldConfig->addComponent(new GridFieldAjaxRefresh(5000, true));
             }
         }
         $sendRecipientGrid = GridField::create('SendRecipientQueue', _t('NewsletterAdmin.SentTo', 'Sent to'), $this->SendRecipientQueue(), $gridFieldConfig);
         $fields->addFieldToTab('Root.SentTo', $sendRecipientGrid);
         //only show restart queue button if the newsletter is stuck in "sending"
         //only show the restart queue button if the user can run the build task (i.e. has full admin permissions)
         if ($this->Status == "Sending" && Permission::check('ADMIN')) {
             $restartLink = Controller::join_links(Director::absoluteBaseURL(), 'dev/tasks/NewsletterSendController?newsletter=' . $this->ID);
             $fields->addFieldToTab('Root.SentTo', new LiteralField('RestartQueue', sprintf('<a href="%s" class="ss-ui-button" data-icon="arrow-circle-double">%s</a>', $restartLink, _t('Newsletter.RestartQueue', 'Restart queue processing'))));
         }
         //only show the TrackedLinks tab, if there are tracked links in the newsletter and the status is "Sent"
         if ($this->TrackedLinks()->count() > 0) {
             $fields->addFieldToTab('Root.TrackedLinks', GridField::create('TrackedLinks', _t('NewsletterAdmin.TrackedLinks', 'Tracked Links'), $this->TrackedLinks(), $gridFieldConfig));
         }
     }
     return $fields;
 }