Changeset 8685

Show
Ignore:
Timestamp:
01/25/10 23:41:45 (3 years ago)
Author:
p_lindheimer
Message:

add rxfax/spandsp option and skip nvfax if not installed re #4007

Files:

Legend:

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

    r8683 r8685  
    9393  if ($amp_conf['AMPENGINE'] == 'asterisk' && isset($astman) && $astman->connected()) { 
    9494    //check for fax modules 
    95     $app = $astman->send_request('Command', array('Command' => 'module show like app_fax.so')); 
    96     if (preg_match('/1 modules loaded/', $app['data'])){$fax['module']='app_fax';} 
     95    $app = $astman->send_request('Command', array('Command' => 'module show like res_fax.so')); 
     96    if (preg_match('/1 modules loaded/', $app['data'])){ 
     97      $fax['module']='res_fax'; 
     98    } else { 
     99      $recive = $astman->send_request('Command', array('Command' => 'module show like app_fax.so')); 
     100      if (preg_match('/1 modules loaded/', $recive['data'])){$fax['module']='app_fax';} 
     101    } 
     102    //TODO: verify this is the right test, no system to check it on yet 
     103    if (!isset($fax['module'])) { 
     104      $app = $astman->send_request('Command', array('Command' => 'module show like app_rxfax.so')); 
     105      $fax['module'] = preg_match('/1 modules loaded/', $app['data']) ? 'spandsp': null; 
     106    } 
    97107    $response = $astman->send_request('Command', array('Command' => 'module show like app_nv_faxdetect.so')); 
    98     if (preg_match('/1 modules loaded/', $response['data'])){$fax['module']='nv_faxdetect';} 
    99     $recive = $astman->send_request('Command', array('Command' => 'module show like res_fax.so')); 
    100     if (preg_match('/1 modules loaded/', $recive['data'])){$fax['module']='res_fax';} 
     108    $fax['nvfax']= preg_match('/1 modules loaded/', $response['data']) ? true : false; 
     109 
    101110    //get license count 
    102111    $lic = $astman->send_request('Command', array('Command' => 'fax show stats')); 
     
    111120 
    112121function fax_get_config($engine){ 
     122 
    113123  $fax=fax_detect(); 
    114   if($fax['module'] == 'app_fax' || $fax['module'] == 'res_fax'){ //dont continue unless we have a fax module in asterisk 
     124  if($fax['module']){ //dont continue unless we have a fax module in asterisk 
    115125    global $ext; 
    116126    global $amp_conf; 
     127    global $core_conf; 
     128    global $version; 
     129 
     130    if (version_compare($version, '1.6', 'ge') && isset($core_conf) && is_a($core_conf, "core_conf")) { 
     131      $core_conf->addSipGeneral('faxdetect','yes'); 
     132    } 
    117133    $dests=fax_get_destinations(); 
    118134    $sender_address=sql('SELECT value FROM fax_details WHERE `key` = \'sender_address\'','getRow'); 
     
    123139        $ext->add($context, $exten, '', new ext_noop('Reciving Fax for Fax Recipient: '.$row['name'].' ('.$row['user'].'), From: ${CALLERID(all)}')); 
    124140        $ext->add($context, $exten, '', new ext_set('TO', '"'.$row['faxemail'].'"'));      
    125         $ext->add($context, $exten, 'receivefax', new ext_receivefax('${ASTSPOOLDIR}/fax/${UNIQUEID}.tif')); //recive fax, then email it on 
     141        if ($fax['module'] == 'spandsp') { 
     142          $ext->add($context, $exten, 'receivefax', new ext_rxfax('${ASTSPOOLDIR}/fax/${UNIQUEID}.tif')); //recive fax, then email it on 
     143        } else { 
     144          $ext->add($context, $exten, 'receivefax', new ext_receivefax('${ASTSPOOLDIR}/fax/${UNIQUEID}.tif')); //recive fax, then email it on 
     145        } 
    126146      } 
    127147      $ext->add($context, 'h', '', new ext_execif('$["${TO}" != ""]','system','\'${ASTVARLIBDIR}/bin/fax-process.pl --to ${TO} --from "'.$sender_address['0'].'" --dest "${FROM_DID}" --subject "New fax from ${URIENCODE(${CALLERID(all)})}" --attachment fax_${URIENCODE(${CALLERID(number)})}.pdf --type application/pdf --file ${ASTSPOOLDIR}/fax/${UNIQUEID}.tif\'')); 
     
    137157  $exten = 's'; 
    138158  $ext->add($context, $exten, '', new ext_noop('Reciving Fax for Fax Recipient: ${FAX_RX_EMAIL} , From: ${CALLERID(all)}')); 
    139   $ext->add($context, $exten, 'receivefax', new ext_receivefax('${ASTSPOOLDIR}/fax/${UNIQUEID}.tif')); //recive fax, then email it on 
     159  if ($fax['module'] == 'spandsp') { 
     160    $ext->add($context, $exten, 'receivefax', new ext_rxfax('${ASTSPOOLDIR}/fax/${UNIQUEID}.tif')); //recive fax, then email it on 
     161  } else { 
     162    $ext->add($context, $exten, 'receivefax', new ext_receivefax('${ASTSPOOLDIR}/fax/${UNIQUEID}.tif')); //recive fax, then email it on 
     163  } 
    140164  $ext->add($context, 'h', '', new ext_execif('$["${FAX_RX_EMAIL}" != ""]','system','\'${ASTVARLIBDIR}/bin/fax-process.pl --to ${FAX_RX_EMAIL} --from "'.$sender_address['0'].'" --dest "${FROM_DID}" --subject "New fax from ${URIENCODE(${CALLERID(all)})}" --attachment fax_${URIENCODE(${CALLERID(number)})}.pdf --type application/pdf --file ${ASTSPOOLDIR}/fax/${UNIQUEID}.tif\'')); 
    141165 
     
    297321    //$html.='<option value="Auto"'.($faxdetection == 'auto' ? 'SELECTED' : '').'>'. _("Auto").'</option>';<li>Auto: allow the system to chose the best fax detection method</li>    
    298322    $html.='<option value="dahdi" '.($fax['detection'] == 'dahdi' ? 'SELECTED' : '').' '.($fax_dahdi_faxdetect?'':'disabled').'>'.$dahdi.'</option>'; 
    299     $html.='<option value="nvfax"'.($fax['detection'] == 'nvfax' ? 'SELECTED' : '').($fax_dahdi['module']=='nv_fax'?'':'disabled').'>'. _("NVFax").'</option>'; 
     323    $html.='<option value="nvfax"'.($fax['detection'] == 'nvfax' ? 'SELECTED' : '').($fax_detect['nvfax']?'':'disabled').'>'. _("NVFax").'</option>'; 
    300324    $html.='<option value="sip" '.($fax['detection'] == 'sip' ? 'SELECTED' : '').' '.((($info['version'] >= "1.6.2") && $fax_sip_faxdetect)?'':'disabled').'>'. _("Sip").'</option>'; 
    301325    $html.='</select></td></tr>'; 
     
    325349} 
    326350 
     351//TODO: modify to check for nvfaxdetect before iserting it and nothing if not there. 
     352//TODO: if not too lazy, put an error into notification panel 
    327353function fax_hookGet_config($engine){ 
    328354  $fax=fax_detect(); 
    329   if($fax['module'] == 'app_fax' || $fax['module'] == 'res_fax'){ //dont continue unless we have a fax module in asterisk 
     355  if($fax['module']){ //dont continue unless we have a fax module in asterisk 
    330356    global $ext; 
    331357    global $engine; 
    332358    $routes=fax_get_incoming(); 
    333359    foreach($routes as $current => $route){ 
     360      if ($route['detection'] == 'nvfax' && !$fax['nvfax']) { 
     361        continue; // skip this one if there is no NVFaxdetect installed on this system 
     362      } 
    334363      if($route['extension']=='' && $route['cidnum']){//callerID only 
    335364        $extension='s/'.$route['cidnum']; 
     
    401430function fax_save_settings($settings){ 
    402431  global $db; 
    403   foreach($settings as $key => $value){ 
     432  if (is_array($settings)) foreach($settings as $key => $value){ 
    404433    sql("REPLACE INTO fax_details (`key`, `value`) VALUES ('".$key."','".$db->escapeSimple($value)."')"); 
    405434  }