/**
 * Gets all survey infos in one big array including the language specific settings
 *
 * @param string $surveyid  The survey ID
 * @param string $languagecode The language code - if not given the base language of the particular survey is used
 * @return array Returns array with survey info or false, if survey does not exist
 */
function getSurveyInfo($surveyid, $languagecode = '')
{
    global $dbprefix, $siteadminname, $siteadminemail, $connect, $languagechanger;
    $surveyid = sanitize_int($surveyid);
    $languagecode = sanitize_languagecode($languagecode);
    $thissurvey = false;
    // if no language code is set then get the base language one
    if (!isset($languagecode) || $languagecode == '') {
        $languagecode = GetBaseLanguageFromSurveyID($surveyid);
    }
    $query = "SELECT * FROM " . db_table_name('surveys') . "," . db_table_name('surveys_languagesettings') . " WHERE sid={$surveyid} and surveyls_survey_id={$surveyid} and surveyls_language='{$languagecode}'";
    $result = db_execute_assoc($query) or safe_die("Couldn't access survey settings<br />{$query}<br />" . $connect->ErrorMsg());
    //Checked
    while ($row = $result->FetchRow()) {
        $thissurvey = $row;
        // now create some stupid array translations - needed for backward compatibility
        // Newly added surveysettings don't have to be added specifically - these will be available by field name automatically
        $thissurvey['name'] = $thissurvey['surveyls_title'];
        $thissurvey['description'] = $thissurvey['surveyls_description'];
        $thissurvey['welcome'] = $thissurvey['surveyls_welcometext'];
        $thissurvey['templatedir'] = $thissurvey['template'];
        $thissurvey['adminname'] = $thissurvey['admin'];
        $thissurvey['tablename'] = $dbprefix . 'survey_' . $thissurvey['sid'];
        $thissurvey['urldescrip'] = $thissurvey['surveyls_urldescription'];
        $thissurvey['url'] = $thissurvey['surveyls_url'];
        $thissurvey['expiry'] = $thissurvey['expires'];
        $thissurvey['email_invite_subj'] = $thissurvey['surveyls_email_invite_subj'];
        $thissurvey['email_invite'] = $thissurvey['surveyls_email_invite'];
        $thissurvey['email_remind_subj'] = $thissurvey['surveyls_email_remind_subj'];
        $thissurvey['email_remind'] = $thissurvey['surveyls_email_remind'];
        $thissurvey['email_confirm_subj'] = $thissurvey['surveyls_email_confirm_subj'];
        $thissurvey['email_confirm'] = $thissurvey['surveyls_email_confirm'];
        $thissurvey['email_register_subj'] = $thissurvey['surveyls_email_register_subj'];
        $thissurvey['email_register'] = $thissurvey['surveyls_email_register'];
        if (!isset($thissurvey['adminname'])) {
            $thissurvey['adminname'] = $siteadminname;
        }
        if (!isset($thissurvey['adminemail'])) {
            $thissurvey['adminemail'] = $siteadminemail;
        }
        if (!isset($thissurvey['urldescrip']) || $thissurvey['urldescrip'] == '') {
            $thissurvey['urldescrip'] = $thissurvey['surveyls_url'];
        }
        $thissurvey['passthrulabel'] = isset($_SESSION['passthrulabel']) ? $_SESSION['passthrulabel'] : "";
        $thissurvey['passthruvalue'] = isset($_SESSION['passthruvalue']) ? $_SESSION['passthruvalue'] : "";
    }
    //not sure this should be here... ToDo: Find a better place
    if (function_exists('makelanguagechanger')) {
        $languagechanger = makelanguagechanger();
    }
    return $thissurvey;
}
Exemplo n.º 2
0
}
if ($embedded_inc != '') {
    require_once $embedded_inc;
}
//CHECK FOR REQUIRED INFORMATION (sid)
if (!$surveyid) {
    if (isset($_GET['lang'])) {
        $baselang = sanitize_languagecode($_GET['lang']);
    } elseif (!isset($baselang)) {
        $baselang = $defaultlang;
    }
    $clang = new limesurvey_lang($baselang);
    if (!isset($defaulttemplate)) {
        $defaulttemplate = "default";
    }
    $languagechanger = makelanguagechanger();
    //Find out if there are any publicly available surveys
    $query = "SELECT a.sid, b.surveyls_title, a.publicstatistics\n\t          FROM " . db_table_name('surveys') . " AS a\n\t\t\t  INNER JOIN " . db_table_name('surveys_languagesettings') . " AS b\n\t\t\t  ON ( surveyls_survey_id = a.sid AND surveyls_language = a.language )\n\t\t\t  WHERE surveyls_survey_id=a.sid\n\t\t\t  AND surveyls_language=a.language\n\t\t\t  AND a.active='Y'\n\t\t\t  AND a.listpublic='Y'\n\t\t\t  AND ((a.expires >= '" . date("Y-m-d H:i") . "') OR (a.expires is null))\n              AND ((a.startdate <= '" . date("Y-m-d H:i") . "') OR (a.startdate is null))\n\t\t\t  ORDER BY surveyls_title";
    $result = db_execute_assoc($query, false, true) or die("Could not connect to database. If you try to install LimeSurvey please refer to the <a href='http://docs.limesurvey.org'>installation docs</a> and/or contact the system administrator of this webpage.");
    //Checked
    $list = array();
    if ($result->RecordCount() > 0) {
        while ($rows = $result->FetchRow()) {
            $result2 = db_execute_assoc("Select surveyls_title from " . db_table_name('surveys_languagesettings') . " where surveyls_survey_id={$rows['sid']} and surveyls_language='{$baselang}'");
            if ($result2->RecordCount()) {
                $languagedetails = $result2->FetchRow();
                $rows['surveyls_title'] = $languagedetails['surveyls_title'];
            }
            $link = "<li><a href='{$rooturl}/index.php?sid=" . $rows['sid'];
            if (isset($_GET['lang'])) {
                $link .= "&lang=" . sanitize_languagecode($_GET['lang']);