/** * 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'); } elseif (isset($aTokenRow['validuntil']) && trim($aTokenRow['validuntil']) != '' && convertDateTimeFormat($aTokenRow['validuntil'], '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 anymore'); } else { if (SendEmailMessage($modmessage, $modsubject, $to, $from, Yii::app()->getConfig("sitename"), $bHtml, getBounceEmail($iSurveyID), null, $customheaders)) { $aResult[$aTokenRow['tid']] = array('name' => $fieldsarray["{FIRSTNAME}"] . " " . $fieldsarray["{LASTNAME}"], 'email' => $fieldsarray["{EMAIL}"], 'status' => 'OK'); if ($sType == 'invite' || $sType == 'register') { $oTokens->updateByPk($aTokenRow['tid'], array('sent' => dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i", Yii::app()->getConfig("timeadjust")))); } if ($sType == 'remind') { $iRCount = $oTokens->findByPk($aTokenRow['tid'])->remindercount + 1; $oTokens->updateByPk($aTokenRow['tid'], array('remindersent' => dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i", Yii::app()->getConfig("timeadjust")))); $oTokens->updateByPk($aTokenRow['tid'], array('remindercount' => $iRCount)); } } else { $aResult[$aTokenRow['tid']] = array('name' => $fieldsarray["{FIRSTNAME}"] . " " . $fieldsarray["{LASTNAME}"], 'email' => $fieldsarray["{EMAIL}"], 'status' => 'fail', 'error' => $maildebug); } } unset($fieldsarray); } return $aResult; }
/** * Handle email action */ function email($iSurveyId, $tokenids = null) { $clang = $this->getController()->lang; $iSurveyId = sanitize_int($iSurveyId); if (!Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'update')) { Yii::app()->session['flashmessage'] = $clang->gT("You do not have sufficient rights to access this page."); $this->getController()->redirect(array("/admin/survey/sa/view/surveyid/{$iSurveyId}")); } // CHECK TO SEE IF A TOKEN TABLE EXISTS FOR THIS SURVEY $bTokenExists = tableExists('{{tokens_' . $iSurveyId . '}}'); if (!$bTokenExists) { self::_newtokentable($iSurveyId); } $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)); $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'); $token = Token::model($iSurveyId)->find(); $aExampleRow = isset($token) ? $token->attributes : array(); $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); foreach ($aSurveyLangs as $sSurveyLanguage) { $aData['thissurvey'][$sSurveyLanguage] = getSurveyInfo($iSurveyId, $sSurveyLanguage); } $aData['surveyid'] = $iSurveyId; $aData['sSubAction'] = $sSubAction; $aData['bEmail'] = $bEmail; $aData['aSurveyLangs'] = $aData['surveylangs'] = $aSurveyLangs; $aData['baselang'] = $sBaseLanguage; $aData['tokenfields'] = array_keys($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 = TokenDynamic::model($iSurveyId)->findUninvitedIDs($aTokenIds, 0, $bEmail, $SQLemailstatuscondition); foreach ($aTokens as $aToken) { $aData['tokenids'][] = $aToken; } } $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 = TokenDynamic::model($iSurveyId)->findUninvitedIDs($aTokenIds, 0, $bEmail, $SQLemailstatuscondition, $SQLremindercountcondition, $SQLreminderdelaycondition); $ctcount = count($ctresult); $emresult = TokenDynamic::model($iSurveyId)->findUninvited($aTokenIds, $iMaxEmails, $bEmail, $SQLemailstatuscondition, $SQLremindercountcondition, $SQLreminderdelaycondition); $emcount = count($emresult); foreach ($aSurveyLangs as $language) { // See #08683 : this allow use of {TOKEN:ANYTHING}, directly replaced by {ANYTHING} $sSubject[$language] = preg_replace("/{TOKEN:([A-Z0-9_]+)}/", "{" . "\$1" . "}", Yii::app()->request->getPost('subject_' . $language)); $sMessage[$language] = preg_replace("/{TOKEN:([A-Z0-9_]+)}/", "{" . "\$1" . "}", Yii::app()->request->getPost('message_' . $language)); if ($bHtml) { $sMessage[$language] = html_entity_decode($sMessage[$language], ENT_QUOTES, Yii::app()->getConfig("emailcharset")); } } $attributes = array_keys(getTokenFieldsAndNames($iSurveyId, true)); $tokenoutput = ""; if ($emcount > 0) { foreach ($emresult as $emrow) { $to = $fieldsarray = array(); $aEmailaddresses = explode(';', $emrow['email']); foreach ($aEmailaddresses as $sEmailaddress) { $to[] = $emrow['firstname'] . " " . $emrow['lastname'] . " <{$sEmailaddress}>"; } $fieldsarray["{EMAIL}"] = $emrow['email']; $fieldsarray["{FIRSTNAME}"] = $emrow['firstname']; $fieldsarray["{LASTNAME}"] = $emrow['lastname']; $fieldsarray["{TOKEN}"] = $emrow['token']; $fieldsarray["{LANGUAGE}"] = $emrow['language']; foreach ($attributes as $attributefield) { $fieldsarray['{' . strtoupper($attributefield) . '}'] = $emrow[$attributefield]; $fieldsarray['{TOKEN:' . strtoupper($attributefield) . '}'] = $emrow[$attributefield]; } $emrow['language'] = trim($emrow['language']); $found = array_search($emrow['language'], $aSurveyLangs); if ($emrow['language'] == '' || $found == false) { $emrow['language'] = $sBaseLanguage; } $from = Yii::app()->request->getPost('from_' . $emrow['language']); $fieldsarray["{OPTOUTURL}"] = $this->getController()->createAbsoluteUrl("/optout/tokens/langcode/" . trim($emrow['language']) . "/surveyid/{$iSurveyId}/token/{$emrow['token']}"); $fieldsarray["{OPTINURL}"] = $this->getController()->createAbsoluteUrl("/optin/tokens/langcode/" . trim($emrow['language']) . "/surveyid/{$iSurveyId}/token/{$emrow['token']}"); $fieldsarray["{SURVEYURL}"] = $this->getController()->createAbsoluteUrl("/survey/index/sid/{$iSurveyId}/token/{$emrow['token']}/lang/" . trim($emrow['language']) . "/"); foreach (array('OPTOUT', 'OPTIN', 'SURVEY') as $key) { $url = $fieldsarray["{{$key}URL}"]; if ($bHtml) { $fieldsarray["{{$key}URL}"] = "<a href='{$url}'>" . htmlspecialchars($url) . '</a>'; } if ($key == 'SURVEY') { $barebone_link = $url; } } $customheaders = array('1' => "X-surveyid: " . $iSurveyId, '2' => "X-tokenid: " . $fieldsarray["{TOKEN}"]); global $maildebug; $modsubject = Replacefields($sSubject[$emrow['language']], $fieldsarray); $modmessage = Replacefields($sMessage[$emrow['language']], $fieldsarray); if (isset($barebone_link)) { $modsubject = str_replace("@@SURVEYURL@@", $barebone_link, $modsubject); $modmessage = str_replace("@@SURVEYURL@@", $barebone_link, $modmessage); } if (trim($emrow['validfrom']) != '' && convertDateTimeFormat($emrow['validfrom'], 'Y-m-d H:i:s', 'U') * 1 > date('U') * 1) { $tokenoutput .= $emrow['tid'] . " " . ReplaceFields($clang->gT("Email to {FIRSTNAME} {LASTNAME} ({EMAIL}) delayed: Token is not yet valid.") . "<br />", $fieldsarray); } elseif (trim($emrow['validuntil']) != '' && convertDateTimeFormat($emrow['validuntil'], 'Y-m-d H:i:s', 'U') * 1 < date('U') * 1) { $tokenoutput .= $emrow['tid'] . " " . ReplaceFields($clang->gT("Email to {FIRSTNAME} {LASTNAME} ({EMAIL}) skipped: Token is not valid anymore.") . "<br />", $fieldsarray); } else { /* * Get attachments. */ if ($sSubAction == 'email') { $sTemplate = 'invitation'; } elseif ($sSubAction == 'remind') { $sTemplate = 'reminder'; } $aRelevantAttachments = array(); if (isset($aData['thissurvey'][$emrow['language']]['attachments'])) { $aAttachments = unserialize($aData['thissurvey'][$emrow['language']]['attachments']); if (!empty($aAttachments)) { if (isset($aAttachments[$sTemplate])) { LimeExpressionManager::singleton()->loadTokenInformation($aData['thissurvey']['sid'], $emrow['token']); foreach ($aAttachments[$sTemplate] as $aAttachment) { if (LimeExpressionManager::singleton()->ProcessRelevance($aAttachment['relevance'])) { $aRelevantAttachments[] = $aAttachment['url']; } } } } } /** * Event for email handling. * Parameter type description: * subject rw Body of the email * to rw Recipient(s) * from rw Sender(s) * type r "invitation" or "reminder" * send w If true limesurvey will send the email. Setting this to false will cause limesurvey to assume the mail has been sent by the plugin. * error w If set and "send" is true, log the error as failed email attempt. * token r Raw token data. */ $event = new PluginEvent('beforeTokenEmail'); $event->set('type', $sTemplate); $event->set('subject', $modsubject); $event->set('to', $to); $event->set('body', $modmessage); $event->set('from', $from); $event->set('bounce', getBounceEmail($iSurveyId)); $event->set('token', $emrow); App()->getPluginManager()->dispatchEvent($event); $modsubject = $event->get('subject'); $modmessage = $event->get('body'); $to = $event->get('to'); $from = $event->get('from'); if ($event->get('send', true) == false) { // This is some ancient global used for error reporting instead of a return value from the actual mail function.. $maildebug = $event->get('error', $maildebug); $success = $event->get('error') == null; } else { $success = SendEmailMessage($modmessage, $modsubject, $to, $from, Yii::app()->getConfig("sitename"), $bHtml, getBounceEmail($iSurveyId), $aRelevantAttachments, $customheaders); } if ($success) { // Put date into sent $token = Token::model($iSurveyId)->findByPk($emrow['tid']); if ($bEmail) { $tokenoutput .= $clang->gT("Invitation sent to:"); $token->sent = dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i", Yii::app()->getConfig("timeadjust")); } else { $tokenoutput .= $clang->gT("Reminder sent to:"); $token->remindersent = dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i", Yii::app()->getConfig("timeadjust")); $token->remindercount++; } $token->save(); //Update central participant survey_links if (!empty($emrow['participant_id'])) { $slquery = SurveyLink::model()->find('participant_id = :pid AND survey_id = :sid AND token_id = :tid', array(':pid' => $emrow['participant_id'], ':sid' => $iSurveyId, ':tid' => $emrow['tid'])); if (!is_null($slquery)) { $slquery->date_invited = dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i", Yii::app()->getConfig("timeadjust")); $slquery->save(); } } $tokenoutput .= "{$emrow['tid']}: {$emrow['firstname']} {$emrow['lastname']} ({$emrow['email']})<br />\n"; if (Yii::app()->getConfig("emailsmtpdebug") == 2) { $tokenoutput .= $maildebug; } } else { $tokenoutput .= ReplaceFields($clang->gT("Email to {FIRSTNAME} {LASTNAME} ({EMAIL}) failed. Error Message:") . " " . $maildebug . "<br />", $fieldsarray); } } unset($fieldsarray); } $aViewUrls = array('tokenbar', 'emailpost'); $aData['tokenoutput'] = $tokenoutput; if ($ctcount > $emcount) { $i = 0; if (isset($aTokenIds)) { while ($i < $iMaxEmails) { array_shift($aTokenIds); $i++; } $aData['tids'] = implode('|', $aTokenIds); } $aData['lefttosend'] = $ctcount - $iMaxEmails; $aViewUrls[] = 'emailwarning'; } else { $aData['tokenoutput'] .= "<strong class='result success text-success'>" . gT("All emails were sent.") . "<strong>"; } $this->_renderWrappedTemplate('token', $aViewUrls, $aData); } else { $this->_renderWrappedTemplate('token', array('tokenbar', 'message' => array('title' => $clang->gT("Warning"), 'message' => $clang->gT("There were no eligible emails to send. This will be because none satisfied the criteria of:") . "<br/> <ul><li>" . $clang->gT("having a valid email address") . "</li>" . "<li>" . $clang->gT("not having been sent an invitation already") . "</li>" . "<li>" . $clang->gT("having already completed the survey") . "</li>" . "<li>" . $clang->gT("having a token") . "</li></ul>")), $aData); } } }
/** * @param integer $iSurveyID The Survey ID * @param string $sFieldCode Field code of the particular field * @param string $sValue The stored response value * @param string $sLanguage Initialized limesurvey_lang object for the resulting response data * @return string */ function getExtendedAnswer($iSurveyID, $sFieldCode, $sValue, $sLanguage) { if ($sValue == null || $sValue == '') { return ''; } //Fieldcode used to determine question, $sValue used to match against answer code //Returns NULL if question type does not suit if (strpos($sFieldCode, "{$iSurveyID}X") === 0) { $fieldmap = createFieldMap($iSurveyID, 'short', false, false, $sLanguage); if (isset($fieldmap[$sFieldCode])) { $fields = $fieldmap[$sFieldCode]; } else { return false; } // If it is a comment field there is nothing to convert here if ($fields['aid'] == 'comment') { return $sValue; } //Find out the question type $this_type = $fields['type']; switch ($this_type) { case 'D': if (trim($sValue) != '') { $qidattributes = getQuestionAttributeValues($fields['qid']); $dateformatdetails = getDateFormatDataForQID($qidattributes, $iSurveyID); $sValue = convertDateTimeFormat($sValue, "Y-m-d H:i:s", $dateformatdetails['phpdate']); } break; case 'N': if (trim($sValue) != '') { if (strpos($sValue, ".") !== false) { $sValue = rtrim(rtrim($sValue, "0"), "."); } $qidattributes = getQuestionAttributeValues($fields['qid']); if ($qidattributes['num_value_int_only']) { $sValue = number_format($sValue, 0, '', ''); } } break; case "L": case "!": case "O": case "^": case "I": case "R": $result = Answer::model()->getAnswerFromCode($fields['qid'], $sValue, $sLanguage); foreach ($result as $row) { $this_answer = $row['answer']; } // while if ($sValue == "-oth-") { $this_answer = gT("Other", null, $sLanguage); } break; case "M": case "J": case "P": switch ($sValue) { case "Y": $this_answer = gT("Yes", null, $sLanguage); break; } break; case "Y": switch ($sValue) { case "Y": $this_answer = gT("Yes", null, $sLanguage); break; case "N": $this_answer = gT("No", null, $sLanguage); break; default: $this_answer = gT("No answer", null, $sLanguage); } break; case "G": switch ($sValue) { case "M": $this_answer = gT("Male", null, $sLanguage); break; case "F": $this_answer = gT("Female", null, $sLanguage); break; default: $this_answer = gT("No answer", null, $sLanguage); } break; case "C": switch ($sValue) { case "Y": $this_answer = gT("Yes", null, $sLanguage); break; case "N": $this_answer = gT("No", null, $sLanguage); break; case "U": $this_answer = gT("Uncertain", null, $sLanguage); break; } break; case "E": switch ($sValue) { case "I": $this_answer = gT("Increase", null, $sLanguage); break; case "D": $this_answer = gT("Decrease", null, $sLanguage); break; case "S": $this_answer = gT("Same", null, $sLanguage); break; } break; case "F": case "H": case "1": $aConditions = array('qid' => $fields['qid'], 'code' => $sValue, 'language' => $sLanguage); if (isset($fields['scale_id'])) { $iScaleID = $fields['scale_id']; } else { $iScaleID = 0; } $result = Answer::model()->getAnswerFromCode($fields['qid'], $sValue, $sLanguage, $iScaleID); foreach ($result as $row) { $this_answer = $row['answer']; } // while if ($sValue == "-oth-") { $this_answer = gT("Other", null, $sLanguage); } break; case "|": //File upload if (substr($sFieldCode, -9) != 'filecount') { //Show the filename, size, title and comment -- no link! $files = json_decode($sValue); $sValue = ''; if (is_array($files)) { foreach ($files as $file) { $sValue .= rawurldecode($file->name) . ' (' . round($file->size) . 'KB) ' . strip_tags($file->title); if (trim(strip_tags($file->comment)) != "") { $sValue .= ' - ' . strip_tags($file->comment); } } } } break; default: } // switch } switch ($sFieldCode) { case 'submitdate': case 'startdate': case 'datestamp': if (trim($sValue) != '') { $dateformatdetails = getDateFormatDataForQID(null, $iSurveyID); $sValue = convertDateTimeFormat($sValue, "Y-m-d H:i:s", $dateformatdetails['phpdate'] . ' H:i:s'); } break; } if (isset($this_answer)) { return $this_answer . " [{$sValue}]"; } else { return $sValue; } }
?> </option> </select></li> <?php $dateformatdata = getDateFormatData(Yii::app()->session['dateformat']); ?> <li><label for='timeadjust'><?php $clang->eT("Time difference (in hours):"); ?> </label> <span><input type='text' size='10' id='timeadjust' name='timeadjust' value="<?php echo htmlspecialchars(str_replace(array('+', ' hours'), array('', ''), getGlobalSetting('timeadjust'))); ?> " /> <?php echo $clang->gT("Server time:") . ' ' . convertDateTimeFormat(date('Y-m-d H:i:s'), 'Y-m-d H:i:s', $dateformatdata['phpdate'] . ' H:i') . " - " . $clang->gT("Corrected time :") . ' ' . convertDateTimeFormat(dateShift(date("Y-m-d H:i:s"), 'Y-m-d H:i:s', getGlobalSetting('timeadjust')), 'Y-m-d H:i:s', $dateformatdata['phpdate'] . ' H:i'); ?> </span></li> <li><label for='iSessionExpirationTime'><?php $clang->eT("Session lifetime (seconds):"); ?> </label> <input type='text' size='10' id='iSessionExpirationTime' name='iSessionExpirationTime' value="<?php echo htmlspecialchars(getGlobalSetting('iSessionExpirationTime')); ?> " /></li> <li><label for='ipInfoDbAPIKey'><?php $clang->eT("IP Info DB API Key:"); ?> </label>
$fieldsarray["{SURVEYURL}"]="<a href='$publicurl/index.php?lang=".trim($emrow['language'])."&sid=$surveyid&token={$emrow['token']}'>".htmlspecialchars("$publicurl/index.php?lang=".trim($emrow['language'])."&sid=$surveyid&token={$emrow['token']}")."</a>"; $fieldsarray["@@SURVEYURL@@"]="$publicurl/index.php?lang=".trim($emrow['language'])."&sid=$surveyid&token={$emrow['token']}"; $_POST['message_'.$emrow['language']] = html_entity_decode($_POST['message_'.$emrow['language']], ENT_QUOTES, $emailcharset); } } $msgsubject=Replacefields($_POST['subject_'.$emrow['language']], $fieldsarray); $sendmessage=Replacefields($_POST['message_'.$emrow['language']], $fieldsarray); $customheaders = array( '1' => "X-surveyid: ".$surveyid, '2' => "X-tokenid: ".$fieldsarray["{TOKEN}"]); if (trim($emrow['validfrom'])!='' && convertDateTimeFormat($emrow['validfrom'],'Y-m-d H:i:s','U')*1>date('U')*1) { $tokenoutput .= $emrow['tid'] ." ".ReplaceFields($clang->gT("Email to {FIRSTNAME} {LASTNAME} ({EMAIL}) delayed: Token is not yet valid.")."<br />", $fieldsarray); } elseif (trim($emrow['validuntil'])!='' && convertDateTimeFormat($emrow['validuntil'],'Y-m-d H:i:s','U')*1<date('U')*1) { $tokenoutput .= $emrow['tid'] ." ".ReplaceFields($clang->gT("Email to {FIRSTNAME} {LASTNAME} ({EMAIL}) skipped: Token is not valid anymore.")."<br />", $fieldsarray); } elseif (SendEmailMessage($sendmessage, $msgsubject, $to, $from, $sitename,$ishtml,getBounceEmail($surveyid),null,$customheaders)) { // Put date into remindersent $today = date_shift(date("Y-m-d H:i:s"), "Y-m-d H:i", $timeadjust); $udequery = "UPDATE ".db_table_name("tokens_{$surveyid}")."\n" ."SET remindersent='$today',remindercount = remindercount+1 WHERE tid={$emrow['tid']}"; // $uderesult = $connect->Execute($udequery) or safe_die ("Could not update tokens<br />$udequery<br />".$connect->ErrorMsg()); //orig: $tokenoutput .= "({$emrow['tid']})[".$clang->gT("Reminder sent to:")." {$emrow['firstname']} {$emrow['lastname']}]<br />\n"; $tokenoutput .= "({$emrow['tid']}) [".$clang->gT("Reminder sent to:")." {$emrow['firstname']} {$emrow['lastname']} ($to)]<br />\n"; }
/** * 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); } } else { //There is nothing in the message or "Send confirmation emails" is set to "No" , so don't send a confirmation email //This section only here as placeholder to indicate new feature :-) } } } }
/** * * @param type $iSurveyID The Survey ID * @param type $sFieldCode Field code of the particular field * @param type $sValue The stored response value * @param object $oLanguage Initialized limesurvey_lang object for the resulting response data * @return string */ function getExtendedAnswer($iSurveyID, $sFieldCode, $sValue, $oLanguage) { if (is_null($sValue) || $sValue == '') { return ''; } $sLanguage = $oLanguage->langcode; //Fieldcode used to determine question, $sValue used to match against answer code //Returns NULL if question type does not suit if (strpos($sFieldCode, "{$iSurveyID}X") === 0) { $fieldmap = createFieldMap($iSurveyID, 'short', false, false, $sLanguage); if (isset($fieldmap[$sFieldCode])) { $fields = $fieldmap[$sFieldCode]; } else { return false; } //Find out the question type $this_type = $fields['type']; switch ($this_type) { case 'D': if (trim($sValue) != '') { $qidattributes = getQuestionAttributeValues($fields['qid']); $dateformatdetails = getDateFormatDataForQID($qidattributes, $iSurveyID); $sValue = convertDateTimeFormat($sValue, "Y-m-d H:i:s", $dateformatdetails['phpdate']); } break; case "L": case "!": case "O": case "^": case "I": case "R": $result = Answers::model()->getAnswerFromCode($fields['qid'], $sValue, $sLanguage) or die("Couldn't get answer type L - getAnswerCode()"); //Checked foreach ($result as $row) { $this_answer = $row['answer']; } // while if ($sValue == "-oth-") { $this_answer = $oLanguage->gT("Other"); } break; case "M": case "J": case "P": switch ($sValue) { case "Y": $this_answer = $oLanguage->gT("Yes"); break; } break; case "Y": switch ($sValue) { case "Y": $this_answer = $oLanguage->gT("Yes"); break; case "N": $this_answer = $oLanguage->gT("No"); break; default: $this_answer = $oLanguage->gT("No answer"); } break; case "G": switch ($sValue) { case "M": $this_answer = $oLanguage->gT("Male"); break; case "F": $this_answer = $oLanguage->gT("Female"); break; default: $this_answer = $oLanguage->gT("No answer"); } break; case "C": switch ($sValue) { case "Y": $this_answer = $oLanguage->gT("Yes"); break; case "N": $this_answer = $oLanguage->gT("No"); break; case "U": $this_answer = $oLanguage->gT("Uncertain"); break; } break; case "E": switch ($sValue) { case "I": $this_answer = $oLanguage->gT("Increase"); break; case "D": $this_answer = $oLanguage->gT("Decrease"); break; case "S": $this_answer = $oLanguage->gT("Same"); break; } break; case "F": case "H": case "1": $aConditions = array('qid' => $fields['qid'], 'code' => $sValue, 'language' => $sLanguage); if (isset($fields['scale_id'])) { $iScaleID = $fields['scale_id']; } else { $iScaleID = 0; } $result = Answers::model()->getAnswerFromCode($fields['qid'], $sValue, $sLanguage, $iScaleID) or die("Couldn't get answer type L - getAnswerCode()"); //Checked foreach ($result as $row) { $this_answer = $row['answer']; } // while $this_answer = $row['answer']; if ($sValue == "-oth-") { $this_answer = $oLanguage->gT("Other"); } break; case "|": //File upload if (substr($sFieldCode, -9) == 'filecount') { $this_answer = $oLanguage->gT("File count"); } else { //Show the filename, size, title and comment -- no link! $files = json_decode($sValue); $sValue = ''; if (is_array($files)) { foreach ($files as $file) { $sValue .= $file->name . ' (' . $file->size . 'KB) ' . strip_tags($file->title) . ' - ' . strip_tags($file->comment) . "<br/>"; } } } break; default: } // switch } switch ($sFieldCode) { case 'submitdate': if (trim($sValue) != '') { $dateformatdetails = getDateFormatDataForQID(array('date_format' => ''), $iSurveyID); $sValue = convertDateTimeFormat($sValue, "Y-m-d H:i:s", $dateformatdetails['phpdate'] . ' H:i:s'); } break; } if (isset($this_answer)) { return $this_answer . " [{$sValue}]"; } else { return $sValue; } }
function globalsettingsdisplay() { global $action, $connect, $js_admin_includes, $editsurvey, $subaction, $scriptname, $clang; global $updateversion, $updatebuild, $updateavailable, $updatelastcheck, $demoModeOnly; if (isset($subaction) && $subaction == "updatecheck") { $updateinfo=updatecheck(); } if (isset($action) && $action == "globalsettings") { if($_SESSION['USER_RIGHT_SUPERADMIN'] == 1) { $js_admin_includes[]='scripts/globalsettings.js'; // header $editsurvey = "<div class='header ui-widget-header'>".$clang->gT("Global settings")."</div>\n"; // beginning TABs section $editsurvey .= "\t<div id='tabs'> <ul> <li><a href='#overview'>".$clang->gT("Overview & update")."</a></li> <li><a href='#general'>".$clang->gT("General")."</a></li> <li><a href='#email'>".$clang->gT("Email settings")."</a></li> <li><a href='#bounce'>".$clang->gT("Bounce settings")."</a></li> <li><a href='#security'>".$clang->gT("Security")."</a></li> <li><a href='#presentation'>".$clang->gT("Presentation")."</a></li> </ul>\n"; $editsurvey .= "<form class='form30' id='frmglobalsettings' name='frmglobalsettings' action='$scriptname' method='post'>\n"; $editsurvey .= "<div id='overview'>\n"; $editsurvey .= checksettings(); $thisupdatecheckperiod=getGlobalSetting('updatecheckperiod'); $editsurvey .= "<br /></p><div class='header ui-widget-header'>".$clang->gT("Updates")."</div><ul>" . "\t<li><label for='updatecheckperiod'>".$clang->gT("Check for updates:")."</label>\n" . "\t\t\t<select name='updatecheckperiod' id='updatecheckperiod'>\n" . "\t\t\t\t<option value='0'"; if ($thisupdatecheckperiod==0) {$editsurvey .= " selected='selected'";} $editsurvey .=">".$clang->gT("Never")."</option>\n" . "\t\t\t\t<option value='1'"; if ($thisupdatecheckperiod==1) {$editsurvey .= " selected='selected'";} $editsurvey .=">".$clang->gT("Every day")."</option>\n" . "\t\t\t\t<option value='7'"; if ($thisupdatecheckperiod==7) {$editsurvey .= " selected='selected'";} $editsurvey .=">".$clang->gT("Every week")."</option>\n" . "<option value='14'"; if ($thisupdatecheckperiod==14) {$editsurvey .= " selected='selected'";} $editsurvey .=">".$clang->gT("Every 2 weeks")."</option>\n" . "<option value='30'"; if ($thisupdatecheckperiod==30) {$editsurvey .= " selected='selected'";} $editsurvey .=">".$clang->gT("Every month")."</option>\n" . "</select> <input type='button' onclick=\"window.open('$scriptname?action=globalsettings&subaction=updatecheck', '_top')\" value='".$clang->gT("Check now")."' /> <span id='lastupdatecheck'>".sprintf($clang->gT("Last check: %s"),$updatelastcheck)."</span></li></ul><p>\n"; if (isset($updateavailable) && $updateavailable==1) { $editsurvey .='<span style="font-weight: bold;">'.sprintf($clang->gT('There is a LimeSurvey update available: Version %s'),$updateversion."($updatebuild)").'</span><br />'; $editsurvey .=sprintf($clang->gT('You can update %smanually%s or use the %s'),"<a href='http://docs.limesurvey.org/tiki-index.php?page=Upgrading+from+a+previous+version'>","</a>","<a href='$scriptname?action=update'>".$clang->gT('3-Click ComfortUpdate').'</a>').'.<br />'; } elseif (isset($updateinfo['errorcode'])) { $editsurvey .=sprintf($clang->gT('There was an error on update check (%s)'),$updateinfo['errorcode']).'.<br />'; $editsurvey .="<textarea readonly='readonly' style='width:35%; height:60px; overflow: auto;'>".strip_tags($updateinfo['errorhtml']).'</textarea>'; } else { $editsurvey .=$clang->gT('There is currently no newer LimeSurvey version available.'); } $editsurvey .= "</p></div>"; // General TAB $editsurvey .= "\t<div id='general'>\n"; // Administrator... $editsurvey .= "<ul>" . "\t<li><label for='sitename'>".$clang->gT("Site name:").(($demoModeOnly==true)?'*':'')."</label>\n" . "\t\t<input type='text' size='50' id='sitename' name='sitename' value=\"".htmlspecialchars(getGlobalSetting('sitename'))."\" /></li>\n" . "\t<li><label for='defaultlang'>".$clang->gT("Default site language:").(($demoModeOnly==true)?'*':'')."</label>\n" . "\t\t<select name='defaultlang' id='defaultlang'>\n"; $actuallang=getGlobalSetting('defaultlang'); foreach (getLanguageData(true) as $langkey2=>$langname) { $editsurvey .= "\t\t\t<option value='".$langkey2."'"; if ($actuallang == $langkey2) {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$langname['nativedescription']." - ".$langname['description']."</option>\n"; } $editsurvey .= "\t\t</select></li>"; $thisdefaulttemplate=getGlobalSetting('defaulttemplate'); $templatenames=array_keys(gettemplatelist()); $editsurvey .= "" . "\t<li><label for='defaulttemplate'>".$clang->gT("Default template:")."</label>\n" . "\t\t\t<select name='defaulttemplate' id='defaulttemplate'>\n"; foreach ($templatenames as $templatename) { $editsurvey.= "\t\t\t\t<option value='$templatename'"; if ($thisdefaulttemplate==$templatename) {$editsurvey .= " selected='selected'";} $editsurvey .=">$templatename</option>\n"; } $editsurvey .="\t\t\t</select></li>\n"; $thisdefaulthtmleditormode=getGlobalSetting('defaulthtmleditormode'); $editsurvey .= "" . "\t<li><label for='defaulthtmleditormode'>".$clang->gT("Default HTML editor mode:").(($demoModeOnly==true)?'*':'')."</label>\n" . "\t\t\t<select name='defaulthtmleditormode' id='defaulthtmleditormode'>\n" . "\t\t\t\t<option value='default'"; if ($thisdefaulthtmleditormode=='default') {$editsurvey .= " selected='selected'";} $editsurvey .=">".$clang->gT("Default HTML editor mode")."</option>\n" . "\t\t\t\t<option value='none'"; if ($thisdefaulthtmleditormode=='none') {$editsurvey .= " selected='selected'";} $editsurvey .=">".$clang->gT("No HTML editor")."</option>\n" . "<option value='inline'"; if ($thisdefaulthtmleditormode=='inline') {$editsurvey .= " selected='selected'";} $editsurvey .=">".$clang->gT("Inline HTML editor")."</option>\n" . "<option value='popup'"; if ($thisdefaulthtmleditormode=='popup') {$editsurvey .= " selected='selected'";} $editsurvey .=">".$clang->gT("Popup HTML editor")."</option>\n" . "</select></li>\n"; $dateformatdata=getDateFormatData($_SESSION['dateformat']); $editsurvey.= "\t<li><label for='timeadjust'>".$clang->gT("Time difference (in hours):")."</label>\n" . "\t\t<span><input type='text' size='10' id='timeadjust' name='timeadjust' value=\"".htmlspecialchars(str_replace(array('+',' hours'),array('',''),getGlobalSetting('timeadjust')))."\" /> " . $clang->gT("Server time:").' '.convertDateTimeFormat(date('Y-m-d H:i:s'),'Y-m-d H:i:s',$dateformatdata['phpdate'].' H:i')." - ".$clang->gT("Corrected time :").' '.convertDateTimeFormat(date_shift(date("Y-m-d H:i:s"), 'Y-m-d H:i:s', getGlobalSetting('timeadjust')),'Y-m-d H:i:s',$dateformatdata['phpdate'].' H:i')." </span></li>\n"; $thisusepdfexport=getGlobalSetting('usepdfexport'); $editsurvey .= "\t<li><label for='usepdfexport'>".$clang->gT("PDF export available:")."</label>\n" . "<select name='usepdfexport' id='usepdfexport'>\n" . "<option value='1'"; if ( $thisusepdfexport == true) {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("On")."</option>\n" . "<option value='0'"; if ( $thisusepdfexport == false) {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("Off")."</option>\n" . "\t\t</select>\n\t</li>\n"; $thisaddTitleToLinks=getGlobalSetting('addTitleToLinks'); $editsurvey .= "\t<li><label for='addTitleToLinks'>".$clang->gT("Screen reader compatibility mode:")."</label>\n" . "<select name='addTitleToLinks' id='addTitleToLinks'>\n" . "<option value='1'"; if ( $thisaddTitleToLinks == true) {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("On")."</option>\n" . "<option value='0'"; if ( $thisaddTitleToLinks == false) {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("Off")."</option>\n" . "</select>\n</li>\n" . "<li><label for='sessionlifetime'>".$clang->gT("Session lifetime (seconds):")."</label>\n" . "<input type='text' size='10' id='sessionlifetime' name='sessionlifetime' value=\"".htmlspecialchars(getGlobalSetting('sessionlifetime'))."\" /></li>" . "<li><label for='ipInfoDbAPIKey'>".$clang->gT("IP Info DB API Key:")."</label>\n" . "<input type='text' size='35' id='ipInfoDbAPIKey' name='ipInfoDbAPIKey' value=\"".htmlspecialchars(getGlobalSetting('ipInfoDbAPIKey'))."\" /></li>" . "<li><label for='googleMapsAPIKey'>".$clang->gT("Google Maps API key:")."</label>\n" . "<input type='text' size='35' id='googleMapsAPIKey' name='googleMapsAPIKey' value=\"".htmlspecialchars(getGlobalSetting('googleMapsAPIKey'))."\" /></li>" ; // End General TAB $editsurvey .= "\t</ul></div>\n"; // Email TAB $editsurvey .= "\t<div id='email'><ul>\n"; //Format $editsurvey.= "\t<li><label for='siteadminemail'>".$clang->gT("Default site admin email:")."</label>\n" . "\t\t<input type='text' size='50' id='siteadminemail' name='siteadminemail' value=\"".htmlspecialchars(getGlobalSetting('siteadminemail'))."\" /></li>\n" . "\t<li><label for='siteadminname'>".$clang->gT("Administrator name:")."</label>\n" . "\t\t<input type='text' size='50' id='siteadminname' name='siteadminname' value=\"".htmlspecialchars(getGlobalSetting('siteadminname'))."\" /><br /><br /></li>\n" . "\t<li><label for='emailmethod'>".$clang->gT("Email method:")."</label>\n" . "\t\t<select id='emailmethod' name='emailmethod'>\n" . "\t\t\t<option value='mail'"; if (getGlobalSetting('emailmethod')=='mail') {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("PHP (default)")."</option>\n" . "\t\t\t<option value='smtp'"; if (getGlobalSetting('emailmethod')=='smtp') {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("SMTP")."</option>\n" . "\t\t\t<option value='sendmail'"; if (getGlobalSetting('emailmethod')=='sendmail') {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("Sendmail")."</option>\n" . "\t\t\t<option value='qmail'"; if (getGlobalSetting('emailmethod')=='qmail') {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("Qmail")."</option>\n" . "\t\t</select></li>\n" . "\t<li>\n\t\t<label for=\"emailsmtphost\">".$clang->gT("SMTP host:")."</label>\n" . "\t\t<input type='text' size='50' id='emailsmtphost' name='emailsmtphost' value=\"".htmlspecialchars(getGlobalSetting('emailsmtphost'))."\" /> <font size='1'>".$clang->gT("Enter your hostname and port, e.g.: my.smtp.com:25")."</font></li>\n" . "\t<li><label for='emailsmtpuser'>".$clang->gT("SMTP username:"******"</label>\n" . "\t\t<input type='text' size='50' id='emailsmtpuser' name='emailsmtpuser' value=\"".htmlspecialchars(getGlobalSetting('emailsmtpuser'))."\" /></li>\n" . "\t<li><label for='emailsmtppassword'>".$clang->gT("SMTP password:"******"</label>\n" . "\t\t<input type='password' size='50' id='emailsmtppassword' name='emailsmtppassword' value='somepassword' /></li>\n" . "\t<li><label for='emailsmtpssl'>".$clang->gT("SMTP SSL/TLS:")."</label>\n" . "\t\t<select id='emailsmtpssl' name='emailsmtpssl'>\n" . "\t\t\t<option value=''"; if (getGlobalSetting('emailsmtpssl')=='') {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("Off")."</option>\n" . "\t\t\t<option value='ssl'"; if (getGlobalSetting('emailsmtpssl')=='ssl' || getGlobalSetting('emailsmtpssl')==1) {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("SSL")."</option>\n" . "\t\t\t<option value='tls'"; if (getGlobalSetting('emailsmtpssl')=='tls') {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("TLS")."</option>\n" . "\t\t</select></li>\n" . "\t<li><label for='emailsmtpdebug'>".$clang->gT("SMTP debug mode:")."</label>\n" . "\t\t<select id='emailsmtpdebug' name='emailsmtpdebug'>\n" . "\t\t\t<option value=''"; if (getGlobalSetting('emailsmtpdebug')=='0') {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("Off")."</option>\n" . "\t\t\t<option value='1'"; if (getGlobalSetting('emailsmtpdebug')=='1' || getGlobalSetting('emailsmtpssl')==1) {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("On errors")."</option>\n" . "\t\t\t<option value='2'"; if (getGlobalSetting('emailsmtpdebug')=='2' || getGlobalSetting('emailsmtpssl')==1) {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("Always")."</option>\n" . "\t\t</select><br /> </li>\n" . "\t<li><label for='maxemails'>".$clang->gT("Email batch size:")."</label>\n" . "\t\t<input type='text' size='5' id='maxemails' name='maxemails' value=\"".htmlspecialchars(getGlobalSetting('maxemails'))."\" /></li>\n" . "\t</ul>\n"; // End Email TAB $editsurvey .= "\t</div>\n"; // Start bounce tab $editsurvey .= "\t<div id='bounce'><ul>\n" . "\t<li><label for='siteadminbounce'>".$clang->gT("Default site bounce email:")."</label>\n" . "\t\t<input type='text' size='50' id='siteadminbounce' name='siteadminbounce' value=\"".htmlspecialchars(getGlobalSetting('siteadminbounce'))."\" /></li>\n" . "\t<li><label for='bounceaccounttype'>".$clang->gT("Server type:")."</label>\n" . "\t\t<select id='bounceaccounttype' name='bounceaccounttype'>\n" . "\t\t\t<option value='off'"; if (getGlobalSetting('bounceaccounttype')=='off') {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("Off")."</option>\n" . "\t\t\t<option value='IMAP'"; if (getGlobalSetting('bounceaccounttype')=='IMAP') {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("IMAP")."</option>\n" . "\t\t\t<option value='POP'"; if (getGlobalSetting('bounceaccounttype')=='POP') {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("POP")."</option>\n" ."\t\t</select></li>\n" . "\t<li><label for='bounceaccounthost'>".$clang->gT("Server name & port:")."</label>\n" . "\t\t<input type='text' size='50' id='bounceaccounthost' name='bounceaccounthost' value=\"".htmlspecialchars(getGlobalSetting('bounceaccounthost'))."\" />\n"."<font size='1'>".$clang->gT("Enter your hostname and port, e.g.: imap.gmail.com:995")."</font>\n" . "\t<li><label for='bounceaccountuser'>".$clang->gT("User name:")."</label>\n" . "\t\t<input type='text' size='50' id='bounceaccountuser' name='bounceaccountuser' value=\"".htmlspecialchars(getGlobalSetting('bounceaccountuser'))."\" /></li>\n" . "\t<li><label for='bounceaccountpass'>".$clang->gT("Password:"******"</label>\n" . "\t\t<input type='password' size='50' id='bounceaccountpass' name='bounceaccountpass' value='enteredpassword' /></li>\n"; $editsurvey.= "\t<li><label for='bounceencryption'>".$clang->gT("Encryption type:")."</label>\n" . "\t\t<select id='bounceencryption' name='bounceencryption'>\n" . "\t\t\t<option value='off'"; if (getGlobalSetting('bounceencryption')=='off') {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("Off")."</option>\n" . "\t\t\t<option value='SSL'"; if (getGlobalSetting('bounceencryption')=='SSL') {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("SSL")."</option>\n" . "\t\t\t<option value='TLS'"; if (getGlobalSetting('bounceencryption')=='TLS') {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("TLS")."</option>\n" ."\t\t</select></li>\n</ul>"; $editsurvey .= "\t</div>\n"; // End of bounce tabs // Security Settings $editsurvey .= "\t<div id='security'><ul>\n"; // Expiration $thissurveyPreview_require_Auth=getGlobalSetting('surveyPreview_require_Auth'); $editsurvey .= "\t<li><label for='surveyPreview_require_Auth'>".$clang->gT("Survey preview only for administration users")."</label>\n" . "\t\t<select id='surveyPreview_require_Auth' name='surveyPreview_require_Auth'>\n" . "\t\t\t<option value='1'"; if ($thissurveyPreview_require_Auth == true) {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("Yes")."</option>\n" . "\t\t\t<option value='0'"; if ($thissurveyPreview_require_Auth == false) {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("No")."</option>\n" . "\t\t</select></li>\n"; // Auto registration $thisfilterxsshtml=getGlobalSetting('filterxsshtml'); $editsurvey .= "\t<li><label for='filterxsshtml'>".$clang->gT("Filter HTML for XSS:").(($demoModeOnly==true)?'*':'')."</label>\n" . "\t\t<select id='filterxsshtml' name='filterxsshtml'>\n" . "\t\t\t<option value='1'"; if ( $thisfilterxsshtml == true) {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("Yes")."</option>\n" . "\t\t\t<option value='0'"; if ( $thisfilterxsshtml == false) {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("No")."</option>\n" . "\t\t</select></li>\n"; $thisusercontrolSameGroupPolicy=getGlobalSetting('usercontrolSameGroupPolicy'); $editsurvey .= "\t<li><label for='usercontrolSameGroupPolicy'>".$clang->gT("Group member can only see own group:")."</label>\n" . "\t\t<select id='usercontrolSameGroupPolicy' name='usercontrolSameGroupPolicy'>\n" . "\t\t\t<option value='1'"; if ( $thisusercontrolSameGroupPolicy == true) {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("Yes")."</option>\n" . "\t\t\t<option value='0'"; if ( $thisusercontrolSameGroupPolicy == false) {$editsurvey .= " selected='selected'";} $editsurvey .= ">".$clang->gT("No")."</option>\n" . "\t\t</select></li>\n"; $thisforce_ssl = getGlobalSetting('force_ssl'); $opt_force_ssl_on = $opt_force_ssl_off = $opt_force_ssl_neither = ''; $warning_force_ssl = $clang->gT('Warning: Before turning on HTTPS, ') . '<a href="https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'"title="' . $clang->gT('Test if your server has SSL enabled by clicking on this link.').'">' . $clang->gT('check if this link works.').'</a><br/> ' . $clang->gT("If the link does not work and you turn on HTTPS, LimeSurvey will break and you won't be able to access it."); // $warning_force_ssl = ' Do <strong>NOT</strong> force "On" if you\'re <strong>not completely certain</strong> your server has a SSL enabled. <br />' // . 'Before turning on HTTPS, <a href="https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'">See if this link works</a><br />' // . 'If not, <strong>LimeSurvey will break</strong> if SSL is forced on but your server does not have a valid secure certificate installed and enabled.<br />'; switch($thisforce_ssl) { case 'on': $warning_force_ssl = ' '; break; case 'off': case 'neither': break; default: $thisforce_ssl = 'neither'; }; $this_opt = 'opt_force_ssl_'.$thisforce_ssl; $$this_opt = ' selected="selected"'; $editsurvey .= '<li><label for="force_ssl">'.$clang->gT('Force HTTPS:')."</label>\n" . "<select name=\"force_ssl\" id=\"force_ssl\">\n\t" . '<option value="on" '.$opt_force_ssl_on.'>'.$clang->gT('On')."</option>\n\t" . '<option value="off" '.$opt_force_ssl_off.'>'.$clang->gT('Off')."</option>\n\t" . '<option value="neither" '.$opt_force_ssl_neither.'>'.$clang->gT('Don\'t force on or off')."</option>\n\t" . "</select></li>\n" . "<li><span style='font-size:0.7em;'>$warning_force_ssl\n</span></li>\n"; unset($thisforce_ssl,$opt_force_ssl_on,$opt_force_ssl_off,$opt_force_ssl_neither,$warning_force_ssl,$this_opt); $editsurvey .= "\t</ul></div>\n"; // presentation settings tab $editsurvey .= "\t<div id='presentation'><ul>\n"; // shownoanswer $shownoanswer=getGlobalSetting('shownoanswer'); $sel_na = array( 0 => '' , 1 => '' , 2 => ''); $sel_na[$shownoanswer] = ' selected="selected"'; $editsurvey .= "\t<li><label for='shownoanswer'>".$clang->gT("Show 'no answer' option for non-mandatory questions:")."</label>\n" . "\t\t<select id='shownoanswer' name='shownoanswer'>\n" . "\t\t\t<option value=\"1\"{$sel_na[1]}>".$clang->gT('Yes')."</option>\n" . "\t\t\t<option value=\"0\"{$sel_na[0]}>".$clang->gT('No')."</option>\n" . "\t\t\t<option value=\"2\"{$sel_na[2]}>".$clang->gT('Survey admin can choose')."</option>\n" . "\t\t</select></li>\n"; $thisrepeatheadings=getGlobalSetting('repeatheadings'); $editsurvey .= "\t<li><label for='repeatheadings'>".$clang->gT("Repeating headings in array questions every X subquestions:")."</label>\n" . "\t\t<input id='repeatheadings' name='repeatheadings' value='$thisrepeatheadings' size='4' maxlength='4' /></li>\n"; // showXquestions $set_xq=getGlobalSetting('showXquestions'); $sel_xq = array( 'hide' => '' , 'show' => '' , 'choose' => ''); $sel_xq[$set_xq] = ' selected="selected"'; if( empty($sel_xq['hide']) && empty($sel_xq['show']) && empty($sel_xq['choose'])) { $sel_xq['choose'] = ' selected="selected"'; }; $editsurvey .= "\t<li><label for=\"showXquestions\">".$clang->gT('Show "There are X questions in this survey"')."</label>\n" . "\t\t<select id=\"showXquestions\" name=\"showXquestions\">\n" . "\t\t\t<option value=\"show\"{$sel_xq['show']}>".$clang->gT('Yes')."</option>\n" . "\t\t\t<option value=\"hide\"{$sel_xq['hide']}>".$clang->gT('No')."</option>\n" . "\t\t\t<option value=\"choose\"{$sel_xq['choose']}>".$clang->gT('Survey admin can choose')."</option>\n" . "\t\t</select></li>\n"; unset($set_xq,$sel_xq); // showgroupinfo $set_gri=getGlobalSetting('showgroupinfo'); $sel_gri = array( 'both' => '' , 'choose' =>'' , 'description' => '' , 'name' => '' , 'none' => '' ); $sel_gri[$set_gri] = ' selected="selected"'; if( empty($sel_gri['both']) && empty($sel_gri['choose']) && empty($sel_gri['description']) && empty($sel_gri['name']) && empty($sel_gri['none'])) { $sel_gri['choose'] = ' selected="selected"'; }; $editsurvey .= "\t<li><label for=\"showgroupinfo\">".$clang->gT('Show question group name and/or description')."</label>\n" . "\t\t<select id=\"showgroupinfo\" name=\"showgroupinfo\">\n" . "\t\t\t<option value=\"both\"{$sel_gri['both']}>".$clang->gT('Show both')."</option>\n" . "\t\t\t<option value=\"name\"{$sel_gri['name']}>".$clang->gT('Show group name only')."</option>\n" . "\t\t\t<option value=\"description\"{$sel_gri['description']}>".$clang->gT('Show group description only')."</option>\n" . "\t\t\t<option value=\"none\"{$sel_gri['none']}>".$clang->gT('Hide both')."</option>\n" . "\t\t\t<option value=\"choose\"{$sel_gri['choose']}>".$clang->gT('Survey admin can choose')."</option>\n" . "\t\t</select></li>\n"; unset($set_gri,$sel_gri); // showqnumcode $set_qnc=getGlobalSetting('showqnumcode'); $sel_qnc = array( 'both' => '' , 'choose' =>'' , 'number' => '' , 'code' => '' , 'none' => '' ); $sel_qnc[$set_qnc] = ' selected="selected"'; if( empty($sel_qnc['both']) && empty($sel_qnc['choose']) && empty($sel_qnc['number']) && empty($sel_qnc['code']) && empty($sel_qnc['none'])) { $sel_qnc['choose'] = ' selected="selected"'; }; $editsurvey .= "\t<li><label for=\"showqnumcode\">".$clang->gT('Show question number and/or question code')."</label>\n" . "\t\t<select id=\"showqnumcode\" name=\"showqnumcode\">\n" . "\t\t\t<option value=\"both\"{$sel_qnc['both']}>".$clang->gT('Show both')."</option>\n" . "\t\t\t<option value=\"number\"{$sel_qnc['number']}>".$clang->gT('Show question number only')."</option>\n" . "\t\t\t<option value=\"code\"{$sel_qnc['code']}>".$clang->gT('Show question code only')."</option>\n" . "\t\t\t<option value=\"none\"{$sel_qnc['none']}>".$clang->gT('Hide both')."</option>\n" . "\t\t\t<option value=\"choose\"{$sel_qnc['choose']}>".$clang->gT('Survey admin can choose')."</option>\n" . "\t\t</select></li>\n"; unset($set_qnc,$sel_qnc); $editsurvey .= "\t</ul>\n"; // End TAB page & form $editsurvey .= "\t</div><input type='hidden' name='action' value='globalsettingssave'/></form>\n"; // End tabs $editsurvey .= "</div>\n"; // The external button to sumbit Survey edit changes $editsurvey .= "\t<p><input type='button' onclick='$(\"#frmglobalsettings\").submit();' class='standardbtn' value='".$clang->gT("Save settings")."' /><br /></p>\n"; if ($demoModeOnly==true) { $editsurvey .= '<p>'.$clang->gT("Note: Demo mode is activated. Marked (*) settings can't be changed.").'</p>\n'; } } else { include("access_denied.php"); } } }
public function getCreationDate() { $dateformatdata = getDateFormatData(Yii::app()->session['dateformat']); return convertDateTimeFormat($this->datecreated, 'Y-m-d', $dateformatdata['phpdate']); }
/** * 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 :-) } } } }
/** * 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(); $aEmailaddresses = explode(';', $emrow['email']); foreach ($aEmailaddresses as $sEmailaddress) { $to[] = $emrow['firstname'] . " " . $emrow['lastname'] . " <{$sEmailaddress}>"; } $fieldsarray["{EMAIL}"] = $emrow['email']; $fieldsarray["{FIRSTNAME}"] = $emrow['firstname']; $fieldsarray["{LASTNAME}"] = $emrow['lastname']; $fieldsarray["{TOKEN}"] = $emrow['token']; $fieldsarray["{LANGUAGE}"] = $emrow['language']; foreach ($attributes as $attributefield => $attributedescription) { $fieldsarray['{' . strtoupper($attributefield) . '}'] = $emrow[$attributefield]; $fieldsarray['{TOKEN:' . strtoupper($attributefield) . '}'] = $emrow[$attributefield]; } $emrow['language'] = trim($emrow['language']); $found = array_search($emrow['language'], $aSurveyLangs); if ($emrow['language'] == '' || $found == false) { $emrow['language'] = $sBaseLanguage; } $from = Yii::app()->request->getPost('from_' . $emrow['language']); $fieldsarray["{OPTOUTURL}"] = $this->getController()->createAbsoluteUrl("/optout/tokens/langcode/" . trim($emrow['language']) . "/surveyid/{$iSurveyId}/token/{$emrow['token']}"); $fieldsarray["{OPTINURL}"] = $this->getController()->createAbsoluteUrl("/optin/tokens/langcode/" . trim($emrow['language']) . "/surveyid/{$iSurveyId}/token/{$emrow['token']}"); $fieldsarray["{SURVEYURL}"] = $this->getController()->createAbsoluteUrl("/survey/index/sid/{$iSurveyId}/token/{$emrow['token']}/langcode/" . trim($emrow['language']) . "/"); foreach (array('OPTOUT', 'OPTIN', 'SURVEY') as $key) { $url = $fieldsarray["{{$key}URL}"]; if ($bHtml) { $fieldsarray["{{$key}URL}"] = "<a href='{$url}'>" . htmlspecialchars($url) . '</a>'; } if ($key == 'SURVEY') { $barebone_link = $url; } } $customheaders = array('1' => "X-surveyid: " . $iSurveyId, '2' => "X-tokenid: " . $fieldsarray["{TOKEN}"]); global $maildebug; $modsubject = Replacefields(Yii::app()->request->getPost('subject_' . $emrow['language']), $fieldsarray); $modmessage = Replacefields(Yii::app()->request->getPost('message_' . $emrow['language']), $fieldsarray); if (isset($barebone_link)) { $modsubject = str_replace("@@SURVEYURL@@", $barebone_link, $modsubject); $modmessage = str_replace("@@SURVEYURL@@", $barebone_link, $modmessage); } if (trim($emrow['validfrom']) != '' && convertDateTimeFormat($emrow['validfrom'], 'Y-m-d H:i:s', 'U') * 1 > date('U') * 1) { $tokenoutput .= $emrow['tid'] . " " . ReplaceFields($clang->gT("Email to {FIRSTNAME} {LASTNAME} ({EMAIL}) delayed: Token is not yet valid.") . "<br />", $fieldsarray); } elseif (trim($emrow['validuntil']) != '' && convertDateTimeFormat($emrow['validuntil'], 'Y-m-d H:i:s', 'U') * 1 < date('U') * 1) { $tokenoutput .= $emrow['tid'] . " " . ReplaceFields($clang->gT("Email to {FIRSTNAME} {LASTNAME} ({EMAIL}) skipped: Token is not valid anymore.") . "<br />", $fieldsarray); } else { if (SendEmailMessage($modmessage, $modsubject, $to, $from, Yii::app()->getConfig("sitename"), $bHtml, getBounceEmail($iSurveyId), null, $customheaders)) { // Put date into sent $udequery = Tokens_dynamic::model($iSurveyId)->findByPk($emrow['tid']); if ($bEmail) { $tokenoutput .= $clang->gT("Invitation sent to:"); $udequery->sent = dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i", Yii::app()->getConfig("timeadjust")); } else { $tokenoutput .= $clang->gT("Reminder sent to:"); $udequery->remindersent = dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i", Yii::app()->getConfig("timeadjust")); $udequery->remindercount = $udequery->remindercount + 1; } $udequery->save(); //Update central participant survey_links if (!empty($emrow['participant_id'])) { $slquery = Survey_links::model()->find('participant_id = "' . $emrow['participant_id'] . '" AND survey_id = ' . $iSurveyId . ' AND token_id = ' . $emrow['tid']); $slquery->date_invited = dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i", Yii::app()->getConfig("timeadjust")); $slquery->save(); } $tokenoutput .= "{$emrow['tid']}: {$emrow['firstname']} {$emrow['lastname']} ({$emrow['email']})<br />\n"; if (Yii::app()->getConfig("emailsmtpdebug") == 2) { $tokenoutput .= $maildebug; } } else { $tokenoutput .= ReplaceFields($clang->gT("Email to {FIRSTNAME} {LASTNAME} ({EMAIL}) failed. Error Message:") . " " . $maildebug . "<br />", $fieldsarray); } } unset($fieldsarray); } $aViewUrls = array('tokenbar', 'emailpost'); $aData['tokenoutput'] = $tokenoutput; if ($ctcount > $emcount) { $i = 0; if (isset($aTokenIds)) { while ($i < $iMaxEmails) { array_shift($aTokenIds); $i++; } $aData['tids'] = implode('|', $aTokenIds); } $aData['lefttosend'] = $ctcount - $iMaxEmails; $aViewUrls[] = 'emailwarning'; } $this->_renderWrappedTemplate('token', $aViewUrls, $aData); } else { $this->_renderWrappedTemplate('token', array('tokenbar', 'message' => array('title' => $clang->gT("Warning"), 'message' => $clang->gT("There were no eligible emails to send. This will be because none satisfied the criteria of:") . "<br/> <ul><li>" . $clang->gT("having a valid email address") . "</li>" . "<li>" . $clang->gT("not having been sent an invitation already") . "</li>" . "<li>" . $clang->gT("having already completed the survey") . "</li>" . "<li>" . $clang->gT("having a token") . "</li></ul>")), $aData); } } }
$aSettingsUpdate['updateavailable'] = array('type' => 'info', 'label' => sprintf(gT('There was an error on update check (%s)'), $updateinfo['errorcode']), 'content' => CHtml::tag('pre', array(), strip_tags($updateinfo['errorhtml']))); } elseif ($updatable) { $aSettingsUpdate['updateavailable'] = array('type' => 'info', 'content' => gT('There is currently no newer LimeSurvey version available.')); } else { $aSettingsUpdate['updateavailable'] = array('type' => 'info', 'content' => sprintf(gT('This is an unstable version and cannot be updated using ComfortUpdate. Please check %s regularly for a newer version.'), CHtml::link(gT("our website"), "http://www.limesurvey.org"))); } $this->widget('ext.SettingsWidget.SettingsWidget', array('title' => gt("Updates"), 'form' => false, 'formHtmlOptions' => array('class' => 'form-core'), 'inlist' => true, 'settings' => $aSettingsUpdate)); ?> </div> <?php // General seetings in one part // Preparing array $aTemplateNames = array_keys(getTemplateList()); $aAdminThemes = array_keys(getAdminThemeList()); $dateformatdata = getDateFormatData(Yii::app()->session['dateformat']); $aGeneralSettings = array('info_general' => array(), 'sitename' => array('type' => 'string', 'label' => gT("Site name") . $sStringDemoMode, 'labelOptions' => array('class' => $sClassDemoMode), 'current' => getGlobalSetting('sitename'), 'htmlOptions' => array('readonly' => $bDemoMode)), 'defaulttemplate' => array('type' => 'select', 'label' => gT('Default template') . $sStringDemoMode, 'labelOptions' => array('class' => $sClassDemoMode), 'htmlOptions' => array('readonly' => $bDemoMode), 'options' => array_combine($aTemplateNames, $aTemplateNames), 'current' => Template::templateNameFilter(getGlobalSetting('defaulttemplate'))), 'admintheme' => array('type' => 'select', 'label' => gT('Administration template') . $sStringDemoMode, 'labelOptions' => array('class' => $sClassDemoMode), 'htmlOptions' => array('readonly' => $bDemoMode), 'options' => array_combine($aAdminThemes, $aAdminThemes), 'current' => getGlobalSetting('admintheme')), 'defaulthtmleditormode' => array('type' => 'select', 'label' => gT('Default HTML editor mode') . $sStringDemoMode, 'labelOptions' => array('class' => $sClassDemoMode), 'htmlOptions' => array('readonly' => $bDemoMode), 'options' => array('none' => gT("No HTML editor", 'unescaped'), 'inline' => gT("Inline HTML editor (default)", 'unescaped'), 'popup' => gT("Popup HTML editor", 'unescaped')), 'current' => getGlobalSetting('defaulthtmleditormode')), 'defaultquestionselectormode' => array('type' => 'select', 'label' => gT('Question type selector') . $sStringDemoMode, 'labelOptions' => array('class' => $sClassDemoMode), 'htmlOptions' => array('readonly' => $bDemoMode), 'options' => array('default' => gT("Full selector (default)", 'unescaped'), 'none' => gT("Simple selector", 'unescaped')), 'current' => getGlobalSetting('defaultquestionselectormode')), 'defaulttemplateeditormode' => array('type' => 'select', 'label' => gT('Template editor') . $sStringDemoMode, 'labelOptions' => array('class' => $sClassDemoMode), 'htmlOptions' => array('readonly' => $bDemoMode), 'options' => array('default' => gT("Full template editor (default)", 'unescaped'), 'none' => gT("Simple template editor", 'unescaped')), 'current' => getGlobalSetting('defaulttemplateeditormode')), 'timeadjust' => array('type' => 'float', 'label' => gt("Time difference (in hours)"), 'current' => str_replace(array('+', ' hours', ' minutes'), array('', '', ''), getGlobalSetting('timeadjust')) / 60, 'help' => sprintf(gT("Server time: %s - Corrected time: %s"), convertDateTimeFormat(date('Y-m-d H:i:s'), 'Y-m-d H:i:s', $dateformatdata['phpdate'] . ' H:i'), convertDateTimeFormat(dateShift(date("Y-m-d H:i:s"), 'Y-m-d H:i:s', getGlobalSetting('timeadjust')), 'Y-m-d H:i:s', $dateformatdata['phpdate'] . ' H:i'))), 'iSessionExpirationTime' => array(), 'GeoNamesUsername' => array('type' => 'string', 'label' => 'GeoNames username for API', 'current' => getGlobalSetting('GeoNamesUsername'), 'htmlOptions' => array('size' => '35')), 'googleMapsAPIKey' => array('type' => 'string', 'label' => 'Google Maps API key', 'current' => getGlobalSetting('googleMapsAPIKey'), 'htmlOptions' => array('size' => '35')), 'ipInfoDbAPIKey' => array('type' => 'string', 'label' => 'IP Info DB API Key', 'current' => getGlobalSetting('ipInfoDbAPIKey'), 'htmlOptions' => array('size' => '35')), 'googleanalyticsapikey' => array('type' => 'string', 'label' => 'Google Analytics API key', 'current' => getGlobalSetting('googleanalyticsapikey'), 'htmlOptions' => array('size' => '35')), 'googletranslateapikey' => array('type' => 'string', 'label' => 'Google Translate API key', 'current' => getGlobalSetting('googletranslateapikey'), 'htmlOptions' => array('size' => '35'))); if (isset(Yii::app()->session->connectionID)) { $aGeneralSettings["iSessionExpirationTime"] = array('type' => 'int', 'label' => 'Session lifetime for surveys (seconds)', 'current' => getGlobalSetting('iSessionExpirationTime'), 'htmlOptions' => array('style' => 'width:10em', 'min' => 1)); } if ($bDemoMode) { $aGeneralSettings['info_general'] = array('type' => 'info', 'class' => 'alert', 'label' => gt("Note"), 'content' => gt("Demo mode is activated. Some settings can't be changed.")); } $this->widget('ext.SettingsWidget.SettingsWidget', array('id' => 'general', 'form' => false, 'formHtmlOptions' => array('class' => 'form-core'), 'inlist' => true, 'settings' => $aGeneralSettings)); ?> <div id='email'> <?php // Email in 2 part : User and SMTP $this->widget('ext.SettingsWidget.SettingsWidget', array('form' => false, 'formHtmlOptions' => array('class' => 'form-core'), 'inlist' => true, 'settings' => array('siteadminemail' => array('type' => 'email', 'label' => gt("Default site admin email"), 'current' => getGlobalSetting('siteadminemail'), 'htmlOptions' => array('size' => '50')), 'siteadminname' => array('type' => 'string', 'label' => gt("Administrator name"), 'current' => getGlobalSetting('siteadminname'), 'htmlOptions' => array('size' => '50'))))); $this->widget('ext.SettingsWidget.SettingsWidget', array('title' => gt("SMTP configuration"), 'form' => false, 'formHtmlOptions' => array('class' => 'form-core'), 'inlist' => true, 'settings' => array('emailmethod' => array('type' => 'select', 'label' => gt("Email method"), 'options' => array('mail' => gT("PHP (default)", 'unescaped'), 'smtp' => gT("SMTP", 'unescaped'), 'sendmail' => gT("Sendmail", 'unescaped'), 'qmail' => gT("Qmail", 'unescaped')), 'current' => getGlobalSetting('emailmethod')), 'emailsmtphost' => array('type' => 'string', 'class' => array('smtp-on'), 'label' => gt("SMTP host"), 'current' => getGlobalSetting('emailsmtphost'), 'htmlOptions' => array('size' => '50'), 'help' => gT("Enter your hostname and port, e.g.: my.smtp.com:25")), 'emailsmtpuser' => array('type' => 'string', 'class' => array('smtp-on'), 'label' => gt("SMTP username"), 'current' => getGlobalSetting('emailsmtpuser'), 'htmlOptions' => array('size' => '50')), 'emailsmtppassword' => array('type' => 'password', 'class' => array('smtp-on'), 'label' => gt("SMTP password"), 'current' => getGlobalSetting('emailsmtppassword'), 'htmlOptions' => array('size' => '50')), 'emailsmtpssl' => array('type' => 'select', 'class' => array('smtp-on'), 'label' => gt("SMTP SSL/TLS"), 'options' => array('' => gT("Off", 'unescaped'), 'ssl' => gT("SSL", 'unescaped'), 'tls' => gT("TLS", 'unescaped')), 'current' => getGlobalSetting('emailsmtpssl'), 'htmlOptions' => array('size' => '50')), 'emailsmtpdebug' => array('type' => 'select', 'label' => gt("SMTP debug mode"), 'options' => array('0' => gT("Off", 'unescaped'), '1' => gT("On errors", 'unescaped'), '2' => gT("Always", 'unescaped')), 'current' => getGlobalSetting('emailsmtpdebug'), 'htmlOptions' => array('size' => '50')), 'maxemails' => array('type' => 'int', 'label' => gt("Email batch size"), 'current' => getGlobalSetting('maxemails'), 'htmlOptions' => array('min' => '1', 'style' => 'width:5em'))))); ?>
'class'=>$sClassDemoMode, ), 'htmlOptions'=>array( 'readonly'=>$bDemoMode, ), 'options'=>array( 'default'=>gT("Full template editor (default)",'unescaped'), 'none'=>gT("Simple template editor",'unescaped'), ), 'current'=>getGlobalSetting('defaulttemplateeditormode'), ), 'timeadjust'=>array( 'type'=>'float', 'label'=>gt("Time difference (in hours)"), 'current'=>str_replace(array('+',' hours',' minutes'),array('','',''),getGlobalSetting('timeadjust'))/60, 'help'=>sprintf(gT("Server time: %s - Corrected time: %s"),convertDateTimeFormat(date('Y-m-d H:i:s'),'Y-m-d H:i:s',$dateformatdata['phpdate'].' H:i'),convertDateTimeFormat(dateShift(date("Y-m-d H:i:s"), 'Y-m-d H:i:s', getGlobalSetting('timeadjust')),'Y-m-d H:i:s',$dateformatdata['phpdate'].' H:i')) ), 'iSessionExpirationTime'=>array( // A place to put iSessionExpirationTime if needed ), 'GeoNamesUsername'=>array( 'type'=>'string', 'label'=>'GeoNames username for API', 'current'=>getGlobalSetting('GeoNamesUsername'), 'htmlOptions'=>array( 'size'=>'35', ) ), 'googleMapsAPIKey'=>array( 'type'=>'string', 'label'=>'Google Maps API key',
function globalsettingsdisplay() { global $action, $connect, $js_admin_includes, $editsurvey, $subaction, $scriptname, $clang; global $updateversion, $updatebuild, $updateavailable, $updatelastcheck, $demoModeOnly; if (isset($subaction) && $subaction == "updatecheck") { $updateinfo = updatecheck(); } if (isset($action) && $action == "globalsettings") { if ($_SESSION['USER_RIGHT_SUPERADMIN'] == 1) { $js_admin_includes[] = 'scripts/globalsettings.js'; // header $editsurvey = "<div class='header'>" . $clang->gT("Global settings") . "</div>\n"; // beginning TABs section $editsurvey .= "\t<div class='tab-pane' id='tab-pane-globalsettings'>\n"; $editsurvey .= "<form id='frmglobalsettings' name='frmglobalsettings' action='{$scriptname}' method='post'>\n"; $editsurvey .= "\t<div class='tab-page'> <h2 class='tab'>" . $clang->gT("Overview & Update") . "</h2>\n"; $editsurvey .= checksettings(); $thisupdatecheckperiod = getGlobalSetting('updatecheckperiod'); $editsurvey .= "<br /></p><div class='header'>" . $clang->gT("Updates") . "</div><ul>" . "\t<li><label for='updatecheckperiod'>" . $clang->gT("Check for updates:") . "</label>\n" . "\t\t\t<select name='updatecheckperiod' id='updatecheckperiod'>\n" . "\t\t\t\t<option value='0'"; if ($thisupdatecheckperiod == 0) { $editsurvey .= " selected='selected'"; } $editsurvey .= ">" . $clang->gT("Never") . "</option>\n" . "\t\t\t\t<option value='1'"; if ($thisupdatecheckperiod == 1) { $editsurvey .= " selected='selected'"; } $editsurvey .= ">" . $clang->gT("Every day") . "</option>\n" . "\t\t\t\t<option value='7'"; if ($thisupdatecheckperiod == 7) { $editsurvey .= " selected='selected'"; } $editsurvey .= ">" . $clang->gT("Every week") . "</option>\n" . "<option value='14'"; if ($thisupdatecheckperiod == 14) { $editsurvey .= " selected='selected'"; } $editsurvey .= ">" . $clang->gT("Every 2 weeks") . "</option>\n" . "<option value='30'"; if ($thisupdatecheckperiod == 30) { $editsurvey .= " selected='selected'"; } $editsurvey .= ">" . $clang->gT("Every month") . "</option>\n" . "</select> <input type='button' onclick=\"window.open('{$scriptname}?action=globalsettings&subaction=updatecheck', '_top')\" value='" . $clang->gT("Check now") . "' /> <span id='lastupdatecheck'>" . sprintf($clang->gT("Last check: %s"), $updatelastcheck) . "</span></li></ul><p>\n"; if (isset($updateavailable) && $updateavailable == 1) { $editsurvey .= '<span style="font-weight: bold;">' . sprintf($clang->gT('There is a LimeSurvey update available: Version %s'), $updateversion . "({$updatebuild})") . '</span><br />'; $editsurvey .= sprintf($clang->gT('You can update %smanually%s or use the %s'), "<a href='http://docs.limesurvey.org/tiki-index.php?page=Upgrading+from+a+previous+version'>", "</a>", "<a href='{$scriptname}?action=update'>" . $clang->gT('3-Click ComfortUpdate') . '</a>') . '.<br />'; } elseif (isset($updateinfo['errorcode'])) { $editsurvey .= sprintf($clang->gT('There was an error on update check (%s)'), $updateinfo['errorcode']) . '.<br />'; $editsurvey .= "<textarea readonly='readonly' style='width:35%; height:60px; overflow: auto;'>" . strip_tags($updateinfo['errorhtml']) . '</textarea>'; } else { $editsurvey .= $clang->gT('There is currently no newer LimeSurvey version available.'); } $editsurvey .= "</p></div>"; // General TAB $editsurvey .= "\t<div class='tab-page'> <h2 class='tab'>" . $clang->gT("General") . "</h2>\n"; // Administrator... $editsurvey .= "<ul>" . "\t<li><label for='sitename'>" . $clang->gT("Site name:") . ($demoModeOnly == true ? '*' : '') . "</label>\n" . "\t\t<input type='text' size='50' id='sitename' name='sitename' value=\"" . htmlspecialchars(getGlobalSetting('sitename')) . "\" /></li>\n" . "\t<li><label for='defaultlang'>" . $clang->gT("Default site language:") . ($demoModeOnly == true ? '*' : '') . "</label>\n" . "\t\t<select name='defaultlang' id='defaultlang'>\n"; $actuallang = getGlobalSetting('defaultlang'); foreach (getLanguageData(true) as $langkey2 => $langname) { $editsurvey .= "\t\t\t<option value='" . $langkey2 . "'"; if ($actuallang == $langkey2) { $editsurvey .= " selected='selected'"; } $editsurvey .= ">" . $langname['nativedescription'] . " - " . $langname['description'] . "</option>\n"; } $editsurvey .= "\t\t</select></li>"; $thisdefaulttemplate = getGlobalSetting('defaulttemplate'); $templatenames = array_keys(gettemplatelist()); $editsurvey .= "" . "\t<li><label for='defaulttemplate'>" . $clang->gT("Default template:") . "</label>\n" . "\t\t\t<select name='defaulttemplate' id='defaulttemplate'>\n"; foreach ($templatenames as $templatename) { $editsurvey .= "\t\t\t\t<option value='{$templatename}'"; if ($thisdefaulttemplate == $templatename) { $editsurvey .= " selected='selected'"; } $editsurvey .= ">{$templatename}</option>\n"; } $editsurvey .= "\t\t\t</select></li>\n"; $thisdefaulthtmleditormode = getGlobalSetting('defaulthtmleditormode'); $editsurvey .= "" . "\t<li><label for='defaulthtmleditormode'>" . $clang->gT("Default HTML editor mode:") . ($demoModeOnly == true ? '*' : '') . "</label>\n" . "\t\t\t<select name='defaulthtmleditormode' id='defaulthtmleditormode'>\n" . "\t\t\t\t<option value='default'"; if ($thisdefaulthtmleditormode == 'default') { $editsurvey .= " selected='selected'"; } $editsurvey .= ">" . $clang->gT("Default HTML editor mode") . "</option>\n" . "\t\t\t\t<option value='none'"; if ($thisdefaulthtmleditormode == 'none') { $editsurvey .= " selected='selected'"; } $editsurvey .= ">" . $clang->gT("No HTML editor") . "</option>\n" . "<option value='inline'"; if ($thisdefaulthtmleditormode == 'inline') { $editsurvey .= " selected='selected'"; } $editsurvey .= ">" . $clang->gT("Inline HTML editor") . "</option>\n" . "<option value='popup'"; if ($thisdefaulthtmleditormode == 'popup') { $editsurvey .= " selected='selected'"; } $editsurvey .= ">" . $clang->gT("Popup HTML editor") . "</option>\n" . "</select></li>\n"; $dateformatdata = getDateFormatData($_SESSION['dateformat']); $editsurvey .= "\t<li><label for='timeadjust'>" . $clang->gT("Time difference (in hours):") . "</label>\n" . "\t\t<input type='text' size='10' id='timeadjust' name='timeadjust' value=\"" . htmlspecialchars(str_replace(array('+', ' hours'), array('', ''), getGlobalSetting('timeadjust'))) . "\" /> " . $clang->gT("Server time:") . ' ' . convertDateTimeFormat(date('Y-m-d H:i:s'), 'Y-m-d H:i:s', $dateformatdata['phpdate'] . ' H:i') . " - " . $clang->gT("Corrected time :") . ' ' . convertDateTimeFormat(date_shift(date("Y-m-d H:i:s"), 'Y-m-d H:i:s', getGlobalSetting('timeadjust')), 'Y-m-d H:i:s', $dateformatdata['phpdate'] . ' H:i') . "\r\n </li>\n"; $thisusepdfexport = getGlobalSetting('usepdfexport'); $editsurvey .= "\t<li><label for='usepdfexport'>" . $clang->gT("PDF export available:") . "</label>\n" . "<select name='usepdfexport' id='usepdfexport'>\n" . "<option value='1'"; if ($thisusepdfexport == true) { $editsurvey .= " selected='selected'"; } $editsurvey .= ">" . $clang->gT("On") . "</option>\n" . "<option value='0'"; if ($thisusepdfexport == false) { $editsurvey .= " selected='selected'"; } $editsurvey .= ">" . $clang->gT("Off") . "</option>\n" . "\t\t</select>\n\t</li>\n"; $thisaddTitleToLinks = getGlobalSetting('addTitleToLinks'); $editsurvey .= "\t<li><label for='addTitleToLinks'>" . $clang->gT("Screen reader compatibility mode:") . "</label>\n" . "<select name='addTitleToLinks' id='addTitleToLinks'>\n" . "<option value='1'"; if ($thisaddTitleToLinks == true) { $editsurvey .= " selected='selected'"; } $editsurvey .= ">" . $clang->gT("On") . "</option>\n" . "<option value='0'"; if ($thisaddTitleToLinks == false) { $editsurvey .= " selected='selected'"; } $editsurvey .= ">" . $clang->gT("Off") . "</option>\n" . "</select>\n</li>\n" . "<li><label for='sessionlifetime'>" . $clang->gT("Session lifetime (seconds):") . "</label>\n" . "<input type='text' size='10' id='sessionlifetime' name='sessionlifetime' value=\"" . htmlspecialchars(getGlobalSetting('sessionlifetime')) . "\" /></li>"; // End General TAB $editsurvey .= "\t</ul></div>\n"; // Email TAB $editsurvey .= "\t<div class='tab-page'> <h2 class='tab'>" . $clang->gT("Email settings") . "</h2><ul>\n"; //Format $editsurvey .= "\t<li><label for='siteadminemail'>" . $clang->gT("Default site admin email:") . "</label>\n" . "\t\t<input type='text' size='50' id='siteadminemail' name='siteadminemail' value=\"" . htmlspecialchars(getGlobalSetting('siteadminemail')) . "\" /></li>\n" . "\t<li><label for='siteadminbounce'>" . $clang->gT("Default site bounce email:") . "</label>\n" . "\t\t<input type='text' size='50' id='siteadminbounce' name='siteadminbounce' value=\"" . htmlspecialchars(getGlobalSetting('siteadminbounce')) . "\" /></li>\n" . "\t<li><label for='siteadminname'>" . $clang->gT("Administrator name:") . "</label>\n" . "\t\t<input type='text' size='50' id='siteadminname' name='siteadminname' value=\"" . htmlspecialchars(getGlobalSetting('siteadminname')) . "\" /><br /><br /></li>\n" . "\t<li><label for='emailmethod'>" . $clang->gT("Email method:") . "</label>\n" . "\t\t<select id='emailmethod' name='emailmethod'>\n" . "\t\t\t<option value='mail'"; if (getGlobalSetting('emailmethod') == 'mail') { $editsurvey .= " selected='selected'"; } $editsurvey .= ">" . $clang->gT("PHP (default)") . "</option>\n" . "\t\t\t<option value='smtp'"; if (getGlobalSetting('emailmethod') == 'smtp') { $editsurvey .= " selected='selected'"; } $editsurvey .= ">" . $clang->gT("SMTP") . "</option>\n" . "\t\t\t<option value='sendmail'"; if (getGlobalSetting('emailmethod') == 'sendmail') { $editsurvey .= " selected='selected'"; } $editsurvey .= ">" . $clang->gT("Sendmail") . "</option>\n" . "\t\t\t<option value='qmail'"; if (getGlobalSetting('emailmethod') == 'qmail') { $editsurvey .= " selected='selected'"; } $editsurvey .= ">" . $clang->gT("Qmail") . "</option>\n" . "\t\t</select></li>\n" . "\t<li><label for='emailsmtphost'>" . $clang->gT("SMTP host:") . "</label>\n" . "\t\t<input type='text' size='50' id='emailsmtphost' name='emailsmtphost' value=\"" . htmlspecialchars(getGlobalSetting('emailsmtphost')) . "\" /> <font size='1'>" . $clang->gT("Enter your hostname and port, e.g.: my.smtp.com:25") . "</font></li>\n" . "\t<li><label for='emailsmtpuser'>" . $clang->gT("SMTP username:"******"</label>\n" . "\t\t<input type='text' size='50' id='emailsmtpuser' name='emailsmtpuser' value=\"" . htmlspecialchars(getGlobalSetting('emailsmtpuser')) . "\" /></li>\n" . "\t<li><label for='emailsmtppassword'>" . $clang->gT("SMTP password:"******"</label>\n" . "\t\t<input type='password' size='50' id='emailsmtppassword' name='emailsmtppassword' value='somepassword' /></li>\n" . "\t<li><label for='emailsmtpssl'>" . $clang->gT("SMTP SSL/TLS:") . "</label>\n" . "\t\t<select id='emailsmtpssl' name='emailsmtpssl'>\n" . "\t\t\t<option value=''"; if (getGlobalSetting('emailsmtpssl') == '') { $editsurvey .= " selected='selected'"; } $editsurvey .= ">" . $clang->gT("Off") . "</option>\n" . "\t\t\t<option value='ssl'"; if (getGlobalSetting('emailsmtpssl') == 'ssl' || getGlobalSetting('emailsmtpssl') == 1) { $editsurvey .= " selected='selected'"; } $editsurvey .= ">" . $clang->gT("SSL") . "</option>\n" . "\t\t\t<option value='tls'"; if (getGlobalSetting('emailsmtpssl') == 'tls') { $editsurvey .= " selected='selected'"; } $editsurvey .= ">" . $clang->gT("TLS") . "</option>\n" . "\t\t</select></li>\n" . "\t<li><label for='emailsmtpdebug'>" . $clang->gT("SMTP debug mode:") . "</label>\n" . "\t\t<select id='emailsmtpdebug' name='emailsmtpdebug'>\n" . "\t\t\t<option value=''"; if (getGlobalSetting('emailsmtpdebug') == '0') { $editsurvey .= " selected='selected'"; } $editsurvey .= ">" . $clang->gT("Off") . "</option>\n" . "\t\t\t<option value='1'"; if (getGlobalSetting('emailsmtpdebug') == '1' || getGlobalSetting('emailsmtpssl') == 1) { $editsurvey .= " selected='selected'"; } $editsurvey .= ">" . $clang->gT("On errors") . "</option>\n" . "\t\t\t<option value='2'"; if (getGlobalSetting('emailsmtpdebug') == '2' || getGlobalSetting('emailsmtpssl') == 1) { $editsurvey .= " selected='selected'"; } $editsurvey .= ">" . $clang->gT("Always") . "</option>\n" . "\t\t</select><br /> </li>\n" . "\t<li><label for='maxemails'>" . $clang->gT("Email batch size:") . "</label>\n" . "\t\t<input type='text' size='5' id='maxemails' name='maxemails' value=\"" . htmlspecialchars(getGlobalSetting('maxemails')) . "\" /></li>\n" . "\t</ul>\n"; // End Email TAB $editsurvey .= "\t</div>\n"; // Security Settings $editsurvey .= "\t<div class='tab-page'> <h2 class='tab'>" . $clang->gT("Security") . "</h2><ul>\n"; // Expiration $thissurveyPreview_require_Auth = getGlobalSetting('surveyPreview_require_Auth'); $editsurvey .= "\t<li><label for='surveyPreview_require_Auth'>" . $clang->gT("Survey preview only for administration users") . "</label>\n" . "\t\t<select id='surveyPreview_require_Auth' name='surveyPreview_require_Auth'>\n" . "\t\t\t<option value='1'"; if ($thissurveyPreview_require_Auth == true) { $editsurvey .= " selected='selected'"; } $editsurvey .= ">" . $clang->gT("Yes") . "</option>\n" . "\t\t\t<option value='0'"; if ($thissurveyPreview_require_Auth == false) { $editsurvey .= " selected='selected'"; } $editsurvey .= ">" . $clang->gT("No") . "</option>\n" . "\t\t</select></li>\n"; // Auto registration $thisfilterxsshtml = getGlobalSetting('filterxsshtml'); $editsurvey .= "\t<li><label for='filterxsshtml'>" . $clang->gT("Filter HTML for XSS:") . ($demoModeOnly == true ? '*' : '') . "</label>\n" . "\t\t<select id='filterxsshtml' name='filterxsshtml'>\n" . "\t\t\t<option value='1'"; if ($thisfilterxsshtml == true) { $editsurvey .= " selected='selected'"; } $editsurvey .= ">" . $clang->gT("Yes") . "</option>\n" . "\t\t\t<option value='0'"; if ($thisfilterxsshtml == false) { $editsurvey .= " selected='selected'"; } $editsurvey .= ">" . $clang->gT("No") . "</option>\n" . "\t\t</select></li>\n"; $thisusercontrolSameGroupPolicy = getGlobalSetting('usercontrolSameGroupPolicy'); $editsurvey .= "\t<li><label for='usercontrolSameGroupPolicy'>" . $clang->gT("Group member can only see own group:") . "</label>\n" . "\t\t<select id='usercontrolSameGroupPolicy' name='usercontrolSameGroupPolicy'>\n" . "\t\t\t<option value='1'"; if ($thisusercontrolSameGroupPolicy == true) { $editsurvey .= " selected='selected'"; } $editsurvey .= ">" . $clang->gT("Yes") . "</option>\n" . "\t\t\t<option value='0'"; if ($thisusercontrolSameGroupPolicy == false) { $editsurvey .= " selected='selected'"; } $editsurvey .= ">" . $clang->gT("No") . "</option>\n" . "\t\t</select></li>\n"; $editsurvey .= "\t</ul></div>\n"; // Miscellaneous Settings $editsurvey .= "\t<div class='tab-page'> <h2 class='tab'>" . $clang->gT("Miscellaneous") . "</h2><ul>\n"; // shownoanswer $shownoanswer = getGlobalSetting('shownoanswer'); $editsurvey .= "\t<li><label for='shownoanswer'>" . $clang->gT("Show 'no answer' option for non-mandatory questions:") . "</label>\n" . "\t\t<select id='shownoanswer' name='shownoanswer'>\n" . "\t\t\t<option value='1'"; if ($shownoanswer == 1) { $editsurvey .= " selected='selected'"; } $editsurvey .= ">" . $clang->gT("Yes") . "</option>\n" . "\t\t\t<option value='0'"; if ($shownoanswer == 0) { $editsurvey .= " selected='selected'"; } $editsurvey .= ">" . $clang->gT("No") . "</option>\n" . "\t\t</select></li>\n"; $thisrepeatheadings = getGlobalSetting('repeatheadings'); $editsurvey .= "\t<li><label for='repeatheadings'>" . $clang->gT("Number of answers to show before repeating the headings in array questions:") . "</label>\n" . "\t\t<input id='repeatheadings' name='repeatheadings' value='{$thisrepeatheadings}' size='4' maxlength='4' /></li>\n"; $editsurvey .= "\t</ul>\n"; // End TAB page & form $editsurvey .= "\t</div><input type='hidden' name='action' value='globalsettingssave'/></form>\n"; // End tabs $editsurvey .= "</div>\n"; // The external button to sumbit Survey edit changes $editsurvey .= "\t<p><input type='button' onclick='\$(\"#frmglobalsettings\").submit();' class='standardbtn' value='" . $clang->gT("Save settings") . "' /><br /></p>\n"; if ($demoModeOnly == true) { $editsurvey .= '<p>' . $clang->gT("Note: Demo mode is activated. Marked (*) settings can't be changed.") . '</p>\\n'; } } else { include "access_denied.php"; } } }