Skip to content

Commit

Permalink
MDL-13572 message: added validation of the email address in the messa…
Browse files Browse the repository at this point in the history
…ging preferences
  • Loading branch information
andyjdavis committed Dec 14, 2011
1 parent 01f7f6f commit 925d068
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions message/output/email/message_output_email.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,19 @@ function send_message($eventdata) {
* @param object $mform preferences form class
*/
function config_form($preferences){
global $USER;
$string = get_string('email','message_email').': <input size="30" name="email_email" value="'.$preferences->email_email.'" />';
global $USER, $OUTPUT;

$inputattributes = array('size'=>'30', 'name'=>'email_email', 'value'=>$preferences->email_email);
$string = get_string('email','message_email') . ': ' . html_writer::empty_tag('input', $inputattributes);

if (empty($preferences->email_email) && !empty($preferences->userdefaultemail)) {
$string .= ' ('.get_string('default').': '.$preferences->userdefaultemail.')';
}

if (!empty($preferences->email_email) && !validate_email($preferences->email_email)) {
$string .= $OUTPUT->container(get_string('invalidemail'), 'error');
}

return $string;
}

Expand Down

0 comments on commit 925d068

Please sign in to comment.