Esempio n. 1
0
function getSurveyMainSection($suid, $primkey)
{
    /* declare */
    $seid = "";
    global $currentmainseid;
    /* returning to survey or starting */
    if (getFromSessionParams(SESSION_PARAM_RGID) == '') {
        /* check in session first (overrides last state) */
        $seid = getFromSessionParams(SESSION_PARAM_MAINSEID);
        if (isSurveySection($seid)) {
            $currentmainseid = $seid;
            return $seid;
        }
        /* check for last state */
        global $db;
        $result = $db->selectQuery('select mainseid from ' . Config::dbSurveyData() . '_states where suid=' . prepareDatabaseString($suid) . '  and primkey = "' . prepareDatabaseString($primkey) . '" order by stateid desc limit 0,1');
        /* we are re-entering */
        if ($db->getNumberOfRows($result) > 0) {
            $row = $db->getRow($result);
            $seid = $row["mainseid"];
            if (isSurveySection($seid)) {
                $currentmainseid = $seid;
                return $seid;
            }
        }
        /* we are starting the survey and no session parameter, then assume root section */
        $currentmainseid = getBaseSectionSeid($suid);
        return $currentmainseid;
    } else {
        /* button action */
        if (isset($_POST['navigation'])) {
            /* back button */
            if ($_POST['navigation'] == Language::buttonBack()) {
                /* check for last state to determine which section we are going to */
                global $db;
                $result = $db->selectQuery('select mainseid from ' . Config::dbSurveyData() . '_states where suid=' . prepareDatabaseString($suid) . '  and primkey = "' . prepareDatabaseString($primkey) . '" order by stateid desc limit 0,1');
                //echo 'select * from ' . Config::dbSurveyData() . '_states where suid=' . prepareDatabaseString($suid) . '  and primkey = "' . prepareDatabaseString($primkey) . '" order by stateid desc limit 0,1';
                if ($db->getNumberOfRows($result) > 0) {
                    $row = $db->getRow($result);
                    $seid = $row["mainseid"];
                    if (isSurveySection($seid)) {
                        $currentmainseid = $seid;
                        return $seid;
                    }
                }
            } else {
                if ($_POST['navigation'] == Language::buttonUpdate()) {
                    /* section does not change, so return from session */
                    $seid = getFromSessionParams(SESSION_PARAM_MAINSEID);
                    if (isSurveySection($seid)) {
                        $currentmainseid = $seid;
                        return $seid;
                    }
                } else {
                    /* section may change, but this is handled by the current section engine
                     * calling the nex section engine, so we keep the same section */
                    $seid = getFromSessionParams(SESSION_PARAM_MAINSEID);
                    if (isSurveySection($seid)) {
                        $currentmainseid = $seid;
                        return $seid;
                    }
                }
            }
        }
        /* everything failed, then assume root section */
        $currentmainseid = getBaseSectionSeid($suid);
        return $currentmainseid;
    }
    /* check last state */
    $currentmainseid = getBaseSectionSeid($suid);
    return $currentmainseid;
}
Esempio n. 2
0
 public function showLoginDirect($primkey, $message)
 {
     global $survey, $engine;
     require_once "display/templates/displayquestion_" . $survey->getTemplate() . ".php";
     $returnStr = $this->showHeader($survey->getTitle(), '<link href="bootstrap/css/sticky-footer-navbar.min.css" rel="stylesheet">');
     if (true) {
         if ($primkey != '') {
             $returnStr .= '<form method="post" id="startform">';
             $returnStr .= '<input type=hidden name="' . POST_PARAM_PRIMKEY . '" value="' . decryptC($primkey, Config::directLoginKey()) . '">';
             $returnStr .= '<input type=hidden name="' . POST_PARAM_SUID . '" value="' . $survey->getSuid() . '">';
             $returnStr .= '<input type=hidden name="' . POST_PARAM_LANGUAGE . '" value="' . loadvar(POST_PARAM_LANGUAGE) . '">';
             $returnStr .= '<input type=hidden name="' . POST_PARAM_PRELOAD . '" value="' . loadvar(POST_PARAM_PRELOAD) . '">';
             $returnStr .= '<input type=hidden name="' . POST_PARAM_MODE . '" value="' . loadvar(POST_PARAM_MODE) . '">';
             $returnStr .= '<input type=hidden name="' . POST_PARAM_URID . '" value="' . loadvar(POST_PARAM_URID) . '">';
             if (loadvar(POST_PARAM_URID) != '') {
                 $_SESSION['URID'] = loadvar(POST_PARAM_URID);
             }
             $returnStr .= '<div style="display: none;"><input type=submit></div>';
             $returnStr .= '</form>';
             $returnStr .= '<script>';
             $returnStr .= '$(document).ready(function(){ $("#startform").submit(); }); ';
             $returnStr .= '</script>';
         } else {
             $returnStr .= '<div id="wrap">';
             $returnStr .= '<div class="container"><p>';
             $engine = loadEngine($survey->getSuid(), $primkey, '', getSurveyVersion(), getBaseSectionSeid($survey->getSuid()));
             $do = $engine->getDisplayObject();
             $returnStr .= $do->showDirectAccessOnlySurvey();
             //$returnStr .= Language::errorDirectLogin();
         }
     } else {
         $returnStr .= '<div id="wrap">';
         $returnStr .= '<div class="container"><p>';
         //$returnStr .= Language::errorDirectLogin();
         $engine = loadEngine($survey->getSuid(), $primkey, '', getSurveyVersion(), getBaseSectionSeid($survey->getSuid()));
         $do = $engine->getDisplayObject();
         $returnStr .= $do->showDirectAccessOnlySurvey();
     }
     /* footer */
     $returnStr .= $this->showFooter();
     return $returnStr;
 }
Esempio n. 3
0
 function showXiCompileRes($content = "")
 {
     $returnStr = $this->showToolsHeader(Language::headerToolsXiCompiler());
     $returnStr .= $content;
     require_once "xicompiler.php";
     set_time_limit(0);
     $compile = loadvar("compile");
     $_SESSION['PARAMETER_RETRIEVAL'] = PARAMETER_SURVEY_RETRIEVAL;
     $xi = new XiCompiler($compile, loadvar("ximode"), getSurveyVersion());
     $xi->generateTypes();
     $xi->generateVariableDescriptives();
     $seid = getBaseSectionSeid($_SESSION["SUID"]);
     $xi->generateRouting($seid);
     $_SESSION['PARAMETER_RETRIEVAL'] = PARAMETER_ADMIN_RETRIEVAL;
     $returnStr .= '<div>
                         <ul class="nav nav-tabs" role="tablist">
                             <li role="presentation" class="active"><a href="#vars" aria-controls="vars" role="tab" data-toggle="tab">' . Language::linkVariables() . '</a></li>
                             <li role="presentation" class=""><a href="#types" aria-controls="types" role="tab" data-toggle="tab">' . Language::linkTypes() . '</a></li>
                             <li role="presentation" class=""><a href="#routing" aria-controls="routing" role="tab" data-toggle="tab">' . Language::linkRouting() . '</a></li>                            
                         </ul>
                         <div class="tab-content">';
     // variables
     $returnStr .= "<div role='tabpanel' class='tab-pane active' id='vars'><textarea class='form-control' name=variablestext id=variablestext style='width: min-width 500px; width: 100%; min-height: 800px; height: 100%'>";
     $returnStr .= "<?php\r\n\r\n" . implode("\r\n", $xi->getVariableDescriptivesOutput()) . "\r\n\r\n?>";
     $returnStr .= "</textarea></div>";
     // types
     $returnStr .= "<div role='tabpanel' class='tab-pane' id='types'><textarea class='form-control' name=typestext id=typestext style='width: min-width 500px; width: 100%; min-height: 800px; height: 100%'>";
     $returnStr .= "<?php\r\n\r\n" . implode("\r\n", $xi->getTypesOutput()) . "\r\n\r\n?>";
     $returnStr .= "</textarea></div>";
     // routing
     $returnStr .= "<div role='tabpanel' class='tab-pane' id='routing'><textarea class='form-control' name=routingtext id=routingtext style='width: min-width 500px; width: 100%; min-height: 800px; height: 100%'>";
     $returnStr .= "<?php\r\n\r\n" . implode("", $xi->getRoutingOutput($seid)) . "\r\n\r\n?>";
     $returnStr .= "</textarea></div>";
     $returnStr .= "</div></div>";
     $returnStr .= '</p></div>    </div>';
     //container and wrap
     $returnStr .= $this->showBottomBar();
     /*$returnStr .= $this->getCodeMirror();
       $returnStr .= '<script src="js/codemirror/mode/php/php.js"></script>';
       $returnStr .= '<script type="text/javascript">                
                           $(document).ready(function() {                
                               //var editor1 = CodeMirror.fromTextArea(document.getElementById("variablestext"), {lineNumbers: true, mode: "application/x-php"});
                               //var editor2 = CodeMirror.fromTextArea(document.getElementById("typestext"), {lineNumbers: true, mode: "application/x-php"});
                               var editor3 = CodeMirror.fromTextArea(document.getElementById("routingtext"), {lineNumbers: true, mode: "application/x-httpd-php"});
                               });
                           </script>';        
                           
       //var editor = CodeMirror.fromTextArea(document.getElementById("variables"), lineNumbers: true, matchBrackets: true, mode: "application/x-httpd-php", indentUnit: 4, indentWithTabs: true});
        */
     $returnStr .= $this->showFooter(false);
     return $returnStr;
 }