本文整理汇总了PHP中message_post_message函数的典型用法代码示例。如果您正苦于以下问题:PHP message_post_message函数的具体用法?PHP message_post_message怎么用?PHP message_post_message使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了message_post_message函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: scheduleexam_update_instance
/**
* @method scheduleexam_update_instance
* @todo Update existing exam.
* @param object $scheduledexam Contains all the details to edit an existing exam
* @return int Updated instance ID
*/
function scheduleexam_update_instance($tool) {
global $DB, $USER;
//$DB->update_record('local_scheduledexams', $tool);
$ures = $DB->update_record('local_scheduledexams', $tool);
$sql = "SELECT * FROM {local_user_clclasses} WHERE classid={$tool->classid}";
$users = $DB->get_records_sql($sql);
foreach ($users as $user) {
$conf = new object();
$conf->username = $DB->get_field('user', 'username', array('id' => $user->userid));
$conf->classname = $DB->get_field('local_clclasses', 'fullname', array('id' => $tool->classid));
$message = get_string('msg_stu_exam', 'local_scheduleexam', $conf);
$userfrom = $DB->get_record('user', array('id' => $USER->id));
$userto = $DB->get_record('user', array('id' => $user->userid));
$message_post_message = message_post_message($userfrom, $userto, $message, FORMAT_HTML);
}
return $ures;
}
示例2: get_string
// We are not a contact!
$messageerror = get_string('userisblockingyounoncontact', 'message');
}
}
if (empty($messageerror)) {
$mform = new send_form();
$defaultmessage = new stdClass();
$defaultmessage->id = $user2->id;
$defaultmessage->message = '';
//Check if the current user has sent a message
$data = $mform->get_data();
if (!empty($data) && !empty($data->message)) {
if (!confirm_sesskey()) {
print_error('invalidsesskey');
}
$messageid = message_post_message($user1, $user2, $data->message, FORMAT_PLAIN, 'direct');
if (!empty($messageid)) {
redirect($CFG->wwwroot . '/message/index.php?usergroup=' . $usergroup . '&id=' . $user2->id);
}
}
}
}
$strmessages = get_string('messages', 'message');
if (!empty($user2)) {
$user2fullname = fullname($user2);
$PAGE->set_title("{$strmessages}: {$user2fullname}");
$PAGE->set_heading("{$strmessages}: {$user2fullname}");
} else {
$PAGE->set_title("{$SITE->shortname}: {$strmessages}");
$PAGE->set_heading("{$SITE->shortname}: {$strmessages}");
}
示例3: require_sesskey
require_sesskey();
$action = optional_param('action', null, PARAM_ALPHA);
$response = null;
switch ($action) {
// Sending a message.
case 'sendmessage':
$userid = required_param('userid', PARAM_INT);
if (empty($userid) || isguestuser($userid) || $userid == $USER->id) {
// Cannot send messags to self, nobody or a guest.
throw new coding_exception('Invalid user to send the message to');
}
$message = required_param('message', PARAM_RAW);
$user2 = core_user::get_user($userid);
// Only attempt to send the message if we have permission to message
// the recipient.
if (message_can_post_message($user2, $USER)) {
$messageid = message_post_message($USER, $user2, $message, FORMAT_MOODLE);
if (!$messageid) {
throw new moodle_exception('errorwhilesendingmessage', 'core_message');
}
} else {
throw new moodle_exception('unabletomessageuser', 'core_message');
}
$response = array();
break;
}
if ($response !== null) {
echo json_encode($response);
exit;
}
throw new coding_exception('Invalid request');
示例4: unassign_users_instance
/**
* @method unassign_users_instance Unassigns the manager to a costcenter
* @param int $id Cost center id
* @param int $userid User ID
*/
public function unassign_users_instance($id, $userid) {
global $DB, $CFG, $USER;
$currenturl = "{$CFG->wwwroot}/local/costcenter/index.php";
$conf = new object();
$conf->username = $DB->get_field('user', 'username', array('id' => $userid));
$conf->costcentername = $DB->get_field('local_costcenter', 'fullname', array('id' => $id));
$delete = $DB->delete_records('local_costcenter_permissions', array('costcenterid' => $id, 'userid' => $userid));
if ($delete) {
$message = get_string('msg_del_reg_schl', 'local_costcenter', $conf);
$userfrom = $DB->get_record('user', array('id' => $USER->id));
$userto = $DB->get_record('user', array('id' => $userid));
$message_post_message = message_post_message($userfrom, $userto, $message, FORMAT_HTML);
$this->set_confirmation(get_string('unassignedsuccess', 'local_costcenter'), $currenturl, array('style' => 'notifysuccess'));
} else {
$this->set_confirmation(get_string('problemunassignedsuccess', 'local_costcenter'), $currenturl, array('style' => 'notifyproblem'));
}
}
示例5: send_instant_messages
/**
* Send private messages from the current USER to other users
*
* @param array $messages An array of message to send.
* @return array
* @since Moodle 2.2
*/
public static function send_instant_messages($messages = array())
{
global $CFG, $USER, $DB;
// Check if messaging is enabled.
if (!$CFG->messaging) {
throw new moodle_exception('disabled', 'message');
}
// Ensure the current user is allowed to run this function
$context = context_system::instance();
self::validate_context($context);
require_capability('moodle/site:sendmessage', $context);
$params = self::validate_parameters(self::send_instant_messages_parameters(), array('messages' => $messages));
//retrieve all tousers of the messages
$receivers = array();
foreach ($params['messages'] as $message) {
$receivers[] = $message['touserid'];
}
list($sqluserids, $sqlparams) = $DB->get_in_or_equal($receivers, SQL_PARAMS_NAMED, 'userid_');
$tousers = $DB->get_records_select("user", "id " . $sqluserids . " AND deleted = 0", $sqlparams);
$blocklist = array();
$contactlist = array();
$sqlparams['contactid'] = $USER->id;
$rs = $DB->get_recordset_sql("SELECT *\n FROM {message_contacts}\n WHERE userid {$sqluserids}\n AND contactid = :contactid", $sqlparams);
foreach ($rs as $record) {
if ($record->blocked) {
// $record->userid is blocking current user
$blocklist[$record->userid] = true;
} else {
// $record->userid have current user as contact
$contactlist[$record->userid] = true;
}
}
$rs->close();
$canreadallmessages = has_capability('moodle/site:readallmessages', $context);
$resultmessages = array();
foreach ($params['messages'] as $message) {
$resultmsg = array();
//the infos about the success of the operation
//we are going to do some checking
//code should match /messages/index.php checks
$success = true;
//check the user exists
if (empty($tousers[$message['touserid']])) {
$success = false;
$errormessage = get_string('touserdoesntexist', 'message', $message['touserid']);
}
//check that the touser is not blocking the current user
if ($success and !empty($blocklist[$message['touserid']]) and !$canreadallmessages) {
$success = false;
$errormessage = get_string('userisblockingyou', 'message');
}
// Check if the user is a contact
//TODO MDL-31118 performance improvement - edit the function so we can pass an array instead userid
$blocknoncontacts = get_user_preferences('message_blocknoncontacts', NULL, $message['touserid']);
// message_blocknoncontacts option is on and current user is not in contact list
if ($success && empty($contactlist[$message['touserid']]) && !empty($blocknoncontacts)) {
// The user isn't a contact and they have selected to block non contacts so this message won't be sent.
$success = false;
$errormessage = get_string('userisblockingyounoncontact', 'message', fullname(core_user::get_user($message['touserid'])));
}
//now we can send the message (at least try)
if ($success) {
//TODO MDL-31118 performance improvement - edit the function so we can pass an array instead one touser object
$success = message_post_message($USER, $tousers[$message['touserid']], $message['text'], external_validate_format($message['textformat']));
}
//build the resultmsg
if (isset($message['clientmsgid'])) {
$resultmsg['clientmsgid'] = $message['clientmsgid'];
}
if ($success) {
$resultmsg['msgid'] = $success;
} else {
// WARNINGS: for backward compatibility we return this errormessage.
// We should have thrown exceptions as these errors prevent results to be returned.
// See http://docs.moodle.org/dev/Errors_handling_in_web_services#When_to_send_a_warning_on_the_server_side .
$resultmsg['msgid'] = -1;
$resultmsg['errormessage'] = $errormessage;
}
$resultmessages[] = $resultmsg;
}
return $resultmessages;
}
示例6: s
echo '<form method="post" action="messageselect.php" style="margin: 0 20px;">
<input type="hidden" name="returnto" value="' . s($returnto) . '" />
<input type="hidden" name="id" value="' . $id . '" />
<input type="hidden" name="format" value="' . $format . '" />
<input type="hidden" name="sesskey" value="' . sesskey() . '" />
';
echo "<h3>" . get_string('previewhtml') . "</h3>";
echo "<div class=\"messagepreview\">\n" . format_text($messagebody, $format) . "\n</div>\n";
echo '<p align="center"><input type="submit" name="send" value="' . get_string('sendmessage', 'message') . '" />' . "\n";
echo '<input type="submit" name="edit" value="' . get_string('update') . '" /></p>';
echo "\n</form>";
} else {
if (!empty($send)) {
$good = 1;
foreach ($SESSION->emailto[$id] as $user) {
$good = $good && message_post_message($USER, $user, $messagebody, $format);
}
if (!empty($good)) {
echo $OUTPUT->heading(get_string('messagedselectedusers'));
unset($SESSION->emailto[$id]);
unset($SESSION->emailselect[$id]);
} else {
echo $OUTPUT->heading(get_string('messagedselectedusersfailed'));
}
echo '<p align="center"><a href="index.php?id=' . $id . '">' . get_string('backtoparticipants') . '</a></p>';
}
}
echo $OUTPUT->footer();
exit;
} else {
echo $OUTPUT->notification(get_string('nousersyet'));
示例7: time
$fromform->school_id = $schoolid;
$fromform->semesterid = $sem->id;
$fromform->programid = $pro_id;
$fromform->notification = 0;
$fromform->requested_date = time();
$fromform->reg_approval = 0;
$fromform->regapproval_date = 0;
$registrar = $DB->get_records_sql("select userid from {local_school_permissions} where roleid = 9 and schoolid = {$fromform->school_id} group by userid");
foreach ($registrar as $reg) {
$registrarid = $reg->userid;
}
$userto = $DB->get_record('user', array('id' => $registrarid));
$userfrom = $DB->get_record('user', array('id' => $USER->id));
$message = get_string('reqidcardsmsg', 'local_request');
if ($DB->insert_record('local_request_idcard', $fromform)) {
message_post_message($userfrom, $userto, $message, FORMAT_HTML);
$conmessage = get_string('requestsubmit', 'local_request');
$options = array('style' => 'notifysuccess');
$hierarchy->set_confirmation($conmessage, $nexturl, $options);
}
}
echo $OUTPUT->header();
$check = $DB->get_record_sql("SELECT * FROM {local_request_idcard} WHERE studentid = {$USER->id} AND reg_approval = 0");
if (!empty($check)) {
$message = get_string('requestiderror', 'local_request');
$options = array('style' => 'notifyproblem');
$hierarchy->set_confirmation($message, $nexturl, $options);
}
echo $OUTPUT->heading(get_string('requisitions_id', 'local_request'));
示例8: test_delete_message
/**
* Test delete_message.
*/
public function test_delete_message()
{
global $DB;
$this->resetAfterTest(true);
$user1 = self::getDataGenerator()->create_user();
$user2 = self::getDataGenerator()->create_user();
$user3 = self::getDataGenerator()->create_user();
$user4 = self::getDataGenerator()->create_user();
// Login as user1.
$this->setUser($user1);
$this->assertEquals(array(), core_message_external::create_contacts(array($user2->id, $user3->id)));
// User user1 does not interchange messages with user3.
$m1to2 = message_post_message($user1, $user2, 'some random text 1', FORMAT_MOODLE);
$m2to3 = message_post_message($user2, $user3, 'some random text 3', FORMAT_MOODLE);
$m3to2 = message_post_message($user3, $user2, 'some random text 4', FORMAT_MOODLE);
$m3to4 = message_post_message($user3, $user4, 'some random text 4', FORMAT_MOODLE);
// Retrieve all messages sent by user2 (they are currently unread).
$lastmessages = message_get_messages($user1->id, $user2->id, 0, false);
// Delete a message not read, as a user from.
$result = core_message_external::delete_message($m1to2, $user1->id, false);
$result = external_api::clean_returnvalue(core_message_external::delete_message_returns(), $result);
$this->assertTrue($result['status']);
$this->assertCount(0, $result['warnings']);
$deletedmessage = $DB->get_record('message', array('id' => $m1to2));
$this->assertNotEquals(0, $deletedmessage->timeuserfromdeleted);
// Try to delete the same message again.
$result = core_message_external::delete_message($m1to2, $user1->id, false);
$result = external_api::clean_returnvalue(core_message_external::delete_message_returns(), $result);
$this->assertFalse($result['status']);
// Try to delete a message that does not belong to me.
try {
$messageid = core_message_external::delete_message($m2to3, $user3->id, false);
$this->fail('Exception expected due invalid messageid.');
} catch (moodle_exception $e) {
$this->assertEquals('You do not have permission to delete this message', $e->errorcode);
}
$this->setUser($user3);
// Delete a message not read, as a user to.
$result = core_message_external::delete_message($m2to3, $user3->id, false);
$result = external_api::clean_returnvalue(core_message_external::delete_message_returns(), $result);
$this->assertTrue($result['status']);
$this->assertCount(0, $result['warnings']);
$deletedmessage = $DB->get_record('message', array('id' => $m2to3));
$this->assertNotEquals(0, $deletedmessage->timeusertodeleted);
// Delete a message read.
$message = $DB->get_record('message', array('id' => $m3to2));
$messageid = message_mark_message_read($message, time());
$result = core_message_external::delete_message($messageid, $user3->id);
$result = external_api::clean_returnvalue(core_message_external::delete_message_returns(), $result);
$this->assertTrue($result['status']);
$this->assertCount(0, $result['warnings']);
$deletedmessage = $DB->get_record('message_read', array('id' => $messageid));
$this->assertNotEquals(0, $deletedmessage->timeuserfromdeleted);
// Invalid message ids.
try {
$result = core_message_external::delete_message(-1, $user1->id);
$this->fail('Exception expected due invalid messageid.');
} catch (dml_missing_record_exception $e) {
$this->assertEquals('invalidrecord', $e->errorcode);
}
// Invalid user.
try {
$result = core_message_external::delete_message($m1to2, -1, false);
$this->fail('Exception expected due invalid user.');
} catch (moodle_exception $e) {
$this->assertEquals('invaliduser', $e->errorcode);
}
// Not active user.
delete_user($user2);
try {
$result = core_message_external::delete_message($m1to2, $user2->id, false);
$this->fail('Exception expected due invalid user.');
} catch (moodle_exception $e) {
$this->assertEquals('userdeleted', $e->errorcode);
}
// Now, as an admin, try to delete any message.
$this->setAdminUser();
$result = core_message_external::delete_message($m3to4, $user4->id, false);
$result = external_api::clean_returnvalue(core_message_external::delete_message_returns(), $result);
$this->assertTrue($result['status']);
$this->assertCount(0, $result['warnings']);
$deletedmessage = $DB->get_record('message', array('id' => $m3to4));
$this->assertNotEquals(0, $deletedmessage->timeusertodeleted);
}
示例9: redirect
$return = $CFG->wwwroot . '/' . $CFG->admin . '/user/user_bulk.php';
if (empty($SESSION->bulk_users)) {
redirect($return);
}
if (empty($CFG->messaging)) {
print_error('messagingdisable', 'error');
}
//TODO: add support for large number of users
if ($confirm and !empty($msg) and confirm_sesskey()) {
list($in, $params) = $DB->get_in_or_equal($SESSION->bulk_users);
$rs = $DB->get_recordset_select('user', "id {$in}", $params);
foreach ($rs as $user) {
//TODO we should probably support all text formats here or only FORMAT_MOODLE
//For now bulk messaging is still using the html editor and its supplying html
//so we have to use html format for it to be displayed correctly
message_post_message($USER, $user, $msg, FORMAT_HTML);
}
$rs->close();
redirect($return);
}
$msgform = new user_message_form('user_bulk_message.php');
if ($msgform->is_cancelled()) {
redirect($return);
} else {
if ($formdata = $msgform->get_data()) {
$options = new stdClass();
$options->para = false;
$options->newlines = true;
$options->smiley = false;
$msg = format_text($formdata->messagebody['text'], $formdata->messagebody['format'], $options);
list($in, $params) = $DB->get_in_or_equal($SESSION->bulk_users);
示例10: tao_handle_message_role_event
/**
* event handler for messaging by role
*/
function tao_handle_message_role_event($eventdata)
{
global $CFG;
require_once $CFG->dirroot . '/local/lib/messagelib.php';
require_once $CFG->dirroot . '/message/lib.php';
if (!($tomessage = tao_message_get_recipients_by_target($eventdata['target'], $eventdata['course'], $eventdata['from']))) {
return true;
// done!
}
$a = (object) array('target' => get_string('messagetarget' . $eventdata['target']->stringkey, 'local'), 'course' => $eventdata['course']->fullname);
if ($eventdata['course']->id == SITEID) {
$footer = get_string('messagelistfooter', 'local', $a);
} else {
$footer = get_string('messagelistfootercourse', 'local', $a);
}
$eventdata['body'] .= '<br /><br />' . $footer;
$fromuser = get_record('user', 'id', $eventdata['from']);
foreach ($tomessage as $user) {
if ($fromuser->id == $user->id) {
continue;
}
message_post_message($fromuser, $user, $eventdata['body'], $eventdata['format'], 'direct');
}
return true;
}
示例11: get_string
//case "2":
//$thistargetstatus = get_string('notachieved', 'ilptarget');
//break;
case "3":
$thistargetstatus = get_string('withdrawn', 'ilptarget');
break;
}
$updatedstatus = get_string('statusupdate', 'ilptarget', $thistargetstatus);
//Sets message details for Targets
$messagefrom = get_record('user', 'id', $USER->id);
$messageto = get_record('user', 'id', $userid);
$targeturl = $CFG->wwwroot . '/mod/ilptarget/target_view.php?' . ($courseid ? 'courseid=' . $courseid . '&' : '') . 'userid=' . $id . '">';
$targetview = get_string('targetviewlink', 'ilptarget');
$updatedstatus = get_string('statusupdate', 'ilptarget', $thistargetstatus);
$message = '<p>' . $updatedstatus . '<br /><a href="' . $targeturl . '&status=' . $status . '">' . $targetview . '</a></p>';
message_post_message($messagefrom, $messageto, $message, FORMAT_HTML, 'direct');
}
}
$mform = new ilptarget_updatetarget_form('', array('userid' => $user->id, 'id' => $id, 'courseid' => $courseid, 'targetpost' => $targetpost, 'linkvalues' => $link_values));
if (!$mform->is_cancelled() && ($fromform = $mform->get_data())) {
$mform->process_data($fromform);
}
if ($action == 'delete') {
//Check to see if we are deleting a comment
$report = get_record('ilptarget_posts', 'id', $targetpost);
delete_records('ilptarget_posts', 'id', $report->id);
delete_records('ilptarget_comments', 'targetpost', $report->id, 'userid', $user->id);
delete_records('event', 'name', $report->name, 'instance', $report->id, 'userid', $user->id);
}
if ($action == 'updatetarget') {
print_heading(get_string('add', 'ilptarget'));
示例12: group_send_invite
function group_send_invite($userid, $fromuserid, $group, $courseid)
{
global $CFG, $COURSE;
if (record_exists('group_invites', 'courseid', $courseid, 'userid', $userid, 'groupid', $group->id)) {
notify(get_string('invitealready', 'block_tao_team_groups'));
} else {
$invite = new stdclass();
$invite->courseid = $courseid;
$invite->userid = $userid;
$invite->fromuserid = $fromuserid;
$invite->groupid = $group->id;
$invite->timemodified = time();
insert_record('group_invites', $invite);
//now send e-mail
$sendto = get_record('user', 'id', $userid);
$sendfrom = get_record('user', 'id', $fromuserid);
$a = new stdclass();
$a->firstname = $sendto->firstname;
$a->group = $group->name;
$a->course = $COURSE->fullname;
$a->link = '<a href="' . $CFG->wwwroot . "/course/view.php?id={$courseid}" . '">' . $CFG->wwwroot . "/course/view.php?id={$courseid}</a>";
message_post_message($sendfrom, $sendto, addslashes(get_string('inviteemailbody', 'block_tao_team_groups', $a)), FORMAT_HTML, 'direct');
notify(get_string('invitesent', 'block_tao_team_groups'), 'notifysuccess');
}
}
示例13: process_data
function process_data($data)
{
global $USER, $CFG;
require_once "{$CFG->dirroot}/message/lib.php";
$courseid = $this->_customdata['courseid'];
$userid = $this->_customdata['userid'];
$id = $this->_customdata['id'];
$concernspost = $this->_customdata['concernspost'];
$commentid = $this->_customdata['commentid'];
//Sets message details for comments
$messagefrom = get_record('user', 'id', $USER->id);
$messageto = get_record('user', 'id', $userid);
$newcomment = get_string('newcomment', 'ilpconcern');
$updatedcomment = get_string('updatedcomment', 'ilpconcern');
$concernview = get_string('concernviewlink', 'ilpconcern');
$commenturl = $CFG->wwwroot . '/mod/ilpconcern/concerns_comments.php?' . ($courseid != SITEID ? 'courseid=' . $courseid . '&' : '') . '&concernspost=' . $concernspost;
if (!($report = get_record('ilpconcern_comments', 'concernspost', $concernspost, 'id', $commentid))) {
$report = new Object();
$report->concernspost = $concernspost;
$report->userid = $USER->id;
$report->created = time();
$report->modified = time();
$report->comment = $data->comment;
$report->format = $data->format;
$commentinstance = insert_record('ilpconcern_comments', $report, true);
$message = '<p>' . $newcomment;
} else {
$report->userid = $USER->id;
$report->comment = $data->comment;
$report->format = $data->format;
$report->modified = time();
$commentinstance = update_record('ilpconcern_comments', $report);
$message = '<p>' . $updatedcomment;
}
if ($CFG->ilpconcern_send_comment_message == 1) {
$message .= '<br /><a href="' . $commenturl . '">' . $concernview . '</a></p>' . $comment;
message_post_message($messagefrom, $messageto, $message, FORMAT_HTML, 'direct');
}
}
示例14: stdClass
$reportstaburl = !empty($reportsviewtab) ? "&selectedtab={$reportsviewtab->id}&tabitem={$reportsviewtab->id}:{$report->id}" : "";
$message = new stdClass();
$message->component = 'block_ilp';
$message->name = 'ilp_comment';
$message->subject = get_string('newreportcomment', 'block_ilp', $report);
$message->userfrom = $dbc->get_user_by_id($USER->id);
$message->userto = $dbc->get_user_by_id($entry->user_id);
$message->fullmessage = get_string('newreportcomment', 'block_ilp', $report);
$message->fullmessageformat = FORMAT_PLAIN;
$message->contexturl = $CFG->wwwroot . "/blocks/ilp/actions/view_main.php?user_id={$entry->user_id}{$reportstaburl}";
$message->contexturlname = get_string('viewreport', 'block_ilp');
if (stripos($CFG->release, "2.") !== false) {
message_send($message);
} else {
require_once $CFG->dirroot . '/message/lib.php';
message_post_message($message->userfrom, $message->userto, $message->fullmessage, $message->fullmessageformat, 'direct');
}
}
$return_url = $CFG->wwwroot . "/blocks/ilp/actions/view_main.php?user_id={$user_id}&selectedtab={$selectedtab}&tabitem={$tabitem}&course_id={$course_id}";
redirect($return_url, get_string("commentcreationsuc", 'block_ilp'), ILP_REDIRECT_DELAY);
}
}
}
if (!empty($comment_id)) {
$comment = $dbc->get_comment_by_id($comment_id);
if (!empty($comment)) {
//only the creator has the right to edit
if ($comment->creator_id == $USER->id) {
//set the form values to the current comment
$mform->set_data($comment);
} else {
示例15: s
echo '<form method="post" action="messageselect.php" style="margin: 0 20px;">
<input type="hidden" name="returnto" value="' . s($returnto) . '" />
<input type="hidden" name="id" value="' . $id . '" />
<input type="hidden" name="format" value="' . $format . '" />
<input type="hidden" name="sesskey" value="' . sesskey() . '" />
';
echo "<h3>" . get_string('previewhtml') . "</h3>";
echo "<div class=\"messagepreview\">\n" . format_text($messagebody, $format) . "\n</div>\n";
echo '<p align="center"><input type="submit" name="send" value="' . get_string('sendmessage', 'message') . '" />' . "\n";
echo '<input type="submit" name="edit" value="' . get_string('update') . '" /></p>';
echo "\n</form>";
} else {
if (!empty($send)) {
$fails = array();
foreach ($SESSION->emailto[$id] as $user) {
if (!message_post_message($USER, $user, $messagebody, $format)) {
$user->fullname = fullname($user);
$fails[] = get_string('messagedselecteduserfailed', 'moodle', $user);
}
}
if (empty($fails)) {
echo $OUTPUT->heading(get_string('messagedselectedusers'));
unset($SESSION->emailto[$id]);
unset($SESSION->emailselect[$id]);
} else {
echo $OUTPUT->heading(get_string('messagedselectedcountusersfailed', 'moodle', count($fails)));
echo '<ul>';
foreach ($fails as $f) {
echo '<li>', $f, '</li>';
}
echo '</ul>';