/**
  * @verb PUT
  * @uri /voicemail/password/:id
  */
 function put_password_id($params)
 {
     if (!isset($params['password'])) {
         return false;
     }
     $uservm = voicemail_getVoicemail();
     $vmcontexts = array_keys($uservm);
     foreach ($vmcontexts as $vmcontext) {
         if (isset($uservm[$vmcontext][$params['id']])) {
             global $astman;
             $uservm[$vmcontext][$params['id']]['pwd'] = $params['password'];
             voicemail_saveVoicemail($uservm);
             $astman->send_request("Command", array("Command" => "voicemail reload"));
             return true;
         }
     }
     return false;
 }
Exemple #2
0
function voicemail_mailbox_add($mbox, $mboxoptsarray)
{
    global $astman;
    //check if VM box already exists
    if (voicemail_mailbox_get($mbox) != null) {
        trigger_error("Voicemail mailbox '{$mbox}' already exists, call to voicemail_maibox_add failed");
        die_freepbx();
    }
    $uservm = voicemail_getVoicemail();
    extract($mboxoptsarray);
    if ($vm != 'disabled') {
        // need to check if there are any options entered in the text field
        if ($options != '') {
            $options = explode("|", $options);
            foreach ($options as $option) {
                $vmoption = explode("=", $option);
                $vmoptions[$vmoption[0]] = $vmoption[1];
            }
        }
        if ($imapuser != '' && $imapuser != '') {
            $vmoptions['imapuser'] = $imapuser;
            $vmoptions['imappassword'] = $imappassword;
        }
        $vmoption = explode("=", $attach);
        $vmoptions[$vmoption[0]] = $vmoption[1];
        $vmoption = explode("=", $saycid);
        $vmoptions[$vmoption[0]] = $vmoption[1];
        $vmoption = explode("=", $envelope);
        $vmoptions[$vmoption[0]] = $vmoption[1];
        $vmoption = explode("=", $delete);
        $vmoptions[$vmoption[0]] = $vmoption[1];
        $uservm[$vmcontext][$extension] = array('mailbox' => $extension, 'pwd' => $vmpwd, 'name' => $name, 'email' => $email, 'pager' => $pager, 'options' => $vmoptions);
        // Update $_REQUEST with 'devinfo_mailbox, so MWI works.
        if (empty($_REQUEST['devinfo_mailbox'])) {
            $_REQUEST['devinfo_mailbox'] = "{$extension}@{$vmcontext}";
        }
    }
    voicemail_saveVoicemail($uservm);
    $vmxobj = new vmxObject($extension);
    // Operator extension can be set even without VmX enabled so that it can be
    // used as an alternate way to provide an operator extension for a user
    // without VmX enabled.
    //
    if (isset($vmx_option_0_system_default) && $vmx_option_0_system_default != '') {
        $vmxobj->setMenuOpt("", 0, 'unavail');
        $vmxobj->setMenuOpt("", 0, 'busy');
    } else {
        if (!isset($vmx_option_0_number)) {
            $vmx_option_0_number = '';
        }
        $vmx_option_0_number = preg_replace("/[^0-9]/", "", $vmx_option_0_number);
        $vmxobj->setMenuOpt($vmx_option_0_number, 0, 'unavail');
        $vmxobj->setMenuOpt($vmx_option_0_number, 0, 'busy');
    }
    if (isset($vmx_state) && $vmx_state) {
        if (isset($vmx_unavail_enabled) && $vmx_unavail_enabled != '') {
            $vmxobj->setState('enabled', 'unavail');
        } else {
            $vmxobj->setState('disabled', 'unavail');
        }
        if (isset($vmx_busy_enabled) && $vmx_busy_enabled != '') {
            $vmxobj->setState('enabled', 'busy');
        } else {
            $vmxobj->setState('disabled', 'busy');
        }
        if (isset($vmx_play_instructions) && $vmx_play_instructions == 'checked') {
            $vmxobj->setVmPlay(true, 'unavail');
            $vmxobj->setVmPlay(true, 'busy');
        } else {
            $vmxobj->setVmPlay(false, 'unavail');
            $vmxobj->setVmPlay(false, 'busy');
        }
        if (isset($vmx_option_1_system_default) && $vmx_option_1_system_default != '') {
            $vmxobj->setFollowMe(1, 'unavail');
            $vmxobj->setFollowMe(1, 'busy');
        } else {
            $vmx_option_1_number = preg_replace("/[^0-9]/", "", $vmx_option_1_number);
            $vmxobj->setMenuOpt($vmx_option_1_number, 1, 'unavail');
            $vmxobj->setMenuOpt($vmx_option_1_number, 1, 'busy');
        }
        if (isset($vmx_option_2_number)) {
            $vmx_option_2_number = preg_replace("/[^0-9]/", "", $vmx_option_2_number);
            $vmxobj->setMenuOpt($vmx_option_2_number, 2, 'unavail');
            $vmxobj->setMenuOpt($vmx_option_2_number, 2, 'busy');
        }
    } else {
        if ($vmxobj->isInitialized()) {
            $vmxobj->disable();
        }
    }
}
function voicemail_update_settings($action, $context = "", $extension = "", $args = null)
{
    global $astman;
    global $tz_settings;
    global $gen_settings;
    /* Ensure we get the most up-to-date voicemail.conf data. */
    if ($action != 'dialplan') {
        $vmconf = voicemail_getVoicemail();
    } else {
        $vmconf = null;
    }
    if ($vmconf !== null) {
        switch ($action) {
            case "tz":
                /* First update all zonemessages opts that are already in vmconf */
                $vmconf["zonemessages"] = is_array($vmconf["zonemessages"]) ? $vmconf["zonemessages"] : array();
                foreach ($vmconf["zonemessages"] as $key => $val) {
                    $id = "tz__{$key}";
                    $vmconf["zonemessages"][$key] = isset($args[$id]) ? $args[$id] : $vmconf["zonemessages"][$key];
                    /* Bad to have empty fields in vmconf. */
                    /* And remove deleted fields, too.     */
                    if (empty($vmconf["zonemessages"][$key]) || $args["tzdel__{$key}"] == "true") {
                        unset($vmconf["zonemessages"][$key]);
                    }
                }
                /* Add new field, if one was specified */
                if (!empty($args["tznew_name"]) && !empty($args["tznew_def"])) {
                    $vmconf["zonemessages"][$args["tznew_name"]] = $args["tznew_def"];
                }
                unset($args[$id]);
                /* Next record any new zonemessages opts that were on the page but not already in vmconf. */
                if (is_array($tz_settings)) {
                    foreach ($tz_settings as $key) {
                        $id = "tz__{$key}";
                        if (isset($args[$id]) && !empty($args[$id])) {
                            $vmconf["zonemessages"][$key] = $args[$id];
                        }
                    }
                }
                break;
            case "settings":
                if (empty($extension) && $action == "settings") {
                    /* First update all general opts that are already in vmconf */
                    $vmconf["general"] = is_array($vmconf["general"]) ? $vmconf["general"] : array();
                    foreach ($vmconf["general"] as $key => $val) {
                        $id = "gen__{$key}";
                        $vmconf["general"][$key] = isset($args[$id]) ? $args[$id] : $vmconf["general"][$key];
                        //The only reason to use \r is if you're writing to a character terminal
                        //(or more likely a "console window" emulating it) and want the next
                        //line you write to overwrite the last one you just wrote
                        //(sometimes used for goofy "ascii animation" effects of e.g. progress bars)
                        //-- this is getting pretty obsolete in a world of GUIs, though;-).
                        //http://stackoverflow.com/questions/1761051/difference-between-n-and-r
                        $vmconf["general"][$key] = str_replace(array("\r", "\n", "\t"), array('', '\\n', '\\t'), $vmconf["general"][$key]);
                        /* Bad to have empty fields in vmconf. */
                        /* also make sure no boolean undefined fields left in there */
                        if (trim($vmconf["general"][$key]) == "" || $vmconf["general"][$key] == 'undefined' && $gen_settings[$key]['type'] == 'flag') {
                            unset($vmconf["general"][$key]);
                        }
                        unset($args[$id]);
                    }
                    /* Next record any new general opts that were on the page but not already in vmconf. */
                    if (is_array($gen_settings)) {
                        foreach ($gen_settings as $key => $descrip) {
                            $id = "gen__{$key}";
                            if (isset($args[$id]) && !empty($args[$id])) {
                                $vmconf["general"][$key] = $args[$id];
                            }
                        }
                    }
                } else {
                    if (!empty($extension)) {
                        global $acct_settings;
                        /* We need this to know the type for each option (text value or flag) */
                        /* Delete user's old settings. */
                        voicemail_mailbox_del($extension);
                        /* Prepare values for user's new settings. 			  */
                        /* Each Voicemail account has a line in voicemail.conf like this: */
                        /* extension => password,name,email,pager,options		  */
                        /* Take care of password, name, email and pager.                  */
                        $pwd = isset($args["acct__pwd"]) ? $args["acct__pwd"] : "";
                        unset($args["acct__pwd"]);
                        if (isset($args["acct__name"]) && $args["acct__name"] != "") {
                            $name = $args["acct__name"];
                        } else {
                            $this_exten = core_users_get($extension);
                            $name = $this_exten["name"];
                        }
                        unset($args["acct__name"]);
                        $email = isset($args["acct__email"]) ? $args["acct__email"] : "";
                        unset($args["acct__email"]);
                        $pager = isset($args["acct__pager"]) ? $args["acct__pager"] : "";
                        unset($args["acct__pager"]);
                        /* Now handle the options. */
                        $options = array();
                        $acct_settings = is_array($acct_settings) ? $acct_settings : array();
                        foreach ($acct_settings as $key => $descrip) {
                            $id = "acct__{$key}";
                            if (isset($args[$id]) && !empty($args[$id]) && $args[$id] != "undefined") {
                                $options[$key] = $args[$id];
                            }
                        }
                        /* Remove call me num from options - that is set in ast db */
                        unset($options["callmenum"]);
                        /* New account values to vmconf */
                        $vmconf[$context][$extension] = array("mailbox" => $extension, "pwd" => $pwd, "name" => $name, "email" => $email, "pager" => $pager, "options" => $options);
                        $callmenum = isset($args["acct__callmenum"]) && !empty($args["acct__callmenum"]) ? $args["acct__callmenum"] : $extension;
                        // Save call me num.
                        $cmd = "database put AMPUSER {$extension}/callmenum {$callmenum}";
                        if ($astman->connected()) {
                            $astman->send_request("Command", array("Command" => $cmd));
                        }
                    }
                }
                break;
            case "bsettings":
                if (!empty($extension)) {
                    /* Get user's old settings, since we are only replacing the basic settings. */
                    $vmbox = voicemail_mailbox_get($extension);
                    /* Delete user's old settings. */
                    voicemail_mailbox_del($extension);
                    /* Prepare values for user's new BASIC settings.		  */
                    /* Each Voicemail account has a line in voicemail.conf like this: */
                    /* extension => password,name,email,pager,options		  */
                    /* Take care of password, name, email and pager.                  */
                    $pwd = isset($args["acct__pwd"]) ? $args["acct__pwd"] : "";
                    unset($args["acct__pwd"]);
                    if (isset($args["acct__name"]) && $args["acct__name"] != "") {
                        $name = $args["acct__name"];
                    } else {
                        $this_exten = core_users_get($extension);
                        $name = $this_exten["name"];
                    }
                    unset($args["acct__name"]);
                    $email = isset($args["acct__email"]) ? $args["acct__email"] : "";
                    unset($args["acct__email"]);
                    $pager = isset($args["acct__pager"]) ? $args["acct__pager"] : "";
                    unset($args["acct__pager"]);
                    /* THESE ARE COMING FROM THE USER'S OLD SETTINGS.                     */
                    $options = $vmbox["options"];
                    /* An array */
                    /* Update the four options listed on the "bsettings" page as needed. */
                    $basic_opts_list = array("attach", "saycid", "envelope", "delete");
                    foreach ($basic_opts_list as $basic_opt) {
                        $id = "acct__" . $basic_opt;
                        if (isset($args[$id]) && !empty($args[$id]) && $args[$id] != "undefined") {
                            $options[$basic_opt] = $args[$id];
                        } else {
                            if ($args[$id] == "undefined") {
                                unset($options[$basic_opt]);
                            }
                        }
                    }
                    /* Remove call me num from options - that is set in ast db. Should not be here anyway, since options are coming from the old settings... */
                    unset($options["callmenum"]);
                    /* New account values to vmconf */
                    $vmconf[$context][$extension] = array("mailbox" => $extension, "pwd" => $pwd, "name" => $name, "email" => $email, "pager" => $pager, "options" => $options);
                    $callmenum = isset($args["acct__callmenum"]) && !empty($args["acct__callmenum"]) ? $args["acct__callmenum"] : $extension;
                    // Save call me num.
                    $cmd = "database put AMPUSER {$extension}/callmenum {$callmenum}";
                    if ($astman->connected()) {
                        $astman->send_request("Command", array("Command" => $cmd));
                    }
                }
                break;
            default:
                return false;
        }
        if (!empty($vmconf)) {
            $vmconf['general']['charset'] = "UTF-8";
        }
        voicemail_saveVoicemail($vmconf);
        if ($astman->connected()) {
            $astman->send_request("Command", array("Command" => "reload app_voicemail.so"));
        }
        return true;
        // Special Case dialplan since no voicemail.conf related configs
    } else {
        if ($action == 'dialplan') {
            // defaults need to be set for checkboxes unless we change them to radio buttons
            //
            $cb = array('VM_OPTS', 'VMX_OPTS_LOOP', 'VMX_OPTS_DOVM');
            foreach ($cb as $cbs) {
                if (!isset($args[$cbs])) {
                    $args[$cbs] = '';
                }
            }
            return voicemail_admin_update($args);
        }
    }
    return false;
}
Exemple #4
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 
}
Exemple #5
0
function core_destinations()
{
    global $amp_conf;
    //static destinations
    $extens = array();
    $category = _("Terminate Call");
    $ds_id = 'blackhole';
    $extens[] = array('destination' => 'app-blackhole,hangup,1', 'description' => _("Hangup"), 'category' => $category, 'id' => $ds_id);
    $extens[] = array('destination' => 'app-blackhole,congestion,1', 'description' => _("Congestion"), 'category' => $category, 'id' => $ds_id);
    $extens[] = array('destination' => 'app-blackhole,busy,1', 'description' => _("Busy"), 'category' => $category, 'id' => $ds_id);
    $extens[] = array('destination' => 'app-blackhole,zapateller,1', 'description' => _("Play SIT Tone (Zapateller)"), 'category' => $category, 'id' => $ds_id);
    $extens[] = array('destination' => 'app-blackhole,musiconhold,1', 'description' => _("Put caller on hold forever"), 'category' => $category, 'id' => $ds_id);
    $extens[] = array('destination' => 'app-blackhole,ring,1', 'description' => _("Play ringtones to caller until they hangup"), 'category' => $category, 'id' => $ds_id);
    $extens[] = array('destination' => 'app-blackhole,no-service,1', 'description' => _("Play no service message"), 'category' => $category, 'id' => $ds_id);
    //get the list of meetmes
    $results = core_users_list();
    $vmboxes = array();
    if (isset($results) && function_exists('voicemail_getVoicemail')) {
        //get voicemail
        $uservm = voicemail_getVoicemail();
        $vmcontexts = array_keys($uservm);
        foreach ($results as $thisext) {
            $extnum = $thisext[0];
            // search vm contexts for this extensions mailbox
            foreach ($vmcontexts as $vmcontext) {
                if (isset($uservm[$vmcontext][$extnum])) {
                    //$vmname = $uservm[$vmcontext][$extnum]['name'];
                    //$vmboxes[$extnum] = array($extnum, '"' . $vmname . '" <' . $extnum . '>');
                    $vmboxes[$extnum] = true;
                }
            }
        }
    }
    // return an associative array with destination and description
    // core provides both users and voicemail boxes as destinations
    if (isset($results)) {
        $cat_id = $amp_conf['AMPEXTENSIONS'] == "deviceanduser" ? 'users' : 'extensions';
        $cat = $amp_conf['AMPEXTENSIONS'] == "deviceanduser" ? 'Users' : 'Extensions';
        foreach ($results as $result) {
            $extens[] = array('destination' => 'from-did-direct,' . $result['0'] . ',1', 'description' => ' ' . $result['0'] . ' ' . $result['1'], 'category' => $cat, 'id' => $cat_id);
            if (isset($vmboxes[$result['0']])) {
                $extens[] = array('destination' => 'ext-local,vmb' . $result['0'] . ',1', 'description' => $result[0] . ' ' . $result[1] . ' (Busy Message)', 'category' => 'Voicemail', 'id' => 'voicemail');
                $extens[] = array('destination' => 'ext-local,vmu' . $result['0'] . ',1', 'description' => $result[0] . ' ' . $result[1] . ' (Unavailable Message)', 'category' => 'Voicemail', 'id' => 'voicemail');
                $extens[] = array('destination' => 'ext-local,vms' . $result['0'] . ',1', 'description' => $result[0] . ' ' . $result[1] . ' (No Message)', 'category' => 'Voicemail', 'id' => 'voicemail');
                $extens[] = array('destination' => 'ext-local,vmi' . $result['0'] . ',1', 'description' => $result[0] . ' ' . $result[1] . ' (Instructions Only)', 'category' => 'Voicemail', 'id' => 'voicemail');
            }
        }
    }
    $trunklist = core_trunks_listbyid();
    if (is_array($trunklist)) {
        foreach ($trunklist as $trunk) {
            switch ($trunk['tech']) {
                case 'enum':
                    break;
                default:
                    $extens[] = array('destination' => 'ext-trunk,' . $trunk['trunkid'] . ',1', 'description' => $trunk['name'] . ' (' . $trunk['tech'] . ')', 'category' => 'Trunks', 'id' => 'trunks');
                    break;
            }
        }
    }
    return $extens;
}
 /**
  * Save Voicemail Settings for an extension
  * @param int $ext      The voicemail extension
  * @param string $pwd      The voicemail password/pin
  * @param string $email    The voicemail email address
  * @param string $page     The voicemail pager number
  * @param string $playcid  Whether to play the CID to the caller
  * @param string $envelope Whether to play the envelope to the caller
  */
 public function saveVMSettingsByExtension($ext, $pwd, $email, $page, $playcid, $envelope)
 {
     $o = $this->getVoicemailBoxByExtension($ext);
     $context = $o['vmcontext'];
     $vmconf = voicemail_getVoicemail();
     if (!empty($vmconf[$context][$ext])) {
         $vmconf[$context][$ext]['pwd'] = $pwd;
         $vmconf[$context][$ext]['email'] = $email;
         $vmconf[$context][$ext]['pager'] = $page;
         $vmconf[$context][$ext]['options']['saycid'] = $playcid ? 'yes' : 'no';
         $vmconf[$context][$ext]['options']['envelope'] = $envelope ? 'yes' : 'no';
         voicemail_saveVoicemail($vmconf);
         $this->astman->Reload("voicemail");
         return true;
     }
     return false;
 }
<?php

if (!defined('FREEPBX_IS_AUTH')) {
    die('No direct script access allowed');
}
//	License for all code of this FreePBX module can be found in the license file inside the module directory
//	Copyright 2013 Schmooze Com Inc.
//
$display_data = array();
/* All extensions. */
$extens = core_users_list();
/* All voicemail.conf settings. */
$uservm = voicemail_getVoicemail();
/* VMAIL info - needed for rnav menu and other page content. */
$vmail_info["activated_info"] = array();
$vmail_info["bycontext"] = array();
$vmail_info["unactivated_info"] = array();
$vmail_info["disabled_list"] = array();
$vmail_info["contexts"] = array();
$vmail_info["contexts"] = array_keys($uservm);
/* All voicemail contexts. */
$extdisplay = isset($_REQUEST["ext"]) ? $_REQUEST["ext"] : "";
$type = isset($_REQUEST["type"]) && $_REQUEST["type"] != "" ? $_REQUEST["type"] : "setup";
$display = isset($_REQUEST["display"]) && $_REQUEST["display"] != "" ? $_REQUEST["display"] : "voicemail";
$rnav_list = "";
$rnav_enabled_index = array();
$rnav_entries = array();
/* Activated mailboxes are those which have a subdirectory on disk. */
global $amp_conf;
$vmail_root = "/" . trim($amp_conf["ASTSPOOLDIR"], "/") . "/voicemail";
if (isset($extens) && is_array($extens)) {
Exemple #8
0
function core_destinations()
{
    //static destinations
    $extens = array();
    $category = _("Terminate Call");
    $extens[] = array('destination' => 'app-blackhole,hangup,1', 'description' => _("Hangup"), 'category' => $category);
    $extens[] = array('destination' => 'app-blackhole,congestion,1', 'description' => _("Congestion"), 'category' => $category);
    $extens[] = array('destination' => 'app-blackhole,busy,1', 'description' => _("Busy"), 'category' => $category);
    $extens[] = array('destination' => 'app-blackhole,zapateller,1', 'description' => _("Play SIT Tone (Zapateller)"), 'category' => $category);
    $extens[] = array('destination' => 'app-blackhole,musiconhold,1', 'description' => _("Put caller on hold forever"), 'category' => $category);
    $extens[] = array('destination' => 'app-blackhole,ring,1', 'description' => _("Play ringtones to caller until they hangup"), 'category' => $category);
    //get the list of meetmes
    $results = core_users_list();
    if (isset($results) && function_exists('voicemail_getVoicemail')) {
        //get voicemail
        $uservm = voicemail_getVoicemail();
        $vmcontexts = array_keys($uservm);
        foreach ($results as $thisext) {
            $extnum = $thisext[0];
            // search vm contexts for this extensions mailbox
            foreach ($vmcontexts as $vmcontext) {
                if (isset($uservm[$vmcontext][$extnum])) {
                    //$vmname = $uservm[$vmcontext][$extnum]['name'];
                    //$vmboxes[$extnum] = array($extnum, '"' . $vmname . '" <' . $extnum . '>');
                    $vmboxes[$extnum] = true;
                }
            }
        }
    }
    // return an associative array with destination and description
    // core provides both users and voicemail boxes as destinations
    if (isset($results)) {
        foreach ($results as $result) {
            $extens[] = array('destination' => 'from-did-direct,' . $result['0'] . ',1', 'description' => ' <' . $result['0'] . '> ' . $result['1'], 'category' => 'Extensions');
            if (isset($vmboxes[$result['0']])) {
                $extens[] = array('destination' => 'ext-local,vmb' . $result['0'] . ',1', 'description' => '<' . $result[0] . '> ' . $result[1] . ' (busy)', 'category' => 'Voicemail');
                $extens[] = array('destination' => 'ext-local,vmu' . $result['0'] . ',1', 'description' => '<' . $result[0] . '> ' . $result[1] . ' (unavail)', 'category' => 'Voicemail');
                $extens[] = array('destination' => 'ext-local,vms' . $result['0'] . ',1', 'description' => '<' . $result[0] . '> ' . $result[1] . ' (no-msg)', 'category' => 'Voicemail');
            }
        }
    }
    $trunklist = core_trunks_listbyid();
    if (is_array($trunklist)) {
        foreach ($trunklist as $trunk) {
            switch ($trunk['tech']) {
                case 'enum':
                    break;
                default:
                    $extens[] = array('destination' => 'ext-trunk,' . $trunk['trunkid'] . ',1', 'description' => $trunk['name'] . ' (' . $trunk['tech'] . ')', 'category' => 'Trunks');
                    break;
            }
        }
    }
    if (isset($extens)) {
        return $extens;
    } else {
        return null;
    }
}