Disabling username in add client form

Discussion in 'Developers' Forum' started by erosbk, Feb 21, 2012.

  1. erosbk

    erosbk New Member

    Is there a way to disallow modifing of "username" field when a reseller edits a client?

    As I could see, if I disable it, it is disabled to when creating... so, where do I have to modify to avoid this behavior?

    As I recall, if username is used as a prefix for ftp/database, is not a good idea to modify the user name of a client.

    Thanks
     
  2. till

    till Super Moderator

    There is no such function available.

    Thats why I use the clientid as prefix for all servivces on my servers and not the username.
     
  3. erosbk

    erosbk New Member

    Thanks Till, I want to implement a restriction, but the problem is that the same code is used to add new client and to modify an existing one. Maybe I could create a copy of the file, and, if it is a modification, call the new one...

    Another solution could be to remove the username in the update sentence when saving client, could you say me please where is that sentence?

    Thanks in advance, maybe in a future I will switch to clientid, but it is not possible right now
     
  4. till

    till Super Moderator

    The form "knows" if its in edit or add mode. Take a look e.g. at the website edit, database edit or email domain edit file to see how a field is disabled on edit in ispconfig.
     
  5. erosbk

    erosbk New Member

    Thanks Till!!! I made some changes and it is working. If it could be userfull, I can paste here the code, maybe with a little modification in server settings a feature like "disable username change" could be implemented, for people like me that prefers loss functionality in pro of using username instead client_id

    Thanks again
     
  6. till

    till Super Moderator

    Please post your code, I will check how we can integrate this in ispconfig.
     
  7. erosbk

    erosbk New Member

    Two files must be edited. I think this could be applied when creating resellers too, I didn't try it yet

    /usr/local/ispconfig/interface/web/client/client_edit.php

    At line (aprox): 129

    Add this code before "parent::eek:nShowEnd():"
    Code:
                    if($this->id > 0) {
                            //* we are editing a existing record
                            $app->tpl->setVar("edit_disabled", 1);
                    } else {
                            $app->tpl->setVar("edit_disabled", 0);
                    }
    
    /usr/local/ispconfig/interface/web/client/templates/client_edit_address.htm

    At line (aprox): 20 -Inside "<div class="ctrlHolder">"

    This lines must be replaced:

    Code:
            <label for="username">{tmpl_var name='username_txt'}*</label>
            <input name="username" id="username" value="{tmpl_var name='username'}" size="30" maxlength="255" type="text" class="textInput" />
    
    with this lines:

    Code:
    <tmpl_if name="edit_disabled">
            <label for="username">{tmpl_var name='username_txt'}*</label>
            <input name="username" id="username" disabled="disabled" value="{tmpl_var name='username'}" size="30" maxlength="255" type="text" class="textInput" />
            <input name="username" type="hidden" value="{tmpl_var name='username'}" />
    <tmpl_else>
            <label for="username">{tmpl_var name='username_txt'}*</label>
            <input name="username" id="username" value="{tmpl_var name='username'}" size="30" maxlength="255" type="text" class="textInput" />
    </tmpl_if>
    
     

Share This Page