本文整理汇总了PHP中SendEmailMessage函数的典型用法代码示例。如果您正苦于以下问题:PHP SendEmailMessage函数的具体用法?PHP SendEmailMessage怎么用?PHP SendEmailMessage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SendEmailMessage函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mail
/**
* Usergroups::mail()
* Function responsible to send an e-mail to a user group.
* @param mixed $ugid
* @return void
*/
public function mail($ugid)
{
$ugid = sanitize_int($ugid);
$clang = Yii::app()->lang;
$action = Yii::app()->request->getPost("action");
if ($action == "mailsendusergroup") {
// user must be in user group or superadmin
$result = UserInGroup::model()->findAllByPk(array('ugid' => $ugid, 'uid' => Yii::app()->session['loginID']));
if (count($result) > 0 || Permission::model()->hasGlobalPermission('superadmin', 'read')) {
$criteria = new CDbCriteria();
$criteria->compare('ugid', $ugid)->addNotInCondition('users.uid', array(Yii::app()->session['loginID']));
$eguresult = UserInGroup::model()->with('users')->findAll($criteria);
//die('me');
$to = array();
foreach ($eguresult as $egurow) {
$to[] = $egurow->users->users_name . ' <' . $egurow->users->email . '>';
}
$from_user_result = User::model()->findByPk(Yii::app()->session['loginID']);
$from_user_row = $from_user_result;
if ($from_user_row->full_name) {
$from = $from_user_row->full_name;
$from .= ' <';
$from .= $from_user_row->email . '> ';
} else {
$from = $from_user_row->users_name . ' <' . $from_user_row->email . '> ';
}
$body = $_POST['body'];
$subject = $_POST['subject'];
if (isset($_POST['copymail']) && $_POST['copymail'] == 1) {
$to[] = $from;
}
$body = str_replace("\n.", "\n..", $body);
$body = wordwrap($body, 70);
//echo $body . '-'.$subject .'-'.'<pre>'.htmlspecialchars($to).'</pre>'.'-'.$from;
if (SendEmailMessage($body, $subject, $to, $from, '')) {
list($aViewUrls, $aData) = $this->index($ugid, array("type" => "success", "message" => "Message(s) sent successfully!"));
} else {
global $maildebug;
global $debug;
global $maildebugbody;
//$maildebug = (isset($maildebug)) ? $maildebug : "Their was a unknown error in the mailing part :)";
//$debug = (isset($debug)) ? $debug : 9;
//$maildebugbody = (isset($maildebugbody)) ? $maildebugbody : 'an unknown error accourd';
$headercfg["type"] = "warning";
$headercfg["message"] = sprintf($clang->gT("Email to %s failed. Error Message:"), $to) . " " . $maildebug;
list($aViewUrls, $aData) = $this->index($ugid, $headercfg);
}
} else {
die;
}
} else {
$where = array('and', 'a.ugid =' . $ugid, 'uid =' . Yii::app()->session['loginID']);
$join = array('where' => "{{user_in_groups}} AS b", 'on' => 'a.ugid = b.ugid');
$result = UserGroup::model()->join(array('a.ugid', 'a.name', 'a.owner_id', 'b.uid'), "{{user_groups}} AS a", $where, $join, 'name');
$crow = $result;
$aData['ugid'] = $ugid;
$aViewUrls = 'mailUserGroup_view';
}
$this->_renderWrappedTemplate('usergroup', $aViewUrls, $aData);
}
示例2: SendEmailByTemplate
function SendEmailByTemplate($ToEmailID, $Email_Point, $ID = 0, array $parm = null)
{
//$ar = Get_template::model()->getEmailContent($Email_Point, $panel_listID);
$ar = $this->getEmailContent($Email_Point, $ID);
//echo '<pre>' . print_r($ar).'</pre>';
//$to = $this->GetToEmailID($Email_Point, $ToEmailID);
$to = $ToEmailID;
$from = $this->GetFromEmailID();
//$subject = $ar['SUBJECT'];//26/06/2014 Remove By Hari
$subject = $body = $this->ReplaceBodyVariables($ar['SUBJECT'], $Email_Point, $ID, $parm);
//26/06/2014 Add By Hari
$whitelist = array('127.0.0.1', '::1');
if (!in_array($_SERVER['REMOTE_ADDR'], $whitelist)) {
$body = $this->ReplaceBodyVariables($ar['BODY'], $Email_Point, $ID, $parm);
} else {
return $body = $this->ReplaceBodyVariables($ar['BODY'], $Email_Point, $ID, $parm);
}
//exit('body-' . $body . '<br>subject-' . $subject . '<br>to-' . $to . '<br>from-' . $from . '<br>sitename-' . Yii::app()->getConfig("sitename") . '<br>true-' . true . '<br>siteadminbounce-' . Yii::app()->getConfig("siteadminbounce"));
$sent = SendEmailMessage($body, $subject, $to, $from, Yii::app()->getConfig("sitename"), true, Yii::app()->getConfig("siteadminbounce"));
return $sent;
}
示例3: adduser
function adduser()
{
if (!Yii::app()->session['USER_RIGHT_CREATE_USER']) {
die(accessDenied('adduser'));
}
$clang = Yii::app()->lang;
$new_user = flattenText(Yii::app()->request->getPost('new_user'), false, true);
$new_email = flattenText(Yii::app()->request->getPost('new_email'), false, true);
$new_full_name = flattenText(Yii::app()->request->getPost('new_full_name'), false, true);
$aViewUrls = array();
$valid_email = true;
if (!validateEmailAddress($new_email)) {
$valid_email = false;
$aViewUrls['message'] = array('title' => $clang->gT("Failed to add user"), 'message' => $clang->gT("The email address is not valid."), 'class' => 'warningheader');
}
if (empty($new_user)) {
$aViewUrls['message'] = array('title' => $clang->gT("Failed to add user"), 'message' => $clang->gT("A username was not supplied or the username is invalid."), 'class' => 'warningheader');
} elseif (User::model()->find("users_name='{$new_user}'")) {
$aViewUrls['message'] = array('title' => $clang->gT("Failed to add user"), 'message' => $clang->gT("The username already exists."), 'class' => 'warningheader');
} elseif ($valid_email) {
$new_pass = createPassword();
$iNewUID = User::model()->insertUser($new_user, $new_pass, $new_full_name, Yii::app()->session['loginID'], $new_email);
if ($iNewUID) {
// add default template to template rights for user
Templates_rights::model()->insertRecords(array('uid' => $iNewUID, 'folder' => 'default', 'use' => '1'));
// add new user to userlist
$sresult = User::model()->getAllRecords(array('uid' => $iNewUID));
$srow = count($sresult);
$userlist = getUserList();
array_push($userlist, array("user" => $srow['users_name'], "uid" => $srow['uid'], "email" => $srow['email'], "password" => $srow["password"], "parent_id" => $srow['parent_id'], "create_survey" => $srow['create_survey'], "participant_panel" => $srow['participant_panel'], "configurator" => $srow['configurator'], "create_user" => $srow['create_user'], "delete_user" => $srow['delete_user'], "superadmin" => $srow['superadmin'], "manage_template" => $srow['manage_template'], "manage_label" => $srow['manage_label']));
// send Mail
$body = sprintf($clang->gT("Hello %s,"), $new_full_name) . "<br /><br />\n";
$body .= sprintf($clang->gT("this is an automated email to notify that a user has been created for you on the site '%s'."), Yii::app()->getConfig("sitename")) . "<br /><br />\n";
$body .= $clang->gT("You can use now the following credentials to log into the site:") . "<br />\n";
$body .= $clang->gT("Username") . ": " . $new_user . "<br />\n";
if (Yii::app()->getConfig("useWebserverAuth") === false) {
// authent is not delegated to web server
// send password (if authorized by config)
if (Yii::app()->getConfig("display_user_password_in_email") === true) {
$body .= $clang->gT("Password") . ": " . $new_pass . "<br />\n";
} else {
$body .= $clang->gT("Password") . ": " . $clang->gT("Please ask your password to your LimeSurvey administrator") . "<br />\n";
}
}
$body .= "<a href='" . $this->getController()->createAbsoluteUrl("/admin") . "'>" . $clang->gT("Click here to log in.") . "</a><br /><br />\n";
$body .= sprintf($clang->gT('If you have any questions regarding this mail please do not hesitate to contact the site administrator at %s. Thank you!'), Yii::app()->getConfig("siteadminemail")) . "<br />\n";
$subject = sprintf($clang->gT("User registration at '%s'", "unescaped"), Yii::app()->getConfig("sitename"));
$to = $new_user . " <{$new_email}>";
$from = Yii::app()->getConfig("siteadminname") . " <" . Yii::app()->getConfig("siteadminemail") . ">";
$extra = '';
$classMsg = '';
if (SendEmailMessage($body, $subject, $to, $from, Yii::app()->getConfig("sitename"), true, Yii::app()->getConfig("siteadminbounce"))) {
$extra .= "<br />" . $clang->gT("Username") . ": {$new_user}<br />" . $clang->gT("Email") . ": {$new_email}<br />";
$extra .= "<br />" . $clang->gT("An email with a generated password was sent to the user.");
$classMsg = 'successheader';
$sHeader = $clang->gT("Success");
} else {
// has to be sent again or no other way
$tmp = str_replace("{NAME}", "<strong>" . $new_user . "</strong>", $clang->gT("Email to {NAME} ({EMAIL}) failed."));
$extra .= "<br />" . str_replace("{EMAIL}", $new_email, $tmp) . "<br />";
$classMsg = 'warningheader';
$sHeader = $clang->gT("Warning");
}
$aViewUrls['mboxwithredirect'][] = $this->_messageBoxWithRedirect($clang->gT("Add user"), $sHeader, $classMsg, $extra, $this->getController()->createUrl("admin/user/setUserRights"), $clang->gT("Set user permissions"), array('action' => 'setUserRights', 'user' => $new_user, 'uid' => $iNewUID));
} else {
$aViewUrls['mboxwithredirect'][] = $this->_messageBoxWithRedirect($clang->gT("Failed to add user"), $clang->gT("The user name already exists."), 'warningheader');
}
}
$this->_renderWrappedTemplate('user', $aViewUrls);
}
示例4: _sendPasswordEmail
/**
* Send the forgot password email
*
* @param string $sEmailAddr
* @param array $aFields
*/
private function _sendPasswordEmail($sEmailAddr, $aFields)
{
$sFrom = Yii::app()->getConfig("siteadminname") . " <" . Yii::app()->getConfig("siteadminemail") . ">";
$sTo = $sEmailAddr;
$sSubject = gT('User data');
$sNewPass = createPassword();
$sSiteName = Yii::app()->getConfig('sitename');
$sSiteAdminBounce = Yii::app()->getConfig('siteadminbounce');
$username = sprintf(gT('Username: %s'), $aFields[0]['users_name']);
$email = sprintf(gT('Email: %s'), $sEmailAddr);
$password = sprintf(gT('New password: %s'), $sNewPass);
$body = array();
$body[] = sprintf(gT('Your user data for accessing %s'), Yii::app()->getConfig('sitename'));
$body[] = $username;
$body[] = $password;
$body = implode("\n", $body);
if (SendEmailMessage($body, $sSubject, $sTo, $sFrom, $sSiteName, false, $sSiteAdminBounce)) {
User::model()->updatePassword($aFields[0]['uid'], $sNewPass);
// For security reasons, we don't show a successful message
$sMessage = gT($this->sent_email_message);
} else {
$sMessage = gT('Email failed');
}
return $sMessage;
}
示例5: actionIndex
//.........这里部分代码省略.........
}
while ($mayinsert != true) {
$newtoken = randomChars($tokenlength);
$ntquery = "SELECT * FROM {{tokens_{$surveyid}}} WHERE token='{$newtoken}'";
$usrow = Yii::app()->db->createCommand($ntquery)->queryRow();
if (!$usrow) {
$mayinsert = true;
}
}
$postfirstname = sanitize_xss_string(strip_tags(Yii::app()->request->getPost('register_firstname')));
$postlastname = sanitize_xss_string(strip_tags(Yii::app()->request->getPost('register_lastname')));
$starttime = sanitize_xss_string(Yii::app()->request->getPost('startdate'));
$endtime = sanitize_xss_string(Yii::app()->request->getPost('enddate'));
/*$postattribute1=sanitize_xss_string(strip_tags(returnGlobal('register_attribute1')));
$postattribute2=sanitize_xss_string(strip_tags(returnGlobal('register_attribute2'))); */
// Insert new entry into tokens db
Tokens_dynamic::sid($thissurvey['sid']);
$token = new Tokens_dynamic();
$token->firstname = $postfirstname;
$token->lastname = $postlastname;
$token->email = Yii::app()->request->getPost('register_email');
$token->emailstatus = 'OK';
$token->token = $newtoken;
if ($starttime && $endtime) {
$token->validfrom = $starttime;
$token->validuntil = $endtime;
}
foreach ($attributeinsertdata as $k => $v) {
$token->{$k} = $v;
}
$result = $token->save();
/**
$result = $connect->Execute($query, array($postfirstname,
$postlastname,
returnGlobal('register_email'),
'OK',
$newtoken)
// $postattribute1, $postattribute2)
) or safeDie ($query."<br />".$connect->ErrorMsg()); //Checked - According to adodb docs the bound variables are quoted automatically
*/
$tid = getLastInsertID($token->tableName());
$fieldsarray["{ADMINNAME}"] = $thissurvey['adminname'];
$fieldsarray["{ADMINEMAIL}"] = $thissurvey['adminemail'];
$fieldsarray["{SURVEYNAME}"] = $thissurvey['name'];
$fieldsarray["{SURVEYDESCRIPTION}"] = $thissurvey['description'];
$fieldsarray["{FIRSTNAME}"] = $postfirstname;
$fieldsarray["{LASTNAME}"] = $postlastname;
$fieldsarray["{EXPIRY}"] = $thissurvey["expiry"];
$message = $thissurvey['email_register'];
$subject = $thissurvey['email_register_subj'];
$from = "{$thissurvey['adminname']} <{$thissurvey['adminemail']}>";
if (getEmailFormat($surveyid) == 'html') {
$useHtmlEmail = true;
$surveylink = $this->createAbsoluteUrl($surveyid . '/lang-' . $baselang . '/tk-' . $newtoken);
$optoutlink = $this->createAbsoluteUrl('optout/local/' . $surveyid . '/' . $baselang . '/' . $newtoken);
$optinlink = $this->createAbsoluteUrl('optin/local/' . $surveyid . '/' . $baselang . '/' . $newtoken);
$fieldsarray["{SURVEYURL}"] = "<a href='{$surveylink}'>" . $surveylink . "</a>";
$fieldsarray["{OPTOUTURL}"] = "<a href='{$optoutlink}'>" . $optoutlink . "</a>";
$fieldsarray["{OPTINURL}"] = "<a href='{$optinlink}'>" . $optinlink . "</a>";
} else {
$useHtmlEmail = false;
$fieldsarray["{SURVEYURL}"] = $this->createAbsoluteUrl('' . $surveyid . '/lang-' . $baselang . '/tk-' . $newtoken);
$fieldsarray["{OPTOUTURL}"] = $this->createAbsoluteUrl('optout/local/' . $surveyid . '/' . $baselang . '/' . $newtoken);
$fieldsarray["{OPTINURL}"] = $this->createAbsoluteUrl('optin/local/' . $surveyid . '/' . $baselang . '/' . $newtoken);
}
$message = ReplaceFields($message, $fieldsarray);
$subject = ReplaceFields($subject, $fieldsarray);
$html = "";
//Set variable
$sitename = Yii::app()->getConfig('sitename');
if (SendEmailMessage($message, $subject, Yii::app()->request->getPost('register_email'), $from, $sitename, $useHtmlEmail, getBounceEmail($surveyid))) {
// TLR change to put date into sent
$today = dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i", Yii::app()->getConfig('timeadjust'));
$query = "UPDATE {{tokens_{$surveyid}}}\n" . "SET sent='{$today}' WHERE tid={$tid}";
$result = dbExecuteAssoc($query) or show_error("Unable to execute this query : {$query}<br />");
//Checked
$html = "<center>" . $clang->gT("Thank you for registering to participate in this survey.") . "<br /><br />\n" . $clang->gT("An email has been sent to the address you provided with access details for this survey. Please follow the link in that email to proceed.") . "<br /><br />\n" . $clang->gT("Survey administrator") . " {ADMINNAME} ({ADMINEMAIL})";
$html = ReplaceFields($html, $fieldsarray);
$html .= "<br /><br /></center>\n";
} else {
$html = "Email Error";
}
//PRINT COMPLETED PAGE
if (!$thissurvey['template']) {
$thistpl = getTemplatePath(validateTemplateDir('default'));
} else {
$thistpl = getTemplatePath(validateTemplateDir($thissurvey['template']));
}
sendCacheHeaders();
doHeader();
Yii::app()->lang = $clang;
// fetch the defined variables and pass it to the header footer templates.
$redata = compact(array_keys(get_defined_vars()));
$this->_printTemplateContent($thistpl . '/startpage.pstpl', $redata, __LINE__);
$this->_printTemplateContent($thistpl . '/survey.pstpl', $redata, __LINE__);
echo $html;
$this->_printTemplateContent($thistpl . '/endpage.pstpl', $redata, __LINE__);
doFooter();
}
示例6: link
}
if ($saver['email']) {
//Send email
if (validate_email($saver['email']) && !returnglobal('redo')) {
$subject = $clang->gT("Saved Survey Details");
$message = $clang->gT("Thank you for saving your survey in progress. The following details can be used to return to this survey and continue where you left off. Please keep this e-mail for your reference - we cannot retrieve the password for you.");
$message .= "\n\n" . $thissurvey['name'] . "\n\n";
$message .= $clang->gT("Name") . ": " . $saver['identifier'] . "\n";
$message .= $clang->gT("Password") . ": " . $saver['password'] . "\n\n";
$message .= $clang->gT("Reload your survey by clicking on the following link (or pasting it into your browser):") . "\n";
$message .= $publicurl . "/index.php?sid={$surveyid}&loadall=reload&scid=" . $scid . "&lang=" . urlencode($saver['language']) . "&loadname=" . urlencode($saver['identifier']) . "&loadpass=" . urlencode($saver['password']);
if (isset($tokendata['token'])) {
$message .= "&token=" . $tokendata['token'];
}
$from = $thissurvey['adminemail'];
if (SendEmailMessage(null, $message, $subject, $saver['email'], $from, $sitename, false, getBounceEmail($surveyid))) {
$emailsent = "Y";
$dataentryoutput .= "<font class='successtitle'>" . $clang->gT("An email has been sent with details about your saved survey") . "</font><br />\n";
}
}
}
} else {
safe_die("Unable to insert record into saved_control table.<br /><br />" . $connect->ErrorMsg());
}
}
$dataentryoutput .= "\t<div class='successheader'>" . $clang->gT("Success") . "</div>\n";
$thisid = $connect->Insert_ID();
$dataentryoutput .= "\t" . $clang->gT("The entry was assigned the following record id: ") . " {$thisid}<br /><br />\n";
}
$dataentryoutput .= $errormsg;
$dataentryoutput .= "\t<input type='submit' value='" . $clang->gT("Add Another Record") . "' onclick=\"window.open('{$scriptname}?action=dataentry&sid={$surveyid}&language=" . $_POST['language'] . "', '_top')\" /><br /><br />\n";
示例7: afterSurveyComplete
/**
* This event is fired by when a response is submitted
* available for a survey.
* @param PluginEvent $event
*/
public function afterSurveyComplete()
{
// This method will send a notification email
$event = $this->getEvent();
$surveyId = $event->get('surveyId');
// Only process the afterSurveyComplete if the plugin is Enabled for this survey and if the survey is Active
if ($this->get('emailCount', 'Survey', $surveyId) < 1 || Survey::model()->findByPk($surveyId)->active != "Y") {
// leave gracefully
return true;
}
// Retrieve response and survey properties
$responseId = $event->get('responseId');
$response = $this->pluginManager->getAPI()->getResponse($surveyId, $responseId);
$sitename = $this->pluginManager->getAPI()->getConfigKey('sitename');
$surveyInfo = getSurveyInfo($surveyId);
$adminemail = $surveyInfo['adminemail'];
$bounce_email = $surveyInfo['bounce_email'];
$isHtmlEmail = $surveyInfo['htmlemail'] == 'Y';
$baseLang = $surveyInfo['language'];
for ($i = 1; $i <= $this->get('emailCount', 'Survey', $surveyId); $i++) {
// Let's check if there is at least a valid destination email address
$aTo = array();
$aAttachTo = array();
$aDestEmail = explode(';', $this->pluginManager->getAPI()->EMevaluateExpression($this->get('emailDestinations_' . $i, 'Survey', $surveyId)));
$aDestEmail = array_map('trim', $aDestEmail);
$aUploadQuestions = explode(';', $this->pluginManager->getAPI()->EMevaluateExpression($this->get('emailAttachFiles_' . $i, 'Survey', $surveyId)));
$aUploadQuestions = array_map('trim', $aUploadQuestions);
// prepare an array of valid destination email addresses
foreach ($aDestEmail as $destemail) {
if (validateEmailAddress($destemail)) {
$aTo[] = $destemail;
}
}
// prepare an array of valid attached files from upload-questions
foreach ($aUploadQuestions as $uploadQuestion) {
$sgqa = 0;
$qtype = '';
if (isset($response[$uploadQuestion])) {
// get SGQA code from question-code. Ther might be a better way to do this though...
$sgqa = $this->pluginManager->getAPI()->EMevaluateExpression('{' . $uploadQuestion . '.sgqa}');
$qtype = $this->pluginManager->getAPI()->EMevaluateExpression('{' . $uploadQuestion . '.type}');
}
// Only add the file if question is relevant
if ($sgqa != 0 && $qtype == "|" && \LimeExpressionManager::QuestionIsRelevant($sgqa)) {
$aFiles = json_decode($response[$uploadQuestion]);
if (!is_null($aFiles) && is_array($aFiles)) {
foreach ($aFiles as $file) {
if (property_exists($file, 'name') && property_exists($file, 'filename')) {
$name = $file->name;
$filename = $file->filename;
$aAttachTo[] = array(0 => $this->pluginManager->getAPI()->getConfigKey('uploaddir') . "/surveys/{$surveyId}/files/" . $filename, 1 => $name);
}
}
}
}
}
if (count($aTo) >= 1) {
// Retrieve the language to use for the notification email
$emailLang = $this->get('emailLang_' . $i, 'Survey', $surveyId);
if ($emailLang == '--') {
// in this case let's select the language used when submitting the response
$emailLang = $response['startlanguage'];
}
$subjectTemplate = $this->get("emailSubject_{$i}_{$emailLang}", 'Survey', $surveyId);
if ($subjectTemplate == "") {
// If subject is not translated, use subject and body from the baseLang
$emailLang = $baseLang;
$subjectTemplate = $this->get("emailSubject_{$i}_{$emailLang}", 'Survey', $surveyId);
}
// Process the email subject and body through ExpressionManager
$subject = $this->pluginManager->getAPI()->EMevaluateExpression($subjectTemplate);
// Prepare an {ANSWERTABLE} variable
if ($surveyInfo['datestamp'] == 'N') {
//$aFilteredFields=array('id', 'submitdate', 'lastpage', 'startlanguage');
// Let's filter submitdate if survey is not datestampped
$aFilteredFields = array('submitdate');
} else {
//$aFilteredFields=array('id', 'lastpage', 'startlanguage');
$aFilteredFields = array();
}
$replacementfields = array('ANSWERTABLE' => $this->translateAnswerTable($surveyId, $responseId, $emailLang, $isHtmlEmail, $aFilteredFields));
// Process emailBody through EM and replace {ANSWERTABLE}
$body = \LimeExpressionManager::ProcessString($this->get("emailBody_{$i}_{$emailLang}", 'Survey', $surveyId), NULL, $replacementfields);
// At last it's time to send the email
SendEmailMessage($body, $subject, $aTo, $adminemail, $sitename, $isHtmlEmail, $bounce_email, $aAttachTo);
}
// END BLOCK 'if' aTo[] not emtpy
}
// END BLOCK 'for' emailCount
}
示例8: sSendEmail
/**
*
* Function to send reminder, invitation or custom mails to participants of a specific survey
* @param $sUser
* @param $sPass
* @param $iVid
* @param $type
* @param $maxLsrcEmails
* @param $subject
* @param $emailText
* @return unknown_type
*/
function sSendEmail($sUser, $sPass, $iVid, $type, $maxLsrcEmails = '', $subject = '', $emailText = '')
{
global $sitename, $siteadminemail;
include "lsrc.config.php";
$lsrcHelper = new lsrcHelper();
$lsrcHelper->debugLsrc("wir sind in " . __FUNCTION__ . " Line " . __LINE__ . ", START OK ");
// wenn maxmails ber den lsrc gegeben wird das nurtzen, ansonsten die default werte aus der config.php
if ($maxLsrcEmails != '') {
$maxemails = $maxLsrcEmails;
}
if (!$lsrcHelper->checkUser($sUser, $sPass)) {
throw new SoapFault("Authentication: ", "User or password wrong");
exit;
}
// Check if all mandatory parameters are present, else abort...
if (!is_int($iVid) || $iVid == 0 || $type == '') {
throw new SoapFault("Server: ", "Mandatory Parameters missing");
exit;
}
if ($type == 'custom' && $subject != '' && $emailText != '') {
//GET SURVEY DETAILS not working here... don't know why...
//$thissurvey=getSurveyInfo($iVid);
$from = $siteadminemail;
$lsrcHelper->debugLsrc("wir sind in " . __FUNCTION__ . " Line " . __LINE__ . ", Admin Email: {$from} ; survey: {$iVid} ; dump: " . print_r($thissurvey) . "");
$emquery = "SELECT firstname, lastname, email, token, tid, language";
//if ($ctfieldcount > 7) {$emquery .= ", attribute_1, attribute_2";}
$emquery .= " FROM " . db_table_name("tokens_{$iVid}") . " WHERE email != '' ";
if (isset($tokenid)) {
$emquery .= " and tid='{$tokenid}'";
}
$tokenoutput .= "\n\n<!-- emquery: {$emquery} -->\n\n";
//$emresult = db_select_limit_assoc($emquery,$maxemails);
$emresult = db_execute_assoc($emquery);
$emcount = $emresult->RecordCount();
if ($emcount > 0) {
$mailsSend = 0;
while ($emrow = $emresult->FetchRow()) {
if (SendEmailMessage($emailText, $subject, $emrow['email'], $from, $sitename, $ishtml = false, getBounceEmail($iVid))) {
$mailsSend++;
} else {
//$tokenoutput .= ReplaceFields($clang->gT("Email to {FIRSTNAME} {LASTNAME} ({EMAIL}) failed. Error Message:")." ".$maildebug."<br />", $fieldsarray);
if ($n == 1) {
$failedAddresses .= "," . $emrow['email'];
} else {
$failedAddresses = $emrow['email'];
$n = 1;
}
}
}
} else {
return "No Mails to send";
}
// if ($ctcount > $emcount)
// {
// $lefttosend = $ctcount-$maxemails;
//
// }else{$lefttosend = 0;}
// if($maxemails>0)
// {
// $returnValue = "".$mailsSend." Mails send. ".$lefttosend." Mails left to send";
// if(isset($failedAddresses))
// $returnValue .= "\nCould not send to: ".$failedAddresses;
// return $returnValue;
// }
if (isset($mailsSend)) {
$returnValue = "" . $mailsSend . " Mails send. ";
if (isset($failedAddresses)) {
$returnValue .= "\nCould not send to: " . $failedAddresses;
}
return $returnValue;
}
}
if ($type == 'invite' || $type == 'remind') {
$emailSenderReturn = $lsrcHelper->emailSender($iVid, $type, $maxLsrcEmails);
return $emailSenderReturn;
} else {
throw new SoapFault("Type: ", "Wrong send Type given. Possible types are: custom, invite or remind");
exit;
}
}
示例9: savedsilent
/**
* savesilent() saves survey responses when the "Resume later" button
* is press but has no interaction. i.e. it does not ask for email,
* username or password or capture.
*
* @return string confirming successful save.
*/
function savedsilent()
{
global $connect, $surveyid, $dbprefix, $thissurvey, $errormsg, $publicurl, $sitename, $timeadjust, $clang, $clienttoken, $thisstep, $modrewrite;
submitanswer();
// Prepare email
$tokenentryquery = 'SELECT * from '.$dbprefix.'tokens_'.$surveyid.' WHERE token=\''.sanitize_paranoid_string($clienttoken).'\';';
$tokenentryresult = db_execute_assoc($tokenentryquery);
$tokenentryarray = $tokenentryresult->FetchRow();
$from = $thissurvey['adminname'].' <'.$thissurvey['adminemail'].'>';
$to = $tokenentryarray['firstname'].' '.$tokenentryarray['lastname'].' <'.$tokenentryarray['email'].'>';
$subject = $clang->gT("Saved Survey Details") . " - " . $thissurvey['name'];
$message = $clang->gT("Thank you for saving your survey in progress. You can return to the survey at the same point you saved it at any time using the link from this or any previous email sent to regarding this survey.","unescaped")."\n\n";
$message .= $clang->gT("Reload your survey by clicking on the following link (or pasting it into your browser):","unescaped")."\n";
$language = $tokenentryarray['language'];
if($modrewrite)
{
$message .= "\n\n$publicurl/$surveyid/lang-$language/tk-$clienttoken";
}
else
{
$message .= "\n\n$publicurl/index.php?lang=$language&sid=$surveyid&token=$clienttoken";
};
if (SendEmailMessage($message, $subject, $to, $from, $sitename, false, getBounceEmail($surveyid)))
{
$emailsent="Y";
}
else
{
echo "Error: Email failed, this may indicate a PHP Mail Setup problem on your server. Your survey details have still been saved, however you will not get an email with the details. You should note the \"name\" and \"password\" you just used for future reference.";
};
return $clang->gT('Your survey was successfully saved.');
};
示例10: str_replace
$ugid = $postusergroupid;
$body = $_POST['body'];
$subject = $_POST['subject'];
if(isset($_POST['copymail']) && $_POST['copymail'] == 1)
{
$to .= ", " . $from;
}
$body = str_replace("\n.", "\n..", $body);
$body = wordwrap($body, 70);
//echo $body . '-'.$subject .'-'.'<pre>'.htmlspecialchars($to).'</pre>'.'-'.$from;
if (SendEmailMessage( $body, $subject, $to, $from,''))
{
$usersummary = "<div class=\"messagebox\">\n";
$usersummary .= "<div class=\"successheader\">".$clang->gT("Message(s) sent successfully!")."</div>\n"
. "<br />".$clang->gT("To:")."". $addressee."<br />\n"
. "<br/><input type=\"submit\" onclick=\"window.location='$scriptname?action=editusergroups&ugid={$ugid}'\" value=\"".$clang->gT("Continue")."\"/>\n";
}
else
{
$usersummary = "<div class=\"messagebox\">\n";
$usersummary .= "<div class=\"warningheader\">".sprintf($clang->gT("Email to %s failed. Error Message:"),$to)." ".$maildebug."</div>";
if ($debug>0)
{
$usersummary .= "<br /><pre>Subject : $subject<br /><br />".htmlspecialchars($maildebugbody)."<br /></pre>";
}
示例11: savedsilent
/**
* savesilent() saves survey responses when the "Resume later" button
* is press but has no interaction. i.e. it does not ask for email,
* username or password or capture.
*
* @return string confirming successful save.
*/
function savedsilent()
{
global $surveyid, $thissurvey, $errormsg, $publicurl, $sitename, $timeadjust, $clang, $clienttoken, $thisstep;
submitanswer();
// Prepare email
$tokenentryquery = 'SELECT * from {{tokens_' . $surveyid . '}} WHERE token=\'' . sanitize_paranoid_string($clienttoken) . '\';';
$tokenentryresult = dbExecuteAssoc($tokenentryquery);
$tokenentryarray = $tokenentryresult->read();
$from = $thissurvey['adminname'] . ' <' . $thissurvey['adminemail'] . '>';
$to = $tokenentryarray['firstname'] . ' ' . $tokenentryarray['lastname'] . ' <' . $tokenentryarray['email'] . '>';
$subject = $clang->gT("Saved Survey Details") . " - " . $thissurvey['name'];
$message = $clang->gT("Thank you for saving your survey in progress. You can return to the survey at the same point you saved it at any time using the link from this or any previous email sent to regarding this survey.") . "\n\n";
$message .= $clang->gT("Reload your survey by clicking on the following link (or pasting it into your browser):") . ":\n";
$language = $tokenentryarray['language'];
//$message .= "\n\n$publicurl/$surveyid/lang-$language/tk-$clienttoken";
$message .= "\n\n" . Yii::app()->getController()->createAbsoluteUrl("/survey/index/sid/{$surveyid}/lang/{$language}/token/{$clienttoken}");
if (SendEmailMessage($message, $subject, $to, $from, $sitename, false, getBounceEmail($surveyid))) {
$emailsent = "Y";
} else {
$clang->eT('Error: Email failed, this may indicate a PHP Mail Setup problem on your server. Your survey details have still been saved, however you will not get an email with the details. You should note the "name" and "password" you just used for future reference.');
if (trim($thissurvey['adminemail']) == '') {
$clang->eT('(Reason: Admin email address empty)');
}
}
return $clang->gT('Your survey was successfully saved.');
}
示例12: email
//.........这里部分代码省略.........
$_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);
}
}
}
示例13: sendRegistrationEmail
/**
* Send the register email with $_POST value
* @param $iSurveyId Survey Id to register
* @return boolean : if email is set to sent (before SMTP problem)
*/
public function sendRegistrationEmail($iSurveyId, $iTokenId)
{
$sLanguage = App()->language;
$aSurveyInfo = getSurveyInfo($iSurveyId, $sLanguage);
$aMail['subject'] = $aSurveyInfo['email_register_subj'];
$aMail['message'] = $aSurveyInfo['email_register'];
$aReplacementFields = array();
$aReplacementFields["{ADMINNAME}"] = $aSurveyInfo['adminname'];
$aReplacementFields["{ADMINEMAIL}"] = $aSurveyInfo['adminemail'];
$aReplacementFields["{SURVEYNAME}"] = $aSurveyInfo['name'];
$aReplacementFields["{SURVEYDESCRIPTION}"] = $aSurveyInfo['description'];
$aReplacementFields["{EXPIRY}"] = $aSurveyInfo["expiry"];
$oToken = Token::model($iSurveyId)->findByPk($iTokenId);
// Reload the token (needed if just created)
foreach ($oToken->attributes as $attribute => $value) {
$aReplacementFields["{" . strtoupper($attribute) . "}"] = $value;
}
$sToken = $oToken->token;
$useHtmlEmail = getEmailFormat($iSurveyId) == 'html';
$aMail['subject'] = preg_replace("/{TOKEN:([A-Z0-9_]+)}/", "{" . "\$1" . "}", $aMail['subject']);
$aMail['message'] = preg_replace("/{TOKEN:([A-Z0-9_]+)}/", "{" . "\$1" . "}", $aMail['message']);
$aReplacementFields["{SURVEYURL}"] = App()->createAbsoluteUrl("/survey/index/sid/{$iSurveyId}", array('lang' => $sLanguage, 'token' => $sToken));
$aReplacementFields["{OPTOUTURL}"] = App()->createAbsoluteUrl("/optout/tokens/surveyid/{$iSurveyId}", array('langcode' => $sLanguage, 'token' => $sToken));
$aReplacementFields["{OPTINURL}"] = App()->createAbsoluteUrl("/optin/tokens/surveyid/{$iSurveyId}", array('langcode' => $sLanguage, 'token' => $sToken));
foreach (array('OPTOUT', 'OPTIN', 'SURVEY') as $key) {
$url = $aReplacementFields["{{$key}URL}"];
if ($useHtmlEmail) {
$aReplacementFields["{{$key}URL}"] = "<a href='{$url}'>" . htmlspecialchars($url) . '</a>';
}
$aMail['subject'] = str_replace("@@{$key}URL@@", $url, $aMail['subject']);
$aMail['message'] = str_replace("@@{$key}URL@@", $url, $aMail['message']);
}
// Replace the fields
$aMail['subject'] = ReplaceFields($aMail['subject'], $aReplacementFields);
$aMail['message'] = ReplaceFields($aMail['message'], $aReplacementFields);
$sFrom = "{$aSurveyInfo['adminname']} <{$aSurveyInfo['adminemail']}>";
$sBounce = getBounceEmail($iSurveyId);
$sTo = $oToken->email;
$sitename = Yii::app()->getConfig('sitename');
// Plugin event for email handling (Same than admin token but with register type)
$event = new PluginEvent('beforeTokenEmail');
$event->set('type', 'register');
$event->set('subject', $aMail['subject']);
$event->set('to', $sTo);
$event->set('body', $aMail['message']);
$event->set('from', $sFrom);
$event->set('bounce', $sBounce);
$event->set('token', $oToken->attributes);
$aMail['subject'] = $event->get('subject');
$aMail['message'] = $event->get('body');
$sTo = $event->get('to');
$sFrom = $event->get('from');
if ($event->get('send', true) == false) {
$this->sMessage = $event->get('message', '');
if ($event->get('error') == null) {
// mimic token system, set send to today
$today = dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i", Yii::app()->getConfig('timeadjust'));
$oToken->sent = $today;
$oToken->save();
}
} elseif (SendEmailMessage($aMail['message'], $aMail['subject'], $sTo, $sFrom, $sitename, $useHtmlEmail, $sBounce)) {
// TLR change to put date into sent
$today = dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i", Yii::app()->getConfig('timeadjust'));
$oToken->sent = $today;
$oToken->save();
$this->sMessage = "<div id='wrapper' class='message tokenmessage'>" . "<p>" . gT("Thank you for registering to participate in this survey.") . "</p>\n" . "<p>{$this->sMailMessage}</p>\n" . "<p>" . sprintf(gT("Survey administrator %s (%s)"), $aSurveyInfo['adminname'], $aSurveyInfo['adminemail']) . "</p>" . "</div>\n";
} else {
$this->sMessage = "<div id='wrapper' class='message tokenmessage'>" . "<p>" . gT("Thank you for registering to participate in this survey.") . "</p>\n" . "<p>" . gT("You are registered but an error happened when trying to send the email - please contact the survey administrator.") . "</p>\n" . "<p>" . sprintf(gT("Survey administrator %s (%s)"), $aSurveyInfo['adminname'], $aSurveyInfo['adminemail']) . "</p>" . "</div>\n";
}
// Allways return true : if we come here, we allways trye to send an email
return true;
}
示例14: actionIndex
//.........这里部分代码省略.........
// Get the survey settings for token length
$tokenlength = $thissurvey['tokenlength'];
//if tokenlength is not set or there are other problems use the default value (15)
if (!isset($tokenlength) || $tokenlength == '') {
$tokenlength = 15;
}
while ($mayinsert != true) {
$newtoken = randomChars($tokenlength);
$oTokenExist = TokenDynamic::model($iSurveyID)->find('token=:token', array(':token' => $newtoken));
if (!$oTokenExist) {
$mayinsert = true;
}
}
$postfirstname = sanitize_xss_string(strip_tags(Yii::app()->request->getPost('register_firstname')));
$postlastname = sanitize_xss_string(strip_tags(Yii::app()->request->getPost('register_lastname')));
$starttime = sanitize_xss_string(Yii::app()->request->getPost('startdate'));
$endtime = sanitize_xss_string(Yii::app()->request->getPost('enddate'));
/*$postattribute1=sanitize_xss_string(strip_tags(returnGlobal('register_attribute1')));
$postattribute2=sanitize_xss_string(strip_tags(returnGlobal('register_attribute2'))); */
// Insert new entry into tokens db
$oToken = Token::create($thissurvey['sid']);
$oToken->firstname = $postfirstname;
$oToken->lastname = $postlastname;
$oToken->email = Yii::app()->request->getPost('register_email');
$oToken->emailstatus = 'OK';
$oToken->token = $newtoken;
if ($starttime && $endtime) {
$oToken->validfrom = $starttime;
$oToken->validuntil = $endtime;
}
$oToken->setAttributes($attributeinsertdata, false);
$result = $oToken->save();
//$tid = $oToken->tid;// Not needed any more
$fieldsarray["{ADMINNAME}"] = $thissurvey['adminname'];
$fieldsarray["{ADMINEMAIL}"] = $thissurvey['adminemail'];
$fieldsarray["{SURVEYNAME}"] = $thissurvey['name'];
$fieldsarray["{SURVEYDESCRIPTION}"] = $thissurvey['description'];
$fieldsarray["{FIRSTNAME}"] = $postfirstname;
$fieldsarray["{LASTNAME}"] = $postlastname;
$fieldsarray["{EXPIRY}"] = $thissurvey["expiry"];
$fieldsarray["{TOKEN}"] = $oToken->token;
$fieldsarray["{EMAIL}"] = $oToken->email;
$token = $oToken->token;
$message = $thissurvey['email_register'];
$subject = $thissurvey['email_register_subj'];
$from = "{$thissurvey['adminname']} <{$thissurvey['adminemail']}>";
$surveylink = $this->createAbsoluteUrl("/survey/index/sid/{$iSurveyID}", array('lang' => $sBaseLanguage, 'token' => $newtoken));
$optoutlink = $this->createAbsoluteUrl("/optout/tokens/surveyid/{$iSurveyID}", array('langcode' => $sBaseLanguage, 'token' => $newtoken));
$optinlink = $this->createAbsoluteUrl("/optin/tokens/surveyid/{$iSurveyID}", array('langcode' => $sBaseLanguage, 'token' => $newtoken));
if (getEmailFormat($iSurveyID) == 'html') {
$useHtmlEmail = true;
$fieldsarray["{SURVEYURL}"] = "<a href='{$surveylink}'>" . $surveylink . "</a>";
$fieldsarray["{OPTOUTURL}"] = "<a href='{$optoutlink}'>" . $optoutlink . "</a>";
$fieldsarray["{OPTINURL}"] = "<a href='{$optinlink}'>" . $optinlink . "</a>";
} else {
$useHtmlEmail = false;
$fieldsarray["{SURVEYURL}"] = $surveylink;
$fieldsarray["{OPTOUTURL}"] = $optoutlink;
$fieldsarray["{OPTINURL}"] = $optinlink;
}
$message = ReplaceFields($message, $fieldsarray);
$subject = ReplaceFields($subject, $fieldsarray);
$html = "";
//Set variable
$sitename = Yii::app()->getConfig('sitename');
if (SendEmailMessage($message, $subject, Yii::app()->request->getPost('register_email'), $from, $sitename, $useHtmlEmail, getBounceEmail($iSurveyID))) {
// TLR change to put date into sent
$today = dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i", Yii::app()->getConfig('timeadjust'));
$oToken->sent = $today;
$oToken->save();
$html = "<div id='wrapper' class='message tokenmessage'>" . "<p>" . $clang->gT("Thank you for registering to participate in this survey.") . "</p>\n" . "<p>" . $clang->gT("An email has been sent to the address you provided with access details for this survey. Please follow the link in that email to proceed.") . "</p>\n" . "<p>" . $clang->gT("Survey administrator") . " {ADMINNAME} ({ADMINEMAIL})</p>" . "</div>\n";
$html = ReplaceFields($html, $fieldsarray);
} else {
$html = "Email Error";
}
//PRINT COMPLETED PAGE
if (!$thissurvey['template']) {
$thistpl = getTemplatePath(validateTemplateDir('default'));
} else {
$thistpl = getTemplatePath(validateTemplateDir($thissurvey['template']));
}
// Same fix than http://bugs.limesurvey.org/view.php?id=8441
ob_start(function ($buffer, $phase) {
App()->getClientScript()->render($buffer);
App()->getClientScript()->reset();
return $buffer;
});
ob_implicit_flush(false);
sendCacheHeaders();
doHeader();
Yii::app()->lang = $clang;
// fetch the defined variables and pass it to the header footer templates.
$redata = compact(array_keys(get_defined_vars()));
$this->_printTemplateContent($thistpl . '/startpage.pstpl', $redata, __LINE__);
$this->_printTemplateContent($thistpl . '/survey.pstpl', $redata, __LINE__);
echo $html;
$this->_printTemplateContent($thistpl . '/endpage.pstpl', $redata, __LINE__);
doFooter();
ob_flush();
}
示例15: adduser
function adduser()
{
if (!Permission::model()->hasGlobalPermission('users', 'create')) {
Yii::app()->setFlashMessage(gT("You do not have sufficient rights to access this page."), 'error');
$this->getController()->redirect(array("admin/user/sa/index"));
}
$new_user = flattenText(Yii::app()->request->getPost('new_user'), false, true);
$aViewUrls = array();
if (empty($new_user)) {
$aViewUrls['message'] = array('title' => gT("Failed to add user"), 'message' => gT("A username was not supplied or the username is invalid."), 'class' => 'text-warning');
} elseif (User::model()->find("users_name=:users_name", array(':users_name' => $new_user))) {
$aViewUrls['message'] = array('title' => gT("Failed to add user"), 'message' => gT("The username already exists."), 'class' => 'text-warning');
} else {
$event = new PluginEvent('createNewUser');
$event->set('errorCode', AuthPluginBase::ERROR_NOT_ADDED);
$event->set('errorMessageTitle', gT("Failed to add user"));
$event->set('errorMessageBody', gT("Plugin is not active"));
App()->getPluginManager()->dispatchEvent($event);
if ($event->get('errorCode') != AuthPluginBase::ERROR_NONE) {
$aViewUrls['message'] = array('title' => $event->get('errorMessageTitle'), 'message' => $event->get('errorMessageBody'), 'class' => 'text-warning');
} else {
$iNewUID = $event->get('newUserID');
$new_pass = $event->get('newPassword');
$new_email = $event->get('newEmail');
$new_full_name = $event->get('newFullName');
// add default template to template rights for user
Permission::model()->insertSomeRecords(array('uid' => $iNewUID, 'permission' => Yii::app()->getConfig("defaulttemplate"), 'entity' => 'template', 'read_p' => 1, 'entity_id' => 0));
// add new user to userlist
$sresult = User::model()->getAllRecords(array('uid' => $iNewUID));
$srow = count($sresult);
$userlist = getUserList();
array_push($userlist, array("user" => $srow['users_name'], "uid" => $srow['uid'], "email" => $srow['email'], "password" => $srow["password"], "parent_id" => $srow['parent_id'], "create_survey" => $srow['create_survey'], "participant_panel" => $srow['participant_panel'], "configurator" => $srow['configurator'], "create_user" => $srow['create_user'], "delete_user" => $srow['delete_user'], "superadmin" => $srow['superadmin'], "manage_template" => $srow['manage_template'], "manage_label" => $srow['manage_label']));
// send Mail
$body = sprintf(gT("Hello %s,"), $new_full_name) . "<br /><br />\n";
$body .= sprintf(gT("this is an automated email to notify that a user has been created for you on the site '%s'."), Yii::app()->getConfig("sitename")) . "<br /><br />\n";
$body .= gT("You can use now the following credentials to log into the site:") . "<br />\n";
$body .= gT("Username") . ": " . htmlspecialchars($new_user) . "<br />\n";
// authent is not delegated to web server or LDAP server
if (Yii::app()->getConfig("auth_webserver") === false && Permission::model()->hasGlobalPermission('auth_db', 'read', $iNewUID)) {
// send password (if authorized by config)
if (Yii::app()->getConfig("display_user_password_in_email") === true) {
$body .= gT("Password") . ": " . $new_pass . "<br />\n";
} else {
$body .= gT("Password") . ": " . gT("Please contact your LimeSurvey administrator for your password.") . "<br />\n";
}
}
$body .= "<a href='" . $this->getController()->createAbsoluteUrl("/admin") . "'>" . gT("Click here to log in.") . "</a><br /><br />\n";
$body .= sprintf(gT('If you have any questions regarding this mail please do not hesitate to contact the site administrator at %s. Thank you!'), Yii::app()->getConfig("siteadminemail")) . "<br />\n";
$subject = sprintf(gT("User registration at '%s'", "unescaped"), Yii::app()->getConfig("sitename"));
$to = $new_user . " <{$new_email}>";
$from = Yii::app()->getConfig("siteadminname") . " <" . Yii::app()->getConfig("siteadminemail") . ">";
$extra = '';
$classMsg = '';
if (SendEmailMessage($body, $subject, $to, $from, Yii::app()->getConfig("sitename"), true, Yii::app()->getConfig("siteadminbounce"))) {
$extra .= "<br />" . gT("Username") . ": {$new_user}<br />" . gT("Email") . ": {$new_email}<br />";
$extra .= "<br />" . gT("An email with a generated password was sent to the user.");
$classMsg = 'text-success';
$sHeader = gT("Success");
} else {
// has to be sent again or no other way
$tmp = str_replace("{NAME}", "<strong>" . $new_user . "</strong>", gT("Email to {NAME} ({EMAIL}) failed."));
$extra .= "<br />" . str_replace("{EMAIL}", $new_email, $tmp) . "<br />";
$classMsg = 'text-warning';
$sHeader = gT("Warning");
}
$aViewUrls['mboxwithredirect'][] = $this->_messageBoxWithRedirect(gT("Add user"), $sHeader, $classMsg, $extra, $this->getController()->createUrl("admin/user/sa/setuserpermissions"), gT("Set user permissions"), array('action' => 'setuserpermissions', 'user' => $new_user, 'uid' => $iNewUID));
}
}
$this->_renderWrappedTemplate('user', $aViewUrls);
}