File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -115,6 +115,19 @@ public function getSubscriberById( $id )
115
115
return $ result ->fetch ( \PDO ::FETCH_ASSOC );
116
116
}
117
117
118
+ public function getSubscriberByEmail ( $ emailAddress )
119
+ {
120
+ $ result = $ this ->db ->query (
121
+ sprintf (
122
+ "SELECT * FROM %s
123
+ WHERE email = '%s' " ,
124
+ $ this ->config ->getTableName ( 'user ' , true ),
125
+ $ emailAddress
126
+ )
127
+ );
128
+ return $ result ->fetch ( \PDO ::FETCH_ASSOC );
129
+ }
130
+
118
131
/**
119
132
* Cleanly delete all records of a subscriber from DB
120
133
* @param int $id ID of subscriber to delete
Original file line number Diff line number Diff line change @@ -135,6 +135,10 @@ public function add( \phpList\Entity\SubscriberEntity $scrEntity )
135
135
throw new \Exception ( 'Cannot insert subscriber with invalid email address: " ' . $ scrEntity ->emailAddress . '" ' );
136
136
}
137
137
138
+ $ entity = $ this ->subscriberModel ->getSubscriberByEmail ($ scrEntity ->emailAddress );
139
+ if ($ entity ["email " ] !== null )
140
+ throw new \Exception ("Subscriber with that email already exists " );
141
+
138
142
// Save subscriber to db
139
143
$ newSubscriberId = $ this ->subscriberModel ->save (
140
144
$ scrEntity ->emailAddress
You can’t perform that action at this time.
0 commit comments