Changeset 7112

Show
Ignore:
Timestamp:
10/23/08 16:05:58 (3 years ago)
Author:
sasargen
Message:

update bulkextensions for freepbx 2.5

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • contributed_modules/modules/bulkextensions/functions.inc.php

    r6285 r7112  
    11<?php 
    2 /* $Id:$ */ 
    3  
    4 function exportextensions_allusers() 
    5 
    6  
     2/* functions.inc.php - functions for BulkExtensions module. */ 
     3include("modules/voicemail/functions.inc.php");   // for using voicemail module functions to retrieve voicemail settings 
     4include("modules/dictate/functions.inc.php");   // for using dictation services functions to retrieve dictation settings 
     5include("modules/languages/functions.inc.php");   // for using languages functions to retrieve language setting 
     6include("modules/findmefollow/functions.inc.php");  // for using findmefollow functions to retreive follow me settings 
     7 
     8/* Verify existence of voicemail, dictate, languages and findmefollow functions. */ 
     9if (function_exists("voicemail_mailbox_get") && function_exists("voicemail_mailbox_add") && function_exists("voicemail_mailbox_del") && function_exists("voicemail_mailbox_remove") && class_exists("vmxObject")) { 
     10  $vm_exists  = TRUE; 
     11} else { 
     12  $vm_exists  = FALSE; 
     13
     14if (function_exists("dictate_get") && function_exists("dictate_update") && function_exists("dictate_del")) { 
     15  $dict_exists  = TRUE; 
     16} else { 
     17  $dict_exists  = FALSE; 
     18
     19if (function_exists("languages_user_get") && function_exists("languages_user_update") && function_exists("languages_user_del")) { 
     20  $lang_exists  = TRUE; 
     21} else { 
     22  $lang_exists  = FALSE; 
     23
     24if (function_exists("findmefollow_get") && function_exists("findmefollow_add") && function_exists("findmefollow_del")) { 
     25  $findme_exists  = TRUE; 
     26} else { 
     27  $findme_exists  = FALSE; 
     28
     29 
     30function exportextensions_allusers() { 
    731  global $db; 
    8   $action = "edit"; 
    9   $fname = "bulkext__" .  (string) time() . ".csv"; 
    10   $csv_header = "action,extension,name,cid_masquerade,sipname,directdid,didalert,mohclass,outboundcid,ringtimer,callwaiting,emergency_cid,tech,hardware,devinfo_secret,devinfo_channel,devinfo_dtmfmode,devinfo_canreinvite,devinfo_context,devinfo_host,devinfo_type,devinfo_nat,devinfo_port,devinfo_qualify,devinfo_callgroup,devinfo_pickupgroup,devinfo_disallow,devinfo_allow,devinfo_dial,devinfo_accountcode,devinfo_mailbox,faxexten,faxemail,answer,wait,privacyman,record_in,record_out,vm,vmpwd,email,pager,attach,saycid,envelope,delete,options,vmcontext,vmx_state,devicetype,password,noanswer,devinfo_immediate,devinfo_signalling,devinfo_echocancel,devinfo_echocancelwhenbridged,devinfo_echotraining,devinfo_busydetect,devinfo_busycount,devinfo_callprogress,devinfo_notransfer\n"; 
    11   $data = $csv_header; 
    12   $exts = get_all_exts(); 
    13  
    14   foreach($exts as $ext) 
    15   { 
    16     $e = $ext[0]; 
     32  global $vm_exists; 
     33  global $dict_exists; 
     34  global $lang_exists; 
     35  global $findme_exists; 
     36  $action   = "edit"; 
     37  $fname    = "bulkext__" .  (string) time() . $_SERVER["SERVER_NAME"] . ".csv"; 
     38  $csv_header   = "action,extension,name,cid_masquerade,sipname,outboundcid,ringtimer,callwaiting,call_screen,password,emergency_cid,tech,hardware,devinfo_channel,devinfo_secret,devinfo_notransfer,devinfo_dtmfmode,devinfo_canreinvite,devinfo_context,devinfo_immediate,devinfo_signalling,devinfo_echocancel,devinfo_echocancelwhenbrdiged,devinfo_echotraining,devinfo_busydetect,devinfo_busycount,devinfo_callprogress,devinfo_host,devinfo_type,devinfo_nat,devinfo_port,devinfo_qualify,devinfo_callgroup,devinfo_pickupgroup,devinfo_disallow,devinfo_allow,devinfo_dial,devinfo_accoountcode,devinfo_mailbox,devicetype,deviceid,deviceuser,description,dictenabled,dictformat,dictemail,langcode,record_in,record_out,vm,vmpwd,email,pager,attach,saycid,envelope,delete,options,vmcontext,vmx_state,vmx_unavail_enabled,vmx_busy_enabled,vmx_play_instructions,vmx_option_0_sytem_default,vmx_option_0_number,vmx_option_1_system_default,vmx_option_1_number,vmx_option_2_number,account,ddial,pre_ring,strategy,grptime,grplist,annmsg_id,ringing,grppre,dring,needsconf,remotealert_id,toolate_id,postdest\n"; 
     39  $data     = $csv_header; 
     40  $exts     = get_all_exts(); 
     41 
     42  foreach ($exts as $ext) { 
     43    $e  = $ext[0]; 
    1744    $u_info = core_users_get($e); 
    1845    $d_info = core_devices_get($e); 
    19     $voicemail = get_voicemail_info($e);  
    20     if($voicemail == null) 
    21     { 
    22       $v_enabled = "disabled"; 
    23       $v_context = ''; 
    24       $v_pwd = ''; 
    25       $v_email = ''; 
    26       $v_pager = ''; 
    27       $v_options = ''; 
    28       $v_attach = ''; 
    29       $v_saycid = ''; 
    30       $v_envelope = ''; 
    31       $v_delete = ''; 
    32     } 
    33     else 
    34     { 
    35       $v_enabled = "enabled"; 
    36       $v_context = isset($voicemail['vmcontext'])?$voicemail['vmcontext']:''; 
    37       $v_pwd = isset($voicemail['pwd'])?$voicemail['pwd']:''; 
    38       $v_email = isset($voicemail['email'])?$voicemail['email']:''; 
    39       $v_pager = isset($voicemail['pager'])?$voicemail['pager']:''; 
    40  
    41       $x = isset($voicemail['options'])?$voicemail['options']:''; 
    42       $p = 0; 
    43       $first = true; 
    44       $c = count($x); 
    45       reset($x); 
    46  
    47       while($p < $c) 
    48       { 
    49         if((key($x) != 'attach') && (key($x) != 'saycid') && (key($x) != 'envelope') && (key($x) != 'delete')) 
    50         { 
    51           if($first) 
    52           { 
    53             $vmopts_output = key($x) . "=" . $x[key($x)]; 
    54             $first = false; 
    55           } else 
    56           { 
    57             $vmopts_output = $vmopts_output . "|" . key($x) . "=" . $x[key($x)]; 
     46    if ($vm_exists) { 
     47      $v_info = voicemail_mailbox_get($e); 
     48    } else { 
     49      $v_info = NULL; 
     50    } 
     51    /* To properly obtain voicemail information, detect enabled/disabled vm value.   */ 
     52    /* Parse extra voicemail options.            */ 
     53    if ($v_info == NULL) { 
     54      $v_enabled  = "disabled"; 
     55    } else { 
     56      $v_enabled  = "enabled"; 
     57      $v_options  = isset($v_info["options"])?$v_info["options"]:""; 
     58      $vm_other_opts  = ""; 
     59      $i    = 0; 
     60      $first    = TRUE; 
     61      $c    = count($v_options); 
     62      reset($v_options); 
     63      while ($i < $c) { 
     64        if ((key($v_options) != "attach") && (key($v_options) != "saycid") && (key($v_options) != "envelope") && (key($v_options) != "delete")) { 
     65          if ($first) { 
     66            $vm_other_opts  = key($v_options) . "=" . $v_options[key($v_options)]; 
     67            $first    = false; 
     68          } else { 
     69            $vm_other_opts .=  "|" . key($v_options) . "=" . $v_options[key($v_options)]; 
    5870          } 
    5971        } 
    60         $p++; 
    61         next($x); 
    62       } 
    63       $v_options = isset($vmopts_output)?$vmopts_output:''; 
    64       $vmopts_output = "";       
    65       $v_attach = "attach=" . isset($x['attach'])?$x['attach']:'no';  
    66       $v_saycid = "saycid=" . isset($x['saycid'])?$x['saycid']:'no'; 
    67       $v_envelope = "envelope=" . isset($x['envelope'])?$x['envelope']:'no'; 
    68       $v_delete = "delete=" . isset($x['delete'])?$x['delete']:'no'; 
    69  
    70     } 
    71  
     72        $i++; 
     73        next($v_options); 
     74      } 
     75    } 
     76    /* Obtain vmx settings. */ 
     77    if ($vm_exists) { 
     78      $vmxobj   = new vmxObject($e); 
     79    } else { 
     80      $vmxobj   = NULL; 
     81    } 
     82     
     83    if (is_object($vmxobj)) { 
     84      $vmx_state    = ($vmxobj->isEnabled())?"checked":""; 
     85      $vmx_unavail_enabled  = ($vmxobj->getState("unavail")=="enabled")?"checked":""; 
     86      $vmx_busy_enabled   = ($vmxobj->getState("busy")=="enabled")?"checked":""; 
     87      $vmx_play_instructions  = ($vmxobj->getVmPlay())?"checked":""; 
     88      $vmx_option_0_number  = $vmxobj->getMenuOpt(0); 
     89      if ($vmx_option_0_number == "") { 
     90        $vmx_option_0_system_default = "checked"; 
     91      } else { 
     92        $vmx_option_0_system_default = ""; 
     93      } 
     94      if (is_object($vmxobj)) { 
     95        if ($vmxobj->hasFollowMe() && $vmxobj->isFollowMe()) { 
     96          $vmx_option_1_system_default  = "checked"; 
     97          $vmx_option_1_number    = ""; 
     98        } else { 
     99          $vmx_option_1_system_default  = ""; 
     100          $vmx_option_1_number    = $vmxobj->getMenuOpt(1); 
     101        } 
     102        $vmx_option_2_number      = $vmxobj->getMenuOpt(2); 
     103      } 
     104    } 
     105       
     106    /* Obtain dictation services settings. */ 
     107    if ($dict_exists) { 
     108      $dictate_settings = dictate_get($e); 
     109    } 
     110 
     111    /* Obtain language code. */ 
     112    if ($lang_exists) { 
     113      $langcode = languages_user_get($e); 
     114    } 
     115 
     116    /* Obtain follow me settings. */ 
     117    if ($findme_exists) { 
     118      $followme_settings = findmefollow_get($u_info["extension"], TRUE); 
     119    } 
     120    if (isset($followme_settings)) { 
     121      $account  = isset($followme_settings["grpnum"])?$followme_settings["grpnum"]:""; 
     122      $strategy = isset($followme_settings["strategy"])?$followme_settings["strategy"]:""; 
     123      $grptime  = isset($followme_settings["grptime"])?$followme_settings["grptime"]:""; 
     124      $grppre   = isset($followme_settings["grppre"])?$followme_settings["grppre"]:""; 
     125      $grplist  = isset($followme_settings["grplist"])?$followme_settings["grplist"]:""; 
     126      $annmsg_id  = isset($followme_settings["annmsg_id"])?$followme_settings["annmsg_id"]:""; 
     127      $postdest = isset($followme_settings["postdest"])?$followme_settings["postdest"]:""; 
     128      $dring    = isset($followme_settings["dring"])?$followme_settings["dring"]:""; 
     129      $needsconf  = isset($followme_settings["needsconf"])?$followme_settings["needsconf"]:""; 
     130      $remotealert_id = isset($followme_settings["remotealert_id"])?$followme_settings["remotealert_id"]:""; 
     131      $toolate_id   = isset($followme_settings["toolate_id"])?$followme_settings["toolate_id"]:""; 
     132      $ringing  = isset($followme_settings["ringing"])?$followme_settings["ringing"]:""; 
     133      $pre_ring   = isset($followme_settings["pre_ring"])?$followme_settings["pre_ring"]:""; 
     134      $ddial    = isset($followme_settings["ddial"])?$followme_settings["ddial"]:""; 
     135    } 
    72136    $csv_line[0]  = $action; 
    73     $csv_line[1]  = isset($u_info['extension'])?$u_info['extension']:''; 
    74     $csv_line[2]  = isset($u_info['name'])?$u_info['name']:''; 
    75     $csv_line[3]  = isset($u_info['cidnum'])?$u_info['cidnum']:''; 
    76     $csv_line[4]  = isset($u_info['sipname'])?$u_info['sipname']:''; 
    77     $csv_line[5]  = isset($u_info['directdid'])?$u_info['directdid']:''; 
    78     $csv_line[6]  = isset($u_info['didalert'])?$u_info['didalert']:''; 
    79     $csv_line[7]  = isset($u_info['mohclass'])?$u_info['mohclass']:''; 
    80     $csv_line[8]  = isset($u_info['outboundcid'])?$u_info['outboundcid']:''; 
    81     $csv_line[9]  = isset($u_info['ringtimer'])?$u_info['ringtimer']:''; 
    82     $csv_line[10] = isset($u_info['callwaiting'])?$u_info['callwaiting']:''; 
    83     $csv_line[11] = isset($d_info['emergency_cid'])?$d_info['emergency_cid']:''; 
    84     $csv_line[12] = isset($d_info['tech'])?$d_info['tech']:''; 
    85     $csv_line[13] = ''; //hardware 
    86     $csv_line[14] = isset($d_info['secret'])?$d_info['secret']:''; 
    87     $csv_line[15] = isset($d_info['channel'])?$d_info['channel']:'';    
    88     $csv_line[16] = isset($d_info['dtmfmode'])?$d_info['dtmfmode']:''; 
    89     $csv_line[17] = isset($d_info['canreinvite'])?$d_info['canreinvite']:''; 
    90     $csv_line[18] = isset($d_info['context'])?$d_info['context']:''; 
    91     $csv_line[19] = isset($d_info['host'])?$d_info['host']:''; 
    92     $csv_line[20] = isset($d_info['type'])?$d_info['type']:''; 
    93     $csv_line[21] = isset($d_info['nat'])?$d_info['nat']:''; 
    94     $csv_line[22] = isset($d_info['port'])?$d_info['port']:''; 
    95     $csv_line[23] = isset($d_info['qualify'])?$d_info['qualify']:''; 
    96     $csv_line[24] = isset($d_info['callgroup'])?$d_info['callgroup']:''; 
    97     $csv_line[25] = isset($d_info['pickupgroup'])?$d_info['pickupgroup']:''; 
    98     $csv_line[26] = isset($d_info['disallow'])?$d_info['disallow']:''; 
    99     $csv_line[27] = isset($d_info['allow'])?$d_info['allow']:''; 
    100     $csv_line[28] = isset($d_info['accountcode'])?$d_info['accountcode']:''; 
    101     $csv_line[28] = isset($d_info['dial'])?$d_info['dial']:''; 
    102     $csv_line[29]   = isset($d_info['accountcode'])?$d_info['accountcode']:''; 
    103     $csv_line[30] = isset($d_info['mailbox'])?$d_info['mailbox']:''; 
    104     $csv_line[31] = isset($u_info['faxexten'])?$u_info['faxexten']:''; 
    105     $csv_line[32] = isset($u_info['faxemail'])?$u_info['faxemail']:''; 
    106     $csv_line[33] = isset($u_info['answer'])?$u_info['answer']:''; 
    107     $csv_line[34] = isset($u_info['wait'])?$u_info['wait']:''; 
    108     $csv_line[35] = isset($u_info['privacyman'])?$u_info['privacyman']:''; 
    109     $csv_line[36] = isset($d_info['record_in'])?$d_info['record_in']:''; 
    110     $csv_line[37] = isset($d_info['record_out'])?$d_info['record_out']:''; 
    111     $csv_line[38] = $v_enabled; 
    112     $csv_line[39] = $v_pwd; 
    113     $csv_line[40] = $v_email; 
    114     $csv_line[41] = $v_pager; 
    115     $csv_line[42] = $v_attach; 
    116     $csv_line[43] = $v_saycid; 
    117     $csv_line[44] = $v_envelope; 
    118     $csv_line[45] = $v_delete; 
    119     $csv_line[46] = $v_options; 
    120     $csv_line[47] = $v_context; 
    121     $csv_line[48] = isset($u_info['vmx_state'])?$u_info['vmx_state']:''; 
    122     $csv_line[49] = isset($d_info['devicetype'])?$d_info['devicetype']:''; 
    123     $csv_line[50] = isset($u_info['password'])?$u_info['password']:''; 
    124     $csv_line[51] = isset($u_info['noanswer'])?$u_info['noanswer']:''; 
    125     $csv_line[52] = isset($d_info['immediate'])?$d_info['immediate']:''; 
    126     $csv_line[53] = isset($d_info['signalling'])?$d_info['signalling']:''; 
    127     $csv_line[54] = isset($d_info['echocancel'])?$d_info['echocancel']:''; 
    128     $csv_line[55] = isset($d_info['echocancelwhenbridged'])?$d_info['echocancelwhenbridged']:''; 
    129     $csv_line[56] = isset($d_info['echotraining'])?$d_info['echotraining']:''; 
    130     $csv_line[57] = isset($d_info['busydetect'])?$d_info['busydetect']:''; 
    131     $csv_line[58] = isset($d_info['busycount'])?$d_info['busycount']:''; 
    132     $csv_line[59] = isset($d_info['callprogress'])?$d_info['callprogress']:''; 
    133     $csv_line[60] = isset($d_info['notransfer'])?$d_info['notransfer']:''; 
    134  
    135     for($i = 0; $i < count($csv_line); $i++) 
    136     { 
    137       if($i != count($csv_line) - 1) 
    138       { 
     137    $csv_line[1]  = isset($u_info["extension"])?$u_info["extension"]:""; 
     138    $csv_line[2]  = isset($u_info["name"])?$u_info["name"]:""; 
     139    $csv_line[3]  = isset($u_info["cid_masquerade"])?$u_info["cid_masquerade"]:""; 
     140    $csv_line[4]  = isset($u_info["sipname"])?$u_info["sipname"]:""; 
     141    $csv_line[5]  = isset($u_info["outboundcid"])?$u_info["outboundcid"]:""; 
     142    $csv_line[6]  = isset($u_info["ringtimer"])?$u_info["ringtimer"]:""; 
     143    $csv_line[7]  = isset($u_info["callwaiting"])?$u_info["callwaiting"]:""; 
     144    $csv_line[8]  = isset($u_info["call_screen"])?$u_info["call_screen"]:"0"; 
     145    $csv_line[9]  = isset($u_info["password"])?$u_info["password"]:""; 
     146 
     147    $csv_line[10] = isset($d_info["emergency_cid"])?$d_info["emergency_cid"]:""; 
     148    $csv_line[11] = isset($d_info["tech"])?$d_info["tech"]:""; 
     149    $csv_line[12] = "";   // hardware 
     150    $csv_line[13] = isset($d_info["channel"])?$d_info["channel"]:""; 
     151    $csv_line[14] = isset($d_info["secret"])?$d_info["secret"]:""; 
     152    $csv_line[15] = isset($d_info["notransfer"])?$d_info["notransfer"]:""; 
     153    $csv_line[16] = isset($d_info["dtmfmode"])?$d_info["dtmfmode"]:""; 
     154    $csv_line[17] = isset($d_info["canreinvite"])?$d_info["canreinvite"]:""; 
     155    $csv_line[18] = isset($d_info["context"])?$d_info["context"]:""; 
     156    $csv_line[19] = isset($d_info["immediate"])?$d_info["immediate"]:""; 
     157    $csv_line[20] = isset($d_info["signalling"])?$d_info["signalling"]:""; 
     158    $csv_line[21] = isset($d_info["echocancel"])?$d_info["echocancel"]:""; 
     159    $csv_line[22] = isset($d_info["echocancelwhenbridged"])?$d_info["echocancelwhenbridged"]:""; 
     160    $csv_line[23] = isset($d_info["echotraining"])?$d_info["echotraining"]:""; 
     161    $csv_line[24] = isset($d_info["busydetect"])?$d_info["busydetect"]:""; 
     162    $csv_line[25] = isset($d_info["busycount"])?$d_info["busycount"]:""; 
     163    $csv_line[26] = isset($d_info["callprogress"])?$d_info["callprogress"]:""; 
     164    $csv_line[27] = isset($d_info["host"])?$d_info["host"]:""; 
     165    $csv_line[28] = isset($d_info["type"])?$d_info["type"]:""; 
     166    $csv_line[29] = isset($d_info["nat"])?$d_info["nat"]:""; 
     167    $csv_line[30] = isset($d_info["port"])?$d_info["port"]:""; 
     168    $csv_line[31] = isset($d_info["qualify"])?$d_info["qualify"]:""; 
     169    $csv_line[32] = isset($d_info["callgroup"])?$d_info["callgroup"]:""; 
     170    $csv_line[33] = isset($d_info["pickupgroup"])?$d_info["pickupgroup"]:""; 
     171    $csv_line[34] = isset($d_info["disallow"])?$d_info["disallow"]:""; 
     172    $csv_line[35] = isset($d_info["allow"])?$d_info["allow"]:""; 
     173    $csv_line[36] = isset($d_info["dial"])?$d_info["dial"]:""; 
     174    $csv_line[37] = isset($d_info["accountcode"])?$d_info["accountcode"]:""; 
     175    $csv_line[38] = isset($d_info["mailbox"])?$d_info["mailbox"]:""; 
     176    $csv_line[39] = isset($d_info["devicetype"])?$d_info["devicetype"]:"fixed"; 
     177    $csv_line[40] = (isset($d_info["deviceid"]) || ($d_info["deviceid"]==""))?$d_info["deviceid"]:(isset($u_info["extension"])?$u_info["extension"]:""); 
     178    $csv_line[41] = (isset($d_info["deviceuser"]) && ($d_info["deviceuser"] != ""))?$d_info["deviceuser"]:(isset($u_info["extension"])?$u_info["extension"]:"none"); 
     179    $csv_line[42] = isset($d_info["description"])?$d_info["description"]:(isset($u_info["name"])?$u_info["name"]:""); 
     180 
     181    $csv_line[43] = isset($dictate_settings["enabled"])?$dictate_settings["enabled"]:"disabled";  // dictenabled 
     182    $csv_line[44] = isset($dictate_settings["format"])?$dictate_settings["format"]:"ogg";   // dictformat (ogg is default) 
     183    $csv_line[45] = isset($dictate_settings["email"])?$dictate_settings["email"]:"";    // dictemail 
     184 
     185    $csv_line[46] = isset($langcode)?$langcode:""; 
     186 
     187    $csv_line[47] = isset($d_info["record_in"])?$d_info["record_in"]:""; 
     188    $csv_line[48] = isset($d_info["record_out"])?$d_info["record_out"]:""; 
     189 
     190    $csv_line[49] = $v_enabled; // vm 
     191    $csv_line[50] = isset($v_info["pwd"])?$v_info["pwd"]:""; 
     192    $csv_line[51] = isset($v_info["email"])?$v_info["email"]:""; 
     193    $csv_line[52] = isset($v_info["pager"])?$v_info["pager"]:""; 
     194    $csv_line[53] = isset($v_info["options"]["attach"])?("attach=" . $v_info["options"]["attach"]):"attach=no"; 
     195    $csv_line[54] = isset($v_info["options"]["saycid"])?("saycid=" . $v_info["options"]["saycid"]):"saycid=no"; 
     196    $csv_line[55] = isset($v_info["options"]["envelope"])?("envelope=" . $v_info["options"]["envelope"]):"envelope=no"; 
     197    $csv_line[56] = isset($v_info["options"]["delete"])?("delete=". $v_info["options"]["delete"]):"delete=no"; 
     198    $csv_line[57] = isset($vm_other_opts)?$vm_other_opts:""; // additional options 
     199    $csv_line[58] = isset($v_info["vmcontext"])?$v_info["vmcontext"]:""; 
     200    $csv_line[59] = isset($vmx_state)?$vmx_state:""; 
     201    $csv_line[60] = isset($vmx_unavail_enabled)?$vmx_unavail_enabled:""; 
     202    $csv_line[61] = isset($vmx_busy_enabled)?$vmx_busy_enabled:""; 
     203    $csv_line[62] = isset($vmx_play_instructions)?$vmx_play_instructions:""; 
     204    $csv_line[63] = isset($vmx_option_0_system_default)?$vmx_option_0_system_default:""; 
     205    $csv_line[64] = isset($vmx_option_0_number)?$vmx_option_0_number:""; 
     206    $csv_line[65] = isset($vmx_option_1_system_default)?$vmx_option_1_system_default:""; 
     207    $csv_line[66] = isset($vmx_option_1_number)?$vmx_option_1_number:""; 
     208    $csv_line[67] = isset($vmx_option_2_number)?$vmx_option_2_number:""; 
     209    $csv_line[68] = isset($account)?$account:""; 
     210    $csv_line[69] = isset($ddial)?$ddial:""; 
     211    $csv_line[70] = isset($pre_ring)?$pre_ring:""; 
     212    $csv_line[71] = isset($strategy)?$strategy:""; 
     213    $csv_line[72] = isset($grptime)?$grptime:""; 
     214    $csv_line[73] = isset($grplist)?$grplist:""; 
     215    $csv_line[74] = isset($annmsg_id)?$annmsg_id:""; 
     216    $csv_line[75] = isset($ringing)?$ringing:""; 
     217    $csv_line[76] = isset($grppre)?$grppre:""; 
     218    $csv_line[77] = isset($dring)?$dring:""; 
     219    $csv_line[78] = isset($needsconf)?$needsconf:""; 
     220    $csv_line[79] = isset($remotealert_id)?$remotealert_id:""; 
     221    $csv_line[80] = isset($toolate_id)?$toolate_id:""; 
     222    $csv_line[81] = isset($postdest)?$postdest:""; 
     223    for ($i = 0; $i < count($csv_line); $i++) { 
     224      /* If the string contains a comma, enclose it in double-quotes. */ 
     225      if (strpos($csv_line[$i], ",") !== FALSE) { 
     226        $csv_line[$i] = "\"" . $csv_line[$i] . "\""; 
     227      } 
     228      if ($i != count($csv_line) - 1) { 
    139229        $data = $data . $csv_line[$i] . ","; 
    140       } else 
    141       { 
     230      } else { 
    142231        $data = $data . $csv_line[$i]; 
    143232      } 
    144          
    145233    } 
    146234    $data = $data . "\n"; 
    147  
    148235    unset($csv_line); 
    149  
    150236  } 
    151  
    152237  force_download($data, $fname); 
    153238  return; 
    154239} 
    155240 
    156 function get_all_exts() 
    157 
    158   $sql = "SELECT extension FROM users ORDER BY extension"; 
    159    
     241function get_all_exts() { 
     242  $sql  = "SELECT extension FROM users ORDER BY extension"; 
    160243  $extens = sql($sql,"getAll"); 
    161  
    162   if (isset($extens)) 
    163   { 
     244  if (isset($extens)) { 
    164245    return $extens; 
    165   } else 
    166   { 
     246  } else { 
    167247    return null; 
    168248  } 
    169249} 
    170250 
    171 function get_voicemail_info($mbox) 
    172 
    173   global $amp_conf; 
    174    
    175   $vmconf = null; 
    176   $section = null; 
    177   my_parse_voicemailconf(rtrim($amp_conf["ASTETCDIR"],"/")."/voicemail.conf", $vmconf, $section); 
    178   if($vmconf == null) echo("Uh-oh"); 
    179   //my_parse_voicemailconf("/etc/asterisk/voicemail.conf", $vmconf, $section); 
    180   //$uservm = voicemail_getVoicemail(); 
    181         $vmcontexts = array_keys($vmconf); 
    182          
    183         foreach ($vmcontexts as $vmcontext) { 
    184     //echo("$vmcontext<br/>"); 
    185     //echo("$mbox<br/>"); 
    186                 if(isset($vmconf[$vmcontext][$mbox])){ 
    187                         $vmbox['vmcontext'] = $vmcontext;                                                                                 
    188                         $vmbox['pwd'] =   $vmconf[$vmcontext][$mbox]['pwd']; 
    189                         $vmbox['name'] =  $vmconf[$vmcontext][$mbox]['name']; 
    190                         $vmbox['email'] = $vmconf[$vmcontext][$mbox]['email']; 
    191                         $vmbox['pager'] = $vmconf[$vmcontext][$mbox]['pager']; 
    192                         $vmbox['options'] = $vmconf[$vmcontext][$mbox]['options']; 
    193                         return $vmbox; 
    194                 } 
    195         } 
    196                                                                              
    197         return null; 
    198  
    199  
    200 
    201  
    202  
    203 /** Recursively read voicemail.conf (and any included files)                     
    204  * This function is called by get_voicemail_info() 
    205  */ 
    206 function my_parse_voicemailconf($filename, &$vmconf, &$section) { 
    207         if (is_null($vmconf)) { 
    208                 $vmconf = array(); 
    209         } 
    210         if (is_null($section)) { 
    211                 $section = "general"; 
    212         } 
    213  
    214         if (file_exists($filename)) {                                       
    215                 $fd = fopen($filename, "r");                        
    216                 while ($line = fgets($fd, 1024)) { 
    217                         if (preg_match("/^\s*(\d+)\s*=>\s*(\d*),(.*),(.*),(.*),(.*)\s*([;#].*)?/",$line,$matches)) { 
    218                                 // "mailbox=>password,name,email,pager,options" 
    219                                 // this is a voicemail line 
    220                                 $vmconf[$section][ $matches[1] ] = array("mailbox"=>$matches[1], 
    221                                                                         "pwd"=>$matches[2], 
    222                                                                         "name"=>$matches[3], 
    223                                                                         "email"=>$matches[4], 
    224                                                                         "pager"=>$matches[5], 
    225                                                                         "options"=>array(), 
    226                                                                         ); 
    227  
    228                                 // parse options 
    229                                                                             
    230                                 foreach (explode("|",$matches[6]) as $opt) { 
    231                                         $temp = explode("=",$opt); 
    232                                         //output($temp); 
    233                                         if (isset($temp[1])) { 
    234                                                 list($key,$value) = $temp; 
    235                                                 $vmconf[$section][ $matches[1] ]["options"][$key] = $value; 
    236                                         } 
    237                                 } 
    238                    } else if (preg_match("/^\s*(\d+)\s*=>\s*dup,(.*)\s*([;#].*)?/",$line,$matches)) { 
    239                                 // "mailbox=>dup,name" 
    240                                 // duplace name line 
    241                                 $vmconf[$section][ $matches[1] ]["dups"][] = $matches[2]; 
    242                         } else if (preg_match("/^\s*#include\s+(.*)\s*([;#].*)?/",$line,$matches)) { 
    243                                 // include another file 
    244  
    245                                 if ($matches[1][0] == "/") { 
    246                                         // absolute path 
    247                                         $filename = $matches[1]; 
    248                                 } else { 
    249                                         // relative path 
    250                                         $filename =  dirname($filename)."/".$matches[1]; 
    251                                 } 
    252  
    253                                 my_parse_voicemailconf($filename, $vmconf, $section); 
    254  
    255                         } else if (preg_match("/^\s*\[(.+)\]/",$line,$matches)) { 
    256                                 // section name 
    257                                 $section = strtolower($matches[1]); 
    258                         } else if (preg_match("/^\s*([a-zA-Z0-9-_]+)\s*=\s*(.*?)\s*([;#].*)?$/",$line,$matches)) { 
    259                                 // name = value 
    260                                 // option line 
    261                                 $vmconf[$section][ $matches[1] ] = $matches[2]; 
    262                         } 
    263                 } 
    264                 fclose($fd);                               
    265         } 
    266 
    267  
    268 function force_download ($data, $name, $mimetype='', $filesize=false) {  
    269     // File size not set?  
    270     if ($filesize == false OR !is_numeric($filesize)) {  
    271         $filesize = strlen($data);  
    272     }  
    273  
    274     // Mimetype not set?  
    275     if (empty($mimetype)) {  
    276         $mimetype = 'application/octet-stream';  
    277     }  
    278  
    279     // Make sure there's not anything else left  
    280     ob_clean_all();  
    281  
    282     // Start sending headers  
    283     header("Pragma: public"); // required  
    284     header("Expires: 0");  
    285     header("Cache-Control: must-revalidate, post-check=0, pre-check=0");  
    286     header("Cache-Control: private",false); // required for certain browsers  
    287     header("Content-Transfer-Encoding: binary");  
    288     header("Content-Type: " . $mimetype);  
    289     header("Content-Length: " . $filesize);  
    290     header("Content-Disposition: attachment; filename=\"" . $name . "\";" );  
    291  
    292     // Send data  
    293     echo $data;  
    294     die();  
    295 }  
    296  
    297 function ob_clean_all () {  
    298     $ob_active = ob_get_length () !== false;  
    299     while($ob_active) {  
    300         ob_end_clean();  
    301         $ob_active = ob_get_length () !== false;  
    302     }  
    303  
    304     return true;  
    305 
    306  
     251function force_download ($data, $name, $mimetype="", $filesize=false) { 
     252    // File size not set? 
     253    if ($filesize == false OR !is_numeric($filesize)) { 
     254        $filesize = strlen($data); 
     255    } 
     256    // Mimetype not set? 
     257    if (empty($mimetype)) { 
     258        $mimetype = "application/octet-stream"; 
     259    } 
     260    // Make sure there's not anything else left 
     261    ob_clean_all(); 
     262    // Start sending headers 
     263    header("Pragma: public"); // required 
     264    header("Expires: 0"); 
     265    header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
     266    header("Cache-Control: private",false); // required for certain browsers 
     267    header("Content-Transfer-Encoding: binary"); 
     268    header("Content-Type: " . $mimetype); 
     269    header("Content-Length: " . $filesize); 
     270    header("Content-Disposition: attachment; filename=\"" . $name . "\";" ); 
     271    // Send data 
     272    echo $data; 
     273    die(); 
     274
     275 
     276function ob_clean_all () { 
     277    $ob_active = ob_get_length () !== false; 
     278    while($ob_active) { 
     279        ob_end_clean(); 
     280        $ob_active = ob_get_length () !== false; 
     281    } 
     282    return true; 
     283
     284 
     285function generate_table_rows() { 
     286  $fh = fopen("modules/bulkextensions/table.csv", "r"); 
     287  if ($fh == NULL) { 
     288    return NULL; 
     289  } 
     290  $k = 0; 
     291  while (($csv_data = fgetcsv($fh, 1000, ",", "\"")) !== FALSE) { 
     292    $k++; 
     293    /* Name,Default,Allowed,On Extensions page,Details */ 
     294    for ($i = 0; $i < 5; $i++) { 
     295      if (isset($csv_data[$i])) { 
     296        $table[$k][$i] .= $csv_data[$i]; 
     297      } else { 
     298        $table[$k][$i] = ""; 
     299      } 
     300    } 
     301  } 
     302  fclose($fh); 
     303  return $table; 
     304
    307305?> 
  • contributed_modules/modules/bulkextensions/module.xml

    r6286 r7112  
    22  <rawname>bulkextensions</rawname> 
    33  <name>Bulk Extensions</name> 
    4   <version>0.2.1</version> 
     4  <description>Bulk Extensions uses CSV files to import and export of extensions.</description> 
     5  <version>2.5.0</version> 
    56  <type>tool</type> 
    67  <category>Third Party Addon</category> 
     
    89    <bulkextensions>Bulk Extensions</bulkextensions> 
    910  </menuitems> 
     11  <depends> 
     12    <version>ge2.5</version> 
     13  </depends> 
    1014  <location></location> 
    1115  <info></info> 
    1216  <changelog> 
    13     *0.2.1* Fix for Export error: Cannot modify header information 
     17    *2.5.0* Version for FreePBX 2.5 
     18    *0.2.1* Beta support for FreePBX 2.5 (unreleased) 
    1419    *0.2.0* New feature - Export Extensions Documented all supported Extension fields Minor code clean ups 
    1520    *0.1.1* Fixed bad path and error in tar file 
  • contributed_modules/modules/bulkextensions/page.bulkextensions.php

    r6006 r7112  
    55// 10000 to 20000 extensions to be processed. 
    66set_time_limit(3000); 
    7  
    87// $change is used as a flag whether or not a reload is needed. If no changes 
    98// are made, no reload will be prompted. 
    109$change = false; 
    11 if ( $_REQUEST["csv_type"] == 'output') 
    12 
     10$output = ""; 
     11 
     12if ($_REQUEST["csv_type"] == "output") { 
    1313  exportextensions_allusers(); 
    14 } elseif ( $_REQUEST["csv_type"] == 'input') 
    15 
    16     $aFields = array  
    17     ( 
     14} elseif ($_REQUEST["csv_type"] == "input") { 
     15    $aFields = array ( 
    1816      "action" => array(false, -1), 
    1917      "extension" => array(false, -1), 
    2018      "name" => array(false, -1), 
    21       "cid_masquerade" => array(false, -1),   // used in core\core_users_add(), see line 2441 
    22       "sipname" => array(false, -1),        // used in core\core_users_add(), see line 2354 (has''default) 
    23       "directdid" => array(false, -1), 
    24       "didalert" => array(false, -1), 
    25       "mohclass" => array(false, -1),       // used in core\core_users_add(), see line 2402 
     19      "cid_masquerade" => array(false, -1), 
     20      "sipname" => array(false, -1), 
    2621      "outboundcid" => array(false, -1), 
    27       "ringtimer" => array(false, -1),      // used in core\core_users_add(), see line 2410 
    28       "callwaiting" => array(false, -1),    // used in core\core_users_add() 
     22      "ringtimer" => array(false, -1), 
     23      "callwaiting" => array(false, -1), 
     24      "call_screen" => array(false, -1), 
     25      "password" => array(false, -1), 
    2926      "emergency_cid" => array(false, -1), 
    3027      "tech" => array(false, -1), 
    3128      "hardware" => array(false, -1), 
     29      "devinfo_channel" => array(false, -1),    // for zap devices 
    3230      "devinfo_secret" => array(false, -1), 
    33       "devinfo_channel" => array(false, -1),     // used for ZAP devices ( see core\core_devices_addzap() ) 
     31      "devinfo_notransfer" => array(false, -1),    // for iax2 devices 
    3432      "devinfo_dtmfmode" => array(false, -1),     // used in core\core_devices_add<sip|zap|iax2>() 
    35       "devinfo_canreinvite" => array(false, -1),  // used in core\core_devices_add<sip|zap|iax2>()  
     33      "devinfo_canreinvite" => array(false, -1),  // used in core\core_devices_add<sip|zap|iax2>() 
    3634      "devinfo_context" => array(false, -1), 
     35      "devinfo_immediate" => array(false, -1),    // for zap devices 
     36      "devinfo_signalling" => array(false, -1),   // for zap devices 
     37      "devinfo_echocancel" => array(false, -1),   // for zap devices 
     38      "devinfo_echocancelwhenbridged" => array(false, -1),  // for zap devices 
     39      "devinfo_echotraining" => array(false, -1), // for zap devices 
     40      "devinfo_busydetect" => array(false, -1),   // for zap devices 
     41      "devinfo_busycount" => array(false, -1),    // for zap devices 
     42      "devinfo_callprogress" => array(false, -1), 
    3743      "devinfo_host" => array(false, -1), 
    3844      "devinfo_type" => array(false, -1), 
     
    4753      "devinfo_accountcode" => array(false, -1), 
    4854      "devinfo_mailbox" => array(false, -1), 
    49       "faxexten" => array(false, -1),       // used in core\core_users_add() 
    50       "faxemail" => array(false, -1),       // used in core\core_users_add() 
    51       "answer" => array(false, -1),       // used in core\core_users_add() 
    52       "wait" => array(false, -1),       // used in core\core_users_add() 
    53       "privacyman" => array(false, -1),     // used in core\core_users_add() 
     55      "devicetype" => array(false, -1), 
     56      "deviceid" => array(false, -1), 
     57      "deviceuser" => array(false, -1), 
     58      "description" => array(false, -1), 
     59      "dictenabled" => array(false, -1), 
     60      "dictformat" => array(false, -1), 
     61      "dictemail" => array(false, -1), 
     62      "langcode" => array(false, -1), 
    5463      "record_in" => array(false, -1), 
    5564      "record_out" => array(false, -1), 
     
    6473      "options" => array(false, -1), 
    6574      "vmcontext" => array(false, -1), 
    66       "vmx_state" => array(false, -1),      // used in core\core_users_add() 
    67       "devicetype" => array(false, -1),     // fixed or Adhoc (used in core\core_devices_add()) 
    68       "password" => array(false, -1),     // defaults to '' in core_users_add() (line 2404) 
    69       "noanswer" => array(false, -1),       // defaults to '' in core_users_add() (line 2412) 
    70       "devinfo_immediate" => array(false, -1),    // for zap 
    71       "devinfo_signalling" => array(false, -1), 
    72       "devinfo_echocancel" => array(false, -1), 
    73       "devinfo_echocancelwhenbridged" => array(false, -1), 
    74       "devinfo_echotraining" => array(false, -1), 
    75       "devinfo_busydetect" => array(false, -1), 
    76       "devinfo_busycount" => array(false, -1), 
    77       "devinfo_callprogress" => array(false, -1),  
    78       "devinfo_notransfer" => array(false, -1),   // for iax2 
    79       "display" => array(false, -1)     // not needed 
    80       // dictation services variables omitted ($dictenabled, $dictformat, $dictemail) 
     75      "vmx_state" => array(false, -1), 
     76      "vmx_unavail_enabled" => array(false, -1), 
     77      "vmx_busy_enabled" => array(false, -1), 
     78      "vmx_play_instructions" => array(false, -1), 
     79      "vmx_option_0_system_default" => array(false, -1), 
     80      "vmx_option_0_number" => array(false, -1), 
     81      "vmx_option_1_system_default" => array(false, -1), 
     82      "vmx_option_1_number" => array(false, -1), 
     83      "vmx_option_2_number" => array(false, -1), 
     84      "account" => array(false, -1), 
     85      "ddial" => array(false, -1), 
     86      "pre_ring" => array(false, -1), 
     87      "strategy" => array(false, -1), 
     88      "grptime" => array(false, -1), 
     89      "grplist" => array(false, -1), 
     90      "annmsg_id" => array(false, -1), 
     91      "ringing" => array(false, -1), 
     92      "grppre" => array(false, -1), 
     93      "dring" => array(false, -1), 
     94      "needsconf" => array(false, -1), 
     95      "remotealert_id" => array(false, -1), 
     96      "toolate_id" => array(false, -1), 
     97      "postdest" => array(false, -1) 
    8198      ); 
    82      
    83       $fh = fopen($_FILES['csvFile']['tmp_name'], "r"); 
    84       if($fh == NULL) 
    85       { 
    86         $file_ok = false; 
    87       } else 
    88       { 
    89         $file_ok = true; 
     99 
     100      $fh = fopen($_FILES["csvFile"]["tmp_name"], "r"); 
     101      if ($fh == NULL) { 
     102        $file_ok = FALSE; 
     103      } else { 
     104        $file_ok = TRUE; 
    90105      } 
    91        
     106 
    92107      $k = 0; 
    93        
    94       while ($file_ok && (($aInfo = fgetcsv($fh, 1000, ",")) !== FALSE))  
    95       { 
     108 
     109      while ($file_ok && (($aInfo = fgetcsv($fh, 2000, ",", "\"")) !== FALSE)) { 
    96110              $k++; 
    97         if ( empty($aInfo[0]) ) 
    98         { 
     111        if (empty($aInfo[0])) { 
    99112          continue; 
    100113        } 
    101          
     114 
    102115        // If this is the first row then we need to check each field listed (these are the headings) 
    103         if ($i==0) 
    104         { 
    105           for ($j=0; $j<count($aInfo); $j++) 
    106           { 
     116        if ($i==0) { 
     117          for ($j=0; $j<count($aInfo); $j++) { 
    107118            $aKeys = array_keys($aFields); 
    108                  
    109             foreach ($aKeys as $sKey) 
    110             { 
    111               if ($aInfo[$j] == $sKey) 
    112               { 
     119            foreach ($aKeys as $sKey) { 
     120              if ($aInfo[$j] == $sKey) { 
    113121                $aFields[$sKey][0] = true; 
    114122                $aFields[$sKey][1] = $j; 
     
    116124            } 
    117125          } 
    118              
    119126          $i++; 
    120           print "<BR><BR>Row $k: Headers parsed. <BR>"; 
     127          $output .= "<BR><BR>Row $k: Headers parsed. <BR>"; 
    121128          continue; 
    122129        } 
    123130 
    124         if ($aFields["action"][0]) 
    125         { 
     131        if ($aFields["action"][0]) { 
    126132          $vars["action"] = trim($aInfo[$aFields["action"][1]]); 
    127133        } 
     134 
     135        if ($aFields["extension"][0]) { 
     136          $vars["extension"]  = trim($aInfo[$aFields["extension"][1]]); 
     137          $vars["extdisplay"] = trim($aInfo[$aFields["extension"][1]]); 
     138        } 
     139 
     140        if ($aFields["name"][0]) { 
     141          $vars["name"] = trim($aInfo[$aFields["name"][1]]); 
     142        } 
     143 
     144        if ($aFields["cid_masquerade"][0]) { 
     145          $vars["cid_masquerade"] = trim($aInfo[$aFields["cid_masquerade"][1]]); 
     146        } 
     147 
     148        if ($aFields["sipname"][0]) { 
     149          $vars["sipname"] = trim($aInfo[$aFields["sipname"][1]]); 
     150        } 
     151 
     152        if ($aFields["outboundcid"][0]) { 
     153          $vars["outboundcid"] = trim($aInfo[$aFields["outboundcid"][1]]); 
     154        } 
     155 
     156        if ($aFields["ringtimer"][0]) { 
     157          $vars["ringtimer"] = trim($aInfo[$aFields["ringtimer"][1]]); 
     158        } 
     159 
     160              if ($aFields["callwaiting"][0]) { 
     161          $vars["callwaiting"] = trim($aInfo[$aFields["callwaiting"][1]]); 
     162        } 
     163 
     164        if ($aFields["call_screen"][0]) { 
     165          $vars["call_screen"] = trim($aInfo[$aFields["call_screen"][1]]); 
     166        } 
     167 
     168        if ($aFields["password"][0]) { 
     169          $vars["password"] = trim($aInfo[$aFields["password"][1]]); 
     170        } 
     171 
     172        if ($aFields["emergency_cid"][0]) { 
     173          $vars["emergency_cid"] = trim($aInfo[$aFields["emergency_cid"][1]]); 
     174        } 
     175 
     176        if ($aFields["tech"][0]) { 
     177          $vars["tech"] = trim($aInfo[$aFields["tech"][1]]); 
     178        } 
     179 
     180              if ($aFields["hardware"][0]) { 
     181          $vars["hardware"] = trim($aInfo[$aFields["hardware"][1]]); 
     182        } 
     183 
     184        if ($aFields["devinfo_channel"][0]) { 
     185          $vars["devinfo_channel"] = trim($aInfo[$aFields["devinfo_channel"][1]]); 
     186        } 
     187 
     188        if ($aFields["devinfo_secret"][0]) { 
     189          $vars["devinfo_secret"] = trim($aInfo[$aFields["devinfo_secret"][1]]); 
     190        } 
     191 
     192        if ($aFields["devinfo_notransfer"][0]) { 
     193          $vars["devinfo_notransfer"] = trim($aInfo[$aFields["devinfo_notransfer"][1]]); 
     194        } 
     195 
     196        if ($aFields["devinfo_dtmfmode"][0]) { 
     197          $vars["devinfo_dtmfmode"] = trim($aInfo[$aFields["devinfo_dtmfmode"][1]]); 
     198        } 
     199 
     200        if ($aFields["devinfo_canreinvite"][0]) { 
     201          $vars["devinfo_canreinvite"] = trim($aInfo[$aFields["devinfo_canreinvite"][1]]); 
     202        } 
     203 
     204        if ($aFields["devinfo_context"][0]) { 
     205          $vars["devinfo_context"] = trim($aInfo[$aFields["devinfo_context"][1]]); 
     206        } 
     207 
     208        if ($aFields["devinfo_immediate"][0]) { 
     209          $vars["devinfo_immediate"] = trim($aInfo[$aFields["devinfo_immediate"][1]]); 
     210        } 
     211 
     212        if ($aFields["devinfo_signalling"][0]) { 
     213          $vars["devinfo_signalling"] = trim($aInfo[$aFields["devinfo_signalling"][1]]); 
     214        } 
     215 
     216        if ($aFields["devinfo_echocancel"][0]) { 
     217          $vars["devinfo_echocancel"] = trim($aInfo[$aFields["devinfo_echocancel"][1]]); 
     218        } 
     219 
     220        if ($aFields["devinfo_echocancelwhenbridged"][0]) { 
     221          $vars["devinfo_echocancelwhenbridged"] = trim($aInfo[$aFields["devinfo_echocancelwhenbridged"][1]]); 
     222        } 
     223 
     224        if ($aFields["devinfo_echotraining"][0]) { 
     225          $vars["devinfo_echotraining"] = trim($aInfo[$aFields["devinfo_echotraining"][1]]); 
     226        } 
     227 
     228        if ($aFields["devinfo_busydetect"][0]) { 
     229          $vars["devinfo_busydetect"] = trim($aInfo[$aFields["devinfo_busydetect"][1]]); 
     230        } 
     231 
     232        if ($aFields["devinfo_busycount"][0]) { 
     233          $vars["devinfo_busycount"] = trim($aInfo[$aFields["devinfo_busycount"][1]]); 
     234        } 
     235 
     236        if ($aFields["devinfo_callprogress"][0]) { 
     237          $vars["devinfo_callprogress"] = trim($aInfo[$aFields["devinfo_callprogress"][1]]); 
     238        } 
     239 
     240        if ($aFields["devinfo_host"][0]) { 
     241          $vars["devinfo_host"] = trim($aInfo[$aFields["devinfo_host"][1]]); 
     242        } 
     243 
     244        if ($aFields["devinfo_type"][0]) { 
     245          $vars["devinfo_type"] = trim($aInfo[$aFields["devinfo_type"][1]]); 
     246        } 
     247 
     248        if ($aFields["devinfo_nat"][0]) { 
     249          $vars["devinfo_nat"] = trim($aInfo[$aFields["devinfo_nat"][1]]); 
     250        } 
     251 
     252        if ($aFields["devinfo_port"][0]) { 
     253          $vars["devinfo_port"] = trim($aInfo[$aFields["devinfo_port"][1]]); 
     254        } 
     255 
     256        if ($aFields["devinfo_qualify"][0]) { 
     257          $vars["devinfo_qualify"] = trim($aInfo[$aFields["devinfo_qualify"][1]]); 
     258        } 
     259 
     260        if ($aFields["devinfo_callgroup"][0]) { 
     261          $vars["devinfo_callgroup"] = trim($aInfo[$aFields["devinfo_callgroup"][1]]); 
     262        } 
     263 
     264        if ($aFields["devinfo_pickupgroup"][0]) { 
     265          $vars["devinfo_pickupgroup"] = trim($aInfo[$aFields["devinfo_pickupgroup"][1]]); 
     266        } 
     267 
     268        if ($aFields["devinfo_disallow"][0]) { 
     269          $vars["devinfo_disallow"] = trim($aInfo[$aFields["devinfo_disallow"][1]]); 
     270        } 
     271 
     272        if ($aFields["devinfo_allow"][0]) { 
     273          $vars["devinfo_allow"] = trim($aInfo[$aFields["devinfo_allow"][1]]); 
     274        } 
     275 
     276        if ($aFields["devinfo_dial"][0]) { 
     277          $vars["devinfo_dial"] = trim($aInfo[$aFields["devinfo_dial"][1]]); 
     278        } 
     279 
     280        if ($aFields["devinfo_accountcode"][0]) { 
     281          $vars["devinfo_accountcode"] = trim($aInfo[$aFields["devinfo_accountcode"][1]]); 
     282        } 
     283 
     284        if ($aFields["devinfo_mailbox"][0]) { 
     285          $vars["devinfo_mailbox"] = trim($aInfo[$aFields["devinfo_mailbox"][1]]); 
     286        } 
     287 
     288        if ($aFields["devicetype"][0]) { 
     289          $vars["devicetype"] = trim($aInfo[$aFields["devicetype"][1]]); 
     290        } 
     291 
     292        if ($aFields["deviceid"][0]) { 
     293          $vars["deviceid"] = trim($aInfo[$aFields["deviceid"][1]]); 
     294        } 
     295 
     296              if ($aFields["deviceuser"][0]) { 
     297          $vars["deviceuser"] = trim($aInfo[$aFields["deviceuser"][1]]); 
     298        } 
     299 
     300        if ($aFields["description"][0]) { 
     301          $vars["description"] = trim($aInfo[$aFields["description"][1]]); 
     302        } 
     303 
     304        if ($aFields["dictenabled"][0]) { 
     305          $vars["dictenabled"] = trim($aInfo[$aFields["dictenabled"][1]]); 
     306        } 
     307 
     308        if ($aFields["dictformat"][0]) { 
     309          $vars["dictformat"] = trim($aInfo[$aFields["dictformat"][1]]); 
     310        } 
     311 
     312        if ($aFields["dictemail"][0]) { 
     313          $vars["dictemail"] = trim($aInfo[$aFields["dictemail"][1]]); 
     314        } 
     315 
     316        if ($aFields["langcode"][0]) { 
     317          $vars["langcode"] = trim($aInfo[$aFields["langcode"][1]]); 
     318        } 
     319 
     320        if ($aFields["record_in"][0]) { 
     321          $vars["record_in"] = trim($aInfo[$aFields["record_in"][1]]); 
     322        } 
     323 
     324        if ($aFields["record_out"][0]) { 
     325          $vars["record_out"] = trim($aInfo[$aFields["record_out"][1]]); 
     326        } 
     327 
     328        if ($aFields["vm"][0]) { 
     329          $vars["vm"] = trim($aInfo[$aFields["vm"][1]]); 
     330        } 
     331 
     332        if ($aFields["vmpwd"][0]) { 
     333          $vars["vmpwd"] = trim($aInfo[$aFields["vmpwd"][1]]); 
     334        } 
     335 
     336        if ($aFields["email"][0]) { 
     337          $vars["email"] = trim($aInfo[$aFields["email"][1]]); 
     338        } 
     339 
     340        if ($aFields["pager"][0]) { 
     341          $vars["pager"] = trim($aInfo[$aFields["pager"][1]]); 
     342        } 
     343 
     344        if ($aFields["attach"][0]) { 
     345          $vars["attach"] = trim($aInfo[$aFields["attach"][1]]); 
     346        } 
     347 
     348        if ($aFields["saycid"][0]) { 
     349          $vars["saycid"] = trim($aInfo[$aFields["saycid"][1]]); 
     350        } 
     351 
     352        if ($aFields["envelope"][0]) { 
     353          $vars["envelope"] = trim($aInfo[$aFields["envelope"][1]]); 
     354        } 
     355 
     356        if ($aFields["delete"][0]) { 
     357          $vars["delete"] = trim($aInfo[$aFields["delete"][1]]); 
     358        } 
     359 
     360        if ($aFields["options"][0]) { 
     361          $vars["options"] = trim($aInfo[$aFields["options"][1]]); 
     362        } 
     363 
     364        if ($aFields["vmcontext"][0]) { 
     365          $vars["vmcontext"] = trim($aInfo[$aFields["vmcontext"][1]]); 
     366        } 
     367 
     368        if ($aFields["vmx_state"][0]) { 
     369          $vars["vmx_state"] = trim($aInfo[$aFields["vmx_state"][1]]); 
     370        } 
     371 
     372        if ($aFields["vmx_unavail_enabled"][0]) { 
     373          $vars["vmx_unavail_enabled"] = trim($aInfo[$aFields["vmx_unavail_enabled"][1]]); 
     374        } 
     375 
     376        if ($aFields["vmx_busy_enabled"][0]) { 
     377          $vars["vmx_busy_enabled"] = trim($aInfo[$aFields["vmx_busy_enabled"][1]]); 
     378        } 
     379 
     380        if ($aFields["vmx_play_instructions"][0]) { 
     381          $vars["vmx_play_instructions"] = trim($aInfo[$aFields["vmx_play_instructions"][1]]); 
     382        } 
     383 
     384        if ($aFields["vmx_option_0_system_default"][0]) { 
     385          $vars["vmx_option_0_system_default"] = trim($aInfo[$aFields["vmx_option_0_system_default"][1]]); 
     386        } 
     387 
     388        if ($aFields["vmx_option_0_number"][0]) { 
     389          $vars["vmx_option_0_number"] = trim($aInfo[$aFields["vmx_option_0_number"][1]]); 
     390        } 
     391 
     392        if ($aFields["vmx_option_1_system_default"][0]) { 
     393          $vars["vmx_option_1_system_default"] = trim($aInfo[$aFields["vmx_option_1_system_default"][1]]); 
     394        } 
     395 
     396        if ($aFields["vmx_option_1_number"][0]) { 
     397          $vars["vmx_option_1_number"] = trim($aInfo[$aFields["vmx_option_1_number"][1]]); 
     398        } 
     399 
     400        if ($aFields["vmx_option_2_number"][0]) { 
     401          $vars["vmx_option_2_number"] = trim($aInfo[$aFields["vmx_option_2_number"][1]]); 
     402        } 
    128403         
    129         if ($aFields["extension"][0]) 
    130         { 
    131           $vars["extension"] = trim($aInfo[$aFields["extension"][1]]); 
    132           $vars["deviceuser"] = trim($aInfo[$aFields["extension"][1]]); 
    133           $vars["user"] = trim($aInfo[$aFields["extension"][1]]); 
    134           $vars["extdisplay"] = trim($aInfo[$aFields["extension"][1]]); 
     404        if ($aFields["account"][0]) { 
     405          $vars["account"] = trim($aInfo[$aFields["account"][1]]); 
     406          if ($vars["account"] == $vars["extension"]) { 
     407            $followme_set = TRUE;   /* indicate we have follow me settings to set */ 
     408          } else { 
     409            $followme_set = FALSE; 
     410          } 
    135411        } 
    136412         
    137         if ($aFields["name"][0]) 
    138         { 
    139           $vars["name"] = trim($aInfo[$aFields["name"][1]]); 
    140           $vars["description"] = trim($aInfo[$aFields["description"][1]]); 
    141         } 
    142          
    143         if ($aFields["cid_masquerade"][0]) 
    144         { 
    145           $vars["cid_masquerade"] = trim($aInfo[$aFields["cid_masquerade"][1]]); 
    146         } 
    147          
    148         if ($aFields["sipname"][0]) 
    149         { 
    150           $vars["sipname"] = trim($aInfo[$aFields["sipname"][1]]); 
    151         } 
    152          
    153         if ($aFields["directdid"][0]) 
    154         { 
    155           $vars["directdid"] = trim($aInfo[$aFields["directdid"][1]]); 
    156         } 
    157          
    158         if ($aFields["didalert"][0]) 
    159         { 
    160           $vars["didalert"] = trim($aInfo[$aFields["didalert"][1]]); 
    161         } 
    162          
    163         if ($aFields["mohclass"][0]) 
    164         { 
    165           $vars["mohclass"] = trim($aInfo[$aFields["mohclass"][1]]); 
    166         } 
    167          
    168         if ($aFields["outboundcid"][0]) 
    169         { 
    170           $vars["outboundcid"] = trim($aInfo[$aFields["outboundcid"][1]]);  
    171         } 
    172          
    173         if ($aFields["ringtimer"][0]) 
    174         { 
    175           $vars["ringtimer"] = trim($aInfo[$aFields["ringtimer"][1]]); 
    176         }        
    177          
    178               if ($aFields["callwaiting"][0]) 
    179         { 
    180           $vars["callwaiting"] = trim($aInfo[$aFields["callwaiting"][1]]); 
    181         } 
    182          
    183         if ($aFields["emergency_cid"][0]) 
    184         { 
    185           $vars["emergency_cid"] = trim($aInfo[$aFields["emergency_cid"][1]]); 
    186         } 
    187  
    188         if ($aFields["tech"][0]) 
    189         { 
    190           $vars["tech"] = trim($aInfo[$aFields["tech"][1]]); 
    191         } 
    192  
    193               if ($aFields["hardware"][0]) 
    194         { 
    195           $vars["hardware"] = trim($aInfo[$aFields["hardware"][1]]); 
    196         } 
    197  
    198         if ($aFields["devinfo_secret"][0]) 
    199         { 
    200           $vars["devinfo_secret"] = trim($aInfo[$aFields["devinfo_secret"][1]]); 
    201         } 
    202          
    203         if ($aFields["devinfo_channel"][0]) 
    204         { 
    205           $vars["devinfo_channel"] = trim($aInfo[$aFields["devinfo_channel"][1]]); 
    206         }        
    207          
    208         if ($aFields["devinfo_dtmfmode"][0]) 
    209         { 
    210           $vars["devinfo_dtmfmode"] = trim($aInfo[$aFields["devinfo_dtmfmode"][1]]); 
    211         } 
    212          
    213         if ($aFields["devinfo_canreinvite"][0]) 
    214         { 
    215           $vars["devinfo_canreinvite"] = trim($aInfo[$aFields["devinfo_canreinvite"][1]]); 
    216         } 
    217  
    218         if ($aFields["devinfo_context"][0]) 
    219         { 
    220           $vars["devinfo_context"] = trim($aInfo[$aFields["devinfo_context"][1]]); 
    221         } 
    222  
    223         if ($aFields["devinfo_host"][0]) 
    224         { 
    225           $vars["devinfo_host"] = trim($aInfo[$aFields["devinfo_host"][1]]); 
    226         } 
    227          
    228         if ($aFields["devinfo_type"][0]) 
    229         { 
    230           $vars["devinfo_type"] = trim($aInfo[$aFields["devinfo_type"][1]]); 
    231         } 
    232    
    233         if ($aFields["devinfo_nat"][0]) 
    234         { 
    235           $vars["devinfo_nat"] = trim($aInfo[$aFields["devinfo_nat"][1]]); 
    236         } 
    237  
    238         if ($aFields["devinfo_port"][0]) 
    239         { 
    240           $vars["devinfo_port"] = trim($aInfo[$aFields["devinfo_port"][1]]); 
    241         } 
    242          
    243         if ($aFields["devinfo_qualify"][0]) 
    244         { 
    245           $vars["devinfo_qualify"] = trim($aInfo[$aFields["devinfo_qualify"][1]]); 
    246         } 
    247          
    248         if ($aFields["devinfo_callgroup"][0]) 
    249         { 
    250           $vars["devinfo_callgroup"] = trim($aInfo[$aFields["devinfo_callgroup"][1]]); 
    251         } 
    252          
    253         if ($aFields["devinfo_pickupgroup"][0]) 
    254         { 
    255           $vars["devinfo_pickupgroup"] = trim($aInfo[$aFields["devinfo_pickupgroup"][1]]); 
    256         } 
    257          
    258         if ($aFields["devinfo_disallow"][0]) 
    259         { 
    260           $vars["devinfo_disallow"] = trim($aInfo[$aFields["devinfo_disallow"][1]]); 
    261         } 
    262          
    263         if ($aFields["devinfo_allow"][0]) 
    264         { 
    265           $vars["devinfo_allow"] = trim($aInfo[$aFields["devinfo_allow"][1]]); 
    266         } 
    267          
    268         if ($aFields["devinfo_dial"][0]) 
    269         { 
    270           $vars["devinfo_dial"] = trim($aInfo[$aFields["devinfo_dial"][1]]); 
    271         } 
    272          
    273         if ($aFields["devinfo_accountcode"][0]) 
    274         { 
    275           $vars["devinfo_accountcode"] = trim($aInfo[$aFields["devinfo_accountcode"][1]]); 
    276         } 
    277                  
    278         if ($aFields["devinfo_mailbox"][0]) 
    279         { 
    280           $vars["devinfo_mailbox"] = trim($aInfo[$aFields["devinfo_mailbox"][1]]); 
    281         } 
    282          
    283         if ($aFields["faxexten"][0]) 
    284         { 
    285           $vars["faxexten"] = trim($aInfo[$aFields["faxexten"][1]]); 
    286         } 
    287  
    288         if ($aFields["faxemail"][0]) 
    289         { 
    290           $vars["faxemail"] = trim($aInfo[$aFields["faxemail"][1]]); 
    291         } 
    292          
    293         if ($aFields["answer"][0]) 
    294         { 
    295           $vars["answer"] = trim($aInfo[$aFields["answer"][1]]); 
    296         } 
    297                  
    298         if ($aFields["wait"][0]) 
    299         { 
    300           $vars["wait"] = trim($aInfo[$aFields["wait"][1]]); 
    301         } 
    302                  
    303         if ($aFields["privacyman"][0]) 
    304         { 
    305           $vars["privacyman"] = trim($aInfo[$aFields["privacyman"][1]]); 
    306         } 
    307                  
    308               if ($aFields["record_in"][0]) 
    309         { 
    310           $vars["record_in"] = trim($aInfo[$aFields["record_in"][1]]); 
    311         } 
    312          
    313         if ($aFields["record_out"][0]) 
    314         { 
    315           $vars["record_out"] = trim($aInfo[$aFields["record_out"][1]]); 
    316         } 
    317          
    318         if ($aFields["vm"][0]) 
    319         { 
    320           $vars["vm"] = trim($aInfo[$aFields["vm"][1]]); 
    321         } 
    322          
    323         if ($aFields["vmpwd"][0]) 
    324         { 
    325           $vars["vmpwd"] = trim($aInfo[$aFields["vmpwd"][1]]); 
    326         } 
    327          
    328         if ($aFields["email"][0]) 
    329         { 
    330           $vars["email"] = trim($aInfo[$aFields["email"][1]]); 
    331         } 
    332          
    333         if ($aFields["pager"][0]) 
    334         { 
    335           $vars["pager"] = trim($aInfo[$aFields["pager"][1]]); 
    336         } 
    337          
    338         if ($aFields["attach"][0]) 
    339         { 
    340           $vars["attach"] = trim($aInfo[$aFields["attach"][1]]); 
    341         } 
    342          
    343         if ($aFields["saycid"][0]) 
    344         { 
    345           $vars["saycid"] = trim($aInfo[$aFields["saycid"][1]]); 
    346         } 
    347          
    348         if ($aFields["envelope"][0]) 
    349         { 
    350           $vars["envelope"] = trim($aInfo[$aFields["envelope"][1]]); 
    351         } 
    352          
    353         if ($aFields["delete"][0]) 
    354         { 
    355           $vars["delete"] = trim($aInfo[$aFields["delete"][1]]); 
    356         } 
    357          
    358         if ($aFields["options"][0]) 
    359         { 
    360           $vars["options"] = trim($aInfo[$aFields["options"][1]]); 
    361         } 
    362          
    363         if ($aFields["vmcontext"][0]) 
    364         { 
    365           $vars["vmcontext"] = trim($aInfo[$aFields["vmcontext"][1]]); 
    366         } 
    367  
    368         if ($aFields["vmx_state"][0]) 
    369         { 
    370           $vars["vmx_state"] = trim($aInfo[$aFields["vmx_state"][1]]); 
    371         }        
    372          
    373         if ($aFields["devicetype"][0]) 
    374         { 
    375           $vars["devicetype"] = trim($aInfo[$aFields["devicetype"][1]]); 
    376         }      
    377  
    378         if ($aFields["password"][0]) 
    379         { 
    380           $vars["password"] = trim($aInfo[$aFields["password"][1]]); 
    381         }      
    382  
    383         if ($aFields["noanswer"][0]) 
    384         { 
    385           $vars["noanswer"] = trim($aInfo[$aFields["noanswer"][1]]); 
    386         } 
    387  
    388         if ($aFields["devinfo_immediate"][0]) 
    389         { 
    390           $vars["devinfo_immediate"] = trim($aInfo[$aFields["devinfo_immediate"][1]]); 
    391         } 
    392  
    393         if ($aFields["devinfo_signalling"][0]) 
    394         { 
    395           $vars["devinfo_signalling"] = trim($aInfo[$aFields["devinfo_signalling"][1]]); 
    396         } 
    397  
    398         if ($aFields["devinfo_echocancel"][0]) 
    399         { 
    400           $vars["devinfo_echocancel"] = trim($aInfo[$aFields["devinfo_echocancel"][1]]); 
    401         } 
    402  
    403         if ($aFields["devinfo_echocancelwhenbridged"][0]) 
    404         { 
    405           $vars["devinfo_echocancelwhenbridged"] = trim($aInfo[$aFields["devinfo_echocancelwhenbridged"][1]]); 
    406         } 
    407  
    408         if ($aFields["devinfo_echotraining"][0]) 
    409         { 
    410           $vars["devinfo_echotraining"] = trim($aInfo[$aFields["devinfo_echotraining"][1]]); 
    411         } 
    412  
    413         if ($aFields["devinfo_busydetect"][0]) 
    414         { 
    415           $vars["devinfo_busydetect"] = trim($aInfo[$aFields["devinfo_busydetect"][1]]); 
    416         } 
    417  
    418         if ($aFields["devinfo_busycount"][0]) 
    419         { 
    420           $vars["devinfo_busycount"] = trim($aInfo[$aFields["devinfo_busycount"][1]]); 
    421         } 
    422  
    423         if ($aFields["devinfo_callprogress"][0]) 
    424         { 
    425           $vars["devinfo_callprogress"] = trim($aInfo[$aFields["devinfo_callprogress"][1]]); 
    426         } 
    427  
    428         if ($aFields["devinfo_notransfer"][0]) 
    429         { 
    430           $vars["devinfo_notransfer"] = trim($aInfo[$aFields["devinfo_notransfer"][1]]); 
    431         } 
    432    
    433          
     413        if ($aFields["ddial"][0]) { 
     414          $vars["ddial"] = trim($aInfo[$aFields["ddial"][1]]); 
     415        } 
     416 
     417              if ($aFields["pre_ring"][0]) { 
     418          $vars["pre_ring"] = trim($aInfo[$aFields["pre_ring"][1]]); 
     419        } 
     420 
     421              if ($aFields["strategy"][0]) { 
     422          $vars["strategy"] = trim($aInfo[$aFields["strategy"][1]]); 
     423        } 
     424 
     425              if ($aFields["grptime"][0]) { 
     426          $vars["grptime"] = trim($aInfo[$aFields["grptime"][1]]); 
     427        } 
     428 
     429              if ($aFields["grplist"][0]) { 
     430          $vars["grplist"] = trim($aInfo[$aFields["grplist"][1]]); 
     431        } 
     432 
     433              if ($aFields["annmsg_id"][0]) { 
     434          $vars["annmsg_id"] = trim($aInfo[$aFields["annmsg_id"][1]]); 
     435        } 
     436 
     437              if ($aFields["ringing"][0]) { 
     438          $vars["ringing"] = trim($aInfo[$aFields["ringing"][1]]); 
     439        } 
     440 
     441              if ($aFields["grppre"][0]) { 
     442          $vars["grppre"] = trim($aInfo[$aFields["grppre"][1]]); 
     443        } 
     444 
     445              if ($aFields["dring"][0]) { 
     446          $vars["dring"] = trim($aInfo[$aFields["dring"][1]]); 
     447        } 
     448 
     449              if ($aFields["needsconf"][0]) { 
     450          $vars["needsconf"] = trim($aInfo[$aFields["needsconf"][1]]); 
     451        } 
     452 
     453              if ($aFields["remotealert_id"][0]) { 
     454          $vars["remotealert_id"] = trim($aInfo[$aFields["remotealert_id"][1]]); 
     455        } 
     456 
     457              if ($aFields["toolate_id"][0]) { 
     458          $vars["toolate_id"] = trim($aInfo[$aFields["toolate_id"][1]]); 
     459        } 
     460 
     461              if ($aFields["postdest"][0]) { 
     462          $vars["postdest"] = trim($aInfo[$aFields["postdest"][1]]); 
     463        } 
     464 
     465        /* Needed fields for creating a Follow Me are account (aka grpnum), strategy, grptime, */ 
     466        /* grplist and pre_ring.                     */ 
     467        if ($followme_set) { 
     468          if (!isset($vars["strategy"]) || ($vars["strategy"] == "")) { 
     469            $vars["strategy"] = "ringallv2";    // default value 
     470          } 
     471           
     472          if(!isset($vars["grptime"]) || ($vars["grptime"] == "")) { 
     473            $vars["grptime"] = "20";      // default value 
     474          } 
     475           
     476          if(!isset($vars["grplist"]) || ($vars["grplist"] == "")) { 
     477            $vars["grplist"] = $vars["extension"];  // default value 
     478          } 
     479           
     480          if(!isset($vars["pre_ring"]) || ($vars["pre_ring"] == "")) { 
     481            $vars["pre_ring"] = "0";      // default value 
     482          } 
     483        } 
     484 
     485        if (!(isset($amp_conf["AMPEXTENSIONS"]) && ($amp_conf["AMPEXTENSIONS"] == "deviceanduser"))) { 
     486          $vars["devicetype"]   = "fixed"; 
     487          $vars["deviceid"] = $vars["deviceuser"] = $vars["extension"]; 
     488          $vars["description"]  = $vars["name"]; 
     489        } else { 
     490          /* deviceid is required; if freepbx is in devicesandusers mode, deviceid cannot be left blank. */ 
     491          if ($vars["deviceid"] == "") { 
     492            $vars["deviceid"] = $vars["extension"]; 
     493          } 
     494        } 
     495 
     496        $vars["display"]  = "bulkextensions"; 
     497        $vars["type"] = "tool"; 
     498 
    434499        $_REQUEST = $vars; 
    435          
    436         switch ($vars["action"]) 
    437         { 
     500 
     501        switch ($vars["action"]) { 
    438502          case "add": 
    439503      // Only add if no voicemail, no user and no device entry already 
    440504      // exist for the extension we're trying to add. 
    441  
    442505      // Check the list of voicemail entries. 
    443       $uservm = voicemail_getVoicemail(); 
    444       $vmcontexts = array_keys($uservm); 
    445        
    446       // vmexists == false means add  new voicemail entry. 
    447       $vmexists = false; 
    448       foreach ($vmcontexts as $vmcontext) 
    449       { 
    450         if (isset($uservm[$vmcontext][$vars["extension"]])) 
    451         { 
    452           $vmexists = true;   // DO NOT add. 
    453         } 
    454       } 
    455       if ($vmexists || core_users_get($vars["extension"]) || core_devices_get($vars["extension"])) 
    456       { 
    457         print "Row $k: Extension " . $vars["extension"] . " already exists" . "<BR>"; 
    458       } else 
    459                         { 
    460         voicemail_mailbox_add($mbox, $vars); 
    461         core_users_add($vars,$vars["vmcontext"]);        
    462         core_devices_add($vars["extension"],$vars["tech"],$vars["devinfo_dial"],$vars["devicetype"],$vars["deviceuser"],$vars["name"],$vars["emergency_cid"]); 
    463         print "Row $k: Added: " . $vars["extension"] . "<BR>"; 
     506      // user_vmexists == false means add  new voicemail entry. 
     507      $user_vmexists = FALSE; 
     508      if ($vm_exists) { 
     509        $uservm = voicemail_getVoicemail(); 
     510        $vmcontexts = array_keys($uservm); 
     511        foreach ($vmcontexts as $vmcontext) { 
     512          if (isset($uservm[$vmcontext][$vars["extension"]])) { 
     513            $user_vmexists = TRUE;    // DO NOT add. 
     514          } 
     515        } 
     516      } 
     517      if ($user_vmexists || core_users_get($vars["extension"]) || core_devices_get($vars["extension"])) { 
     518        $output .= "Row $k: Extension " . $vars["extension"] . " already exists" . "<BR>"; 
     519      } else { 
     520        if ($vm_exists) { 
     521          voicemail_mailbox_add($vars["extension"], $vars); 
     522        } 
     523        core_users_add($vars); 
     524        core_devices_add($vars["deviceid"],$vars["tech"],$vars["devinfo_dial"],$vars["devicetype"],$vars["deviceuser"],$vars["description"],$vars["emergency_cid"]); 
     525         
     526        if ($lang_exists) { 
     527          languages_user_update($vars["extension"], $vars["langcode"]); 
     528        } 
     529        if ($dict_exists) { 
     530          dictate_update($vars["extension"], $vars["dictenabled"], $vars["dictformat"], $vars["dictemail"]); 
     531        } 
     532        if ($findme_exists && $followme_set) { 
     533          findmefollow_add($vars["account"], $vars["strategy"], $vars["grptime"], $vars["grplist"], $vars["postdest"], $vars["grppre"], $vars["annmsg_id"], $vars["dring"], $vars["needsconf"], $vars["remotealert_id"], $vars["toolate_id"], $vars["ringing"], $vars["pre_ring"], $vars["ddial"]); 
     534        } 
     535        $output .= "Row $k: Added: " . $vars["extension"] . "<BR>"; 
    464536        $change = true; 
    465537      } 
    466  
    467538      break; 
    468539    case "edit": 
    469                         // Edit is just a delete and an add. Voicemail 
    470                         // messages are not deleted.   
    471       // First delete: 
    472540      // Functions core_devices_del and core_users_del 
    473541      // do not check that the device or user actually 
    474       // do exist
    475       // We check that the device or user exists before deleting 
    476      // by looking them up by the extension. 
     542      // exists
     543      // We check that the device or user exists before 
     544                        // deleting by looking them up by the extension. 
    477545      // Only if the device or user exists do we call 
    478546      // core_devices_del or core_users_del. 
    479       if (core_devices_get($vars["extension"])) 
    480       { 
     547      if (core_devices_get($vars["extension"])) { 
    481548        core_devices_del($vars["extension"]); 
    482       } 
    483  
    484       if (core_users_get($vars["extension"])) 
    485       { 
     549        $change = true; 
     550      } 
     551      if (core_users_get($vars["extension"])) { 
    486552        core_users_del($vars["extension"]); 
    487553        core_users_cleanastdb($vars["extension"]); 
    488       } 
    489  
     554        if ($findme_exists) { 
     555          findmefollow_del($vars["extension"]); 
     556        } 
     557        if ($dict_exists) { 
     558          dictate_del($vars["extension"]); 
     559        } 
     560        if ($lang_exists) { 
     561          languages_user_del($vars["extension"]); 
     562        } 
     563        $change = true; 
     564      } 
    490565      // The voicemail functions have their own internal 
    491566      // checking. 
    492567      // If the voicemail box in question does not exist, 
    493568      // the functions simply return.  No harm done. 
    494       voicemail_mailbox_del($vars["extension"]); 
    495  
    496  
    497       // Then add: 
    498       // No checks necessary; all deleted. 
    499  
    500       voicemail_mailbox_add($mbox, $vars); 
    501       core_users_add($vars,$vars["vmcontext"]);        
    502       core_devices_add($vars["extension"],$vars["tech"],$vars["devinfo_dial"],$vars["devicetype"],$vars["deviceuser"],$vars["name"],$vars["emergency_cid"]); 
    503       $change = true; 
    504  
    505       print "Row $k: Edited: " . $vars["extension"] . "<BR>";      
     569      // 
     570      // When editting an existing extension do not call 
     571      // voicemail_mailbox_remove, it will delete existing 
     572      // voicemail messages, which is undesirable. 
     573      if ($vm_exists) { 
     574        voicemail_mailbox_del($vars["extension"]); 
     575      } 
     576      // Only add if no voicemail, no user and no device entry already 
     577      // exist for the extension we're trying to add. 
     578      // Check the list of voicemail entries. 
     579      // user_vmexists == false means add new voicemail entry. 
     580      $user_vmexists = FALSE; 
     581      if ($vm_exists) { 
     582        $uservm = voicemail_getVoicemail(); 
     583        $vmcontexts = array_keys($uservm); 
     584        foreach ($vmcontexts as $vmcontext) { 
     585          if (isset($uservm[$vmcontext][$vars["extension"]])) { 
     586            $user_vmexists = TRUE;    // DO NOT add. 
     587          } 
     588        } 
     589      } 
     590      if ($user_vmexists || core_users_get($vars["extension"]) || core_devices_get($vars["extension"])) { 
     591        $output .= "Row $k: Extension " . $vars["extension"] . " already exists" . "<BR>"; 
     592      } else { 
     593        if ($vm_exists) { 
     594          voicemail_mailbox_add($vars["extension"], $vars); 
     595        } 
     596        core_users_add($vars); 
     597        core_devices_add($vars["deviceid"],$vars["tech"],$vars["devinfo_dial"],$vars["devicetype"],$vars["deviceuser"],$vars["description"],$vars["emergency_cid"]); 
     598        if ($lang_exists) { 
     599          languages_user_update($vars["extension"], $vars["langcode"]); 
     600        } 
     601        if ($dict_exists) { 
     602          dictate_update($vars["extension"], $vars["dictenabled"], $vars["dictformat"], $vars["dictemail"]); 
     603        } 
     604        if ($findme_exists && $followme_set) { 
     605          findmefollow_add($vars["account"], $vars["strategy"], $vars["grptime"], $vars["grplist"], $vars["postdest"], $vars["grppre"], $vars["annmsg_id"], $vars["dring"], $vars["needsconf"], $vars["remotealert_id"], $vars["toolate_id"], $vars["ringing"], $vars["pre_ring"], $vars["ddial"]); 
     606        } 
     607        $change = true; 
     608      } 
     609      $output .= "Row $k: Edited: " . $vars["extension"] . "<BR>"; 
    506610      break; 
    507611    case "del": 
     
    513617      // Only if the device or user exists do we call 
    514618      // core_devices_del or core_users_del. 
    515       if (core_devices_get($vars["extension"])) 
    516       { 
     619      if (core_devices_get($vars["extension"])) { 
    517620        core_devices_del($vars["extension"]); 
    518621        $change = true; 
    519622      } 
    520  
    521       if (core_users_get($vars["extension"])) 
    522       { 
     623      if (core_users_get($vars["extension"])) { 
    523624        core_users_del($vars["extension"]); 
    524625        core_users_cleanastdb($vars["extension"]); 
     626        if ($findme_exists) { 
     627          findmefollow_del($vars["extension"]); 
     628        } 
     629        if ($dict_exists) { 
     630          dictate_del($vars["extension"]); 
     631        } 
     632        if ($lang_exists) { 
     633          languages_user_del($vars["extension"]); 
     634        } 
    525635        $change = true; 
    526636      } 
    527  
    528637      // The voicemail functions have their own internal 
    529638      // checking. 
    530639      // If the voicemail box in question does not exist, 
    531640      // the functions simply return.  No harm done. 
    532       voicemail_mailbox_remove($vars["extension"]); 
    533       if(voicemail_mailbox_del($vars["extension"])) 
    534       { 
    535         $change = true; 
    536       } 
    537       if (function_exists('findmefollow_del')) 
    538       { 
    539           findmefollow_del($vars["extension"]); 
    540       } 
    541  
    542       print "Row $k: Deleted: " . $vars["extension"] . "<BR>"; 
     641      // 
     642      // call remove BEFORE del 
     643      if ($vm_exists) { 
     644        voicemail_mailbox_remove($vars["extension"]); 
     645        voicemail_mailbox_del($vars["extension"]); 
     646      } 
     647      $output .= "Row $k: Deleted: " . $vars["extension"] . "<BR>"; 
    543648      break; 
    544649    default: 
    545       print "Row $k: Unrecognized action: the only actions recognized are add, edit, del.\n"; 
     650      $output .= "Row $k: Unrecognized action: the only actions recognized are add, edit, del.\n"; 
    546651      break; 
    547652        } 
    548653 
    549               //  
    550         if ($change) 
    551         { 
     654        if ($change) { 
    552655      needreload(); 
    553656        } 
    554             
    555657      } // while loop 
    556        
    557 } else  
     658 
     659       print $output; 
     660 
     661} else 
    558662{ 
    559   /**************************************************************** 
    560   * $description is the same as $name     * 
    561   * $extension, $deviceuser and $user are all the same  * 
    562   * can leave devinfo_mailbox blank, since      * 
    563   * voicemail_mailboxadd will fill it in      * 
    564   ****************************************************************/ 
     663  $table_output = ""; 
     664  $table_rows = generate_table_rows(); 
     665  if ($table_rows === NULL) { 
     666    $table_output = "Table unavailable"; 
     667  } else { 
     668    $table_output .=  "<table cellspacing='0' cellpadding='4' rules='rows'>"; 
     669    $table_output .=  "<tr valign='top'> 
     670            <th align='left' valign='top'>#</th> 
     671            <th align='left' valign='top'>Name</th> 
     672            <th align='left' valign='top'>Default</th> 
     673            <th align='left' valign='top'>Allowed</th> 
     674            <th align='left' valign='top'>On Extensions page</th> 
     675            <th align='left' valign='top'>Details</th> 
     676          </tr>"; 
     677    $i = 1; 
     678    foreach ($table_rows as $row) { 
     679      $table_output .= "<tr>"; 
     680      $table_output .= "<td valign='top'>" . $i . "</td>"; 
     681      $i++; 
     682      foreach ($row as $col) { 
     683        $table_output .= "<td valign='top'>" . $col . "</td>"; 
     684      } 
     685      $table_output .= "</tr>"; 
     686    } 
     687    $table_output .= "</table>"; 
     688  } 
     689 
    565690?> 
    566691<h1>Bulk Extensions</h1> 
     
    568693<h2>Manage Extensions in bulk using CSV files.</h2> 
    569694 
    570 <p>Start by downloading the 
     695<p> 
     696Start by downloading the 
    571697<a href="modules/bulkextensions/template.csv">Template CSV file</a> 
    572 (right-click > save as) or clicking the Export Extensions button. The table 
    573 below explains each column in the CSV file. Modify the CSV file to add, edit, 
    574 or delete Extensions as desired. Then load the CSV file. As the CSV file is 
    575 processed, the action taken for each row will be displayed. <b>Bulk extension 
    576 changes can take a long time to complete. Please allow up to 30 seconds per 
    577 100 extensions.</b></p> 
    578  
    579 <form action="<?php $_SERVER['PHP_SELF'] ?>" name="uploadcsv" method="post" enctype="multipart/form-data"> 
     698(right-click > save as) or clicking the Export Extensions button. 
     699</p> 
     700<p> 
     701The table below explains each column in the CSV file. Modify the CSV file to add, 
     702edit, or delete Extensions as desired. You can change the column order of the CSV 
     703file as you like, however, the column names must be preserved. Then load the CSV 
     704file. After the CSV file is processed, the action taken for each row will be 
     705displayed. 
     706</p> 
     707<p> 
     708<b>Bulk extension changes can take a long time to complete. It can take 30-60 
     709seconds to add 100 extensions on a small system. However, on a system with 2000 
     710extensions it can take about 5 minutes to add 100 new extensions.</b> 
     711</p> 
     712 
     713<form action="<?php $_SERVER["PHP_SELF"] ?>" name="uploadcsv" method="post" enctype="multipart/form-data"> 
    580714<input id="csv_type" name="csv_type" type="hidden" value="none"> 
    581715<input type="submit" onclick="document.getElementById('csv_type').value='output';" value="Export Extensions"> 
     
    587721<hr> 
    588722<h3>Bulk Extensions CSV File Columns</h3> 
    589  
    590 <table cellspacing="0" cellpadding="4" rules="rows"> 
    591  <tr valign="top"> 
    592   <th align="left" valign="top">#</th> 
    593   <th align="left" valign="top">Name</th> 
    594   <th align="left" valign="top">Default</th> 
    595   <th align="left" valign="top">Allowed</th> 
    596   <th align="left" valign="top">On Extensions page</th> 
    597   <th align="left" valign="top">Details</th> 
    598  </tr> 
    599  <tr valign="top"> 
    600   <td valign="top">1</td> 
    601   <td valign="top">action</td> 
    602   <td valign="top"></td> 
    603   <td valign="top">add, del, edit</td> 
    604   <td valign="top"></td> 
    605   <td valign="top">Add, Delete, or Edit an Extension.</td> 
    606  </tr> 
    607  <tr valign="top"> 
    608   <td valign="top">2</td> 
    609   <td valign="top">extension</td> 
    610   <td valign="top"></td> 
    611   <td valign="top"></td> 
    612   <td valign="top">User Extension</td> 
    613   <td valign="top">The extension number to dial to reach this user.</td> 
    614  </tr> 
    615  <tr valign="top"> 
    616   <td valign="top">3</td> 
    617   <td valign="top">name</td> 
    618   <td valign="top"></td> 
    619   <td valign="top"></td> 
    620   <td valign="top">Display Name</td> 
    621   <td valign="top">The caller id name for calls from this user will be set to this name. Only 
    622   enter the name, NOT the number.</td> 
    623  </tr> 
    624  <tr valign="top"> 
    625   <td valign="top">4</td> 
    626   <td valign="top">cid_masquerade</td> 
    627   <td valign="top"></td> 
    628   <td valign="top"></td> 
    629   <td valign="top">CID Num Alias</td> 
    630   <td valign="top">The CID Number to use for internal calls, if different from the extension 
    631   number. This is used to masquerade as a different user. A common example is a 
    632   team of support people who would like their internal callerid to display the 
    633   general support number (a ringgroup or queue). There will be no effect on 
    634   external calls.</td> 
    635  </tr> 
    636  <tr valign="top"> 
    637   <td valign="top">5</td> 
    638   <td valign="top">sipname</td> 
    639   <td valign="top"></td> 
    640   <td valign="top"></td> 
    641   <td valign="top">SIP Alias</td> 
    642   <td valign="top">If you want to support direct sip dialing of users internally or through 
    643   anonymous sip calls, you can supply a friendly name that can be used in 
    644   addition to the users extension to call them.</td> 
    645  </tr> 
    646  <tr valign="top"> 
    647   <td valign="top">6</td> 
    648   <td valign="top">directdid</td> 
    649   <td valign="top"></td> 
    650   <td valign="top"></td> 
    651   <td valign="top">Direct DID</td> 
    652   <td valign="top">The direct DID that is associated with this extension. The DID should be 
    653   in the same format as provided by the provider (e.g. full number, 4 digits for 
    654   10x4, etc). 
    655   <br><br> 
    656   Format should be: <b>XXXXXXXXXX</b> 
    657   <br><br> 
    658   Leave this field blank to disable the direct DID feature for this extension. 
    659   All non-numeric characters will be stripped.</td> 
    660  </tr> 
    661  <tr valign="top"> 
    662   <td valign="top">7</td> 
    663   <td valign="top">didalert</td> 
    664   <td valign="top"></td> 
    665   <td valign="top"></td> 
    666   <td valign="top">DID Alert Info</td> 
    667   <td valign="top">Alert Info can be used for distinctive ring on SIP phones. Set this value 
    668   to the desired Alert Info to be sent to the phone when this DID is called. 
    669   Leave blank to use default values. Will have no effect if no Direct DID is 
    670   set.</td> 
    671  </tr> 
    672  <tr valign="top"> 
    673   <td valign="top">8</td> 
    674   <td valign="top">mohclass</td> 
    675   <td valign="top">default</td> 
    676   <td valign="top">default, none, any valid MoH class</td> 
    677   <td valign="top">Music on Hold</td> 
    678   <td valign="top">Set the MoH class that will be used for calls that come in on this Direct 
    679   DID. For example, choose a type appropriate for a originating country which 
    680   may have announcements in their language. Only effects MoH class when the call 
    681   came in from the Direct DID.</td> 
    682  </tr> 
    683  <tr valign="top"> 
    684   <td valign="top">9</td> 
    685   <td valign="top">outboundcid</td> 
    686   <td valign="top"></td> 
    687   <td valign="top"></td> 
    688   <td valign="top">Outbound CID</td> 
    689   <td valign="top">Overrides the caller id when dialing out a trunk. Any setting here will 
    690   override the common outbound caller id set in the Trunks admin. 
    691   <br><br> 
    692   Format: <b>&quot;caller name&quot; &lt;#######&gt;</b> 
    693   <br><br> 
    694   Leave this field blank to disable the outbound callerid feature for this 
    695   user.</td> 
    696  </tr> 
    697  <tr valign="top"> 
    698   <td valign="top">10</td> 
    699   <td valign="top">ringtimer</td> 
    700   <td valign="top">0</td> 
    701   <td valign="top">0-120</td> 
    702   <td valign="top">Ring Time</td> 
    703   <td valign="top">Number of seconds to ring prior to going to voicemail. 0 (Default) will 
    704   use the value set in the General Tab. If no voicemail is configured this will 
    705   be ignored.</td> 
    706  </tr> 
    707  <tr valign="top"> 
    708   <td valign="top">11</td> 
    709   <td valign="top">callwaiting</td> 
    710   <td valign="top">enabled</td> 
    711   <td valign="top">enabled, disabled</td> 
    712   <td valign="top">Call Waiting</td> 
    713   <td valign="top">Set the initial/current Call Waiting state for this user's extension.</td> 
    714  </tr> 
    715  <tr valign="top"> 
    716   <td valign="top">12</td> 
    717   <td valign="top">emergency_cid</td> 
    718   <td valign="top"></td> 
    719   <td valign="top"></td> 
    720   <td valign="top">Emergency CID</td> 
    721   <td valign="top">This caller id will always be set when dialing out an Outbound Route 
    722   flagged as Emergency. The Emergency CID overrides all other caller id 
    723   settings.</td> 
    724  </tr> 
    725  <tr valign="top"> 
    726   <td valign="top">13</td> 
    727   <td valign="top">tech</td> 
    728   <td valign="top"></td> 
    729   <td valign="top">sip, iax2, zap, custom</td> 
    730   <td valign="top"></td> 
    731   <td valign="top">Device channel type.</td> 
    732  </tr> 
    733  <tr valign="top"> 
    734   <td valign="top">14</td> 
    735   <td valign="top">hardware</td> 
    736   <td valign="top"></td> 
    737   <td valign="top">generic, custom</td> 
    738   <td valign="top"></td> 
    739   <td valign="top"></td> 
    740  </tr> 
    741  <tr valign="top"> 
    742   <td valign="top">15</td> 
    743   <td valign="top">devinfo_secret</td> 
    744   <td valign="top"></td> 
    745   <td valign="top"></td> 
    746   <td valign="top">secret</td> 
    747   <td valign="top">See sip.conf file or iax.conf file.</td> 
    748  </tr> 
    749  <tr valign="top"> 
    750   <td valign="top">16</td> 
    751   <td valign="top">devinfo_channel</td> 
    752   <td valign="top"></td> 
    753   <td valign="top"></td> 
    754   <td valign="top">channel</td> 
    755   <td valign="top">See zapata.conf.</td> 
    756  </tr> 
    757  <tr valign="top"> 
    758   <td valign="top">17</td> 
    759   <td valign="top">devinfo_dtmfmode</td> 
    760   <td valign="top">rfc2833</td> 
    761   <td valign="top"></td> 
    762   <td valign="top">dtmfmode</td> 
    763   <td valign="top">See sip.conf file.</td> 
    764  </tr> 
    765  <tr valign="top"> 
    766   <td valign="top">18</td> 
    767   <td valign="top">devinfo_canreinvite</td> 
    768   <td valign="top">no</td> 
    769   <td valign="top"></td> 
    770   <td valign="top">canreinvite</td> 
    771   <td valign="top">See sip.conf file.</td> 
    772  </tr> 
    773  <tr valign="top"> 
    774   <td valign="top">19</td> 
    775   <td valign="top">devinfo_context</td> 
    776   <td valign="top">from-internal</td> 
    777   <td valign="top"></td> 
    778   <td valign="top">context</td> 
    779   <td valign="top">Device context.</td> 
    780  </tr> 
    781  <tr valign="top"> 
    782   <td valign="top">20</td> 
    783   <td valign="top">devinfo_host</td> 
    784   <td valign="top">dynamic</td> 
    785   <td valign="top"></td> 
    786   <td valign="top">host</td> 
    787   <td valign="top">See sip.conf file or iax.conf file.</td> 
    788  </tr> 
    789  <tr valign="top"> 
    790   <td valign="top">21</td> 
    791   <td valign="top">devinfo_type</td> 
    792   <td valign="top">friend</td> 
    793   <td valign="top"></td> 
    794   <td valign="top">type</td> 
    795   <td valign="top">See sip.conf file or iax.conf file.</td> 
    796  </tr> 
    797  <tr valign="top"> 
    798   <td valign="top">22</td> 
    799   <td valign="top">devinfo_nat</td> 
    800   <td valign="top">yes</td> 
    801   <td valign="top"></td> 
    802   <td valign="top">nat</td> 
    803   <td valign="top">See sip.conf file.</td> 
    804  </tr> 
    805  <tr valign="top"> 
    806   <td valign="top">23</td> 
    807   <td valign="top">devinfo_port</td> 
    808   <td valign="top"></td> 
    809   <td valign="top"></td> 
    810   <td valign="top">port</td> 
    811   <td valign="top">See sip.conf file or iax.conf file. Default for sip is 5060, iax2 is 
    812   4569.</td> 
    813  </tr> 
    814  <tr valign="top"> 
    815   <td valign="top">24</td> 
    816   <td valign="top">devinfo_qualify</td> 
    817   <td valign="top">yes</td> 
    818   <td valign="top"></td> 
    819   <td valign="top">qualify</td> 
    820   <td valign="top">See sip.conf file or iax.conf file.</td> 
    821  </tr> 
    822  <tr valign="top"> 
    823   <td valign="top">25</td> 
    824   <td valign="top">devinfo_callgroup</td> 
    825   <td valign="top"></td> 
    826   <td valign="top"></td> 
    827   <td valign="top">callgroup</td> 
    828   <td valign="top">See sip.conf file.</td> 
    829  </tr> 
    830  <tr valign="top"> 
    831   <td valign="top">26</td> 
    832   <td valign="top">devinfo_pickupgroup</td> 
    833   <td valign="top"></td> 
    834   <td valign="top"></td> 
    835   <td valign="top">pickupgroup</td> 
    836   <td valign="top">See sip.conf file.</td> 
    837  </tr> 
    838  <tr valign="top"> 
    839   <td valign="top">27</td> 
    840   <td valign="top">devinfo_disallow</td> 
    841   <td valign="top"></td> 
    842   <td valign="top"></td> 
    843   <td valign="top">disallow</td> 
    844   <td valign="top">See conf file for device tech. Codec(s) to disallow.</td> 
    845  </tr> 
    846  <tr valign="top"> 
    847   <td valign="top">28</td> 
    848   <td valign="top">devinfo_allow</td> 
    849   <td valign="top"></td> 
    850   <td valign="top"></td> 
    851   <td valign="top">allow</td> 
    852   <td valign="top">See conf file for device tech. Codec(s) to allow.</td> 
    853  </tr> 
    854  <tr valign="top"> 
    855   <td valign="top">29</td> 
    856   <td valign="top">devinfo_dial</td> 
    857   <td valign="top"></td> 
    858   <td valign="top"></td> 
    859   <td valign="top">dial</td> 
    860   <td valign="top">See conf file for device tech. Default is TECH/exten, i.e SIP/101. For zap 
    861   it is TECH/channel, i.e. ZAP/1.</td> 
    862  </tr> 
    863  <tr valign="top"> 
    864   <td valign="top">30</td> 
    865   <td valign="top">devinfo_accountcode</td> 
    866   <td valign="top"></td> 
    867   <td valign="top"></td> 
    868   <td valign="top">accountcode</td> 
    869   <td valign="top">See conf file for device tech.</td> 
    870  </tr> 
    871  <tr valign="top"> 
    872   <td valign="top">31</td> 
    873   <td valign="top">devinfo_mailbox</td> 
    874   <td valign="top"></td> 
    875   <td valign="top"></td> 
    876   <td valign="top">mailbox</td> 
    877   <td valign="top">See conf file for device tech. Default is exten@device, i.e 101@device.</td> 
    878  </tr> 
    879  <tr valign="top"> 
    880   <td valign="top">32</td> 
    881   <td valign="top">faxexten</td> 
    882   <td valign="top">default</td> 
    883   <td valign="top">default, disabled, system, any valid extension</td> 
    884   <td valign="top">Fax Extension</td> 
    885   <td valign="top">Select 'system' to have the system receive and email faxes. 
    886   <br><br> 
    887   The FreePBX default is defined in General Settings.</td> 
    888  </tr> 
    889  <tr valign="top"> 
    890   <td valign="top">33</td> 
    891   <td valign="top">faxemail</td> 
    892   <td valign="top"></td> 
    893   <td valign="top"></td> 
    894   <td valign="top">Fax Email</td> 
    895   <td valign="top">Email address is used if 'system' has been chosen for the fax extension 
    896   above. 
    897   <br><br> 
    898   Leave this blank to use the FreePBX default in General Settings.</td> 
    899  </tr> 
    900  <tr valign="top"> 
    901   <td valign="top">34</td> 
    902   <td valign="top">answer</td> 
    903   <td valign="top">0</td> 
    904   <td valign="top">0-2</td> 
    905   <td valign="top">Fax Detection Type</td> 
    906   <td valign="top">Selecting Zaptel or NVFax will immediately answer the call and play 
    907   ringing tones to the caller for the number of seconds in Pause below. Use 
    908   NVFax on SIP or IAX trunks. 0 = None, 1 = Zaptel, 2 = NVFax.</td> 
    909  </tr> 
    910  <tr valign="top"> 
    911   <td valign="top">35</td> 
    912   <td valign="top">wait</td> 
    913   <td valign="top">0</td> 
    914   <td valign="top"></td> 
    915   <td valign="top">Pause after answer</td> 
    916   <td valign="top">The number of seconds we should wait after performing an Immediate Answer. 
    917   The primary purpose of this is to pause and listen for a fax tone before 
    918   allowing the call to proceed. Default is 0.</td> 
    919  </tr> 
    920  <tr valign="top"> 
    921   <td valign="top">36</td> 
    922   <td valign="top">privacyman</td> 
    923   <td valign="top">0</td> 
    924   <td valign="top">0, 1</td> 
    925   <td valign="top">Privacy Manager</td> 
    926   <td valign="top">If no Caller ID is sent, Privacy Manager asks the caller to enter their 10 
    927   digit phone number. The caller is given 3 attempts. 0 = No, 1 = Yes.</td> 
    928  </tr> 
    929  <tr valign="top"> 
    930   <td valign="top">37</td> 
    931   <td valign="top">record_in</td> 
    932   <td valign="top">Adhoc</td> 
    933   <td valign="top">Adhoc, Always, Never</td> 
    934   <td valign="top">Record Incoming</td> 
    935   <td valign="top">Record all inbound calls received at this extension.</td> 
    936  </tr> 
    937  <tr valign="top"> 
    938   <td valign="top">38</td> 
    939   <td valign="top">record_out</td> 
    940   <td valign="top">Adhoc</td> 
    941   <td valign="top">Adhoc, Always, Never</td> 
    942   <td valign="top">Record Outgoing</td> 
    943   <td valign="top">Record all outbound calls received at this extension.</td> 
    944  </tr> 
    945  <tr valign="top"> 
    946   <td valign="top">39</td> 
    947   <td valign="top">vm</td> 
    948   <td valign="top">disabled</td> 
    949   <td valign="top">enabled, disabled</td> 
    950   <td valign="top">Status</td> 
    951   <td valign="top">Set voicemail status for this user.</td> 
    952  </tr> 
    953  <tr valign="top"> 
    954   <td valign="top">40</td> 
    955   <td valign="top">vmpwd</td> 
    956   <td valign="top"></td> 
    957   <td valign="top"></td> 
    958   <td valign="top">Voicemail Password</td> 
    959   <td valign="top">This is the password used to access the voicemail system. 
    960   <br><br> 
    961   This password can only contain numbers. 
    962   <br><br> 
    963   A user can change the password you enter here after logging into the voicemail 
    964   system (*98) with a phone.</td> 
    965  </tr> 
    966  <tr valign="top"> 
    967   <td valign="top">41</td> 
    968   <td valign="top">email</td> 
    969   <td valign="top"></td> 
    970   <td valign="top"></td> 
    971   <td valign="top">Email Address</td> 
    972   <td valign="top">The email address that voicemails are sent to.</td> 
    973  </tr> 
    974  <tr valign="top"> 
    975   <td valign="top">42</td> 
    976   <td valign="top">pager</td> 
    977   <td valign="top"></td> 
    978   <td valign="top"></td> 
    979   <td valign="top">Pager Email Address</td> 
    980   <td valign="top">Pager/mobile email address to which short voicemail notifcations are 
    981   sent.</td> 
    982  </tr> 
    983  <tr valign="top"> 
    984   <td valign="top">43</td> 
    985   <td valign="top">attach</td> 
    986   <td valign="top">attach=no</td> 
    987   <td valign="top">attach=yes, attach=no</td> 
    988   <td valign="top">Email Attachment</td> 
    989   <td valign="top">Option to attach voicemails to email.</td> 
    990  </tr> 
    991  <tr valign="top"> 
    992   <td valign="top">44</td> 
    993   <td valign="top">saycid</td> 
    994   <td valign="top">saycid=no</td> 
    995   <td valign="top">saycid=yes, saycid=no</td> 
    996   <td valign="top">Play CID</td> 
    997   <td valign="top">Read back caller's telephone number prior to playing the incoming message, 
    998   and just after announcing the date and time the message was left.</td> 
    999  </tr> 
    1000  <tr valign="top"> 
    1001   <td valign="top">45</td> 
    1002   <td valign="top">envelope</td> 
    1003   <td valign="top">envelope=no</td> 
    1004   <td valign="top">envelope=yes, envelope=no</td> 
    1005   <td valign="top">Play Envelope</td> 
    1006   <td valign="top">Envelope controls whether or not the voicemail system will play the 
    1007   message envelope (date/time) before playing the voicemail message. This settng 
    1008   does not affect the operation of the envelope option in the advanced voicemail 
    1009   menu.</td> 
    1010  </tr> 
    1011  <tr valign="top"> 
    1012   <td valign="top">46</td> 
    1013   <td valign="top">delete</td> 
    1014   <td valign="top">delete=no</td> 
    1015   <td valign="top">delete=yes, delete=no</td> 
    1016   <td valign="top">Delete Vmail</td> 
    1017   <td valign="top">If set to &quot;yes&quot; the message will be deleted from the 
    1018   voicemailbox (after having been emailed).  Provides functionality that allows 
    1019   a user to receive their voicemail via email alone, rather than having the 
    1020   voicemail able to be retrieved from the Web interface or the Extension 
    1021   handset. CAUTION: MUST HAVE attach voicemail to email SET TO YES OTHERWISE 
    1022   YOUR MESSAGES WILL BE LOST FOREVER.</td> 
    1023  </tr> 
    1024  <tr valign="top"> 
    1025   <td valign="top">47</td> 
    1026   <td valign="top">options</td> 
    1027   <td valign="top"></td> 
    1028   <td valign="top"></td> 
    1029   <td valign="top">VM Options</td> 
    1030   <td valign="top">Separate options with pipe ( | ) 
    1031   <br><br>ie: review=yes|maxmessage=60</td> 
    1032  </tr> 
    1033  <tr valign="top"> 
    1034   <td valign="top">48</td> 
    1035   <td valign="top">vmcontext</td> 
    1036   <td valign="top">default</td> 
    1037   <td valign="top"></td> 
    1038   <td valign="top">VM Context</td> 
    1039   <td valign="top">This is the Voicemail Context which is normally set to default. Do not 
    1040   change unless you understand the implications.</td> 
    1041  </tr> 
    1042  <tr valign="top"> 
    1043   <td valign="top">49</td> 
    1044   <td valign="top">vmx_state</td> 
    1045   <td valign="top"></td> 
    1046   <td valign="top">checked, (leave blank to disable)</td> 
    1047   <td valign="top">VmX Locater&trade;</td> 
    1048   <td valign="top">Enable/Disable the VmX Locater feature for this user. When enabled all 
    1049   settings are controlled by the user in the User Portal (ARI). Disabling will 
    1050   not delete any existing user settings but will disable access to the 
    1051   feature</td> 
    1052  </tr> 
    1053  <tr valign="top"> 
    1054   <td valign="top">50</td> 
    1055   <td valign="top">devicetype</td> 
    1056   <td valign="top">fixed</td> 
    1057   <td valign="top">fixed, adhoc</td> 
    1058   <td valign="top"></td> 
    1059   <td valign="top">Extensions require that devicetype is fixed. If devicetype is adhoc, 
    1060   FreePBX must manage it in Device and Users mode, not Extensions mode.</td> 
    1061  </tr> 
    1062  <tr valign="top"> 
    1063   <td valign="top">51</td> 
    1064   <td valign="top">password</td> 
    1065   <td valign="top"></td> 
    1066   <td valign="top"></td> 
    1067   <td valign="top">User Password</td> 
    1068   <td valign="top">A user will enter this password when logging onto a device.</td> 
    1069  </tr> 
    1070  <tr valign="top"> 
    1071   <td valign="top">52</td> 
    1072   <td valign="top">noanswer</td> 
    1073   <td valign="top"></td> 
    1074   <td valign="top"></td> 
    1075   <td valign="top">Defaults to blank.</td> 
    1076  </tr> 
    1077  <tr valign="top"> 
    1078   <td valign="top">53</td> 
    1079   <td valign="top">devinfo_immediate</td> 
    1080   <td valign="top">no</td> 
    1081   <td valign="top"></td> 
    1082   <td valign="top">immediate</td> 
    1083   <td valign="top">See zapata.conf file.</td> 
    1084  </tr> 
    1085  <tr valign="top"> 
    1086   <td valign="top">54</td> 
    1087   <td valign="top">devinfo_signalling</td> 
    1088   <td valign="top">fxo_ks</td> 
    1089   <td valign="top"></td> 
    1090   <td valign="top">signalling</td> 
    1091   <td valign="top">See zapata.conf file.</td> 
    1092  </tr> 
    1093  <tr valign="top"> 
    1094   <td valign="top">55</td> 
    1095   <td valign="top">devinfo_echocancel</td> 
    1096   <td valign="top">yes</td> 
    1097   <td valign="top"></td> 
    1098   <td valign="top">echocancel</td> 
    1099   <td valign="top">See zapata.conf file.</td> 
    1100  </tr> 
    1101  <tr valign="top"> 
    1102   <td valign="top">56</td> 
    1103   <td valign="top">devinfo_echocancelwhenbridged</td> 
    1104   <td valign="top">no</td> 
    1105   <td valign="top"></td> 
    1106   <td valign="top">echocancelwhenbridged</td> 
    1107   <td valign="top">See zapata.conf file.</td> 
    1108  </tr> 
    1109  <tr valign="top"> 
    1110   <td valign="top">57</td> 
    1111   <td valign="top">devinfo_echotraining</td> 
    1112   <td valign="top">800</td> 
    1113   <td valign="top"></td> 
    1114   <td valign="top">echotraining</td> 
    1115   <td valign="top">See zapata.conf file.</td> 
    1116  </tr> 
    1117  <tr valign="top"> 
    1118   <td valign="top">58</td> 
    1119   <td valign="top">devinfo_busydetect</td> 
    1120   <td valign="top">no</td> 
    1121   <td valign="top"></td> 
    1122   <td valign="top">busydetect</td> 
    1123   <td valign="top">See zapata.conf file.</td> 
    1124  </tr> 
    1125  <tr valign="top"> 
    1126   <td valign="top">59</td> 
    1127   <td valign="top">devinfo_busycount</td> 
    1128   <td valign="top">7</td> 
    1129   <td valign="top"></td> 
    1130   <td valign="top">busycount</td> 
    1131   <td valign="top">See zapata.conf file.</td> 
    1132  </tr> 
    1133  <tr valign="top"> 
    1134   <td valign="top">60</td> 
    1135   <td valign="top">devinfo_callprogress</td> 
    1136   <td valign="top">no</td> 
    1137   <td valign="top"></td> 
    1138   <td valign="top">callprogress</td> 
    1139   <td valign="top">See zapata.conf file.</td> 
    1140  </tr> 
    1141  <tr valign="top"> 
    1142   <td valign="top">61</td> 
    1143   <td valign="top">devinfo_notransfer</td> 
    1144   <td valign="top">yes</td> 
    1145   <td valign="top"></td> 
    1146   <td valign="top">notransfer</td> 
    1147   <td valign="top">See iax.conf file.</td> 
    1148  </tr> 
    1149 </table> 
    1150  
    1151723<?php 
     724  print $table_output; 
    1152725} 
    1153726?> 
    1154  
  • contributed_modules/modules/bulkextensions/template.csv

    r6005 r7112  
    1 action,extension,name,cid_masquerade,sipname,directdid,didalert,mohclass,outboundcid,ringtimer,callwaiting,emergency_cid,tech,hardware,devinfo_secret,devinfo_channel,devinfo_dtmfmode,devinfo_canreinvite,devinfo_context,devinfo_host,devinfo_type,devinfo_nat,devinfo_port,devinfo_qualify,devinfo_callgroup,devinfo_pickupgroup,devinfo_disallow,devinfo_allow,devinfo_dial,devinfo_accountcode,devinfo_mailbox,faxexten,faxemail,answer,wait,privacyman,record_in,record_out,vm,vmpwd,email,pager,attach,saycid,envelope,delete,options,vmcontext,vmx_state,devicetype,password,noanswer,devinfo_immediate,devinfo_signalling,devinfo_echocancel,devinfo_echocancelwhenbridged,devinfo_echotraining,devinfo_busydetect,devinfo_busycount,devinfo_callprogress,devinfo_notransfer 
     1action,extension,name,cid_masquerade,sipname,outboundcid,ringtimer,callwaiting,call_screen,emergency_cid,tech,hardware,devinfo_channel,devinfo_secret,devinfo_notransfer,devinfo_dtmfmode,devinfo_canreinvite,devinfo_context,devinfo_immediate,devinfo_signalling,devinfo_echocancel,devinfo_echocancelwhenbrdiged,devinfo_echotraining,devinfo_busydetect,devinfo_busycount,devinfo_callprogress,devinfo_host,devinfo_type,devinfo_nat,devinfo_port,devinfo_qualify,devinfo_callgroup,devinfo_pickupgroup,devinfo_disallow,devinfo_allow,devinfo_dial,devinfo_accoountcode,devinfo_mailbox,devicetype,deviceid,deviceuser,description,dictenabled,dictformat,dictemail,langcode,record_in,record_out,vm,vmpwd,email,pager,attach,saycid,envelope,delete,options,vmcontext,vmx_state,vmx_unavail_enabled,vmx_busy_enabled,vmx_play_instructions,vmx_option_0_sytem_default,vmx_option_0_number,vmx_option_1_system_default,vmx_option_1_number,vmx_option_2_number,account,ddial,pre_ring,strategy,grptime,grplist,annmsg_id,ringing,grppre,dring,needsconf,remotealert_id,toolate_id,postdest 
    22 
    3 add,12345,John Doe,,,,,default,,0,enabled,,sip,,1234,,rfc2833,no,from-internal,dynamic,friend,yes,5060,yes,,,,,,,12345@default,default,,0,0,0,Adhoc,Adhoc,enabled,123456789,jdoe@nowhere.fast.net,PagerA12345@nowhere.fast.net,attach=no,saycid=no,envelope=no,delete=no,,default,,fixed,,,,,,,,,,, 
    4 add,12345,John Doe,,,,,default,,0,enabled,,iax2,,1234,,,,from-internal,dynamic,friend,,4569,yes,,,,,,,12345@default,default,,0,0,0,Adhoc,Adhoc,enabled,123456789,jdoe@nowhere.fast.net,PagerA12345@nowhere.fast.net,attach=no,saycid=no,envelope=no,delete=no,,default,,fixed,,,,,,,,,,,yes 
    5 add,12345,John Doe,,,,,default,,0,enabled,,zap,,,1,,,from-internal,,,,,,,,,,,,12345@default,default,,0,0,0,Adhoc,Adhoc,enabled,123456789,jdoe@nowhere.fast.net,PagerA12345@nowhere.fast.net,attach=no,saycid=no,envelope=no,delete=no,,default,,fixed,,,no,fxo_ks,yes,no,800,no,7,no, 
     3edit,999999,John Doe,999999,,,0,enabled,0,,sip,,,1234,,rfc2833,no,from-internal,,,,,,,,,dynamic,friend,yes,5060,yes,,,,,SIP/999999,,999999@device,fixed,,999999,John Doe,disabled,ogg,,,Adhoc,Adhoc,enabled,1234,j.doe@foo.bar,j.doe.pager@foo.bar,attach=no,saycid=no,envelope=no,delete=no,,default,,,,,checked,,,,,999999,CHECKED,0,ringallv2,20,999999-552244,2,Ring,TEST,,CHECKED,0,0,"ext-local,vmu552244,1" 
     4edit,123456,Jane Doe,1234,"sipalias,man",SUPPORT <1234>,8,enabled,memory,411,iax2,,,1234,yes,,,from-internal,,,,,,,,,dynamic,friend,,4569,yes,,,,,IAX2/123456,,123456@device,fixed,,123456,Jane Doe,disabled,ogg,,en,Adhoc,Adhoc,enabled,1234,j.doe@foo.bar,j.doe.pager@foo.bar,attach=yes,saycid=no,envelope=yes,delete=yes,review=yes,default,checked,checked,checked,checked,checked,,,27328,27329,,,,,,,,,,,,,, 
     5edit,654321,Jorge Doe,654321,,,0,enabled,0,,zap,,5001,,,,,from-internal,no,fxo_ks,yes,,800,no,7,no,,,,,,,,,,ZAP/5001,,654321@device,fixed,,654321,Jorge Doe,disabled,ogg,,,Adhoc,Adhoc,enabled,1234,,,attach=no,saycid=no,envelope=no,delete=no,,default,checked,,,,,70904,,,,654321,CHECKED,13,hunt,25,654321-27346-123456-999999,2,default,,,CHECKED,2,2,"app-blackhole,zapateller,1" 
    66 
    7 del,12345,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 
    87 
    9 edit,12345,John Doe,,,,,default,,0,enabled,,sip,,1234,,rfc2833,no,from-internal,dynamic,friend,yes,5060,yes,,,,,,,12345@default,default,,0,0,0,Adhoc,Adhoc,enabled,123456789,jdoe@nowhere.fast.net,PagerA12345@nowhere.fast.net,attach=no,saycid=no,envelope=no,delete=no,,default,,fixed,,,,,,,,,,, 
    10 edit,12345,John Doe,,,,,default,,0,enabled,,iax2,,1234,,,,from-internal,dynamic,friend,,4569,yes,,,,,,,12345@default,default,,0,0,0,Adhoc,Adhoc,enabled,123456789,jdoe@nowhere.fast.net,PagerA12345@nowhere.fast.net,attach=no,saycid=no,envelope=no,delete=no,,default,,fixed,,,,,,,,,,,yes 
    11 edit,12345,John Doe,,,,,default,,0,enabled,,zap,,,1,,,from-internal,,,,,,,,,,,,12345@default,default,,0,0,0,Adhoc,Adhoc,enabled,123456789,jdoe@nowhere.fast.net,PagerA12345@nowhere.fast.net,attach=no,saycid=no,envelope=no,delete=no,,default,,fixed,,,no,fxo_ks,yes,no,800,no,7,no, 
     8add,999999,John Doe,999999,,,0,enabled,0,,sip,,,1234,,rfc2833,no,from-internal,,,,,,,,,dynamic,friend,yes,5060,yes,,,,,SIP/999999,,999999@device,fixed,,999999,John Doe,disabled,ogg,,,Adhoc,Adhoc,enabled,1234,j.doe@foo.bar,j.doe.pager@foo.bar,attach=no,saycid=no,envelope=no,delete=no,,default,,,,,checked,,,,,999999,CHECKED,0,ringallv2,20,999999-552244,2,Ring,TEST,,CHECKED,0,0,"ext-local,vmu552244,1" 
     9add,123456,Jane Doe,1234,"sipalias,man",SUPPORT <1234>,8,enabled,memory,411,iax2,,,1234,yes,,,from-internal,,,,,,,,,dynamic,friend,,4569,yes,,,,,IAX2/123456,,123456@device,fixed,,123456,Jane Doe,disabled,ogg,,en,Adhoc,Adhoc,enabled,1234,j.doe@foo.bar,j.doe.pager@foo.bar,attach=yes,saycid=no,envelope=yes,delete=yes,review=yes,default,checked,checked,checked,checked,checked,,,27328,27329,,,,,,,,,,,,,, 
     10add,654321,Jorge Doe,654321,,,0,enabled,0,,zap,,5001,,,,,from-internal,no,fxo_ks,yes,,800,no,7,no,,,,,,,,,,ZAP/5001,,654321@device,fixed,,654321,Jorge Doe,disabled,ogg,,,Adhoc,Adhoc,enabled,1234,,,attach=no,saycid=no,envelope=no,delete=no,,default,checked,,,,,70904,,,,654321,CHECKED,13,hunt,25,654321-27346-123456-999999,2,default,,,CHECKED,2,2,"app-blackhole,zapateller,1" 
    1211 
     12 
     13del,999999 
     14del,123456 
     15del,654321 
     16