* @copyright Australian Consortium for Social and Political Research Incorporated (ACSPRI) 2007,2008,2009,2010,2011 * @package queXS * @subpackage admin * @link http://www.acspri.org.au/software queXS was writen for ACSPRI * @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2 * */ /** * Configuration file */ include_once(dirname(__FILE__).'/../config.inc.php'); /** * Database */ include_once(dirname(__FILE__).'/../db.inc.php'); /** * XHTML functions */ include_once(dirname(__FILE__).'/../functions/functions.xhtml.php'); $display = true; $msg = ""; if (isset($_POST['submit'])) { $operator_id = intval($_POST['operator_id']); $chat_enable = $voip = $enabled = 0; if (isset($_POST['voip'])) $voip = 1; if (isset($_POST['chat_enable'])) $chat_enable = 1; if (isset($_POST['enabled'])) $enabled = 1; if (HTPASSWD_PATH !== false && $_POST['existing_username'] != $_POST['username'] && empty($_POST['password'])) { $msg = "

" . T_("If changing usernames, you must specify a new password") . "

"; } else { $sql = "UPDATE operator SET username = " . $db->qstr($_POST['username']) . ", lastName = " . $db->qstr($_POST['lastName']) . ", firstName = " . $db->qstr($_POST['firstName']) . ", chat_user = " . $db->qstr($_POST['chat_user']) . ", chat_password = " . $db->qstr($_POST['chat_password']) . ", Time_zone_name = " . $db->qstr($_POST['timezone']) . ", voip = $voip, enabled = $enabled, chat_enable = $chat_enable WHERE operator_id = $operator_id"; $rs = $db->Execute($sql); if (!empty($rs)) { //only update extension if we aren't on a case $sql = "SELECT case_id FROM `case` WHERE current_operator_id = $operator_id"; $cc= $db->GetOne($sql); if (empty($cc)) { $sql = "UPDATE extension SET current_operator_id = NULL WHERE current_operator_id= $operator_id"; $db->Execute($sql); if (!empty($_POST['extension_id'])) { $sql = "UPDATE extension SET current_operator_id = $operator_id WHERE extension_id = " . intval($_POST['extension_id']); $db->Execute($sql); } } if (HTPASSWD_PATH !== false && !empty($_POST['password'])) { //update password in htaccess include_once(dirname(__FILE__).'/../functions/functions.htpasswd.php'); $htp = New Htpasswd(HTPASSWD_PATH); $htp->deleteUser($_POST["existing_username"]); $htp->deleteUser($_POST["username"]); $htp->addUser($_POST["username"],$_POST["password"]); $htg = New Htgroup(HTGROUP_PATH); $htg->deleteUserFromGroup($_POST["existing_username"],HTGROUP_INTERVIEWER); $htg->addUserToGroup($_POST["username"],HTGROUP_INTERVIEWER); } $msg = "

" . T_("Successfully updated user") . ": " . $_POST['username'] . "

"; } else { $msg = "

" . T_("Failed to update user") . ": " . $_POST['username'] . " " . T_("Please make sure the username is unique") . "

"; } } $_GET['edit'] = $operator_id; } if (isset($_GET['edit'])) { xhtml_head(T_("Edit Operator settings"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../include/bootstrap-toggle/css/bootstrap-toggle.min.css", "../css/custom.css"),array("../js/jquery-2.1.3.min.js","../include/bootstrap-3.3.2/js/bootstrap.min.js","../include/bootstrap-toggle/js/bootstrap-toggle.min.js")); $operator_id = intval($_GET['edit']); $sql = "SELECT * FROM operator WHERE operator_id = $operator_id"; $rs = $db->GetRow($sql); $sql = "SELECT Time_zone_name as value, Time_zone_name as description FROM timezone_template"; $tz = $db->GetAll($sql); ?>
" . T_("Operator") . ": " . $rs['username'] . ""; echo "
"; if (!empty($msg)) echo $msg; $sql = "SELECT extension_id as value, extension as description, CASE WHEN current_operator_id = $operator_id THEN 'selected=\'selected\'' ELSE '' END AS selected FROM extension WHERE current_operator_id IS NULL OR current_operator_id = $operator_id"; $ers = $db->GetAll($sql); ?>
"/>
" class="btn btn-default"/> 
" data-off="" value="1" />
" data-off="" value="1"/>
" data-off="" value="1" />
"/>
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']); $sql = "UPDATE operator SET enabled = 0 WHERE operator_id = '$operator_id'"; $db->Execute($sql); } if (isset($_GET['enable'])) { $operator_id = intval($_GET['enable']); $sql = "UPDATE operator SET enabled = 1 WHERE operator_id = '$operator_id'"; $db->Execute($sql); } if (isset($_GET['operator_id'])) { $operator_id = intval($_GET['operator_id']); $sql = "SELECT *,SUBSTRING_INDEX(e.extension, '/', -1) as ext FROM extension as e WHERE e.current_operator_id = $operator_id"; $rs = $db->GetRow($sql); if (!empty($rs)) { $display = false; if (isset($_GET['winbat']) || isset($_GET['sh'])) { header("Content-Type: text/txt"); if (isset($_GET['winbat'])) header("Content-Disposition: attachment; filename=operator_$operator_id.bat"); else header("Content-Disposition: attachment; filename=operator_$operator_id.sh"); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Pragma: public"); // HTTP/1.0 if (isset($_GET['winbat'])) echo "voipclient.exe -i -u {$rs['ext']} -p {$rs['password']} -h " . $_SERVER['SERVER_NAME']; else echo "./voipclient -i -u {$rs['ext']} -p {$rs['password']} -h " . $_SERVER['SERVER_NAME']; } } } if ($display) { $sql = "SELECT operator_id, CONCAT(firstName, ' ', lastName) as name, CONCAT ('', e.extension ,'') as `extension`, CONCAT('" . TQ_("Win .bat file") . "') as winbat, CONCAT('" . TQ_("*nix script file") . "') as sh, CASE WHEN enabled = 0 THEN CONCAT('  ') ELSE CONCAT('  ') END as enabledisable, CASE WHEN voip = 0 THEN CONCAT('" . TQ_("Enable VoIP") . "') ELSE CONCAT('" . TQ_("Disable VoIP") . "') END as voipenabledisable, CONCAT('  ') as edit, username FROM operator LEFT JOIN `extension` as e ON (e.current_operator_id = operator_id)"; $rs = $db->GetAll($sql); xhtml_head(T_("Operator list"),true,array("../include/bootstrap-3.3.2/css/bootstrap.min.css","../include/font-awesome-4.3.0/css/font-awesome.css","../css/custom.css")); $columns = array("operator_id","name","username","extension","enabledisable","edit"); $titles = array("ID",T_("Operator"),T_("Username"),T_("Extension")," "," "); if (VOIP_ENABLED) { $columns[] = "voipenabledisable"; $columns[] = "winbat"; $columns[] = "sh"; $titles[] = T_("VoIP ON/Off"); $titles[] = T_("Win file");//Windows VoIP $titles[] = T_("*nix flle");//*nix VoIP } echo "
"; xhtml_table($rs,$columns,$titles); echo "
"; echo "
 " . T_("Add an operator") . "
 " . T_("Extensions") . "
" . T_("Assign to questionnaire") . "
 " . T_("Operator skills") . "
 " . T_("Operator performance") . "
"; if (VOIP_ENABLED) { print "
" . T_("Download the file for each user and save in the same folder as the voip.exe executable. When the file is executed, it will run the voip.exe program with the correct connection details to connect the operator to the VoIP server"). "

"; print " " . T_("Download Win file") . "
"; print " " . T_("Download Linux file") . "
"; } print "
"; xhtml_foot(); } ?>