Changeset 8688 for modules/branches/2.7/fax
- Timestamp:
- 01/26/10 21:46:19 (3 years ago)
- Files:
-
- modules/branches/2.7/fax/functions.inc.php (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/branches/2.7/fax/functions.inc.php
r8686 r8688 57 57 58 58 function fax_dahdi_faxdetect(){ 59 return true;60 61 //TODO Get this right62 59 /* 63 60 * kepping this always set to true for freepbx 2.7 as we cant currently properly detect this - MB 64 61 * 65 62 */ 66 global $asterisk_conf; 67 $faxdetect=false; 68 $dadset=parse_ini_file($asterisk_conf['astetcdir'].'/'.(ast_with_dahdi()?'chan_dahdi':'zapata').'.conf'); 69 return (isset($dadset['faxdetect']) && ($dadset['faxdetect'] == 'incoming' || $dadset['faxdetect'] == 'both')); 63 return true; 70 64 } 71 65 … … 94 88 //check for fax modules 95 89 $app = $astman->send_request('Command', array('Command' => 'module show like res_fax')); 96 if (preg_match('/ 1modules loaded/', $app['data'])){90 if (preg_match('/[1-9] modules loaded/', $app['data'])){ 97 91 $fax['module']='res_fax'; 98 92 } else { 99 93 $recive = $astman->send_request('Command', array('Command' => 'module show like app_fax')); 100 if (preg_match('/ 1modules loaded/', $recive['data'])){$fax['module']='app_fax';}94 if (preg_match('/[1-9] modules loaded/', $recive['data'])){$fax['module']='app_fax';} 101 95 } 102 //TODO: verify this is the right test, no system to check it on yet103 96 if (!isset($fax['module'])) { 104 97 $app = $astman->send_request('Command', array('Command' => 'module show like app_rxfax.so')); 105 $fax['module'] = preg_match('/ 1modules loaded/', $app['data']) ? 'spandsp': null;98 $fax['module'] = preg_match('/[1-9] modules loaded/', $app['data']) ? 'spandsp': null; 106 99 } 107 100 $response = $astman->send_request('Command', array('Command' => 'module show like app_nv_faxdetect')); 108 $fax['nvfax']= preg_match('/ 1modules loaded/', $response['data']) ? true : false;101 $fax['nvfax']= preg_match('/[1-9] modules loaded/', $response['data']) ? true : false; 109 102 110 103 //get license count … … 137 130 foreach ($dests as $row) { 138 131 $exten=$row['user']; 139 $ext->add($context, $exten, '', new ext_noop('Rec iving Fax for Fax Recipient: '.$row['name'].' ('.$row['user'].'), From: ${CALLERID(all)}'));132 $ext->add($context, $exten, '', new ext_noop('Receiving Fax for: '.$row['name'].' ('.$row['user'].'), From: ${CALLERID(all)}')); 140 133 $ext->add($context, $exten, '', new ext_set('TO', '"'.$row['faxemail'].'"')); 141 134 if ($fax['module'] == 'spandsp') { … … 151 144 //write out res_fax.conf and res_fax_digium.conf 152 145 fax_write_conf(); 153 } 154 // generate ext-fax-legacy used for both legacy mode and app-fax feature code155 //156 $context='ext-fax-legacy';157 $exten = 's';158 $ext->add($context, $exten, '', new ext_noop('Reciving Fax for Fax Recipient: ${FAX_RX_EMAIL} , From: ${CALLERID(all)}'));159 if ($fax['module'] == 'spandsp') {160 $ext->add($context, $exten, 'receivefax', new ext_rxfax('${ASTSPOOLDIR}/fax/${UNIQUEID}.tif')); //recive fax, then email it on161 } else {162 $ext->add($context, $exten, 'receivefax', new ext_receivefax('${ASTSPOOLDIR}/fax/${UNIQUEID}.tif')); //recive fax, then email it on163 }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\''));165 166 $modulename = 'fax';167 $fcc = new featurecode($modulename, 'simu_fax');168 $fc_simu_fax = $fcc->getCodeActive();169 unset($fcc);170 171 if ($fc_simu_fax != '') {172 $default_address = sql('SELECT value FROM fax_details WHERE `key` = \'FAX_RX_EMAIL\'','getRow');173 $ext->addInclude('from-internal-additional', 'app-fax'); // Add the include from from-internal174 $ext->add('app-fax', $fc_simu_fax, '', new ext_setvar('FAX_RX_EMAIL', $default_address[0]));175 $ext->add('app-fax', $fc_simu_fax, '', new ext_goto('1', 's', 'ext-fax-legacy'));176 $ext->add('app-fax', 'h', '', new ext_macro('hangupcall'));177 }146 // generate ext-fax-legacy used for both legacy mode and app-fax feature code 147 // 148 $context='ext-fax-legacy'; 149 $exten = 's'; 150 $ext->add($context, $exten, '', new ext_noop('Receiving Fax for: ${FAX_RX_EMAIL} , From: ${CALLERID(all)}')); 151 if ($fax['module'] == 'spandsp') { 152 $ext->add($context, $exten, 'receivefax', new ext_rxfax('${ASTSPOOLDIR}/fax/${UNIQUEID}.tif')); //recive fax, then email it on 153 } else { 154 $ext->add($context, $exten, 'receivefax', new ext_receivefax('${ASTSPOOLDIR}/fax/${UNIQUEID}.tif')); //recive fax, then email it on 155 } 156 $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\'')); 157 158 $modulename = 'fax'; 159 $fcc = new featurecode($modulename, 'simu_fax'); 160 $fc_simu_fax = $fcc->getCodeActive(); 161 unset($fcc); 162 163 if ($fc_simu_fax != '') { 164 $default_address = sql('SELECT value FROM fax_details WHERE `key` = \'FAX_RX_EMAIL\'','getRow'); 165 $ext->addInclude('from-internal-additional', 'app-fax'); // Add the include from from-internal 166 $ext->add('app-fax', $fc_simu_fax, '', new ext_setvar('FAX_RX_EMAIL', $default_address[0])); 167 $ext->add('app-fax', $fc_simu_fax, '', new ext_goto('1', 's', 'ext-fax-legacy')); 168 $ext->add('app-fax', 'h', '', new ext_macro('hangupcall')); 169 } 170 } 178 171 } 179 172 … … 291 284 292 285 //dont allow detection to be set if we have no valid detection types 293 if(!$fax_dahdi_faxdetect &&!$fax_sip_faxdetect){286 if(!$fax_dahdi_faxdetect && !$fax_sip_faxdetect && !$fax_detect['nvfax']){ 294 287 $js="if ($(this).val() == 'true'){alert('"._('No fax detection methods found or no valid licences. Faxing cannot be enabled.')."');return false;}"; 295 288 $html.='<td><input type="radio" name="faxenabled" value="false" CHECKED />No'; … … 336 329 $html.='<table class="legacyemail" >'; 337 330 $html.='<tr ><td><a href="#" class="info">'._("Fax Email Destination").'<span>'._('Address to email faxes to on fax detection.<br />PLEASE NOTE: In this version of FreePBX, you can now set the fax destination from a list of destinations. Extensions/Users can be fax enabled in the user/extension screen and set an email address there. This will create a new destination type that can be selected. To upgrade this option to the full destination list, select YES to Detect Faxes and select a destination. After clicking submit, this route will be upgraded. This Legacy option will no longer be available after the change, it is provided to handle legacy migrations from previous versions of FreePBX only.').'.</span></a>:</td>'; 338 $html.='<td><input name=" faxlegacyemail" value="'.$fax['legacy_email'].'"></td></tr>';331 $html.='<td><input name="legacy_email" value="'.$fax['legacy_email'].'"></td></tr>'; 339 332 $html.='</table>'; 340 333 $html.='<table class="faxdest27 faxdetect" style="display: none" >'; … … 349 342 } 350 343 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 panel353 344 function fax_hookGet_config($engine){ 354 345 $fax=fax_detect(); … … 359 350 foreach($routes as $current => $route){ 360 351 if ($route['detection'] == 'nvfax' && !$fax['nvfax']) { 352 //TODO: add notificatoin to notification panel that this was skipped because NVFaxdetec not present 361 353 continue; // skip this one if there is no NVFaxdetect installed on this system 362 354 } … … 380 372 } else { 381 373 if (!isset($default_fax_rx_email)) { 382 //TODO Need to add error checking383 //384 374 $default_address = sql('SELECT value FROM fax_details WHERE `key` = \'fax_rx_email\'','getRow'); 385 375 $default_fax_rx_email = $default_address[0]; … … 403 393 $display=isset($_REQUEST['display'])?$_REQUEST['display']:''; 404 394 $action=isset($_REQUEST['action'])?$_REQUEST['action']:''; 405 $cidnum=isset($_REQUEST['cidnum'])?$_REQUEST['cidnum']:''; 406 $extension=isset($_REQUEST['extension'])?$_REQUEST['extension']:''; 407 $extdisplay=isset($_REQUEST['extdisplay'])?$_REQUEST['extdisplay']:''; 408 $enabled=isset($_REQUEST['faxenabled'])?$_REQUEST['faxenabled']:''; 409 $detection=isset($_REQUEST['faxdetection'])?$_REQUEST['faxdetection']:''; 410 $detectionwait=isset($_REQUEST['faxdetectionwait'])?$_REQUEST['faxdetectionwait']:''; 411 $dest=(isset($_REQUEST['gotoFAX'])?$_REQUEST['gotoFAX'].'FAX':null); 412 $dest=isset($_REQUEST[$dest])?$_REQUEST[$dest]:''; 413 $legacy_email=isset($_REQUEST['legacy_email'])?$_REQUEST['legacy_email']:NULL; 414 if(!isset($legacy_email)||isset($dest)){$legacy_email=null;} 415 416 if ($display == 'did' && isset($action) && $action!=''){ 395 if ($display == 'did' && $action!=''){ 396 397 $cidnum=isset($_REQUEST['cidnum'])?$_REQUEST['cidnum']:''; 398 $extension=isset($_REQUEST['extension'])?$_REQUEST['extension']:''; 399 $extdisplay=isset($_REQUEST['extdisplay'])?$_REQUEST['extdisplay']:''; 400 $enabled=isset($_REQUEST['faxenabled'])?$_REQUEST['faxenabled']:'false'; 401 $detection=isset($_REQUEST['faxdetection'])?$_REQUEST['faxdetection']:''; 402 $detectionwait=isset($_REQUEST['faxdetectionwait'])?$_REQUEST['faxdetectionwait']:''; 403 $dest=(isset($_REQUEST['gotoFAX'])?$_REQUEST['gotoFAX'].'FAX':null); 404 $dest=isset($_REQUEST[$dest])?$_REQUEST[$dest]:''; 405 if ($enabled != 'legacy') { 406 $legacy_email = null; 407 } else { 408 $legacy_email=isset($_REQUEST['legacy_email'])?$_REQUEST['legacy_email']:''; 409 } 417 410 fax_delete_incoming($extdisplay); //remove mature entry on edit or delete 418 if (($action == 'edtIncoming' ||$action == 'addIncoming')&& $enabled=='true'){411 if (($action == 'edtIncoming' || $action == 'addIncoming') && $enabled != 'false'){ 419 412 fax_save_incoming($cidnum,$extension,$enabled,$detection,$detectionwait,$dest,$legacy_email); 420 413 } … … 425 418 function fax_save_incoming($cidnum,$extension,$enabled,$detection,$detectionwait,$dest,$legacy_email){ 426 419 global $db; 427 sql("INSERT INTO fax_incoming (cidnum, extension, detection, detectionwait, destination, legacy_email) VALUES ('".$db->escapeSimple($cidnum)."', '".$db->escapeSimple($extension)."', '".$db->escapeSimple($detection)."', '".$db->escapeSimple($detectionwait)."', '".$db->escapeSimple($dest)."','".$db-> quoteSmart($legacy_email)."')");420 sql("INSERT INTO fax_incoming (cidnum, extension, detection, detectionwait, destination, legacy_email) VALUES ('".$db->escapeSimple($cidnum)."', '".$db->escapeSimple($extension)."', '".$db->escapeSimple($detection)."', '".$db->escapeSimple($detectionwait)."', '".$db->escapeSimple($dest)."','".$db->escapeSimple($legacy_email)."')"); 428 421 } 429 422 … … 446 439 global $asterisk_conf; 447 440 return true; 448 //TODO Fix This Later449 /*450 * kepping this always set to true for freepbx 2.7 as we cant currently properly detect this - MB451 *452 */453 //these files probobly shouldnt be hardcoded454 $files=array('sip_general_additional.conf','sip_general_custom.conf','sip_custom.conf');455 foreach($files as $file){$set.=parse_ini_file($file);}//read setting from files456 return ($set['faxdetect'] == 'yes');457 441 } 458 442
