Changeset 8612

Show
Ignore:
Timestamp:
01/14/10 17:22:41 (3 years ago)
Author:
mbrevda
Message:

re #4007; replace multipal intances of functions with variables

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/2.7/fax/functions.inc.php

    r8611 r8612  
    255255    //TODO: we want to get rid of this since it will be 2.7 only... 
    256256    // 
     257    $fax_dahdi_faxdetect=fax_dahdi_faxdetect(); 
     258    $fax_sip_faxdetect=fax_sip_faxdetect(); 
     259    $dahdi=ast_with_dahdi()?_('Dahdi'):_('Zaptel'); 
     260    $fax_detect=fax_detect(); 
    257261    $html='<script type="text/javascript">$(document).ready(function(){ 
    258262    $("input[name=Submit]").click(function(){ 
    259263      if($("input[name=faxenabled]:checked").val()=="true" && !$("input[name=gotoFAX]:checked").val()){//ensure the user selected a fax destination 
    260       alert('._('"You have selected Fax Detection on this route. Please select a valid destination to route calls detected as faxes to."').');return false; 
    261       } 
    262     }) 
    263     }); 
    264     </script>'; 
     264      alert('._('"You have selected Fax Detection on this route. Please select a valid destination to route calls detected as faxes to."').');return false; } }) });</script>'; 
    265265    $html .= '<tr><td colspan="2"><h5>'; 
    266266    $html .= _("Fax Detect"); 
    267267    $html .= '<hr></h5></td></tr>'; 
    268     $fax=fax_detect()
    269     if(!$fax['module']){//error message if there are no modules loaded in asterisk 
     268    $fax=$fax_detect
     269    /*if(!$fax['module']){//error message if there are no modules loaded in asterisk 
    270270      $html .= '<table><tr><td><style>.faxerror{color:red; '.(($faxenabled == 'no')?'':'display: none;').'}</style><span class=faxerror>'._('It seems that you dont have fax receving modules installed in Asterisk or Asterisk is unreachable.<br/> Fax-related dialplan will <strong>NOT</strong> be generated!<br /> Please contact your vendor for more information.').'</span></td></tr></table>'; 
    271     } 
     271    }*/ 
    272272    if($fax['module'] == 'res_fax' && $fax['license'] < 1){//error message if there are no fax licenses 
    273273      $html .= '<table><tr><td><style>.faxerror{color:red; '.(($faxenabled == 'no')?'':'display: none;').'}</style><span class=faxerror>'._('It seems that you dont have any fax licenses on this system. Fax-related dialplan will <strong>NOT</strong> be generated!<br /> Please contact your vendor for more information.').'</span></td></tr></table>'; 
     
    276276    $html .= '<td><a href="#" class="info">'; 
    277277    $html .= _("Detect Faxes").'<span>'._("Attemp to detect faxes on this DID.<ul><li>No: No attempts are made to auto-determain the call type; all calls sent to destination below. Use this option if this DID is used exclusevly for voice OR fax.</li><li>Yes: try to auto determain the type of call; route to the fax destination if call is a fax, otherwise send to regular destination. Use this option if you receive both voice and fax calls on this line</li></ul>").'.</span></a>:</td>'; 
    278     //js to show/hide the detection type/time/destination 
    279     $js = "if ($('input[name=extension]').val() == ''){//disable if there is no did 
    280               alert('"._('Fax detection can only be enabled when the Inbound Route contains a DID')."');return false; 
    281           } 
    282           if ($(this).val() == 'true'){ 
    283             $('.faxdetect').slideDown(); 
    284             $('select[name=faxdetection]').trigger('click'); 
    285           }else{ 
    286             $('.faxdetect').slideUp(); 
    287             $('select[name=faxdetection]').trigger('click'); 
    288           } 
    289           if(\$(this).val() == 'true'){\$('.faxerror').show();}else{\$('.faxerror').hide();//show error notice if it exists, only when using faxdetect 
    290           }"; 
    291     $html .= '<td><input type="radio" name="faxenabled" value="false" CHECKED onclick="'.$js.'"/>No'; 
    292     $html .= '<input type="radio" name="faxenabled" value="true" '.(($faxenabled == 'yes')?'CHECKED':'').' onclick="'.$js.'"/>Yes</td></tr>'; 
    293     $html .= '</table>'; 
    294278     
     279    //dont allow detection to be set if we have no valid detection types 
     280    if(!$fax_dahdi_faxdetect&&!$fax_sip_faxdetect){ 
     281      $js="if ($(this).val() == 'true'){ 
     282          alert('"._('No fax detection methods found or no valid licences. Faxing cannot be enabled.')."');return false; 
     283      }"; 
     284      $html .= '<td><input type="radio" name="faxenabled" value="false" CHECKED />No'; 
     285      $html .= '<input type="radio" name="faxenabled" value="true"  onclick="'.$js.'"/>Yes</td></tr>'; 
     286      $html .= '</table>'; 
     287    }else{//show detection options 
     288      //js to show/hide the detection type/time/destination 
     289      $js = "if ($('input[name=extension]').val() == ''){//disable if there is no did 
     290                alert('"._('Fax detection can only be enabled when the Inbound Route contains a DID')."');return false; 
     291            } 
     292            if ($(this).val() == 'true'){ 
     293              $('.faxdetect').slideDown(); 
     294              $('select[name=faxdetection]').trigger('click'); 
     295            }else{ 
     296              $('.faxdetect').slideUp(); 
     297              $('select[name=faxdetection]').trigger('click'); 
     298            } 
     299            if(\$(this).val() == 'true'){\$('.faxerror').show();}else{\$('.faxerror').hide();//show error notice if it exists, only when using faxdetect 
     300            }"; 
     301      $html .= '<td><input type="radio" name="faxenabled" value="false" CHECKED onclick="'.$js.'"/>No'; 
     302      $html .= '<input type="radio" name="faxenabled" value="true" '.(($faxenabled == 'yes')?'CHECKED':'').' onclick="'.$js.'"/>Yes</td></tr>'; 
     303      $html .= '</table>'; 
     304    }  
    295305    //fax detection+destinations 
    296306    $html .= '<table class=faxdetect '.($faxdetection?'':'style="display: none;"').'>';  
    297307    $info = engine_getinfo(); 
    298     $html .= '<tr><td width="156px"><a href="#" class="info">'._("Fax Detection type").'<span>'._("Type of fax detection to use.<ul><li>".(ast_with_dahdi()?"Dahdi":"Zaptel").": use ".(ast_with_dahdi()?"Dahdi":"Zaptel")." fax detection; requires 'faxdetect=' to be set to 'incoming' or 'both' in ".(ast_with_dahdi()?"dahdi":"zaptel").".conf</li><li>Sip: use sip fax detection (t38). Requires asterisk 1.6.2 or greater and 'faxdetect=yes' in the sip config files</li></ul>").'.</span></a>:</td>'; 
     308    $html .= '<tr><td width="156px"><a href="#" class="info">'._('Fax Detection type').'<span>'._("Type of fax detection to use.<ul><li>".$dahdi.": use ".$dahdi." fax detection; requires 'faxdetect=' to be set to 'incoming' or 'both' in ".$dahdi.".conf</li><li>Sip: use sip fax detection (t38). Requires asterisk 1.6.2 or greater and 'faxdetect=yes' in the sip config files</li></ul>").'.</span></a>:</td>'; 
    299309    $html .= '<td><select name="faxdetection" tabindex="'.++$tabindex.'">'; 
    300310    //$html .= '<option value="Auto"'.($faxdetection == 'auto' ? 'SELECTED' : '').'>'. _("Auto").'</option>';<li>Auto: allow the system to chose the best fax detection method</li> 
    301     $html .= '<option value="dahdi" '.($faxdetection == 'dahdi' ? 'SELECTED' : '').' '.(fax_dahdi_faxdetect()?'':'disabled').'>'. _((ast_with_dahdi()?"Dahdi":"Zaptel")).'</option>'; 
    302     $html .= '<option value="sip" '.($faxdetection == 'sip' ? 'SELECTED' : '').' '.((($info['version'] >= "1.6.2") && fax_sip_faxdetect())?'':'disabled').'>'. _("Sip").'</option>'; 
     311    $html .= '<option value="dahdi" '.($faxdetection == 'dahdi' ? 'SELECTED' : '').' '.($fax_dahdi_faxdetect?'':'disabled').'>'.$dahdi.'</option>'; 
     312    $html .= '<option value="sip" '.($faxdetection == 'sip' ? 'SELECTED' : '').' '.((($info['version'] >= "1.6.2") && $fax_sip_faxdetect)?'':'disabled').'>'. _("Sip").'</option>'; 
    303313/* 
    304314 * code for nvfaxdetect. I'm not sure if we should be offering this,  
     
    314324*/   
    315325    //if we cant find ANY valid faxdetect type, then dont show options   
    316     $html .= '<tr class=faxdetectionwait '.(fax_detect()&& fax_dahdi_faxdetect()?'':'style="display: none;"').'><td><a href="#" class="info">'._("Fax Detection Time").'<span>'._('How long to wait and try to detect fax. Please note that callers to a '.(ast_with_dahdi()?"dahdi":"zaptel").' channel will hear ringing for this amount of time (i.e. the system wont "answer" the call, it will just play ringing)').'.</span></a>:</td>'; 
     326    $html .= '<tr class=faxdetectionwait '.($fax_detect&& $fax_dahdi_faxdetect?'':'style="display: none;"').'><td><a href="#" class="info">'._("Fax Detection Time").'<span>'._('How long to wait and try to detect fax. Please note that callers to a '.$dahdi.' channel will hear ringing for this amount of time (i.e. the system wont "answer" the call, it will just play ringing)').'.</span></a>:</td>'; 
    317327    $html .= '<td><select name="faxdetectionwait" tabindex="'.++$tabindex.'">'; 
    318328    if(!$faxdetectionwait){$faxdetectionwait=4;}//default wait time is 4 second 
     
    322332    //if we cant find ANY valid faxdetect type, then dont show options   
    323333    $html .= '</select></td></tr>'; 
    324     $html .= '<tr class=faxdestination '.(fax_detect()?'':'style="display: none;"').'><td><a href="#" class="info">'._("Fax Destination").'<span>'._('Where to send the call if we detect that its a fax').'.</span></a>:</td>'; 
     334    $html .=  
     335    $html .= '<tr class=faxdestination '.($fax_detect?'':'style="display: none;"').'><td><a href="#" class="info">'._("Fax Destination").'<span>'._('Where to send the call if we detect that its a fax').'.</span></a>:</td>'; 
    325336    $html .= '</tr>'; 
    326     $html .= fax_detect()?drawselects(isset($faxdestination)?$faxdestination:null,'FAX'):''; 
     337    $html .= $fax_detect?drawselects(isset($faxdestination)?$faxdestination:null,'FAX'):''; 
    327338    $html .= '</table>'; 
    328339    $html .= '<table>';