📄 page.extensions.php
字号:
<?php /* $Id: page.extensions.php 1945 2006-05-21 06:29:26Z qldrob $ *///Copyright (C) 2004 Coalescent Systems Inc. (info@coalescentsystems.ca)////This program is free software; you can redistribute it and/or//modify it under the terms of the GNU General Public License//as published by the Free Software Foundation; either version 2//of the License, or (at your option) any later version.////This program is distributed in the hope that it will be useful,//but WITHOUT ANY WARRANTY; without even the implied warranty of//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the//GNU General Public License for more details.include 'common/php-asmanager.php';//make sure we can connect to Asterisk ManagercheckAstMan();/* User specific stuff */$dispnum = 'extensions'; //used for switch in config.php//create vars from the requestextract($_REQUEST);// Clean up warnings for undef'ed varsif (!isset($extdisplay)) $extdisplay='';if (!isset($record_in)) $record_in='';if (!isset($record_out)) $record_out='';if (!isset($emergencycid)) $emergencycid='';if (!isset($outboundcid)) $outboundcid='';//make sure we can connect to Asterisk ManagercheckAstMan();//read in the voicemail.conf and set appropriate variables for display$uservm = getVoicemail();$vmcontexts = array_keys($uservm);$vm=false;foreach ($vmcontexts as $vmcontext) { if(isset($extdisplay) && isset($uservm[$vmcontext][$extdisplay])){ //echo $extdisplay.' found in context '.$vmcontext.'<hr>'; $incontext = $vmcontext; //the context for the current extension $vmpwd = $uservm[$vmcontext][$extdisplay]['pwd']; $name = $uservm[$vmcontext][$extdisplay]['name']; $email = $uservm[$vmcontext][$extdisplay]['email']; $pager = $uservm[$vmcontext][$extdisplay]['pager']; //loop through all options $options=""; if (is_array($uservm[$vmcontext][$extdisplay]['options'])) { $alloptions = array_keys($uservm[$vmcontext][$extdisplay]['options']); if (isset($alloptions)) { foreach ($alloptions as $option) { if ( ($option!="attach") && ($option!="envelope") && ($option!="saycid") && ($option!="delete") && ($option!='') ) $options .= $option.'='.$uservm[$vmcontext][$extdisplay]['options'][$option].'|'; } $options = rtrim($options,'|'); // remove the = sign if there are no options set $options = rtrim($options,'='); } extract($uservm[$vmcontext][$extdisplay]['options'], EXTR_PREFIX_ALL, "vmops"); } $vm=true; }}$vmcontext = $_SESSION["AMP_user"]->_deptname; //AMP Users can only add to their department's contextif (empty($vmcontext)) if (isset($incontext)) $vmcontext = isset($_REQUEST['vmcontext'])?$_REQUEST['vmcontext']:$incontext;if (empty($vmcontext)) $vmcontext = 'default';//check if the extension is within range for this userif (isset($extension) && !checkRange($extension)){ echo "<script>javascript:alert('". _("Warning! Extension")." ".$extension." "._("is not allowed for your account").".');</script>";} else { //deviceid and extension are the same and fixed $deviceid = $deviceuser = isset($extension)?$extension:''; $description = isset($_REQUEST['description'])?$_REQUEST['description']:''; //user name should be equal to device description $_REQUEST['name'] = $description; //if submitting form, update database if (!isset($action)) $action=''; switch ($action) { case "add": core_users_add($_REQUEST,$vmcontext); core_devices_add($deviceid,$tech,$dial,$devicetype,$deviceuser,$description,$emergency_cid); needreload(); break; case "del": core_devices_del($extdisplay); core_users_del($extdisplay,$incontext,$uservm); core_users_cleanastdb($extdisplay); needreload(); break; case "edit": //just delete and re-add core_devices_del($extdisplay); core_devices_add($deviceid,$tech,$dial,$devicetype,$deviceuser,$description,$emergency_cid); core_users_edit($extdisplay,$_REQUEST,$vmcontext,$incontext,$uservm); // Need to re-propogate all the vm info here, because it could have changed $uservm = getVoicemail(); $vmcontexts = array_keys($uservm); $vm=false; foreach ($vmcontexts as $vmcontext) { if(isset($uservm[$vmcontext][$extdisplay])){ $incontext = $vmcontext; //the context for the current extension $vmpwd = $uservm[$vmcontext][$extdisplay]['pwd']; $name = $uservm[$vmcontext][$extdisplay]['name']; $email = $uservm[$vmcontext][$extdisplay]['email']; $pager = $uservm[$vmcontext][$extdisplay]['pager']; $options=""; if (is_array($uservm[$vmcontext][$extdisplay]['options'])) { $alloptions = array_keys($uservm[$vmcontext][$extdisplay]['options']); if (isset($alloptions)) { foreach ($alloptions as $option) { if ( ($option!="attach") && ($option!="envelope") && ($option!="saycid") && ($option!="delete") && ($option!='') ) $options .= $option.'='.$uservm[$vmcontext][$extdisplay]['options'][$option].'|'; } $options = rtrim($options,'|'); // remove the = sign if there are no options set $options = rtrim($options,'='); } extract($uservm[$vmcontext][$extdisplay]['options'], EXTR_PREFIX_ALL, "vmops"); } $vm=true; } } needreload(); break; case "resetall": //form a url with this option to nuke the AMPUSER & DEVICE trees and start over. core_users2astdb(); core_devices2astdb(); break; }}?></div><div class="rnav"><?php $devices = core_devices_list();drawListMenu($devices, isset($_REQUEST['skip'])?$_REQUEST['skip']:0, $dispnum, isset($extdisplay)?$extdisplay:null, _("Extension"));?></div><div class="content"><?php if ($action == 'del') { echo '<br><h3>'.$extdisplay.' '._("deleted").'!</h3><br><br><br><br><br><br><br><br>'; } else if( (isset($tech)?$tech:'') == '' && (isset($extdisplay)?$extdisplay:'') == '' ) {?> <h2><?php echo _("Add an Extension")?></h2> <h5><?php echo _("Select device technology:")?></h5> <li><a href="<?php echo $_SERVER['PHP_SELF'].'?display='.$display; ?>&tech=sip"><?php echo _("SIP")?></a><br><br> <li><a href="<?php echo $_SERVER['PHP_SELF'].'?display='.$display; ?>&tech=iax2"><?php echo _("IAX2")?></a><br><br> <li><a href="<?php echo $_SERVER['PHP_SELF'].'?display='.$display; ?>&tech=zap"><?php echo _("ZAP")?></a><br><br> <li><a href="<?php echo $_SERVER['PHP_SELF'].'?display='.$display; ?>&tech=custom"><?php echo _("Custom")?></a><br><br><?php } else { $delURL = $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'].'&action=del';?><?php if ($extdisplay != null) { $deviceInfo=core_devices_get($extdisplay); extract($deviceInfo,EXTR_PREFIX_ALL,'devinfo'); $extenInfo=core_users_get($extdisplay); extract($extenInfo); $tech = $devinfo_tech; if (is_array($deviceInfo)) extract($deviceInfo);?> <h2><?php echo strtoupper($tech)." "._("Extension")?>: <?php echo $extdisplay; ?></h2> <p><a href="<?php echo $delURL ?>"><?php echo _("Delete Extension")?> <?php echo $extdisplay ?></a></p><?php // implementation of module hook echo $module_hook->hookHtml;} else { ?> <h2><?php echo _("Add")." ".strtoupper($tech)." "._("Extension")?></h2><?php } ?><?php?> <form name="addNew" action="<?php $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return addNew_onsubmit();"> <input type="hidden" name="display" value="<?php echo $dispnum?>"> <input type="hidden" name="action" value="<?php echo ($extdisplay ? 'edit' : 'add') ?>"> <input type="hidden" name="extdisplay" value="<?php echo $extdisplay ?>"> <input type="hidden" name="tech" value="<?php echo $tech ?>"> <table> <tr><td colspan="2"><h5><?php echo ($extdisplay ? _('Edit Extension') : _('Add Extension')) ?><hr></h5></td></tr> <tr <?php echo ($extdisplay ? 'style="display:none"':'') ?>> <td> <a href="#" class="info"><?php echo _("Extension Number")?><span><?php echo _('Use a unique number. The device will use this number to authenicate to the system, and users will dial it to ring the device.').' '._('You can not use 0')?></span></a>: </td> <td> <input type="text" name="extension" value="<?php echo $extdisplay ?>"> </td> </tr> <tr> <td> <a href="#" class="info"><?php echo _("Display Name")?><span><?php echo _("The caller id name for this device will be set to this.")?><br></span></a>: </td><td> <input type="text" name="description" value="<?php echo htmlspecialchars($devinfo_description) ?>"/> </td> </tr> <input type="hidden" name="devicetype" value="fixed"/> <input type="hidden" name="deviceuser" value="same"/> <input type="hidden" name="password" value=""/> <tr> <td colspan="2"> <h5><br><?php echo _("Extension Options")?><hr></h5> </td> </tr> <tr> <td> <a href="#" class="info"><?php echo _("Direct DID")?><span><?php echo _("The 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>Leave this field blank to disable the direct DID feature for this extension. All non-numeric characters will be stripped.")?><br></span></a>: </td><td> <input type="text" name="directdid" value="<?php echo htmlentities($directdid) ?>"/> </td> </tr> <tr> <td> <a href="#" class="info"><?php echo _("DID Alert Info")?><span><?php echo _("Alert Info can be used for distinctive ring on SIP phones. Set this value to the desired Alert Info to be sent to the phone when this DID is called. Leave blank to use default values. Will have no effect if no Direct DID is set")?><br></span></a>: </td><td> <input type="text" name="didalert" value="<?php echo htmlentities($didalert) ?>"/> </td> </tr> <tr> <td> <a href="#" class="info"><?php echo _("Outbound CID")?><span><?php echo _("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\" <#######></b><br><br>Leave this field blank to disable the outbound callerid feature for this extension.")?><br></span></a>: </td><td> <input type="text" name="outboundcid" value="<?php echo htmlentities($outboundcid) ?>"/> </td> </tr> <tr> <td> <a href="#" class="info"><?php echo _("Emergency CID")?><span><?php echo _("This caller id will always be set when dialing out an Outbound Route flagged as Emergency. The Emergency CID overrides all other caller id settings.")?><br></span></a>: </td><td> <input type="text" name="emergency_cid" value="<?php echo htmlspecialchars($emergency_cid) ?>"/> </td> </tr> <tr> <td> <a href="#" class="info"><?php echo _("Record Incoming")?><span><?php echo _("Record all inbound calls received at this extension.")?><br></span></a>: </td><td> <select name="record_in"/> <option value="Adhoc" <?php echo ($record_in == "On-Demand") ? 'selected' : '' ?>><?php echo _("On Demand")?> <option value="Always" <?php echo ($record_in == "Always") ? 'selected' : '' ?>><?php echo _("Always")?> <option value="Never" <?php echo ($record_in == "Never") ? 'selected' : '' ?>><?php echo _("Never")?> </select> </td> </tr> <tr> <td> <a href="#" class="info"><?php echo _("Record Outgoing")?><span><?php echo _("Record all outbound calls received at this extension.")?><br></span></a>: </td><td> <select name="record_out"/> <option value="Adhoc" <?php echo ($record_out == "On-Demand") ? 'selected' : '' ?>><?php echo _("On Demand")?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -