@@ -24,64 +24,65 @@ class Mail_Form_Admin extends Zend_Form
24
24
/** Initialize this form. */
25
25
public function init ()
26
26
{
27
- $ this ->setName ('mail_config ' );
27
+ $ this ->setName ('mail_admin ' );
28
28
$ this ->setMethod ('POST ' );
29
29
30
- $ provider = new Zend_Form_Element_Select ('provider ' );
30
+ $ csrf = new Midas_Form_Element_Hash ('csrf ' );
31
+ $ csrf ->setSalt ('5qzSHzCdNuPfYaT99Jq5WcKe ' );
32
+ $ csrf ->setDecorators (array ('ViewHelper ' ));
33
+
34
+ $ provider = new Zend_Form_Element_Select (MAIL_PROVIDER_KEY );
31
35
$ provider ->setLabel ('Provider ' );
32
36
$ provider ->setRequired (true );
33
37
$ provider ->addValidator ('NotEmpty ' , true );
34
-
35
- if (class_exists ('\google\appengine\api\mail\Message ' , false )) {
36
- $ provider ->addMultiOption ('app_engine ' , 'Google App Engine ' );
37
- }
38
-
39
38
$ provider ->addMultiOptions (array (
40
- 'mail ' => 'PHP Mail Function ' ,
41
- 'send_grid ' => 'SendGrid Service ' ,
42
- 'smtp ' => 'External SMTP Server ' ,
39
+ MAIL_PROVIDER_APP_ENGINE => 'Google App Engine ' ,
40
+ MAIL_PROVIDER_MAIL => 'PHP Mail Function ' ,
41
+ MAIL_PROVIDER_SEND_GRID => 'SendGrid Service ' ,
42
+ MAIL_PROVIDER_SMTP => 'External SMTP Server ' ,
43
43
));
44
44
45
- $ fromAddress = new Zend_Form_Element_Text (' from_address ' );
45
+ $ fromAddress = new Zend_Form_Element_Text (MAIL_FROM_ADDRESS_KEY );
46
46
$ fromAddress ->setLabel ('From email address ' );
47
47
$ fromAddress ->setRequired (true );
48
48
$ fromAddress ->addValidator ('NotEmpty ' , true );
49
49
$ fromAddress ->addValidator ('EmailAddress ' , true );
50
50
51
- $ addressVerification = new Zend_Form_Element_Checkbox (' address_verification ' );
51
+ $ addressVerification = new Zend_Form_Element_Checkbox (MAIL_ADDRESS_VERIFICATION_KEY );
52
52
$ addressVerification ->setLabel ('Require email address verification ' );
53
53
54
54
$ this ->addDisplayGroup (array ($ provider , $ fromAddress , $ addressVerification ), 'global ' );
55
55
56
- $ sendGridUsername = new Zend_Form_Element_Text (' send_grid_username ' );
56
+ $ sendGridUsername = new Zend_Form_Element_Text (MAIL_SEND_GRID_USERNAME_KEY );
57
57
$ sendGridUsername ->setLabel ('SendGrid User Name ' );
58
58
$ sendGridUsername ->addValidator ('NotEmpty ' , true );
59
59
60
- $ sendGridPassword = new Zend_Form_Element_Text (' send_grid_password ' );
60
+ $ sendGridPassword = new Zend_Form_Element_Text (MAIL_SEND_GRID_PASSWORD_KEY );
61
61
$ sendGridPassword ->setLabel ('SendGrid Password ' );
62
62
$ sendGridPassword ->addValidator ('NotEmpty ' , true );
63
63
64
64
$ this ->addDisplayGroup (array ($ sendGridUsername , $ sendGridPassword ), 'send_grid ' );
65
65
66
- $ smtpHost = new Zend_Form_Element_Text (' smtp_host ' );
66
+ $ smtpHost = new Zend_Form_Element_Text (MAIL_SMTP_HOST_KEY );
67
67
$ smtpHost ->setLabel ('Server name ' );
68
68
$ smtpHost ->addValidator ('NotEmpty ' , true );
69
69
$ smtpHost ->addValidator ('Hostname ' , true );
70
70
71
- $ smtpPort = new Zend_Form_Element_Text (' smtp_port ' );
71
+ $ smtpPort = new Zend_Form_Element_Text (MAIL_SMTP_PORT_KEY );
72
72
$ smtpPort ->setLabel ('Port ' );
73
73
$ smtpPort ->addValidator ('NotEmpty ' , true );
74
74
$ smtpPort ->addValidator ('Digits ' , true );
75
- $ smtpPort ->addValidator ('Between ' , array ('min ' => 1 , 'max ' => 65535 ));
75
+ $ smtpPort ->addValidator ('Between ' , true , array ('min ' => 1 , 'max ' => 65535 ));
76
+ $ smtpPort ->setAttrib ('maxlength ' , 5 );
76
77
77
- $ smtpUseSsl = new Zend_Form_Element_Checkbox (' smtp_use_ssl ' );
78
+ $ smtpUseSsl = new Zend_Form_Element_Checkbox (MAIL_SMTP_USE_SSL_KEY );
78
79
$ smtpUseSsl ->setLabel ('Use SSL ' );
79
80
80
- $ smtpUsername = new Zend_Form_Element_Text (' smtp_username ' );
81
+ $ smtpUsername = new Zend_Form_Element_Text (MAIL_SMTP_USERNAME_KEY );
81
82
$ smtpUsername ->setLabel ('User name ' );
82
83
$ smtpUsername ->addValidator ('NotEmpty ' , true );
83
84
84
- $ smtpPassword = new Zend_Form_Element_Text ( ' smtp_password ' );
85
+ $ smtpPassword = new Zend_Form_Element_Password ( MAIL_SMTP_PASSWORD_KEY );
85
86
$ smtpPassword ->setLabel ('Password ' );
86
87
$ smtpPassword ->addValidator ('NotEmpty ' , true );
87
88
@@ -90,6 +91,6 @@ public function init()
90
91
$ submit = new Zend_Form_Element_Submit ('submit ' );
91
92
$ submit ->setLabel ('Save ' );
92
93
93
- $ this ->addElements (array ($ provider , $ fromAddress , $ addressVerification , $ smtpHost , $ smtpPort , $ smtpUseSsl , $ smtpUsername , $ smtpPassword , $ submit ));
94
+ $ this ->addElements (array ($ csrf , $ provider , $ fromAddress , $ addressVerification , $ smtpHost , $ smtpPort , $ smtpUseSsl , $ smtpUsername , $ smtpPassword , $ submit ));
94
95
}
95
96
}
0 commit comments