本文整理汇总了PHP中getTokenFieldsAndNames函数的典型用法代码示例。如果您正苦于以下问题:PHP getTokenFieldsAndNames函数的具体用法?PHP getTokenFieldsAndNames怎么用?PHP getTokenFieldsAndNames使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getTokenFieldsAndNames函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: loadSurveyById
/**
* Loads a survey from the database that has the given ID. If no matching
* survey is found then null is returned. Note that no results are loaded
* from this function call, only survey structure/definition.
*
* In the future it would be nice to load all languages from the db at
* once and have the infrastructure be able to return responses based
* on language codes.
*
* @param int $id
* @return SurveyObj
*/
public function loadSurveyById($id, $lang = null)
{
$survey = new SurveyObj();
$clang = Yii::app()->lang;
$intId = sanitize_int($id);
$survey->id = $intId;
$survey->info = getSurveyInfo($survey->id);
$availableLanguages = Survey::model()->findByPk($intId)->getAllLanguages();
if (is_null($lang) || in_array($lang, $availableLanguages) === false) {
// use base language when requested language is not found or no specific language is requested
$lang = Survey::model()->findByPk($intId)->language;
}
$clang = new limesurvey_lang($lang);
$survey->fieldMap = createFieldMap($intId, 'full', true, false, $lang);
// Check to see if timings are present and add to fieldmap if needed
if ($survey->info['savetimings'] == "Y") {
$survey->fieldMap = $survey->fieldMap + createTimingsFieldMap($intId, 'full', true, false, $lang);
}
if (empty($intId)) {
//The id given to us is not an integer, croak.
safeDie("An invalid survey ID was encountered: {$sid}");
}
//Load groups
$sQuery = 'SELECT g.* FROM {{groups}} AS g ' . 'WHERE g.sid = ' . $intId . ' AND g.language = \'' . $lang . '\' ' . 'ORDER BY g.group_order;';
$recordSet = Yii::app()->db->createCommand($sQuery)->query()->readAll();
$survey->groups = $recordSet;
//Load questions
$sQuery = 'SELECT q.* FROM {{questions}} AS q ' . 'JOIN {{groups}} AS g ON (q.gid = g.gid and q.language = g.language) ' . 'WHERE q.sid = ' . $intId . ' AND q.language = \'' . $lang . '\' ' . 'ORDER BY g.group_order, q.question_order;';
$survey->questions = Yii::app()->db->createCommand($sQuery)->query()->readAll();
//Load answers
$sQuery = 'SELECT DISTINCT a.* FROM {{answers}} AS a ' . 'JOIN {{questions}} AS q ON a.qid = q.qid ' . 'WHERE q.sid = ' . $intId . ' AND a.language = \'' . $lang . '\' ' . 'ORDER BY a.qid, a.sortorder;';
//$survey->answers = Yii::app()->db->createCommand($sQuery)->queryAll();
$aAnswers = Yii::app()->db->createCommand($sQuery)->queryAll();
foreach ($aAnswers as $aAnswer) {
if (Yii::app()->controller->action->id != 'remotecontrol') {
$aAnswer['answer'] = stripTagsFull($aAnswer['answer']);
}
$survey->answers[$aAnswer['qid']][$aAnswer['scale_id']][$aAnswer['code']] = $aAnswer;
}
//Load language settings for requested language
$sQuery = 'SELECT * FROM {{surveys_languagesettings}} WHERE surveyls_survey_id = ' . $intId . ' AND surveyls_language = \'' . $lang . '\';';
$recordSet = Yii::app()->db->createCommand($sQuery)->query();
$survey->languageSettings = $recordSet->read();
$recordSet->close();
if (tableExists('tokens_' . $survey->id) && array_key_exists('token', SurveyDynamic::model($survey->id)->attributes) && Permission::model()->hasSurveyPermission($survey->id, 'tokens', 'read')) {
// Now add the tokenFields
$survey->tokenFields = getTokenFieldsAndNames($survey->id);
unset($survey->tokenFields['token']);
}
return $survey;
}
开发者ID:jdbaltazar,项目名称:survey-office,代码行数:63,代码来源:SurveyDao.php
示例2: tokensExport
function tokensExport($iSurveyID)
{
$sEmailFiter = trim(App()->request->getPost('filteremail'));
$iTokenStatus = App()->request->getPost('tokenstatus');
$iInvitationStatus = App()->request->getPost('invitationstatus');
$iReminderStatus = App()->request->getPost('reminderstatus');
$sTokenLanguage = App()->request->getPost('tokenlanguage');
$oSurvey = Survey::model()->findByPk($iSurveyID);
$bIsNotAnonymous = $oSurvey->anonymized == 'N' && $oSurvey->active == 'Y';
// db table exist (survey_$iSurveyID) ?
$bquery = "SELECT * FROM {{tokens_{$iSurveyID}}} where 1=1";
$databasetype = Yii::app()->db->getDriverName();
if (trim($sEmailFiter) != '') {
if (in_array($databasetype, array('mssql', 'sqlsrv', 'dblib'))) {
$bquery .= ' and CAST(email as varchar) like ' . dbQuoteAll('%' . $_POST['filteremail'] . '%', true);
} else {
$bquery .= ' and email like ' . dbQuoteAll('%' . $_POST['filteremail'] . '%', true);
}
}
if ($_POST['tokenstatus'] == 1) {
$bquery .= " and completed<>'N'";
} elseif ($iTokenStatus == 2) {
$bquery .= " and completed='N'";
} elseif ($iTokenStatus == 3 && $bIsNotAnonymous) {
$bquery .= " and completed='N' and token not in (select token from {{survey_{$iSurveyID}}} group by token)";
} elseif ($iTokenStatus == 4 && $bIsNotAnonymous) {
$bquery .= " and completed='N' and token in (select token from {{survey_{$iSurveyID}}} group by token)";
}
if ($iInvitationStatus == 1) {
$bquery .= " and sent<>'N'";
}
if ($iInvitationStatus == 2) {
$bquery .= " and sent='N'";
}
if ($iReminderStatus == 1) {
$bquery .= " and remindersent<>'N'";
}
if ($iReminderStatus == 2) {
$bquery .= " and remindersent='N'";
}
if ($sTokenLanguage != '') {
$bquery .= " and language=" . dbQuoteAll($sTokenLanguage);
}
$bquery .= " ORDER BY tid";
Yii::app()->loadHelper('database');
$bresult = Yii::app()->db->createCommand($bquery)->query();
//dbExecuteAssoc($bquery) is faster but deprecated!
//HEADERS should be after the above query else timeout errors in case there are lots of tokens!
header("Content-Disposition: attachment; filename=tokens_" . $iSurveyID . ".csv");
header("Content-type: text/comma-separated-values; charset=UTF-8");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: cache");
// Export UTF8 WITH BOM
$tokenoutput = chr(hexdec('EF')) . chr(hexdec('BB')) . chr(hexdec('BF'));
$tokenoutput .= "tid,firstname,lastname,email,emailstatus,token,language,validfrom,validuntil,invited,reminded,remindercount,completed,usesleft";
$attrfieldnames = getAttributeFieldNames($iSurveyID);
$attrfielddescr = getTokenFieldsAndNames($iSurveyID, true);
foreach ($attrfieldnames as $attr_name) {
$tokenoutput .= ", {$attr_name}";
if (isset($attrfielddescr[$attr_name])) {
$tokenoutput .= " <" . str_replace(",", " ", $attrfielddescr[$attr_name]['description']) . ">";
}
}
$tokenoutput .= "\n";
echo $tokenoutput;
$tokenoutput = "";
// Export token line by line and fill $aExportedTokens with token exported
Yii::import('application.libraries.Date_Time_Converter', true);
$aExportedTokens = array();
while ($brow = $bresult->read()) {
if (trim($brow['validfrom'] != '')) {
$datetimeobj = new Date_Time_Converter($brow['validfrom'], "Y-m-d H:i:s");
$brow['validfrom'] = $datetimeobj->convert('Y-m-d H:i');
}
if (trim($brow['validuntil'] != '')) {
$datetimeobj = new Date_Time_Converter($brow['validuntil'], "Y-m-d H:i:s");
$brow['validuntil'] = $datetimeobj->convert('Y-m-d H:i');
}
$tokenoutput .= '"' . trim($brow['tid']) . '",';
$tokenoutput .= '"' . trim($brow['firstname']) . '",';
$tokenoutput .= '"' . trim($brow['lastname']) . '",';
$tokenoutput .= '"' . trim($brow['email']) . '",';
$tokenoutput .= '"' . trim($brow['emailstatus']) . '",';
$tokenoutput .= '"' . trim($brow['token']) . '",';
$tokenoutput .= '"' . trim($brow['language']) . '",';
$tokenoutput .= '"' . trim($brow['validfrom']) . '",';
$tokenoutput .= '"' . trim($brow['validuntil']) . '",';
$tokenoutput .= '"' . trim($brow['sent']) . '",';
$tokenoutput .= '"' . trim($brow['remindersent']) . '",';
$tokenoutput .= '"' . trim($brow['remindercount']) . '",';
$tokenoutput .= '"' . trim($brow['completed']) . '",';
$tokenoutput .= '"' . trim($brow['usesleft']) . '",';
foreach ($attrfieldnames as $attr_name) {
$tokenoutput .= '"' . trim($brow[$attr_name]) . '",';
}
$tokenoutput = substr($tokenoutput, 0, -1);
// remove last comma
$tokenoutput .= "\n";
echo $tokenoutput;
$tokenoutput = '';
//.........这里部分代码省略.........
开发者ID:wrenchpilot,项目名称:LimeSurvey,代码行数:101,代码来源:export_helper.php
示例3: attributeMapToken
function attributeMapToken()
{
Yii::app()->loadHelper('common');
App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('adminscripts') . "attributeMapToken.js");
App()->getClientScript()->registerCssFile(Yii::app()->getConfig('adminstyleurl') . "attributeMapToken.css");
$iSurveyID = (int) Yii::app()->request->getQuery('sid');
$aCPDBAttributes = ParticipantAttributeName::model()->getCPDBAttributes();
$aTokenAttributes = getTokenFieldsAndNames($iSurveyID, TRUE);
$selectedattribute = array();
$selectedcentralattribute = array();
$alreadymappedattid = array();
$alreadymappedattdisplay = array();
$alreadymappedattnames = array();
$i = 0;
$j = 0;
foreach ($aTokenAttributes as $key => $value) {
if ($value['cpdbmap'] == '') {
$selectedattribute[$value['description']] = $key;
} else {
$attributeid = $value['cpdbmap'];
$continue = false;
foreach ($aCPDBAttributes as $attribute) {
if ($attribute['attribute_id'] == $attributeid) {
$continue = true;
}
}
if ($continue) {
$alreadymappedattid[] = $attributeid;
$alreadymappedattdisplay[] = $key;
$alreadymappedattnames[$key] = $value['description'];
} else {
$selectedattribute[$value['description']] = $key;
}
}
}
foreach ($aCPDBAttributes as $row) {
if (!in_array($row['attribute_id'], $alreadymappedattid)) {
$selectedcentralattribute[$row['attribute_id']] = $row['attribute_name'];
}
}
$aData = array('attribute' => $selectedcentralattribute, 'tokenattribute' => $selectedattribute, 'alreadymappedattributename' => $alreadymappedattdisplay, 'alreadymappedattdescription' => $alreadymappedattnames);
$this->_renderWrappedTemplate('participants', 'attributeMapToken', $aData);
}
开发者ID:jdbaltazar,项目名称:survey-office,代码行数:43,代码来源:participantsaction.php
示例4: attributeMapToken
function attributeMapToken()
{
Yii::app()->loadHelper('common');
$this->getController()->_js_admin_includes(Yii::app()->getConfig('adminscripts') . "attributeMapToken.js");
$this->getController()->_css_admin_includes(Yii::app()->getConfig('adminstyleurl') . "attributeMapToken.css");
$iSurveyId = Yii::app()->request->getQuery('sid');
$attributes = ParticipantAttributeNames::model()->getAttributes();
$tokenattributefieldnames = getTokenFieldsAndNames($iSurveyId, TRUE);
$selectedattribute = array();
$selectedcentralattribute = array();
$alreadymappedattid = array();
$alreadymappedattdisplay = array();
$alreadymappedattnames = array();
$i = 0;
$j = 0;
foreach ($tokenattributefieldnames as $key => $value) {
if (is_numeric($key[10])) {
$selectedattribute[$value['description']] = $key;
} else {
$attributeid = substr($key, 15);
$continue = false;
foreach ($attributes as $attribute) {
if ($attribute['attribute_id'] == $attributeid) {
$continue = true;
}
}
if ($continue) {
array_push($alreadymappedattid, $attributeid);
array_push($alreadymappedattdisplay, $key);
$alreadymappedattnames[$key] = $value['description'];
} else {
$selectedattribute[$value['description']] = $key;
}
}
}
foreach ($attributes as $row) {
if (!in_array($row['attribute_id'], $alreadymappedattid)) {
$selectedcentralattribute[$row['attribute_id']] = $row['attribute_name'];
}
}
$aData = array('attribute' => $selectedcentralattribute, 'tokenattribute' => $selectedattribute, 'alreadymappedattributename' => $alreadymappedattdisplay, 'alreadymappedattdescription' => $alreadymappedattnames);
$this->_renderWrappedTemplate('participants', 'attributeMapToken', $aData);
}
开发者ID:pmaonline,项目名称:limesurvey-quickstart,代码行数:43,代码来源:participantsaction.php
示例5: email
/**
* Handle email action
*/
function email($iSurveyId, $tokenids = null)
{
/* Check permissions */
if (!hasSurveyPermission($iSurveyId, 'tokens', 'read')) {
die("You do not have permission to view this page");
// TODO Replace
}
$aTokenIds = $tokenids;
if (empty($tokenids)) {
$aTokenIds = Yii::app()->request->getPost('tokenids', false);
}
if (!empty($aTokenIds)) {
$aTokenIds = explode('|', $aTokenIds);
$aTokenIds = array_filter($aTokenIds);
$aTokenIds = array_map('sanitize_int', $aTokenIds);
}
$aTokenIds = array_unique(array_filter((array) $aTokenIds));
// CHECK TO SEE IF A TOKEN TABLE EXISTS FOR THIS SURVEY
$bTokenExists = tableExists('{{tokens_' . $iSurveyId . '}}');
if (!$bTokenExists) {
self::_newtokentable($iSurveyId);
}
$clang = $this->getController()->lang;
$iSurveyId = sanitize_int($iSurveyId);
if (!hasSurveyPermission($iSurveyId, 'tokens', 'update')) {
die("no permissions");
// TODO Replace
}
$sSubAction = Yii::app()->request->getParam('action');
$sSubAction = !in_array($sSubAction, array('email', 'remind')) ? 'email' : $sSubAction;
$bEmail = $sSubAction == 'email';
Yii::app()->loadHelper('surveytranslator');
Yii::app()->loadHelper('/admin/htmleditor');
Yii::app()->loadHelper('replacements');
$query = Tokens_dynamic::model($iSurveyId)->find();
$aExampleRow = empty($query) ? array() : $query->attributes;
$aSurveyLangs = Survey::model()->findByPk($iSurveyId)->additionalLanguages;
$sBaseLanguage = Survey::model()->findByPk($iSurveyId)->language;
array_unshift($aSurveyLangs, $sBaseLanguage);
$aTokenFields = getTokenFieldsAndNames($iSurveyId, true);
$iAttributes = 0;
$bHtml = getEmailFormat($iSurveyId) == 'html';
$timeadjust = Yii::app()->getConfig("timeadjust");
$aData['thissurvey'] = getSurveyInfo($iSurveyId);
$aData['surveyid'] = $iSurveyId;
$aData['sSubAction'] = $sSubAction;
$aData['bEmail'] = $bEmail;
$aData['aSurveyLangs'] = $aData['surveylangs'] = $aSurveyLangs;
$aData['baselang'] = $sBaseLanguage;
$aData['tokenfields'] = $aTokenFields;
$aData['nrofattributes'] = $iAttributes;
$aData['examplerow'] = $aExampleRow;
$aData['tokenids'] = $aTokenIds;
$aData['ishtml'] = $bHtml;
$iMaxEmails = Yii::app()->getConfig('maxemails');
if (Yii::app()->request->getPost('bypassbademails') == 'Y') {
$SQLemailstatuscondition = "emailstatus = 'OK'";
} else {
$SQLemailstatuscondition = "emailstatus <> 'OptOut'";
}
if (!Yii::app()->request->getPost('ok')) {
if (empty($aData['tokenids'])) {
$aTokens = Tokens_dynamic::model($iSurveyId)->findUninvited($aTokenIds, 0, $bEmail, $SQLemailstatuscondition);
foreach ($aTokens as $aToken) {
$aData['tokenids'][] = $aToken['tid'];
}
}
$this->_renderWrappedTemplate('token', array('tokenbar', $sSubAction), $aData);
} else {
$SQLremindercountcondition = "";
$SQLreminderdelaycondition = "";
if (!$bEmail) {
if (Yii::app()->request->getPost('maxremindercount') && Yii::app()->request->getPost('maxremindercount') != '' && intval(Yii::app()->request->getPost('maxremindercount')) != 0) {
$SQLremindercountcondition = "remindercount < " . intval(Yii::app()->request->getPost('maxremindercount'));
}
if (Yii::app()->request->getPost('minreminderdelay') && Yii::app()->request->getPost('minreminderdelay') != '' && intval(Yii::app()->request->getPost('minreminderdelay')) != 0) {
// Yii::app()->request->getPost('minreminderdelay') in days (86400 seconds per day)
$compareddate = dateShift(date("Y-m-d H:i:s", time() - 86400 * intval(Yii::app()->request->getPost('minreminderdelay'))), "Y-m-d H:i", $timeadjust);
$SQLreminderdelaycondition = " ( " . " (remindersent = 'N' AND sent < '" . $compareddate . "') " . " OR " . " (remindersent < '" . $compareddate . "'))";
}
}
$ctresult = Tokens_dynamic::model($iSurveyId)->findUninvited($aTokenIds, 0, $bEmail, $SQLemailstatuscondition, $SQLremindercountcondition, $SQLreminderdelaycondition);
$ctcount = count($ctresult);
$emresult = Tokens_dynamic::model($iSurveyId)->findUninvited($aTokenIds, $iMaxEmails, $bEmail, $SQLemailstatuscondition, $SQLremindercountcondition, $SQLreminderdelaycondition);
$emcount = count($emresult);
foreach ($aSurveyLangs as $language) {
$_POST['message_' . $language] = autoUnescape(Yii::app()->request->getPost('message_' . $language));
$_POST['subject_' . $language] = autoUnescape(Yii::app()->request->getPost('subject_' . $language));
if ($bHtml) {
$_POST['message_' . $language] = html_entity_decode(Yii::app()->request->getPost('message_' . $language), ENT_QUOTES, Yii::app()->getConfig("emailcharset"));
}
}
$attributes = getTokenFieldsAndNames($iSurveyId);
$tokenoutput = "";
if ($emcount > 0) {
foreach ($emresult as $emrow) {
$to = array();
//.........这里部分代码省略.........
开发者ID:rawaludin,项目名称:LimeSurvey,代码行数:101,代码来源:tokens.php
示例6: emailTokens
/**
* Sends email to tokens - invitation and reminders
*
* @param mixed $iSurveyID
* @param array $aResultTokens
* @param string $sType type of notification invite|register|remind
* @return array of results
*/
function emailTokens($iSurveyID, $aResultTokens, $sType)
{
Yii::app()->loadHelper('common');
$oSurvey = Survey::model()->findByPk($iSurveyID);
if (getEmailFormat($iSurveyID) == 'html') {
$bHtml = true;
} else {
$bHtml = false;
}
$attributes = array_keys(getTokenFieldsAndNames($iSurveyID));
$oSurveyLocale = SurveyLanguageSetting::model()->findAllByAttributes(array('surveyls_survey_id' => $iSurveyID));
$oTokens = Token::model($iSurveyID);
$aSurveyLangs = $oSurvey->additionalLanguages;
array_unshift($aSurveyLangs, $oSurvey->language);
//Convert result to associative array to minimize SurveyLocale access attempts
foreach ($oSurveyLocale as $rows) {
$oTempObject = array();
foreach ($rows as $k => $v) {
$oTempObject[$k] = $v;
}
$aSurveyLocaleData[$rows['surveyls_language']] = $oTempObject;
}
foreach ($aResultTokens as $aTokenRow) {
//Select language
$aTokenRow['language'] = trim($aTokenRow['language']);
$found = array_search($aTokenRow['language'], $aSurveyLangs);
if ($aTokenRow['language'] == '' || $found == false) {
$aTokenRow['language'] = $oSurvey['language'];
}
$sTokenLanguage = $aTokenRow['language'];
//Build recipient
$to = array();
$aEmailaddresses = explode(';', $aTokenRow['email']);
foreach ($aEmailaddresses as $sEmailaddress) {
$to[] = $aTokenRow['firstname'] . " " . $aTokenRow['lastname'] . " <{$sEmailaddress}>";
}
//Populate attributes
$fieldsarray["{SURVEYNAME}"] = $aSurveyLocaleData[$sTokenLanguage]['surveyls_title'];
if ($fieldsarray["{SURVEYNAME}"] == '') {
$fieldsarray["{SURVEYNAME}"] = $aSurveyLocaleData[$oSurvey['language']]['surveyls_title'];
}
$fieldsarray["{SURVEYDESCRIPTION}"] = $aSurveyLocaleData[$sTokenLanguage]['surveyls_description'];
if ($fieldsarray["{SURVEYDESCRIPTION}"] == '') {
$fieldsarray["{SURVEYDESCRIPTION}"] = $aSurveyLocaleData[$oSurvey['language']]['surveyls_description'];
}
$fieldsarray["{ADMINNAME}"] = $oSurvey['admin'];
$fieldsarray["{ADMINEMAIL}"] = $oSurvey['adminemail'];
$from = $fieldsarray["{ADMINNAME}"] . ' <' . $fieldsarray["{ADMINEMAIL}"] . '>';
if ($from == '') {
$from = Yii::app()->getConfig('siteadminemail');
}
foreach ($attributes as $attributefield) {
$fieldsarray['{' . strtoupper($attributefield) . '}'] = $aTokenRow[$attributefield];
$fieldsarray['{TOKEN:' . strtoupper($attributefield) . '}'] = $aTokenRow[$attributefield];
}
//create urls
$fieldsarray["{OPTOUTURL}"] = Yii::app()->getController()->createAbsoluteUrl("/optout/tokens/langcode/" . trim($aTokenRow['language']) . "/surveyid/{$iSurveyID}/token/{$aTokenRow['token']}");
$fieldsarray["{OPTINURL}"] = Yii::app()->getController()->createAbsoluteUrl("/optin/tokens/langcode/" . trim($aTokenRow['language']) . "/surveyid/{$iSurveyID}/token/{$aTokenRow['token']}");
$fieldsarray["{SURVEYURL}"] = Yii::app()->getController()->createAbsoluteUrl("/survey/index/sid/{$iSurveyID}/token/{$aTokenRow['token']}/lang/" . trim($aTokenRow['language']) . "/");
if ($bHtml) {
foreach (array('OPTOUT', 'OPTIN', 'SURVEY') as $key) {
$url = $fieldsarray["{{$key}URL}"];
$fieldsarray["{{$key}URL}"] = "<a href='{$url}'>" . htmlspecialchars($url) . '</a>';
if ($key == 'SURVEY') {
$barebone_link = $url;
}
}
}
//mail headers
$customheaders = array('1' => "X-surveyid: " . $iSurveyID, '2' => "X-tokenid: " . $fieldsarray["{TOKEN}"]);
global $maildebug;
//choose appriopriate email message
if ($sType == 'invite') {
$sSubject = $aSurveyLocaleData[$sTokenLanguage]['surveyls_email_invite_subj'];
$sMessage = $aSurveyLocaleData[$sTokenLanguage]['surveyls_email_invite'];
} else {
if ($sType == 'register') {
$sSubject = $aSurveyLocaleData[$sTokenLanguage]['surveyls_email_register_subj'];
$sMessage = $aSurveyLocaleData[$sTokenLanguage]['surveyls_email_register'];
} else {
$sSubject = $aSurveyLocaleData[$sTokenLanguage]['surveyls_email_remind_subj'];
$sMessage = $aSurveyLocaleData[$sTokenLanguage]['surveyls_email_remind'];
}
}
$modsubject = Replacefields($sSubject, $fieldsarray);
$modmessage = Replacefields($sMessage, $fieldsarray);
if (isset($barebone_link)) {
$modsubject = str_replace("@@SURVEYURL@@", $barebone_link, $modsubject);
$modmessage = str_replace("@@SURVEYURL@@", $barebone_link, $modmessage);
}
if (isset($aTokenRow['validfrom']) && trim($aTokenRow['validfrom']) != '' && convertDateTimeFormat($aTokenRow['validfrom'], 'Y-m-d H:i:s', 'U') * 1 > date('U') * 1) {
$aResult[$aTokenRow['tid']] = array('name' => $fieldsarray["{FIRSTNAME}"] . " " . $fieldsarray["{LASTNAME}"], 'email' => $fieldsarray["{EMAIL}"], 'status' => 'fail', 'error' => 'Token not valid yet');
//.........这里部分代码省略.........
开发者ID:withhope,项目名称:HIT-Survey,代码行数:101,代码来源:token_helper.php
示例7: import
//.........这里部分代码省略.........
unset($writearray[$column]);
}
$dupfound = false;
$invalidemail = false;
if ($filterduplicatetoken != false) {
$dupquery = "SELECT count(tid) from {{tokens_" . intval($iSurveyId) . "}} where 1=1";
foreach ($filterduplicatefields as $field) {
if (isset($writearray[$field])) {
$dupquery .= " and " . Yii::app()->db->quoteColumnName($field) . " = " . Yii::app()->db->quoteValue($writearray[$field]);
}
}
$dupresult = Yii::app()->db->createCommand($dupquery)->queryScalar();
if ($dupresult > 0) {
$dupfound = true;
$duplicatelist[] = Yii::app()->db->quoteValue($writearray['firstname']) . " " . Yii::app()->db->quoteValue($writearray['lastname']) . " (" . Yii::app()->db->quoteValue($writearray['email']) . ")";
}
}
$writearray['email'] = trim($writearray['email']);
//treat blank emails
if ($filterblankemail && $writearray['email'] == '') {
$invalidemail = true;
$invalidemaillist[] = $line[0] . " " . $line[1] . " ( )";
}
if ($writearray['email'] != '') {
$aEmailAddresses = explode(';', $writearray['email']);
foreach ($aEmailAddresses as $sEmailaddress) {
if (!validateEmailAddress($sEmailaddress)) {
$invalidemail = true;
$invalidemaillist[] = $line[0] . " " . $line[1] . " (" . $line[2] . ")";
}
}
}
if (isset($writearray['token'])) {
$writearray['token'] = sanitize_token($writearray['token']);
}
if (!$dupfound && !$invalidemail) {
// unset all empty value
foreach ($writearray as $key => $value) {
if ($writearray[$key] == "") {
unset($writearray[$key]);
}
if (substr($value, 0, 1) == '"' && substr($value, -1) == '"') {
// Fix CSV quote
$value = substr($value, 1, -1);
}
}
// Some default value : to be moved to Token model rules in future release ?
// But think we have to accept invalid email etc ... then use specific scenario
$writearray['emailstatus'] = isset($writearray['emailstatus']) ? $writearray['emailstatus'] : "OK";
$writearray['language'] = isset($writearray['language']) ? $writearray['language'] : $sBaseLanguage;
$oToken = Token::create($iSurveyId);
foreach ($writearray as $key => $value) {
//if(in_array($key,$oToken->attributes)) Not needed because we filter attributes before
$oToken->{$key} = $value;
}
$ir = $oToken->save();
if (!$ir) {
$duplicatelist[] = $writearray['firstname'] . " " . $writearray['lastname'] . " (" . $writearray['email'] . ")";
} else {
$xz++;
}
}
$xv++;
}
$recordcount++;
}
$recordcount = $recordcount - 1;
unlink($sFilePath);
$aData['tokenlistarray'] = $tokenlistarray;
$aData['xz'] = $xz;
$aData['xv'] = $xv;
$aData['recordcount'] = $recordcount;
$aData['firstline'] = $firstline;
$aData['duplicatelist'] = $duplicatelist;
$aData['invalidformatlist'] = $invalidformatlist;
$aData['invalidemaillist'] = $invalidemaillist;
$aData['thissurvey'] = getSurveyInfo($iSurveyId);
$aData['iSurveyId'] = $aData['surveyid'] = $iSurveyId;
$this->_renderWrappedTemplate('token', array('tokenbar', 'csvpost'), $aData);
}
} else {
$aData['aEncodings'] = $aEncodings;
$aData['iSurveyId'] = $iSurveyId;
$aData['thissurvey'] = getSurveyInfo($iSurveyId);
$aData['surveyid'] = $iSurveyId;
$aTokenTableFields = getTokenFieldsAndNames($iSurveyId);
unset($aTokenTableFields['sent']);
unset($aTokenTableFields['remindersent']);
unset($aTokenTableFields['remindercount']);
unset($aTokenTableFields['usesleft']);
foreach ($aTokenTableFields as $sKey => $sValue) {
if ($sValue['description'] != $sKey) {
$sValue['description'] .= ' - ' . $sKey;
}
$aNewTokenTableFields[$sKey] = $sValue['description'];
}
$aData['aTokenTableFields'] = $aNewTokenTableFields;
$this->_renderWrappedTemplate('token', array('tokenbar', 'csvupload'), $aData);
}
}
开发者ID:josetorerobueno,项目名称:test_repo,代码行数:101,代码来源:tokens.php
示例8: eT
<select name='attribute_select[]' multiple size='20' class="form-control" id="attribute_select">
<option value='first_name' id='first_name'><?php
eT("First name");
?>
</option>
<option value='last_name' id='last_name'><?php
eT("Last name");
?>
</option>
<option value='email_address' id='email_address'><?php
eT("Email address");
?>
</option>
<?php
$attrfieldnames = getTokenFieldsAndNames($surveyid, true);
foreach ($attrfieldnames as $attr_name => $attr_desc) {
echo "<option value='{$attr_name}' id='{$attr_name}' />" . $attr_desc['description'] . "</option>\n";
}
?>
</select>
</div>
</div>
</div>
<?php
}
?>
</div>
</div>
</div>
开发者ID:mfavetti,项目名称:LimeSurvey,代码行数:31,代码来源:exportresults_view.php
示例9: attributeMapToken
/**
* This function is responsible for attribute mapping while copying participants from tokens to CPDB
*/
public function attributeMapToken()
{
Yii::app()->loadHelper('common');
$this->registerScriptFile('ADMIN_SCRIPT_PATH', 'attributeMapToken.js');
$this->registerCssFile('ADMIN', 'attributeMapToken.css');
$iSurveyID = (int) Yii::app()->request->getQuery('sid');
$aCPDBAttributes = ParticipantAttributeName::model()->getCPDBAttributes();
$aTokenAttributes = getTokenFieldsAndNames($iSurveyID, TRUE);
$selectedattribute = array();
$selectedcentralattribute = array();
$alreadymappedattid = array();
$alreadymappedattdisplay = array();
$alreadymappedattnames = array();
foreach ($aTokenAttributes as $key => $value) {
if ($value['cpdbmap'] == '') {
$selectedattribute[$value['description']] = $key;
} else {
$attributeid = $value['cpdbmap'];
$continue = false;
foreach ($aCPDBAttributes as $attribute) {
if ($attribute['attribute_id'] == $attributeid) {
$continue = true;
}
}
if ($continue) {
$alreadymappedattid[] = $attributeid;
$alreadymappedattdisplay[] = $key;
$alreadymappedattnames[$key] = $value['description'];
} else {
$selectedattribute[$value['description']] = $key;
}
}
}
foreach ($aCPDBAttributes as $row) {
if (!in_array($row['attribute_id'], $alreadymappedattid)) {
$selectedcentralattribute[$row['attribute_id']] = $row['attribute_name'];
}
}
if (count($selectedattribute) === 0) {
Yii::app()->setFlashMessage(gT("There are no unmapped attributes"), 'warning');
}
$aData = array('attribute' => $selectedcentralattribute, 'tokenattribute' => $selectedattribute, 'alreadymappedattributename' => $alreadymappedattdisplay, 'alreadymappedattdescription' => $alreadymappedattnames);
$this->_renderWrappedTemplate('participants', 'attributeMapToken', $aData);
}
开发者ID:sickpig,项目名称:LimeSurvey,代码行数:47,代码来源:participantsaction.php
示例10: _getReplacementFields
private function _getReplacementFields($fieldtype, $surveyid)
{
$clang = Yii::app()->lang;
$replFields = array();
switch ($fieldtype) {
case 'survey-desc':
case 'survey-welc':
case 'survey-endtext':
case 'edittitle':
// for translation
// for translation
case 'editdescription':
// for translation
// for translation
case 'editwelcome':
// for translation
// for translation
case 'editend':
// for translation
$replFields[] = array('TOKEN:FIRSTNAME', $clang->gT("Firstname from token"));
$replFields[] = array('TOKEN:LASTNAME', $clang->gT("Lastname from token"));
$replFields[] = array('TOKEN:EMAIL', $clang->gT("Email from the token"));
$attributes = getTokenFieldsAndNames($surveyid, true);
foreach ($attributes as $attributefield => $attributedescription) {
$replFields[] = array('TOKEN:' . strtoupper($attributefield), sprintf($clang->gT("Token attribute: %s"), $attributedescription['description']));
}
$replFields[] = array('EXPIRY', $clang->gT("Survey expiration date"));
return array($replFields, false);
case 'email-admin-notification':
$replFields[] = array('RELOADURL', $clang->gT("Reload URL"));
$replFields[] = array('VIEWRESPONSEURL', $clang->gT("View response URL"));
$replFields[] = array('EDITRESPONSEURL', $clang->gT("Edit response URL"));
$replFields[] = array('STATISTICSURL', $clang->gT("Statistics URL"));
$replFields[] = array('TOKEN', $clang->gT("Token code for this participant"));
$replFields[] = array('TOKEN:FIRSTNAME', $clang->gT("First name from token"));
$replFields[] = array('TOKEN:LASTNAME', $clang->gT("Last name from token"));
$replFields[] = array('SURVEYNAME', $clang->gT("Name of the survey"));
$replFields[] = array('SURVEYDESCRIPTION', $clang->gT("Description of the survey"));
$attributes = getTokenFieldsAndNames($surveyid, true);
foreach ($attributes as $attributefield => $attributedescription) {
$replFields[] = array(strtoupper($attributefield), sprintf($clang->gT("Token attribute: %s"), $attributedescription['description']));
}
$replFields[] = array('ADMINNAME', $clang->gT("Name of the survey administrator"));
$replFields[] = array('ADMINEMAIL', $clang->gT("Email address of the survey administrator"));
return array($replFields, false);
case 'email-admin-resp':
$replFields[] = array('RELOADURL', $clang->gT("Reload URL"));
$replFields[] = array('VIEWRESPONSEURL', $clang->gT("View response URL"));
$replFields[] = array('EDITRESPONSEURL', $clang->gT("Edit response URL"));
$replFields[] = array('STATISTICSURL', $clang->gT("Statistics URL"));
$replFields[] = array('ANSWERTABLE', $clang->gT("Answers from this response"));
$replFields[] = array('TOKEN', $clang->gT("Token code for this participant"));
$replFields[] = array('TOKEN:FIRSTNAME', $clang->gT("First name from token"));
$replFields[] = array('TOKEN:LASTNAME', $clang->gT("Last name from token"));
$replFields[] = array('SURVEYNAME', $clang->gT("Name of the survey"));
$replFields[] = array('SURVEYDESCRIPTION', $clang->gT("Description of the survey"));
$attributes = getTokenFieldsAndNames($surveyid, true);
foreach ($attributes as $attributefield => $attributedescription) {
$replFields[] = array(strtoupper($attributefield), sprintf($clang->gT("Token attribute: %s"), $attributedescription['description']));
}
$replFields[] = array('ADMINNAME', $clang->gT("Name of the survey administrator"));
$replFields[] = array('ADMINEMAIL', $clang->gT("Email address of the survey administrator"));
return array($replFields, false);
case 'email-inv':
case 'email-rem':
// these 2 fields are supported by email-inv and email-rem
// but not email-reg for the moment
$replFields[] = array('EMAIL', $clang->gT("Email from the token"));
$replFields[] = array('TOKEN', $clang->gT("Token code for this participant"));
$replFields[] = array('OPTOUTURL', $clang->gT("URL for a respondent to opt-out this survey"));
$replFields[] = array('OPTINURL', $clang->gT("URL for a respondent to opt-in this survey"));
case 'email-reg':
$replFields[] = array('FIRSTNAME', $clang->gT("Firstname from token"));
$replFields[] = array('LASTNAME', $clang->gT("Lastname from token"));
$replFields[] = array('SURVEYNAME', $clang->gT("Name of the survey"));
$replFields[] = array('SURVEYDESCRIPTION', $clang->gT("Description of the survey"));
$attributes = getTokenFieldsAndNames($surveyid, true);
foreach ($attributes as $attributefield => $attributedescription) {
$replFields[] = array(strtoupper($attributefield), sprintf($clang->gT("Token attribute: %s"), $attributedescription['description']));
}
$replFields[] = array('ADMINNAME', $clang->gT("Name of the survey administrator"));
$replFields[] = array('ADMINEMAIL', $clang->gT("Email address of the survey administrator"));
$replFields[] = array('SURVEYURL', $clang->gT("URL of the survey"));
$replFields[] = array('EXPIRY', $clang->gT("Survey expiration date"));
return array($replFields, false);
case 'email-conf':
$replFields[] = array('TOKEN', $clang->gT("Token code for this participant"));
$replFields[] = array('FIRSTNAME', $clang->gT("Firstname from token"));
$replFields[] = array('LASTNAME', $clang->gT("Lastname from token"));
$replFields[] = array('SURVEYNAME', $clang->gT("Name of the survey"));
$replFields[] = array('SURVEYDESCRIPTION', $clang->gT("Description of the survey"));
$attributes = getTokenFieldsAndNames($surveyid, true);
foreach ($attributes as $attributefield => $attributedescription) {
$replFields[] = array(strtoupper($attributefield), sprintf($clang->gT("Token attribute: %s"), $attributedescription['description']));
}
$replFields[] = array('ADMINNAME', $clang->gT("Name of the survey administrator"));
$replFields[] = array('ADMINEMAIL', $clang->gT("Email address of the survey administrator"));
$replFields[] = array('SURVEYURL', $clang->gT("URL of the survey"));
$replFields[] = array('EXPIRY', $clang->gT("Survey expiration date"));
// email-conf can accept insertans fields for non anonymous surveys
//.........这里部分代码省略.........
开发者ID:pmaonline,项目名称:limesurvey-quickstart,代码行数:101,代码来源:limereplacementfields.php
示例11: exportresults
//.........这里部分代码省略.........
$selecthide = "selected='selected'";
} elseif (incompleteAnsFilterState() == "incomplete") {
$selectinc = "selected='selected'";
} else {
$selectshow = "selected='selected'";
}
$aFields = array();
foreach ($aFieldMap as $sFieldName => $fieldinfo) {
$sCode = viewHelper::getFieldCode($fieldinfo);
$aFields[$sFieldName] = $sCode . ' - ' . htmlspecialchars(ellipsize(html_entity_decode(viewHelper::getFieldText($fieldinfo)), 30, 0.6, '...'));
$aFieldsOptions[$sFieldName] = array('title' => viewHelper::getFieldText($fieldinfo), 'data-fieldname' => $fieldinfo['fieldname'], 'data-emcode' => viewHelper::getFieldCode($fieldinfo, array('LEMcompat' => true)));
// No need to filter title : Yii do it (remove all tag)
}
$data['SingleResponse'] = (int) returnGlobal('id');
$data['selecthide'] = $selecthide;
$data['selectshow'] = $selectshow;
$data['selectinc'] = $selectinc;
$data['afieldcount'] = $iFieldCount;
$data['aFields'] = $aFields;
$data['aFieldsOptions'] = $aFieldsOptions;
//get max number of datasets
$iMaximum = SurveyDynamic::model($iSurveyID)->getMaxId();
$data['max_datasets'] = $iMaximum;
$data['surveyid'] = $iSurveyID;
$data['imageurl'] = Yii::app()->getConfig('imageurl');
$data['thissurvey'] = $thissurvey;
$data['display']['menu_bars']['browse'] = gT("Export results");
// Export plugins, leave out all entries that are not plugin
$exports = array_filter($exports);
$exportData = array();
foreach ($exports as $key => $plugin) {
$event = new PluginEvent('listExportOptions');
$event->set('type', $key);
$oPluginManager = App()->getPluginManager();
$oPluginManager->dispatchEvent($event, $plugin);
$exportData[$key] = array('onclick' => $event->get('onclick'), 'label' => $event->get('label'), 'checked' => $event->get('default', false), 'tooltip' => $event->get('tooltip', null));
}
$data['exports'] = $exportData;
// Pass available exports
$data['headexports'] = array('code' => array('label' => gT("Question code"), 'help' => null, 'checked' => false), 'abbreviated' => array('label' => gT("Abbreviated question text"), 'help' => null, 'checked' => false), 'full' => array('label' => gT("Full question text"), 'help' => null, 'checked' => true), 'codetext' => array('label' => gT("Question code and question text"), 'help' => null, 'checked' => false));
// Add a plugin for adding headexports : a public function getRegistereddPlugins($event) can help here.
$aLanguagesCode = Survey::model()->findByPk($iSurveyID)->getAllLanguages();
$aLanguages = array();
foreach ($aLanguagesCode as $sLanguage) {
$aLanguages[$sLanguage] = getLanguageNameFromCode($sLanguage, false);
}
$data['aLanguages'] = $aLanguages;
// Pass available exports
$this->_renderWrappedTemplate('export', 'exportresults_view', $data);
return;
}
// Export Language is set by default to surveybaselang
// * the explang language code is used in SQL queries
// * the alang object is used to translate headers and hardcoded answers
// In the future it might be possible to 'post' the 'export language' from
// the exportresults form
$explang = Yii::app()->request->getPost('exportlang', $surveybaselang);
//Get together our FormattingOptions and then call into the exportSurvey
//function.
$options = new FormattingOptions();
$options->selectedColumns = Yii::app()->request->getPost('colselect');
$options->responseMinRecord = sanitize_int(Yii::app()->request->getPost('export_from'));
$options->responseMaxRecord = sanitize_int(Yii::app()->request->getPost('export_to'));
$options->answerFormat = $sAnswerFormat;
$options->convertY = $bConvertY;
$options->yValue = $bConvertY ? $sYValue : null;
$options->convertN = $bConvertN;
$options->nValue = $bConvertN ? $sNValue : null;
$options->headingTextLength = Yii::app()->request->getPost('abbreviatedtext') ? (int) Yii::app()->request->getPost('abbreviatedtextto') : null;
$options->useEMCode = Yii::app()->request->getPost('emcode');
$options->headCodeTextSeparator = Yii::app()->request->getPost('codetextseparator');
$options->headerSpacesToUnderscores = $bHeaderSpacesToUnderscores;
$options->headingFormat = $sHeadingFormat;
$options->responseCompletionState = incompleteAnsFilterState();
$options->output = 'display';
// Replace token information by the column name
if (in_array('first_name', Yii::app()->request->getPost('attribute_select', array()))) {
$options->selectedColumns[] = "firstname";
}
if (in_array('last_name', Yii::app()->request->getPost('attribute_select', array()))) {
$options->selectedColumns[] = "lastname";
}
if (in_array('email_address', Yii::app()->request->getPost('attribute_select', array()))) {
$options->selectedColumns[] = "email";
}
$attributeFields = array_keys(getTokenFieldsAndNames($iSurveyID, TRUE));
foreach ($attributeFields as $attr_name) {
if (in_array($attr_name, Yii::app()->request->getPost('attribute_select', array()))) {
$options->selectedColumns[] = $attr_name;
}
}
if (Yii::app()->request->getPost('response_id')) {
$sF
|
请发表评论