本文整理汇总了PHP中get_list_of_charsets函数的典型用法代码示例。如果您正苦于以下问题:PHP get_list_of_charsets函数的具体用法?PHP get_list_of_charsets怎么用?PHP get_list_of_charsets使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_list_of_charsets函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: email_to_user
//.........这里部分代码省略.........
// If no html has been given, BUT there is an html wrapping template then
// auto convert the text to html and then wrap it.
$autohtml = trim(text_to_html($messagetext));
$context['body'] = $autohtml;
$temphtml = $renderer->render_from_template('core/email_html', $context);
if ($autohtml != $temphtml) {
$messagehtml = $temphtml;
}
}
}
$context['body'] = $messagetext;
$mail->Subject = $renderer->render_from_template('core/email_subject', $context);
$mail->FromName = $renderer->render_from_template('core/email_fromname', $context);
$messagetext = $renderer->render_from_template('core/email_text', $context);
// Autogenerate a MessageID if it's missing.
if (empty($mail->MessageID)) {
$mail->MessageID = generate_email_messageid();
}
if ($messagehtml && !empty($user->mailformat) && $user->mailformat == 1) {
// Don't ever send HTML to users who don't want it.
$mail->isHTML(true);
$mail->Encoding = 'quoted-printable';
$mail->Body = $messagehtml;
$mail->AltBody = "\n{$messagetext}\n";
} else {
$mail->IsHTML(false);
$mail->Body = "\n{$messagetext}\n";
}
if ($attachment && $attachname) {
if (preg_match("~\\.\\.~", $attachment)) {
// Security check for ".." in dir path.
$temprecipients[] = array($supportuser->email, fullname($supportuser, true));
$mail->addStringAttachment('Error in attachment. User attempted to attach a filename with a unsafe name.', 'error.txt', '8bit', 'text/plain');
} else {
require_once $CFG->libdir . '/filelib.php';
$mimetype = mimeinfo('type', $attachname);
$attachmentpath = $attachment;
// Before doing the comparison, make sure that the paths are correct (Windows uses slashes in the other direction).
$attachpath = str_replace('\\', '/', $attachmentpath);
// Make sure both variables are normalised before comparing.
$temppath = str_replace('\\', '/', realpath($CFG->tempdir));
// If the attachment is a full path to a file in the tempdir, use it as is,
// otherwise assume it is a relative path from the dataroot (for backwards compatibility reasons).
if (strpos($attachpath, $temppath) !== 0) {
$attachmentpath = $CFG->dataroot . '/' . $attachmentpath;
}
$mail->addAttachment($attachmentpath, $attachname, 'base64', $mimetype);
}
}
// Check if the email should be sent in an other charset then the default UTF-8.
if (!empty($CFG->sitemailcharset) || !empty($CFG->allowusermailcharset)) {
// Use the defined site mail charset or eventually the one preferred by the recipient.
$charset = $CFG->sitemailcharset;
if (!empty($CFG->allowusermailcharset)) {
if ($useremailcharset = get_user_preferences('mailcharset', '0', $user->id)) {
$charset = $useremailcharset;
}
}
// Convert all the necessary strings if the charset is supported.
$charsets = get_list_of_charsets();
unset($charsets['UTF-8']);
if (in_array($charset, $charsets)) {
$mail->CharSet = $charset;
$mail->FromName = core_text::convert($mail->FromName, 'utf-8', strtolower($charset));
$mail->Subject = core_text::convert($mail->Subject, 'utf-8', strtolower($charset));
$mail->Body = core_text::convert($mail->Body, 'utf-8', strtolower($charset));
$mail->AltBody = core_text::convert($mail->AltBody, 'utf-8', strtolower($charset));
foreach ($temprecipients as $key => $values) {
$temprecipients[$key][1] = core_text::convert($values[1], 'utf-8', strtolower($charset));
}
foreach ($tempreplyto as $key => $values) {
$tempreplyto[$key][1] = core_text::convert($values[1], 'utf-8', strtolower($charset));
}
}
}
foreach ($temprecipients as $values) {
$mail->addAddress($values[0], $values[1]);
}
foreach ($tempreplyto as $values) {
$mail->addReplyTo($values[0], $values[1]);
}
if ($mail->send()) {
set_send_count($user);
if (!empty($mail->SMTPDebug)) {
echo '</pre>';
}
return true;
} else {
// Trigger event for failing to send email.
$event = \core\event\email_failed::create(array('context' => context_system::instance(), 'userid' => $from->id, 'relateduserid' => $user->id, 'other' => array('subject' => $subject, 'message' => $messagetext, 'errorinfo' => $mail->ErrorInfo)));
$event->trigger();
if (CLI_SCRIPT) {
mtrace('Error: lib/moodlelib.php email_to_user(): ' . $mail->ErrorInfo);
}
if (!empty($mail->SMTPDebug)) {
echo '</pre>';
}
return false;
}
}
开发者ID:lucaboesch,项目名称:moodle,代码行数:101,代码来源:moodlelib.php
示例2: useredit_shared_definition
function useredit_shared_definition(&$mform, $editoroptions = null)
{
global $CFG, $USER, $DB;
$user = $DB->get_record('user', array('id' => $USER->id));
useredit_load_preferences($user, false);
$strrequired = get_string('required');
$nameordercheck = new stdClass();
$nameordercheck->firstname = 'a';
$nameordercheck->lastname = 'b';
if (fullname($nameordercheck) == 'b a') {
// See MDL-4325
$mform->addElement('text', 'lastname', get_string('lastname'), 'maxlength="100" size="30"');
$mform->addElement('text', 'firstname', get_string('firstname'), 'maxlength="100" size="30"');
} else {
$mform->addElement('text', 'firstname', get_string('firstname'), 'maxlength="100" size="30"');
$mform->addElement('text', 'lastname', get_string('lastname'), 'maxlength="100" size="30"');
}
$mform->addRule('firstname', $strrequired, 'required', null, 'client');
$mform->setType('firstname', PARAM_NOTAGS);
$mform->addRule('lastname', $strrequired, 'required', null, 'client');
$mform->setType('lastname', PARAM_NOTAGS);
// Do not show email field if change confirmation is pending
if (!empty($CFG->emailchangeconfirmation) and !empty($user->preference_newemail)) {
$notice = get_string('emailchangepending', 'auth', $user);
$notice .= '<br /><a href="edit.php?cancelemailchange=1&id=' . $user->id . '">' . get_string('emailchangecancel', 'auth') . '</a>';
$mform->addElement('static', 'emailpending', get_string('email'), $notice);
} else {
$mform->addElement('text', 'email', get_string('email'), 'maxlength="100" size="30"');
$mform->addRule('email', $strrequired, 'required', null, 'client');
}
$choices = array();
$choices['0'] = get_string('emaildisplayno');
$choices['1'] = get_string('emaildisplayyes');
$choices['2'] = get_string('emaildisplaycourse');
$mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices);
$mform->setDefault('maildisplay', 2);
$choices = array();
$choices['0'] = get_string('textformat');
$choices['1'] = get_string('htmlformat');
$mform->addElement('select', 'mailformat', get_string('emailformat'), $choices);
$mform->setDefault('mailformat', 1);
if (!empty($CFG->allowusermailcharset)) {
$choices = array();
$charsets = get_list_of_charsets();
if (!empty($CFG->sitemailcharset)) {
$choices['0'] = get_string('site') . ' (' . $CFG->sitemailcharset . ')';
} else {
$choices['0'] = get_string('site') . ' (UTF-8)';
}
$choices = array_merge($choices, $charsets);
$mform->addElement('select', 'preference_mailcharset', get_string('emailcharset'), $choices);
}
$choices = array();
$choices['0'] = get_string('emaildigestoff');
$choices['1'] = get_string('emaildigestcomplete');
$choices['2'] = get_string('emaildigestsubjects');
$mform->addElement('select', 'maildigest', get_string('emaildigest'), $choices);
$mform->setDefault('maildigest', 0);
$choices = array();
$choices['1'] = get_string('autosubscribeyes');
$choices['0'] = get_string('autosubscribeno');
$mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices);
$mform->setDefault('autosubscribe', 1);
if (!empty($CFG->forum_trackreadposts)) {
$choices = array();
$choices['0'] = get_string('trackforumsno');
$choices['1'] = get_string('trackforumsyes');
$mform->addElement('select', 'trackforums', get_string('trackforums'), $choices);
$mform->setDefault('trackforums', 0);
}
$editors = editors_get_enabled();
if (count($editors) > 1) {
$choices = array();
$choices['0'] = get_string('texteditor');
$choices['1'] = get_string('htmleditor');
$mform->addElement('select', 'htmleditor', get_string('textediting'), $choices);
$mform->setDefault('htmleditor', 1);
} else {
$mform->addElement('hidden', 'htmleditor');
$mform->setDefault('htmleditor', 1);
$mform->setType('htmleditor', PARAM_INT);
}
if (empty($CFG->enableajax)) {
$mform->addElement('static', 'ajaxdisabled', get_string('ajaxuse'), get_string('ajaxno'));
} else {
$choices = array();
$choices['0'] = get_string('ajaxno');
$choices['1'] = get_string('ajaxyes');
$mform->addElement('select', 'ajax', get_string('ajaxuse'), $choices);
$mform->setDefault('ajax', 0);
}
$choices = array();
$choices['0'] = get_string('screenreaderno');
$choices['1'] = get_string('screenreaderyes');
$mform->addElement('select', 'screenreader', get_string('screenreaderuse'), $choices);
$mform->setDefault('screenreader', 0);
$mform->addHelpButton('screenreader', 'screenreaderuse');
$mform->addElement('text', 'city', get_string('city'), 'maxlength="120" size="21"');
$mform->setType('city', PARAM_MULTILANG);
$mform->addRule('city', $strrequired, 'required', null, 'client');
//.........这里部分代码省略.........
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:101,代码来源:editlib.php
示例3: config_form
/**
* Creates necessary fields in the messaging config form.
*
* @param array $preferences An array of user preferences
*/
function config_form($preferences)
{
global $USER, $OUTPUT, $CFG;
$string = '';
$choices = array();
$choices['0'] = get_string('textformat');
$choices['1'] = get_string('htmlformat');
$current = $preferences->mailformat;
$string .= $OUTPUT->container(html_writer::label(get_string('emailformat'), 'mailformat'));
$string .= $OUTPUT->container(html_writer::select($choices, 'mailformat', $current, false, array('id' => 'mailformat')));
$string .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'userid', 'value' => $USER->id));
if (!empty($CFG->allowusermailcharset)) {
$choices = array();
$charsets = get_list_of_charsets();
if (!empty($CFG->sitemailcharset)) {
$choices['0'] = get_string('site') . ' (' . $CFG->sitemailcharset . ')';
} else {
$choices['0'] = get_string('site') . ' (UTF-8)';
}
$choices = array_merge($choices, $charsets);
$current = $preferences->mailcharset;
$string .= $OUTPUT->container(html_writer::label(get_string('emailcharset'), 'mailcharset'));
$string .= $OUTPUT->container(html_writer::select($choices, 'preference_mailcharset', $current, false, array('id' => 'mailcharset')));
}
if (!empty($CFG->messagingallowemailoverride)) {
$inputattributes = array('size' => '30', 'name' => 'email_email', 'value' => $preferences->email_email, 'id' => 'email_email');
$string .= html_writer::label(get_string('email', 'message_email'), 'email_email');
$string .= $OUTPUT->container(html_writer::empty_tag('input', $inputattributes));
if (empty($preferences->email_email) && !empty($preferences->userdefaultemail)) {
$string .= $OUTPUT->container(get_string('ifemailleftempty', 'message_email', $preferences->userdefaultemail));
}
if (!empty($preferences->email_email) && !validate_email($preferences->email_email)) {
$string .= $OUTPUT->container(get_string('invalidemail'), 'error');
}
$string .= '<br/>';
}
return $string;
}
开发者ID:dg711,项目名称:moodle,代码行数:43,代码来源:message_output_email.php
示例4: email_to_user
//.........这里部分代码省略.........
}
$mail->Subject = substr($subject, 0, 900);
$temprecipients[] = array($user->email, fullname($user));
// Set word wrap.
$mail->WordWrap = $wordwrapwidth;
if (!empty($from->customheaders)) {
// Add custom headers.
if (is_array($from->customheaders)) {
foreach ($from->customheaders as $customheader) {
$mail->addCustomHeader($customheader);
}
} else {
$mail->addCustomHeader($from->customheaders);
}
}
if (!empty($from->priority)) {
$mail->Priority = $from->priority;
}
if ($messagehtml && !empty($user->mailformat) && $user->mailformat == 1) {
// Don't ever send HTML to users who don't want it.
$mail->isHTML(true);
$mail->Encoding = 'quoted-printable';
$mail->Body = $messagehtml;
$mail->AltBody = "\n{$messagetext}\n";
} else {
$mail->IsHTML(false);
$mail->Body = "\n{$messagetext}\n";
}
if ($attachment && $attachname) {
if (preg_match("~\\.\\.~", $attachment)) {
// Security check for ".." in dir path.
$temprecipients[] = array($supportuser->email, fullname($supportuser, true));
$mail->addStringAttachment('Error in attachment. User attempted to attach a filename with a unsafe name.', 'error.txt', '8bit', 'text/plain');
} else {
require_once $CFG->libdir . '/filelib.php';
$mimetype = mimeinfo('type', $attachname);
$attachmentpath = $attachment;
// Before doing the comparison, make sure that the paths are correct (Windows uses slashes in the other direction).
$attachpath = str_replace('\\', '/', $attachmentpath);
// Make sure both variables are normalised before comparing.
$temppath = str_replace('\\', '/', $CFG->tempdir);
// If the attachment is a full path to a file in the tempdir, use it as is,
// otherwise assume it is a relative path from the dataroot (for backwards compatibility reasons).
if (strpos($attachpath, realpath($temppath)) !== 0) {
$attachmentpath = $CFG->dataroot . '/' . $attachmentpath;
}
$mail->addAttachment($attachmentpath, $attachname, 'base64', $mimetype);
}
}
// Check if the email should be sent in an other charset then the default UTF-8.
if (!empty($CFG->sitemailcharset) || !empty($CFG->allowusermailcharset)) {
// Use the defined site mail charset or eventually the one preferred by the recipient.
$charset = $CFG->sitemailcharset;
if (!empty($CFG->allowusermailcharset)) {
if ($useremailcharset = get_user_preferences('mailcharset', '0', $user->id)) {
$charset = $useremailcharset;
}
}
// Convert all the necessary strings if the charset is supported.
$charsets = get_list_of_charsets();
unset($charsets['UTF-8']);
if (in_array($charset, $charsets)) {
$mail->CharSet = $charset;
$mail->FromName = core_text::convert($mail->FromName, 'utf-8', strtolower($charset));
$mail->Subject = core_text::convert($mail->Subject, 'utf-8', strtolower($charset));
$mail->Body = core_text::convert($mail->Body, 'utf-8', strtolower($charset));
$mail->AltBody = core_text::convert($mail->AltBody, 'utf-8', strtolower($charset));
foreach ($temprecipients as $key => $values) {
$temprecipients[$key][1] = core_text::convert($values[1], 'utf-8', strtolower($charset));
}
foreach ($tempreplyto as $key => $values) {
$tempreplyto[$key][1] = core_text::convert($values[1], 'utf-8', strtolower($charset));
}
}
}
foreach ($temprecipients as $values) {
$mail->addAddress($values[0], $values[1]);
}
foreach ($tempreplyto as $values) {
$mail->addReplyTo($values[0], $values[1]);
}
if ($mail->send()) {
set_send_count($user);
if (!empty($mail->SMTPDebug)) {
echo '</pre>';
}
return true;
} else {
// Trigger event for failing to send email.
$event = \core\event\email_failed::create(array('context' => context_system::instance(), 'userid' => $from->id, 'relateduserid' => $user->id, 'other' => array('subject' => $subject, 'message' => $messagetext, 'errorinfo' => $mail->ErrorInfo)));
$event->trigger();
if (CLI_SCRIPT) {
mtrace('Error: lib/moodlelib.php email_to_user(): ' . $mail->ErrorInfo);
}
if (!empty($mail->SMTPDebug)) {
echo '</pre>';
}
return false;
}
}
开发者ID:riawarra,项目名称:moodle,代码行数:101,代码来源:moodlelib.php
示例5: email_to_user
//.........这里部分代码省略.........
} else {
$mail->From = $CFG->noreplyaddress;
$mail->FromName = fullname($from);
if (empty($replyto)) {
$tempreplyto[] = array($CFG->noreplyaddress, get_string('noreplyname'));
}
}
}
if (!empty($replyto)) {
$tempreplyto[] = array($replyto, $replytoname);
}
$mail->Subject = substr($subject, 0, 900);
$temprecipients[] = array($user->email, fullname($user));
$mail->WordWrap = $wordwrapwidth;
// set word wrap
if (!empty($from->customheaders)) {
// Add custom headers
if (is_array($from->customheaders)) {
foreach ($from->customheaders as $customheader) {
$mail->AddCustomHeader($customheader);
}
} else {
$mail->AddCustomHeader($from->customheaders);
}
}
if (!empty($from->priority)) {
$mail->Priority = $from->priority;
}
if ($messagehtml && !empty($user->mailformat) && $user->mailformat == 1) {
// Don't ever send HTML to users who don't want it
$mail->IsHTML(true);
$mail->Encoding = 'quoted-printable';
// Encoding to use
$mail->Body = $messagehtml;
$mail->AltBody = "\n{$messagetext}\n";
} else {
$mail->IsHTML(false);
$mail->Body = "\n{$messagetext}\n";
}
if ($attachment && $attachname) {
if (preg_match("~\\.\\.~", $attachment)) {
// Security check for ".." in dir path
$temprecipients[] = array($supportuser->email, fullname($supportuser, true));
$mail->AddStringAttachment('Error in attachment. User attempted to attach a filename with a unsafe name.', 'error.txt', '8bit', 'text/plain');
} else {
require_once $CFG->libdir . '/filelib.php';
$mimetype = mimeinfo('type', $attachname);
$mail->AddAttachment($CFG->dataroot . '/' . $attachment, $attachname, 'base64', $mimetype);
}
}
// Check if the email should be sent in an other charset then the default UTF-8
if (!empty($CFG->sitemailcharset) || !empty($CFG->allowusermailcharset)) {
// use the defined site mail charset or eventually the one preferred by the recipient
$charset = $CFG->sitemailcharset;
if (!empty($CFG->allowusermailcharset)) {
if ($useremailcharset = get_user_preferences('mailcharset', '0', $user->id)) {
$charset = $useremailcharset;
}
}
// convert all the necessary strings if the charset is supported
$charsets = get_list_of_charsets();
unset($charsets['UTF-8']);
if (in_array($charset, $charsets)) {
$textlib = textlib_get_instance();
$mail->CharSet = $charset;
$mail->FromName = $textlib->convert($mail->FromName, 'utf-8', strtolower($charset));
$mail->Subject = $textlib->convert($mail->Subject, 'utf-8', strtolower($charset));
$mail->Body = $textlib->convert($mail->Body, 'utf-8', strtolower($charset));
$mail->AltBody = $textlib->convert($mail->AltBody, 'utf-8', strtolower($charset));
foreach ($temprecipients as $key => $values) {
$temprecipients[$key][1] = $textlib->convert($values[1], 'utf-8', strtolower($charset));
}
foreach ($tempreplyto as $key => $values) {
$tempreplyto[$key][1] = $textlib->convert($values[1], 'utf-8', strtolower($charset));
}
}
}
foreach ($temprecipients as $values) {
$mail->AddAddress($values[0], $values[1]);
}
foreach ($tempreplyto as $values) {
$mail->AddReplyTo($values[0], $values[1]);
}
if ($mail->Send()) {
set_send_count($user);
$mail->IsSMTP();
// use SMTP directly
if (!empty($mail->SMTPDebug)) {
echo '</pre>';
}
return true;
} else {
mtrace('ERROR: ' . $mail->ErrorInfo);
add_to_log(SITEID, 'library', 'mailer', $FULLME, 'ERROR: ' . $mail->ErrorInfo);
if (!empty($mail->SMTPDebug)) {
echo '</pre>';
}
return false;
}
}
开发者ID:hitphp,项目名称:moodle,代码行数:101,代码来源:moodlelib.php
示例6: email_to_user
//.........这里部分代码省略.........
if (empty($replyto)) {
$mail->AddReplyTo($CFG->noreplyaddress, get_string('noreplyname'));
}
}
}
if (!empty($replyto)) {
$mail->AddReplyTo($replyto, $replytoname);
}
$mail->Subject = substr(stripslashes($subject), 0, 900);
$mail->AddAddress(stripslashes($user->email), fullname($user));
$mail->WordWrap = $wordwrapwidth;
// set word wrap
if (!empty($from->customheaders)) {
// Add custom headers
if (is_array($from->customheaders)) {
foreach ($from->customheaders as $customheader) {
$mail->AddCustomHeader($customheader);
}
} else {
$mail->AddCustomHeader($from->customheaders);
}
}
if (!empty($from->priority)) {
$mail->Priority = $from->priority;
}
if ($messagehtml && $user->mailformat == 1) {
// Don't ever send HTML to users who don't want it
$mail->IsHTML(true);
$mail->Encoding = 'quoted-printable';
// Encoding to use
$mail->Body = $messagehtml;
$mail->AltBody = "\n{$messagetext}\n";
} else {
$mail->IsHTML(false);
$mail->Body = "\n{$messagetext}\n";
}
if ($attachment && $attachname) {
if (ereg("\\.\\.", $attachment)) {
// Security check for ".." in dir path
$mail->AddAddress($supportuser->email, fullname($supportuser, true));
$mail->AddStringAttachment('Error in attachment. User attempted to attach a filename with a unsafe name.', 'error.txt', '8bit', 'text/plain');
} else {
require_once $CFG->libdir . '/filelib.php';
$mimetype = mimeinfo('type', $attachname);
$mail->AddAttachment($CFG->dataroot . '/' . $attachment, $attachname, 'base64', $mimetype);
}
}
/// If we are running under Unicode and sitemailcharset or allowusermailcharset are set, convert the email
/// encoding to the specified one
if (!empty($CFG->sitemailcharset) || !empty($CFG->allowusermailcharset)) {
/// Set it to site mail charset
$charset = $CFG->sitemailcharset;
/// Overwrite it with the user mail charset
if (!empty($CFG->allowusermailcharset)) {
if ($useremailcharset = get_user_preferences('mailcharset', '0', $user->id)) {
$charset = $useremailcharset;
}
}
/// If it has changed, convert all the necessary strings
$charsets = get_list_of_charsets();
unset($charsets['UTF-8']);
if (in_array($charset, $charsets)) {
/// Save the new mail charset
$mail->CharSet = $charset;
/// And convert some strings
$mail->FromName = $textlib->convert($mail->FromName, 'utf-8', $mail->CharSet);
//From Name
foreach ($mail->ReplyTo as $key => $rt) {
//ReplyTo Names
$mail->ReplyTo[$key][1] = $textlib->convert($rt[1], 'utf-8', $mail->CharSet);
}
$mail->Subject = $textlib->convert($mail->Subject, 'utf-8', $mail->CharSet);
//Subject
foreach ($mail->to as $key => $to) {
$mail->to[$key][1] = $textlib->convert($to[1], 'utf-8', $mail->CharSet);
//To Names
}
$mail->Body = $textlib->convert($mail->Body, 'utf-8', $mail->CharSet);
//Body
$mail->AltBody = $textlib->convert($mail->AltBody, 'utf-8', $mail->CharSet);
//Subject
}
}
if ($mail->Send()) {
set_send_count($user);
$mail->IsSMTP();
// use SMTP directly
if (!empty($mail->SMTPDebug)) {
echo '</pre>';
}
return true;
} else {
mtrace('ERROR: ' . $mail->ErrorInfo);
add_to_log(SITEID, 'library', 'mailer', $FULLME, 'ERROR: ' . $mail->ErrorInfo);
if (!empty($mail->SMTPDebug)) {
echo '</pre>';
}
return false;
}
}
开发者ID:nadavkav,项目名称:rtlMoodle,代码行数:101,代码来源:moodlelib.php
示例7: useredit_shared_definition
function useredit_shared_definition(&$mform, $editoroptions = null, $filemanageroptions = null)
{
global $CFG, $USER, $DB;
$user = $DB->get_record('user', array('id' => $USER->id));
useredit_load_preferences($user, false);
$strrequired = get_string('required');
// Add the necessary names.
foreach (useredit_get_required_name_fields() as $fullname) {
$mform->addElement('text', $fullname, get_string($fullname), 'maxlength="100" size="30"');
$mform->addRule($fullname, $strrequired, 'required', null, 'client');
$mform->setType($fullname, PARAM_NOTAGS);
}
$enabledusernamefields = useredit_get_enabled_name_fields();
// Add the enabled additional name fields.
foreach ($enabledusernamefields as $addname) {
$mform->addElement('text', $addname, get_string($addname), 'maxlength="100" size="30"');
$mform->setType($addname, PARAM_NOTAGS);
}
// Do not show email field if change confirmation is pending
if (!empty($CFG->emailchangeconfirmation) and !empty($user->preference_newemail)) {
$notice = get_string('emailchangepending', 'auth', $user);
$notice .= '<br /><a href="edit.php?cancelemailchange=1&id=' . $user->id . '">' . get_string('emailchangecancel', 'auth') . '</a>';
$mform->addElement('static', 'emailpending', get_string('email'), $notice);
} else {
$mform->addElement('text', 'email', get_string('email'), 'maxlength="100" size="30"');
$mform->addRule('email', $strrequired, 'required', null, 'client');
$mform->setType('email', PARAM_EMAIL);
}
$choices = array();
$choices['0'] = get_string('emaildisplayno');
$choices['1'] = get_string('emaildisplayyes');
$choices['2'] = get_string('emaildisplaycourse');
$mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices);
$mform->setDefault('maildisplay', 2);
$choices = array();
$choices['0'] = get_string('textformat');
$choices['1'] = get_string('htmlformat');
$mform->addElement('select', 'mailformat', get_string('emailformat'), $choices);
$mform->setDefault('mailformat', 1);
if (!empty($CFG->allowusermailcharset)) {
$choices = array();
$charsets = get_list_of_charsets();
if (!empty($CFG->sitemailcharset)) {
$choices['0'] = get_string('site') . ' (' . $CFG->sitemailcharset . ')';
} else {
$choices['0'] = get_string('site') . ' (UTF-8)';
}
$choices = array_merge($choices, $charsets);
$mform->addElement('select', 'preference_mailcharset', get_string('emailcharset'), $choices);
}
$choices = array();
$choices['0'] = get_string('emaildigestoff');
$choices['1'] = get_string('emaildigestcomplete');
$choices['2'] = get_string('emaildigestsubjects');
$mform->addElement('select', 'maildigest', get_string('emaildigest'), $choices);
$mform->setDefault('maildigest', 0);
$mform->addHelpButton('maildigest', 'emaildigest');
$choices = array();
$choices['1'] = get_string('autosubscribeyes');
$choices['0'] = get_string('autosubscribeno');
$mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices);
$mform->setDefault('autosubscribe', 1);
if (!empty($CFG->forum_trackreadposts)) {
$choices = array();
$choices['0'] = get_string('trackforumsno');
$choices['1'] = get_string('trackforumsyes');
$mform->addElement('select', 'trackforums', get_string('trackforums'), $choices);
$mform->setDefault('trackforums', 0);
}
$editors = editors_get_enabled();
if (count($editors) > 1) {
$choices = array('' => get_string('defaulteditor'));
$firsteditor = '';
foreach (array_keys($editors) as $editor) {
if (!$firsteditor) {
$firsteditor = $editor;
}
$choices[$editor] = get_string('pluginname', 'editor_' . $editor);
}
$mform->addElement('select', 'preference_htmleditor', get_string('textediting'), $choices);
$mform->setDefault('preference_htmleditor', '');
} else {
// Empty string means use the first chosen text editor.
$mform->addElement('hidden', 'preference_htmleditor');
$mform->setDefault('preference_htmleditor', '');
$mform->setType('preference_htmleditor', PARAM_PLUGIN);
}
$mform->addElement('text', 'city', get_string('city'), 'maxlength="120" size="21"');
$mform->setType('city', PARAM_TEXT);
if (!empty($CFG->defaultcity)) {
$mform->setDefault('city', $CFG->defaultcity);
}
$choices = get_string_manager()->get_list_of_countries();
$choices = array('' => get_string('selectacountry') . '...') + $choices;
$mform->addElement('select', 'country', get_string('selectacountry'), $choices);
if (!empty($CFG->country)) {
$mform->setDefault('country', $CFG->country);
}
$choices = get_list_of_timezones();
$choices['99'] = get_string('serverlocaltime');
//.........这里部分代码省略.........
开发者ID:helenagarcia90,项目名称:moodle,代码行数:101,代码来源:editlib.php
示例8: useredit_shared_definition
function useredit_shared_definition(&$mform)
{
global $CFG, $USER;
$user = get_record('user', 'id', $USER->id);
useredit_load_preferences($user, false);
$strrequired = get_string('required');
$nameordercheck = new object();
$nameordercheck->firstname = 'a';
$nameordercheck->lastname = 'b';
if (fullname($nameordercheck) == 'b a') {
// See MDL-4325
$mform->addElement('text', 'lastname', get_string('lastname'), 'maxlength="100" size="30"');
$mform->addElement('text', 'firstname', get_string('firstname'), 'maxlength="100" size="30"');
} else {
$mform->addElement('text', 'firstname', get_string('firstname'), 'maxlength="100" size="30"');
$mform->addElement('text', 'lastname', get_string('lastname'), 'maxlength="100" size="30"');
}
$mform->addRule('firstname', $strrequired, 'required', null, 'client');
$mform->setType('firstname', PARAM_NOTAGS);
$mform->addRule('lastname', $strrequired, 'required', null, 'client');
$mform->setType('lastname', PARAM_NOTAGS);
// Do not show email field if change confirmation is pending
if ($CFG->emailchangeconfirmation && !empty($user->preference_newemail)) {
$notice = get_string('auth_emailchangepending', 'auth', $user);
$notice .= '<br /><a href="edit.php?cancelemailchange=1&id=' . $user->id . '">' . get_string('auth_emailchangecancel', 'auth') . '</a>';
$mform->addElement('static', 'emailpending', get_string('email'), $notice);
} else {
$mform->addElement('text', 'email', get_string('email'), 'maxlength="100" size="30"');
$mform->addRule('email', $strrequired, 'required', null, 'client');
}
$choices = array();
$choices['0'] = get_string('emaildisplayno');
$choices['1'] = get_string('emaildisplayyes');
$choices['2'] = get_string('emaildisplaycourse');
$mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices);
$mform->setDefault('maildisplay', 2);
$choices = array();
$choices['0'] = get_string('emailenable');
$choices['1'] = get_string('emaildisable');
$mform->addElement('select', 'emailstop', get_string('emailactive'), $choices);
$mform->setDefault('emailenable', 1);
$choices = array();
$choices['0'] = get_string('textformat');
$choices['1'] = get_string('htmlformat');
$mform->addElement('select', 'mailformat', get_string('emailformat'), $choices);
$mform->setDefault('mailformat', 1);
$mform->setAdvanced('mailformat');
if (!empty($CFG->allowusermailcharset)) {
$choices = array();
$charsets = get_list_of_charsets();
if (!empty($CFG->sitemailcharset)) {
$choices['0'] = get_string('site') . ' (' . $CFG->sitemailcharset . ')';
} else {
$choices['0'] = get_string('site') . ' (UTF-8)';
}
$choices = array_merge($choices, $charsets);
$mform->addElement('select', 'preference_mailcharset', get_string('emailcharset'), $choices);
$mform->setAdvanced('preference_mailcharset');
}
$choices = array();
$choices['0'] = get_string('emaildigestoff');
$choices['1'] = get_string('emaildigestcomplete');
$choices['2'] = get_string('emaildigestsubjects');
$mform->addElement('select', 'maildigest', get_string('emaildigest'), $choices);
$mform->setDefault('maildigest', 0);
$mform->setAdvanced('maildigest');
$choices = array();
$choices['1'] = get_string('autosubscribeyes');
$choices['0'] = get_string('autosubscribeno');
$mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices);
$mform->setDefault('autosubscribe', 1);
$mform->setAdvanced('autosubscribe');
if (!empty($CFG->forum_trackreadposts)) {
$choices = array();
$choices['0'] = get_string('trackforumsno');
$choices['1'] = get_string('trackforumsyes');
$mform->addElement('select', 'trackforums', get_string('trackforums'), $choices);
$mform->setDefault('trackforums', 0);
$mform->setAdvanced('trackforums');
}
if ($CFG->htmleditor) {
$choices = array();
$choices['0'] = get_string('texteditor');
$choices['1'] = get_string('htmleditor');
$mform->addElement('select', 'htmleditor', get_string('textediting'), $choices);
$mform->setDefault('htmleditor', 1);
$mform->setAdvanced('htmleditor');
}
if (empty($CFG->enableajax)) {
$mform->addElement('static', 'ajaxdisabled', get_string('ajaxuse'), get_string('ajaxno'));
$mform->setAdvanced('ajaxdisabled');
} else {
$choices = array();
$choices['0'] = get_string('ajaxno');
$choices['1'] = get_string('ajaxyes');
$mform->addElement('select', 'ajax', get_string('ajaxuse'), $choices);
$mform->setDefault('ajax', 0);
$mform->setAdvanced('ajax');
}
$choices = array();
//.........这里部分代码省略.........
开发者ID:r007,项目名称:PMoodle,代码行数:101,代码来源:editlib.php
示例9: admin_setting_configtext
// TODO: add path validation
$temp->add(new admin_setting_configtext('pathtodu', get_string('pathtodu', 'admin'), get_string('configpathtodu', 'admin'), '', PARAM_RAW));
// TODO: add path validation
$temp->add(new admin_setting_configtext('aspellpath', get_string('aspellpath', 'admin'), get_string('edhelpaspellpath'), '', PARAM_RAW));
// TODO: add path validation
$ADMIN->add('server', $temp, 0);
// "email" settingpage
$temp = new admin_settingpage('mail', get_string('mail', 'admin'));
$temp->add(new admin_setting_configtext('smtphosts', get_string('smtphosts', 'admin'), get_string('configsmtphosts', 'admin'), '', PARAM_HOST));
$temp->add(new admin_setting_configtext('smtpuser', get_string('smtpuser', 'admin'), get_string('configsmtpuser', 'admin'), '', PARAM_NOTAGS));
$temp->add(new admin_setting_configpasswordunmask('smtppass', get_string('smtppass', 'admin'), get_string('configsmtpuser', 'admin'), '', PARAM_RAW));
$temp->add(new admin_setting_configtext('noreplyaddress', get_string('noreplyaddress', 'admin'), get_string('confignoreplyaddress', 'admin'), 'noreply@' . $_SERVER['HTTP_HOST'], PARAM_NOTAGS));
$temp->add(new admin_setting_configtext('allowemailaddresses', get_string('allowemailaddresses', 'admin'), get_string('configallowemailaddresses', 'admin'), '', PARAM_NOTAGS));
$temp->add(new admin_setting_configtext('denyemailaddresses', get_string('denyemailaddresses', 'admin'), get_string('configdenyemailaddresses', 'admin'), '', PARAM_NOTAGS));
$temp->add(new admin_setting_configselect('digestmailtime', get_string('digestmailtime', 'admin'), get_string('configdigestmailtime', 'admin'), 17, array('00' => '00', '01' => '01', '02' => '02', '03' => '03', '04' => '04', '05' => '05', '06' => '06', '07' => '07', '08' => '08', '09' => '09', '10' => '10', '11' => '11', '12' => '12', '13' => '13', '14' => '14', '15' => '15', '16' => '16', '17' => '17', '18' => '18', '19' => '19', '20' => '20', '21' => '21', '22' => '22', '23' => '23')));
$charsets = get_list_of_charsets();
unset($charsets['UTF-8']);
// not needed here
$options = array();
$options['0'] = get_string('none');
$options = array_merge($options, $charsets);
$temp->add(new admin_setting_configselect('sitemailcharset', get_string('sitemailcharset', 'admin'), get_string('configsitemailcharset', 'admin'), '', $options));
$temp->add(new admin_setting_configcheckbox('allowusermailcharset', get_string('allowusermailcharset', 'admin'), get_string('configallowusermailcharset', 'admin'), 0));
if (isloggedin()) {
global $USER;
$primaryadminemail = $USER->email;
$primaryadminname = fullname($USER, true);
} else {
// no defaults during installation - admin user must be created first
$primaryadminemail = NULL;
$primaryadminname = NULL;
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:31,代码来源:server.php
示例10: useredit_shared_definition_preferences
/**
* Adds user preferences elements to user edit form.
*
* @param stdClass $user
* @param moodleform $mform
* @param array|null $editoroptions
* @param array|null $filemanageroptions
*/
function useredit_shared_definition_preferences($user, &$mform, $editoroptions = null, $filemanageroptions = null)
{
global $CFG;
$choices = array();
$choices['0'] = get_string('emaildisplayno');
$choices['1'] = get_string('emaildisplayyes');
$choices['2'] = get_string('emaildisplaycourse');
$mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices);
$mform->setDefault('maildisplay', $CFG->defaultpreference_maildisplay);
$choices = array();
$choices['0'] = get_string('textformat');
$choices['1'] = get_string('htmlformat');
$mform->addElement('select', 'mailformat', get_string('emailformat'), $choices);
$mform->setDefault('mailformat', $CFG->defaultpreference_mailformat);
if (!empty($CFG->allowusermailcharset)) {
$choices = array();
$charsets = get_list_of_charsets();
if (!empty($CFG->sitemailcharset)) {
$choices['0'] = get_string('site') . ' (' . $CFG->sitemailcharset . ')';
} else {
$choices['0'] = get_string('site') . ' (UTF-8)';
}
$choices = array_merge($choices, $charsets);
$mform->addElement('select', 'preference_mailcharset', get_string('emailcharset'), $choices);
}
$choices = array();
$choices['0'] = get_string('emaildigestoff');
$choices['1'] = get_string('emaildigestcomplete');
$choices['2'] = get_string('emaildigestsubjects');
$mform->addElement('select', 'maildigest', get_string('emaildigest'), $choices);
$mform->setDefault('maildigest', $CFG->defaultpreference_maildigest);
$mform->addHelpButton('maildigest', 'emaildigest');
$choices = array();
$choices['1'] = get_string('autosubscribeyes');
$choices['0'] = get_string('autosubscribeno');
$mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices);
$mform->setDefault('autosubscribe', $CFG->defaultpreference_autosubscribe);
if (!empty($CFG->forum_trackreadposts)) {
$choices = array();
$choices['0'] = get_string('trackforumsno');
$choices['1'] = get_string('trackforumsyes');
$mform->addElement('select', 'trackforums', get_string('trackforums'), $choices);
$mform->setDefault('trackforums', $CFG->defaultpreference_trackforums);
}
$editors = editors_get_enabled();
if (count($editors) > 1) {
$choices = array('' => get_string('defaulteditor'));
$firsteditor = '';
foreach (array_keys($editors) as $editor) {
if (!$firsteditor) {
$firsteditor = $editor;
}
$choices[$editor] = get_string('pluginname', 'editor_' . $editor);
}
$mform->addElement('select', 'preference_htmleditor', get_string('textediting'), $choices);
$mform->setDefault('preference_htmleditor', '');
} else {
// Empty string means use the first chosen text editor.
$mform->addElement('hidden', 'preference_htmleditor');
$mform->setDefault('preference_htmleditor', '');
$mform->setType('preference_htmleditor', PARAM_PLUGIN);
}
$mform->addElement('select', 'lang', get_string('preferredlanguage'), get_string_manager()->get_list_of_translations());
$mform->setDefault('lang', $CFG->lang);
}
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:73,代码来源:editlib.php
示例11: email_to_user
//.........这里部分代码省略.........
if (empty($replyto)) {
$mail->AddReplyTo($CFG->noreplyaddress, get_string('noreplyname'));
}
}
}
if (!empty($replyto)) {
$mail->AddReplyTo($replyto, $replytoname);
}
$mail->Subject = substr(stripslashes($subject), 0, 900);
$mail->AddAddress($user->email, fullname($user));
$mail->WordWrap = 79;
// set word wrap
if (!empty($from->customheaders)) {
// Add custom headers
if (is_array($from->customheaders)) {
foreach ($from->customheaders as $customheader) {
$mail->AddCustomHeader($customheader);
}
} else {
$mail->AddCustomHeader($from->customheaders);
}
}
if (!empty($from->priority)) {
$mail->Priority = $from->priority;
}
if ($messagehtml && $user->mailformat == 1) {
// Don't ever send HTML to users who don't want it
$mail->IsHTML(true);
$mail->Encoding = 'quoted-printable';
// Encoding to use
$mail->Body = $messagehtml;
$mail->AltBody = "\n{$messagetext}\n";
} else {
$mail->IsHTML(false);
$mail->Body = "\n{$messagetext}\n";
}
if ($attachment && $attachname) {
if (ereg("\\.\\.", $attachment)) {
// Security check for ".." in dir path
$mail->AddAddress($supportuser->email, fullname($supportuser, true));
$mail->AddStringAttachment('Error in attachment. User attempted to attach a filename with a unsafe name.', 'error.txt', '8bit', 'text/plain');
} else {
require_once $CFG->libdir . '/filelib.php';
$mimetype = mimeinfo('type', $attachname);
$mail->AddAttachment($CFG->dataroot . '/' . $attachment, $attachname, 'base64', $mimetype);
}
}
/// If we are running under Unicode and sitemailcharset or allowusermailcharset are set, convert the email
/// encoding to the specified one
if (!empty($CFG->sitemailcharset) || !empty($CFG->allowusermailcharset)) {
/// Set it to site mail charset
$charset = $CFG->sitemailcharset;
/// Overwrite it with the user mail charset
if (!empty($CFG->allowusermailcharset)) {
if ($useremailcharset = get_user_preferences('mailcharset', '0', $user->id)) {
$charset = $useremailcharset;
}
}
/// If it has changed, convert all the necessary strings
$charsets = get_list_of_charsets();
unset($charsets['UTF-8']);
if (in_array($charset, $charsets)) {
/// Save the new mail charset
$mail->CharSet = $charset;
/// And convert some strings
$mail->FromName = $textlib->convert($mail->FromName, 'utf-8', $mail->CharSet);
//From Name
foreach ($mail->ReplyTo as $key => $rt) {
//ReplyTo Names
$mail->ReplyTo[$key][1] = $textlib->convert($rt, 'utf-8', $mail->CharSet);
}
$mail->Subject = $textlib->convert($mail->Subject, 'utf-8', $mail->CharSet);
//Subject
foreach ($mail->to as $key => $to) {
$mail->to[$key][1] = $textlib->convert($to, 'utf-8', $mail->CharSet);
//To Names
}
$mail->Body = $textlib->convert($mail->Body, 'utf-8', $mail->CharSet);
//Body
$mail->AltBody = $textlib->convert($mail->AltBody, 'utf-8', $mail->CharSet);
//Subject
}
}
if ($mail->Send()) {
set_send_count($user);
$mail->IsSMTP();
// use SMTP directly
if (!empty($CFG->debugsmtp)) {
echo '</pre>';
}
return true;
} else {
mtrace('ERROR: ' . $mail->ErrorInfo);
add_to_log(SITEID, 'library', 'mailer', $FULLME, 'ERROR: ' . $mail->ErrorInfo);
if (!empty($CFG->debugsmtp)) {
echo '</pre>';
}
return false;
}
}
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:101,代码来源:moodlelib.php
|
请发表评论