| 1 |
<?php |
|---|
| 2 |
/* $Id$ */ |
|---|
| 3 |
// |
|---|
| 4 |
/* |
|---|
| 5 |
* functions.inc.php |
|---|
| 6 |
* |
|---|
| 7 |
* Copyright 2009 James Finstrom <jfinstrom@RhinoEquipment.com> |
|---|
| 8 |
* |
|---|
| 9 |
* This program is free software; you can redistribute it and/or modify |
|---|
| 10 |
* it under the terms of the GNU General Public License as published by |
|---|
| 11 |
* the Free Software Foundation; either version 2 of the License, or |
|---|
| 12 |
* (at your option) any later version. |
|---|
| 13 |
* |
|---|
| 14 |
* This program is distributed in the hope that it will be useful, |
|---|
| 15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 17 |
* GNU General Public License for more details. |
|---|
| 18 |
* |
|---|
| 19 |
* You should have received a copy of the GNU General Public License |
|---|
| 20 |
* along with this program; if not, write to the Free Software |
|---|
| 21 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|---|
| 22 |
* MA 02110-1301, USA. |
|---|
| 23 |
*/ |
|---|
| 24 |
function tweet2call_get_config($engine) { |
|---|
| 25 |
global $db; |
|---|
| 26 |
global $ext; |
|---|
| 27 |
global $version; |
|---|
| 28 |
global $astman; |
|---|
| 29 |
switch($engine) { |
|---|
| 30 |
case "asterisk": |
|---|
| 31 |
$id = "app-tweet2call"; |
|---|
| 32 |
$results = sql("SELECT * FROM `tweet2call_departments`;","getAll",DB_FETCHMODE_ASSOC); |
|---|
| 33 |
if (empty($results)) { |
|---|
| 34 |
return array(); |
|---|
| 35 |
} else { |
|---|
| 36 |
foreach ($results as $result) { |
|---|
| 37 |
$exten = $result['queue']; |
|---|
| 38 |
$priority = $result['weight']; |
|---|
| 39 |
$department = $result['department']; |
|---|
| 40 |
$ext->add($id , $department , '' , new ext_setvar("QUEUE_PRIO", $priority)); |
|---|
| 41 |
$ext->add($id , $department , '' , new ext_goto('1', $exten, 'ext-queues')); |
|---|
| 42 |
} |
|---|
| 43 |
} |
|---|
| 44 |
} |
|---|
| 45 |
} |
|---|
| 46 |
|
|---|
| 47 |
function tweet2call_add_department($dept, $queue, $weight){ |
|---|
| 48 |
global $db; |
|---|
| 49 |
$results = sql("INSERT INTO tweet2call_departments (department, queue, weight) VALUES ('$dept', '$queue', '$weight') ON DUPLICATE KEY UPDATE queue='$queue', weight = '$weight'"); |
|---|
| 50 |
needreload(); |
|---|
| 51 |
} |
|---|
| 52 |
|
|---|
| 53 |
function tweet2call_del_department($dept){ |
|---|
| 54 |
global $db; |
|---|
| 55 |
//$results = sql("DELETE FROM tweet2call_departments WHERE department = '$dept'"); |
|---|
| 56 |
$sql= "DELETE FROM tweet2call_departments WHERE department = '$dept'"; |
|---|
| 57 |
$result = $db->query($sql); |
|---|
| 58 |
if(DB::IsError($result)) { |
|---|
| 59 |
die_freepbx($result->getMessage().$sql); |
|---|
| 60 |
} |
|---|
| 61 |
needreload(); |
|---|
| 62 |
|
|---|
| 63 |
} |
|---|
| 64 |
|
|---|
| 65 |
function tweet2call_add_settings($twitid, $twitpass, $polltime, $blacklist, $trunk){ |
|---|
| 66 |
global $db; |
|---|
| 67 |
$results = sql("INSERT INTO tweet2call_settings (twitid, twitpass, polltime, blacklist, trunk) VALUES ('$twitid', '$twitpass', '$polltime', '$blacklist', '$trunk') ON DUPLICATE KEY UPDATE twitpass='$twitpass', polltime = '$polltime', blacklist='$blacklist', trunk = '$trunk'"); |
|---|
| 68 |
} |
|---|
| 69 |
|
|---|
| 70 |
?> |
|---|