本文整理汇总了PHP中isTokenCompletedDatestamped函数的典型用法代码示例。如果您正苦于以下问题:PHP isTokenCompletedDatestamped函数的具体用法?PHP isTokenCompletedDatestamped怎么用?PHP isTokenCompletedDatestamped使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isTokenCompletedDatestamped函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: submittokens
/**
* 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)
{
$surveyid = Yii::app()->getConfig('surveyID');
if (isset($_SESSION['survey_' . $surveyid]['s_lang'])) {
$thissurvey = getSurveyInfo($surveyid, $_SESSION['survey_' . $surveyid]['s_lang']);
} else {
$thissurvey = getSurveyInfo($surveyid);
}
$clienttoken = $_SESSION['survey_' . $surveyid]['token'];
$sitename = Yii::app()->getConfig("sitename");
$emailcharset = Yii::app()->getConfig("emailcharset");
// Shift the date due to global timeadjust setting
$today = dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i", Yii::app()->getConfig("timeadjust"));
// check how many uses the token has left
$token = Token::model($surveyid)->findByAttributes(array('token' => $clienttoken));
if ($quotaexit == true) {
$token->completed = 'Q';
$token->usesleft--;
} else {
if ($token->usesleft <= 1) {
// Finish the token
if (isTokenCompletedDatestamped($thissurvey)) {
$token->completed = $today;
} else {
$token->completed = 'Y';
}
if (isset($token->participant_id)) {
$slquery = SurveyLink::model()->find('participant_id = :pid AND survey_id = :sid AND token_id = :tid', array(':pid' => $token->participant_id, ':sid' => $surveyid, ':tid' => $token->tid));
if ($slquery) {
if (isTokenCompletedDatestamped($thissurvey)) {
$slquery->date_completed = $today;
} else {
// Update the survey_links table if necessary, to protect anonymity, use the date_created field date
$slquery->date_completed = $slquery->date_created;
}
$slquery->save();
}
}
}
$token->usesleft--;
}
$token->save();
if ($quotaexit == false) {
if ($token && trim(strip_tags($thissurvey['email_confirm'])) != "" && $thissurvey['sendconfirmation'] == "Y") {
// if($token->completed == "Y" || $token->completed == $today)
// {
$from = "{$thissurvey['adminname']} <{$thissurvey['adminemail']}>";
$subject = $thissurvey['email_confirm_subj'];
$aReplacementVars = array();
$aReplacementVars["ADMINNAME"] = $thissurvey['admin'];
$aReplacementVars["ADMINEMAIL"] = $thissurvey['adminemail'];
$aReplacementVars['ADMINEMAIL'] = $thissurvey['adminemail'];
//Fill with token info, because user can have his information with anonimity control
$aReplacementVars["FIRSTNAME"] = $token->firstname;
$aReplacementVars["LASTNAME"] = $token->lastname;
$aReplacementVars["TOKEN"] = $token->token;
// added survey url in replacement vars
$surveylink = Yii::app()->createAbsoluteUrl("/survey/index/sid/{$surveyid}", array('lang' => $_SESSION['survey_' . $surveyid]['s_lang'], 'token' => $token->token));
$aReplacementVars['SURVEYURL'] = $surveylink;
$attrfieldnames = getAttributeFieldNames($surveyid);
foreach ($attrfieldnames as $attr_name) {
$aReplacementVars[strtoupper($attr_name)] = $token->{$attr_name};
}
$dateformatdatat = getDateFormatData($thissurvey['surveyls_dateformat']);
$numberformatdatat = getRadixPointData($thissurvey['surveyls_numberformat']);
$redata = array('thissurvey' => $thissurvey);
$subject = templatereplace($subject, $aReplacementVars, $redata, '', false, null, array(), true);
$subject = html_entity_decode($subject, ENT_QUOTES, $emailcharset);
if (getEmailFormat($surveyid) == 'html') {
$ishtml = true;
} else {
$ishtml = false;
}
$message = $thissurvey['email_confirm'];
//$message=ReplaceFields($message, $fieldsarray, true);
$message = templatereplace($message, $aReplacementVars, $redata, '', false, null, array(), true);
if (!$ishtml) {
$message = strip_tags(breakToNewline(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
$sToAddress = validateEmailAddresses($token->email);
if ($sToAddress) {
$aAttachments = unserialize($thissurvey['attachments']);
$aRelevantAttachments = array();
/*
* Iterate through attachments and check them for relevance.
*/
if (isset($aAttachments['confirmation'])) {
foreach ($aAttachments['confirmation'] as $aAttachment) {
$relevance = $aAttachment['relevance'];
// If the attachment is relevant it will be added to the mail.
//.........这里部分代码省略.........
示例2: insert
//.........这里部分代码省略.........
$dateformatdetails = getDateFormatDataForQID($qidattributes, $thissurvey);
$datetimeobj = new Date_Time_Converter($_POST[$fieldname], $dateformatdetails['phpdate']);
$insert_data[$fieldname] = $datetimeobj->convert("Y-m-d H:i:s");
} else {
$insert_data[$fieldname] = $_POST[$fieldname];
}
}
}
}
Survey_dynamic::sid($surveyid);
$new_response = new Survey_dynamic();
foreach ($insert_data as $column => $value) {
$new_response->{$column} = $value;
}
$new_response->save();
$last_db_id = $new_response->getPrimaryKey();
if (isset($_POST['closerecord']) && isset($_POST['token']) && $_POST['token'] != '') {
// get submit date
if (isset($_POST['closedate'])) {
$submitdate = $_POST['closedate'];
} else {
$submitdate = dateShift(date("Y-m-d H:i:s"), "Y-m-d", $timeadjust);
}
// check how many uses the token has left
$usesquery = "SELECT usesleft FROM {{tokens_}}{$surveyid} WHERE token='" . $_POST['token'] . "'";
$usesresult = dbExecuteAssoc($usesquery);
$usesrow = $usesresult->readAll();
//$usesresult->row_array()
if (isset($usesrow)) {
$usesleft = $usesrow[0]['usesleft'];
}
// query for updating tokens
$utquery = "UPDATE {{tokens_{$surveyid}}}\n";
if (isTokenCompletedDatestamped($thissurvey)) {
if (isset($usesleft) && $usesleft <= 1) {
$utquery .= "SET usesleft=usesleft-1, completed='{$submitdate}'\n";
} else {
$utquery .= "SET usesleft=usesleft-1\n";
}
} else {
if (isset($usesleft) && $usesleft <= 1) {
$utquery .= "SET usesleft=usesleft-1, completed='Y'\n";
} else {
$utquery .= "SET usesleft=usesleft-1\n";
}
}
$utquery .= "WHERE token='" . $_POST['token'] . "'";
$utresult = dbExecuteAssoc($utquery);
//Yii::app()->db->Execute($utquery) or safeDie ("Couldn't update tokens table!<br />\n$utquery<br />\n".Yii::app()->db->ErrorMsg());
// save submitdate into survey table
$srid = Yii::app()->db->getLastInsertID();
// Yii::app()->db->getLastInsertID();
$sdquery = "UPDATE {{survey_{$surveyid}}} SET submitdate='" . $submitdate . "' WHERE id={$srid}\n";
$sdresult = dbExecuteAssoc($sdquery) or safeDie("Couldn't set submitdate response in survey table!<br />\n{$sdquery}<br />\n");
$last_db_id = Yii::app()->db->getLastInsertID();
}
if (isset($_POST['save']) && $_POST['save'] == "on") {
$srid = Yii::app()->db->getLastInsertID();
//Yii::app()->db->getLastInsertID();
$aUserData = Yii::app()->session;
//CREATE ENTRY INTO "saved_control"
$saved_control_table = '{{saved_control}}';
$columns = array("sid", "srid", "identifier", "access_code", "email", "ip", "refurl", 'saved_thisstep', "status", "saved_date");
$values = array("'" . $surveyid . "'", "'" . $srid . "'", "'" . $saver['identifier'] . "'", "'" . $password . "'", "'" . $saver['email'] . "'", "'" . $aUserData['ip_address'] . "'", "'" . getenv("HTTP_REFERER") . "'", 0, "'" . "S" . "'", "'" . dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i:s", "'" . Yii::app()->getConfig('timeadjust')) . "'");
$SQL = "INSERT INTO {$saved_control_table}\n (" . implode(',', $columns) . ")\n VALUES\n (" . implode(',', $values) . ")";
/*$scdata = array("sid"=>$surveyid,
示例3: submittokens
/**
* 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;
global $surveyid;
global $clienttoken;
$clang = Yii::app()->lang;
$sitename = Yii::app()->getConfig("sitename");
$emailcharset = Yii::app()->getConfig("emailcharset");
// Shift the date due to global timeadjust setting
$today = dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i", Yii::app()->getConfig("timeadjust"));
// check how many uses the token has left
$usesquery = "SELECT usesleft, participant_id, tid FROM {{tokens_{$surveyid}}} WHERE token='" . $clienttoken . "'";
$usesresult = dbExecuteAssoc($usesquery);
$usesrow = $usesresult->read();
if (isset($usesrow)) {
$usesleft = $usesrow['usesleft'];
$participant_id = $usesrow['participant_id'];
$token_id = $usesrow['tid'];
}
$utquery = "UPDATE {{tokens_{$surveyid}}}\n";
if ($quotaexit == true) {
$utquery .= "SET completed='Q', usesleft=usesleft-1\n";
} elseif (isTokenCompletedDatestamped($thissurvey)) {
if (isset($usesleft) && $usesleft <= 1) {
$utquery .= "SET usesleft=usesleft-1, completed='{$today}'\n";
if (!empty($participant_id)) {
//Update the survey_links table if necessary
$slquery = Survey_links::model()->find('participant_id = "' . $participant_id . '" AND survey_id = ' . $surveyid . ' AND token_id = ' . $token_id);
$slquery->date_completed = $today;
$slquery->save();
}
} else {
$utquery .= "SET usesleft=usesleft-1\n";
}
} else {
if (isset($usesleft) && $usesleft <= 1) {
$utquery .= "SET usesleft=usesleft-1, completed='Y'\n";
if (!empty($participant_id)) {
//Update the survey_links table if necessary, to protect anonymity, use the date_created field date
$slquery = Survey_links::model()->find('participant_id = "' . $participant_id . '" AND survey_id = ' . $surveyid . ' AND token_id = ' . $token_id);
$slquery->date_completed = $slquery->date_created;
$slquery->save();
}
} else {
$utquery .= "SET usesleft=usesleft-1\n";
}
}
$utquery .= "WHERE token='" . $clienttoken . "'";
$utresult = dbExecuteAssoc($utquery) or safeDie("Couldn't update tokens table!<br />\n{$utquery}<br />\n");
//Checked
if ($quotaexit == false) {
// TLR change to put date into sent and completed
$cnfquery = "SELECT * FROM {{tokens_{$surveyid}}} WHERE token='" . $clienttoken . "' AND completed!='N' AND completed!=''";
$cnfresult = dbExecuteAssoc($cnfquery);
//Checked
$cnfrow = $cnfresult->read();
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']);
$numberformatdatat = getRadixPointData($thissurvey['surveyls_numberformat']);
$fieldsarray["{EXPIRY}"] = convertDateTimeFormat($thissurvey["expiry"], 'Y-m-d H:i:s', $dateformatdatat['phpdate']);
$subject = ReplaceFields($subject, $fieldsarray, true);
$subject = html_entity_decode($subject, ENT_QUOTES, $emailcharset);
if (getEmailFormat($surveyid) == 'html') {
$ishtml = true;
} else {
$ishtml = false;
}
if (trim(strip_tags($thissurvey['email_confirm'])) != "" && $thissurvey['sendconfirmation'] == "Y") {
$message = $thissurvey['email_confirm'];
$message = ReplaceFields($message, $fieldsarray, true);
if (!$ishtml) {
$message = strip_tags(breakToNewline(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 (validateEmailAddress($cnfrow['email'])) {
SendEmailMessage($message, $subject, $to, $from, $sitename, $ishtml);
}
//.........这里部分代码省略.........