Changeset 8685
- Timestamp:
- 01/25/10 23:41:45 (3 years ago)
- Files:
-
- modules/branches/2.7/fax/functions.inc.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/branches/2.7/fax/functions.inc.php
r8683 r8685 93 93 if ($amp_conf['AMPENGINE'] == 'asterisk' && isset($astman) && $astman->connected()) { 94 94 //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 } 97 107 $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 101 110 //get license count 102 111 $lic = $astman->send_request('Command', array('Command' => 'fax show stats')); … … 111 120 112 121 function fax_get_config($engine){ 122 113 123 $fax=fax_detect(); 114 if($fax['module'] == 'app_fax' || $fax['module'] == 'res_fax'){ //dont continue unless we have a fax module in asterisk124 if($fax['module']){ //dont continue unless we have a fax module in asterisk 115 125 global $ext; 116 126 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 } 117 133 $dests=fax_get_destinations(); 118 134 $sender_address=sql('SELECT value FROM fax_details WHERE `key` = \'sender_address\'','getRow'); … … 123 139 $ext->add($context, $exten, '', new ext_noop('Reciving Fax for Fax Recipient: '.$row['name'].' ('.$row['user'].'), From: ${CALLERID(all)}')); 124 140 $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 } 126 146 } 127 147 $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\'')); … … 137 157 $exten = 's'; 138 158 $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 } 140 164 $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\'')); 141 165 … … 297 321 //$html.='<option value="Auto"'.($faxdetection == 'auto' ? 'SELECTED' : '').'>'. _("Auto").'</option>';<li>Auto: allow the system to chose the best fax detection method</li> 298 322 $html.='<option value="dahdi" '.($fax['detection'] == 'dahdi' ? 'SELECTED' : '').' '.($fax_dahdi_faxdetect?'':'disabled').'>'.$dahdi.'</option>'; 299 $html.='<option value="nvfax"'.($fax['detection'] == 'nvfax' ? 'SELECTED' : '').($fax_d ahdi['module']=='nv_fax'?'':'disabled').'>'. _("NVFax").'</option>';323 $html.='<option value="nvfax"'.($fax['detection'] == 'nvfax' ? 'SELECTED' : '').($fax_detect['nvfax']?'':'disabled').'>'. _("NVFax").'</option>'; 300 324 $html.='<option value="sip" '.($fax['detection'] == 'sip' ? 'SELECTED' : '').' '.((($info['version'] >= "1.6.2") && $fax_sip_faxdetect)?'':'disabled').'>'. _("Sip").'</option>'; 301 325 $html.='</select></td></tr>'; … … 325 349 } 326 350 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 327 353 function fax_hookGet_config($engine){ 328 354 $fax=fax_detect(); 329 if($fax['module'] == 'app_fax' || $fax['module'] == 'res_fax'){ //dont continue unless we have a fax module in asterisk355 if($fax['module']){ //dont continue unless we have a fax module in asterisk 330 356 global $ext; 331 357 global $engine; 332 358 $routes=fax_get_incoming(); 333 359 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 } 334 363 if($route['extension']=='' && $route['cidnum']){//callerID only 335 364 $extension='s/'.$route['cidnum']; … … 401 430 function fax_save_settings($settings){ 402 431 global $db; 403 foreach($settings as $key => $value){432 if (is_array($settings)) foreach($settings as $key => $value){ 404 433 sql("REPLACE INTO fax_details (`key`, `value`) VALUES ('".$key."','".$db->escapeSimple($value)."')"); 405 434 }
