function queues_check_compoundrecordings()
{
    global $db;
    $compound_recordings = array();
    $sql = "SELECT extension, descr, agentannounce_id, ivr_id FROM queues_config WHERE (ivr_id != 'none' AND ivr_id != '') OR agentannounce_id != ''";
    $results = sql($sql, "getAll", DB_FETCHMODE_ASSOC);
    if (function_exists('ivr_get_details')) {
        $ivr_details = ivr_get_details();
        foreach ($ivr_details as $item) {
            $ivr_hash[$item['id']] = $item;
        }
        $check_ivr = true;
    } else {
        $check_ivr = false;
    }
    foreach ($results as $result) {
        $agentannounce = $result['agentannounce_id'] ? recordings_get_file($result['agentannounce_id']) : '';
        if (strpos($agentannounce, "&") !== false) {
            $compound_recordings[] = array('extension' => $result['extension'], 'descr' => $result['descr'], 'error' => _("Agent Announce Msg"));
        }
        if ($result['ivr_id'] != 'none' && $result['ivr_id'] != '' && $check_ivr) {
            $id = $ivr_hash[$result['ivr_id']]['announcement_id'];
            $announce = $id ? recordings_get_file($id) : '';
            if (strpos($announce, "&") !== false) {
                $compound_recordings[] = array('extension' => $result['extension'], 'descr' => $result['descr'], 'error' => sprintf(_("IVR Announce: %s"), $ivr_hash[$result['ivr_id']]['displayname']));
            }
        }
    }
    return $compound_recordings;
}
Esempio n. 2
0
function ivr_show_edit($id, $nbroptions, $post)
{
    global $db;
    global $tabindex;
    $ivr_details = ivr_get_details($id);
    $ivr_dests = ivr_get_dests($id);
    ?>
	<div class="content">
	<h2><?php 
    echo _("Digital Receptionist");
    ?>
</h2>
	<h3><?php 
    echo _("Edit Menu") . " " . $ivr_details['displayname'];
    ?>
</h3>
<?php 
    ?>
	<form name="prompt" action="<?php 
    $_SERVER['PHP_SELF'];
    ?>
" method="post" onsubmit="return prompt_onsubmit();">
	<input type="hidden" name="action" value="edited" />
	<input type="hidden" name="display" value="ivr" />
	<input type="hidden" name="id" value="<?php 
    echo $id;
    ?>
" />
	<input name="Submit" type="submit" value="<?php 
    echo _("Save");
    ?>
" tabindex="<?php 
    echo ++$tabindex;
    ?>
" disabled>
<?php 
    $usage_list = array();
    if (function_exists('queues_ivr_usage')) {
        $usage_list = queues_ivr_usage($id);
    }
    if (count($usage_list)) {
        ?>
		<a href="#" class="info"><?php 
        echo _("Queue Breakout Menu Usage List");
        ?>
<span><?php 
        echo _("This IVR is being used by the following Queues, providing an ability for callers to hear this Queue's announcement periodically and giving callers an option to break out of the queue into this IVR's menu options. This queue can not be deleted when being used in this mode");
        ?>
</span></a>
<?php 
        $count = 0;
        foreach ($usage_list as $link) {
            $label = '<span><img width="16" height="16" border="0" title="' . $link['description'] . '" alt="" src="images/queue_link.png"/>&nbsp;' . $link['description'] . '</span>';
            echo "<br /><a href=" . $link['url_query'] . ">" . $label . "</a>";
        }
        echo "<br />";
    } else {
        ?>
	<input name="delete" type="submit" value="<?php 
        echo _("Delete") . " " . _("Digital Receptionist") . " {$ivr_details['displayname']}";
        ?>
" disabled/>
<?php 
    }
    if ($id) {
        $usage_list = framework_display_destination_usage(ivr_getdest($id));
        if (!empty($usage_list)) {
            ?>
			<br /><a href="#" class="info"><?php 
            echo $usage_list['text'];
            ?>
:<span><?php 
            echo $usage_list['tooltip'];
            ?>
</span></a>
		<?php 
        }
    }
    ?>
	<table>
		<tr><td colspan=2><hr /></td></tr>
		<tr>
			<td><a href="#" class="info"><?php 
    echo _("Change Name");
    ?>
<span><?php 
    echo _("This changes the short name, visible on the right, of this IVR");
    ?>
</span></a></td>
			<td><input type="text" name="displayname" value="<?php 
    echo $ivr_details['displayname'];
    ?>
" tabindex="<?php 
    echo ++$tabindex;
    ?>
"></td>
		</tr>

<?php 
    $annmsg_id = isset($ivr_details['announcement_id']) ? $ivr_details['announcement_id'] : '';
    if (function_exists('recordings_list')) {
        //only include if recordings is enabled
        ?>
		<tr>
			<td><a href="#" class="info"><?php 
        echo _("Announcement");
        ?>
<span><?php 
        echo _("Message to be played to the caller. To add additional recordings please use the \"System Recordings\" MENU to the left");
        ?>
</span></a></td>
			<td>
				<select name="annmsg_id" tabindex="<?php 
        echo ++$tabindex;
        ?>
">
				<?php 
        $tresults = recordings_list();
        echo '<option value="">' . _("None") . "</option>";
        if (isset($tresults[0])) {
            foreach ($tresults as $tresult) {
                echo '<option value="' . $tresult['id'] . '"' . ($tresult['id'] == $annmsg_id ? ' SELECTED' : '') . '>' . $tresult['displayname'] . "</option>\n";
            }
        }
        ?>
				</select>
			</td>
		</tr>
	
<?php 
    } else {
        ?>
		<tr>
			<td><a href="#" class="info"><?php 
        echo _("Announcement");
        ?>
<span><?php 
        echo _("Message to be played to the caller.<br><br>You must install and enable the \"Systems Recordings\" Module to edit this option");
        ?>
</span></a></td>
			<td>
			<?php 
        $default = isset($annmsg_id) ? $annmsg_id : '';
        ?>
				<input type="hidden" name="annmsg_id" value="<?php 
        echo $default;
        ?>
"><?php 
        echo $default != '' ? $default : 'None';
        ?>
			</td>
		</tr>
<?php 
    }
    ?>
		<tr>
			<td><a href="#" class="info"><?php 
    echo _("Timeout");
    ?>
<span><?php 
    echo _("The amount of time (in seconds) before the 't' option, if specified, is used");
    ?>
</span></a></td>
			<td><input type="text" name="timeout" value="<?php 
    echo $ivr_details['timeout'];
    ?>
" tabindex="<?php 
    echo ++$tabindex;
    ?>
"></td>
		</tr>
		<?php 
    if ($ivr_details['enable_directory'] && function_exists('voicemail_getVoicemail')) {
        ?>
		<tr>
			<td><a href="#" class="info"><?php 
        echo _("Enable Directory");
        ?>
<span><?php 
        echo _("Let callers into the IVR dial '#' to access the directory. WARNING: this feature is deprecated and will be removed from future versions. You should install the Directory module and assign an IVR destination to use Directory functionality.");
        ?>
</span></a></td>
			<td><input type="checkbox" name="ena_directory" <?php 
        echo $ivr_details['enable_directory'];
        ?>
 tabindex="<?php 
        echo ++$tabindex;
        ?>
"></td>
		</tr>
		<tr>
			<td><a href="#" class="info"><?php 
        echo _("Directory Context");
        ?>
<span><?php 
        echo _("When # is selected, this is the voicemail directory context that is used");
        ?>
</span></a></td>
			<td>
				<select name="dircontext" tabindex="<?php 
        echo ++$tabindex;
        ?>
">
					<?php 
        $vm_results = voicemail_getVoicemail();
        $vmcontexts = array_keys($vm_results);
        foreach ($vmcontexts as $vmc) {
            if ($vmc != 'general' && $vmc != 'zonemessages') {
                echo '<option value="' . $vmc . '"' . ($vmc == $ivr_details['dircontext'] ? ' SELECTED' : '') . '>' . $vmc . "</option>\n";
            }
        }
        ?>
				</select>
			</td>
		</tr>
		<?php 
    }
    ?>
		<tr>
			<td><a href="#" class="info"><?php 
    echo _("VM Return to IVR");
    ?>
<span><?php 
    echo _("If checked, upon exiting voicemail a caller will be returned to this IVR if they got a users voicemail");
    ?>
</span></a></td>
			<td><input type="checkbox" name="retvm" <?php 
    echo $ivr_details['retvm'];
    ?>
 tabindex="<?php 
    echo ++$tabindex;
    ?>
"></td>
		</tr>
<?php 
    if (!function_exists('directory_list')) {
        ?>
		<tr>
			<td><a href="#" class="info"><?php 
        echo _("Enable Direct Dial");
        ?>
<span><?php 
        echo _("Let callers into the IVR dial an extension directly");
        ?>
</span></a></td>
			<td><input type="checkbox" name="ena_directdial" <?php 
        echo $ivr_details['enable_directdial'];
        ?>
 tabindex="<?php 
        echo ++$tabindex;
        ?>
"></td>
		</tr>
<?php 
    } else {
        ?>
		<tr>
			<td><a href="#" class="info"><?php 
        echo _("Direct Dial Options");
        ?>
<span><?php 
        echo _("Provides options for callers to direct dial an extension. Direct dialing can be completely disabled, it can be enabled for all extensions on a system, or it can be tied to a Company Directory allowing any member listed in that directory to be dialed directly if their extension is known. If an extension in the chosen directory is overridden, only that overridden number is dialable");
        ?>
</span></a></td>
			<td>
				<select name="ena_directdial" tabindex="<?php 
        echo ++$tabindex;
        ?>
">
					<?php 
        $dlist = directory_list();
        echo '<option value=""' . ($ivr_details['enable_directdial'] == '' ? ' SELECTED' : '') . '>' . _('Disabled') . "</option>\n";
        echo '<option value="CHECKED"' . (strtoupper($ivr_details['enable_directdial']) == 'CHECKED' ? ' SELECTED' : '') . '>' . _('All Extensions') . "</option>\n";
        foreach ($dlist as $dir) {
            echo '<option value="' . $dir['id'] . '"' . ($ivr_details['enable_directdial'] == $dir['id'] ? ' SELECTED' : '') . '>' . $dir['dirname'] . "</option>\n";
        }
        ?>
				</select>
			</td>
		</tr>

<?php 
    }
    ?>
		<tr>
			<td><a href="#" class="info"><?php 
    echo _("Loop Before t-dest");
    ?>
<span><?php 
    echo _("If checked, and there is a 't' (timeout) destination defined below, the IVR will loop back to the beginning if no input is provided for the designated loop counts prior to going to the timeout (t) destination.");
    ?>
</span></a></td>
			<td><input type="checkbox" name="alt_timeout" <?php 
    echo $ivr_details['alt_timeout'];
    ?>
 tabindex="<?php 
    echo ++$tabindex;
    ?>
"></td>
		</tr>
<?php 
    $timeout_id = isset($ivr_details['timeout_id']) ? $ivr_details['timeout_id'] : '';
    if (function_exists('recordings_list')) {
        //only include if recordings is enabled
        ?>
		<tr>
			<td><a href="#" class="info"><?php 
        echo _("Timeout Message");
        ?>
<span><?php 
        echo _("If a timeout occurs and a message is selected, it will be played in place of the announcement message when looping back to the top of the IVR. It will not be played if the t destination is the next target.");
        ?>
</span></a></td>
			<td>
				<select name="timeout_id" tabindex="<?php 
        echo ++$tabindex;
        ?>
">
				<?php 
        //$tresults obtained above
        echo '<option value="">' . _("None") . "</option>";
        if (isset($tresults[0])) {
            foreach ($tresults as $tresult) {
                echo '<option value="' . $tresult['id'] . '"' . ($tresult['id'] == $timeout_id ? ' SELECTED' : '') . '>' . $tresult['displayname'] . "</option>\n";
            }
        }
        ?>
				</select>
			</td>
		</tr>
<?php 
    }
    ?>
		<tr>
			<td><a href="#" class="info"><?php 
    echo _("Loop Before i-dest");
    ?>
<span><?php 
    echo _("If checked, and there is an 'i' (invalid extension) destination defined below, the IVR will play invalid option and then loop back to the beginning for the designated loop counts prior to going to the invalid (i) destination.");
    ?>
</span></a></td>
			<td><input type="checkbox" name="alt_invalid" <?php 
    echo $ivr_details['alt_invalid'];
    ?>
 tabindex="<?php 
    echo ++$tabindex;
    ?>
"></td>
		</tr>
<?php 
    $invalid_id = isset($ivr_details['invalid_id']) ? $ivr_details['invalid_id'] : '';
    if (function_exists('recordings_list')) {
        //only include if recordings is enabled
        ?>
		<tr>
			<td><a href="#" class="info"><?php 
        echo _("Invalid Message");
        ?>
<span><?php 
        echo _("If an invalid extension is pressed and a message is selected, it will be played in place of the announcement message when looping back to the top of the IVR. It will not be played if the t destination is the next target. If nothing is selected, the system will play a default invalid extension message before going back to the main announcement");
        ?>
</span></a></td>
			<td>
				<select name="invalid_id" tabindex="<?php 
        echo ++$tabindex;
        ?>
">
				<?php 
        //$tresults obtained above
        echo '<option value="">' . _("None") . "</option>";
        if (isset($tresults[0])) {
            foreach ($tresults as $tresult) {
                echo '<option value="' . $tresult['id'] . '"' . ($tresult['id'] == $invalid_id ? ' SELECTED' : '') . '>' . $tresult['displayname'] . "</option>\n";
            }
        }
        ?>
				</select>
			</td>
		</tr>
<?php 
    }
    ?>
		<tr>
			<td><a href="#" class="info"><?php 
    echo _("Repeat Loops:");
    ?>
<span><?php 
    echo _("The number of times we should loop when invalid input or no input has been entered before going to the defined or default generated 'i' or 't' options. If the 'i' or 't' options are defined, the above check boxes must be checked in order to loop.");
    ?>
</span></a></td>
			<td>
				<select name="loops" tabindex="<?php 
    echo ++$tabindex;
    ?>
">
				<?php 
    $default = isset($ivr_details['loops']) ? $ivr_details['loops'] : 2;
    for ($i = 0; $i <= 9; $i++) {
        echo '<option value="' . $i . '" ' . ($i == $default ? 'SELECTED' : '') . '>' . $i . '</option>';
    }
    ?>
		
				</select>		
			</td>
		</tr>

		<tr><td colspan=2><hr /></td></tr>
		<tr><td colspan=2>

			<input name="increase" type="submit" value="<?php 
    echo _("Increase Options");
    ?>
" disabled>
			&nbsp;
			<input name="Submit" type="submit" value="<?php 
    echo _("Save");
    ?>
" tabindex="<?php 
    echo ++$tabindex;
    ?>
" disabled>
			&nbsp;
			<?php 
    if ($nbroptions > 1) {
        ?>
			<input name="decrease" type="submit" value="<?php 
        echo _("Decrease Options");
        ?>
" disabled>
			<?php 
    }
    ?>
		</td>
	</tr>
	<tr><td colspan=2><hr /></td></tr></table>
	<style type="text/css">
	#ivr-dests tr:nth-child(odd){
	background-color: #FCE7CE;
	}
	</style>
	<table id="ivr-dests">
<?php 
    // Draw the destinations
    $dests = ivr_get_dests($id);
    $count = 0;
    if (!empty($dests)) {
        foreach ($dests as $dest) {
            drawdestinations($count, $dest['selection'], $dest['dest'], $dest['ivr_ret']);
            $count++;
        }
    }
    while ($count < $nbroptions) {
        drawdestinations($count, null, null, 0);
        $count++;
    }
    ?>
	
</table>
<?php 
    if ($nbroptions < $count) {
        echo "<input type='hidden' name='nbroptions' value={$count} />\n";
    } else {
        echo "<input type='hidden' name='nbroptions' value={$nbroptions} />\n";
    }
    global $module_hook;
    echo $module_hook->hookHtml;
    ?>
	<input name="increase" type="submit" value="<?php 
    echo _("Increase Options");
    ?>
" disabled>
	&nbsp;
	<input name="Submit" type="submit" value="<?php 
    echo _("Save");
    ?>
" disabled>
	&nbsp;
	<?php 
    if ($nbroptions > 1) {
        ?>
	<input name="decrease" type="submit" value="<?php 
        echo _("Decrease Options");
        ?>
" disabled>
	<?php 
    }
    ?>
	
	<script language="javascript">
	<!--
$(document).ready(function() {  
	$(':submit:disabled').removeAttr('disabled'); 
});

function delEntry(e){
	$('[name=option'+e+'],[name=goto'+e+']').val('').parent().parent().fadeOut(500,function(){$(this).remove();});
}
 
var theForm = document.prompt;
theForm.displayname.focus();

	function prompt_onsubmit() {
		var msgInvalidOption = "<?php 
    echo _("Invalid option");
    ?>
";
		
		defaultEmptyOK = true;

		// go thru the form looking for options
		// where the option isn't blank (as that will be removed) do the validation
	    var allelems = theForm.elements;
        if (allelems != null)
        {
        	var i, elem;
            for (i = 0; elem = allelems[i]; i++)
            {
            	if (elem.type == 'text' && elem.name.indexOf('option') == 0)
                {
                	if (elem.value != '') {
                    	if (!isIVROption(elem.value))
                        	return warnInvalid(elem, msgInvalidOption);
                        
                        var gotoNum = elem.name.charAt(6);
                        var isok = validateSingleDestination(theForm,gotoNum,true);
                        if (!isok)
                        	return false;
                    }
                 }
          	}
        }
                              	
		return true;
	}
	
	//-->

	</script>
        </form>
        </div>
<?php 
}
function fax_get_config($engine)
{
    global $version;
    global $ext;
    global $amp_conf;
    global $core_conf;
    global $astman;
    $ast_ge_11 = version_compare($version, '11', 'ge');
    $ast_ge_10 = version_compare($version, '10', 'ge');
    $ast_lt_18 = version_compare($version, '1.8', 'lt');
    $ast_ge_16 = version_compare($version, '1.6', 'ge');
    $fax = fax_detect($version);
    $astman->database_deltree("FAX");
    // do not continue unless we have a fax module in asterisk
    if ($fax['module'] && ($ast_lt_18 || $fax['ffa'] || $fax['spandsp'])) {
        $t38_fb = $ast_ge_16 ? ',f' : '';
        $context = 'ext-fax';
        $dests = fax_get_destinations();
        if ($dests) {
            foreach ($dests as $row) {
                $exten = $row['user'];
                $astman->database_put("FAX/" . $exten, "attachformat", $row['faxattachformat']);
                $astman->database_put("FAX/" . $exten, "email", $row['faxemail']);
                $ext->add($context, $exten, '', new ext_set('FAX_FOR', $row['name'] . ' (' . $row['user'] . ')'));
                $ext->add($context, $exten, '', new ext_noop('Receiving Fax for: ${FAX_FOR}, From: ${CALLERID(all)}'));
                $ext->add($context, $exten, '', new ext_set('FAX_ATTACH_FORMAT', '${DB(FAX/' . $exten . '/attachformat)}'));
                $ext->add($context, $exten, '', new ext_set('FAX_RX_EMAIL', '${DB(FAX/' . $exten . '/email)}'));
                $ext->add($context, $exten, 'receivefax', new ext_goto('receivefax', 's'));
            }
        }
        /*
         FAX Failures are not handled well as of this coding
         in by ReceiveFAX.  If there is a license available
         then it provides information. If not, nothing is
         provided. FAXSTATUS is supported in 1.4 to handle
         legacy with RxFax(). In order to create dialplan
         to try and handle all cases, we use FAXSTATUS and
         set it ourselves as needed. It appears that if a
         fax fails with ReceiveFAX we can always continue
         execution and if it succeeds, then execution goes
         to hangup. So using that information we try to
         trap and report on all cases.
        */
        $exten = 's';
        $ext->add($context, $exten, '', new ext_macro('user-callerid'));
        // $cmd,n,Macro(user-callerid)
        $ext->add($context, $exten, '', new ext_noop('Receiving Fax for: ${FAX_RX_EMAIL} , From: ${CALLERID(all)}'));
        $ext->add($context, $exten, 'receivefax', new ext_stopplaytones(''));
        switch ($fax['module']) {
            case 'app_rxfax':
                $ext->add($context, $exten, '', new ext_rxfax('${ASTSPOOLDIR}/fax/${UNIQUEID}.tif'));
                //receive fax, then email it on
                break;
            case 'app_fax':
                // $fax['receivefax'] should be rxfax or receivefax, it could be none in which case we don't know. We'll just make it
                // ReceiveFAX in that case since it will fail anyhow.
                if ($fax['receivefax'] == 'rxfax') {
                    $ext->add($context, $exten, '', new ext_rxfax('${ASTSPOOLDIR}/fax/${UNIQUEID}.tif'));
                    //receive fax, then email it on
                } elseif ($fax['receivefax'] == 'receivefax') {
                    $ext->add($context, $exten, '', new ext_receivefax('${ASTSPOOLDIR}/fax/${UNIQUEID}.tif' . $t38_fb));
                    //receive fax, then email it on
                } else {
                    $ext->add($context, $exten, '', new ext_noop('ERROR: NO Receive FAX application detected, putting in dialplan for ReceiveFAX as default'));
                    $ext->add($context, $exten, '', new ext_receivefax('${ASTSPOOLDIR}/fax/${UNIQUEID}.tif' . $t38_fb));
                    //receive fax, then email it on
                    $ext->add($context, $exten, '', new ext_execif('$["${FAXSTATUS}" = ""]', 'Set', 'FAXSTATUS=${IF($["${FAXOPT(error)}" = ""]?"FAILED LICENSE EXCEEDED":"FAILED FAXOPT: error: ${FAXOPT(error)} status: ${FAXOPT(status)} statusstr: ${FAXOPT(statusstr)}")}'));
                }
                break;
            case 'res_fax':
                $ext->add($context, $exten, '', new ext_receivefax('${ASTSPOOLDIR}/fax/${UNIQUEID}.tif' . $t38_fb));
                //receive fax, then email it on
                if ($ast_ge_16) {
                    if ($fax['ffa']) {
                        $ext->add($context, $exten, '', new ext_execif('$["${FAXSTATUS}"="" | "${FAXSTATUS}" = "FAILED" & "${FAXERROR}" = "INIT_ERROR"]', 'Set', 'FAXSTATUS=FAILED LICENSE MAY BE EXCEEDED check log errors'));
                    }
                    $ext->add($context, $exten, '', new ext_execif('$["${FAXSTATUS:0:6}"="FAILED" && "${FAXERROR}"!="INIT_ERROR"]', 'Set', 'FAXSTATUS="FAILED: error: ${FAXERROR} statusstr: ${FAXOPT(statusstr)}"'));
                } else {
                    // Some versions or settings appear to have successful completions continue, so check status and goto hangup code
                    if ($fax['ffa']) {
                        $ext->add($context, $exten, '', new ext_execif('$["${FAXOPT(error)}"=""]', 'Set', 'FAXSTATUS=FAILED LICENSE MAY BE EXCEEDED'));
                    }
                    $ext->add($context, $exten, '', new ext_execif('$["${FAXOPT(error)}"!="" && "${FAXOPT(error)}"!="NO_ERROR"]', 'Set', 'FAXSTATUS="FAILED FAXOPT: error: ${FAXOPT(error)} status: ${FAXOPT(status)} statusstr: ${FAXOPT(statusstr)}"'));
                }
                $ext->add($context, $exten, '', new ext_hangup());
                break;
            default:
                // unknown
                $ext->add($context, $exten, '', new ext_noop('No Known FAX Technology installed to receive a fax, aborting'));
                $ext->add($context, $exten, '', new ext_set('FAXSTATUS', 'FAILED No Known Fax Reception Apps available to process'));
                $ext->add($context, $exten, '', new ext_hangup());
        }
        $exten = 'h';
        // if there is a file there, mail it even if we failed:
        $ext->add($context, $exten, '', new ext_gotoif('$[${STAT(e,${ASTSPOOLDIR}/fax/${UNIQUEID}.tif)} = 0]', 'failed'));
        $ext->add($context, $exten, '', new ext_noop_trace('PROCESSING FAX with status: [${FAXSTATUS}] for: [${FAX_RX_EMAIL}], From: [${CALLERID(all)}]'));
        //delete is a variable so that other modules can prevent it should then need to prosses the file further
        $ext->add($context, $exten, 'delete_opt', new ext_set('DELETE_AFTER_SEND', 'true'));
        $ext->add($context, $exten, 'process', new ext_gotoif('$[${LEN(${FAX_RX_EMAIL})} = 0]', 'noemail'));
        $ext->add($context, $exten, '', new ext_system('${ASTVARLIBDIR}/bin/fax2mail.php --remotestationid "${FAXOPT(remotestationid)}" --to "${FAX_RX_EMAIL}" --dest "${FROM_DID}" --callerid \'${STRREPLACE(CALLERID(all),\',\\\\\')}\' --file ${ASTSPOOLDIR}/fax/${UNIQUEID}.tif --exten "${FAX_FOR}" --delete "${DELETE_AFTER_SEND}" --attachformat "${FAX_ATTACH_FORMAT}"'));
        $ext->add($context, $exten, 'end', new ext_macro('hangupcall'));
        $ext->add($context, $exten, 'noemail', new ext_noop('ERROR: No Email Address to send FAX: status: [${FAXSTATUS}],  From: [${CALLERID(all)}]'));
        $ext->add($context, $exten, '', new ext_system('${ASTVARLIBDIR}/bin/fax2mail.php --file ${ASTSPOOLDIR}/fax/${UNIQUEID}.tif --delete "${DELETE_AFTER_SEND}"'));
        $ext->add($context, $exten, '', new ext_macro('hangupcall'));
        $ext->add($context, $exten, 'failed', new ext_noop('FAX ${FAXSTATUS} for: ${FAX_RX_EMAIL} , From: ${CALLERID(all)}'), 'process', 101);
        $ext->add($context, $exten, '', new ext_macro('hangupcall'));
        $modulename = 'fax';
        $fcc = new featurecode($modulename, 'simu_fax');
        $fc_simu_fax = $fcc->getCodeActive();
        unset($fcc);
        if ($fc_simu_fax != '') {
            $default_address = sql('SELECT value FROM fax_details WHERE `key` = \'FAX_RX_EMAIL\'', 'getRow');
            $ext->addInclude('from-internal-additional', 'app-fax');
            // Add the include from from-internal
            $ext->add('app-fax', $fc_simu_fax, '', new ext_setvar('FAX_RX_EMAIL', $default_address[0]));
            $ext->add('app-fax', $fc_simu_fax, '', new ext_goto('1', 's', 'ext-fax'));
            $ext->add('app-fax', 'h', '', new ext_macro('hangupcall'));
        }
        // This is not really needed but is put here in
        // case some ever accidently switches the order below
        // when checking for this setting since $fax['module']
        // will be set there and the 2nd part never checked
        $fax_settings['force_detection'] = 'yes';
    } else {
        $fax_settings = fax_get_settings();
    }
    if ($fax['module'] && ($ast_lt_18 || $fax['ffa'] || $fax['spandsp']) || $fax_settings['force_detection'] == 'yes') {
        if ($ast_ge_11 && isset($core_conf) && is_a($core_conf, "core_conf")) {
            $core_conf->addSipGeneral('faxdetect', 'no');
        } else {
            if ($ast_ge_16 && isset($core_conf) && is_a($core_conf, "core_conf")) {
                $core_conf->addSipGeneral('faxdetect', 'yes');
            }
        }
        $ext->add('ext-did-0001', 'fax', '', new ext_setvar('__DIRECTION', $amp_conf['INBOUND_NOTRANS'] ? 'INBOUND' : ''));
        $ext->add('ext-did-0001', 'fax', '', new ext_goto('${CUT(FAX_DEST,^,1)},${CUT(FAX_DEST,^,2)},${CUT(FAX_DEST,^,3)}'));
        $ext->add('ext-did-0002', 'fax', '', new ext_setvar('__DIRECTION', $amp_conf['INBOUND_NOTRANS'] ? 'INBOUND' : ''));
        $ext->add('ext-did-0002', 'fax', '', new ext_goto('${CUT(FAX_DEST,^,1)},${CUT(FAX_DEST,^,2)},${CUT(FAX_DEST,^,3)}'));
        // Add fax extension to ivr and announcement as inbound controle may be passed quickly to them and still detection is desired
        if (function_exists('ivr_get_details')) {
            $ivrlist = ivr_get_details();
            if (is_array($ivrlist)) {
                foreach ($ivrlist as $item) {
                    $ext->add("ivr-" . $item['id'], 'fax', '', new ext_goto('${CUT(FAX_DEST,^,1)},${CUT(FAX_DEST,^,2)},${CUT(FAX_DEST,^,3)}'));
                }
            }
        }
        if (function_exists('announcement_list')) {
            foreach (announcement_list() as $row) {
                $ext->add('app-announcement-' . $row['announcement_id'], 'fax', '', new ext_goto('${CUT(FAX_DEST,^,1)},${CUT(FAX_DEST,^,2)},${CUT(FAX_DEST,^,3)}'));
            }
        }
    }
}
function ivr_getdestinfo($dest)
{
    global $active_modules;
    if (substr(trim($dest), 0, 4) == 'ivr-') {
        $exten = explode(',', $dest);
        $exten = substr($exten[0], 4);
        $thisexten = ivr_get_details($exten);
        if (empty($thisexten)) {
            return array();
        } else {
            //$type = isset($active_modules['ivr']['type'])?$active_modules['ivr']['type']:'setup';
            return array('description' => sprintf(_("IVR: %s"), $thisexten['name'] ? $thisexten['name'] : $thisexten['id']), 'edit_url' => 'config.php?display=ivr&action=edit&id=' . urlencode($exten));
        }
    } else {
        return false;
    }
}
Esempio n. 5
0
            case 'invalid_recording':
            case 'invalid_retry_recording':
            case 'timeout_retry_recording':
            case 'timeout_recording':
                $ivr[$d] = 'default';
                break;
            case 'timeout_time':
                $ivr[$d] = 10;
                break;
            default:
                $ivr[$d] = '';
                break;
        }
    }
} else {
    $ivr = ivr_get_details($id);
    $heading = _('Edit IVR: ');
    $heading .= $ivr['name'] ? $ivr['name'] : 'ID ' . $ivr['id'];
    $usage_list = framework_display_destination_usage(ivr_getdest($ivr['id']));
    if (!empty($usage_list)) {
        $infohtml = '
		<div class="panel panel-default">
			<div class="panel-heading">
				' . $usage_list['text'] . '
			</div>
			<div class="panel-body">
    			' . $usage_list['tooltip'] . '
			</div>
		</div>
		';
    }
Esempio n. 6
0
function ivr_get_name($id)
{
    $res = ivr_get_details($id);
    if (isset($res['displayname'])) {
        return $res['displayname'];
    } else {
        return null;
    }
}
function queues_get($account, $queues_conf_only = false)
{
    global $db, $astman, $amp_conf;
    if ($account == "") {
        return array();
    }
    $account = q($account);
    //get all the variables for the queue
    $sql = "SELECT keyword,data FROM queues_details WHERE id = {$account}";
    $results = $db->getAssoc($sql);
    if (empty($results)) {
        return array();
    }
    //okay, but there can be multiple member variables ... do another select for them
    $results['member'] = queues_get_static_members($account);
    //if 'queue-youarenext=queue-youarenext', then assume we want to announce position
    if (!$queues_conf_only) {
        if (isset($results['queue-youarenext']) && $results['queue-youarenext'] == 'queue-youarenext') {
            $results['announce-position'] = 'yes';
        } else {
            $results['announce-position'] = 'no';
        }
    }
    //if 'eventmemberstatusoff=Yes', then assume we want to 'eventmemberstatus=no'
    if (isset($results['eventmemberstatusoff'])) {
        if (strtolower($results['eventmemberstatusoff']) == 'yes') {
            $results['eventmemberstatus'] = 'no';
        } else {
            $results['eventmemberstatus'] = 'yes';
        }
    } elseif (!isset($results['eventmemberstatus'])) {
        $results['eventmemberstatus'] = 'no';
    }
    if ($queues_conf_only) {
        $sql = "SELECT ivr_id, callback_id FROM queues_config WHERE extension = {$account}";
        $config = sql($sql, "getRow", DB_FETCHMODE_ASSOC);
    } else {
        $sql = "SELECT * FROM queues_config WHERE extension = {$account}";
        $config = sql($sql, "getRow", DB_FETCHMODE_ASSOC);
        $results['prefix'] = $config['grppre'];
        $results['alertinfo'] = $config['alertinfo'];
        $results['agentannounce_id'] = $config['agentannounce_id'];
        $results['maxwait'] = $config['maxwait'];
        $results['name'] = $config['descr'];
        $results['joinannounce_id'] = $config['joinannounce_id'];
        $results['password'] = $config['password'];
        $results['goto'] = $config['dest'];
        $results['announcemenu'] = $config['ivr_id'];
        $results['callback'] = $config['callback_id'];
        $results['rtone'] = $config['ringing'];
        $results['cwignore'] = $config['cwignore'];
        $results['qregex'] = $config['qregex'];
        $results['queuewait'] = $config['queuewait'];
        $results['use_queue_context'] = $config['use_queue_context'];
        $results['togglehint'] = $config['togglehint'];
        $results['qnoanswer'] = $config['qnoanswer'];
        $results['callconfirm'] = $config['callconfirm'];
        $results['callconfirm_id'] = $config['callconfirm_id'];
        $results['monitor_type'] = $config['monitor_type'];
        $results['monitor_heard'] = $config['monitor_heard'];
        $results['monitor_spoken'] = $config['monitor_spoken'];
        // TODO: why the str_replace?
        //
        if ($astman) {
            $account = str_replace("'", '', $account);
            //get dynamic members priority from astDB
            $get = $astman->database_show('QPENALTY/' . $account . '/agents');
            if ($get) {
                foreach ($get as $key => $value) {
                    $key1 = explode('/', $key);
                    $mem[$key1[4]] = $value;
                }
                foreach ($mem as $mem => $pnlty) {
                    $dynmem[] = $mem . ',' . $pnlty;
                }
                $results['dynmembers'] = implode("\n", $dynmem);
            } else {
                $results['dynmembers'] = '';
            }
            $results['dynmemberonly'] = $astman->database_get('QPENALTY/' . $account, 'dynmemberonly');
        } else {
            fatal("Cannot connect to Asterisk Manager with " . $amp_conf["AMPMGRUSER"] . "/" . $amp_conf["AMPMGRPASS"]);
        }
    }
    $results['context'] = '';
    $results['periodic-announce'] = '';
    if ($config['ivr_id'] != 'none' && $config['ivr_id'] != '') {
        if (function_exists('ivr_get_details')) {
            $results['context'] = "ivr-" . $config['ivr_id'];
            $arr = ivr_get_details($config['ivr_id']);
            if (isset($arr['announcement']) && $arr['announcement'] != '') {
                $periodic = recordings_get_file($arr['announcement']);
                // We need to strip off all but the first sound file of any compound sound files
                $periodic_arr = explode("&", $periodic);
                $results['periodic-announce'] = $periodic_arr[0];
            }
        }
    } else {
        if ($config['callback_id'] != 'none' && $config['callback_id'] != '') {
            if (function_exists('vqplus_callback_get')) {
                $results['context'] = "queuecallback-" . $config['callback_id'];
                $arr = vqplus_callback_get($config['callback_id']);
                if (isset($arr[0]) && is_array($arr[0])) {
                    /* Vqplus 13 moved to BMO, which made the return value format different. */
                    $arr = $arr[0];
                }
                if (isset($arr['announcement']) && $arr['announcement'] != '') {
                    $periodic = recordings_get_file($arr['announcement']);
                    // We need to strip off all but the first sound file of any compound sound files
                    $periodic_arr = explode("&", $periodic);
                    $results['periodic-announce'] = $periodic_arr[0];
                }
            }
        }
    }
    return $results;
}
Esempio n. 8
0
	';
} else {
    if (function_exists('ivr_get_details')) {
        $breakouttype = 'announcemenu';
        $breakouthtml = "<input type=\"hidden\" name=\"breakouttype\" value=\"announcemenu\">";
    } else {
        if (function_exists('vqplus_callback_get')) {
            $breakouttype = 'callback';
            $breakouthtml = "<input type=\"hidden\" name=\"breakouttype\" value=\"callback\">";
        }
    }
}
//IVR Breakout
if (function_exists('ivr_get_details')) {
    $default = isset($announcemenu) ? $announcemenu : "none";
    $unique_aas = ivr_get_details();
    $compound_recordings = false;
    $is_error = false;
    $ivrboopts = '';
    if (isset($unique_aas) && is_array($unique_aas)) {
        foreach ($unique_aas as $unique_aa) {
            $menu_id = $unique_aa['id'];
            $menu_name = $unique_aa['name'] ? $unique_aa['name'] : 'IVR ' . $unique_aa['id'];
            $unique_aa['announcement'] = recordings_get_file($unique_aa['announcement']);
            if (strpos($unique_aa['announcement'], "&") === false) {
                $ivrboopts .= '<option value="' . $menu_id . '" ' . ($default == $menu_id ? 'SELECTED' : '') . '>' . ($menu_name ? $menu_name : _("Menu ID ") . $menu_id) . "</option>\n";
            } else {
                $compound_recordings = true;
                if ($menu_id == $default) {
                    $ivrboopts .= '<option style="color:red" value="' . $menu_id . '" ' . ($default == $menu_id ? 'SELECTED' : '') . '>' . ($menu_name ? $menu_name : _("Menu ID ") . $menu_id) . " (**)</option>\n";
                    $is_error = true;