Changeset 5366

Show
Ignore:
Timestamp:
12/07/07 20:37:01 (10 months ago)
Author:
p_lindheimer
Message:

add audio label, password protect, fix bug for javascript validation to work, add extension/dest registry support and a little more cleanup

Files:

Legend:

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

    r5221 r5366  
    2121} 
    2222 
     23function vmblast_getdest($exten) { 
     24        return array("vmblast-grp,$exten,1"); 
     25} 
     26 
     27function vmblast_getdestinfo($dest) { 
     28        if (substr(trim($dest),0,12) == 'vmblast-grp,') { 
     29                $grp = explode(',',$dest); 
     30                $grp = $grp[1]; 
     31                $thisgrp = vmblast_get($grp); 
     32                if (empty($thisgrp)) { 
     33                        return array(); 
     34                } else { 
     35                        return array('description' => 'Voicemail Group '.$grp.': '.$thisgrp['description'], 
     36                                     'edit_url' => 'config.php?display=vmblast&extdisplay=GRP-'.urlencode($grp), 
     37                                                                  ); 
     38                } 
     39        } else { 
     40                return false; 
     41        } 
     42} 
     43 
     44 
    2345/*      Generates dialplan for vmblast We call this with retrieve_conf 
    2446*/ 
    25  
    2647function vmblast_get_config($engine) { 
    2748        global $ext;  // is this the best way to pass this? 
     
    3152                        $contextname = 'vmblast-grp'; 
    3253                        $ringlist = vmblast_list(); 
     54 
     55                        if (function_exists('recordings_list')) {  
     56                                $recordings_installed = true; 
     57                                $got_recordings = false; 
     58                        } else { 
     59                                $recordings_installed = false; 
     60                        } 
     61 
    3362                        if (is_array($ringlist)) { 
    3463                                foreach($ringlist as $item) { 
     
    3766                                        $grplist = explode('&',$grp['grplist']); 
    3867                                        $ext->add($contextname, $grpnum, '', new ext_macro('user-callerid')); 
     68                                        $ext->add($contextname, $grpnum, '', new ext_answer('')); 
     69                                        $ext->add($contextname, $grpnum, '', new ext_wait('1')); 
     70 
     71                                        if (isset($grp['password']) && trim($grp['password']) != "" && ctype_digit(trim($grp['password']))) { 
     72                                                $ext->add($contextname, $grpnum, '', new ext_authenticate($grp['password'])); 
     73                                        } 
     74 
    3975                                        $ext->add($contextname, $grpnum, '', new ext_setvar('GRPLIST','')); 
    4076                                        foreach ($grplist as $exten) { 
     
    4278                                                $ext->add($contextname, $grpnum, '', new ext_setvar('GRPLIST','${GRPLIST}&'.$exten.'@${VMCONTEXT}')); 
    4379                                        } 
    44                                         $ext->add($contextname, $grpnum, '', new ext_vm('${GRPLIST:1},s')); 
    45                                         $ext->add($contextname, $grpnum, '', new ext_hangup('')); 
     80 
     81                                        // Add a message and confirmation so they know what group they are in 
     82                                        // 
     83                                        if ($grp['audio_label'] == -1 || !$recordings_installed) { 
     84                                                $ext->add($contextname, $grpnum, '', new ext_saydigits($grpnum)); 
     85                                        } else { 
     86                                                if (!$got_recordings) { 
     87                                                        $recordings = recordings_list(); 
     88                                                        $got_recordings = true; 
     89                                                        $recording_hash = array(); 
     90                                                        foreach ($recordings as $recording) { 
     91                                                                $recording_hash[$recording[0]] = $recording[2]; 
     92                                                        } 
     93                                                } 
     94                                                if (isset($recording_hash[$grp['audio_label']])) { 
     95                                                        $ext->add($contextname, $grpnum, '', new ext_playback($recording_hash[$grp['audio_label']])); 
     96                                                } else { 
     97                                                        $ext->add($contextname, $grpnum, '', new ext_saydigits($grpnum)); 
     98                                                } 
     99                                        } 
     100                                        $ext->add($contextname, $grpnum, '', new ext_goto('1','vmblast','app-vmblast')); 
    46101                                } 
     102                                $contextname = 'app-vmblast'; 
     103                                $ext->add($contextname, 'vmblast', '', new ext_background('if-correct-press&digits/1')); 
     104                                $ext->add($contextname, 'vmblast', '', new ext_waitexten('20')); 
     105                                $ext->add($contextname, 'vmblast', '', new ext_playback('sorry-youre-having-problems&goodbye')); 
     106                                $ext->add($contextname, 'vmblast', '', new ext_hangup('')); 
     107 
     108                                $ext->add($contextname, '1', '', new ext_vm('${GRPLIST:1},s')); 
     109                                $ext->add($contextname, '1', '', new ext_hangup('')); 
    47110                        } 
    48111                break; 
     
    50113} 
    51114 
    52 function vmblast_add($grpnum,$grplist,$description) { 
    53         $sql = "INSERT INTO vmblast (grpnum, grplist, description) VALUES (".$grpnum.", '".str_replace("'", "''", $grplist)."', '".str_replace("'", "''", $description)."')"; 
     115function vmblast_check_extensions($exten=true) { 
     116        $extenlist = array(); 
     117        if (is_array($exten) && empty($exten)) { 
     118                return $extenlist; 
     119        } 
     120        $sql = "SELECT grpnum ,description FROM vmblast "; 
     121        if (is_array($exten)) { 
     122                $sql .= "WHERE grpnum in ('".implode("','",$exten)."')"; 
     123        } 
     124        $results = sql($sql,"getAll",DB_FETCHMODE_ASSOC); 
     125 
     126        foreach ($results as $result) { 
     127                $thisexten = $result['grpnum']; 
     128                $extenlist[$thisexten]['description'] = _("Voicemail Group: ").$result['description']; 
     129                $extenlist[$thisexten]['status'] = 'INUSE'; 
     130                $extenlist[$thisexten]['edit_url'] = 'config.php?display=vmblast&extdisplay=GRP-'.urlencode($thisexten); 
     131        } 
     132        return $extenlist; 
     133
     134 
     135 
     136function vmblast_add($grpnum,$grplist,$description,$audio_label= -1, $password = '') { 
     137        $sql = "INSERT INTO vmblast (grpnum, grplist, description, audio_label, password) VALUES (".$grpnum.", '".str_replace("'", "''", $grplist)."', '".str_replace("'", "''", $description)."', $audio_label, '".str_replace("'","''", $password)."')"; 
    54138        $results = sql($sql); 
    55139} 
     
    73157 
    74158function vmblast_get($grpnum) { 
    75         $results = sql("SELECT grpnum, grplist, description FROM vmblast WHERE grpnum = $grpnum","getRow",DB_FETCHMODE_ASSOC); 
     159        $results = sql("SELECT grpnum, grplist, description, audio_label, password FROM vmblast WHERE grpnum = $grpnum","getRow",DB_FETCHMODE_ASSOC); 
    76160        return $results; 
    77161} 
  • contributed_modules/modules/vmblast/install.php

    r5237 r5366  
    99} 
    1010 
     11echo "Upgrading vmblast to add audio_label field.."; 
     12$sql = "SELECT audio_label FROM vmblast"; 
     13$confs = $db->getRow($sql, DB_FETCHMODE_ASSOC); 
     14if (!DB::IsError($confs)) { // no error... Already done 
     15        echo "Not Required<br />"; 
     16} else { 
     17        $sql = "ALTER TABLE vmblast ADD audio_label INT ( 11 ) NOT NULL DEFAULT -1"; 
     18        $results = $db->query($sql); 
     19        if(DB::IsError($results)) { 
     20                die($results->getMessage()); 
     21        } 
     22        echo "Done<br />"; 
     23} 
     24 
     25echo "Upgrading vmblast to add password field.."; 
     26$sql = "SELECT password FROM vmblast"; 
     27$confs = $db->getRow($sql, DB_FETCHMODE_ASSOC); 
     28if (!DB::IsError($confs)) { // no error... Already done 
     29        echo "Not Required<br />"; 
     30} else { 
     31        $sql = "ALTER TABLE vmblast ADD password VARCHAR ( 20 ) NOT NULL"; 
     32        $results = $db->query($sql); 
     33        if(DB::IsError($results)) { 
     34                die($results->getMessage()); 
     35        } 
     36        echo "Done<br />"; 
     37} 
     38 
     39echo "Converting grplist from varchar 255 to blob to handle large groups.."; 
     40$sql = "ALTER TABLE `vmblast` CHANGE `grplist` `grplist` BLOB NOT NULL"; 
     41$results = $db->query($sql); 
     42if(DB::IsError($results)) { 
     43        echo "ERROR: failed to convert field<br />"; 
     44} else { 
     45        echo "OK<br />"; 
     46} 
     47 
    1148?> 
  • contributed_modules/modules/vmblast/install.sql

    r5237 r5366  
    1 CREATE TABLE IF NOT EXISTS `vmblast` ( `grpnum` BIGINT( 11 ) NOT NULL , `grplist` VARCHAR( 255 ) NOT NULL , `description` VARCHAR( 35 ) NOT NULL , PRIMARY KEY  (`grpnum`) ) TYPE = MYISAM ;  
     1CREATE TABLE IF NOT EXISTS `vmblast`  
     2(  
     3        `grpnum` INT( 11 ) NOT NULL ,  
     4        `grplist` BLOB NOT NULL ,  
     5        `description` VARCHAR( 35 ) NOT NULL ,  
     6        `audio_label` INT( 11 ) NOT NULL DEFAULT -1 ,  
     7        `password` VARCHAR( 20 ) NOT NULL ,  
     8        PRIMARY KEY  (`grpnum`)  
     9);  
  • contributed_modules/modules/vmblast/module.xml

    r5238 r5366  
    22        <rawname>vmblast</rawname> 
    33        <name>VoiceMail Blasting</name> 
    4         <version>1.0.2</version> 
     4        <version>1.1.0</version> 
    55        <type>setup</type> 
    6         <category>Inbound Call Control</category> 
     6        <category>Internal Options &amp; Configuration</category> 
    77        <description> 
    88                Creates a group of extensions that Calls a group of voicemail boxes and allows you to leave a Msg for them all at once.  
    99        </description> 
    1010        <changelog> 
     11                *1.1.0* add audio label, password protect, fix bug for javascript validation to work, add extension/dest registry support 
    1112                *1.0.2* increase grouplist field to varchar(255) to increase the vmblast list 
    1213                *1.0.l* fix: context, redisplay of groups, get proper vm contexts, beep before leaving msg 
     
    1516                <vmblast>VoiceMail Blasting</vmblast> 
    1617        </menuitems> 
    17         <info>http://aussievoip.com.au/wiki/freePBX-VMBlasting</info> 
     18        <depends> 
     19                <version>2.4.0beta1</version> 
     20        </depends> 
    1821        <location>release/vmblast-1.0.2.tgz</location> 
    1922        <md5sum>936bf3071733255cc89e278204615540</md5sum> 
  • contributed_modules/modules/vmblast/page.vmblast.php

    r5221 r5366  
    1212$dispnum = 'vmblast'; //used for switch on config.php 
    1313 
    14 isset($_REQUEST['action'])?$action = $_REQUEST['action']:$action=''; 
     14$action      = isset($_REQUEST['action'])      ? $action      : ''; 
     15 
    1516//the extension we are currently displaying 
    16 isset($_REQUEST['extdisplay'])?$extdisplay=$_REQUEST['extdisplay']:$extdisplay=''; 
    17 isset($_REQUEST['account'])?$account = $_REQUEST['account']:$account=''; 
    18 isset($_REQUEST['description'])?$description = $_REQUEST['description']:$description=''; 
     17$extdisplay  = isset($_REQUEST['extdisplay'])  ? $extdisplay  : ''; 
     18$account     = isset($_REQUEST['account'])     ? $account     : ''; 
     19$description = isset($_REQUEST['description']) ? $description : ''; 
     20$audio_label = isset($_REQUEST['audio_label']) ? $audio_label : -1; 
     21$password    = isset($_REQUEST['password'])    ? $password    : ''; 
    1922 
    2023if (isset($_REQUEST["grplist"])) { 
     
    5154                //add group 
    5255                if ($action == 'addGRP') { 
    53                         vmblast_add($account,implode("&",$grplist),$description); 
    54                         needreload(); 
    55                         redirect_standard(); 
     56 
     57                        $conflict_url = array(); 
     58                        $usage_arr = framework_check_extension_usage($account); 
     59                        if (!empty($usage_arr)) { 
     60                                $conflict_url = framework_display_extension_usage_alert($usage_arr); 
     61 
     62                        } else if (vmblast_add($account,implode("&",$grplist),$description)) { 
     63                                needreload(); 
     64                                redirect_standard(); 
     65                        } 
    5666                } 
    5767                 
     
    6676                if ($action == 'editGRP') { 
    6777                        vmblast_del($account);   
    68                         vmblast_add($account,implode("&",$grplist),$description); 
     78                        vmblast_add($account,implode("&",$grplist),$description,$audio_label,$password); 
    6979                        needreload(); 
    7080                        redirect_standard('extdisplay'); 
     
    99109                $grplist = explode("&", $grpliststr); 
    100110                $description = $thisgrp['description']; 
     111                $audio_label = $thisgrp['audio_label']; 
     112                $password    = $thisgrp['password']; 
    101113                unset($grpliststr); 
    102114                unset($thisgrp); 
     
    112124                echo "<h2>"._("VMBlast Group").": ".ltrim($extdisplay,'GRP-')."</h2>"; 
    113125                echo "<p>".$delButton."</p>"; 
     126 
     127                $usage_list = framework_display_destination_usage(vmblast_getdest(ltrim($extdisplay,'GRP-'))); 
     128                if (!empty($usage_list)) { 
     129                ?> 
     130                        <a href="#" class="info"><?php echo $usage_list['text']?>:<span><?php echo $usage_list['tooltip']?></span></a> 
     131                <?php 
     132                } 
     133 
    114134        } else { 
    115135                $grplist = explode("-", '');; 
     
    117137                $ringing = ''; 
    118138 
     139                if (!empty($conflict_url)) { 
     140                        echo "<h5>"._("Conflicting Extensions")."</h5>"; 
     141                        echo implode('<br .>',$conflict_url); 
     142                } 
    119143                echo "<h2>"._("Add VMBlast Group")."</h2>"; 
    120144        } 
     
    124148                        <input type="hidden" name="action" value="<?php echo ($extdisplay ? 'editGRP' : 'addGRP'); ?>"> 
    125149                        <table> 
    126                         <tr><td colspan="2"><h5><?php  echo ($extdisplay ? _("Edit VMBlast Group") : _("Add VMBlast Group")) ?><hr></h5></td></tr> 
     150                        <tr> 
     151                                <td colspan="2"><h5><?php  echo ($extdisplay ? _("Edit VMBlast Group") : _("Add VMBlast Group")) ?><hr></h5> 
     152                                </td> 
     153                        </tr> 
    127154                        <tr> 
    128155<?php 
    129         if ($extdisplay) {  
     156                               if ($extdisplay) {  
    130157 
    131158?> 
    132159                                <input size="5" type="hidden" name="account" value="<?php  echo ltrim($extdisplay,'GRP-'); ?>"> 
    133 <?php          } else { ?> 
     160<?php   } else { ?> 
    134161                                <td><a href="#" class="info"><?php echo _("VMBlast Number")?>:<span><?php echo _("The number users will dial to voicemail boxes in this VMBlast group")?></span></a></td> 
    135162                                <td><input size="5" type="text" name="account" value="<?php  if ($gresult[0]==0) { echo "500"; } else { echo $gresult[0] + 1; } ?>"></td> 
    136163<?php           } ?> 
    137164                        </tr> 
     165 
    138166                        <tr> 
    139167                                <td> <a href="#" class="info"><?php echo _("Group Description:")?>:<span><?php echo _("Provide a descriptive title for this VMBlast Group.")?></span></a></td> 
    140168                                <td><input size="20" maxlength="35" type="text" name="description" value="<?php echo htmlspecialchars($description); ?>"></td> 
    141169                        </tr> 
     170 
     171<?php if(function_exists('recordings_list')) { //only include if recordings is enabled?> 
     172                        <tr> 
     173                                <td><a href="#" class="info"><?php echo _("Audio Label:")?><span><?php echo _("Play this message to the caller so they can confirm they have dialed the proper voice mail group number, or have the system simply read the group number.")?></span></a></td> 
     174                                <td> 
     175                                        <select name="audio_label"/> 
     176                                        <?php 
     177                                                $tresults = recordings_list(); 
     178                                                $default = (isset($audio_label) ? $audio_label : -1); 
     179                                                echo '<option value="">'._("Read Group Number")."</option>"; 
     180                                                if (isset($tresults[0])) { 
     181                                                        foreach ($tresults as $tresult) { 
     182                                                                echo '<option value="'.$tresult[0].'"'.($tresult[0] == $default ? ' SELECTED' : '').'>'.$tresult[1]."</option>\n"; 
     183                                                        } 
     184                                                } 
     185                                        ?>               
     186                                        </select>                
     187                                </td> 
     188                        </tr> 
     189<?php } else { ?> 
     190                        <tr> 
     191                                <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> 
     192                                <td> 
     193                                        <?php 
     194                                                $default = (isset($audio_label) ? $audio_label : -1); 
     195                                        ?> 
     196                                        <input type="hidden" name="audio_label" value="<?php echo $default; ?>"><?php echo ($default != -1 ? $default : _('Read Group Number')); ?> 
     197                                </td> 
     198                        </tr> 
     199<?php }  
     200?> 
     201                        <tr> 
     202                                <td><a href="#" class="info"><?php echo _("Optional Password")?>:<span><?php echo _('You can optionally include a password to authenticate before providing access to this group voicemail list.')?></span></a></td> 
     203                                <td><input size="12" type="text" name="password" value="<?php  echo $password ?>"> 
     204                                </td> 
     205                        </tr> 
     206 
    142207                        <tr> 
    143208                                <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> 
    144209                                <td valign="top"> 
    145210<?php 
    146                 $rows = count($grplist)+1;  
    147                 ($rows < 5) ? 5 : (($rows > 20) ? 20 : $rows); 
    148 ?> 
    149                                         <textarea id="grplist" cols="15" rows="<?php  echo $rows ?>" name="grplist"><?php echo implode("\n",$grplist);?></textarea><br> 
    150                                          
    151                                         <input type="submit" style="font-size:10px;" value="<?php echo _("Clean & Remove duplicates")?>" /> 
    152                                 </td> 
    153          
     211                                                $rows = count($grplist)+1;  
     212                                                ($rows < 5) ? 5 : (($rows > 20) ? 20 : $rows); 
     213?> 
     214                                        <textarea id="grplist" cols="15" rows="<?php  echo $rows ?>" name="grplist"><?php echo implode("\n",$grplist);?></textarea> 
     215                                </td> 
     216                        </tr> 
     217 
     218                        <tr> 
     219                                <td> 
     220                                <a href=# class="info"><?php echo _("Extension Quick Pick")?> 
     221                                        <span> 
     222                                                <?php echo _("Choose an extension to append to the end of the extension list above.")?> 
     223                                        </span> 
     224                                </a> 
     225                                </td> 
     226                                <td> 
     227                                        <select onChange="insertExten();" id="insexten"> 
     228                                                <option value=""><?php echo _("(pick extension)")?></option> 
     229        <?php 
     230                                                $results = core_users_list(); 
     231                                                foreach ($results as $result) { 
     232                                                        if ($result[2] != 'novm') { 
     233                                                                echo "<option value='".$result[0]."'>".$result[0]." (".$result[1].")</option>\n"; 
     234                                                        } 
     235                                                } 
     236        ?> 
     237                                        </select> 
     238                                </td> 
     239                        </tr> 
     240 
    154241                        <tr> 
    155242                        <td colspan="2"><br><h6><input name="Submit" type="submit" value="<?php echo _("Submit Changes")?>"></h6></td>           
     
    165252<script language="javascript"> 
    166253<!-- 
     254 
     255function insertExten() { 
     256        exten = document.getElementById('insexten').value; 
     257 
     258        grpList=document.getElementById('grplist'); 
     259        if (grpList.value[ grpList.value.length - 1 ] == "\n") { 
     260                grpList.value = grpList.value + exten; 
     261        } else { 
     262                grpList.value = grpList.value + '\n' + exten; 
     263        } 
     264 
     265        // reset element 
     266        document.getElementById('insexten').value = ''; 
     267} 
     268 
    167269 
    168270function checkGRP(theForm) { 
     
    171273        var msgInvalidExtList = "<?php echo _('Please enter an extension list.'); ?>"; 
    172274        var msgInvalidDescription = "<?php echo _('Please enter a valid Group Description'); ?>"; 
    173  
    174         // set up the Destination stuff 
    175         setDestinations(theForm, 1); 
     275        var msgInvalidPassword = "<?php echo _('Please enter a valid numeric password, only numbers are allowed'); ?>"; 
    176276 
    177277        // form validation 
     
    182282                return warnInvalid(theForm.account, msgInvalidGrpNumStartWithZero); 
    183283        } 
     284 
     285        defaultEmptyOK = true; 
     286        if (!isInteger(theForm.password.value)) 
     287                return warnInvalid(theForm.password, msgInvalidPassword); 
    184288         
    185289        defaultEmptyOK = false;  
     
    190294                return warnInvalid(theForm.grplist, msgInvalidExtList); 
    191295 
    192         if (!validateDestinations(theForm, 1, true)) 
    193                 return false; 
    194  
    195296        return true;             
    196297} 
Donate



Support
Download
Develop
Forums
News
Documentation
Paid Support
About

Paid Ads