Changeset 6129

Show
Ignore:
Timestamp:
07/23/08 00:30:32 (4 years ago)
Author:
p_lindheimer
Message:

#2064 changed conference to use recording_id

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/2.5/conferences/functions.inc.php

    r5884 r6129  
    6060  } else { 
    6161    return false; 
     62  } 
     63} 
     64 
     65function 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; 
    6279  } 
    6380} 
     
    94111          $roomuserpin = $room['userpin']; 
    95112          $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          } 
    97119           
    98120          // Add optional hint 
     
    193215function conferences_get($account){ 
    194216  //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); 
    196218  return $results; 
    197219} 
     
    201223} 
    202224 
    203 function conferences_add($account,$name,$userpin,$adminpin,$options,$joinmsg=null){ 
     225function conferences_add($account,$name,$userpin,$adminpin,$options,$joinmsg_id=null){ 
    204226  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\")"); 
    206228} 
    207229?> 
  • modules/branches/2.5/conferences/install.php

    r4767 r6129  
    11<?php 
     2if (! function_exists("out")) { 
     3  function out($text) { 
     4    echo $text."<br />"; 
     5  } 
     6} 
     7 
     8if (! function_exists("outn")) { 
     9  function outn($text) { 
     10    echo $text; 
     11  } 
     12} 
    213 
    314global $db; 
    415global $amp_conf; 
    516 
    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 = " 
     18CREATE 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"; 
    1728$check = $db->query($sql); 
    1829if(DB::IsError($check)) { 
    19   die_freepbx("Can not create annoucment table"); 
     30  die_freepbx("Can not create meetme table"); 
    2031} 
    2132 
    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// 
     35outn(_("Checking if recordings need migration..")); 
     36$sql = "SELECT joinmsg_id FROM meetme"; 
    2437$check = $db->getRow($sql, DB_FETCHMODE_ASSOC); 
    2538if(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  } 
    3151 
    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++; 
    8168    } 
    8269  } 
     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"); 
    8393} 
    84  
    8594?> 
  • modules/branches/2.5/conferences/module.xml

    r6073 r6129  
    22  <rawname>conferences</rawname> 
    33  <name>Conferences</name> 
    4   <version>2.5.0</version> 
     4  <version>2.5.1</version> 
    55  <type>setup</type> 
    66  <category>Internal Options &amp; Configuration</category> 
    77  <description>Allow creation of conference rooms (meet-me) where multiple people can talk together.</description> 
    88  <changelog> 
     9    *2.5.1* #2064 Migrate recordings to recording ids 
    910    *2.5.0* #2845, added blf hints, added delete and add icons 
    1011    *2.4.0.2* #2604, #2843 fix mal-formed html tags, Russian Translation 
     
    2223  </changelog> 
    2324  <depends> 
    24     <version>2.4.0</version> 
     25    <version>2.5.0alpha1</version> 
     26    <module>recordings ge 3.3.8</module> 
    2527  </depends> 
    2628  <menuitems> 
  • modules/branches/2.5/conferences/page.conferences.php

    r5972 r6129  
    3131      if (!empty($usage_arr)) { 
    3232        $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) { 
    3434        needreload(); 
    3535        redirect_standard(); 
     
    4343    case "edit":  //just delete and re-add 
    4444      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']); 
    4646      needreload(); 
    4747      redirect_standard('extdisplay'); 
     
    145145    <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> 
    146146    <td> 
    147       <select name="joinmsg" tabindex="<?php echo ++$tabindex;?>"> 
     147      <select name="joinmsg_id" tabindex="<?php echo ++$tabindex;?>"> 
    148148      <?php 
    149149        $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>"
    152152        if (isset($tresults[0])) { 
    153153          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"
    155155          } 
    156156        } 
     
    164164    <td> 
    165165      <?php 
    166         $default = (isset($joinmsg) ? $joinmsg : ''); 
     166        $default = (isset($joinmsg_id) ? $joinmsg_id : ''); 
    167167      ?> 
    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'); ?> 
    169169    </td> 
    170170  </tr>