diff --git a/code/Newsletter/BouncedList.php b/code/Newsletter/BouncedList.php
index 38da33e9..fe516903 100755
--- a/code/Newsletter/BouncedList.php
+++ b/code/Newsletter/BouncedList.php
@@ -19,8 +19,36 @@ class BouncedList extends TableListField {
function sourceItems() {
$id = $this->nlType->GroupID;
- // @TODO Try to find way to show Firstname and Surname under a 'Username' heading
- return DataObject::get( 'Email_BounceRecord', "`GroupID`='$id'", null, "INNER JOIN `Group_Members` USING(`MemberID`)" );
+ // @TODO Try to find way to show Firstname and Surname under a 'Username' heading";
+ // Get a list of all bounces for all subscribers to this mailing list
+ $bouncedSubscribers = DataObject::get( 'Email_BounceRecord', "`GroupID`='$id'", null, "INNER JOIN `Group_Members` USING(`MemberID`)" );
+
+ // @TODO Find faster/elegenter way to do this. Probably some sort of SQL JOIN would work instead
+ // If there are bounces logged for this Mailing List
+ if ($bouncedSubscribers) {
+ $bouncedSubscribersWithMemberID = new DataObjectSet();
+ // Convert bounce to array so we can easily iterate through them
+ $bouncedSubscribersArray = $bouncedSubscribers->toArray();
+ // Iterate through each bounce record and add 'GroupID' to it (this is clumsy)
+ foreach($bouncedSubscribersArray as $key => $bouncedSubscriberObject)
+ {
+ $bouncedSubscriberArray = $bouncedSubscriberObject->getAllFields();
+ // Add MemberID to DataObjectSet so the removebouncedmember link will work
+ $bouncedSubscriberArray['GroupID'] = $id;
+ $bouncedSubscribersWithMemberID->push(new ArrayData($bouncedSubscriberArray));
+ }
+ return $bouncedSubscribersWithMemberID;
+ } else {
+ return null;
+ }
+
+ }
+
+ /**
+ * Sets the template to be rendered with
+ */
+ function FieldHolder() {
+ return $this->renderWith('NewsletterAdmin_BouncedList');
}
function setController($controller) {
@@ -28,12 +56,7 @@ class BouncedList extends TableListField {
}
// Not needed now that we are extending TableListField instead of FormField
- // @TODO Remove NewsletterAdmin_BouncedList.ss after copying out any needed bits
/*
- function FieldHolder() {
- return $this->renderWith( 'NewsletterAdmin_BouncedList' );
- }
-
function Entries() {
$id = $this->nlType->GroupID;
diff --git a/code/NewsletterAdmin.php b/code/NewsletterAdmin.php
index 705102f2..e6f7c7e4 100755
--- a/code/NewsletterAdmin.php
+++ b/code/NewsletterAdmin.php
@@ -291,7 +291,7 @@ class NewsletterAdmin extends LeftAndMain {
$unsubscribedList = new UnsubscribedList("Unsubscribed", $mailType)
),
new Tab("Bounced",
- new LiteralField('Instructions', '
Instructions:
- Uncheck the box and click the "Save" button to disable sending to an email address.
- To delete an email address from your mailing list, click the red "X" icon.
'),
+ new LiteralField('Instructions', 'Instructions:
- Uncheck the box and click the "Save" button to disable sending to an email address. @TODO Make this functional
- To remove a recipients\'s email address from your mailing list, click the red "X" icon.
'),
$bouncedList = new BouncedList("Bounced", $mailType )
)
)
@@ -323,6 +323,37 @@ class NewsletterAdmin extends LeftAndMain {
}
+ /**
+ * Removes a bounced member from the mailing list
+ *
+ * @return String
+ */
+ function removebouncedmember($urlParams) {
+ // First remove the Bounce entry
+ $memberID = Convert::raw2sql($urlParams['ID']);
+ if (is_numeric($memberID)) {
+ $bounceObject = DataObject::get_by_id('Email_BounceRecord', $memberID);
+ if($bounceObject) {
+ // Remove this bounce record
+ $bounceObject->delete();
+
+ $memberObject = DataObject::get_by_id('Member', $bounceObject->MemberID);
+ $groupID = Convert::raw2sql($_REQUEST['GroupID']);
+ if(is_numeric($groupID) && is_object($memberObject)) {
+ // Remove the member from the mailing list
+ $memberObject->Groups()->remove($groupID);
+ } else {
+ user_error("MemberTableField::delete: Bad parameters: Group=$groupID, Member=$memberID", E_USER_ERROR);
+ }
+ // @TODO Reload whole right frame so that Recipients and Bounced tabs will be updated after bounced member is removed.
+ return 1;
+ }
+ }else{
+ return 0;
+ }
+ }
+
+
/**
* Reloads the list of recipients via ajax
*/
diff --git a/templates/Includes/NewsletterAdmin_BouncedList.ss b/templates/Includes/NewsletterAdmin_BouncedList.ss
index 38199653..6f105bb7 100755
--- a/templates/Includes/NewsletterAdmin_BouncedList.ss
+++ b/templates/Includes/NewsletterAdmin_BouncedList.ss
@@ -1,24 +1,55 @@
-<% if Entries %>
-
-
-
- User name |
- Email address |
- Reason: |
- Last bounce at |
-
-
-
- <% control Entries %>
-
- $Member.FirstName $Member.Surname |
- $Member.Email |
- $Record.BounceMessage |
- $Record.Created.Long |
-
- <% end_control %>
-
-
-<% else %>
-No emails sent have bounced.
-<% end_if %>
+
+ <% include TableListField_PageControls %>
+
+
+
+ <% if Markable %> | <% end_if %>
+ <% control Headings %>
+ $Title |
+ <% end_control %>
+ <% if Can(delete) %> | <% end_if %>
+
+
+
+ <% if HasSummary %>
+
+
+ <% if Markable %> | <% end_if %>
+ $SummaryTitle |
+ <% control SummaryFields %>
+ class="$Function"<% end_if %>> |
+ <% end_control %>
+ <% if Can(delete) %> | <% end_if %>
+
+
+ <% end_if %>
+
+
+ <% if Items %>
+ <% control Items %>
+ class="$HighlightClasses"<% end_if %>>
+ <% if Markable %>$MarkingCheckbox | <% end_if %>
+ <% control Fields %>
+ $Value |
+ <% end_control %>
+ <% if Can(delete) %>
+ |
+ <% end_if %>
+
+ <% end_control %>
+ <% else %>
+
+ <% if Markable %> | <% end_if %>
+ No bounce records found |
+ <% if Can(delete) %> | <% end_if %>
+
+ <% end_if %>
+ <% if Can(add) %>$AddRecordForm.AsTableRow<% end_if %>
+
+
+
+ <% if Can(export) %>
+ $ExportButton
+ <% end_if %>
+
+
\ No newline at end of file