Index: /freepbx/trunk/amp_conf/astetc/extensions.conf =================================================================== --- /freepbx/trunk/amp_conf/astetc/extensions.conf (revision 3838) +++ /freepbx/trunk/amp_conf/astetc/extensions.conf (revision 3874) @@ -926,5 +926,11 @@ exten => s,n,Set(AMPUSERCIDNAME=${DB(AMPUSER/${AMPUSER}/cidname)}) exten => s,n,GotoIf($["x${AMPUSERCIDNAME:1:2}" = "x"]?report) -exten => s,n,Set(CALLERID(all)=${AMPUSERCIDNAME} <${AMPUSER}>) + +; user may masquerade as a different user internally, so set the internal cid as indicated +; but keep the REALCALLERID which is used to determine their true identify and lookup info +; during outbound calls. +; +exten => s,n,Set(AMPUSERCID=${IF($["${DB_EXISTS(AMPUSER/${AMPUSER}/cidnum)}" = "1"]?${DB_RESULT}:${AMPUSER})}) +exten => s,n,Set(CALLERID(all)=${AMPUSERCIDNAME} <${AMPUSERCID}>) exten => s,n,Set(REALCALLERIDNUM=${DB(DEVICE/${REALCALLERIDNUM}/user)}) exten => s,n(report),Noop(TTL: ${TTL} ARG1: ${ARG1}) Index: /freepbx/trunk/amp_conf/htdocs/admin/modules/core/functions.inc.php =================================================================== --- /freepbx/trunk/amp_conf/htdocs/admin/modules/core/functions.inc.php (revision 3865) +++ /freepbx/trunk/amp_conf/htdocs/admin/modules/core/functions.inc.php (revision 3874) @@ -1194,4 +1194,5 @@ //write to astdb if ($astman) { + $cid_masquerade = (isset($cid_masquerade) && trim($cid_masquerade) != "")?trim($cid_masquerade):$extension; $astman->database_put("AMPUSER",$extension."/password",isset($password)?$password:''); $astman->database_put("AMPUSER",$extension."/ringtimer",isset($ringtimer)?$ringtimer:''); @@ -1200,4 +1201,5 @@ $astman->database_put("AMPUSER",$extension."/outboundcid",isset($outboundcid)?"\"".$outboundcid."\"":''); $astman->database_put("AMPUSER",$extension."/cidname",isset($name)?"\"".$name."\"":''); + $astman->database_put("AMPUSER",$extension."/cidnum",$cid_masquerade); $astman->database_put("AMPUSER",$extension."/voicemail","\"".isset($voicemail)?$voicemail:''."\""); $astman->database_put("AMPUSER",$extension."/device","\"".isset($device)?$device:''."\""); @@ -1206,5 +1208,5 @@ } - if ($vmx_state) { + if ($vmx_state && $voicemail != "novm") { $unavail_mode="enabled"; @@ -1276,4 +1278,6 @@ if ($astman) { $results['vmx_state']=$astman->database_get("AMPUSER",$extension."/vmx/unavail/state"); + $cid_masquerade=$astman->database_get("AMPUSER",$extension."/cidnum"); + $results['cid_masquerade'] = (trim($cid_masquerade) != "")?$cid_masquerade:$extension; } else { fatal("Cannot connect to Asterisk Manager with ".$amp_conf["AMPMGRUSER"]."/".$amp_conf["AMPMGRPASS"]); @@ -1303,4 +1307,5 @@ $astman->database_del("AMPUSER",$extension."/outboundcid"); $astman->database_del("AMPUSER",$extension."/cidname"); + $astman->database_del("AMPUSER",$extension."/cidnum"); $astman->database_del("AMPUSER",$extension."/voicemail"); $astman->database_del("AMPUSER",$extension."/device"); @@ -2443,5 +2448,5 @@ // Ensure variables possibly extracted later exist $name = $directdid = $didalert = $outboundcid = $answer = null; - $record_in = $record_out = $faxexten = $faxemail = $mohclass = $sipname = null; + $record_in = $record_out = $faxexten = $faxemail = $mohclass = $sipname = $cid_masquerade = null; // Init vars from $_REQUEST[] @@ -2486,4 +2491,5 @@ $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'; @@ -2511,4 +2517,6 @@ } $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.', '!isCallerID()', $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 user for internal calls, if different then the extension number. This is used to masquerade as a different user. A common example is a team support persons who would like their internal callerid to display the general support number (a ringgroup or queue). There will be no efffect 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."));