//TODO: add support for large number of users if ($confirm and !empty($msg) and confirm_sesskey()) { $in = implode(',', $SESSION->bulk_users); if ($rs = $DB->get_recordset_select('user', "id IN ({$in})", null)) { foreach ($rs as $user) { message_post_message($USER, $user, $msg, FORMAT_HTML, 'direct'); } $rs->close(); } redirect($return); } // disable html editor if not enabled in preferences if (!get_user_preferences('message_usehtmleditor', 0)) { $CFG->htmleditor = ''; } $msgform = new user_message_form('user_bulk_message.php'); if ($msgform->is_cancelled()) { redirect($return); } else { if ($formdata = $msgform->get_data()) { $options = new object(); $options->para = false; $options->newlines = true; $options->smiley = false; $msg = format_text($formdata->messagebody, $formdata->format, $options); $in = implode(',', $SESSION->bulk_users); $userlist = $DB->get_records_select_menu('user', "id IN ({$in})", null, 'fullname', 'id,' . $DB->sql_fullname() . ' AS fullname'); $usernames = implode(', ', $userlist); $optionsyes = array(); $optionsyes['confirm'] = 1; $optionsyes['sesskey'] = sesskey();