Version: current

     1 <?php
     2
     3 /**
     4  * Displays a list of all members that have unsubscribed from the list
     5  *
     6  * @package newsletter
     7  */
     8 class UnsubscribedList 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 FieldHolder() {
    22         return $this->renderWith( 'NewsletterAdmin_UnsubscribedList' );
    23     }
    24
    25     function Entries() {
    26
    27         $id = $this->nlType->ID;
    28
    29         if(defined('DB::USE_ANSI_SQL')) {
    30             $unsubscribeRecords = DataObject::get('UnsubscribeRecord', "\"NewsletterTypeID\"='$id'" );
    31         } else {
    32             $unsubscribeRecords = DataObject::get('UnsubscribeRecord', "`NewsletterTypeID`='$id'" );
    33         }
    34
    35
    36         // user_error($id, E_USER_ERROR );
    37
    38         if( !$unsubscribeRecords )
    39             return null;
    40
    41         foreach( $unsubscribeRecords as $unsubscribeRecord ) {
    42             if( $unsubscribeRecord ) {
    43                 $unsubscribedUsers[] = new ArrayData( array(
    44                     'Record' => $unsubscribeRecord,
    45                     'Member' => DataObject::get_by_id( 'Member', $unsubscribeRecord->MemberID )
    46                 ));
    47             }
    48         }
    49
    50         return new DataObjectSet( $unsubscribedUsers );
    51     }
    52
    53     function setController($controller) {
    54         $this->controller = $controller;
    55     }
    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. -