@@ -70,15 +70,23 @@ function onShowNew() {
7070 }
7171
7272 parent ::onShowNew ();
73- }
74-
75- function onShowEnd () {
76- global $ app , $ conf ;
7773
78- $ app ->tpl ->setVar ("selector " , str_replace ('._domainkey ' , '' , $ this ->dataRecord ['name ' ]), true );
79- $ app ->tpl ->setVar ("public_key " , str_replace ('v=DKIM1; t=s; p= ' , '' , $ this ->dataRecord ['data ' ]), true );
74+ $ soa = $ app ->db ->queryOneRecord ("SELECT * FROM dns_soa WHERE id = ? AND " . $ app ->tform ->getAuthSQL ('r ' ), $ _GET ['zone ' ]);
75+ $ sql =$ app ->db ->queryOneRecord ("SELECT domain, dkim_public, dkim_selector, dkim FROM mail_domain WHERE domain = ? AND " . $ app ->tform ->getAuthSQL ('r ' ), substr_replace ($ soa ['origin ' ],'' ,-1 ));
76+ if (isset ($ sql ['domain ' ]) && $ sql ['domain ' ] != '' ) {
77+ if ($ sql ['dkim ' ] == 'y ' ) {
78+ $ public_key =str_replace (array ('-----BEGIN PUBLIC KEY----- ' ,'-----END PUBLIC KEY----- ' ,"\r" ,"\n" ),'' ,$ sql ['dkim_public ' ]);
79+ $ app ->tpl ->setVar ('public_key ' , $ public_key , true );
80+ $ app ->tpl ->setVar ('selector ' , $ sql ['dkim_selector ' ], true );
81+ } else {
82+ //TODO: show warning - use mail_domain for dkim and enabled dkim
83+ }
84+ $ app ->tpl ->setVar ('edit_disabled ' , 1 );
85+ } else {
86+ $ app ->tpl ->setVar ('edit_disabled ' , 0 );
87+ }
88+ $ app ->tpl ->setVar ('name ' , $ soa ['origin ' ], true );
8089
81- parent ::onShowEnd ();
8290 }
8391
8492 function onSubmit () {
@@ -109,7 +117,7 @@ function onSubmit() {
109117 // add dkim-settings to the public-key in the txt-record
110118 if (!empty ($ this ->dataRecord ['data ' ])) {
111119 $ this ->dataRecord ['data ' ]='v=DKIM1; t=s; p= ' .$ this ->dataRecord ['data ' ];
112- $ this ->dataRecord ['name ' ]=$ this ->dataRecord ['selector ' ].'._domainkey ' ;
120+ $ this ->dataRecord ['name ' ]=$ this ->dataRecord ['selector ' ].'._domainkey. ' . $ this -> dataRecord [ ' name ' ] ;
113121// $this->dataRecord['ttl']=60;
114122 }
115123 // Update the serial number and timestamp of the RR record
0 commit comments