如何隐藏whmcs按钮?

时间:2015-07-04 15:21:03

标签: hide whmcs

您好我希望有人可以在客户详细信息页面上提供帮助我需要隐藏电子邮件转发按钮和DNS管理按钮(如果客户端已选择自定义名称服务器)。我无法解决儿子任何帮助都很受欢迎。这是接受输入的代码;

<form method="post" action="{$smarty.server.PHP_SELF}?action=domaindetails">
<input type="hidden" name="sub" value="savens">
<input type="hidden" name="id" value="{$domainid}">
<p><input type="radio" name="nschoice" value="default" id="nschoicedefault" onclick="usedefaultns()"{if $defaultns} checked{/if} /> <label for="nschoicedefault">{$LANG.nschoicedefault}</label><br />
<input type="radio" name="nschoice" value="custom" id="nschoicecustom" onclick="usecustomns()"{if !$defaultns} checked{/if} /> <label for="nschoicecustom">{$LANG.nschoicecustom}</label></p>

以下是按钮的代码;

 {if $emailforwarding}
 <td><form method="post" action="{$smarty.server.PHP_SELF}?action=domainemailforwarding">
    <input type="hidden" name="domainid" value="{$domainid}">
    <p align="center">
    <input type="submit" value="{$LANG.domainemailforwarding}" class="button">}
    </p>
    </form></td>
    {/if}
    {if $dnsmanagement}
    <td><form method="post" action="{$smarty.server.PHP_SELF}?action=domaindns">
    <input type="hidden" name="domainid" value="{$domainid}">
    <p align="center">
    {<input type="submit" value="{$LANG.domaindnsmanagement}" class="button">}
    </p>
    </form></td>
    {/if}

1 个答案:

答案 0 :(得分:1)

我建议编写一个辅助函数并在tpl文件的顶部调用它 并将域ID传递给它。

然后,您可以使用WHMCS内部API函数Domain Nameservers来获取域名服务器,然后将它们与WHMCS数据库中tblconfiguration中的默认名称服务器进行比较。

像这样的东西

{php}
  // include our helper php file
  require_once(dirname(__FILE__).'/Helper.php');

  //get domain id from our template variables 
  $domainid = $this->get_template_vars('domainid');

  //call to our helper function passing the domain ID
  $hasCustomeNameServers = Helper::hasCustomNameServers($domainid);

  //Once we've compared the nameservers agains the default ones we write
  //our binary check to the template
  if($hasCustomeNameServers >0){
  $this->assign('hasCustomeNameServers',true);}
{/php}

然后在我们的Helper.php旁边,我们有类似下面的内容

<?php

 class Helper {
   public static function hasCustomNameServers($domainid) {

      $isCustom = 0;

     //Interal API call to get the domains nameservers
     $command = "domaingetnameservers";
     $adminuser = "admin";
     $values["domainid"] = $domainid;

     $results = localAPI($command,$values,$adminuser); 

     //get default nameservers
     $defautName1 ='';
     $sql = mysql_query('SELECT value FROM tblconfiguration '.
            ' WHERE setting = "DefaultNameserver1"');
     if ($res = mysql_fetch_assoc($sql)) {  
     $defautName1 = $res["value"];}

     $defautName2 ='';
     $sql = mysql_query('SELECT value FROM tblconfiguration '.
            ' WHERE setting = "DefaultNameserver2"');
     if ($res = mysql_fetch_assoc($sql)) {  
     $defautName2 = $res["value"];}

     //compare results
     foreach ($results as &$value) {
          if($value == $defautName1 || $value == $defautName2){
            $isCustom++;
          } 
     }

    return $isCustom;   

   }
 }

现在,只需在模板上包装{if $ emailforwarding}和{if $ dnsmanagement}阻止我们的支票{if!hasCustomeNameServers}

我希望这可以帮助您朝着正确的方向前进,这绝不是一个全面的答案,而是我认为您应该采用的方法指南。

相关问题