Changeset 11299

Show
Ignore:
Timestamp:
02/05/11 18:01:45 (2 years ago)
Author:
pnlarsson
Message:

Added instead of hardcoded settings. Added some images, re #4688

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • contributed_modules/modules/extcfg/astman.inc

    r7577 r11299  
    279279  } 
    280280} 
    281 ?>  
  • contributed_modules/modules/extcfg/functions.inc.php

    r7577 r11299  
    2626define("CFIM", "CF"); 
    2727define("YAC", "YAC"); 
     28define("DND", "DND"); 
    2829 
    2930require("astman.inc"); 
    3031 
    3132function extcfg_init(){ 
    32   global $server; 
     33  global $server, $amp_conf; 
     34 
    3335/*  mysql_connect('localhost', 'asteriskuser', 'amp109') or die ("Could not connect to MySQL"); 
    3436  mysql_select_db('asterisk') or die ("Could not select asterisk database" . mysql_error());   
     
    5153    $i++; 
    5254  } 
     55 
    5356  */ 
    5457   
    5558  $server[] = array( 
    56    "db_host" => "localhost"
    57    "db_user" => "asteriskuser"
    58    "db_passwd" => "amp109",  
    59    "db_db" => "asterisk"
    60    "astman_host" => "localhost"
    61    "astman_user" => "admin",  
    62    "astman_passwd" => "amp111",  
    63    "name" => "mlin1", 
     59   "db_host" => $amp_conf['AMPDBHOST']
     60   "db_user" => $amp_conf['AMPDBUSER']
     61   "db_passwd" => $amp_conf['AMPDBPASS'],  
     62   "db_db" => $amp_conf['AMPDBNAME']
     63   "astman_host" => 'localhost'
     64   "astman_user" => $amp_conf['AMPMGRUSER'],  
     65   "astman_passwd" => $amp_conf['AMPMGRPASS'],  
     66   "name" => "localhost", 
    6467   "astman" => new AstMan 
    6568  ); 
     
    110113  sort($exts); 
    111114   
    112   echo "<table border='0' cellspacing='0' cellpadding='3'><tr><th>Ext</th><th>DND</th><th>Call<br>Waiting</th><th>Call Forward<br>All</th><th>Call Forward<br>Busy</th><th>Call Forward<br>No Answer</th><th>IP</th><th>port</th><th>Status</th><th>Device</th><th>Tech</th></tr>"; 
     115  echo "<table border='0' cellspacing='0' cellpadding='3' style=''><tr><th></th><th>Extension</th><th>DND</th><th>Call<br>Waiting</th><th>Call Forward<br>All</th><th>Call Forward<br>Busy</th><th>Call Forward<br>No Answer</th><th>IP</th><th>port</th><th>Status</th><th>Device</th><th>Tech</th></tr>"; 
    113116 
    114117  foreach($exts as $ext){ 
    115     $status_bg = $status_arr[$ext[0]]['ok'] ? '#8f8' : '#f88'; 
     118    $status_bg = $status_arr[$ext[0]]['ok'] ? '#88ff88' : '#ff8888'; 
     119  $dnd_f = empty($dnd[$ext[1]][$ext[0]]) ? '' : '<img src="/admin/images/accept.png" border="0">'; 
     120  $cw_f = ''; 
     121  if(!empty($cw[$ext[1]][$ext[0]])){ 
     122    if($cw[$ext[1]][$ext[0]] == 'ENABLED'){ 
     123      $cw_f = '<img src="/admin/images/accept.png" border="0">'; 
     124    } 
     125  } 
     126  $cfim_f = empty($cfim[$ext[1]][$ext[0]]) ? '' : $cfim[$ext[1]][$ext[0]]; 
     127  $cfbs_f = empty($cfbs[$ext[1]][$ext[0]]) ? '' : $cfbs[$ext[1]][$ext[0]]; 
     128  $cfna_f = empty($cfna[$ext[1]][$ext[0]]) ? '' : $cfna[$ext[1]][$ext[0]]; 
     129  $ip = empty($status_arr[$ext[0]]['ip']) ? '' : $status_arr[$ext[0]]['ip']; 
     130  $port = empty($status_arr[$ext[0]]['port']) ? '' : $status_arr[$ext[0]]['port']; 
     131  $status = empty($status_arr[$ext[0]]['status']) ? '' : $status_arr[$ext[0]]['status']; 
     132  $device = empty($status_arr[$ext[0]]['device']) ? '' : $status_arr[$ext[0]]['device']; 
     133  $type = empty($status_arr[$ext[0]]['type']) ? '' : $status_arr[$ext[0]]['type']; 
    116134    echo "<tr bgcolor='" . varBg($i++) . "'> 
    117       <td><a href='" . $PHP_SELF . "?display=extcfg&type=tool&action=phone&phone={$ext[0]}&srv={$ext[1]}'>{$ext[0]}</a></td> 
    118       <td>{$dnd[$ext[1]][$ext[0]]}&nbsp;</td> 
    119       <td>{$cw[$ext[1]][$ext[0]]}&nbsp;</td> 
    120       <td>{$cfim[$ext[1]][$ext[0]]}&nbsp;</td> 
    121       <td>{$cfbs[$ext[1]][$ext[0]]}&nbsp;</td> 
    122       <td>{$cfna[$ext[1]][$ext[0]]}&nbsp;</td> 
    123       <td>{$status_arr[$ext[0]]['ip']}</td> 
    124       <td>{$status_arr[$ext[0]]['port']}</td> 
    125       <td style='background-color: $status_bg;'>{$status_arr[$ext[0]]['status']}</td> 
    126       <td>{$status_arr[$ext[0]]['device']}</td> 
    127       <td>{$status_arr[$ext[0]]['type']}</td> 
     135      <td><a href='/admin/config.php?type=setup&display=extensions&extdisplay={$ext[0]}'><img src='/admin/images/telephone_edit.png' border=0 title='Edit extension'></a></td> 
     136      <td><a href='" . $_SERVER['PHP_SELF'] . "?display=extcfg&type=tool&action=phone&phone={$ext[0]}&srv={$ext[1]}'>{$ext[0]} - {$ext[2]}</a></td> 
     137      <td style='text-align: center;'>$dnd_f&nbsp;</td> 
     138      <td style='text-align: center;'>$cw_f&nbsp;</td> 
     139      <td>$cfim_f&nbsp;</td> 
     140      <td>$cfbs_f&nbsp;</td> 
     141      <td>$cfna_f&nbsp;</td> 
     142      <td>$ip</td> 
     143      <td>$port</td> 
     144      <td style='background-color: $status_bg;'>$status</td> 
     145      <td>$device</td> 
     146      <td>$type</td> 
    128147    </tr>"; 
    129148  } 
     
    194213  $serv = $server[$srv]; 
    195214 
    196 /*  if ($_REQUEST["YAC"]) 
    197     $serv['astman']->PutDB(YAC, $ext, $_REQUEST["YAC"]); 
    198   else 
    199     $serv['astman']->DelDB(YAC, $ext);    */ 
    200   if ($_REQUEST["DND"]) 
     215  if (isset($_REQUEST["DND"])) 
    201216    $serv['astman']->PutDB(DND, $ext, "YES"); 
    202217  else 
    203218    $serv['astman']->DelDB(DND, $ext);     
    204   if ($_REQUEST["CW"]
     219  if (isset($_REQUEST["CW"])
    205220    $serv['astman']->PutDB(CW, $ext, "ENABLED"); 
    206221  else 
    207222    $serv['astman']->DelDB(CW, $ext);     
    208   if ($_REQUEST["CFBS"]
     223  if (!empty($_REQUEST["CFBS"])
    209224    $serv['astman']->PutDB(CFBS, $ext, $_REQUEST["CFBS"]); 
    210225  else 
    211226    $serv['astman']->DelDB(CFBS, $ext);     
    212   if ($_REQUEST["CFIM"]
     227  if (!empty($_REQUEST["CFIM"])
    213228    $serv['astman']->PutDB(CFIM, $ext, $_REQUEST["CFIM"]); 
    214229  else 
    215230    $serv['astman']->DelDB(CFIM, $ext);     
    216   if ($_REQUEST["CFNA"]
     231  if (!empty($_REQUEST["CFNA"])
    217232    $serv['astman']->PutDB(CFNA, $ext, $_REQUEST["CFNA"]); 
    218233  else 
     
    224239  $exts = array(); 
    225240 
    226   $sql = "SELECT id FROM devices d WHERE LENGTH(id) < 6 ORDER BY CAST(id AS UNSIGNED);"; 
    227   $sql_iax = "SELECT id,data FROM iax WHERE keyword = 'callerid' ORDER BY id"; 
    228   $sql_sip = "SELECT id,data FROM sip WHERE keyword = 'callerid' ORDER BY id"; 
    229   $sql_zap = "SELECT id,data FROM zap WHERE keyword = 'callerid' ORDER BY id"; 
     241  $sql = "SELECT id, description FROM devices d ORDER BY CAST(id AS UNSIGNED);"; 
    230242   
    231243  mysql_connect($server, $user, $passwd) or die ("Could not connect to MySQL"); 
    232244  mysql_select_db($db) or die ("Could not select $db database");   
    233245   
    234  $result = mysql_query($sql) or die ("Query failed"); 
     246  $result = mysql_query($sql) or die ("Query failed"); 
    235247  while ($kolumn = mysql_fetch_array($result)) { 
    236     $exts[] = array($kolumn["id"], $astman_nr); 
     248    $exts[] = array($kolumn["id"], $astman_nr, $kolumn['description']); 
    237249  } 
    238250   
    239251  return ($exts);  
    240    
    241   $result = mysql_query($sql_iax) or die ("IAX Query failed"); 
    242   while ($kolumn = mysql_fetch_array($result)) { 
    243     $exts[] = array($kolumn["id"],$astman_nr); 
    244   } 
    245    
    246   $result = mysql_query($sql_sip) or die ("SIP Query failed"); 
    247   while ($kolumn = mysql_fetch_array($result)) { 
    248     $exts[] = array($kolumn["id"],$astman_nr); 
    249   } 
    250    
    251   $result = mysql_query($sql_zap) or die ("ZAP Query failed"); 
    252   while ($kolumn = mysql_fetch_array($result)) { 
    253     $exts[] = array($kolumn["id"],$astman_nr); 
    254   } 
    255   sort($exts); 
    256   return ($exts); 
    257252} 
    258253 
     
    336331    $sep = trim(substr($sccp_device, -27, 16)); 
    337332    $ip = trim(substr($sccp_device, -43, 15)); 
    338     $extension = $sccp_sep_arr[$sep]; 
     333    $extension = empty($sccp_sep_arr[$sep]) ? null : $sccp_sep_arr[$sep]; 
    339334    $ok = $sep == '--' ? false : true; 
    340335    if ($extension){ 
     
    346341   
    347342  $mgcp_endpoints_res = $astman->Query("Action: Command\r\nCommand: mgcp show endpoints\r\n\r\n"); 
     343 
     344  if (strpos($mgcp_endpoints_res, 'Gateway')){ 
    348345   
    349346  $mgcp_endpoints = get_astman_lines($mgcp_endpoints_res); 
    350347  unset($mgcp_endpoints[0]); 
    351    
     348 
    352349  foreach($mgcp_endpoints as $mgcp_endpoint){ 
    353350    $extension = ''; 
     
    377374    } 
    378375  } 
     376  } 
    379377   
    380378  return $arr;   
     
    394392function varBg($i = 0){ 
    395393  if($i%2 == 0) 
    396     return '#fff'; 
     394    return '#ffffff'; 
    397395  else 
    398     return '#eee'; 
     396    return '#eeeeee'; 
    399397} 
    400398?>