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":
                core_users_del($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
function core_users_configprocess()
{
    if (!class_exists('agi_asteriskmanager')) {
        include 'common/php-asmanager.php';
    }
    //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":
                $conflict_url = array();
                $usage_arr = framework_check_extension_usage($_REQUEST['extension']);
                if (!empty($usage_arr)) {
                    $GLOBALS['abort'] = true;
                    $conflict_url = framework_display_extension_usage_alert($usage_arr, true);
                    global $currentcomponent;
                    $id = 0;
                    $currentcomponent->addguielem('_top', new gui_link_label('conflict', _("Conflicting Extensions"), _("The following extension numbers are in conflict, you can click on the item(s) below to edit the conflicting entity."), true));
                    foreach ($conflict_url as $edit_link) {
                        $currentcomponent->addguielem('_top', new gui_link('conflict' . $i++, $edit_link['label'], $edit_link['url']));
                    }
                    $msg = $_REQUEST['display'] == 'users' ? _("Configure user again:") : _("Configure extension again:");
                    $currentcomponent->addguielem('_top', new gui_subheading('conflict_end', $msg, false));
                    unset($_REQUEST['action']);
                    redirect_standard_continue();
                } elseif (core_users_add($_REQUEST)) {
                    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":
                core_users_del($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.º 3
0
}
if (in_array('addext', $actions)) {
    $actions_taken = true;
    debug("core_devices_add({$ext}, {$tech}, '', 'fixed', {$ext}, {$displayname}, {$emergencycid})");
    $any_devices = core_devices_get($ext);
    if (count($any_devices) > 0 || !core_devices_add($ext, $tech, '', 'fixed', $ext, $displayname, $emergencycid)) {
        var_dump($any_devices);
        fatal("Attempt to add device failed, aborting");
        exit(1);
    }
}
if (in_array('remext', $actions)) {
    $actions_taken = true;
    if (core_users_get($ext) != null) {
        debug("removing user {$ext}");
        core_users_del($ext);
        core_devices_del($ext);
    } else {
        debug("not removing user {$ext}");
    }
    if (voicemail_mailbox_get($ext) != null) {
        debug("removing vm {$ext}");
        voicemail_mailbox_del($ext);
    } else {
        debug("not removing vm {$ext}");
    }
}
if ($actions_taken) {
    debug("Request completed successfully");
    exit(0);
} else {