Changeset 8693 for modules/branches

Show
Ignore:
Timestamp:
01/27/10 03:01:24 (3 years ago)
Author:
p_lindheimer
Message:

added destination registry functions and fixed insert bug introduced in previous checkin re #4007

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/2.7/fax/functions.inc.php

    r8688 r8693  
    11<?php  
    22/* $Id */ 
     3 
     4function fax_getdest($exten) { 
     5  return array("ext-fax,$exten,1"); 
     6} 
     7 
     8function fax_getdestinfo($dest) { 
     9  global $amp_conf; 
     10  if (substr(trim($dest),0,8) == 'ext-fax,') { 
     11    $usr = explode(',',$dest); 
     12    $usr = $usr[1]; 
     13    $thisusr = fax_get_user($usr); 
     14    if (empty($thisusr)) { 
     15      return array(); 
     16    } else { 
     17      $display = ($amp_conf['AMPEXTENSIONS'] == "deviceanduser")?'users':'extensions'; 
     18      return array('description' => sprintf(_("Fax user %s"),$usr), 
     19                   'edit_url' => 'config.php?display='.$display.'&extdisplay='.urlencode($usr), 
     20                  ); 
     21    } 
     22  } else { 
     23    return false; 
     24  } 
     25} 
     26 
     27function fax_check_destinations($dest=true) { 
     28  global $active_modules; 
     29 
     30  $destlist = array(); 
     31  if (is_array($dest) && empty($dest)) { 
     32    return $destlist; 
     33  } 
     34  $sql = "SELECT a.extension, a.cidnum, b.description, a.destination FROM fax_incoming a JOIN incoming b "; 
     35  $sql .= "WHERE a.extension = b.extension AND a.cidnum = b.cidnum AND a.legacy_email IS NULL "; 
     36  if ($dest !== true) { 
     37    $sql .= "AND a.destination in ('".implode("','",$dest)."') "; 
     38  } 
     39  $sql .= "ORDER BY extension, cidnum"; 
     40  $results = sql($sql,"getAll",DB_FETCHMODE_ASSOC); 
     41 
     42  //$type = isset($active_modules['announcement']['type'])?$active_modules['announcement']['type']:'setup'; 
     43 
     44  foreach ($results as $result) { 
     45    $thisdest = $result['destination']; 
     46    $thisid   = $result['extension'].'/'.$result['cidnum']; 
     47    $destlist[] = array( 
     48      'dest' => $thisdest, 
     49      'description' => sprintf(_("Inbound Fax Detection: %s (%s)"),$result['description'],$thisid), 
     50      'edit_url' => 'config.php?display=did&extdisplay='.urlencode($thisid), 
     51    ); 
     52  } 
     53  return $destlist; 
     54} 
    355 
    456function fax_applyhooks() { 
     
    3183    }elseif($fax['module'] == 'res_fax' && $fax['license'] < 1){//missing licese 
    3284      $currentcomponent->addguielem($section, new gui_label('error',_('<font color="red">'._('ERROR: Fax license missing! Fax-related dialplan will <strong>NOT</strong> be generated! Please contact your vendor for more information.').'</font>'))); 
     85    } 
     86    $usage_list = framework_display_destination_usage(fax_getdest($extdisplay)); 
     87    if (!empty($usage_list)) { 
     88      $currentcomponent->addguielem('_top', new gui_link_label('faxdests', "&nbsp;Fax".$usage_list['text'], $usage_list['tooltip'], true), 5); 
    3389    } 
    3490     
     
    418474function fax_save_incoming($cidnum,$extension,$enabled,$detection,$detectionwait,$dest,$legacy_email){ 
    419475  global $db; 
    420   sql("INSERT INTO fax_incoming (cidnum, extension, detection, detectionwait, destination, legacy_email) VALUES ('".$db->escapeSimple($cidnum)."', '".$db->escapeSimple($extension)."', '".$db->escapeSimple($detection)."', '".$db->escapeSimple($detectionwait)."', '".$db->escapeSimple($dest)."','".$db->escapeSimple($legacy_email)."')"); 
     476  $legacy_email =  $legacy_email === null ? 'NULL' : "'".$db->escapeSimple("$legacy_email")."'"; 
     477  sql("INSERT INTO fax_incoming (cidnum, extension, detection, detectionwait, destination, legacy_email) VALUES ('".$db->escapeSimple($cidnum)."', '".$db->escapeSimple($extension)."', '".$db->escapeSimple($detection)."', '".$db->escapeSimple($detectionwait)."', '".$db->escapeSimple($dest)."',".$legacy_email.")"); 
    421478} 
    422479