function Version($rowOrVnid = "") { if (is_array($rowOrVnid)) { $this->version = $rowOrVnid; } else { if ($rowOrVnid != "") { global $db; $result = $db->selectQuery('select * from ' . Config::dbSurvey() . '_versions where suid=' . prepareDatabaseString(getSurvey()) . ' and vnid = ' . prepareDatabaseString($rowOrVnid)); $this->version = $db->getRow($result); } } }
function redirect($page) { global $survey; $returnStr = $this->showHeader($survey->getTitle(), '<link href="bootstrap/css/sticky-footer-navbar.min.css" rel="stylesheet">'); $returnStr .= '<form method="post" action="../index.php">'; $returnStr .= '<input type=hidden name="' . POST_PARAM_PRIMKEY . '" value="' . addslashes(encryptC($this->primkey, Config::directLoginKey())) . '">'; $returnStr .= '<input type=hidden name="' . POST_PARAM_SUID . '" value="' . getSurvey() . '">'; $returnStr .= '<input type=hidden name="' . POST_PARAM_LANGUAGE . '" value="' . getSurveyLanguage() . '">'; $returnStr .= '<input type=hidden name="' . POST_PARAM_MODE . '" value="' . getSurveyMode() . '">'; $returnStr .= setSessionParamsPost(array('page' => $page)); $returnStr .= '</form>'; $returnStr .= '<script>'; $returnStr .= '$(document).ready(function(){ $("form:first").submit(); }); '; $returnStr .= '</script></body><html>'; return $returnStr; }
function addAction($primkey, $urid, $page, $systemtype = USCIC_SMS, $actiontype = 1) { global $db; $query = 'INSERT INTO ' . Config::dbSurveyData() . '_actions (primkey, sessionid, urid, suid, ipaddress, systemtype, action, actiontype, params, language, mode, version) VALUES ('; if ($primkey != '') { $query .= '\'' . prepareDatabaseString($primkey) . '\', '; } else { $query .= 'NULL, '; } $query .= '\'' . session_id() . '\', '; if ($urid != '') { $query .= '\'' . $urid . '\', '; } else { $query .= 'NULL, '; } if ($systemtype == USCIC_SURVEY) { $query .= getSurvey() . ', '; } else { $query .= 'NULL, '; } $query .= '\'' . prepareDatabaseString(getClientIp()) . '\', '; $query .= $systemtype . ', '; $query .= '\'' . prepareDatabaseString($page) . '\', '; $query .= $actiontype . ', '; if (Config::logParams()) { //log post vars? $query .= ' AES_ENCRYPT(\'' . prepareDatabaseString(serialize($_POST)) . '\', \'' . Config::logActionParamsKey() . '\'), '; } else { $query .= ' NULL, '; } if ($systemtype == USCIC_SURVEY) { $query .= getSurveyLanguage() . ', '; $query .= getSurveyMode() . ', '; $query .= getSurveyVersion(); } else { $query .= 'NULL, NULL, NULL'; } $query .= ")"; $db->executeQuery($query); if (isset($this->LogActions[$primkey])) { //unset so it is read in again.. unset($this->LogActions[$primkey]); } }
function showTest($content = "") { $returnStr = $this->showToolsHeader(Language::headerToolsTester()); $returnStr .= $content; $surveys = new Surveys(); $surveys = $surveys->getSurveys(); if (sizeof($surveys) > 0) { $returnStr .= "<form id=refreshform method=post>"; $returnStr .= '<input type=hidden name=page value="translator.tools.test">'; $returnStr .= '<input type=hidden name="' . SMS_POST_SURVEY . '" id="' . SMS_POST_SURVEY . '_hidden" value="' . getSurvey() . '">'; $returnStr .= '<input type=hidden name="' . SMS_POST_MODE . '" id="' . SMS_POST_MODE . '_hidden" value="' . getSurveyMode() . '">'; $returnStr .= '<input type=hidden name="' . SMS_POST_LANGUAGE . '" id="' . SMS_POST_LANGUAGE . '_hidden" value="' . getSurveyLanguage() . '">'; $returnStr .= "</form>"; $returnStr .= "<form method=post>"; $returnStr .= '<input type=hidden name=' . POST_PARAM_SE . ' value="' . addslashes(USCIC_SURVEY) . '">'; $returnStr .= '<input type=hidden name=' . POST_PARAM_PRIMKEY . ' value="' . addslashes(encryptC(generateRandomPrimkey(8), Config::directLoginKey())) . '">'; $returnStr .= '<input type=hidden name=' . POST_PARAM_NEW_PRIMKEY . ' value="1">'; $returnStr .= '<input type=hidden name=' . POST_PARAM_SURVEY_EXECUTION_MODE . ' value="' . SURVEY_EXECUTION_MODE_TEST . '">'; $returnStr .= '<span class="label label-default">' . Language::labelToolsTestSettings() . '</span>'; $returnStr .= '<div class="well well-sm">'; $returnStr .= $this->displayComboBox(); $returnStr .= '<table>'; $returnStr .= '<tr><td>' . Language::labelTestSurvey() . "</td><td><select onchange='document.getElementById(\"" . SMS_POST_SURVEY . "_hidden\").value=this.value; document.getElementById(\"refreshform\").submit();' name=" . POST_PARAM_SUID . " class='selectpicker show-tick'>"; $current = new Survey(getSurvey()); foreach ($surveys as $survey) { $selected = ""; if ($survey->getSuid() == $current->getSuid()) { $selected = "SELECTED"; } $returnStr .= "<option {$selected} value=" . $survey->getSuid() . '>' . $survey->getName() . '</option>'; } $returnStr .= "</select></td></tr>"; $user = new User($_SESSION['URID']); $cm = getSurveyMode(); $cl = getSurveyLanguage(); $modes = $user->getModes(getSurvey()); $langs = explode("~", $user->getLanguages(getSurvey(), getSurveyMode())); $default = $current->getDefaultLanguage(); if (!inArray($default, $langs)) { $langs[] = $default; } $returnStr .= "<tr><td>" . Language::labelTestModeInput() . "</td><td>" . $this->displayModesAdmin(POST_PARAM_MODE, POST_PARAM_MODE, getSurveyMode(), "", implode("~", $modes), "onchange='document.getElementById(\"" . SMS_POST_MODE . "_hidden\").value=this.value; document.getElementById(\"refreshform\").submit();'") . "</td></tr>"; $returnStr .= "<tr><td>" . Language::labelTestLanguage() . "</td><td>" . $this->displayLanguagesAdmin(POST_PARAM_LANGUAGE, POST_PARAM_LANGUAGE, getSurveyLanguage(), true, true, false, "", implode("~", $langs)) . "</td></tr>"; $returnStr .= '</table>'; $returnStr .= '</div>'; $returnStr .= '<button type="submit" class="btn btn-default navbar-btn">' . Language::buttonTest() . '</button>'; $returnStr .= "</form>"; } else { $returnStr .= $this->displayInfo(Language::messageNoSurveysAvailable()); } $returnStr .= '</p></div></div>'; //container and wrap $returnStr .= $this->showBottomBar(); $returnStr .= $this->showFooter(false); return $returnStr; }
private function storeAnswer($primkey, $variable, $answer, $striptags = true) { global $engine; $localdb = null; if (Config::useTransactions() == true) { global $transdb; $localdb = $transdb; } else { global $db; $localdb = $db; } $dirty = $this->getDirty(); $prim = $primkey; $var = $variable; //$engine->prefixVariableName($variable); $ans = $answer; if ($ans == "" && $ans !== 0) { // preserve '0' as answer $ans = null; } $version = getSurveyVersion(); $language = getSurveyLanguage(); $mode = getSurveyMode(); $suid = getSurvey(); // set session language/mode here if changed through routing! if ($ans != null) { if (strtoupper($variable) == strtoupper(VARIABLE_LANGUAGE)) { $_SESSION['PARAMS'][SESSION_PARAM_LANGUAGE] = $ans; } else { if (strtoupper($variable) == strtoupper(VARIABLE_MODE)) { $_SESSION['PARAMS'][SESSION_PARAM_MODE] = $ans; } else { if (strtoupper($variable) == strtoupper(VARIABLE_VERSION)) { $_SESSION['PARAMS'][SESSION_PARAM_VERSION] = $ans; } else { if (strtoupper($variable) == strtoupper(VARIABLE_TEMPLATE)) { $_SESSION['PARAMS'][SESSION_PARAM_TEMPLATE] = $ans; } } } } } /* set attributes for data record processing in export */ $this->suid = $suid; $this->primkey = $prim; $this->language = $language; $this->mode = $mode; $this->version = $version; $this->ts = date("Y-m-d h:i:s", time()); if (Config::prepareDataQueries() == false) { global $survey; $key = $survey->getDataEncryptionKey(); if ($ans == null && $ans !== 0) { $answer = 'null'; } else { $answer = '"' . prepareDatabaseString($ans, $striptags) . '"'; if ($key != "") { $answer = "aes_encrypt('" . prepareDatabaseString($ans, $striptags) . "', '" . $key . "')"; } } $queryparams = 'suid, primkey, variablename, answer, dirty, version, language, mode'; $queryvalues = prepareDatabaseString($suid); $queryvalues .= ",'" . prepareDatabaseString($prim) . "'"; $queryvalues .= ",'" . prepareDatabaseString($var) . "'"; $queryvalues .= "," . $answer; $queryvalues .= "," . prepareDatabaseString($dirty); $queryvalues .= "," . prepareDatabaseString($version); $queryvalues .= "," . prepareDatabaseString($language); $queryvalues .= "," . prepareDatabaseString($mode); $query = 'REPLACE INTO ' . Config::dbSurveyData() . '_data (' . $queryparams . ') VALUES (' . $queryvalues . ')'; //echo $query; if ($localdb->executeQuery($query)) { $this->variable["answer"] = $ans; // hook for extra storage if (function_exists("storeAnswerExtra")) { storeAnswerExtra($query); } return true; } return false; } else { $bp = new BindParam(); $bp->add(MYSQL_BINDING_STRING, $suid); $bp->add(MYSQL_BINDING_STRING, $prim); $bp->add(MYSQL_BINDING_STRING, $var); $bp->add(MYSQL_BINDING_STRING, $ans); $bp->add(MYSQL_BINDING_INTEGER, $dirty); $bp->add(MYSQL_BINDING_INTEGER, $version); $bp->add(MYSQL_BINDING_INTEGER, $language); $bp->add(MYSQL_BINDING_INTEGER, $mode); global $survey; $key = $survey->getDataEncryptionKey(); $answer = "?"; if ($key != "") { $answer = "aes_encrypt(?, '" . $key . "')"; } $queryparams = 'suid, primkey, variablename, answer, dirty, version, language, mode'; $queryvalues = '?,?,?,' . $answer . ',?,?,?,?'; $query = 'REPLACE INTO ' . Config::dbSurveyData() . '_data (' . $queryparams . ') VALUES (' . $queryvalues . ')'; if ($localdb->executeBoundQuery($query, $bp->get())) { $this->variable["answer"] = $ans; // hook for extra storage if (function_exists("storeAnswerExtra")) { storeAnswerExtra($queryparams, $queryvalues, $bp); } return true; } return false; } }
function checkUserAccess() { $user = new User($_SESSION['URID']); $cm = getSurveyMode(); $cl = getSurveyLanguage(); $modes = $user->getModes(); $languages = explode("~", $user->getLanguages(getSurvey(), getSurveyMode())); if (!inArray($cm, $modes) || !inArray($cl, $languages)) { return false; } return true; }
public function showNavBar() { $returnStr = $this->getHeader(); //language $rgid = $this->engine->getRgid(); $variablenames = $this->getRealVariables(explode("~", $this->engine->getDisplayed())); $variablenamesfull = $this->engine->getDisplayed(); $template = $this->engine->getTemplate(); $click = ""; if ($template != "") { $group = $this->engine->getGroup($template); $click = $this->engine->replaceFills($group->getClickLanguageChange()); } else { $vars = explode("~", $variablenames); $var = $this->engine->getVariableDescriptive($vars[0]); $click = $this->engine->replaceFills($var->getClickLanguageChange()); } $click = str_replace("'", "", $click); $clickmode = ""; if ($template != "") { $group = $this->engine->getGroup($template); $clickmode = $this->engine->replaceFills($group->getClickModeChange()); } else { $vars = explode("~", $variablenames); $var = $this->engine->getVariableDescriptive($vars[0]); $clickmode = $this->engine->replaceFills($var->getClickModeChange()); } $clickmode = str_replace("'", "", $clickmode); // begin language global $survey; $user = new User($_SESSION['URID']); $allowedmodes = $user->getModes(); $allowedlanguages = explode("~", $user->getLanguages(getSurvey(), getSurveyMode())); $default = $survey->getDefaultLanguage(); $ut = "sysadmin"; if ($user->getUserType() == USER_TRANSLATOR) { $ut = "translator"; if (!inArray($default, $allowedlanguages)) { $allowedlanguages[] = $default; } } else { if ($user->GetUserType() == USER_TESTER) { $ut = "tester"; } } if (getSurveyModeAllowChange() == MODE_CHANGE_RESPONDENT_ALLOWED) { //$allowed = explode("~", $survey->getAllowedModes()); if (sizeof($allowedmodes) > 1) { $template = $this->engine->getTemplate(); $returnStr .= '<li class="dropdown">'; $returnStr .= ' <a href="#" class="dropdown-toggle" data-toggle="dropdown">Mode <b class="caret"></b></a>'; $returnStr .= '<ul class="dropdown-menu" role="menu">'; $current = getSurveyMode(); $modes = Common::surveyModes(); foreach ($modes as $key => $mode) { if (inArray($key, $allowedmodes)) { $check = ''; if ($key == $current) { $check = ' <span class="glyphicon glyphicon-ok"></span>'; } //$returnStr .= '<li><a href=# onclick=\'document.getElementById("r").value="' . setSessionsParamString(array_merge(array(SESSION_PARAM_LASTACTION => $this->engine->getLastSurveyAction(), SESSION_PARAM_SURVEY => $survey->getSuid(), SESSION_PARAM_PRIMKEY => $this->primkey, SESSION_PARAM_RGID => $rgid, SESSION_PARAM_VARIABLES => $variablenames, SESSION_PARAM_GROUP => $template, SESSION_PARAM_MODE => $current, SESSION_PARAM_VERSION => getSurveyVersion(), SESSION_PARAM_LANGUAGE => getSurveyLanguage(), SESSION_PARAM_TIMESTAMP => time(), SESSION_PARAM_SEID => $this->engine->getSeid(), SESSION_PARAM_MAINSEID => $this->engine->getMainSeid()), array(SESSION_PARAM_NEWMODE => $key))) . '"; document.getElementById("navigation").value="' . NAVIGATION_MODE_CHANGE . '"; $("#form").submit(); \'>' . $mode . $check . '</a></li>'; $returnStr .= '<li><a href=# onclick=\'document.getElementById("r").value="' . setSessionsParamString(array_merge(array(SESSION_PARAM_SURVEY => $survey->getSuid(), SESSION_PARAM_PRIMKEY => $this->engine->getPrimaryKey(), SESSION_PARAM_RGID => $rgid, SESSION_PARAM_VARIABLES => $variablenames, SESSION_PARAM_GROUP => $template, SESSION_PARAM_MODE => getSurveyMode(), SESSION_PARAM_LANGUAGE => getSurveyLanguage(), SESSION_PARAM_TEMPLATE => getSurveyTemplate(), SESSION_PARAM_TIMESTAMP => time(), SESSION_PARAM_SEID => $this->engine->getSeid(), SESSION_PARAM_MAINSEID => $this->engine->getMainSeid()), array(SESSION_PARAM_NEWMODE => $key))) . '"; document.getElementById("navigation").value="' . addslashes(Language::buttonUpdate()) . '"; ' . $clickmode . ' document.getElementById("form").submit(); \'>' . $mode . $check . '</a></li>'; } } $returnStr .= '</ul></li>'; } } if (getSurveyLanguageAllowChange() == LANGUAGE_CHANGE_RESPONDENT_ALLOWED) { //$allowed = explode("~", $survey->getAllowedLanguages(getSurveyMode())); if (sizeof($allowedlanguages) > 1) { $returnStr .= '<li class="dropdown">'; $returnStr .= ' <a href="#" class="dropdown-toggle" data-toggle="dropdown">Language <b class="caret"></b></a><ul class="dropdown-menu">'; $langs = Language::getLanguagesArray(); //getSurveyLanguages($this->engine->survey); foreach ($langs as $lang) { if (inArray($lang["value"], $allowedlanguages)) { $check = ''; if ($lang["value"] == getSurveyLanguage()) { $check = ' <span class="glyphicon glyphicon-ok"></span>'; } $returnStr .= '<li><a href=# onclick=\'document.getElementById("r").value="' . setSessionsParamString(array_merge(array(SESSION_PARAM_SURVEY => $survey->getSuid(), SESSION_PARAM_PRIMKEY => $this->engine->getPrimaryKey(), SESSION_PARAM_RGID => $rgid, SESSION_PARAM_VARIABLES => $variablenames, SESSION_PARAM_GROUP => $template, SESSION_PARAM_MODE => getSurveyMode(), SESSION_PARAM_LANGUAGE => getSurveyLanguage(), SESSION_PARAM_TEMPLATE => getSurveyTemplate(), SESSION_PARAM_TIMESTAMP => time(), SESSION_PARAM_SEID => $this->engine->getSeid(), SESSION_PARAM_MAINSEID => $this->engine->getMainSeid()), array(SESSION_PARAM_NEWLANGUAGE => $lang["value"]))) . '"; document.getElementById("navigation").value="' . addslashes(Language::buttonUpdate()) . '"; ' . $click . ' document.getElementById("form").submit(); \'>' . $lang["name"] . $check . '</a></li>'; } } $returnStr .= '</ul></li>'; } //end language } $user = new User($_SESSION['URID']); $returnStr .= '<li class="dropdown"> <a href="#" class="dropdown-toggle" data-hover="dropdown" data-toggle="dropdown">' . $user->getName() . ' <b class="caret"></b></a> <ul class="dropdown-menu"> <li class="dropdown-header">' . $this->engine->getPrimaryKey() . '</li> <li class="dropdown-header">' . $variablenamesfull . '</li>'; $windowopen = 'window.open(\'tester/' . setSessionParams(array('reporturid' => $_SESSION['URID'], 'testpage' => 'report', 'reportsuid' => $this->engine->getSuid(), 'reportseid' => $this->engine->getSeid(), 'reportmainseid' => $this->engine->getMainSeid(), 'reportrgid' => $rgid, 'reportdisplayed' => $variablenames, 'reportlanguage' => getSurveyLanguage(), 'reportmode' => getSurveyMode(), 'reportversion' => getSurveyVersion(), 'reportprimkey' => $this->engine->getPrimarykey())) . '\', \'popupWindow\', \'width=770,height=500,scrollbars=yes,top=100,left=100\'); return false;'; $javascript = ' onclick="' . $windowopen . '"'; $returnStr .= '<li><a style="cursor: pointer;" ' . $javascript . '><span class="glyphicon glyphicon-remove-sign"></span> ' . Language::linkReportProblem() . '</a></li>'; $windowopen = 'window.open(\'tester/' . setSessionParams(array('testpage' => 'watch', 'watchurid' => $_SESSION['URID'], 'watchsuid' => $this->engine->getSuid(), 'watchseid' => $this->engine->getSeid(), 'watchmainseid' => $this->engine->getMainSeid(), 'watchrgid' => $rgid, 'watchdisplayed' => $variablenames, 'watchlanguage' => getSurveyLanguage(), 'watchmode' => getSurveyMode(), 'watchversion' => getSurveyVersion(), 'watchprimkey' => $this->engine->getPrimarykey())) . '\', \'popupWindow\', \'width=770,height=650,scrollbars=yes,top=100,left=100\'); return false;'; $javascript = ' onclick="' . $windowopen . '"'; $returnStr .= '<li><a style="cursor: pointer;" ' . $javascript . '><span class="glyphicon glyphicon-zoom-in"></span> ' . Language::linkWatch() . '</a></li>'; $first = $this->engine->isFirstState(); if ($first == false || $first == true && $this->engine->getForward() == true) { if ($this->engine->getForward() == true) { $stateid = $this->engine->getStateId() + 1; } else { $stateid = $this->engine->getStateId(); } $windowopen = 'window.open(\'tester/' . setSessionParams(array('testpage' => 'jumpback', 'jumpurid' => $_SESSION['URID'], 'jumpsuid' => $this->engine->getSuid(), 'jumpstateid' => $stateid, 'jumpprimkey' => $this->engine->getPrimaryKey())) . '\', \'popupWindow\', \'width=770,height=300,scrollbars=yes,top=100,left=100\'); return false;'; $javascript = ' onclick="' . $windowopen . '"'; $returnStr .= '<li><a style="cursor: pointer;" ' . $javascript . '><span class="glyphicon glyphicon-arrow-left"></span> ' . Language::linkJumpBack() . '</a></li>'; } $returnStr .= '<li><a href="' . setSessionParams(array('page' => $ut . '.tools.test', 'suid' => $this->engine->getSuid())) . '&se=' . addslashes(USCIC_SMS) . '"><span class="glyphicon glyphicon-home"></span> ' . Language::linkBackToNubis() . '</a></li> <li class="divider"></li> <li><a href="index.php?rs=1&se=2"><span class="glyphicon glyphicon-log-out"></span> ' . Language::linkLogout() . '</a></li> </ul> </li> </ul> '; $returnStr .= '</div><!--/.nav-collapse --> </div> </div>'; return $returnStr; }
function showOutputStatisticsParadata($content = "") { $survey = new Survey($_SESSION['SUID']); //echo $_SESSION["SUID"] . '----'; $headers[] = array('link' => setSessionParamsHref(array('page' => 'sysadmin.output'), Language::headerOutput()), 'label' => Language::headerOutputData()); $headers[] = array('link' => setSessionParamsHref(array('page' => 'sysadmin.output.statistics'), Language::headerOutputStatistics()), 'label' => Language::headerOutputStatistics()); $headers[] = array('link' => '', 'label' => Language::headerOutputStatisticsParadata()); $returnStr = $this->showOutputHeader($headers); $returnStr .= $content; $returnStr .= $this->displayComboBox(); $surveys = new Surveys(); $surveys = $surveys->getSurveys(); if (sizeof($surveys) > 0) { $returnStr .= "<form id=refreshform method=post>"; $returnStr .= '<input type=hidden name=page value="sysadmin.output.statistics.paradata">'; $returnStr .= '<input type=hidden name="' . SMS_POST_SURVEY . '" id="' . SMS_POST_SURVEY . '_hidden" value="' . getSurvey() . '">'; $returnStr .= '<input type=hidden name="' . SMS_POST_MODE . '" id="' . SMS_POST_MODE . '_hidden" value="' . getSurveyMode() . '">'; $returnStr .= '<input type=hidden name="' . SMS_POST_LANGUAGE . '" id="' . SMS_POST_LANGUAGE . '_hidden" value="' . getSurveyLanguage() . '">'; $returnStr .= "</form>"; $returnStr .= '<div class="well well-sm">'; $returnStr .= '<table>'; $returnStr .= '<tr><td>' . Language::labelTestSurvey() . "</td><td><select onchange='document.getElementById(\"" . SMS_POST_SURVEY . "_hidden\").value=this.value; document.getElementById(\"refreshform\").submit();' name=" . POST_PARAM_SUID . " class='selectpicker show-tick'>"; $current = new Survey(getSurvey()); foreach ($surveys as $s) { $selected = ""; if ($s->getSuid() == $current->getSuid()) { $selected = "SELECTED"; } $returnStr .= "<option {$selected} value=" . $s->getSuid() . '>' . $s->getName() . '</option>'; } $returnStr .= "</select></td></tr>"; $returnStr .= '</table><br/><br/>'; $sections = $survey->getSections(); foreach ($sections as $section) { $returnStr .= '<a href="index.php?r=' . setSessionsParamString(array('page' => 'sysadmin.output.statistics.paradata.section', 'seid' => $section->getSeid())) . '" class="list-group-item">' . $section->getName() . ' ' . $section->getDescription() . '</a>'; } $returnStr .= "</div>"; } else { $returnStr .= $this->displayInfo(Language::messageNoSurveysAvailable()); } $returnStr .= '</p></div> </div>'; //container and wrap $returnStr .= $this->showBottomBar(); $returnStr .= $this->showFooter(false); return $returnStr; }
function surveyEntry() { global $engine; if ($this->checkDateTime() == false) { /* get whatever the language is (either post or default) and use it */ $l = getSurveyLanguage(); if (file_exists("language/language" . getSurveyLanguagePostFix($l) . ".php")) { require_once 'language' . getSurveyLanguagePostFix($l) . '.php'; // language } else { require_once 'language_en.php'; // fall back on english language file } $login = new Login(session_id()); return $login->getClosedScreen(); } $logactions = new LogActions(); $nosessionactions = $logactions->getNumberOfSurveyActionsBySession($this->phpid, USCIC_SURVEY); /* no entry yet, then ask for prim_key in login screen */ if ($nosessionactions == 0 || loadvarSurvey(POST_PARAM_NEW_PRIMKEY) == '1') { //no entry yet: ask for prim_key! if (loadvarSurvey(POST_PARAM_NEW_PRIMKEY) == '1') { $logactions->deleteLoggedInSurveySession($this->phpid); } /* get whatever the language is (either post or default) and use it */ $l = getSurveyLanguage(); if (file_exists("language/language" . getSurveyLanguagePostFix($l) . ".php")) { require_once 'language' . getSurveyLanguagePostFix($l) . '.php'; // language } else { require_once 'language_en.php'; // fall back on english language file } $logactions->addAction('', '', "loginstart", USCIC_SURVEY, 1); $login = new Login($this->phpid); return $login->getLoginScreen(); } else { //entry: is this person logged in? $loggedin = $logactions->getLoggedInSurveySession($this->phpid); // gets the last logged in action /* no prim_key assigned to this sessionid. Assign if given (and check for pwd etc??)! */ if ($loggedin["count"] == 0) { /* we don't have active session, so take the template we can get */ global $survey; require_once "display/templates/displayquestion_" . getSurveyTemplate() . ".php"; // we don't have an active session, so fall back to whatever was passed along as language in post OR is the default language $l = getSurveyLanguage(); if (file_exists("language/language" . getSurveyLanguagePostFix($l) . ".php")) { //echo 'well done'; require_once 'language' . getSurveyLanguagePostFix($l) . '.php'; // language } else { require_once 'language_en.php'; // fall back on english language file } $primkey = loadvarSurvey(POST_PARAM_PRIMKEY); $_SESSION['PRIMKEY'] = $primkey; if ($primkey != '' && strlen($primkey) < 20) { // make sure primkey is not encrypted! //check!!!!!! $login = new Login($this->phpid); if ($login->checkAccess()) { $primkey = $_SESSION['PRIMKEY']; $logactions->addAction($primkey, '', "loggedin", USCIC_SURVEY, 1); // pass along primkey to load correct engine! $engine = loadEngine(getSurvey(), $primkey, $this->phpid, getSurveyVersion(), getSurveySection(getSurvey(), $primkey)); $engine->setFirstForm(true); return $engine->getNextQuestion(); } else { // incorrect login..start new session endSession(); session_start(); session_regenerate_id(true); $logactions->addAction('', '', "loginempty", USCIC_SURVEY, 1); $login = new Login(session_id()); global $survey; return $login->getLoginScreen($survey->getLoginError()); } } else { $logactions->addAction('', '', "loginempty", USCIC_SURVEY, 1); $login = new Login($this->phpid); global $survey; if ($survey->getAccessType() == LOGIN_ANONYMOUS) { return $login->getLoginScreen(Language::messageEnterPrimKey()); } else { if ($survey->getAccessType() == LOGIN_LOGINCODE) { return $login->getLoginScreen($survey->getLoginError()); } else { return $login->getLoginScreen(Language::messageEnterPrimKeyDirectAccess()); } } } } else { //continue interview! EXTRA CHECK!!! /* update survey info with what we know from the last session action */ setSurvey($loggedin["suid"]); /* include survey template now that we know which survey we are in */ global $survey; require_once "display/templates/displayquestion_" . getSurveyTemplate() . ".php"; /* update interview mode with what we know from the last session action * IF we are not changing the interview mode right now */ if (isset($_POST['navigation']) && $_POST['navigation'] != NAVIGATION_MODE_CHANGE && $survey->getReentryMode() == MODE_REENTRY_YES) { setSurveyMode($loggedin["mode"]); } /* update language with what we know from the last session action * IF we are not changing the language right now */ if (isset($_POST['navigation']) && $_POST['navigation'] != NAVIGATION_LANGUAGE_CHANGE && $survey->getReentryLanguage(getSurveyMode()) == LANGUAGE_REENTRY_YES) { setSurveyLanguage($loggedin["language"]); } /* update version with what we know from the last session action */ setSurveyVersion($loggedin["version"]); // include language file $l = getSurveyLanguage(); //echo 'NOW: ' . $l; if (file_exists("language/language" . getSurveyLanguagePostFix($l) . ".php")) { //echo 'well done'; require_once 'language' . getSurveyLanguagePostFix($l) . '.php'; // language } else { require_once 'language_en.php'; // fall back on english language file } // pass along primkey to load correct engine! $engine = loadEngine(getSurvey(), $loggedin["primkey"], $this->phpid, getSurveyVersion(), getSurveySection(getSurvey(), $loggedin["primkey"])); /* handle button click */ return $engine->getNextQuestion(); } } }
function showIssues($content = "") { $returnStr = $this->showToolsHeader(Language::linkReported()); $returnStr .= $content; $surveys = new Surveys(); $surveys = $surveys->getSurveys(); if (sizeof($surveys) > 0) { $returnStr .= "<form id=refreshform method=post>"; $returnStr .= '<input type=hidden name=page value="sysadmin.tools.issues">'; $returnStr .= '<input type=hidden name="' . SMS_POST_SURVEY . '" id="' . SMS_POST_SURVEY . '_hidden" value="' . getSurvey() . '">'; $returnStr .= '<input type=hidden name="' . SMS_POST_MODE . '" id="' . SMS_POST_MODE . '_hidden" value="' . getSurveyMode() . '">'; $returnStr .= '<input type=hidden name="' . SMS_POST_LANGUAGE . '" id="' . SMS_POST_LANGUAGE . '_hidden" value="' . getSurveyLanguage() . '">'; $returnStr .= "</form>"; // get reported issues for survey global $survey; $issues = $survey->getReportedIssues(); // no problems reported if (sizeof($issues) == 0) { $returnStr .= "<br/>" . '<div class="alert alert-warning">' . 'No reported problems found' . '</div>'; } else { $returnStr .= $this->displayComboBox(); $returnStr .= '<span class="label label-default">Filter by</span>'; $returnStr .= '<div class="well well-sm">'; $returnStr .= '<table>'; $returnStr .= '<tr><td>' . Language::labelTestSurvey() . "</td><td><select onchange='document.getElementById(\"" . SMS_POST_SURVEY . "_hidden\").value=this.value; document.getElementById(\"refreshform\").submit();' name=" . POST_PARAM_SUID . " class='selectpicker show-tick'>"; $current = new Survey(getSurvey()); foreach ($surveys as $survey) { $selected = ""; if ($survey->getSuid() == $current->getSuid()) { $selected = "SELECTED"; } $returnStr .= "<option {$selected} value=" . $survey->getSuid() . '>' . $survey->getName() . '</option>'; } $returnStr .= "</select></td></tr></table></div>"; $returnStr .= $this->displayDataTablesScripts(array("colvis", "rowreorder")); $returnStr .= "<script type='text/javascript'>\n \$(document).ready(function(){\n \$('#issuetable').dataTable(\n {\n \"iDisplayLength\": " . sizeof($issues) . ",\n dom: 'C<\"clear\">lfrtip',\n searching: false,\n paging: false\n } \n );\n \n });</script>\n\n "; // $returnStr .= "<br/><table id='issuetable' class='table table-bordered table-striped'><thead>"; $returnStr .= "<th>Reported by</th><th>Reported on</th><th>Category</th><th>Description</th><th>Primary key</th><th>Interview mode</th><th>Language</th>"; $returnStr .= "</thead><tbody>"; $modes = Common::surveyModes(); $languages = Language::getLanguagesArray(); $cats = Language::reportProblemCategories(); foreach ($issues as $is) { $us = new User($is['urid']); $returnStr .= "<tr>"; $returnStr .= "<td>" . $us->getUsername() . "</td>"; $returnStr .= "<td>" . $is["ts"] . "</td>"; $returnStr .= "<td>" . $cats[$is["category"]] . "</td>"; $returnStr .= "<td>" . $is["comment"] . "</td>"; $returnStr .= "<td>" . $is["primkey"] . "</td>"; $returnStr .= "<td>" . $modes[$is["mode"]] . "</td>"; $returnStr .= "<td>" . $languages[str_replace("_", "", getSurveyLanguagePostFix($is["language"]))]['name'] . "</td>"; $returnStr .= "</tr>"; } $returnStr .= "</tbody></table>"; } } else { $returnStr .= $this->displayInfo(Language::messageNoSurveysAvailable()); } $returnStr .= '</p></div></div>'; //container and wrap $returnStr .= $this->showBottomBar(); $returnStr .= $this->showFooter(false); return $returnStr; }
function showEditUser($urid, $message = "") { $user = new User($urid); $returnStr = $this->showSysAdminHeader(Language::messageSMSTitle()); $returnStr .= '<div id="wrap">'; $returnStr .= $this->showNavBar(); $returnStr .= '<div class="container"><p>'; $returnStr .= '<ol class="breadcrumb">'; $returnStr .= '<li>' . setSessionParamsHref(array('page' => 'sysadmin.users'), Language::headerUsers()) . '</li>'; if ($user->getUsername() == '') { $returnStr .= '<li>' . Language::labelUserAddUser() . '</li>'; } else { $returnStr .= '<li>' . Language::labelEdit() . ' ' . $user->getUsername() . '</li>'; } $returnStr .= '</ol>'; $returnStr .= $message; $returnStr .= $this->displayComboBox(); $returnStr .= '<form id="editform" method="post">'; $returnStr .= '<span class="label label-default">' . Language::labelUserGeneral() . '</span>'; $returnStr .= '<div class="well">'; $returnStr .= setSessionParamsPost(array('page' => 'sysadmin.users.edituserres', 'urid' => $urid)); $returnStr .= '<div class="row">'; $returnStr .= '<div class="col-md-6">'; $returnStr .= '<table>'; $returnStr .= '<tr><td>' . Language::labelUserUserName() . '</td><td><input type="text" class="form-control" name="username" value="' . convertHTLMEntities($user->getUsername(), ENT_QUOTES) . '"></td></tr>'; $returnStr .= '<tr><td>' . Language::labelUserUserNameName() . '</td><td><input type="text" class="form-control" name="name" value="' . convertHTLMEntities($user->getName(), ENT_QUOTES) . '"></td></tr>'; $returnStr .= '<tr><td align=top>' . Language::labelUserActive() . '</td><td>'; $returnStr .= $this->showDropDown(array(VARIABLE_ENABLED => Language::labelEnabled(), VARIABLE_DISABLED => Language::labelDisabled()), $user->getStatus(), 'status'); $returnStr .= '</td></tr>'; $returnStr .= '<tr><td align=top>' . Language::labelUserUserType() . '</td><td>'; $returnStr .= $this->showDropDown(array(USER_INTERVIEWER => Language::labelInterviewer(), USER_NURSE => Language::labelNurse(), USER_SUPERVISOR => Language::labelSupervisor(), USER_TRANSLATOR => Language::labelTranslator(), USER_RESEARCHER => Language::labelResearcher(), USER_SYSADMIN => Language::labelSysadmin(), USER_TESTER => Language::labelTester()), $user->getUserType(), 'usertype', 'usertype'); $returnStr .= '</td></tr>'; $returnStr .= "<script type='text/javascript'>"; $returnStr .= '$( document ).ready(function() { $("#usertype").change(function (e) { if (this.value == ' . USER_NURSE . ') { $("#subtype").show(); $("#subtype2").hide(); } else if (this.value == ' . USER_SYSADMIN . ') { $("#subtype2").show(); $("#subtype").hide(); } else { $("#subtype").hide(); $("#subtype2").hide(); } if (this.value == ' . USER_INTERVIEWER . ' || this.value == ' . USER_CATIINTERVIEWER . ' || this.value == ' . USER_NURSE . ' || this.value == ' . USER_SUPERVISOR . ') { $("#super").show(); $("#accessdiv").hide(); $("#surveyaccess").hide(); } else { $("#super").hide(); $("#accessdiv").show(); $("#surveyaccess").show(); } }); })'; $returnStr .= "</script>"; if (inArray($user->getUserType(), array(USER_NURSE))) { $returnStr .= '<tr id=subtype><td align=top>' . Language::labelUserUserSubType() . '</td><td>'; $returnStr .= $this->showDropDown(array(USER_NURSE_MAIN => Language::labelNurseMain(), USER_NURSE_LAB => Language::labelNurseLab(), USER_NURSE_FIELD => Language::labelNurseField(), USER_NURSE_VISION => Language::labelNurseVision()), $user->getUserSubType(), 'usersubtype'); $returnStr .= '</td></tr>'; } else { if (inArray($user->getUserType(), array(USER_SYSADMIN))) { $returnStr .= '<tr id=subtype2><td align=top>' . Language::labelUserUserSubType() . '</td><td>'; $returnStr .= $this->showDropDown(array(USER_SYSADMIN_MAIN => Language::labelSysadminMain(), USER_SYSADMIN => Language::labelSysadminAdmin()), $user->getUserSubType(), 'usersubtype'); $returnStr .= '</td></tr>'; } else { $returnStr .= '<tr id=subtype style="display: none;"><td align=top>' . Language::labelUserUserSubType() . '</td><td>'; $returnStr .= $this->showDropDown(array(USER_NURSE_MAIN => Language::labelNurseMain(), USER_NURSE_LAB => Language::labelNurseLab(), USER_NURSE_FIELD => Language::labelNurseField(), USER_NURSE_VISION => Language::labelNurseVision()), $user->getUserSubType(), 'usersubtype'); $returnStr .= '</td></tr>'; $returnStr .= '<tr id=subtype2 style="display: none;"><td align=top>' . Language::labelUserUserSubType() . '</td><td>'; $returnStr .= $this->showDropDown(array(USER_SYSADMIN_MAIN => Language::labelSysadminMain(), USER_SYSADMIN => Language::labelSysadminAdmin()), $user->getUserSubType(), 'usersubtype'); $returnStr .= '</td></tr>'; } } if (inArray($user->getUserType(), array(USER_INTERVIEWER, USER_CATIINTERVIEWER, USER_NURSE, USER_SUPERVISOR))) { $returnStr .= '<tr id=super><td>' . Language::labelUserSupervisor() . '</td><td>'; $users = new Users(); $users = $users->getUsersByType(USER_SUPERVISOR); $returnStr .= $this->displayUsers($users, $user->getSupervisor(), 'uridsel', true); $returnStr .= '</td></tr>'; } $extra = ''; if (inArray($user->getUserType(), array(USER_NURSE, USER_INTERVIEWER, USER_SUPERVISOR, USER_CATIINTERVIEWER))) { $extra = "style='display: none;'"; } $returnStr .= '<tr id="surveyaccess"' . $extra . '><td>' . Language::labelUserSurveyAllowed() . '</td><td>' . $this->displaySurveys(SETTING_USER_SURVEYS . "[]", SETTING_USER_SURVEYS, implode("~", $user->getSurveysAccess()), '', "multiple") . '</td></tr>'; $returnStr .= '</table></div>'; $returnStr .= '<div class="col-md-6">'; $returnStr .= '<table>'; $returnStr .= '<tr><td align=top>' . Language::labelUserPassword() . '</td><td><input type="text" class="form-control" name="pwd1"></td></tr>'; $returnStr .= '<tr><td align=top>' . Language::labelUserPassword2() . '</td><td><input type="text" class="form-control" name="pwd2"></td></tr>'; $returnStr .= '</table></div></div>'; if ($urid != "") { $returnStr .= '<br/><input type="submit" class="btn btn-default" value="' . Language::buttonEdit() . '"/>'; } else { $returnStr .= '<br/><input type="submit" class="btn btn-default" value="' . Language::buttonAdd() . '"/>'; } $returnStr .= '</div></form>'; $suid = $_SESSION['SUID']; /* available surveys */ if ($urid != "") { $extra = ''; if (inArray($user->getUserType(), array(USER_NURSE, USER_INTERVIEWER, USER_SUPERVISOR, USER_CATIINTERVIEWER))) { $extra = "style='display: none;'"; } $returnStr .= "<div " . $extra . " id='accessdiv'>"; $returnStr .= "<form id=refreshform method=post>"; $returnStr .= '<input type=hidden name=page value="sysadmin.users.edituser">'; $returnStr .= '<input type=hidden name="' . SMS_POST_SURVEY . '" id="' . SMS_POST_SURVEY . '_hidden" value="' . getSurvey() . '">'; $returnStr .= "</form>"; $returnStr .= '<form id="editform1" method="post">'; $returnStr .= setSessionParamsPost(array('page' => 'sysadmin.users.edituseraccessres', 'urid' => $urid)); $returnStr .= '<span class="label label-default">' . Language::labelUserAccess() . '</span>'; $returnStr .= '<div class="well">'; $returnStr .= "<table>"; $allsurveys = $user->getSurveysAccess(); if (!inArray($suid, $allsurveys)) { $suid = $allsurveys[0]; } $survey = new Survey($suid); $u = $_SESSION['URID']; $_SESSION['URID'] = $urid; // pretend to be edited user for a moment to get surveys to display $returnStr .= '<tr><td>' . Language::labelUserSurveyAccess() . '</td><td>' . $this->displaySurveys(SMS_POST_SURVEY, SMS_POST_SURVEY, $suid, '', "") . '</td></tr>'; $_SESSION['URID'] = $u; $returnStr .= "<script type='text/javascript'>"; $returnStr .= '$( document ).ready(function() { $("#' . SMS_POST_SURVEY . '").change(function (e) { $("#' . SMS_POST_SURVEY . '_hidden").val(this.value); $("#refreshform").submit(); }); })'; $returnStr .= "</script>"; /* available modes */ $modes = Common::surveyModes(); $allowedmodes = explode("~", $survey->getAllowedModes()); $usermodes = $user->getModes($suid); foreach ($allowedmodes as $mode) { $returnStr .= "<tr class='modesrow'><td>" . $modes[$mode] . "</td><td>"; $returnStr .= $this->displayUserMode(SETTING_USER_MODE . $mode, inArray($mode, $usermodes)); $userlanguages = $user->getLanguages($suid, $mode); $returnStr .= "<td>" . Language::labelUserLanguageAllowed() . "</td>"; $returnStr .= "<td>" . $this->displayLanguagesAdmin(SETTING_USER_LANGUAGES . $mode, SETTING_USER_LANGUAGES . $mode, $userlanguages, true, false, false, "multiple", $survey->getAllowedLanguages($mode)) . "</td>"; $returnStr .= "</tr>"; } $returnStr .= '</table>'; $returnStr .= '<br/><input type="submit" class="btn btn-default" value="' . Language::buttonEdit() . '"/>'; $returnStr .= '</div></form></div>'; } $returnStr .= '</p></div> </div>'; //container and wrap $returnStr .= $this->showBottomBar(); $returnStr .= $this->showFooter(false); return $returnStr; }
require 'contact.php'; require 'contacts.php'; } /* check for execution mode */ if (inArray(loadvar(POST_PARAM_SURVEY_EXECUTION_MODE), array(SURVEY_EXECUTION_MODE_NORMAL, SURVEY_EXECUTION_MODE_TEST))) { $_SESSION[SURVEY_EXECUTION_MODE] = loadvar(POST_PARAM_SURVEY_EXECUTION_MODE); } if (!isset($_SESSION[SURVEY_EXECUTION_MODE])) { $_SESSION[SURVEY_EXECUTION_MODE] = SURVEY_EXECUTION_MODE_NORMAL; // by default normal mode } // set timezone date_default_timezone_set(Config::timezone()); $logActions = new LogActions(); /* global variables */ $suid = getSurvey(); $survey = new Survey($suid); /* set the template for the questions display */ require 'displayquestionsms.php'; require 'displayquestiontest.php'; require 'displayquestionnurse.php'; /* js shrinker */ if (Config::useDynamicMinify()) { require 'jshrink/minifier.php'; } $mode = null; // wait with calling this until later! $modechange = null; $version = null; // wait with calling this until later! $language = null;