Changeset 2400

Show
Ignore:
Timestamp:
09/10/06 19:26:08 (7 years ago)
Author:
mheydon1973
Message:

Extensions page now uses functions from Devices and Users, thus stopping any duplicate of code

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freepbx/trunk/amp_conf/htdocs/admin/modules/core/functions.inc.php

    r2399 r2400  
    546546  } 
    547547  //unless defined, $dial is TECH/id 
    548   //zap is an exception 
    549   if (empty($dial) && strtolower($tech) == "zap") 
    550     $dial = "ZAP/".$_REQUEST['channel']; 
    551   if (empty($dial)) 
    552     $dial = strtoupper($tech)."/".$id; 
     548  if ( $dial == '' ) { 
     549    //zap is an exception 
     550    if ( strtolower($tech) == "zap" ) { 
     551      $zapchan = $_REQUEST['devinfo_channel'] != '' ? $_REQUEST['devinfo_channel'] : $_REQUEST['channel']; 
     552      $dial = 'ZAP/'.$zapchan; 
     553    } else { 
     554      $dial = strtoupper($tech)."/".$id; 
     555    } 
     556  } 
     557  //if (empty($dial) && strtolower($tech) == "zap") 
     558  //  $dial = "ZAP/".($_REQUEST['channel'] != '' ? $_REQUEST['channel'] : $_REQUEST['devinfo_channel']); 
     559  //if (empty($dial)) 
     560  //  $dial = strtoupper($tech)."/".$id; 
    553561   
    554562  //check to see if we are requesting a new user 
     
    775783    if ( substr($req, 0, 8) == 'devinfo_' ) { 
    776784      $keyword = substr($req, 8); 
    777       $sipfields[] = array($account, $keyword, $data); 
     785      if ( $keyword == 'dial' && $data == '' ) { 
     786        $sipfields[] = array($account, $keyword, 'SIP/'.$account); 
     787      } else { 
     788        $sipfields[] = array($account, $keyword, $data); 
     789      } 
    778790    } 
    779791  } 
     
    850862    if ( substr($req, 0, 8) == 'devinfo_' ) { 
    851863      $keyword = substr($req, 8); 
    852       $iaxfields[] = array($account, $keyword, $data); 
     864      if ( $keyword == 'dial' && $data == '' ) { 
     865        $iaxfields[] = array($account, $keyword, 'IAX/'.$account); 
     866      } else { 
     867        $iaxfields[] = array($account, $keyword, $data); 
     868      } 
    853869    } 
    854870  } 
     
    920936    if ( substr($req, 0, 8) == 'devinfo_' ) { 
    921937      $keyword = substr($req, 8); 
    922       $zapfields[] = array($account, $keyword, $data); 
     938      if ( $keyword == 'dial' && $data == '' ) { 
     939        $zapchan = $_REQUEST['devinfo_channel'] != '' ? $_REQUEST['devinfo_channel'] : $_REQUEST['channel']; 
     940        $zapfields[] = array($account, $keyword, 'ZAP/'.$zapchan); 
     941      } else { 
     942        $zapfields[] = array($account, $keyword, $data); 
     943      } 
    923944    } 
    924945  } 
     
    21972218  global $currentcomponent; 
    21982219 
    2199   //if ( $dispnum == 'users' || $dispnum == 'extensions' ) { 
    2200   if ( $dispnum == 'users' ) { 
     2220  if ( $dispnum == 'users' || $dispnum == 'extensions' ) { 
    22012221    // Setup option list we need 
    22022222    $currentcomponent->addoptlistitem('recordoptions', 'Adhoc', 'On Demand'); 
     
    22412261 
    22422262  // Init vars from $_REQUEST[] 
     2263  $display = $_REQUEST['display']; 
    22432264  $action = $_REQUEST['action']; 
    22442265  $extdisplay = $_REQUEST['extdisplay']; 
    2245    
    2246   if ($action == 'del') { 
     2266 
     2267  if ( $action == 'del' ) { // Deleted 
     2268 
    22472269    $currentcomponent->addguielem('_top', new gui_subheading('del', $extdisplay.' '._("deleted"), false)); 
     2270 
     2271  } elseif ( $display == 'extensions' && ($extdisplay == '' && $_REQUEST['tech_hardware'] == '') ) { // Adding 
     2272 
     2273    // do nothing as you want the Devices to handle this bit 
     2274 
    22482275  } else { 
     2276 
    22492277    $delURL = $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'].'&action=del'; 
    22502278   
    2251     if (is_string($extdisplay)) {  
     2279    if ( is_string($extdisplay) ) {  
    22522280      $extenInfo=core_users_get($extdisplay); 
    22532281      extract($extenInfo); 
     
    22552283        extract($deviceInfo); 
    22562284   
    2257       $currentcomponent->addguielem('_top', new gui_pageheading('title', _("User").": $extdisplay", false), 0); 
    2258       $currentcomponent->addguielem('_top', new gui_link('del', _("Delete User")." $extdisplay", $delURL, true, false), 0); 
    2259  
    2260     } else { 
     2285      if ( $display == 'extensions' ) { 
     2286        $currentcomponent->addguielem('_top', new gui_pageheading('title', _("Extension").": $extdisplay", false), 0); 
     2287        $currentcomponent->addguielem('_top', new gui_link('del', _("Delete Extension")." $extdisplay", $delURL, true, false), 0); 
     2288      } else { 
     2289        $currentcomponent->addguielem('_top', new gui_pageheading('title', _("User").": $extdisplay", false), 0); 
     2290        $currentcomponent->addguielem('_top', new gui_link('del', _("Delete User")." $extdisplay", $delURL, true, false), 0); 
     2291      } 
     2292 
     2293    } elseif ( $display != 'extensions' ) { 
    22612294      $currentcomponent->addguielem('_top', new gui_pageheading('title', 'Add User/Extension'), 0); 
    22622295    } 
     
    22762309    $currentcomponent->addguielem('_top', new gui_hidden('extdisplay', $extdisplay)); 
    22772310     
    2278     $section = ($extdisplay ? 'Edit User' : 'Add User'); 
     2311    if ( $display == 'extensions' ) { 
     2312      $section = ($extdisplay ? 'Edit Extension' : 'Add Extension');       
     2313    } else { 
     2314      $section = ($extdisplay ? 'Edit User' : 'Add User'); 
     2315    } 
    22792316    if ( $extdisplay ) { 
    22802317      $currentcomponent->addguielem($section, new gui_hidden('extension', $extdisplay)); 
     
    22822319      $currentcomponent->addguielem($section, new gui_textbox('extension', $extdisplay, 'User Extension', 'The extension number to dial to reach this user.', '!isInteger()', $msgInvalidExtNum, false)); 
    22832320    } 
    2284     $currentcomponent->addguielem($section, new gui_password('password', $password, 'User Password', _("A user will enter this password when logging onto a device.").' '.$fc_logon.' '._('logs into a device.').' '.$fc_logoff.' '._('logs out of a device.'), '!isInteger() && !isWhitespace()', $msgInvalidExtPwd, true)); 
    2285     // extra JS function check required for blank password warning -- call last in the onsubmit() function 
    2286     $currentcomponent->addjsfunc('onsubmit()', "\treturn checkBlankUserPwd();\n", 9); 
     2321    if ( $display != 'extensions' ) { 
     2322      $currentcomponent->addguielem($section, new gui_password('password', $password, 'User Password', _("A user will enter this password when logging onto a device.").' '.$fc_logon.' '._('logs into a device.').' '.$fc_logoff.' '._('logs out of a device.'), '!isInteger() && !isWhitespace()', $msgInvalidExtPwd, true)); 
     2323      // extra JS function check required for blank password warning -- call last in the onsubmit() function 
     2324      $currentcomponent->addjsfunc('onsubmit()', "\treturn checkBlankUserPwd();\n", 9); 
     2325    } 
    22872326    $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.', '!isCallerID()', $msgInvalidOutboundCID, false)); 
    22882327     
     
    23112350 
    23122351function core_users_configprocess() { 
    2313   include 'common/php-asmanager.php'; 
     2352  if ( !class_exists('agi_asteriskmanager') ) 
     2353    include 'common/php-asmanager.php'; 
    23142354   
    23152355  //create vars from the request 
     
    23462386  global $currentcomponent; 
    23472387 
    2348   //if ( $dispnum == 'devices' || $dispnum == 'extensions' ) { 
    2349   if ( $dispnum == 'devices' ) { 
     2388  if ( $dispnum == 'devices' || $dispnum == 'extensions' ) { 
    23502389    // Setup arrays for device types 
    23512390    $currentcomponent->addgeneralarray('devtechs'); 
     
    24492488 
    24502489  // Init vars from $_REQUEST[] 
     2490  $display = $_REQUEST['display']; 
    24512491  $action = $_REQUEST['action']; 
    24522492  $extdisplay = $_REQUEST['extdisplay']; 
     
    24552495  if ( $action == 'del' ) { // Deleted 
    24562496 
    2457     $currentcomponent->addguielem('_top', new gui_subheading('del', $extdisplay.' '._("deleted"), false)); 
     2497    if ( $display != 'extensions' ) 
     2498      $currentcomponent->addguielem('_top', new gui_subheading('del', $extdisplay.' '._("deleted"), false)); 
    24582499 
    24592500  } elseif ( $extdisplay == '' && $tech_hardware == '' ) { // Adding 
    24602501 
    2461     $currentcomponent->addguielem('_top', new gui_pageheading('title', 'Add Device'), 0); 
     2502    if ( $display != 'extensions') { 
     2503      $currentcomponent->addguielem('_top', new gui_pageheading('title', 'Add Device'), 0); 
     2504    } else { 
     2505      $currentcomponent->addguielem('_top', new gui_pageheading('title', 'Add an Extension'), 0); 
     2506    } 
    24622507    $currentcomponent->addguielem('_top', new gui_label('instructions', 'Please select your Device below then click Submit')); 
    24632508    $currentcomponent->addguielem('Device', new gui_selectbox('tech_hardware', $currentcomponent->getoptlist('devicelist'), '', 'Device', '', false)); 
     
    24692514 
    24702515      $deviceInfo = core_devices_get($extdisplay); 
    2471       $currentcomponent->addguielem('_top', new gui_pageheading('title', _("Device").": $extdisplay", false), 0); 
    2472  
    2473       $delURL = $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'].'&action=del'; 
    2474       $currentcomponent->addguielem('_top', new gui_link('del', _("Delete Device")." $extdisplay", $delURL, true, false), 0); 
    2475  
     2516 
     2517      if ( $display != 'extensions' ) { 
     2518        $currentcomponent->addguielem('_top', new gui_pageheading('title', _("Device").": $extdisplay", false), 0); 
     2519 
     2520        $delURL = $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'].'&action=del'; 
     2521        $currentcomponent->addguielem('_top', new gui_link('del', _("Delete Device")." $extdisplay", $delURL, true, false), 0); 
     2522      } 
     2523   
    24762524    } else { 
    24772525 
     
    24812529      unset($tmparr); 
    24822530       
    2483       $currentcomponent->addguielem('_top', new gui_pageheading('title', _('Add').' '.strtoupper($deviceInfo['tech']).' '._('Device')), 0); 
    2484  
    2485     } 
    2486  
    2487     extract($deviceInfo, EXTR_PREFIX_ALL, 'devinfo'); 
     2531      if ( $display != 'extensions' ) { 
     2532        $currentcomponent->addguielem('_top', new gui_pageheading('title', _('Add').' '.strtoupper($deviceInfo['tech']).' '._('Device')), 0); 
     2533      } else { 
     2534        $currentcomponent->addguielem('_top', new gui_pageheading('title', _('Add').' '.strtoupper($deviceInfo['tech']).' '._('Extension')), 0); 
     2535      } 
     2536 
     2537    } 
     2538 
     2539    if ( is_array($deviceInfo) ) 
     2540      extract($deviceInfo, EXTR_PREFIX_ALL, 'devinfo'); 
    24882541 
    24892542    // Setup vars for use in the gui later on              
     
    24942547    $msgInvalidDevDesc = 'Please enter a valid Description for this device'; 
    24952548    $msgInvalidEmergCID = 'Please enter a valid Emergency CID'; 
     2549    $msgInvalidExtNum = 'Please enter a valid extension number.'; 
    24962550     
    24972551    // Actual gui 
     
    24992553    $currentcomponent->addguielem('_top', new gui_hidden('extdisplay', $extdisplay)); 
    25002554 
    2501     $section = "Device Info"; 
    2502     if ( $extdisplay ) { // Editing 
    2503       $currentcomponent->addguielem($section, new gui_hidden('deviceid', $extdisplay)); 
    2504     } else { // Adding 
    2505       $currentcomponent->addguielem($section, new gui_textbox('deviceid', $extdisplay, 'Device ID', 'Give your device a unique integer ID.  The device will use this ID to authenicate to the system.', '!isInteger()', $msgInvalidDevID, false)); 
    2506     } 
    2507     $currentcomponent->addguielem($section, new gui_textbox('description', $devinfo_description, 'Description', 'The caller id name for this device will be set to this description until it is logged into.', '!isAlphanumeric() || isWhitespace()', $msgInvalidDevDesc, false)); 
    2508     $currentcomponent->addguielem($section, new gui_textbox('emergency_cid', $devinfo_emergency_cid, 'Emergency CID', '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.', '!isCallerID()', $msgInvalidEmergCID)); 
    2509     $currentcomponent->addguielem($section, new gui_selectbox('devicetype', $currentcomponent->getoptlist('devicetypelist'), $devinfo_devicetype, 'Device Type', _('Devices can be fixed or adhoc. Fixed devices are always associated to the same extension/user. Adhoc devices can be logged into and logged out of by users.').' '.$fc_logon.' '._('logs into a device.').' '.$fc_logoff.' '._('logs out of a device.'), false)); 
    2510     $currentcomponent->addguielem($section, new gui_selectbox('deviceuser', $currentcomponent->getoptlist('deviceuserlist'), $devinfo_user, 'Default User', 'Fixed devices will always mapped to this user.  Adhoc devices will be mapped to this user by default.<br><br>If selecting "New User", a new User Extension of the same Device ID will be set as the Default User.', false)); 
     2555    if ( $display != 'extensions' ) { 
     2556      $section = 'Device Info'; 
     2557      if ( $extdisplay ) { // Editing 
     2558        $currentcomponent->addguielem($section, new gui_hidden('deviceid', $extdisplay)); 
     2559      } else { // Adding 
     2560        $currentcomponent->addguielem($section, new gui_textbox('deviceid', $extdisplay, 'Device ID', 'Give your device a unique integer ID.  The device will use this ID to authenicate to the system.', '!isInteger()', $msgInvalidDevID, false)); 
     2561      } 
     2562      $currentcomponent->addguielem($section, new gui_textbox('description', $devinfo_description, 'Description', 'The caller id name for this device will be set to this description until it is logged into.', '!isAlphanumeric() || isWhitespace()', $msgInvalidDevDesc, false)); 
     2563      $currentcomponent->addguielem($section, new gui_textbox('emergency_cid', $devinfo_emergency_cid, 'Emergency CID', '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.', '!isCallerID()', $msgInvalidEmergCID)); 
     2564      $currentcomponent->addguielem($section, new gui_selectbox('devicetype', $currentcomponent->getoptlist('devicetypelist'), $devinfo_devicetype, 'Device Type', _('Devices can be fixed or adhoc. Fixed devices are always associated to the same extension/user. Adhoc devices can be logged into and logged out of by users.').' '.$fc_logon.' '._('logs into a device.').' '.$fc_logoff.' '._('logs out of a device.'), false)); 
     2565      $currentcomponent->addguielem($section, new gui_selectbox('deviceuser', $currentcomponent->getoptlist('deviceuserlist'), $devinfo_user, 'Default User', 'Fixed devices will always mapped to this user.  Adhoc devices will be mapped to this user by default.<br><br>If selecting "New User", a new User Extension of the same Device ID will be set as the Default User.', false)); 
     2566    } else { 
     2567      $section = 'Extension Options'; 
     2568      $currentcomponent->addguielem($section, new gui_textbox('emergency_cid', $devinfo_emergency_cid, 'Emergency CID', '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.', '!isCallerID()', $msgInvalidEmergCID)); 
     2569    } 
    25112570    $currentcomponent->addguielem($section, new gui_hidden('tech', $devinfo_tech)); 
    25122571    $currentcomponent->addguielem($section, new gui_hidden('hardware', $devinfo_hardware)); 
    25132572 
    2514     $section = "Device Options"
     2573    $section = 'Device Options'
    25152574    $devopts = $currentcomponent->getgeneralarrayitem('devtechs', $devinfo_tech); 
    25162575    foreach ($devopts as $devopt=>$devoptarr) { 
     
    25312590 
    25322591function core_devices_configprocess() { 
    2533   include 'common/php-asmanager.php'; 
     2592  if ( !class_exists('agi_asteriskmanager') ) 
     2593    include 'common/php-asmanager.php'; 
    25342594 
    25352595  //make sure we can connect to Asterisk Manager 
     
    25392599  extract($_REQUEST); 
    25402600 
     2601  // fixed users only in extensions mode 
     2602  if ( $display == 'extensions' ) { 
     2603    $devicetype = 'fixed'; 
     2604    $deviceid = $deviceuser = $extension; 
     2605        $description = $name; 
     2606  } 
     2607   
    25412608  //if submitting form, update database 
    25422609  switch ($action) { 
  • freepbx/trunk/amp_conf/htdocs/admin/modules/core/page.extensions.php

    r2397 r2400  
    1111//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1212//GNU General Public License for more details. 
    13  
    14 include 'common/php-asmanager.php'; 
    15  
    16  
    17  
    18 //make sure we can connect to Asterisk Manager 
    19 checkAstMan(); 
    20  
    21 /* User specific stuff */ 
    22  
    23 $dispnum = 'extensions'; //used for switch in config.php 
    24  
    25 //create vars from the request 
    26 extract($_REQUEST); 
    27  
    28 // Clean up warnings for undef'ed vars 
    29 if (!isset($extdisplay)) $extdisplay=''; 
    30 if (!isset($record_in)) $record_in=''; 
    31 if (!isset($record_out)) $record_out=''; 
    32 if (!isset($emergencycid)) $emergencycid=''; 
    33 if (!isset($outboundcid)) $outboundcid=''; 
    34  
    35 //make sure we can connect to Asterisk Manager 
    36 checkAstMan(); 
    37  
    38 //read in the voicemail.conf and set appropriate variables for display 
    39 $uservm = voicemail_getVoicemail(); 
    40 $vmcontexts = array_keys($uservm); 
    41 $vm=false; 
    42 foreach ($vmcontexts as $vmcontext) { 
    43   if(isset($extdisplay) && isset($uservm[$vmcontext][$extdisplay])){ 
    44     //echo $extdisplay.' found in context '.$vmcontext.'<hr>'; 
    45     $incontext = $vmcontext;  //the context for the current extension 
    46     $vmpwd = $uservm[$vmcontext][$extdisplay]['pwd']; 
    47     $name = $uservm[$vmcontext][$extdisplay]['name']; 
    48     $email = $uservm[$vmcontext][$extdisplay]['email']; 
    49     $pager = $uservm[$vmcontext][$extdisplay]['pager']; 
    50     //loop through all options 
    51     $options=""; 
    52     if (is_array($uservm[$vmcontext][$extdisplay]['options'])) { 
    53       $alloptions = array_keys($uservm[$vmcontext][$extdisplay]['options']); 
    54       if (isset($alloptions)) { 
    55         foreach ($alloptions as $option) { 
    56           if ( ($option!="attach") && ($option!="envelope") && ($option!="saycid") && ($option!="delete") && ($option!='') ) 
    57             $options .= $option.'='.$uservm[$vmcontext][$extdisplay]['options'][$option].'|'; 
    58         } 
    59         $options = rtrim($options,'|'); 
    60         // remove the = sign if there are no options set 
    61         $options = rtrim($options,'='); 
    62          
    63       } 
    64       extract($uservm[$vmcontext][$extdisplay]['options'], EXTR_PREFIX_ALL, "vmops"); 
    65     } 
    66     $vm=true; 
    67   } 
    68 } 
    69  
    70 $vmcontext = $_SESSION["AMP_user"]->_deptname; //AMP Users can only add to their department's context 
    71 if (empty($vmcontext))  
    72   if (isset($incontext)) 
    73     $vmcontext = isset($_REQUEST['vmcontext'])?$_REQUEST['vmcontext']:$incontext; 
    74 if (empty($vmcontext)) 
    75   $vmcontext = 'default'; 
    76  
    77 //check if the extension is within range for this user 
    78 if (isset($extension) && !checkRange($extension)){ 
    79   echo "<script>javascript:alert('". _("Warning! Extension")." ".$extension." "._("is not allowed for your account").".');</script>"; 
    80 } else { 
    81   //deviceid and extension are the same and fixed 
    82   $deviceid = $deviceuser = isset($extension)?$extension:''; 
    83   $description = isset($_REQUEST['description'])?$_REQUEST['description']:''; 
    84    
    85   //user name should be equal to device description 
    86   $_REQUEST['name'] = $description; 
    87  
    88   //if submitting form, update database 
    89   if (!isset($action))  
    90     $action=''; 
    91   switch ($action) { 
    92     case "add": 
    93       core_users_add($_REQUEST,$vmcontext); 
    94       core_devices_add($deviceid,$tech,$dial,$devicetype,$deviceuser,$description,$emergency_cid); 
    95       needreload(); 
    96     break; 
    97     case "del": 
    98       core_devices_del($extdisplay); 
    99       core_users_del($extdisplay,$incontext,$uservm); 
    100       core_users_cleanastdb($extdisplay); 
    101       needreload(); 
    102     break; 
    103     case "edit":  //just delete and re-add 
    104       core_devices_del($extdisplay); 
    105       core_devices_add($deviceid,$tech,$dial,$devicetype,$deviceuser,$description,$emergency_cid); 
    106       core_users_edit($extdisplay,$_REQUEST,$vmcontext,$incontext,$uservm); 
    107       // Need to re-propogate all the vm info here, because it could have changed 
    108       $uservm = voicemail_getVoicemail(); 
    109       $vmcontexts = array_keys($uservm); 
    110       $vm=false; 
    111       foreach ($vmcontexts as $vmcontext) { 
    112         if(isset($uservm[$vmcontext][$extdisplay])){ 
    113           $incontext = $vmcontext;  //the context for the current extension 
    114           $vmpwd = $uservm[$vmcontext][$extdisplay]['pwd']; 
    115           $name = $uservm[$vmcontext][$extdisplay]['name']; 
    116           $email = $uservm[$vmcontext][$extdisplay]['email']; 
    117           $pager = $uservm[$vmcontext][$extdisplay]['pager']; 
    118           $options=""; 
    119           if (is_array($uservm[$vmcontext][$extdisplay]['options'])) { 
    120             $alloptions = array_keys($uservm[$vmcontext][$extdisplay]['options']); 
    121             if (isset($alloptions)) { 
    122               foreach ($alloptions as $option) { 
    123                 if ( ($option!="attach") && ($option!="envelope") && ($option!="saycid") && ($option!="delete") && ($option!='') ) 
    124                 $options .= $option.'='.$uservm[$vmcontext][$extdisplay]['options'][$option].'|'; 
    125               } 
    126               $options = rtrim($options,'|'); 
    127               // remove the = sign if there are no options set 
    128               $options = rtrim($options,'='); 
    129             } 
    130             extract($uservm[$vmcontext][$extdisplay]['options'], EXTR_PREFIX_ALL, "vmops"); 
    131           } 
    132           $vm=true; 
    133         } 
    134       } 
    135       needreload(); 
    136                 break; 
    137     case "resetall":  //form a url with this option to nuke the AMPUSER & DEVICE trees and start over. 
    138       core_users2astdb(); 
    139       core_devices2astdb(); 
    140     break; 
    141   } 
    142 } 
    14313?> 
    144 </div> 
    14514 
    14615<div class="rnav"> 
    14716<?php  
    148 $devices = core_devices_list(); 
    149 drawListMenu($devices, isset($_REQUEST['skip'])?$_REQUEST['skip']:0, $dispnum, isset($extdisplay)?$extdisplay:null, _("Extension")); 
     17$extens = core_users_list(); 
     18drawListMenu($extens, $_REQUEST['skip'], $_REQUEST['display'], $_REQUEST['extdisplay'], _("Extension")); 
    15019?> 
    15120</div> 
    152  
    153  
    154 <div class="content"> 
    155 <?php  
    156   if ($action == 'del') { 
    157     echo '<br><h3>'.$extdisplay.' '._("deleted").'!</h3><br><br><br><br><br><br><br><br>'; 
    158   } else if( (isset($tech)?$tech:'') == '' && (isset($extdisplay)?$extdisplay:'') == '' ) { 
    159 ?> 
    160     <h2><?php echo _("Add an Extension")?></h2> 
    161     <h5><?php echo _("Select device technology:")?></h5> 
    162     <li><a href="<?php echo $_SERVER['PHP_SELF'].'?display='.$display; ?>&tech=sip"><?php echo _("SIP")?></a><br><br> 
    163     <li><a href="<?php echo $_SERVER['PHP_SELF'].'?display='.$display; ?>&tech=iax2"><?php echo _("IAX2")?></a><br><br> 
    164     <li><a href="<?php echo $_SERVER['PHP_SELF'].'?display='.$display; ?>&tech=zap"><?php echo _("ZAP")?></a><br><br> 
    165     <li><a href="<?php echo $_SERVER['PHP_SELF'].'?display='.$display; ?>&tech=custom"><?php echo _("Custom")?></a><br><br> 
    166 <?php 
    167   } else { 
    168     $delURL = $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'].'&action=del'; 
    169 ?> 
    170 <?php if ($extdisplay != null) {   
    171   $deviceInfo=core_devices_get($extdisplay); 
    172   extract($deviceInfo,EXTR_PREFIX_ALL,'devinfo'); 
    173   $extenInfo=core_users_get($extdisplay); 
    174   extract($extenInfo); 
    175   $tech = $devinfo_tech; 
    176   if (is_array($deviceInfo)) extract($deviceInfo); 
    177 ?> 
    178     <h2><?php echo strtoupper($tech)." "._("Extension")?>: <?php echo $extdisplay; ?></h2> 
    179     <p><a href="<?php echo $delURL ?>"><?php echo _("Delete Extension")?> <?php echo $extdisplay ?></a></p> 
    180 <?php  
    181     // implementation of module hook 
    182     echo $module_hook->hookHtml; 
    183 } else { ?> 
    184     <h2><?php echo _("Add")." ".strtoupper($tech)." "._("Extension")?></h2> 
    185 <?php } ?> 
    186 <?php 
    187 ?> 
    188     <form name="addNew" action="<?php $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return addNew_onsubmit();"> 
    189     <input type="hidden" name="display" value="<?php echo $dispnum?>"> 
    190     <input type="hidden" name="action" value="<?php echo ($extdisplay ? 'edit' : 'add') ?>"> 
    191     <input type="hidden" name="extdisplay" value="<?php echo $extdisplay ?>"> 
    192     <input type="hidden" name="tech" value="<?php echo $tech ?>"> 
    193     <table> 
    194      
    195     <tr><td colspan="2"><h5><?php echo ($extdisplay ? _('Edit Extension') : _('Add Extension')) ?><hr></h5></td></tr> 
    196  
    197     <tr <?php echo ($extdisplay ? 'style="display:none"':'') ?>> 
    198       <td> 
    199         <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>: 
    200       </td> 
    201       <td> 
    202         <input type="text" name="extension" value="<?php echo $extdisplay ?>"> 
    203       </td> 
    204     </tr> 
    205  
    206     <tr> 
    207       <td> 
    208         <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>: 
    209       </td><td> 
    210         <input type="text" name="description" value="<?php echo htmlspecialchars($devinfo_description) ?>"/> 
    211       </td> 
    212     </tr> 
    213     <input type="hidden" name="devicetype" value="fixed"/> 
    214     <input type="hidden" name="deviceuser" value="same"/> 
    215     <input type="hidden" name="password" value=""/> 
    216      
    217     <tr> 
    218       <td colspan="2"> 
    219         <h5><br><?php echo _("Extension Options")?><hr></h5> 
    220       </td> 
    221     </tr> 
    222      
    223     <tr> 
    224       <td> 
    225         <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>: 
    226       </td><td> 
    227         <input type="text" name="directdid" value="<?php echo htmlentities($directdid) ?>"/> 
    228       </td> 
    229     </tr> 
    230  
    231     <tr> 
    232       <td> 
    233         <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>: 
    234       </td><td> 
    235         <input type="text" name="didalert" value="<?php echo htmlentities($didalert) ?>"/> 
    236       </td> 
    237     </tr> 
    238  
    239     <tr> 
    240       <td> 
    241         <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\" &lt;#######&gt;</b><br><br>Leave this field blank to disable the outbound callerid feature for this extension.")?><br></span></a>: 
    242       </td><td> 
    243         <input type="text" name="outboundcid" value="<?php echo htmlentities($outboundcid) ?>"/> 
    244       </td> 
    245     </tr> 
    246  
    247     <tr> 
    248          <td> 
    249              <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>: 
    250          </td><td> 
    251              <input type="text" name="emergency_cid" value="<?php echo htmlspecialchars($emergency_cid) ?>"/> 
    252          </td> 
    253     </tr> 
    254  
    255     <tr> 
    256       <td> 
    257         <a href="#" class="info"><?php echo _("Record Incoming")?><span><?php echo _("Record all inbound calls received at this extension.")?><br></span></a>: 
    258       </td><td> &nbsp; 
    259         <select name="record_in"/> 
    260           <option value="Adhoc" <?php  echo ($record_in == "On-Demand") ? 'selected' : '' ?>><?php echo _("On Demand")?> 
    261           <option value="Always" <?php  echo ($record_in == "Always") ? 'selected' : '' ?>><?php echo _("Always")?> 
    262           <option value="Never" <?php  echo ($record_in == "Never") ? 'selected' : '' ?>><?php echo _("Never")?> 
    263         </select> 
    264       </td> 
    265     </tr> 
    266      
    267     <tr> 
    268       <td> 
    269         <a href="#" class="info"><?php echo _("Record Outgoing")?><span><?php echo _("Record all outbound calls received at this extension.")?><br></span></a>: 
    270       </td><td> &nbsp; 
    271         <select name="record_out"/> 
    272           <option value="Adhoc" <?php  echo ($record_out == "On-Demand") ? 'selected' : '' ?>><?php echo _("On Demand")?> 
    273           <option value="Always" <?php  echo ($record_out == "Always") ? 'selected' : '' ?>><?php echo _("Always")?> 
    274           <option value="Never" <?php  echo ($record_out == "Never") ? 'selected' : '' ?>><?php echo _("Never")?> 
    275         </select> 
    276       </td> 
    277     </tr> 
    278  
    279       <td><br></td> 
    280  
    281     <tr><td colspan="2"><h5><?php echo _("Fax Handling")?><hr></h5></td></tr> 
    282     <tr> 
    283       <td> 
    284         <a class="info" href="#"><?php echo _("Fax Extension")?><span><?php echo _("Select 'system' to have the system receive and email faxes.<br><br>The freePBX default is defined in General Settings.")?></span></a>: 
    285       </td> 
    286       <td>&nbsp; 
    287         <select name="faxexten"> 
    288 <?php  
    289 // Cleaning up warnings. I should do this a better way. 
    290 if (!isset($faxexten)) 
    291   $faxexten = null; 
    292 if (!isset($faxemail)) 
    293   $faxemail = null; 
    294 if (!isset($answer)) 
    295   $answer = '0'; 
    296 ?> 
    297           <option value="default" <?php  echo ($faxexten == 'default' ? 'SELECTED' : '')?>><?php echo _("freePBX default")?> 
    298           <option value="disabled" <?php  echo ($faxexten == 'disabled' ? 'SELECTED' : '')?>><?php echo _("disabled")?> 
    299           <option value="system" <?php  echo ($faxexten == 'system' ? 'SELECTED' : '')?>><?php echo _("system")?> 
    300       <?php  
    301         //get unique devices 
    302         $devices = core_devices_list(); 
    303         if (isset($devices)) { 
    304           foreach ($devices as $device) { 
    305             echo '<option value="'.$device[0].'" '.($faxexten == $device[0] ? 'SELECTED' : '').'>'.$device[1].' &lt;'.$device[0].'&gt;'; 
    306           } 
    307         } 
    308       ?>   
    309         </select> 
    310       </td> 
    311     </tr> 
    312     <tr> 
    313       <td> 
    314         <a class="info" href="#"><?php echo _("Fax Email")?><span><?php echo _("Email address is used if 'system' has been chosen for the fax extension above.<br><br>Leave this blank to use the freePBX default in General Settings.")?></span></a>: 
    315       </td> 
    316       <td> 
    317         <input type="text" size="20" name="faxemail" value="<?php echo htmlspecialchars($faxemail)?>"/> 
    318       </td> 
    319     </tr> 
    320     <tr> 
    321       <td><a href="#" class="info"><?php echo _("Fax Detection Type")?><span><?php echo _('Selecting Zaptel or NVFax will immediately answer the call and play ringing tones to the caller for the number of seconds in Pause below. Use NVFax on SIP or IAX trunks.')?></span></a>:</td> 
    322       <td>&nbsp; 
    323         <select name="answer"> 
    324           <option value="0" <?php  echo ($answer == '0' ? 'SELECTED' : '')?>><?php echo _("None")?> 
    325           <option value="1" <?php  echo ($answer == '1' ? 'SELECTED' : '')?>><?php echo _("Zaptel")?> 
    326           <option value="2" <?php  echo ($answer == '2' ? 'SELECTED' : '')?>><?php echo _("NVFax")?> 
    327         </select> 
    328       </td> 
    329     </tr> 
    330     <tr> 
    331       <td><a href="#" class="info"><?php echo _("Pause after answer")?><span><?php echo _('The number of seconds we should wait after performing an Immediate Answer. The primary purpose of this is to pause and listen for a fax tone before allowing the call to proceed.')?></span></a>:</td> 
    332       <td><input type="text" name="wait" size="3" value="<?php echo isset($wait)?$wait:'' ?>"></td> 
    333     </tr> 
    334     <tr> 
    335       <td><br></td> 
    336     </tr> 
    337 <?php 
    338 if (!isset($privacyman)) 
    339   $privacyman = '0'; 
    340 ?> 
    341     <tr><td colspan="2"><h5><?php echo _("Privacy")?><hr></h5></td></tr> 
    342     <tr> 
    343       <td><a href="#" class="info"><?php echo _("Privacy Manager")?><span><?php echo _('If no Caller ID is sent, Privacy Manager will asks the caller to enter their 10 digit phone number. The caller is given 3 attempts.')?></span></a>:</td> 
    344       <td> 
    345         <select name="privacyman"> 
    346           <option value="0" <?php  echo ($privacyman == '0' ? 'SELECTED' : '')?>><?php echo _("No")?> 
    347           <option value="1" <?php  echo ($privacyman == '1' ? 'SELECTED' : '')?>><?php echo _("Yes")?> 
    348         </select> 
    349       </td> 
    350     </tr> 
    351     <tr> 
    352       <td><br></td> 
    353     </tr>    
    354      
    355     <tr> 
    356       <td colspan="2"> 
    357         <h5><br><?php echo _("Device Options")?><hr></h5> 
    358       </td> 
    359     </tr> 
    360      
    361 <?php 
    362 switch(strtolower($tech)) { 
    363   case "zap": 
    364     $basic = array( 
    365       'channel' => '', 
    366     ); 
    367     $advanced = array( 
    368       'context' => 'from-internal', 
    369       'signalling' => 'fxo_ks', 
    370       'echocancel' => 'yes', 
    371       'echocancelwhenbridged' => 'no', 
    372       'echotraining' => '800', 
    373       'immediate' => 'no',       
    374       'busydetect' => 'no', 
    375       'busycount' => '7', 
    376       'callprogress' => 'no', 
    377       'dial' => '', 
    378       'accountcode' => '', 
    379       'mailbox' => '' 
    380     ); 
    381   break; 
    382   case "iax2": 
    383     $basic = array( 
    384       'secret' => '', 
    385     ); 
    386     $advanced = array( 
    387       'notransfer' => 'yes', 
    388       'context' => 'from-internal', 
    389       'host' => 'dynamic', 
    390       'type' => 'friend', 
    391       'port' => '4569', 
    392       'qualify' => 'no', 
    393       'disallow' => '', 
    394       'allow' => '', 
    395       'dial' => '', 
    396       'accountcode' => '', 
    397       'mailbox' => '' 
    398     );     
    399   break; 
    400   case "sip": 
    401     $basic = array( 
    402       'secret' => '', 
    403       'dtmfmode' => 'rfc2833' 
    404     ); 
    405     $advanced = array( 
    406       'canreinvite' => 'no', 
    407       'context' => 'from-internal', 
    408       'host' => 'dynamic', 
    409       'type' => 'friend', 
    410       'nat' => 'never', 
    411       'port' => '5060', 
    412       'qualify' => 'no', 
    413       'callgroup' => '', 
    414       'pickupgroup' => '', 
    415       'disallow' => '', 
    416       'allow' => '', 
    417       'dial' => '', 
    418       'accountcode' => '', 
    419       'mailbox' => '' 
    420     ); 
    421   break; 
    422   case "custom": 
    423     $basic = array( 
    424       'dial' => '', 
    425     ); 
    426     $advanced = array(); 
    427   break; 
    428 } 
    429  
    430 if($extdisplay != '') { 
    431   foreach($basic as $key => $value) { 
    432     echo "<tr><td>"._("{$key}")."</td><td><input type=\"text\" name=\"{$key}\" value=\"{$$key}\"/></td></tr>"; 
    433   } 
    434   foreach($advanced as $key => $value) { 
    435     echo "<tr><td>"._("{$key}")."</td><td><input type=\"text\" name=\"{$key}\" value=\"{$$key}\"/></td></tr>"; 
    436   } 
    437 } else { 
    438   foreach($basic as $key => $value) { 
    439     echo "<tr><td>{$key}</td><td><input type=\"text\" name=\"{$key}\" value=\"{$value}\"/></td></tr>"; 
    440   } 
    441   foreach($advanced as $key => $value) { 
    442     echo "<input type=\"hidden\" name=\"{$key}\" value=\"{$value}\"/>"; 
    443   } 
    444 } 
    445 ?> 
    446  
    447       <tr><td colspan=2> 
    448         <h5><br><br><?php echo _("Voicemail & Directory:")?>&nbsp;&nbsp;&nbsp;&nbsp; 
    449           <select name="vm" onchange="checkVoicemail(addNew);"> 
    450             <option value="enabled" <?php  echo ($vm) ? 'selected' : '' ?>><?php echo _("Enabled");?></option>  
    451             <option value="disabled" <?php  echo (!$vm) ? 'selected' : '' ?>><?php echo _("Disabled");?></option>  
    452           </select> 
    453         <hr></h5> 
    454       </td></tr> 
    455       <tr><td colspan=2> 
    456         <table id="voicemail" <?php  echo ($vm) ? '' : 'style="display:none;"' ?>> 
    457         <tr> 
    458           <td> 
    459             <a href="#" class="info"><?php echo _("voicemail password")?><span><?php echo _("This is the password used to access the voicemail system.<br><br>This password can only contain numbers.<br><br>A user can change the password you enter here after logging into the voicemail system (*98) with a phone.")?><br><br></span></a>:  
    460           </td><td> 
    461             <input size="10" type="text" name="vmpwd" value="<?php echo isset($vmpwd)?$vmpwd:'' ?>"/> 
    462           </td> 
    463         </tr> 
    464         <tr> 
    465           <td><a href="#" class="info"><?php echo _("email address")?><span><?php echo _("The email address that voicemails are sent to.")?></span></a>: </td> 
    466           <td><input type="text" name="email" value="<?php echo htmlspecialchars(isset($email)?$email:''); ?>"/></td> 
    467         </tr> 
    468         <tr> 
    469           <td><a href="#" class="info"><?php echo _("pager email address")?><span><?echo _("Pager/mobile email address that short voicemail notifcations are sent to.")?></span></a>: </td> 
    470           <td><input type="text" name="pager" value="<?php echo htmlspecialchars(isset($pager)?$pager:''); ?>"/></td> 
    471         </tr> 
    472         <tr> 
    473           <td><a href="#" class="info"><?php echo _("email attachment")?><span><?php echo _("Option to attach voicemails to email.")?></span></a>: </td> 
    474           <?php if (isset($vmops_attach) && $vmops_attach == "yes"){?> 
    475           <td><input  type="radio" name="attach" value="attach=yes" checked=checked/> <?php echo _("yes");?> &nbsp;&nbsp;&nbsp;&nbsp;<input  type="radio" name="attach" value="attach=no"/> <?php echo _("no");?></td> 
    476           <?php } else{ ?> 
    477           <td><input  type="radio" name="attach" value="attach=yes" /> <?php echo _("yes");?> &nbsp;&nbsp;&nbsp;&nbsp;<input  type="radio" name="attach" value="attach=no" checked=checked /> <?php echo _("no");?></td> <?php }?> 
    478         </tr> 
    479   
    480         <tr> 
    481           <td><a href="#" class="info"><?php echo _("Play CID")?><span><?php echo _("Read back caller's telephone number prior to playing the incoming message, and just after announcing the date and time the message was left.")?></span></a>: </td> 
    482           <?php if (isset($vmops_saycid) && $vmops_saycid == "yes"){?> 
    483           <td><input  type="radio" name="saycid" value="saycid=yes" checked=checked/> <?php echo _("yes");?> &nbsp;&nbsp;&nbsp;&nbsp;<input  type="radio" name="saycid" value="saycid=no"/> <?php echo _("no");?></td> 
    484           <?php } else{ ?> 
    485           <td><input  type="radio" name="saycid" value="saycid=yes" /> <?php echo _("yes");?> &nbsp;&nbsp;&nbsp;&nbsp;<input  type="radio" name="saycid" value="saycid=no" checked=checked /> <?php echo _("no");?></td> <?php }?> 
    486         </tr> 
    487  
    488         <tr> 
    489           <td><a href="#" class="info"><?php echo _("Play Envelope")?><span><?php echo _("Envelope controls whether or not the voicemail system will play the message envelope (date/time) before playing the voicemail message. This settng does not affect the operation of the envelope option in the advanced voicemail menu.")?></span></a>: </td> 
    490           <?php if (isset($vmops_envelope) && $vmops_envelope == "yes"){?> 
    491           <td><input  type="radio" name="envelope" value="envelope=yes" checked=checked/> <?php echo _("yes");?> &nbsp;&nbsp;&nbsp;&nbsp;<input  type="radio" name="envelope" value="envelope=no"/> <?php echo _("no");?></td> 
    492           <?php } else{ ?> 
    493           <td><input  type="radio" name="envelope" value="envelope=yes" /> <?php echo _("yes");?> &nbsp;&nbsp;&nbsp;&nbsp;<input  type="radio" name="envelope" value="envelope=no" checked=checked /> <?php echo _("no");?></td> <?php }?> 
    494         </tr> 
    495  
    496         <tr> 
    497           <td><a href="#" class="info"><?php echo _("Delete Vmail")?><span><?php echo _("If set to \"yes\" the message will be deleted from the voicemailbox (after having been emailed). Provides functionality that allows a user to receive their voicemail via email alone, rather than having the voicemail able to be retrieved from the Webinterface or the Extension handset.  CAUTION: MUST HAVE attach voicemail to email SET TO YES OTHERWISE YOUR MESSAGES WILL BE LOST FOREVER.")?> 
    498 </span></a>: </td> 
    499           <?php if (isset($vmops_delete) && $vmops_delete == "yes"){?> 
    500           <td><input  type="radio" name="delete" value="delete=yes" checked=checked/> <?php echo _("yes");?> &nbsp;&nbsp;&nbsp;&nbsp;<input  type="radio" name="delete" value="delete=no"/> <?php echo _("no");?></td> 
    501           <?php } else{ ?> 
    502           <td><input  type="radio" name="delete" value="delete=yes" /> <?php echo _("yes");?> &nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="delete" value="delete=no" checked=checked /> <?php echo _("no");?></td> <?php }?> 
    503         </tr> 
    504          
    505         <tr> 
    506           <td><a href="#" class="info"><?php echo _("vm options")?><span><?php echo _("Separate options with pipe ( | )")?><br><br><?php echo _("ie: review=yes|maxmessage=60")?></span></a>: </td> 
    507           <td><input size="20" type="text" name="options" value="<?php  echo htmlspecialchars(isset($options)?$options:''); ?>" /></td> 
    508         </tr> 
    509         <tr> 
    510           <td><?php echo _("vm context:")?> </td> 
    511           <td><input size="20" type="text" name="vmcontext" value="<?php  echo $vmcontext; ?>" /></td> 
    512         </tr> 
    513       </table> 
    514     </td></tr> 
    515      
    516      
    517     <tr> 
    518       <td colspan=2> 
    519         <br><br><h6><input name="Submit" type="submit" value="<?php echo _("Submit")?>"> 
    520       </td> 
    521     </tr> 
    522     </table> 
    523  
    524 <script language="javascript"> 
    525 <!-- 
    526  
    527 var theForm = document.addNew; 
    528 if (theForm.extension.value == "") { 
    529   theForm.extension.focus(); 
    530 } else { 
    531   theForm.description.focus(); 
    532 } 
    533  
    534 function addNew_onsubmit() { 
    535   var msgInvalidExtNum = "<?php echo _('Please enter a valid extension number.'); ?>"; 
    536   var msgInvalidDevDesc = "<?php echo _('Please enter a valid Description for this device'); ?>"; 
    537   var msgInvalidOutboundCID = "<?php echo _('Please enter a valid Outbound CID'); ?>"; 
    538   var msgInvalidEmergCID = "<?php echo _('Please enter a valid Emergency CID'); ?>"; 
    539   var msgInvalidDTMFMODE = "<?php echo _('Please enter the dtmfmode for this device'); ?>"; 
    540   var msgInvalidChannel = "<?php echo _('Please enter the channel for this device'); ?>"; 
    541   var msgInvalidVmPwd = "<?php echo _('Please enter a valid Voicemail Password, using digits only'); ?>"; 
    542   var msgInvalidEmail = "<?php echo _('Please enter a valid Email Address'); ?>"; 
    543   var msgInvalidPager = "<?php echo _('Please enter a valid Pager Email Address'); ?>"; 
    544   var msgInvalidVMContext = "<?php echo _('VM Context cannot be blank'); ?>"; 
    545   var msgConfirmSecret = "<?php echo _('You have not entered a Secret for this device, although this is possible it is generally bad practice to not assign a Secret to a device.\n\nAre you sure you want to leave the Secret empty?'); ?>"; 
    546  
    547   defaultEmptyOK = false; 
    548   if (!isInteger(theForm.extension.value)) 
    549     return warnInvalid(theForm.extension, msgInvalidExtNum); 
    550  
    551   if (!isCallerID(theForm.description.value)) 
    552     return warnInvalid(theForm.description, msgInvalidDevDesc); 
    553  
    554   defaultEmptyOK = true; 
    555   if (!isCallerID(theForm.outboundcid.value)) 
    556     return warnInvalid(theForm.outboundcid, msgInvalidOutboundCID); 
    557  
    558   if (!isCallerID(theForm.emergency_cid.value)) 
    559     return warnInvalid(theForm.emergency_cid, msgInvalidEmergCID); 
    560  
    561   defaultEmptyOK = false; 
    562   if (theForm.dtmfmode != undefined && isEmpty(theForm.dtmfmode.value)) 
    563     return warnInvalid(theForm.dtmfmode, msgInvalidDTMFMODE); 
    564  
    565   if (theForm.channel != undefined && isEmpty(theForm.channel.value)) 
    566     return warnInvalid(theForm.channel, msgInvalidChannel); 
    567  
    568   // voicemail stuff 
    569   if (theForm.vm.value == "enabled") { 
    570     defaultEmptyOK = false; 
    571     if (!isInteger(theForm.vmpwd.value)) 
    572       return warnInvalid(theForm.vmpwd, msgInvalidVmPwd); 
    573      
    574     defaultEmptyOK = true; 
    575     if (!isEmail(theForm.email.value)) 
    576       return warnInvalid(theForm.email, msgInvalidEmail); 
    577        
    578     if (!isEmail(theForm.pager.value)) 
    579       return warnInvalid(theForm.pager, msgInvalidPager); 
    580        
    581     defaultEmptyOK = false; 
    582     if (isEmpty(theForm.vmcontext.value) || isWhitespace(theForm.vmcontext.value)) 
    583       return warnInvalid(theForm.vmcontext, msgInvalidVMContext); 
    584      
    585   } 
    586  
    587   if (theForm.secret != undefined && isEmpty(theForm.secret.value)) { 
    588     var cnf = confirm(msgConfirmSecret); 
    589     if (!cnf) { 
    590       theForm.secret.focus(); 
    591       return false; 
    592     } 
    593   } 
    594  
    595   return true; 
    596 } 
    597  
    598 function checkVoicemail(theForm) { 
    599   $vm = theForm.elements["vm"].value; 
    600   if ($vm == 'disabled') { 
    601     document.getElementById('voicemail').style.display='none'; 
    602     theForm.vmpwd.value = ''; 
    603     theForm.email.value = ''; 
    604     theForm.pager.value = ''; 
    605   } else { 
    606     document.getElementById('voicemail').style.display='block'; 
    607   } 
    608 } 
    609  
    610 //--> 
    611 </script> 
    612  
    613     </form> 
    614 <?php      
    615   } //end if action == delGRP 
    616    
    617  
    618 ?> 
    619  
    620