Ticket #1784: sqlite3-support.dpatch

File sqlite3-support.dpatch, 2.4 kB (added by diego_iastrubni, 2 years ago)

fix for this bug

Line 
1 #! /bin/sh /usr/share/dpatch/dpatch-run
2 ## sqlite3-support.dpatch by Diego Iastrubni <diego.iastrubni@xorcom.com>
3 ##
4 ## DP: SQLite3 support. See upstream http://www.freepbx.org/trac/ticket/1784
5
6 @DPATCH@
7 diff -urNad freepbx-module-disa~/install.php freepbx-module-disa/install.php
8 --- freepbx-module-disa~/install.php    2006-05-31 13:16:43.000000000 +0300
9 +++ freepbx-module-disa/install.php     2007-02-18 13:23:32.000000000 +0200
10 @@ -1,12 +1,41 @@
11  <?php
12  
13  global $db;
14 +global $amp_conf;
15 +
16 +$autoincrement = (($amp_conf["AMPDBENGINE"] == "sqlite") || ($amp_conf["AMPDBENGINE"] == "sqlite3")) ? "AUTOINCREMENT":"AUTO_INCREMENT";
17 +
18 +$sql = "CREATE TABLE IF NOT EXISTS manager (
19 +       `manager_id` INTEGER NOT NULL  PRIMARY KEY $autoincrement,
20 +       `name` VARCHAR( 15 ) NOT NULL ,
21 +       `secret` VARCHAR( 50 ) ,
22 +       `deny` VARCHAR( 255 ) ,
23 +       `permit` VARCHAR( 255 ) ,
24 +       `read` VARCHAR( 50 ) ,
25 +       `write` VARCHAR( 50 )
26 +)";
27 +
28 +$sql = "CREATE TABLE IF NOT EXISTS disa (
29 +       disa_id INTEGER NOT NULL PRIMARY KEY $autoincrement,
30 +       displayname VARCHAR( 50 ),
31 +       pin VARCHAR ( 50 ),
32 +       cid VARCHAR ( 50 ),
33 +       context VARCHAR ( 50 ),
34 +       digittimeout INTEGER,
35 +       resptimeout INTEGER,
36 +       needconf VARCHAR( 10 )
37 +);";
38 +
39 +$check = $db->query($sql);
40 +if (DB::IsError($check)) {
41 +       die( "Can not create `disa` table: " . $check->getMessage() .  "\n");
42 +}
43  
44  // Manage upgrade from DISA 1.0
45  // r2.0 Add Timeouts and add wait for confirmation
46  $sql = "SELECT digittimeout FROM disa";
47  $check = $db->getRow($sql, DB_FETCHMODE_ASSOC);
48 -if(DB::IsError($check)) {
49 +if (DB::IsError($check)) {
50         // add new fields - Digit Timeout
51         $sql = 'ALTER TABLE disa ADD COLUMN digittimeout INT DEFAULT "5"';
52         $result = $db->query($sql);
53 @@ -26,5 +55,4 @@
54         }
55  }
56  
57 -
58  ?>
59 diff -urNad freepbx-module-disa~/install.sql freepbx-module-disa/install.sql
60 --- freepbx-module-disa~/install.sql    2006-05-31 13:16:43.000000000 +0300
61 +++ freepbx-module-disa/install.sql     1970-01-01 02:00:00.000000000 +0200
62 @@ -1 +0,0 @@
63 -CREATE TABLE IF NOT EXISTS disa ( disa_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY , displayname VARCHAR( 50 ), pin VARCHAR ( 50 ), cid VARCHAR ( 50 ), context VARCHAR ( 50 ), digittimeout INT, resptimeout INT, needconf VARCHAR( 10 ) );
64 diff -urNad freepbx-module-disa~/uninstall.sql freepbx-module-disa/uninstall.sql
65 --- freepbx-module-disa~/uninstall.sql  2006-05-31 13:16:43.000000000 +0300
66 +++ freepbx-module-disa/uninstall.sql   2007-02-18 13:23:32.000000000 +0200
67 @@ -1 +1 @@
68 -DROP TABLE disa;
69 +DROP TABLE IF EXISTS disa;
Donate



Support
Download
Develop
Forums
News
Documentation
Paid Support
About

Paid Ads