julez
18th August 2006, 18:28
Hi forum,
System installed is:
- SuSE 10.1
- ISPConfig 2.2.6 stable
We set up our system with prefix [DOMAIN]_ so that every user gets a system username like "domain.tld_user".
Now to keep the system clean we'd like generate all usernames from their given email-addresses. "user1@domain.tld" would automatically get "domain.tld_user1" as his system username.
An _almost_ smooth way to reach that would be editing /home/admispconfig/ispconfig/lib/plugins/isp_username.plugin.php line 80+ this way:
// neuer Username
if($user_prefix != '') {
// Mit User-Prefix
$len_textbox = ((30 - strlen($user_prefix)) < 10)? 10: 29 - strlen($user_prefix);
// PRE-MOD $out_user = $user_prefix.'<input type="text" name="plugin[user]" size="'.$len_textbox.'" maxlength="'.(32 - strlen($user_prefix)).'" class="text" >';
$out_user = $user_prefix.'<input type="text" name="plugin[user]" size="'.$len_textbox.'" maxlength="'.(32 - strlen($user_prefix)).'" class="text" onBlur="this.form.plugin[user].value = this.form.plugin[email].value" >';
} else {
//Ohne User-Prefix
$out_user = $user_prefix.'<input type="text" name="plugin[user]" size="30" maxlength="32" class="text">';
}
$go_api->renderer->element_jscript_nummer++;
}
/************************************************** **
* Emailadresse vorbereiten
************************************************** ***/
//if($go_api->db->queryOneRecord("SELECT * FROM isp_isp_domain, isp_dep, isp_nodes WHERE isp_isp_domain.doc_id = isp_dep.child_doc_id AND isp_isp_domain.doctype_id = isp_dep.child_doctype_id AND isp_dep.parent_doctype_id = ".$web['doctype_id']." AND isp_dep.p
//PRE-MOD $out_email = '<input type="text" name="plugin[email]" size="10" maxlength="32" class="text" value="'.$user["user_email"].'">@'.$web["web_domain"];
$out_email = '<input type="text" name="plugin[email]" size="10" maxlength="32" class="text" value="'.$user["user_email"].'" onBlur="this.form.plugin[user].value = this.form.plugin[email].value" >@'.$web["web_domain"]; }
Leaving the field "email" would fill the next field "username" automatically an keep the value even if changed manually.
Unfortunately Javascript can't deal with the brackets [] in
"this.form.plugin[user].value = this.form.plugin[email].value".
I tested it with renamed input name="pluginemail" and input name="pluginuser" and it worked like a charm.
Renaming the input name="plugin[email]" will break ISPConfig. Leaving them like they are breaks the hack.
Any hints on another solution are highly appreciated.
jz
System installed is:
- SuSE 10.1
- ISPConfig 2.2.6 stable
We set up our system with prefix [DOMAIN]_ so that every user gets a system username like "domain.tld_user".
Now to keep the system clean we'd like generate all usernames from their given email-addresses. "user1@domain.tld" would automatically get "domain.tld_user1" as his system username.
An _almost_ smooth way to reach that would be editing /home/admispconfig/ispconfig/lib/plugins/isp_username.plugin.php line 80+ this way:
// neuer Username
if($user_prefix != '') {
// Mit User-Prefix
$len_textbox = ((30 - strlen($user_prefix)) < 10)? 10: 29 - strlen($user_prefix);
// PRE-MOD $out_user = $user_prefix.'<input type="text" name="plugin[user]" size="'.$len_textbox.'" maxlength="'.(32 - strlen($user_prefix)).'" class="text" >';
$out_user = $user_prefix.'<input type="text" name="plugin[user]" size="'.$len_textbox.'" maxlength="'.(32 - strlen($user_prefix)).'" class="text" onBlur="this.form.plugin[user].value = this.form.plugin[email].value" >';
} else {
//Ohne User-Prefix
$out_user = $user_prefix.'<input type="text" name="plugin[user]" size="30" maxlength="32" class="text">';
}
$go_api->renderer->element_jscript_nummer++;
}
/************************************************** **
* Emailadresse vorbereiten
************************************************** ***/
//if($go_api->db->queryOneRecord("SELECT * FROM isp_isp_domain, isp_dep, isp_nodes WHERE isp_isp_domain.doc_id = isp_dep.child_doc_id AND isp_isp_domain.doctype_id = isp_dep.child_doctype_id AND isp_dep.parent_doctype_id = ".$web['doctype_id']." AND isp_dep.p
//PRE-MOD $out_email = '<input type="text" name="plugin[email]" size="10" maxlength="32" class="text" value="'.$user["user_email"].'">@'.$web["web_domain"];
$out_email = '<input type="text" name="plugin[email]" size="10" maxlength="32" class="text" value="'.$user["user_email"].'" onBlur="this.form.plugin[user].value = this.form.plugin[email].value" >@'.$web["web_domain"]; }
Leaving the field "email" would fill the next field "username" automatically an keep the value even if changed manually.
Unfortunately Javascript can't deal with the brackets [] in
"this.form.plugin[user].value = this.form.plugin[email].value".
I tested it with renamed input name="pluginemail" and input name="pluginuser" and it worked like a charm.
Renaming the input name="plugin[email]" will break ISPConfig. Leaving them like they are breaks the hack.
Any hints on another solution are highly appreciated.
jz