root/modules/branches/2.7/disa/install.php

Revision 6176, 1.7 kB (checked in by p_lindheimer, 5 years ago)

re #2949, re #2922 - fix install script errors, change DISA to use authenticate and change dialplan so you don't have to re-authenticate each time

  • Property svn:mime-type set to text/html
  • Property svn:eol-style set to native
Line 
1 <?php
2
3 global $db;
4 global $amp_conf;
5
6 $autoincrement = (($amp_conf["AMPDBENGINE"] == "sqlite") || ($amp_conf["AMPDBENGINE"] == "sqlite3")) ? "AUTOINCREMENT":"AUTO_INCREMENT";
7
8 $sql = "CREATE TABLE IF NOT EXISTS disa (
9   disa_id INTEGER NOT NULL PRIMARY KEY $autoincrement,
10   displayname VARCHAR( 50 ),
11   pin VARCHAR ( 50 ),
12   cid VARCHAR ( 50 ),
13   context VARCHAR ( 50 ),
14   digittimeout INTEGER,
15   resptimeout INTEGER,
16   needconf VARCHAR( 10 ),
17   hangup VARCHAR( 10 )
18 );";
19
20 $check = $db->query($sql);
21 if (DB::IsError($check)) {
22   die( "Can not create `disa` table: " . $check->getMessage() .  "\n");
23 }
24
25  
26 // Manage upgrade from DISA 1.0
27 // r2.0 Add Timeouts and add wait for confirmation
28 $sql = "SELECT digittimeout FROM disa";
29 $check = $db->getRow($sql, DB_FETCHMODE_ASSOC);
30 if(DB::IsError($check)) {
31   // add new fields - Digit Timeout
32   $sql = 'ALTER TABLE disa ADD COLUMN digittimeout INT DEFAULT "5"';
33   $result = $db->query($sql);
34   if(DB::IsError($result)) {
35     die_freepbx($result->getDebugInfo());
36   }
37   // Response Timeout
38   $sql = 'ALTER TABLE disa ADD COLUMN resptimeout INT DEFAULT "10"';
39   $result = $db->query($sql);
40   if(DB::IsError($result)) {
41     die_freepbx($result->getDebugInfo());
42   }
43   $sql = 'ALTER TABLE disa ADD COLUMN needconf VARCHAR ( 10 )  DEFAULT ""';
44   $result = $db->query($sql);
45   if(DB::IsError($result)) {
46     die_freepbx($result->getDebugInfo());
47   }
48 }
49
50 //update to 2.5, add hangup
51 //  ALTER TABLE `disa` CHANGE `hangup` `hangup` VARCHAR( 10 )
52
53 $sql = "SELECT hangup FROM disa";
54 $check = $db->getRow($sql, DB_FETCHMODE_ASSOC);
55 if(DB::IsError($check)) {
56   $sql = 'ALTER TABLE `disa` ADD COLUMN `hangup` VARCHAR( 10 )';
57   $result = $db->query($sql);
58   if(DB::IsError($result)) {
59     die_freepbx($result->getDebugInfo());
60   }
61 }
62
63 ?>
Note: See TracBrowser for help on using the browser.