@@ -106,6 +106,39 @@ function onShowEnd() {
106106
107107 }
108108
109+ /*
110+ * Now we have to check, if we should use the domain-module to select the domain
111+ * or not
112+ */
113+ $ app ->uses ('ini_parser,getconf ' );
114+ $ settings = $ app ->getconf ->get_global_config ('domains ' );
115+ if ($ settings ['use_domain_module ' ] == 'y ' ) {
116+ /*
117+ * The domain-module is in use.
118+ */
119+ $ domains = $ app ->tools_sites ->getDomainModuleDomains ();
120+ $ domain_select = '' ;
121+ if (is_array ($ domains ) && sizeof ($ domains ) > 0 ) {
122+ /* We have domains in the list, so create the drop-down-list */
123+ foreach ( $ domains as $ domain ) {
124+ $ domain_select .= "<option value= " . $ domain ['domain_id ' ] ;
125+ if ($ domain ['domain ' ].'. ' == $ this ->dataRecord ["origin " ]) {
126+ $ domain_select .= " selected " ;
127+ }
128+ $ domain_select .= "> " . $ app ->functions ->idn_decode ($ domain ['domain ' ]) . ".</option> \r\n" ;
129+ }
130+ }
131+ else {
132+ /*
133+ * We have no domains in the domain-list. This means, we can not add ANY new domain.
134+ * To avoid, that the variable "domain_option" is empty and so the user can
135+ * free enter a domain, we have to create a empty option!
136+ */
137+ $ domain_select .= "<option value=''></option> \r\n" ;
138+ }
139+ $ app ->tpl ->setVar ("domain_option " , $ domain_select );
140+ }
141+
109142 if ($ this ->id > 0 ) {
110143 //* we are editing a existing record
111144 $ app ->tpl ->setVar ("edit_disabled " , 1 );
@@ -120,6 +153,19 @@ function onShowEnd() {
120153 function onSubmit () {
121154 global $ app , $ conf ;
122155
156+ /* check if the domain module is used - and check if the selected domain can be used! */
157+ $ app ->uses ('ini_parser,getconf ' );
158+ $ settings = $ app ->getconf ->get_global_config ('domains ' );
159+ if ($ settings ['use_domain_module ' ] == 'y ' ) {
160+ $ domain_check = $ app ->tools_sites ->checkDomainModuleDomain ($ this ->dataRecord ['origin ' ]);
161+ if (!$ domain_check ) {
162+ // invalid domain selected
163+ $ app ->tform ->errorMessage .= $ app ->tform ->lng ("origin_error_empty " )."<br /> " ;
164+ } else {
165+ $ this ->dataRecord ['origin ' ] = $ domain_check .'. ' ;
166+ }
167+ }
168+
123169 if ($ _SESSION ["s " ]["user " ]["typ " ] != 'admin ' ) {
124170 // Get the limits of the client
125171 $ client_group_id = intval ($ _SESSION ["s " ]["user " ]["default_group " ]);
0 commit comments