[solved]Hide / Disable to client set websites as inactive

Discussion in 'Developers' Forum' started by branov, Apr 1, 2019.

  1. branov

    branov New Member

    Hi, Im trying to modify ISPConfig and hide field "Active" in website creating / editing form. I do not want to let clients to enable or disable their websites on their own.

    I tried to this modification of ''sites/templates/web_vhost_domain_edit.htm'' (added is_admin condition)

    Code:
    <tmpl_if name="is_admin"> {tmpl_hook name="field_active"} <div class="form-group"> <label class="col-sm-3 control-label">{tmpl_var name='active_txt'}</label> <div class="col-sm-9"> {tmpl_var name='active'} </div> </div> </tmpl_if>
    
    But there is a problem with this modification. Every website edit user made = website is set as inactive.

    I try to look around the code what is the active/inactive workaround but I didnt find anything how this function works. Where is the string / form created / inserted / setted.

    Please, can you someone help me, how to achieve my goal? Or is possible to implement this feature also to ISPConfig release?

    Thank you so much!
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    When you create the website as admin for the client then the site is under admin protection, a client can not set it to inactive himself then, no matter if he sees the active checkbox or not.

    Regarding your code, the problem with that is that you try to hide an HTML checkbox and when it's not present, then this is the same as when it is unticked so the website gets turned off.
     
  3. branov

    branov New Member

    I know, that when is website created by admin is protected by user changes. But, in my case, the user create website, then admin disable / inactive this website and I want to prevent to user to re-enable the site.

    Till, what is your recomandation to do this code changes in right way, please?
     
  4. branov

    branov New Member

    I tried to modify my change to:

    Code:
    <tmpl_if name="is_admin">
    {tmpl_hook name="field_active"}
    <div class="form-group">
    <label class="col-sm-3 control-label">{tmpl_var name='active_txt'}</label>
    <div class="col-sm-9">
    {tmpl_var name='active'}
    </div>
    </div>
    <tmpl_else>
    <input type="hidden" name="active" value="{tmpl_var name='active'}" />
    </tmpl_if>
    
    and set default value for hidden active field in the web_vhost_domain_edit.php but this code cause this {tmpl_var name='active'} in the hidden field is replace by another input field ({tmpl_var name='active'} is replaced by <input type=.......).
     
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    This can not work as {tmpl_var name='active'} is not a field value, it is the complete html checkbox code.
     
  6. branov

    branov New Member

    OK, another idea, can I somehow set "disabled" attribute to this auto-generated HTML if is client logged in? This could be much mor easier change in the code to achieve my goal.
     
  7. branov

    branov New Member

    solved
     
  8. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    You did not write how it was solved. Users finding this thread later are disappointed to not see how to solve the issue.
     

Share This Page