Hi.
In my modified addstamp.ph for Moodle 2.2, E-mail notification is sent out regardless of whether the student has turned email notifications on or off in his Email notification settings in the Messaging section. I can't find a way to NOT send an E-mail notification if the student does not want to receive an email stating that so-and-so has given him a stamp.
In Moodle 1.9, if the student were to disable his account, he would not receive any E-mail notification from the awarding of a stamp. Now, how do I implement this for Moodle 2.2? Here's my code:
//E-mail notification!
$user = $DB->get_record('user', array('id' => $data->userto));
$subjectOfMsg = $USER->firstname." ".$USER->lastname."'s just given you a NEW STAMP in ".$course->shortname;
$success = email_to_user($user, $USER, $subjectOfMsg, $data->text);
if ($success == "1")
{
echo "E-mail successful sent to ".$user->firstname." ".$user->lastname."!";
} else if ($success == "emailstop") {
echo "E-mail of ".$user->firstname." ".$user->lastname." has been DISABLED!"
.'
E-mail NOT sent';
} else if (!$success){
echo "Error: E-mail unsuccessful.";
}
//email end