Exemplo n.º 1
0
function core_users_configprocess()
{
    //create vars from the request
    extract($_REQUEST);
    //make sure we can connect to Asterisk Manager
    if (!checkAstMan()) {
        return false;
    }
    //check if the extension is within range for this user
    if (isset($extension) && !checkRange($extension)) {
        echo "<script>javascript:alert('" . _("Warning! Extension") . " " . $extension . " " . _("is not allowed for your account") . ".');</script>";
        $GLOBALS['abort'] = true;
    } else {
        //if submitting form, update database
        if (!isset($action)) {
            $action = null;
        }
        switch ($action) {
            case "add":
                if (core_users_add($_REQUEST)) {
                    // TODO: Check this if it's the same in device and user mode, and in fact we can't support this in that
                    //       mode at least without fixing the complexities of adding the devices which gets ugly!
                    //
                    $this_dest = core_getdest($_REQUEST['extension']);
                    fwmsg::set_dest($this_dest[0]);
                    needreload();
                    //redirect_standard_continue();
                } else {
                    // really bad hack - but if core_users_add fails, want to stop core_devices_add
                    // Comment, this does not help everywhere. Other hooks functions can hook before
                    // this like voicemail!
                    //
                    $GLOBALS['abort'] = true;
                }
                break;
            case "del":
                \FreePBX::Core()->delUser($extdisplay);
                core_users_cleanastdb($extdisplay);
                if (function_exists('findmefollow_del')) {
                    findmefollow_del($extdisplay);
                }
                needreload();
                //redirect_standard_continue();
                break;
            case "edit":
                if (core_users_edit($extdisplay, $_REQUEST)) {
                    needreload();
                    //redirect_standard_continue('extdisplay');
                } else {
                    // really bad hack - but if core_users_edit fails, want to stop core_devices_edit
                    $GLOBALS['abort'] = true;
                }
                break;
        }
    }
    return true;
}
Exemplo n.º 2
0
                 $register = core_trunks_getTrunkRegister($trunknum);
             }
         }
     }
     if (count($dialpattern_array) == 0) {
         $dialpattern_array = core_trunks_get_dialrules($trunknum);
     }
     $upper_tech = strtoupper($tech);
     if (trim($trunk_name) == '') {
         $trunk_name = $upper_tech == 'ZAP' | $upper_tech == 'DAHDI' ? sprintf(_('%s Channel %s'), $upper_tech, $channelid) : $channelid;
     }
     // find which routes use this trunk
     $routes = core_trunks_gettrunkroutes($trunknum);
     $num_routes = count($routes);
     if ($num_routes > 0) {
         $usage_list = framework_display_destination_usage(core_getdest(ltrim($extdisplay, 'OUT_')));
     }
 } else {
     // 'Add New Trunk' selected.
     // Generic defaults
     $outcid = "";
     $maxchans = "";
     $dialoutprefix = "";
     if ($tech == 'zap' || $tech == 'dahdi') {
         $channelid = 'g0';
     } else {
         $channelid = '';
     }
     // only for iax2/sip
     $peerdetails = "host=***provider ip address***\nusername=***userid***\nsecret=***password***\ntype=peer";
     $usercontext = "";
Exemplo n.º 3
0
function core_users_configpageload()
{
    global $currentcomponent;
    global $amp_conf;
    // Ensure variables possibly extracted later exist
    $name = $outboundcid = $record_in = $record_out = $sipname = $cid_masquerade = $newdid_name = $newdid = $newdidcid = $call_screen = $pinless = null;
    // Init vars from $_REQUEST[]
    $display = isset($_REQUEST['display']) ? $_REQUEST['display'] : null;
    $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
    $extdisplay = isset($_REQUEST['extdisplay']) ? $_REQUEST['extdisplay'] : null;
    $tech_hardware = isset($_REQUEST['tech_hardware']) ? $_REQUEST['tech_hardware'] : null;
    if ($action == 'del') {
        // Deleted
        $currentcomponent->addguielem('_top', new gui_subheading('del', $extdisplay . ' ' . _("deleted"), false));
    } elseif ($display == 'extensions' && ($extdisplay == '' && $tech_hardware == '')) {
        // Adding
        // do nothing as you want the Devices to handle this bit
    } else {
        $delURL = $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'] . '&action=del';
        if (is_string($extdisplay)) {
            if (!isset($GLOBALS['abort']) || $GLOBALS['abort'] !== true) {
                $extenInfo = core_users_get($extdisplay);
                extract($extenInfo);
            }
            if (isset($deviceInfo) && is_array($deviceInfo)) {
                extract($deviceInfo);
            }
            if ($display == 'extensions') {
                $currentcomponent->addguielem('_top', new gui_pageheading('title', _("Extension") . ": {$extdisplay}", false), 0);
                if (!isset($GLOBALS['abort']) || $GLOBALS['abort'] !== true) {
                    $tlabel = sprintf(_("Delete Extension %s"), $extdisplay);
                    $label = '<span><img width="16" height="16" border="0" title="' . $tlabel . '" alt="" src="images/user_delete.png"/>&nbsp;' . $tlabel . '</span>';
                    $currentcomponent->addguielem('_top', new gui_link('del', $label, $delURL, true, false), 0);
                    $usage_list = framework_display_destination_usage(core_getdest($extdisplay));
                    if (!empty($usage_list)) {
                        $currentcomponent->addguielem('_top', new gui_link_label('dests', $usage_list['text'], $usage_list['tooltip'], true), 0);
                    }
                }
            } else {
                $currentcomponent->addguielem('_top', new gui_pageheading('title', _("User") . ": {$extdisplay}", false), 0);
                if (!isset($GLOBALS['abort']) || $GLOBALS['abort'] !== true) {
                    $tlabel = sprintf(_("Delete User %s"), $extdisplay);
                    $label = '<span><img width="16" height="16" border="0" title="' . $tlabel . '" alt="" src="images/user_delete.png"/>&nbsp;' . $tlabel . '</span>';
                    $currentcomponent->addguielem('_top', new gui_link('del', $label, $delURL, true, false), 0);
                    $usage_list = framework_display_destination_usage(core_getdest($extdisplay));
                    if (!empty($usage_list)) {
                        $currentcomponent->addguielem('_top', new gui_link_label('dests', $usage_list['text'], $usage_list['tooltip'], true), 0);
                    }
                }
            }
        } elseif ($display != 'extensions') {
            $currentcomponent->addguielem('_top', new gui_pageheading('title', _("Add User/Extension")), 0);
        }
        // Setup vars for use in the gui later on
        $fc_logon = featurecodes_getFeatureCode('core', 'userlogon');
        $fc_logoff = featurecodes_getFeatureCode('core', 'userlogoff');
        $msgInvalidExtNum = _("Please enter a valid extension number.");
        $msgInvalidCidNum = _("Please enter a valid CID Num Alias (must be a valid number).");
        $msgInvalidExtPwd = _("Please enter valid User Password using numbers only");
        $msgInvalidDispName = _("Please enter a valid Display Name");
        $msgInvalidOutboundCID = _("Please enter a valid Outbound CID");
        $msgInvalidPause = _("Please enter a valid pause time in seconds, using digits only");
        $msgInvalidDIDNum = _("You have entered a non-standard dialpattern for your DID. You can only enter standard dialpatterns. You must use the inbound routing form to enter non-standard patterns");
        $msgInvalidCIDNum = _("Please enter a valid Caller ID Number or leave it blank for your Assigned DID/CID pair");
        // This is the actual gui stuff
        $currentcomponent->addguielem('_top', new gui_hidden('action', $extdisplay ? 'edit' : 'add'));
        $currentcomponent->addguielem('_top', new gui_hidden('extdisplay', $extdisplay));
        if ($display == 'extensions') {
            $section = $extdisplay ? _("Edit Extension") : _("Add Extension");
        } else {
            $section = $extdisplay ? _("Edit User") : _("Add User");
        }
        if (trim($extdisplay) != '') {
            $currentcomponent->addguielem($section, new gui_hidden('extension', $extdisplay), 2);
        } else {
            $currentcomponent->addguielem($section, new gui_textbox('extension', $extdisplay, _("User Extension"), _("The extension number to dial to reach this user."), '!isInteger()', $msgInvalidExtNum, false), 3);
        }
        if ($display != 'extensions') {
            $currentcomponent->addguielem($section, new gui_password('password', $password, _("User Password"), _("A user will enter this password when logging onto a device.") . ' ' . $fc_logon . ' ' . _("logs into a device.") . ' ' . $fc_logoff . ' ' . _("logs out of a device."), '!isInteger() && !isWhitespace()', $msgInvalidExtPwd, true));
            // extra JS function check required for blank password warning -- call last in the onsubmit() function
            $currentcomponent->addjsfunc('onsubmit()', "\treturn checkBlankUserPwd();\n", 9);
        }
        $currentcomponent->addguielem($section, new gui_textbox('name', $name, _("Display Name"), _("The caller id name for calls from this user will be set to this name. Only enter the name, NOT the number."), '!isAlphanumeric() || isWhitespace()', $msgInvalidDispName, false));
        $cid_masquerade = trim($cid_masquerade) == $extdisplay ? "" : $cid_masquerade;
        $currentcomponent->addguielem($section, new gui_textbox('cid_masquerade', $cid_masquerade, _("CID Num Alias"), _("The CID Number to use for internal calls, if different from the extension number. This is used to masquerade as a different user. A common example is a team of support people who would like their internal callerid to display the general support number (a ringgroup or queue). There will be no effect on external calls."), '!isWhitespace() && !isInteger()', $msgInvalidCidNum, false));
        $currentcomponent->addguielem($section, new gui_textbox('sipname', $sipname, _("SIP Alias"), _("If you want to support direct sip dialing of users internally or through anonymous sip calls, you can supply a friendly name that can be used in addition to the users extension to call them.")));
        // If user mode, list devices associated with this user
        //
        if ($display == 'users' && trim($extdisplay != '')) {
            $section = _("User Devices");
            $device_list = core_devices_list('all', 'full');
            usort($device_list, 'dev_grp');
            $link_count = 0;
            foreach ($device_list as $device_item) {
                if ($device_item['user'] == $extdisplay) {
                    $editURL = $_SERVER['PHP_SELF'] . '?type=setup&display=devices&skip=0&extdisplay=' . $device_item['id'];
                    $device_icon = $device_item['devicetype'] == 'fixed' ? 'images/telephone_key.png' : 'images/telephone_edit.png';
                    $device_label = '&nbsp;';
                    $device_label .= _("Edit:");
                    $device_label .= '&nbsp;' . $device_item['id'] . '&nbsp;' . $device_item['description'];
                    $device_label = '<span>
						<img width="16" height="16" border="0" title="Edit Device" alt="Edit Device" src="' . $device_icon . '"/>' . $device_label . '</span> ';
                    $currentcomponent->addguielem($section, new gui_link('dev' . $link_count++, $device_label, $editURL, true, false), 2);
                }
            }
        }
        $section = _("Extension Options");
        $currentcomponent->addguielem($section, new gui_textbox('outboundcid', $outboundcid, _("Outbound CID"), _("Overrides the caller id when dialing out a trunk. Any setting here will override the common outbound caller id set in the Trunks admin.<br><br>Format: <b>\"caller name\" &lt;#######&gt;</b><br><br>Leave this field blank to disable the outbound callerid feature for this user."), '!isCallerID()', $msgInvalidOutboundCID, true), 3);
        $ringtimer = isset($ringtimer) ? $ringtimer : '0';
        $currentcomponent->addguielem($section, new gui_selectbox('ringtimer', $currentcomponent->getoptlist('ringtime'), $ringtimer, _("Ring Time"), _("Number of seconds to ring prior to going to voicemail. Default will use the value set in the General Tab. If no voicemail is configured this will be ignored."), false));
        if (!isset($callwaiting)) {
            if ($amp_conf['ENABLECW']) {
                $callwaiting = 'enabled';
            } else {
                $callwaiting = 'disabled';
            }
        }
        $currentcomponent->addguielem($section, new gui_selectbox('callwaiting', $currentcomponent->getoptlist('callwaiting'), $callwaiting, _("Call Waiting"), _("Set the initial/current Call Waiting state for this user's extension"), false));
        $currentcomponent->addguielem($section, new gui_selectbox('call_screen', $currentcomponent->getoptlist('call_screen'), $call_screen, _("Call Screening"), _("Call Screening requires external callers to say their name, which will be played back to the user and allow the user to accept or reject the call.  Screening with memory only verifies a caller for their caller-id once. Screening without memory always requires a caller to say their name. Either mode will always announce the caller based on the last introduction saved with that callerid. If any user on the system uses the memory option, when that user is called, the caller will be required to re-introduce themselves and all users on the system will have that new introduction associated with the caller's CallerId."), false));
        $currentcomponent->addguielem($section, new gui_selectbox('pinless', $currentcomponent->getoptlist('pinless'), $pinless, _("Pinless Dialing"), _("Enabling Pinless Dialing will allow this extension to bypass any pin codes normally required on outbound calls"), false));
        $section = _("Assigned DID/CID");
        $currentcomponent->addguielem($section, new gui_textbox('newdid_name', $newdid_name, _("DID Description"), _("A description for this DID, such as \"Fax\"")), 4);
        $currentcomponent->addguielem($section, new gui_textbox('newdid', $newdid, _("Add Inbound DID"), _("A direct DID that is associated with this extension. The DID should be in the same format as provided by the provider (e.g. full number, 4 digits for 10x4, etc).<br><br>Format should be: <b>XXXXXXXXXX</b><br><br>.An optional CID can also be associated with this DID by setting the next box"), '!isDialpattern()', $msgInvalidDIDNum, true), 4);
        $currentcomponent->addguielem($section, new gui_textbox('newdidcid', $newdidcid, _("Add Inbound CID"), _("Add a CID for more specific DID + CID routing. A DID must be specified in the above Add DID box. In addition to standard dial sequences, you can also put Private, Blocked, Unknown, Restricted, Anonymous and Unavailable in order to catch these special cases if the Telco transmits them."), "!frm_{$display}_isValidCID()", $msgInvalidCIDNum, true), 4);
        $dids = core_did_list('extension');
        $did_count = 0;
        foreach ($dids as $did) {
            $did_dest = split(',', $did['destination']);
            if (isset($did_dest[1]) && $did_dest[1] == $extdisplay) {
                $did_title = $did['description'] != '' ? $did['description'] : _("DID / CID");
                $addURL = $_SERVER['PHP_SELF'] . '?type=setup&display=did&&extdisplay=' . $did['extension'] . '/' . $did['cidnum'];
                $did_icon = 'images/email_edit.png';
                $did_label = trim($did['extension']) == '' ? ' ' . _("Any DID") : ' ' . $did['extension'];
                if (trim($did['cidnum']) != '') {
                    $did_label .= ' / ' . $did['cidnum'];
                }
                if (trim($did['description']) != '') {
                    $did_label .= ' (' . $did['description'] . ')';
                }
                $did_label = '&nbsp;<span>
					<img width="16" height="16" border="0" title="' . $did_title . '" alt="" src="' . $did_icon . '"/>' . $did_label . '</span> ';
                $currentcomponent->addguielem($section, new gui_link('did_' . $did_count++, $did_label, $addURL, true, false), 4);
            }
        }
        $section = _("Recording Options");
        $currentcomponent->addguielem($section, new gui_selectbox('record_in', $currentcomponent->getoptlist('recordoptions'), $record_in, _("Record Incoming"), _("Record all inbound calls received at this extension."), false));
        $currentcomponent->addguielem($section, new gui_selectbox('record_out', $currentcomponent->getoptlist('recordoptions'), $record_out, _("Record Outgoing"), _("Record all outbound calls received at this extension."), false));
    }
}