function getTokenData($surveyid, $token) { global $dbprefix, $connect; $query = "SELECT * FROM " . db_table_name('tokens_' . $surveyid) . " WHERE token='" . db_quote($token) . "'"; $result = db_execute_assoc($query) or safe_die("Couldn't get token info in getTokenData()<br />" . $query . "<br />" . $connect->ErrorMsg()); //Checked while ($row = $result->FetchRow()) { $thistoken = array("firstname" => $row['firstname'], "lastname" => $row['lastname'], "email" => $row['email'], "language" => $row['language'], "usesleft" => $row['usesleft']); $attrfieldnames = GetAttributeFieldnames($surveyid); foreach ($attrfieldnames as $attr_name) { $thistoken[$attr_name] = $row[$attr_name]; } } // while return $thistoken; }
."</div>\n"; } if ($subaction == "importldap" && bHasSurveyPermission($surveyid, 'tokens','import')) { $tokenoutput .= "\t<div class='header ui-widget-header'>".$clang->gT("Upload LDAP entries")."</div>\n"; formldap(); $tokenoutput .= "<div class='messagebox ui-corner-all'>\n" ."\t<div class='header ui-widget-header'>".$clang->gT("Note:")."</div><br />\n" .$clang->gT("LDAP queries are defined by the administrator in the config-ldap.php file")."\n" ."</div>\n"; } if ($subaction == "upload" && bHasSurveyPermission($surveyid, 'tokens','import')) { $attrfieldnames=GetAttributeFieldnames($surveyid); $duplicatelist=array(); $invalidemaillist=array(); $invalidformatlist=array(); $tokenoutput .= "\t<div class='header ui-widget-header'>".$clang->gT("Token file upload")."</div>\n" ."\t<div class='messagebox ui-corner-all'>\n"; if (!isset($tempdir)) { $the_path = $homedir; } else { $the_path = $tempdir; } $the_file_name = $_FILES['the_file']['name']; $the_file = $_FILES['the_file']['tmp_name'];
/** * Marks a tokens as completed and sends a confirmation email to the participiant. * If $quotaexit is set to true then the user exited the survey due to a quota * restriction and the according token is only marked as 'Q' * * @param mixed $quotaexit */ function submittokens($quotaexit = false) { global $thissurvey, $timeadjust, $emailcharset; global $dbprefix, $surveyid, $connect; global $sitename, $thistpl, $clang, $clienttoken; // Shift the date due to global timeadjust setting $today = date_shift(date("Y-m-d H:i:s"), "Y-m-d H:i", $timeadjust); $utquery = "UPDATE {$dbprefix}tokens_{$surveyid}\n"; if ($quotaexit == true) { $utquery .= "SET completed='Q'\n"; } elseif (bIsTokenCompletedDatestamped($thissurvey)) { $utquery .= "SET completed='{$today}'\n"; } else { $utquery .= "SET completed='Y'\n"; } $utquery .= "WHERE token='" . db_quote($clienttoken) . "'"; $utresult = $connect->Execute($utquery) or safe_die("Couldn't update tokens table!<br />\n{$utquery}<br />\n" . $connect->ErrorMsg()); //Checked if ($quotaexit == false) { // TLR change to put date into sent and completed $cnfquery = "SELECT * FROM " . db_table_name("tokens_{$surveyid}") . " WHERE token='" . db_quote($clienttoken) . "' AND completed!='N' AND completed!=''"; $cnfresult = db_execute_assoc($cnfquery); //Checked $cnfrow = $cnfresult->FetchRow(); if (isset($cnfrow)) { $from = "{$thissurvey['adminname']} <{$thissurvey['adminemail']}>"; $to = $cnfrow['email']; $subject = $thissurvey['email_confirm_subj']; $fieldsarray["{ADMINNAME}"] = $thissurvey['adminname']; $fieldsarray["{ADMINEMAIL}"] = $thissurvey['adminemail']; $fieldsarray["{SURVEYNAME}"] = $thissurvey['name']; $fieldsarray["{SURVEYDESCRIPTION}"] = $thissurvey['description']; $fieldsarray["{FIRSTNAME}"] = $cnfrow['firstname']; $fieldsarray["{LASTNAME}"] = $cnfrow['lastname']; $fieldsarray["{TOKEN}"] = $clienttoken; $attrfieldnames = GetAttributeFieldnames($surveyid); foreach ($attrfieldnames as $attr_name) { $fieldsarray["{" . strtoupper($attr_name) . "}"] = $cnfrow[$attr_name]; } $dateformatdatat = getDateFormatData($thissurvey['surveyls_dateformat']); $fieldsarray["{EXPIRY}"] = convertDateTimeFormat($thissurvey["expiry"], 'Y-m-d H:i:s', $dateformatdatat['phpdate']); $subject = Replacefields($subject, $fieldsarray); if ($thissurvey['private'] == "N") { // Survey is not anonymous, we can translate insertAns placeholder $subject = insertansReplace($subject); } $subject = html_entity_decode($subject, ENT_QUOTES, $emailcharset); if (getEmailFormat($surveyid) == 'html') { $ishtml = true; } else { $ishtml = false; } if (trim(strip_tags($thissurvey['email_confirm'])) != "") { $message = $thissurvey['email_confirm']; $message = Replacefields($message, $fieldsarray); if ($thissurvey['private'] == "N") { // Survey is not anonymous, we can translate insertAns placeholder $message = insertansReplace($message); } if (!$ishtml) { $message = strip_tags(br2nl(html_entity_decode($message, ENT_QUOTES, $emailcharset))); } else { $message = html_entity_decode($message, ENT_QUOTES, $emailcharset); } //Only send confirmation email if there is a valid email address if (validate_email($cnfrow['email'])) { SendEmailMessage($message, $subject, $to, $from, $sitename, $ishtml); } } else { //There is nothing in the message, so don't send a confirmation email //This section only here as placeholder to indicate new feature :-) } } } }