Changeset 3376

Show
Ignore:
Timestamp:
12/19/06 19:06:06 (6 years ago)
Author:
gregmac
Message:

Merged revisions 3372-3373 via svnmerge from
https://svn.sourceforge.net/svnroot/amportal/freepbx/trunk

........

r3372 | gregmac | 2006-12-19 18:12:57 -0500 (Tue, 19 Dec 2006) | 5 lines


drawselects() updated:

  • removed usage of goto_indicate and 'goto' hidden field,
  • it's no longer possible to have no options selected
  • Now supports a 'category' value in the destinations hook, which overrides the module name and allows modules to add destinations to any radio/select box combo (instead of being limited to their own name)

........

r3373 | gregmac | 2006-12-19 18:14:17 -0500 (Tue, 19 Dec 2006) | 1 line


Updated tooltip for custom destination

........

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freepbx/branches/2.2

    • Property svnmerge-integrated changed from /freepbx/trunk:1-3224,3231,3245-3246,3300-3302,3312,3315,3336,3338,3341-3347,3349,3351,3353,3367-3368,3370 to /freepbx/trunk:1-3224,3231,3245-3246,3300-3302,3312,3315,3336,3338,3341-3347,3349,3351,3353,3367-3368,3370,3372-3373
  • freepbx/branches/2.2/amp_conf/htdocs/admin/functions.inc.php

    r3350 r3376  
    615615  global $active_modules; 
    616616   
    617   // This is purely to remove a warning.  
    618   if (!isset($selectHtml)) { $selectHtml=''; } 
    619   $selectHtml .= '<tr><td colspan=2>';  
     617  $all_destinations = array(); 
     618 
     619  $selectHtml = '<tr><td colspan=2>';  
    620620   
    621621  //check for module-specific destination functions 
    622   foreach ($active_modules as $mod => $displayname) { 
    623     $funct = strtolower($mod.'_destinations'); 
     622  foreach ($active_modules as $rawmod => $module) { 
     623    $funct = strtolower($rawmod.'_destinations'); 
    624624   
    625625    //if the modulename_destinations() function exits, run it and display selections for it 
    626626    if (function_exists($funct)) { 
    627       $options = ""; 
    628       $destArray = $funct(); //returns an array with 'destination' and 'description'. 
    629       $checked = false; 
    630       if (isset($destArray)) { 
    631         //loop through each option returned by the module 
     627      $destArray = $funct(); //returns an array with 'destination' and 'description', and optionally 'category' 
     628      if (is_Array($destArray)) { 
    632629        foreach ($destArray as $dest) { 
    633           // check to see if the currently selected goto matches one these destinations 
    634           if ($dest['destination'] == $goto) 
    635             $checked = true;  //there is a match, so we select the radio for this group 
    636  
    637           // create an select option for each destination  
    638           $options .= '<option value="'.$dest['destination'].'" '.(strpos($goto,$dest['destination']) === false ? '' : 'SELECTED').'>'.($dest['description'] ? $dest['description'] : $dest['destination']); 
    639         } 
    640          
    641         // make a unique id to be used for the HTML id 
    642         // This allows us to have multiple drawselect() sets on the page without 
    643         // conflicting with each other 
    644         $radioid = uniqid("drawselect"); 
    645          
    646         $selectHtml .=  '<input type="radio" id="'.$radioid.'" name="goto_indicate'.$i.'" value="'.$mod.'" '. 
    647                 'onclick="javascript:this.form.goto'.$i.'.value=\''.$mod.'\';" '. 
    648                 'onkeypress="javascript:if (event.keyCode == 0 || (document.all && event.keyCode == 13)) this.form.goto'.$i.'.value=\''.$mod.'\';" '. 
    649                 ($checked? 'CHECKED=CHECKED' : '').' /> '; 
    650         $selectHtml .= '<label for="'.$radioid.'">'._($displayname['displayname']).':</label> '; 
    651         if ($checked) { $gotomod = $mod; } 
    652         $selectHtml .=  '<select name="'.$mod.$i.'" onfocus="document.getElementById(\''.$radioid.'\').checked = true; this.form.goto'.$i.'.value=\''.$mod.'\';">'; 
    653         $selectHtml .= $options;   
    654         $selectHtml .=  "</select><br>\n"; 
    655       } 
    656        
    657     } 
     630          $cat = (isset($dest['category']) ? $dest['category'] : $module['displayname']); 
     631          $all_destinations[$cat][] = $dest; 
     632        } 
     633      } 
     634    } 
     635  } 
     636//  var_dump($all_destinations); 
     637//  var_dump($goto); 
     638 
     639  $foundone = false; 
     640  foreach ($all_destinations as $cat=>$destination) { 
     641    // create a select option for each destination  
     642    $options = ""; 
     643    $checked = false; 
     644    foreach ($destination as $dest) { 
     645      $options .= '<option value="'.$dest['destination'].'" '.(strpos($goto,$dest['destination']) === false ? '' : 'SELECTED').'>'.($dest['description'] ? $dest['description'] : $dest['destination']); 
     646 
     647      // check to see if the currently selected goto matches one these destinations 
     648      if($dest['destination'] == $goto) $checked = true; 
     649    } 
     650 
     651    // make a unique id to be used for the HTML id 
     652    // This allows us to have multiple drawselect() sets on the page without 
     653    // conflicting with each other 
     654    $radioid = uniqid("drawselect"); 
     655    // 
     656    $cat_identifier = preg_replace('/[^a-zA-Z0-9]/','_', $cat); 
     657       
     658    $selectHtml .=  '<input type="radio" id="'.$radioid.'" name="goto'.$i.'" value="'.$cat_identifier.'" '. 
     659                    //'onclick="javascript:this.form.goto'.$i.'.value=\''.$cat.'\';" '. 
     660                    //'onkeypress="javascript:if (event.keyCode == 0 || (document.all && event.keyCode == 13)) this.form.goto'.$i.'.value=\''.$cat.'\';" '. 
     661                    ($checked? 'CHECKED=CHECKED' : '').' /> '; 
     662    $selectHtml .= '<label for="'.$radioid.'">'._($cat).':</label> '; 
     663     
     664    // set the  
     665//    if ($checked) { $gotomod = $cat; }  
     666 
     667    $selectHtml .=  '<select name="'.$cat_identifier.$i.'" onfocus="document.getElementById(\''.$radioid.'\').checked = true; this.form.goto'.$i.'.value=\''.$cat.'\';">'; 
     668    $selectHtml .= $options;   
     669    $selectHtml .=  "</select><br>\n"; 
     670 
     671    if ($checked) $foundone = true; 
    658672  } 
    659673  /* --- MODULES END --- */ 
     674   
     675  // This is selected if $foundone is false (and goto is not blank) - basically, a fallback 
     676  // The ONLY time no radio box is selected is if $goto is empty 
     677  $custom_selected = !$foundone && !empty($goto); 
    660678   
    661679  //display a custom goto field 
    662680  $radioid = uniqid("drawselect"); 
    663   $selectHtml .= '<input type="radio" id="'.$radioid.'" name="goto_indicate'.$i.'" value="custom" onclick="javascript:this.form.goto'.$i.'.value=\'custom\';" onkeypress="javascript:if (event.keyCode == 0 || (document.all && event.keyCode == 13)) this.form.goto'.$i.'.value=\'custom\';" '.(strpos($goto,'custom') === false ? '' : 'CHECKED=CHECKED').' />'; 
    664   $selectHtml .= '<a href="#" class="info"> '._("Custom App<span><br>ADVANCED USERS ONLY<br><br>Uses Goto() to send caller to a custom context.<br><br>The context name <b>MUST</b> contain the word 'custom' and should be in the format custom-context , extension , priority. Example entry:<br><br><b>custom-myapp,s,1</b><br><br>The <b>[custom-myapp]</b> context would need to be created and included in extensions_custom.conf</span>").'</a>:'; 
    665   $selectHtml .= '<input type="text" size="15" name="custom'.$i.'" value="'.(strpos($goto,'custom') === false ? '' : $goto).'" onfocus="document.getElementById(\''.$radioid.'\').checked = true;" />'; 
    666   $gotomod = isset($gotomod)?$gotomod:'custom'; 
    667   $selectHtml .= "\n<input type='hidden' name='goto$i' value='$gotomod'>"; 
     681  $selectHtml .= '<input type="radio" id="'.$radioid.'" name="goto'.$i.'" value="custom" '. 
     682                 //'onclick="javascript:this.form.goto'.$i.'.value=\'custom\';" '. 
     683           //'onkeypress="javascript:if (event.keyCode == 0 || (document.all && event.keyCode == 13)) this.form.goto'.$i.'.value=\'custom\';" '. 
     684           ($custom_selected ? 'CHECKED=CHECKED' : '').' />'; 
     685  $selectHtml .= '<a href="#" class="info"> '._("Custom App<span><br>ADVANCED USERS ONLY<br><br>Uses Goto() to send caller to a custom context.<br><br>The context name should start with \"custom-\", and be in the format custom-context,extension,priority. Example entry:<br><br><b>custom-myapp,s,1</b><br><br>The <b>[custom-myapp]</b> context would need to be created and included in extensions_custom.conf</span>").'</a>:'; 
     686  $selectHtml .= '<input type="text" size="15" name="custom'.$i.'" value="'.($custom_selected ? $goto : '').'" onfocus="document.getElementById(\''.$radioid.'\').checked = true;" />'; 
    668687 
    669688  //close off our row 
     
    21672186        redirect($url, false); 
    21682187} 
     2188 
    21692189?>