Changeset 1881

Show
Ignore:
Timestamp:
05/06/06 15:37:59 (7 years ago)
Author:
mheydon1973
Message:

Added ability to use a FeatureCode? without having to type the featurecode digits, which obviously could be changed

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/2.1/miscdests/functions.inc.php

    r1565 r1881  
    2525    case "asterisk": 
    2626      $contextname = 'ext-miscdests'; 
     27      $fctemplate = '/\{(.+)\:(.+)\}/'; 
     28       
    2729      if(is_array($destlist = miscdests_list())) { 
    2830         
     
    3436          $miscdialdest = $miscdest['destdial']; 
    3537 
     38          // exchange {mod:fc} for the relevent feature codes in $miscdialdest 
     39          $miscdialdest = preg_replace_callback($fctemplate, "miscdests_lookupfc", $miscdialdest); 
     40 
     41          // write out the dialplan details 
    3642          $ext->add($contextname, $miscid, '', new ext_noop('MiscDest: '.$miscdescription)); 
    3743          $ext->add($contextname, $miscid, '', new ext_dial('Local/'.$miscdialdest.'@from-internal', '')); 
     
    7480} 
    7581 
     82function miscdests_lookupfc($matches) { 
     83  $modulename = $matches[1]; 
     84  $featurename = $matches[2]; 
     85 
     86  $fcc = new featurecode($modulename, $featurename); 
     87  $fc = $fcc->getCodeActive(); 
     88  return $fc; 
     89} 
    7690?> 
  • modules/branches/2.1/miscdests/module.xml

    r1854 r1881  
    22  <rawname>miscdests</rawname> 
    33  <name>Misc Destinations</name> 
    4   <version>1.0</version> 
     4  <version>1.1.0</version> 
    55  <type>setup</type> 
    66  <category>Basic</category> 
  • modules/branches/2.1/miscdests/page.miscdests.php

    r1565 r1881  
    3333} 
    3434 
    35 //get meetme rooms 
    36 //this function needs to be available to other modules (those that use goto destinations) 
    37 //therefore we put it in globalfunctions.php 
    3835$miscdests = miscdests_list(); 
     36 
     37// Make array of feature code for <SELECT> list 
     38$featurecodes = featurecodes_getAllFeaturesDetailed(); 
     39if (isset($featurecodes)) { 
     40  foreach ($featurecodes as $item) { 
     41    $moduledesc = _($item['moduledescription']); 
     42    $moduleena = ($item['moduleenabled'] == 1 ? true : false); 
     43    if ($moduleena) { 
     44      $featureena = ($item['featureenabled'] == 1 ? true : false); 
     45      if ($featureena) { 
     46        $featureid = $item['modulename'] . ':' . $item['featurename']; 
     47        $featuredesc = _($item['featuredescription']); 
     48         
     49        $featurecodedefault = (isset($item['defaultcode']) ? $item['defaultcode'] : ''); 
     50        $featurecodecustom = (isset($item['customcode']) ? $item['customcode'] : ''); 
     51        $featureactualcode = ($featurecodecustom != '' ? $featurecodecustom : $featurecodedefault); 
     52         
     53        $fclist[$featureid] = $featuredesc; 
     54      } 
     55    } 
     56  } 
     57  asort($fclist); 
     58} 
     59 
    3960?> 
    4061 
     
    6384    $thisMiscDest = miscdests_get($extdisplay); 
    6485    //create variables 
     86    $description = ""; 
     87    $destdial = ""; 
    6588    extract($thisMiscDest); 
    6689  } 
     
    91114  <tr> 
    92115    <td><a href="#" class="info"><?php echo _("dial:")?><span><?php echo _("Enter the digits to dial for this Misc Destination.")?></span></a></td> 
    93     <td><input type="text" name="destdial" value="<?php echo (isset($destdial) ? $destdial : ''); ?>"></td> 
     116    <td> 
     117      <input type="text" name="destdial" value="<?php echo (isset($destdial) ? $destdial : ''); ?>">&nbsp;&nbsp; 
     118      <?php if (isset($fclist)) { ?> 
     119      <select id="fc" onchange="fc_onchange();"> 
     120      <option value="">--<?php echo _("featurecode"); ?>--</option> 
     121      <?php 
     122      foreach ($fclist as $fckey => $fcdesc) { 
     123        ?> 
     124        <option value="{<?php echo $fckey; ?>}"><?php echo _($fcdesc); ?></option> 
     125        <?php 
     126      } 
     127      ?> 
     128      </select> 
     129      <?php } ?> 
     130    </td> 
    94131  </tr> 
    95132 
    96133   
    97134  <tr> 
    98     <td colspan="2"><br><h6><input name="Submit" type="submit" value="<?php echo _("Submit Changes")?>"></h6></td>     
     135    <td colspan="2"><br><h6><input name="Submit" type="submit" value="<?php echo _("Submit Changes")?>"></h6> 
     136    </td> 
    99137  </tr> 
    100138  </table> 
     
    118156  if (!isAlphanumeric(theForm.description.value)) 
    119157    return warnInvalid(theForm.description, msgInvalidDescription); 
     158 
     159  // go thru text and remove the {} bits so we only check the actual dial digits 
     160  var fldText = theForm.destdial.value; 
     161  var chkText = ""; 
     162   
     163  if ( (fldText.indexOf("{") > -1) && (fldText.indexOf("}") > -1) ) { // has one or more sets of {mod:fc} 
    120164     
    121   if (!isDialDigits(theForm.destdial.value)) 
     165    var inbraces = false; 
     166    for (var i=0; i<fldText.length; i++) { 
     167      if ( (fldText.charAt(i) == "{") && (inbraces == false) ) { 
     168        inbraces = true; 
     169      } else if ( (fldText.charAt(i) == "}") && (inbraces == true) ) { 
     170        inbraces = false; 
     171      } else if ( inbraces == false ) { 
     172        chkText += fldText.charAt(i); 
     173      } 
     174    } 
     175     
     176    // if there is nothing in chkText but something in fldText 
     177    // then the field must contain a featurecode only, therefore 
     178    // there really is something in thre! 
     179    if ( (chkText == "") & (fldText != "") ) 
     180      chkText = "0"; 
     181       
     182  } else { 
     183    chkText = fldText; 
     184  } 
     185  // now do the check using the chkText var made above 
     186  if (!isDialDigits(chkText)) 
    122187    return warnInvalid(theForm.destdial, msgInvalidDial); 
    123    
     188   
    124189  return true; 
    125190} 
    126191 
     192function fc_onchange() { 
     193  theForm.destdial.value = theForm.fc.value; 
     194  theForm.fc.selectedIndex = 0; 
     195} 
    127196//--> 
    128197</script>