Version: current

     1 <?php
     2
     3 /**
     4  * Form field showing a list of bounced addresses
     5  *
     6  * @package newsletter
     7  */
     8 class BouncedList extends FormField {
     9
    10     protected $nlType;
    11
    12     function __construct( $name, $newsletterType ) {
    13         parent::__construct( $name, '', null );
    14
    15         if( is_object( $newsletterType ) )
    16             $this->nlType = $newsletterType;
    17         else
    18             $this->nlType = DataObject::get_by_id( 'NewsletterType', $newsletterType );
    19     }
    20
    21     function setController($controller) {
    22         $this->controller = $controller;
    23     }
    24
    25     function FieldHolder() {
    26         return $this->renderWith( 'NewsletterAdmin_BouncedList' );
    27     }
    28
    29     function Entries() {
    30
    31         $id = $this->nlType->GroupID;
    32
    33         if(defined('DB::USE_ANSI_SQL')) {
    34             //$bounceRecords = DataObject::get( 'Email_BounceRecord', "\"GroupID\"=\"$id\"", null, "INNER JOIN \"Group_Members\" USING(\"MemberID\")" );
    35             $bounceRecords = DataObject::get( 'Email_BounceRecord', "\"GroupID\"='$id'", null, "INNER JOIN \"Group_Members\" ON \"Email_BounceRecord\".\"MemberID\" = \"Group_Members\".\"MemberID\"" );
    36         } else {
    37             $bounceRecords = DataObject::get( 'Email_BounceRecord', "`GroupID`='$id'", null, "INNER JOIN `Group_Members` USING(`MemberID`)" );
    38         }
    39
    40         //user_error($id, E_USER_ERROR );
    41
    42         if( !$bounceRecords )
    43             return null;
    44
    45         foreach( $bounceRecords as $bounceRecord ) {
    46             if( $bounceRecord ) {
    47                 $bouncedUsers[] = new ArrayData( array(
    48                     'Record' => $bounceRecord,
    49                     'GroupID' => $id,
    50                     'Member' => DataObject::get_by_id( 'Member', $bounceRecord->MemberID )
    51                 ));
    52             }
    53         }
    54
    55         return new DataObjectSet( $bouncedUsers );
    56     }
    57 }
    58 ?>

[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -