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; }
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; }
} //voicemail symlink // exec("rm -f /var/spool/asterisk/voicemail/device/" . $ext, $output, $return_val); exec("/bin/ln -s /var/spool/asterisk/voicemail/" . $vmcontext . "/" . $ext . "/ /var/spool/asterisk/voicemail/device/" . $ext, $output, $return_val); if ($return_val != 0) { error("Error code {$return_val} when sym-linking vmail context {$vmcontext} to device directory for {$ext}. Trying to carry on but you should investigate."); } } } } if (in_array('addext', $actions)) { $actions_taken = true; $any_users = core_users_get($ext); debug("core_users_add({$user_add_arr})"); if (isset($any_users['extension']) || !core_users_add($user_add_arr)) { var_dump($any_users); fatal("Attempt to add user failed, aborting"); exit(1); } } 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); } }