Changeset 5366
- Timestamp:
- 12/07/07 20:37:01 (10 months ago)
- Files:
-
- contributed_modules/modules/vmblast/functions.inc.php (modified) (6 diffs)
- contributed_modules/modules/vmblast/install.php (modified) (1 diff)
- contributed_modules/modules/vmblast/install.sql (modified) (1 diff)
- contributed_modules/modules/vmblast/module.xml (modified) (2 diffs)
- contributed_modules/modules/vmblast/page.vmblast.php (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
contributed_modules/modules/vmblast/functions.inc.php
r5221 r5366 21 21 } 22 22 23 function vmblast_getdest($exten) { 24 return array("vmblast-grp,$exten,1"); 25 } 26 27 function 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 23 45 /* Generates dialplan for vmblast We call this with retrieve_conf 24 46 */ 25 26 47 function vmblast_get_config($engine) { 27 48 global $ext; // is this the best way to pass this? … … 31 52 $contextname = 'vmblast-grp'; 32 53 $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 33 62 if (is_array($ringlist)) { 34 63 foreach($ringlist as $item) { … … 37 66 $grplist = explode('&',$grp['grplist']); 38 67 $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 39 75 $ext->add($contextname, $grpnum, '', new ext_setvar('GRPLIST','')); 40 76 foreach ($grplist as $exten) { … … 42 78 $ext->add($contextname, $grpnum, '', new ext_setvar('GRPLIST','${GRPLIST}&'.$exten.'@${VMCONTEXT}')); 43 79 } 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')); 46 101 } 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('')); 47 110 } 48 111 break; … … 50 113 } 51 114 52 function vmblast_add($grpnum,$grplist,$description) { 53 $sql = "INSERT INTO vmblast (grpnum, grplist, description) VALUES (".$grpnum.", '".str_replace("'", "''", $grplist)."', '".str_replace("'", "''", $description)."')"; 115 function 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 136 function 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)."')"; 54 138 $results = sql($sql); 55 139 } … … 73 157 74 158 function 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); 76 160 return $results; 77 161 } contributed_modules/modules/vmblast/install.php
r5237 r5366 9 9 } 10 10 11 echo "Upgrading vmblast to add audio_label field.."; 12 $sql = "SELECT audio_label FROM vmblast"; 13 $confs = $db->getRow($sql, DB_FETCHMODE_ASSOC); 14 if (!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 25 echo "Upgrading vmblast to add password field.."; 26 $sql = "SELECT password FROM vmblast"; 27 $confs = $db->getRow($sql, DB_FETCHMODE_ASSOC); 28 if (!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 39 echo "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); 42 if(DB::IsError($results)) { 43 echo "ERROR: failed to convert field<br />"; 44 } else { 45 echo "OK<br />"; 46 } 47 11 48 ?> 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 ; 1 CREATE 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 2 2 <rawname>vmblast</rawname> 3 3 <name>VoiceMail Blasting</name> 4 <version>1. 0.2</version>4 <version>1.1.0</version> 5 5 <type>setup</type> 6 <category>In bound Call Control</category>6 <category>Internal Options & Configuration</category> 7 7 <description> 8 8 Creates a group of extensions that Calls a group of voicemail boxes and allows you to leave a Msg for them all at once. 9 9 </description> 10 10 <changelog> 11 *1.1.0* add audio label, password protect, fix bug for javascript validation to work, add extension/dest registry support 11 12 *1.0.2* increase grouplist field to varchar(255) to increase the vmblast list 12 13 *1.0.l* fix: context, redisplay of groups, get proper vm contexts, beep before leaving msg … … 15 16 <vmblast>VoiceMail Blasting</vmblast> 16 17 </menuitems> 17 <info>http://aussievoip.com.au/wiki/freePBX-VMBlasting</info> 18 <depends> 19 <version>2.4.0beta1</version> 20 </depends> 18 21 <location>release/vmblast-1.0.2.tgz</location> 19 22 <md5sum>936bf3071733255cc89e278204615540</md5sum> contributed_modules/modules/vmblast/page.vmblast.php
r5221 r5366 12 12 $dispnum = 'vmblast'; //used for switch on config.php 13 13 14 isset($_REQUEST['action'])?$action = $_REQUEST['action']:$action=''; 14 $action = isset($_REQUEST['action']) ? $action : ''; 15 15 16 //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 : ''; 19 22 20 23 if (isset($_REQUEST["grplist"])) { … … 51 54 //add group 52 55 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 } 56 66 } 57 67 … … 66 76 if ($action == 'editGRP') { 67 77 vmblast_del($account); 68 vmblast_add($account,implode("&",$grplist),$description );78 vmblast_add($account,implode("&",$grplist),$description,$audio_label,$password); 69 79 needreload(); 70 80 redirect_standard('extdisplay'); … … 99 109 $grplist = explode("&", $grpliststr); 100 110 $description = $thisgrp['description']; 111 $audio_label = $thisgrp['audio_label']; 112 $password = $thisgrp['password']; 101 113 unset($grpliststr); 102 114 unset($thisgrp); … … 112 124 echo "<h2>"._("VMBlast Group").": ".ltrim($extdisplay,'GRP-')."</h2>"; 113 125 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 114 134 } else { 115 135 $grplist = explode("-", '');; … … 117 137 $ringing = ''; 118 138 139 if (!empty($conflict_url)) { 140 echo "<h5>"._("Conflicting Extensions")."</h5>"; 141 echo implode('<br .>',$conflict_url); 142 } 119 143 echo "<h2>"._("Add VMBlast Group")."</h2>"; 120 144 } … … 124 148 <input type="hidden" name="action" value="<?php echo ($extdisplay ? 'editGRP' : 'addGRP'); ?>"> 125 149 <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> 127 154 <tr> 128 155 <?php 129 if ($extdisplay) {156 if ($extdisplay) { 130 157 131 158 ?> 132 159 <input size="5" type="hidden" name="account" value="<?php echo ltrim($extdisplay,'GRP-'); ?>"> 133 <?php } else { ?>160 <?php } else { ?> 134 161 <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> 135 162 <td><input size="5" type="text" name="account" value="<?php if ($gresult[0]==0) { echo "500"; } else { echo $gresult[0] + 1; } ?>"></td> 136 163 <?php } ?> 137 164 </tr> 165 138 166 <tr> 139 167 <td> <a href="#" class="info"><?php echo _("Group Description:")?>:<span><?php echo _("Provide a descriptive title for this VMBlast Group.")?></span></a></td> 140 168 <td><input size="20" maxlength="35" type="text" name="description" value="<?php echo htmlspecialchars($description); ?>"></td> 141 169 </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 142 207 <tr> 143 208 <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> 144 209 <td valign="top"> 145 210 <?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 154 241 <tr> 155 242 <td colspan="2"><br><h6><input name="Submit" type="submit" value="<?php echo _("Submit Changes")?>"></h6></td> … … 165 252 <script language="javascript"> 166 253 <!-- 254 255 function 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 167 269 168 270 function checkGRP(theForm) { … … 171 273 var msgInvalidExtList = "<?php echo _('Please enter an extension list.'); ?>"; 172 274 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'); ?>"; 176 276 177 277 // form validation … … 182 282 return warnInvalid(theForm.account, msgInvalidGrpNumStartWithZero); 183 283 } 284 285 defaultEmptyOK = true; 286 if (!isInteger(theForm.password.value)) 287 return warnInvalid(theForm.password, msgInvalidPassword); 184 288 185 289 defaultEmptyOK = false; … … 190 294 return warnInvalid(theForm.grplist, msgInvalidExtList); 191 295 192 if (!validateDestinations(theForm, 1, true))193 return false;194 195 296 return true; 196 297 }
