From 2288dc81342b7fa26e8ff779a8459e230ea4384b Mon Sep 17 00:00:00 2001 From: azammitdcarf Date: Thu, 12 Nov 2009 03:45:25 +0000 Subject: [PATCH] VoIP is done on an operator by operator basis --- admin/operators.php | 8 +++++--- call.php | 10 +++++----- database/quexs.sql | 1 + functions/functions.operator.php | 26 ++++++++++++++++++++++++++ include/limesurvey/index.php | 2 +- record.php | 4 ++-- status.php | 8 ++++---- supervisor.php | 30 ++++++++++++++++++++++++------ 8 files changed, 68 insertions(+), 21 deletions(-) diff --git a/admin/operators.php b/admin/operators.php index 02a41b0d..cfeba5d8 100644 --- a/admin/operators.php +++ b/admin/operators.php @@ -62,14 +62,16 @@ if (isset($_POST['operator'])) $supervisor = 0; $temporary = 0; $refusal = 0; + $voip = 0; if (isset($_POST['supervisor']) && $_POST['supervisor'] == "on") $supervisor = 1; if (isset($_POST['refusal']) && $_POST['refusal'] == "on") $refusal = 1; if (isset($_POST['temporary']) && $_POST['temporary'] == "on") $temporary = 1; + if (isset($_POST['voip']) && $_POST['voip'] == "on") $voip = 1; if (!empty($_POST['operator'])) { $sql = "INSERT INTO operator - (`operator_id` ,`username` ,`firstName` ,`lastName`, `extension`, `Time_zone_name`) - VALUES (NULL , $operator, $firstname , $lastname, $extension, $time_zone_name);"; + (`operator_id` ,`username` ,`firstName` ,`lastName`, `extension`, `Time_zone_name`,`voip`) + VALUES (NULL , $operator, $firstname , $lastname, $extension, $time_zone_name, $voip);"; if ($db->Execute($sql)) { @@ -123,6 +125,7 @@ if ($a)

+

@@ -134,4 +137,3 @@ if ($a) xhtml_foot(); ?> - diff --git a/call.php b/call.php index 803c72b8..db14cf86 100644 --- a/call.php +++ b/call.php @@ -155,7 +155,7 @@ if (isset($_POST['submit'])) $call_id = get_call($operator_id,$respondent_id,$contact_phone_id,true); if ($call_id) { - if (VOIP_ENABLED) + if (is_voip_enabled($operator_id)) { include("functions/functions.voip.php"); $v = new voip(); @@ -173,7 +173,7 @@ if (isset($_POST['submit'])) { $outcome_id = bigintval($_POST['outcome']); end_call($operator_id,$outcome_id); - if (VOIP_ENABLED) + if (is_voip_enabled($operator_id)) { include("functions/functions.voip.php"); $v = new voip(); @@ -187,7 +187,7 @@ if (isset($_POST['submit'])) else { //if no outcome selected, just hang up the call - if (VOIP_ENABLED) + if (is_voip_enabled($operator_id)) { include("functions/functions.voip.php"); $v = new voip(); @@ -251,7 +251,7 @@ switch($state) { //determine whether to begin calling based on extension status $es = 1; - if (VOIP_ENABLED) + if (is_voip_enabled($operator_id)) { include("functions/functions.voip.php"); $v = new voip(); @@ -331,7 +331,7 @@ switch($state) { //determine whether to begin calling based on extension status $es = 1; - if (VOIP_ENABLED) + if (is_voip_enabled($operator_id)) { include("functions/functions.voip.php"); $v = new voip(); diff --git a/database/quexs.sql b/database/quexs.sql index c4dc9ea8..757d5e73 100644 --- a/database/quexs.sql +++ b/database/quexs.sql @@ -304,6 +304,7 @@ CREATE TABLE `operator` ( `extension` varchar(10) NOT NULL, `Time_zone_name` char(64) NOT NULL, `enabled` tinyint(1) NOT NULL default '1', + `voip` tinyint(1) NOT NULL default '1', PRIMARY KEY (`operator_id`), UNIQUE KEY `username` (`username`), UNIQUE KEY `extension` (`extension`) diff --git a/functions/functions.operator.php b/functions/functions.operator.php index a5457f55..4a0baa24 100644 --- a/functions/functions.operator.php +++ b/functions/functions.operator.php @@ -44,6 +44,32 @@ include_once(dirname(__FILE__).'/../config.inc.php'); include_once(dirname(__FILE__).'/../db.inc.php'); +/** + * Return if VOIP is enabled on an operator by operator basis + * Will always return false if VOIP is globally disabled + * + * @param int $operator_id the operator id + * @return bool True if enabled, false if not + */ +function is_voip_enabled($operator_id) +{ + if (VOIP_ENABLED == false) + return false; + + global $db; + + $sql = "SELECT voip + FROM operator + WHERE operator_id = '$operator_id'"; + + $rs = $db->GetRow($sql); + + if ($rs['voip'] == '1') + return true; + + return false; +} + /** * Return the period of the day for the respondent * diff --git a/include/limesurvey/index.php b/include/limesurvey/index.php index f9a65f9e..60ff43f7 100644 --- a/include/limesurvey/index.php +++ b/include/limesurvey/index.php @@ -2094,7 +2094,7 @@ UpdateSessionGroupList($_SESSION['s_lang']); { if (isset($_GET[$field])) { - $_SESSION[$field]=$_GET[$field]; + $_SESSION[$field]=urldecode($_GET[$field]); } } } diff --git a/record.php b/record.php index 9b88cc4e..4faf56ba 100644 --- a/record.php +++ b/record.php @@ -54,7 +54,7 @@ if (is_on_call($operator_id) == 3) { $newtext = T_("Stop REC"); xhtml_head(T_("Record"),true,array("css/call.css"),array("js/window.js"),"onload='toggleRec(\"$newtext\",\"record.php?stop=stop\",\"online\")'"); - if (VOIP_ENABLED) + if (is_voip_enabled($operator_id)) { $call_id = get_call($operator_id); if ($call_id) @@ -77,7 +77,7 @@ if (is_on_call($operator_id) == 3) { $newtext = T_("Start REC"); xhtml_head(T_("Record"),true,array("css/call.css"),array("js/window.js"),"onload='toggleRec(\"$newtext\",\"record.php?start=start\",\"offline\")'"); - if (VOIP_ENABLED) + if (is_voip_enabled($operator_id)) { include("functions/functions.voip.php"); $v = new voip(); diff --git a/status.php b/status.php index 12becb3f..2b0623ec 100644 --- a/status.php +++ b/status.php @@ -58,7 +58,7 @@ $btext = false; if ($state == 4 && AUTO_POPUP) $btext = "onload=\"poptastic('call.php')\""; -xhtml_head(T_("Status"),true,array("css/status.css"),array("js/popupkeep.js"),$btext,5); +xhtml_head(T_("Status"),true,array("css/status.css"),array("js/popupkeep.js"),$btext,10); print "
" . get_operator_time($operator_id,"%a %d %b %h:%i%p") ."
"; @@ -66,16 +66,16 @@ print "
" . get_operator_time($operator_id,"%a %d %b %h:%i%p") //Then confirm whether or not they are on a call (or use the database table, call to determine) -if (VOIP_ENABLED) +if (is_voip_enabled($operator_id)) { include("functions/functions.voip.php"); $v = new voip(); $v->connect(VOIP_SERVER); $ext = get_extension($operator_id); if ($v->getExtensionStatus($ext)) - print ""; + print "
" . T_("VoIP On") . "
"; else - print ""; + print "
" . T_("VoIP Off") . "
"; } else print "
" . T_("No VoIP") . "
"; diff --git a/supervisor.php b/supervisor.php index 16a63309..23e676f2 100644 --- a/supervisor.php +++ b/supervisor.php @@ -58,19 +58,28 @@ $callstatus = is_on_call($operator_id); if ($callstatus == 3) //On a call { - if (VOIP_ENABLED) + if (is_voip_enabled($operator_id)) { if (isset($_GET['callsupervisor'])) { include("functions/functions.voip.php"); $v = new voip(); $v->connect(VOIP_SERVER); - $v->addParty(get_extension($operator_id),SUPERVISOR_EXTENSION); - print "

" . T_("Calling the supervisor, you may close this window") . "

"; + if (strcmp($_GET['callsupervisor'],"hangup") == 0) + { + $v->hangup(get_extension($operator_id)); + print "

" . T_("You may now close this window") . "

"; + } + else + { + $v->addParty(get_extension($operator_id),SUPERVISOR_EXTENSION); + print "

" . T_("Calling the supervisor, you may close this window") . "

"; + } } else { print "

" . T_("Click here to call the supervisor's phone. A conference call will be created with the respondent, yourself and the supervisor. Otherwise close this window") . "

"; +// print "

" . T_("Hangup when calling the supervisor") . "

"; } } else @@ -80,19 +89,28 @@ if ($callstatus == 3) //On a call } else if ($callstatus == 0 || $callstatus == 4 || $callstatus == 5) { - if (VOIP_ENABLED) + if (is_voip_enabled($operator_id)) { if (isset($_GET['callsupervisor'])) { include("functions/functions.voip.php"); $v = new voip(); $v->connect(VOIP_SERVER); - $v->dial(get_extension($operator_id),SUPERVISOR_EXTENSION); - print "

" . T_("Calling the supervisor, you may close this window") . "

"; + if (strcmp($_GET['callsupervisor'],"hangup") == 0) + { + $v->hangup(get_extension($operator_id)); + print "

" . T_("You may now close this window") . "

"; + } + else + { + $v->dial(get_extension($operator_id),SUPERVISOR_EXTENSION); + print "

" . T_("Calling the supervisor, you may close this window") . "

"; + } } else { print "

" . T_("Click here to call the supervisor's phone. Otherwise close this window") . "

"; +// print "

" . T_("Hangup when calling the supervisor") . "

"; } } else