Example #1
0
function voicemail_configprocess()
{
    //create vars from the request
    extract($_REQUEST);
    $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
    $extdisplay = isset($_REQUEST['extdisplay']) ? $_REQUEST['extdisplay'] : null;
    //if submitting form, update database
    switch ($action) {
        case "add":
            if (!isset($GLOBALS['abort']) || $GLOBALS['abort'] !== true) {
                $usage_arr = framework_check_extension_usage($_REQUEST['extension']);
                if (!empty($usage_arr)) {
                    $GLOBALS['abort'] = true;
                } else {
                    voicemail_mailbox_add($extdisplay, $_REQUEST);
                    needreload();
                }
            }
            break;
        case "del":
            // call remove before del, it needs to know context info
            //
            voicemail_mailbox_remove($extdisplay);
            voicemail_mailbox_del($extdisplay);
            needreload();
            break;
        case "edit":
            if (!isset($GLOBALS['abort']) || $GLOBALS['abort'] !== true) {
                voicemail_mailbox_del($extdisplay);
                if ($vm != 'disabled') {
                    voicemail_mailbox_add($extdisplay, $_REQUEST);
                }
                needreload();
            }
            break;
    }
}
Example #2
0
        debug("core_devices_del({$ext}, true)");
        debug("core_devices_add({$ext},'sip'," . $device_list['dial'] . ",'fixed',{$ext}," . $device_list['description'] . "," . $device_list['emergency_cid'] . ",true)");
        core_devices_del($ext, true);
        core_devices_add($ext, 'sip', $device_list['dial'], 'fixed', $ext, $device_list['description'], $device_list['emergency_cid'], true);
        // doesn't return a return code, so hope it worked:-)
        debug("voicemail_mailbox_del({$ext})");
        debug("voicemail_mailbox_add({$ext}, {$user_mod_arr})");
        voicemail_mailbox_del($ext);
        voicemail_mailbox_add($ext, $user_mod_arr);
    }
}
if (in_array('addvm', $actions)) {
    $actions_taken = true;
    if (($existing_vmbox = voicemail_mailbox_get($ext)) == null) {
        debug("voicemail_mailbox_add({$ext}, {$user_add_arr})");
        voicemail_mailbox_add($ext, $user_add_arr);
    } else {
        debug(print_r($existing_vmbox, true));
        fatal("voicemail_mailbox_get({$ext}) indicates the box already exists, aborting");
        exit(1);
    }
    // check if we need to create symlink if if addext is not being called
    if (!in_array('addext', $actions)) {
        $thisUser = core_users_get($ext);
        // This is a bit kludgey, the other way is to reformat the core_users_get() info and do a core_users_add() in edit mode
        //
        if (!empty($thisUser)) {
            $this_vmcontext = $user_add_arr['vmcontext'];
            sql("UPDATE `users` SET `voicemail` = '{$this_vmcontext}' WHERE `extension` = '{$ext}'");
            if ($astman) {
                $astman->database_put("AMPUSER", $ext . "/voicemail", "\"" . isset($this_vmcontext) ? $this_vmcontext : '' . "\"");