Changeset 6129
- Timestamp:
- 07/22/08 22:30:32 (1 month ago)
- Files:
-
- modules/branches/2.5/conferences/functions.inc.php (modified) (4 diffs)
- modules/branches/2.5/conferences/install.php (copied) (copied from modules/branches/2.5/announcement/install.php) (1 diff)
- modules/branches/2.5/conferences/module.xml (modified) (2 diffs)
- modules/branches/2.5/conferences/page.conferences.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/branches/2.5/conferences/functions.inc.php
r5884 r6129 60 60 } else { 61 61 return false; 62 } 63 } 64 65 function conferences_recordings_usage($recording_id) { 66 global $active_modules; 67 68 $results = sql("SELECT `exten`, `description` FROM `meetme` WHERE `joinmsg_id` = '$recording_id'","getAll",DB_FETCHMODE_ASSOC); 69 if (empty($results)) { 70 return array(); 71 } else { 72 foreach ($results as $result) { 73 $usage_arr[] = array( 74 'url_query' => 'config.php?display=conferences&extdisplay='.urlencode($result['exten']), 75 'description' => "Conference: ".$result['description'], 76 ); 77 } 78 return $usage_arr; 62 79 } 63 80 } … … 94 111 $roomuserpin = $room['userpin']; 95 112 $roomadminpin = $room['adminpin']; 96 $roomjoinmsg = (isset($room['joinmsg'])?$room['joinmsg']:''); 113 114 if (isset($room['joinmsg_id']) && $room['joinmsg_id'] != '') { 115 $roomjoinmsg = recordings_get_file($room['joinmsg_id']); 116 } else { 117 $roomjoinmsg = ''; 118 } 97 119 98 120 // Add optional hint … … 193 215 function conferences_get($account){ 194 216 //get all the variables for the meetme 195 $results = sql("SELECT exten,options,userpin,adminpin,description,joinmsg FROM meetme WHERE exten = '$account'","getRow",DB_FETCHMODE_ASSOC);217 $results = sql("SELECT exten,options,userpin,adminpin,description,joinmsg_id FROM meetme WHERE exten = '$account'","getRow",DB_FETCHMODE_ASSOC); 196 218 return $results; 197 219 } … … 201 223 } 202 224 203 function conferences_add($account,$name,$userpin,$adminpin,$options,$joinmsg =null){225 function conferences_add($account,$name,$userpin,$adminpin,$options,$joinmsg_id=null){ 204 226 global $active_modules; 205 $results = sql("INSERT INTO meetme (exten,description,userpin,adminpin,options,joinmsg ) values (\"$account\",\"$name\",\"$userpin\",\"$adminpin\",\"$options\",\"$joinmsg\")");227 $results = sql("INSERT INTO meetme (exten,description,userpin,adminpin,options,joinmsg_id) values (\"$account\",\"$name\",\"$userpin\",\"$adminpin\",\"$options\",\"$joinmsg_id\")"); 206 228 } 207 229 ?> modules/branches/2.5/conferences/install.php
r4767 r6129 1 1 <?php 2 if (! function_exists("out")) { 3 function out($text) { 4 echo $text."<br />"; 5 } 6 } 7 8 if (! function_exists("outn")) { 9 function outn($text) { 10 echo $text; 11 } 12 } 2 13 3 14 global $db; 4 15 global $amp_conf; 5 16 6 $ autoincrement = (($amp_conf["AMPDBENGINE"] == "sqlite") || ($amp_conf["AMPDBENGINE"] == "sqlite3")) ? "AUTOINCREMENT":"AUTO_INCREMENT";7 $sql = "CREATE TABLE IF NOT EXISTS announcement ( 8 announcement_id integer NOT NULL PRIMARY KEY $autoincrement, 9 description VARCHAR( 50 ),10 recording VARCHAR( 255 ),11 allow_skip INT,12 post_dest VARCHAR( 255 ),13 return_ivr TINYINT(1) NOT NULL DEFAULT 0,14 noanswer TINYINT(1) NOT NULL DEFAULT 0,15 repeat_msg VARCHAR(2) NOT NULL DEFAULT '' 16 )";17 $sql = " 18 CREATE TABLE IF NOT EXISTS `meetme` 19 ( 20 `exten` VARCHAR( 50 ) NOT NULL , 21 `options` VARCHAR( 15 ) , 22 `userpin` VARCHAR( 50 ) , 23 `adminpin` VARCHAR( 50 ) , 24 `description` VARCHAR( 50 ) , 25 `joinmsg_id` INTEGER 26 ) 27 "; 17 28 $check = $db->query($sql); 18 29 if(DB::IsError($check)) { 19 die_freepbx("Can not create annoucmenttable");30 die_freepbx("Can not create meetme table"); 20 31 } 21 32 22 // Version 0.3 adds auto-return to IVR 23 $sql = "SELECT return_ivr FROM announcement"; 33 // Version 2.5 migrate to recording ids 34 // 35 outn(_("Checking if recordings need migration..")); 36 $sql = "SELECT joinmsg_id FROM meetme"; 24 37 $check = $db->getRow($sql, DB_FETCHMODE_ASSOC); 25 38 if(DB::IsError($check)) { 26 // add new field 27 $sql = "ALTER TABLE announcement ADD return_ivr TINYINT(1) NOT NULL DEFAULT 0;"; 28 $result = $db->query($sql); 29 if(DB::IsError($result)) { die_freepbx($result->getDebugInfo()); } 30 } 39 // Add recording_id field 40 // 41 out("migrating"); 42 outn(_("adding joinmsg_id field..")); 43 $sql = "ALTER TABLE meetme ADD joinmsg_id INTEGER"; 44 $result = $db->query($sql); 45 if(DB::IsError($result)) { 46 out(_("fatal error")); 47 die_freepbx($result->getDebugInfo()); 48 } else { 49 out(_("ok")); 50 } 31 51 32 // Version 0.4 adds auto-return to IVR 33 $sql = "SELECT noanswer FROM announcement"; 34 $check = $db->getRow($sql, DB_FETCHMODE_ASSOC); 35 if(DB::IsError($check)) { 36 // add new field 37 $sql = "ALTER TABLE announcement ADD noanswer TINYINT(1) NOT NULL DEFAULT 0;"; 38 $result = $db->query($sql); 39 if(DB::IsError($result)) { die_freepbx($result->getDebugInfo()); } 40 } 41 42 // Version 0.8 upgrade 43 $repeat = (($amp_conf["AMPDBENGINE"] == "sqlite") || ($amp_conf["AMPDBENGINE"] == "sqlite3")) ? "repeat":"`repeat`"; 44 $sql = "SELECT $repeat FROM announcement"; 45 $check = $db->getRow($sql, DB_FETCHMODE_ASSOC); 46 if(! DB::IsError($check)) { 47 // Change field name because php5 was not happy with repeat 48 // 49 $sql = "ALTER TABLE announcement CHANGE $repeat repeat_msg VARCHAR( 2 ) NOT NULL DEFAULT '' ;"; 50 $result = $db->query($sql); 51 if(DB::IsError($result)) { 52 die_freepbx($result->getDebugInfo()); 53 } 54 } 55 56 // Version 0.6 adds repeat_msg 57 $sql = "SELECT repeat_msg FROM announcement"; 58 $check = $db->getRow($sql, DB_FETCHMODE_ASSOC); 59 if(DB::IsError($check)) { 60 // add new field 61 $sql = "ALTER TABLE announcement ADD repeat_msg VARCHAR(2) NOT NULL DEFAULT '';"; 62 $result = $db->query($sql); 63 if(DB::IsError($result)) { die_freepbx($result->getDebugInfo()); } 64 } 65 66 $results = array(); 67 $sql = "SELECT announcement_id, post_dest FROM announcement"; 68 $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); 69 if (!DB::IsError($results)) { // error - table must not be there 70 foreach ($results as $result) { 71 $old_dest = $result['post_dest']; 72 $announcement_id = $result['announcement_id']; 73 74 $new_dest = merge_ext_followme(trim($old_dest)); 75 if ($new_dest != $old_dest) { 76 $sql = "UPDATE announcement SET post_dest = '$new_dest' WHERE announcement_id = $announcement_id AND post_dest = '$old_dest'"; 77 $results = $db->query($sql); 78 if(DB::IsError($results)) { 79 die_freepbx($results->getMessage()); 80 } 52 // Get all the valudes and replace them with joinmsg_id 53 // 54 outn(_("migrate to recording ids..")); 55 $sql = "SELECT `exten`, `joinmsg` FROM `meetme`"; 56 $results = $db->getAll($sql, DB_FETCHMODE_ASSOC); 57 if(DB::IsError($results)) { 58 out(_("fatal error")); 59 die_freepbx($results->getDebugInfo()); 60 } 61 $migrate_arr = array(); 62 $count = 0; 63 foreach ($results as $row) { 64 if (trim($row['joinmsg']) != '') { 65 $rec_id = recordings_get_or_create_id($row['joinmsg'], 'conference'); 66 $migrate_arr[] = array($rec_id, $row['exten']); 67 $count++; 81 68 } 82 69 } 70 if ($count) { 71 $compiled = $db->prepare('UPDATE `meetme` SET `joinmsg_id` = ? WHERE `exten` = ?'); 72 $result = $db->executeMultiple($compiled,$migrate_arr); 73 if(DB::IsError($result)) { 74 out(_("fatal error")); 75 die_freepbx($result->getDebugInfo()); 76 } 77 } 78 out(sprintf(_("migrated %s entries"),$count)); 79 80 // Now remove the old recording field replaced by new id field 81 // 82 outn(_("dropping joinmsg field..")); 83 $sql = "ALTER TABLE `meetme` DROP `joinmsg`"; 84 $result = $db->query($sql); 85 if(DB::IsError($result)) { 86 out(_("no joinmsg field???")); 87 } else { 88 out(_("ok")); 89 } 90 91 } else { 92 out("already migrated"); 83 93 } 84 85 94 ?> modules/branches/2.5/conferences/module.xml
r6073 r6129 2 2 <rawname>conferences</rawname> 3 3 <name>Conferences</name> 4 <version>2.5. 0</version>4 <version>2.5.1</version> 5 5 <type>setup</type> 6 6 <category>Internal Options & Configuration</category> 7 7 <description>Allow creation of conference rooms (meet-me) where multiple people can talk together.</description> 8 8 <changelog> 9 *2.5.1* #2064 Migrate recordings to recording ids 9 10 *2.5.0* #2845, added blf hints, added delete and add icons 10 11 *2.4.0.2* #2604, #2843 fix mal-formed html tags, Russian Translation … … 22 23 </changelog> 23 24 <depends> 24 <version>2.4.0</version> 25 <version>2.5.0alpha1</version> 26 <module>recordings ge 3.3.8</module> 25 27 </depends> 26 28 <menuitems> modules/branches/2.5/conferences/page.conferences.php
r5972 r6129 31 31 if (!empty($usage_arr)) { 32 32 $conflict_url = framework_display_extension_usage_alert($usage_arr); 33 } elseif (conferences_add($_REQUEST['account'],$_REQUEST['name'],$_REQUEST['userpin'],$_REQUEST['adminpin'],$_REQUEST['options'],$_REQUEST['joinmsg ']) !== false) {33 } elseif (conferences_add($_REQUEST['account'],$_REQUEST['name'],$_REQUEST['userpin'],$_REQUEST['adminpin'],$_REQUEST['options'],$_REQUEST['joinmsg_id']) !== false) { 34 34 needreload(); 35 35 redirect_standard(); … … 43 43 case "edit": //just delete and re-add 44 44 conferences_del($_REQUEST['account']); 45 conferences_add($_REQUEST['account'],$_REQUEST['name'],$_REQUEST['userpin'],$_REQUEST['adminpin'],$_REQUEST['options'],$_REQUEST['joinmsg ']);45 conferences_add($_REQUEST['account'],$_REQUEST['name'],$_REQUEST['userpin'],$_REQUEST['adminpin'],$_REQUEST['options'],$_REQUEST['joinmsg_id']); 46 46 needreload(); 47 47 redirect_standard('extdisplay'); … … 145 145 <td><a href="#" class="info"><?php echo _("Join Message:")?><span><?php echo _("Message to be played to the caller before joining the conference.<br><br>To add additional recordings please use the \"System Recordings\" MENU to the left")?></span></a></td> 146 146 <td> 147 <select name="joinmsg " tabindex="<?php echo ++$tabindex;?>">147 <select name="joinmsg_id" tabindex="<?php echo ++$tabindex;?>"> 148 148 <?php 149 149 $tresults = recordings_list(); 150 $default = (isset($joinmsg ) ? $joinmsg: '');151 echo '<option value="">'._("None") ;150 $default = (isset($joinmsg_id) ? $joinmsg_id : ''); 151 echo '<option value="">'._("None")."</option>"; 152 152 if (isset($tresults[0])) { 153 153 foreach ($tresults as $tresult) { 154 echo '<option value="'.$tresult[ 2].'"'.($tresult[2] == $default ? ' SELECTED' : '').'>'.$tresult[1];154 echo '<option value="'.$tresult['id'].'"'.($tresult['id'] == $default ? ' SELECTED' : '').'>'.$tresult['displayname']."</option>\n"; 155 155 } 156 156 } … … 164 164 <td> 165 165 <?php 166 $default = (isset($joinmsg ) ? $joinmsg: '');166 $default = (isset($joinmsg_id) ? $joinmsg_id : ''); 167 167 ?> 168 <input type="hidden" name="joinmsg " value="<?php echo $default; ?>"><?php echo ($default != '' ? $default : 'None'); ?>168 <input type="hidden" name="joinmsg_id" value="<?php echo $default; ?>"><?php echo ($default != '' ? $default : 'None'); ?> 169 169 </td> 170 170 </tr>
