Toll Allow

voipBull

Active Member
Dec 3, 2023
118
25
28
Hello community,

Is there a way to pre-populate a drop-down list of 'Tollallow' options, instead of the default free-form text field for Tollallow?

I was looking through the code in `extension_edit.php` and found the below piece of code. By the looks of it, it does look for an array type session variable 'toll allow' that will present the data into a drop-down list.

Code:
if (permission_exists('extension_toll')) {
        echo "<tr>\n";
        echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
        echo "    ".$text['label-toll_allow']."\n";
        echo "</td>\n";
        echo "<td class='vtable' align='left'>\n";
        if (!empty($_SESSION['toll allow']['name']) && is_array($_SESSION['toll allow']['name'])) {
            echo "    <select class='formfld' name='toll_allow' id='toll_allow'>\n";
            echo "        <option value=''></option>\n";
            foreach ($_SESSION['toll allow']['name'] as $name) {
                if ($name == $toll_allow) {
                    echo "        <option value='".escape($name)."' selected='selected'>".escape($name)."</option>\n";
                }
                else {
                    echo "        <option value='".escape($name)."'>".escape($name)."</option>\n";
                }
            }
            echo "    </select>\n";
        }
        else {
            echo "    <input class='formfld' type='text' name='toll_allow' maxlength='255' value=\"".escape($toll_allow ?? '')."\">\n";
        }
        echo "<br />\n";
        echo $text['description-toll_allow']."\n";
        echo "</td>\n";
        echo "</tr>\n";
    }

I couldn't find where this 'toll allow' session variable is being set. Anyone has any idea? or is this just legacy code that is not in use anymore.

Thanks
 
A session variable for `toll allow` is not set. You can add print_r or var_dump debugging code to extension_edit.php to verify this. The FusionPBX code for toll allow has been written to allow any text in this field and the code as it is written allows for you to add a session variable to the page to turn the toll allow into a set drop-down list with
PHP:
$_SESSION['toll allow']['name'] = ['voipBull', 'local', 'longdistance', 'international'];

1745960860567.png

But this method of code insertion will be in conflict with running code updates, and other issues of global session variables. If you want toll allow to be populated from a default setting or domain setting then you would need to add a small amount of code in a couple of locations on the page and rewrite the toll allow section to pull from default settings or domain settings variables.

There are other ways in which you may populate session variable. Each method, including default settings/domain settings, you will need to think through all scenarios to allow for the level of flexibility required.