Changeset 5389

Show
Ignore:
Timestamp:
12/10/07 14:01:40 (5 years ago)
Author:
p_lindheimer
Message:

add default vmblast group with auto-add from extensions/users, change to multi-select list, fix js validation allowing empty lists

Files:

Legend:

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

    r5381 r5389  
    5050      $ext->addInclude('from-internal-additional','vmblast-grp'); 
    5151      $contextname = 'vmblast-grp'; 
    52       $ringlist = vmblast_list(); 
     52      $vmlist = vmblast_list(); 
    5353 
    5454      if (function_exists('recordings_list')) {  
     
    5959      } 
    6060 
    61       if (is_array($ringlist)) { 
    62         foreach($ringlist as $item) { 
     61      if (is_array($vmlist)) { 
     62        foreach($vmlist as $item) { 
    6363          $grpnum = ltrim($item['0']); 
    6464          $grp = vmblast_get($grpnum); 
    65           $grplist = explode('&',$grp['grplist'])
     65          $grplist = $grp['grplist']
    6666          $ext->add($contextname, $grpnum, '', new ext_macro('user-callerid')); 
    6767          $ext->add($contextname, $grpnum, '', new ext_answer('')); 
     
    139139  global $db; 
    140140 
    141   $grplist = $grplist; 
    142   foreach ($grplist as $key => $value) { 
    143     $grplist[$key] = addslashes(trim($value)); 
     141  if (is_array($grplist)) { 
     142    $xtns = $grplist; 
     143  } else { 
     144    $xtns = explode("\n",$grplist); 
     145  } 
     146 
     147  foreach ($xtns as $key => $value) { 
     148    $xtns[$key] = addslashes(trim($value)); 
    144149  } 
    145150    // Sanity check input. 
    146151 
    147152  $compiled = $db->prepare("INSERT INTO vmblast_groups (grpnum, ext) values ('$grpnum',?)"); 
    148   $result   = $db->executeMultiple($compiled,$grplist); 
     153  $result   = $db->executeMultiple($compiled,$xtns); 
    149154  if(DB::IsError($result)) { 
    150155    die_freepbx($result->getDebugInfo()."<br><br>".'error adding to vmblast_groups table');  
     
    231236  } 
    232237 
    233   //if ($tech_hardware != null && ($pagename == 'extensions' || $pagename == 'users')) { 
    234238  if ($tech_hardware != null || $pagename == 'users') { 
    235239    vmblast_applyhooks(); 
     
    272276    if ($default_group != "") { 
    273277      $in_default_vmblast_grp = vmblast_check_default($extdisplay); 
    274       $currentcomponent->addguielem($section, new gui_selectbox('in_default_vmblast_grp', $currentcomponent->getoptlist('vmblast_group'), $in_default_vmblast_grp, _('Default VMblast Group'), _('You can include or exclude this extension/device from being part of the default voicemail blast group when creating or editing.'), false)); 
     278      $currentcomponent->addguielem($section, new gui_selectbox('in_default_vmblast_grp', $currentcomponent->getoptlist('vmblast_group'), $in_default_vmblast_grp, _('Default VMblast Group'), _('You can include or exclude this extension/user from being part of the default voicemail blast group when creating or editing. Choosing this option will be ignored if the user does not have a voicemial box.'), false)); 
    275279    }  
    276280  } 
     
    285289  $ext = isset($_REQUEST['extdisplay'])?$_REQUEST['extdisplay']:null; 
    286290  $extn = isset($_REQUEST['extension'])?$_REQUEST['extension']:null; 
     291  $vm_enabled = isset($_REQUEST['vm']) && $_REQUEST['vm'] == 'enabled' ? true : false; 
    287292  $in_default_vmblast_grp = isset($_REQUEST['in_default_vmblast_grp'])?$_REQUEST['in_default_vmblast_grp']:false; 
    288293 
    289294  $extdisplay = ($ext==='') ? $extn : $ext; 
    290295   
    291   if ($action == "add" || $action == "edit") { 
     296  if (($action == "add" || $action == "edit") && $vm_enabled) { 
    292297    if (!isset($GLOBALS['abort']) || $GLOBALS['abort'] !== true) { 
    293298      if ($in_default_vmblast_grp !== false) { 
     
    295300      } 
    296301    } 
    297   } elseif ($action == "del") { 
     302  } elseif ($extdisplay != '' && ($action == "del" || ($action == "edit" && !$vm_enabled))) { 
    298303    $sql = "DELETE FROM vmblast_groups WHERE ext = '$extdisplay'"; 
    299304    sql($sql); 
  • contributed_modules/modules/vmblast/module.xml

    r5374 r5389  
    22  <rawname>vmblast</rawname> 
    33  <name>VoiceMail Blasting</name> 
    4   <version>1.1.2</version> 
     4  <version>1.2.0</version> 
    55  <type>setup</type> 
    66  <category>Internal Options &amp; Configuration</category> 
     
    99  </description> 
    1010  <changelog> 
     11    *1.2.0* change to use proper multi-select list, fix bug in js validation of empty list, add default vmblast group 
    1112    *1.1.2* add vmblast_group table and migrate from old grplist field 
    1213    *1.1.1* fixed a couple SQL bugs, improved dialplan so you can skip annoucement and messages immeditiately (except if saydigits used) 
  • contributed_modules/modules/vmblast/page.vmblast.php

    r5381 r5389  
    2121$password    = isset($_REQUEST['password'])    ? $password    : ''; 
    2222$default_group  = isset($_REQUEST['default_group']) ? $default_group : '0'; 
    23  
    24 if (isset($_REQUEST["grplist"])) { 
    25   $grplist = explode("\n",$_REQUEST["grplist"]); 
    26  
    27   if (!$grplist) { 
    28     $grplist = array(); 
    29   } 
    30    
    31   foreach (array_keys($grplist) as $key) { 
    32     //trim it 
    33     $grplist[$key] = trim($grplist[$key]); 
    34      
    35     // remove invalid chars 
    36     $grplist[$key] = preg_replace("/[^0-9#*]/", "", $grplist[$key]); 
    37      
    38     if ($grplist[$key] == ltrim($extdisplay,'GRP-').'#') 
    39       $grplist[$key] = rtrim($grplist[$key],'#'); 
    40      
    41     // remove blanks 
    42     if ($grplist[$key] == "") unset($grplist[$key]); 
    43   } 
    44    
    45   // check for duplicates, and re-sequence 
    46   $grplist = array_values(array_unique($grplist)); 
    47 
     23$vmblast_list   = isset($_REQUEST['vmblast_list'])  ? $vmblast_list  : ''; 
    4824 
    4925// do if we are submitting a form 
     
    6137        $conflict_url = framework_display_extension_usage_alert($usage_arr); 
    6238 
    63       } else if (vmblast_add($account,$grplist,$description)) { 
     39      } else if (vmblast_add($account,$vmblast_list,$description)) { 
    6440        needreload(); 
    6541        redirect_standard(); 
     
    7753    if ($action == 'editGRP') { 
    7854      vmblast_del($account);   
    79       vmblast_add($account,$grplist,$description,$audio_label,$password,$default_group); 
     55      vmblast_add($account,$vmblast_list,$description,$audio_label,$password,$default_group); 
    8056      needreload(); 
    8157      redirect_standard('extdisplay'); 
     
    11288    $password    = $thisgrp['password']; 
    11389    $default_group = $thisgrp['default_group']; 
    114     unset($grpliststr); 
    11590    unset($thisgrp); 
    11691     
     
    190165<?php } else { ?> 
    191166      <tr> 
    192         <td><a href="#" class="info"><?php echo _("Audio Label:")?><span><?php echo _("The group number will be payed to the caller so they can confirm they have dialed the prooper voice mail group number.<br><br>You must install and enable the \"Systems Recordings\" Module to edit this option and choose from recordings.")?></span></a></td> 
     167        <td><a href="#" class="info"><?php echo _("Audio Label:")?><span><?php echo _("The group number will be played to the caller so they can confirm they have dialed the proper voice mail group number.<br><br>You must install and enable the \"Systems Recordings\" Module to edit this option and choose from recordings.")?></span></a></td> 
    193168        <td> 
    194169          <?php 
     
    207182 
    208183      <tr> 
    209         <td valign="top"><a href="#" class="info"><?php echo _("Extension list")?>:<span><br><?php echo _("List Voicemail boxes to mass send to. One per line.")?><br></span></a></td> 
    210         <td valign="top"> 
    211 <?php 
    212             $rows = count($grplist)+1;  
    213             ($rows < 5) ? 5 : (($rows > 20) ? 20 : $rows); 
    214 ?> 
    215           <textarea id="grplist" cols="15" rows="<?php  echo $rows ?>" name="grplist"><?php echo implode("\n",$grplist);?></textarea> 
    216         </td> 
    217       </tr> 
    218  
    219       <tr> 
    220         <td> 
    221         <a href=# class="info"><?php echo _("Extension Quick Pick")?> 
    222           <span> 
    223             <?php echo _("Choose an extension to append to the end of the extension list above.")?> 
    224           </span> 
    225         </a> 
    226         </td> 
    227         <td> 
    228           <select onChange="insertExten();" id="insexten"> 
    229             <option value=""><?php echo _("(pick extension)")?></option> 
    230   <?php 
     184        <td valign='top'><a href='#' class='info'><?php echo _("Voicemail Box List:")."<span><br>"._("Select voice mail boxes to add to this group. Use Ctrl key to select multiple..") ?>  
     185  <br><br></span></a> 
     186        </td> 
     187        <td valign="top">  
     188          <select multiple="multiple" name="vmblast_list[]" id="xtnlist" > 
     189            <?php  
    231190            $results = core_users_list(); 
     191            if (!is_array($results)) $results = array(); 
    232192            foreach ($results as $result) { 
    233193              if ($result[2] != 'novm') { 
    234                 echo "<option value='".$result[0]."'>".$result[0]." (".$result[1].")</option>\n"; 
     194                echo '<option value="'.$result[0].'" '; 
     195                if (array_search($result[0], $grplist) !== false) echo ' selected="selected" '; 
     196                echo '>'.$result[0].' ('.$result[1].')</option>'; 
    235197              } 
    236198            } 
    237   ?> 
     199           ?> 
    238200          </select> 
    239         </td> 
    240       </tr> 
    241  
    242       <tr> 
    243         <td> 
    244           <a href='#' class='info'><?php echo _("Default Page Group") ?>  
    245             <span> <?php echo _("Each PBX system can have a single Default Page Group. If specified, extensions can be automatically added (or removed) from the default page group in the Extensions (or Users) tab.<br />Making this group the default will uncheck the option from the current default group if specified.") ?> </span> 
     201        <br> 
     202        </td> 
     203      </tr> 
     204 
     205      <tr> 
     206        <td> 
     207          <a href='#' class='info'><?php echo _("Default VMBlast Group") ?>  
     208            <span> <?php echo _("Each PBX system can have a single Default Voicemail Blast Group. If specified, extensions can be automatically added (or removed) from this default group in the Extensions (or Users) tab.<br />Making this group the default will uncheck the option from the current default group if specified.") ?> </span> 
    246209          </a> 
    247210        </td> 
     
    263226<script language="javascript"> 
    264227<!-- 
    265  
    266 function insertExten() { 
    267   exten = document.getElementById('insexten').value; 
    268  
    269   grpList=document.getElementById('grplist'); 
    270   if (grpList.value[ grpList.value.length - 1 ] == "\n") { 
    271     grpList.value = grpList.value + exten; 
    272   } else { 
    273     grpList.value = grpList.value + '\n' + exten; 
    274   } 
    275  
    276   // reset element 
    277   document.getElementById('insexten').value = ''; 
    278 } 
    279  
    280228 
    281229function checkGRP(theForm) { 
     
    285233  var msgInvalidDescription = "<?php echo _('Please enter a valid Group Description'); ?>"; 
    286234  var msgInvalidPassword = "<?php echo _('Please enter a valid numeric password, only numbers are allowed'); ?>"; 
     235  var msgInvalidExtList = "<?php echo _('Please select at least one extension'); ?>"; 
    287236 
    288237  // form validation 
     
    302251    return warnInvalid(theForm.description, msgInvalidDescription); 
    303252   
    304   if (isEmpty(theForm.grplist.value)) 
    305     return warnInvalid(theForm.grplist, msgInvalidExtList); 
     253  var selected = 0; 
     254  for (var i=0; i < theForm.xtnlist.options.length; i++) { 
     255    if (theForm.xtnlist.options[i].selected) selected += 1; 
     256  } 
     257  if (selected < 1) { 
     258    theForm.xtnlist.focus(); 
     259    alert(msgInvalidExtList); 
     260    return false; 
     261  } 
    306262 
    307263  return true;     
    308264} 
     265 
    309266//--> 
    310267</script>