File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11<?php
22namespace Craft \Plugins \Postmaster \NotificationTypes ;
33
4+ use Craft \PostmasterHelper ;
5+ use Craft \Postmaster_TransportModel ;
46use Craft \Plugins \Postmaster \Components \BaseNotificationType ;
57
68class DefaultNotificationType extends BaseNotificationType {
@@ -9,6 +11,18 @@ class DefaultNotificationType extends BaseNotificationType {
911
1012 public $ id = 'default ' ;
1113
14+ public function onBeforeSend (Postmaster_TransportModel $ model )
15+ {
16+ $ this ->notification ->parse (array ());
17+
18+ if ($ this ->hasExtraConditionals () && !$ this ->areExtraConditionalsValid ())
19+ {
20+ return false ;
21+ }
22+
23+ return true ;
24+ }
25+
1226 public function getInputHtml (Array $ data = array ())
1327 {
1428 return $ this ->craft ()->templates ->render ('postmaster/notification_types/default/fields ' , $ data );
@@ -23,4 +37,15 @@ public function getSettingsModelClassName()
2337 {
2438 return '\Craft\Postmaster_DefaultNotificationTypeSettingsModel ' ;
2539 }
40+
41+ public function hasExtraConditionals ()
42+ {
43+ return PostmasterHelper::hasExtraConditionals ($ this ->getSetting ('extraConditionals ' ));
44+ }
45+
46+ public function areExtraConditionalsValid ()
47+ {
48+ return PostmasterHelper::validateExtraConditionals ($ this ->getSetting ('extraConditionals ' ));
49+ }
50+
2651}
Original file line number Diff line number Diff line change @@ -145,19 +145,12 @@ public function areTriggersValid($isNewEntry)
145145
146146 public function hasExtraConditionals ()
147147 {
148- $ extra = trim ($ this ->getSetting ('extraConditionals ' ));
149-
150- if ($ extra && !empty ($ extra ))
151- {
152- return true ;
153- }
154-
155- return false ;
148+ return PostmasterHelper::hasExtraConditionals ($ this ->getSetting ('extraConditionals ' ));
156149 }
157150
158151 public function areExtraConditionalsValid ()
159152 {
160- return strtolower ($ this ->settings -> extraConditionals ) !== ' false ' ? true : false ;
153+ return PostmasterHelper:: validateExtraConditionals ($ this ->getSetting ( ' extraConditionals ' )) ;
161154 }
162155
163156 public function areStatusesValid (EntryModel $ entry )
@@ -186,22 +179,6 @@ public function areSectionsValid(EntryModel $entry)
186179 return false ;
187180 }
188181
189- /*
190- public function parseExtraConditionals(EntryModel $entry)
191- {
192- if($this->hasExtraConditionals())
193- {
194- $return = craft()->templates->renderString($this->settings->extraConditionals, array(
195- 'entry' => $entry
196- ));
197-
198- return trim($return);
199- }
200-
201- return;
202- }
203- */
204-
205182 public function getEvents ()
206183 {
207184 if (is_array ($ this ->settings ->events ) && count ($ this ->settings ->events ))
Original file line number Diff line number Diff line change 1+ <?php
2+ namespace Craft ;
3+
4+ class PostmasterHelper
5+ {
6+ public static function hasExtraConditionals ($ extraConditionals )
7+ {
8+ if ($ extraConditionals && !empty ($ extraConditionals ))
9+ {
10+ return true ;
11+ }
12+
13+ return false ;
14+ }
15+
16+ public static function validateExtraConditionals ($ extraConditionals )
17+ {
18+ return strtolower ($ extraConditionals ) !== 'false ' ;
19+ }
20+ }
You can’t perform that action at this time.
0 commit comments