Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 2 > Tips/Tricks/Mods

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 18th August 2006, 17:28
julez julez is offline
Junior Member
 
Join Date: Jan 2006
Location: Berlin, Germany
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Generate username from email-address

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:

Code:
                // 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
Code:
"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
Reply With Quote
Sponsored Links
  #2  
Old 18th August 2006, 19:25
julez julez is offline
Junior Member
 
Join Date: Jan 2006
Location: Berlin, Germany
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default FIXED: Generate username from email-address

Hi forum,

i found a quick'n'dirty solution on my own to make it work:

Code:
                // 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" readonly="readonly" >';
                } 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"].'" onKeyUp="document.forms[0].elements[2].value = document.forms[0].elements[1].value" >@'.$web["web_domain"];
Just check the code parts marked in red and you'll see.

jz

Last edited by julez; 18th August 2006 at 19:32.
Reply With Quote
  #3  
Old 19th August 2006, 14:10
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,711
Thanks: 1,899
Thanked 2,702 Times in 2,545 Posts
Default

Sounds interesting. Please report back if it works reliably.
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #4  
Old 22nd August 2006, 14:05
julez julez is offline
Junior Member
 
Join Date: Jan 2006
Location: Berlin, Germany
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Falko,

patch is running stable for us.

Maybe it can be added to next release with an additional switch like "Generate Usernames from eMail-Address" when user-prefix ist set to [WEB] oder [DOMAIN] in ISPConfig system settings.

Regards,

jz
Reply With Quote
  #5  
Old 23rd August 2006, 15:10
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,711
Thanks: 1,899
Thanked 2,702 Times in 2,545 Posts
Default

I've added this request to our bugtracker for now.
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #6  
Old 23rd September 2006, 02:35
xgportal xgportal is offline
Junior Member
 
Join Date: Sep 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I tried that patch, but i removed the readonly, since if i don't ispconfig tells me the username must be 4 or more chars. and i left my [DOMAIN]_ setting too.
Reply With Quote
  #7  
Old 28th December 2006, 19:19
ciprianz ciprianz is offline
Junior Member
 
Join Date: Dec 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I don't why but it is not working for me
I modified in Management and set user prefix to [Domain]
I also modified the code from isp_username.plugin.php

But it doesn't modify anything in database
all it does it generates the user name.
any ideea?
Reply With Quote
  #8  
Old 29th December 2006, 16:54
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,711
Thanks: 1,899
Thanked 2,702 Times in 2,545 Posts
Default

Which ISPConfig version do you use?
The patch was made for ISPConfig 2.2.6, I don't know if it works in newer versions.
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #9  
Old 29th December 2006, 17:52
ciprianz ciprianz is offline
Junior Member
 
Join Date: Dec 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I used ISPConfig 2.2.9
Thank you for asking
Reply With Quote
  #10  
Old 30th December 2006, 21:34
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,711
Thanks: 1,899
Thanked 2,702 Times in 2,545 Posts
 
Default

I don't know if it's working in ISPConfig 2.2.9...
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
username and e-mail address jorge Installation/Configuration 5 10th March 2007 09:14
Problem with 'CC' & 'BCC' email not being delivered. snowfly HOWTO-Related Questions 10 20th July 2006 12:36
Using different username for email dstme General 3 16th November 2005 17:27
Receiving Email and Username Problem dstme General 20 16th November 2005 09:33
UebiMiau webmail adding @localhostname to email address except first address. Kamran Shah Installation/Configuration 5 11th October 2005 17:01


All times are GMT +2. The time now is 15:28.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.