root/modules/branches/2.10/callback/install.php

Revision 7470, 2.1 kB (checked in by mickecarlsson, 4 years ago)

Added missing GPL text, corrected license version

  • Property svn:mime-type set to text/plain
  • Property svn:eol-style set to native
Line 
1 <?php
2 //This file is part of FreePBX.
3 //
4 //    FreePBX is free software: you can redistribute it and/or modify
5 //    it under the terms of the GNU General Public License as published by
6 //    the Free Software Foundation, either version 2 of the License, or
7 //    (at your option) any later version.
8 //
9 //    FreePBX is distributed in the hope that it will be useful,
10 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
11 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 //    GNU General Public License for more details.
13 //
14 //    You should have received a copy of the GNU General Public License
15 //    along with FreePBX.  If not, see <http://www.gnu.org/licenses/>.
16 //
17 // Copyright (C) 2004 Coalescent Systems Inc. (info@coalescentsystems.ca)
18 global $db;
19 global $amp_conf;
20
21 $autoincrement = ($amp_conf["AMPDBENGINE"] == "sqlite3") ? "AUTOINCREMENT":"AUTO_INCREMENT";
22
23 $sql = "CREATE TABLE IF NOT EXISTS callback (
24   callback_id INTEGER NOT NULL PRIMARY KEY $autoincrement,
25   description VARCHAR( 50 ) ,
26   callbacknum VARCHAR( 100 ) ,
27   destination VARCHAR( 50 ) ,
28   sleep INTEGER,
29   deptname VARCHAR( 50 )
30 );";
31
32 $check = $db->query($sql);
33 if (DB::IsError($check)) {
34   die_freepbx( "Can not create `callback` table: " . $check->getMessage() .  "\n");
35 }
36
37
38 // Version 1.1 upgrade - add sleep time.
39 $sql = "SELECT sleep FROM callback";
40 $check = $db->getRow($sql, DB_FETCHMODE_ASSOC);
41 if(DB::IsError($check)) {
42   // add new field
43   sql('ALTER TABLE callback ADD COLUMN sleep INT DEFAULT 0');
44   }
45
46 $results = array();
47 $sql = "SELECT callback_id, destination FROM callback";
48 $results = $db->getAll($sql, DB_FETCHMODE_ASSOC);
49 if (!DB::IsError($results)) { // error - table must not be there
50   foreach ($results as $result) {
51     $old_dest  = $result['destination'];
52     $callback_id    = $result['callback_id'];
53
54     $new_dest = merge_ext_followme(trim($old_dest));
55     if ($new_dest != $old_dest) {
56       $sql = "UPDATE callback SET destination = '$new_dest' WHERE callback_id = $callback_id  AND destination = '$old_dest'";
57       $results = $db->query($sql);
58       if(DB::IsError($results)) {
59         die_freepbx($results->getMessage());
60       }
61     }
62   }
63 }
64
65 ?>
Note: See TracBrowser for help on using the browser.