From 227d4ce08b90bf6675b875efc7fc11545744e7d6 Mon Sep 17 00:00:00 2001 From: azammitdcarf Date: Mon, 21 Feb 2011 00:30:48 +0000 Subject: [PATCH] Merged changes from vm line --- admin/operatorlist.php | 54 +++++++++++++++++++++-- admin/operators.php | 2 +- functions/functions.freepbx.php | 69 +++++++++++++++++++++++++++++- functions/functions.limesurvey.php | 2 +- include/limesurvey/group.php | 2 + include/limesurvey/question.php | 6 ++- include/limesurvey/quexs.php | 10 +++++ include/limesurvey/survey.php | 3 ++ voip/downloadvoipclient.php | 4 +- 9 files changed, 141 insertions(+), 11 deletions(-) diff --git a/admin/operatorlist.php b/admin/operatorlist.php index c3e7c4f1..e333ce49 100644 --- a/admin/operatorlist.php +++ b/admin/operatorlist.php @@ -62,9 +62,41 @@ if (isset($_POST)) $htp->addUser($_POST["username" . $operator_id],$val); } } + else if (substr($key,0,8) == "timezone") + { + $operator_id = intval(substr($key,8)); + $tzone = $db->qstr($val); + $sql = "UPDATE operator + SET Time_zone_name = $tzone + WHERE operator_id = '$operator_id'"; + $db->Execute($sql); + } } } +if (isset($_GET['voipdisable'])) +{ + $operator_id = intval($_GET['voipdisable']); + + $sql = "UPDATE operator + SET voip = 0 + WHERE operator_id = '$operator_id'"; + + $db->Execute($sql); +} + +if (isset($_GET['voipenable'])) +{ + $operator_id = intval($_GET['voipenable']); + + $sql = "UPDATE operator + SET voip = 1 + WHERE operator_id = '$operator_id'"; + + $db->Execute($sql); +} + + if (isset($_GET['disable'])) { $operator_id = intval($_GET['disable']); @@ -113,9 +145,9 @@ if (isset($_GET['operator_id'])) header("Pragma: public"); // HTTP/1.0 if (isset($_GET['winbat'])) - echo "voipclient.exe -i -u {$rs['ext']} -p {$rs['extension_password']} -h " . $_SERVER['SERVER_ADDR']; + echo "voipclient.exe -i -u {$rs['ext']} -p {$rs['extension_password']} -h " . $_SERVER['SERVER_NAME']; else - echo "./voipclient -i -u {$rs['ext']} -p {$rs['extension_password']} -h " . $_SERVER['SERVER_ADDR']; + echo "./voipclient -i -u {$rs['ext']} -p {$rs['extension_password']} -h " . $_SERVER['SERVER_NAME']; } } } @@ -125,6 +157,12 @@ if ($display) $sql = "SELECT CONCAT(firstName, ' ', lastName) as name, CONCAT('
') as password, + CONCAT('
') as timezone, CONCAT('" . T_("Windows bat file") . "') as winbat, CONCAT('" . T_("*nix script file") . "') as sh, CASE WHEN enabled = 0 THEN @@ -133,6 +171,12 @@ if ($display) CONCAT('" . T_("Disable") . "') END as enabledisable, + CASE WHEN voip = 0 THEN + CONCAT('" . T_("Enable VoIP") . "') + ELSE + CONCAT('" . T_("Disable VoIP") . "') + END + as voipenabledisable, username FROM operator"; @@ -140,8 +184,8 @@ if ($display) xhtml_head(T_("Operator list"),true,array("../css/table.css")); - $columns = array("name","username","enabledisable"); - $titles = array(T_("Operator"),T_("Username"),T_("Enable/Disable")); + $columns = array("name","username","enabledisable","timezone"); + $titles = array(T_("Operator"),T_("Username"),T_("Enable/Disable"),T_("Update timezone")); if (VOIP_ENABLED) { @@ -150,8 +194,10 @@ if ($display) print "

" . T_("Download Windows VoIP Executable") . "

"; print "

" . T_("Download Linux VoIP Executable") . "

"; + $columns[] = "voipenabledisable"; $columns[] = "winbat"; $columns[] = "sh"; + $titles[] = T_("Enable/Disable VoIP"); $titles[] = T_("Windows VoIP"); $titles[] = T_("*nix VoIP"); } diff --git a/admin/operators.php b/admin/operators.php index 2d51c1d1..aefdb6a8 100644 --- a/admin/operators.php +++ b/admin/operators.php @@ -135,7 +135,7 @@ if (isset($_POST['operator'])) $a = T_("Added:") . " " . $operator; if (FREEPBX_PATH !== false) - $a .= "
" . T_("Please reload FreePBX for the new VoIP extension to take effect"); + $a .= "
" . T_("FreePBX has been reloaded for the new VoIP extension to take effect"); $oid = $db->Insert_ID(); diff --git a/functions/functions.freepbx.php b/functions/functions.freepbx.php index 01587b38..22ec5839 100644 --- a/functions/functions.freepbx.php +++ b/functions/functions.freepbx.php @@ -114,9 +114,76 @@ function freepbx_add_extension($extension,$name,$password) freepbx_core_users_add($amp_conf,$astman,$vars); freepbx_core_devices_add($amp_conf,$astman,$vars["deviceid"],$vars["tech"],$vars["devinfo_dial"],$vars["devicetype"],$vars["deviceuser"],$vars["description"],$vars["emergency_cid"],false,$vars); - freepbx_need_reload(); + freepbx_do_reload($amp_conf,$astman,$asterisk_conf); } +function freepbx_do_reload(&$amp_conf,&$astman,&$asterisk_conf) +{ + global $db; + + array($return); + + if (isset($amp_conf["PRE_RELOAD"]) && !empty($amp_conf['PRE_RELOAD'])) { + exec( $amp_conf["PRE_RELOAD"], $output, $exit_val ); + + } + + $retrieve = $amp_conf['AMPBIN'].'/retrieve_conf 2>&1'; + //exec($retrieve.'&>'.$asterisk_conf['astlogdir'].'/freepbx-retrieve.log', $output, $exit_val); + exec($retrieve, $output, $exit_val); + + + if ($exit_val != 0) { + $return['status'] = false; + $return['message'] = sprintf(_('Reload failed because retrieve_conf encountered an error: %s'),$exit_val); + $return['num_errors']++; + $notify->add_critical('freepbx','RCONFFAIL', _("retrieve_conf failed, config not applied"), $return['message']); + return $return; + } + + if (!isset($astman) || !$astman) { + $return['status'] = false; + $return['message'] = _('Reload failed because FreePBX could not connect to the asterisk manager interface.'); + $return['num_errors']++; + return $return; + } + + //reload MOH to get around 'reload' not actually doing that. + $astman->send_request('Command', array('Command'=>'moh reload')); + + //reload asterisk (>= 1.4) + $astman->send_request('Command', array('Command'=>'module reload')); + + $return['status'] = true; + + if ($amp_conf['FOPRUN'] && !$amp_conf['FOPDISABLE']) { + //bounce op_server.pl + $wOpBounce = $amp_conf['AMPBIN'].'/bounce_op.sh'; + exec($wOpBounce.' &>'.$asterisk_conf['astlogdir'].'/freepbx-bounce_op.log', $output, $exit_val); + + if ($exit_val != 0) { + $desc = _('Could not reload the FOP operator panel server using the bounce_op.sh script. Configuration changes may not be reflected in the panel display.'); + $return['num_errors']++; + } + } + + if (isset($amp_conf["POST_RELOAD"]) && !empty($amp_conf['POST_RELOAD'])) { + exec( $amp_conf["POST_RELOAD"], $output, $exit_val ); + + if ($exit_val != 0) { + $desc = sprintf(_("Exit code was %s and output was: %s"), $exit_val, "\n\n".implode("\n",$output)); + $return['num_errors']++; + } + } + + $sql = "UPDATE ".FREEPBX_DATABASE.".admin SET value = 'false' WHERE variable = 'need_reload'"; + + $db->Execute($sql); + + return $return; +} + + function freepbx_need_reload() { diff --git a/functions/functions.limesurvey.php b/functions/functions.limesurvey.php index 23a1cc2d..ee308370 100644 --- a/functions/functions.limesurvey.php +++ b/functions/functions.limesurvey.php @@ -290,7 +290,7 @@ function create_limesurvey_questionnaire($title,$exittoend = true) . "'', '"; if ($exittoend) - $isquery .= QUEXS_URL . "rs_project_end.php')"; + $isquery .= "{ENDINTERVIEWURL}')"; else $isquery .= "{STARTINTERVIEWURL}')"; diff --git a/include/limesurvey/group.php b/include/limesurvey/group.php index aae78f78..eac30b7c 100644 --- a/include/limesurvey/group.php +++ b/include/limesurvey/group.php @@ -232,6 +232,8 @@ if ((isset($move) && $move == "movesubmit") && (!isset($notanswered) || !$notan $quexs_url = get_start_interview_url(); $url = str_replace("{STARTINTERVIEWURL}", $quexs_url, $url); + $end_url = get_end_interview_url(); + $url = str_replace("{ENDINTERVIEWURL}", $end_url, $url); header("Location: {$url}"); diff --git a/include/limesurvey/question.php b/include/limesurvey/question.php index ec7abeb4..1bfba7ca 100644 --- a/include/limesurvey/question.php +++ b/include/limesurvey/question.php @@ -309,8 +309,10 @@ if ((isset($move) && $move == "movesubmit") && (!isset($notanswered) || !$notan include_once("quexs.php"); $quexs_url = get_start_interview_url(); $url = str_replace("{STARTINTERVIEWURL}", $quexs_url, $url); - - header("Location: {$url}"); + $end_url = get_end_interview_url(); + $url = str_replace("{ENDINTERVIEWURL}", $end_url, $url); + + header("Location: {$url}"); } //if($thissurvey['printanswers'] != 'Y' && $thissurvey['usecookie'] != 'Y' && $tokensexist !=1) diff --git a/include/limesurvey/quexs.php b/include/limesurvey/quexs.php index d8e31b2e..0ed23446 100644 --- a/include/limesurvey/quexs.php +++ b/include/limesurvey/quexs.php @@ -687,6 +687,16 @@ function get_respondent_selection_url() } +/** + * Get the URL to end the interview + * + * @return string The URL to end the interview + */ +function get_end_interview_url() +{ + return QUEXS_URL . "rs_project_end.php"; +} + /** * Get start interviewer URL * diff --git a/include/limesurvey/survey.php b/include/limesurvey/survey.php index becdee86..5fc6b7e7 100644 --- a/include/limesurvey/survey.php +++ b/include/limesurvey/survey.php @@ -189,6 +189,9 @@ if ((isset($move) && $move == "movesubmit") && (!isset($notanswered) || !$notans $quexs_url = get_start_interview_url(); $url = str_replace("{STARTINTERVIEWURL}", $quexs_url, $url); + $end_url = get_end_interview_url(); + $url = str_replace("{ENDINTERVIEWURL}", $end_url, $url); + //Automatically redirect the page to the "url" setting for the survey session_write_close(); diff --git a/voip/downloadvoipclient.php b/voip/downloadvoipclient.php index 47a53706..c3048b62 100644 --- a/voip/downloadvoipclient.php +++ b/voip/downloadvoipclient.php @@ -70,7 +70,7 @@ if ($operator_id) copy(realpath(dirname(__FILE__) . '/../voipclient'),"$zipdir/voipclient"); $f1 = "$zipdir/voipclient"; $f2 = "$zipdir/startvoip"; - file_put_contents($f2, "./voipclient -i -u {$rs['ext']} -p {$rs['extension_password']} -h " . $_SERVER['SERVER_ADDR']); + file_put_contents($f2, "./voipclient -i -u {$rs['ext']} -p {$rs['extension_password']} -h " . $_SERVER['SERVER_NAME']); } else @@ -79,7 +79,7 @@ if ($operator_id) copy(realpath(dirname(__FILE__) . '/../voipclient.exe'),"$zipdir/voipclient.exe"); $f1 = "$zipdir/voipclient.exe"; $f2 = "$zipdir/startvoip.bat"; - file_put_contents($f2, "voipclient.exe -i -u {$rs['ext']} -p {$rs['extension_password']} -h " . $_SERVER['SERVER_ADDR']); + file_put_contents($f2, "voipclient.exe -i -u {$rs['ext']} -p {$rs['extension_password']} -h " . $_SERVER['SERVER_NAME']); }