1 <?php
2
3 4 5 6 7 8 9 10 11
12 class UnsubscribeRecord extends DataObject {
13
14 static $has_one = array(
15 'NewsletterType' => 'NewsletterType',
16 'Member' => 'Member'
17 );
18
19 20 21 22
23 function requireDefaultRecords() {
24 parent::requireDefaultRecords();
25
26 if(in_array('Email_BlackList', DB::getConn()->tableList())) {
27 DB::query("INSERT INTO \"UnsubscribeRecord\" SELECT * FROM \"Member_UnsubscribeRecord\"");
28 DB::query("RENAME TABLE \"Member_UnsubscribeRecord\" TO \"_obsolete_Member_UnsubscribeRecord\"");
29
30 echo("<div style=\"padding:5px; color:white; background-color:blue;\">Data in Member_UnsubscribeRecord has been moved to the new UnsubscribeRecord table. To drop the obsolete table, issue this SQL command: \"DROP TABLE '_obsolete_Member_UnsubscribeRecord'\".</div>");
31 }
32 }
33
34 35 36 37 38 39
40 function unsubscribe($member, $newsletterType) {
41 if(!class_exists('NewsletterType')) {
42 user_error("UnsubscribeRecord::unsubscribe() called without the newsletter module available", E_USER_WARNING);
43 return;
44 }
45
46
47 $this->MemberID = (is_numeric($member))
48 ? $member
49 : $member->ID;
50
51 $this->NewsletterTypeID = (is_numeric($newsletterType))
52 ? $newsletterType
53 : $newsletterType->ID;
54
55 $this->write();
56 }
57
58
59 protected
60 $from = '',
61 $to = '$Email',
62 $subject = '',
63 $body = '';
64
65 function __construct($record = null, $isSingleton = false) {
66 $this->subject = _t('Member.SUBJECTPASSWORDCHANGED');
67
68 $this->body = '
69 <h1>' . _t('Member.EMAILPASSWORDINTRO', "Here's your new password") . '</h1>
70 <p>
71 <strong>' . _t('Member.EMAIL') . ':</strong> $Email<br />
72 <strong>' . _t('Member.PASSWORD') . ':</strong> $Password
73 </p>
74 <p>' . _t('Member.EMAILPASSWORDAPPENDIX', 'Your password has been changed. Please keep this email, for future reference.') . '</p>';
75
76 parent::__construct($record, $isSingleton);
77 }
78 }
79
80 ?>
[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.
-