root/modules/branches/2.6/conferences/install.php

Revision 6720, 2.2 kB (checked in by mickecarlsson, 5 years ago)

Enclosed text strings for localization, added swedish language

Line 
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 }
13
14 global $db;
15 global $amp_conf;
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 ";
28 $check = $db->query($sql);
29 if(DB::IsError($check)) {
30     die_freepbx("Can not create meetme table");
31 }
32
33 // Version 2.5 migrate to recording ids
34 //
35 outn(_("Checking if recordings need migration.."));
36 $sql = "SELECT joinmsg_id FROM meetme";
37 $check = $db->getRow($sql, DB_FETCHMODE_ASSOC);
38 if(DB::IsError($check)) {
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     }
51
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++;
68         }
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"));
93 }
94 ?>
95
Note: See TracBrowser for help on using the browser.