本文整理汇总了PHP中MessageManager::send_message方法的典型用法代码示例。如果您正苦于以下问题:PHP MessageManager::send_message方法的具体用法?PHP MessageManager::send_message怎么用?PHP MessageManager::send_message使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessageManager
的用法示例。
在下文中一共展示了MessageManager::send_message方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: switch
/* For licensing terms, see /license.txt */
/**
* Responses to AJAX calls
*/
//require_once '../global.inc.php';
$action = $_GET['a'];
switch ($action) {
case 'send_message':
$subject = isset($_REQUEST['subject']) ? trim($_REQUEST['subject']) : null;
$messageContent = isset($_REQUEST['content']) ? trim($_REQUEST['content']) : null;
if (empty($subject) || empty($messageContent)) {
echo Display::display_error_message(get_lang('ErrorSendingMessage'));
exit;
}
$result = MessageManager::send_message($_REQUEST['user_id'], $subject, $messageContent);
if ($result) {
echo Display::display_confirmation_message(get_lang('MessageHasBeenSent'));
} else {
echo Display::display_error_message(get_lang('ErrorSendingMessage'));
}
break;
case 'send_invitation':
$subject = isset($_REQUEST['subject']) ? trim($_REQUEST['subject']) : null;
$invitationContent = isset($_REQUEST['content']) ? trim($_REQUEST['content']) : null;
SocialManager::send_invitation_friend_user($_REQUEST['user_id'], $subject, $invitationContent);
break;
case 'find_users':
if (api_is_anonymous()) {
echo '';
break;
示例2: suscribe_users_to_session
/**
* Subscribes users (students) to the given session and optionally (default) unsubscribes previous users
* @author Carlos Vargas from existing code
* @param integer Session ID
* @param array List of user IDs
* @param bool Whether to unsubscribe existing users (true, default) or not (false)
* @return void Nothing, or false on error
**/
public static function suscribe_users_to_session($id_session, $user_list, $session_visibility = SESSION_VISIBLE_READ_ONLY, $empty_users = true, $send_email = false)
{
if ($id_session != strval(intval($id_session))) {
return false;
}
foreach ($user_list as $intUser) {
if ($intUser != strval(intval($intUser))) {
return false;
}
}
$tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$session_info = api_get_session_info($id_session);
if ($session_info) {
$session_name = $session_info['name'];
} else {
return false;
}
//from function parameter
if (empty($session_visibility)) {
$session_visibility = $session_info['visibility'];
//loaded from DB
//default status loaded if empty
if (empty($session_visibility)) {
$session_visibility = SESSION_VISIBLE_READ_ONLY;
}
// by default readonly 1
} else {
if (!in_array($session_visibility, array(SESSION_VISIBLE_READ_ONLY, SESSION_VISIBLE, SESSION_INVISIBLE))) {
$session_visibility = SESSION_VISIBLE_READ_ONLY;
}
}
$sql = "SELECT id_user FROM {$tbl_session_rel_course_rel_user} WHERE id_session = '{$id_session}' AND status = 0";
$result = Database::query($sql);
$existingUsers = array();
while ($row = Database::fetch_array($result)) {
$existingUsers[] = $row['id_user'];
}
$sql = "SELECT c_id FROM {$tbl_session_rel_course} WHERE id_session = '{$id_session}'";
$result = Database::query($sql);
$course_list = array();
while ($row = Database::fetch_array($result)) {
$course_list[] = $row['c_id'];
}
if ($send_email) {
//sending emails only
if (is_array($user_list) && count($user_list) > 0) {
foreach ($user_list as $user_id) {
if (!in_array($user_id, $existingUsers)) {
$subject = '[' . get_setting('siteName') . '] ' . get_lang('YourReg') . ' ' . get_setting('siteName');
$user_info = api_get_user_info($user_id);
$content = get_lang('Dear') . " " . stripslashes($user_info['complete_name']) . ",\n\n" . sprintf(get_lang('YouAreRegisterToSessionX'), $session_name) . " \n\n" . get_lang('Address') . " " . api_get_setting('siteName') . " " . get_lang('Is') . " : " . api_get_path(WEB_PATH) . "\n\n" . get_lang('Problem') . "\n\n" . get_lang('Formula') . ",\n\n" . get_setting('administratorName') . " " . get_setting('administratorSurname') . "\n" . get_lang('Manager') . " " . get_setting('siteName') . "\nT. " . get_setting('administratorTelephone') . "\n" . get_lang('Email') . " : " . get_setting('emailAdministrator');
MessageManager::send_message($user_id, $subject, $content, array(), array(), null, null, null, null, null);
}
}
}
}
foreach ($course_list as $courseId) {
// for each course in the session
$nbr_users = 0;
$courseId = Database::escape_string($courseId);
// delete existing users
if ($empty_users) {
foreach ($existingUsers as $existing_user) {
if (!in_array($existing_user, $user_list)) {
$sql = "DELETE FROM {$tbl_session_rel_course_rel_user} WHERE id_session='{$id_session}' AND c_id ='{$courseId}' AND id_user='{$existing_user}' AND status = 0";
$result = Database::query($sql);
if (Database::affected_rows($result)) {
$nbr_users--;
}
}
}
}
//Replace with this new function
//
// insert new users into session_rel_course_rel_user and ignore if they already exist
foreach ($user_list as $enreg_user) {
if (!in_array($enreg_user, $existingUsers)) {
$enreg_user = Database::escape_string($enreg_user);
$insert_sql = "INSERT IGNORE INTO {$tbl_session_rel_course_rel_user}(id_session, c_id, id_user, visibility, status) VALUES('{$id_session}','{$courseId}','{$enreg_user}','{$session_visibility}', '0')";
$result = Database::query($insert_sql);
if (Database::affected_rows($result)) {
$nbr_users++;
}
}
}
// count users in this session-course relation
$sql = "SELECT COUNT(id_user) as nbUsers FROM {$tbl_session_rel_course_rel_user} WHERE id_session='{$id_session}' AND c_id ='{$courseId}' AND status<>2";
$rs = Database::query($sql);
list($nbr_users) = Database::fetch_array($rs);
//.........这里部分代码省略.........
示例3: isset
$user_list = isset($_POST['invitation']) ? $_POST['invitation'] : null;
$group_id = intval($_POST['id']);
if (!is_array($user_list)) {
$user_list = array();
}
if ($form_sent == 1) {
// invite this users
$result = $usergroup->add_users_to_groups($user_list, array($group_id), GROUP_USER_PERMISSION_PENDING_INVITATION);
$title = get_lang('YouAreInvitedToGroup') . ' ' . $group_info['name'];
$content = get_lang('YouAreInvitedToGroupContent') . ' ' . $group_info['name'] . ' <br />';
$content .= get_lang('ToSubscribeClickInTheLinkBelow') . ' <br />';
$content .= '<a href="' . api_get_path(WEB_CODE_PATH) . 'social/invitations.php?accept=' . $group_id . '">' . get_lang('Subscribe') . '</a>';
if (is_array($user_list) && count($user_list) > 0) {
//send invitation message
foreach ($user_list as $user_id) {
$result = MessageManager::send_message($user_id, $title, $content);
}
Display::addFlash(Display::return_message(get_lang('InvitationSent')));
}
header('Location: ' . api_get_self() . '?id=' . $group_id);
exit;
}
}
$nosessionUsersList = $sessionUsersList = array();
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
$friends = SocialManager::get_friends(api_get_user_id());
$suggest_friends = false;
$Users = array();
if (!$friends) {
$suggest_friends = true;
} else {
示例4: send_invitation_mail
/**
* Send the invitation by mail.
*
* @param int invitedUser - the userId (course user) or emailaddress of additional user
* $param string $invitation_code - the unique invitation code for the URL
* @return void
*/
public static function send_invitation_mail($invitedUser, $invitation_code, $invitation_title, $invitation_text)
{
$_user = api_get_user_info();
$_course = api_get_course_info();
// Replacing the **link** part with a valid link for the user
$survey_link = api_get_path(WEB_CODE_PATH) . 'survey/fillsurvey.php?course=' . $_course['code'] . '&invitationcode=' . $invitation_code;
$text_link = '<a href="' . $survey_link . '">' . get_lang('ClickHereToAnswerTheSurvey') . "</a><br />\r\n<br />\r\n" . get_lang('OrCopyPasteTheFollowingUrl') . " <br />\r\n " . $survey_link;
$replace_count = 0;
$full_invitation_text = api_str_ireplace('**link**', $text_link, $invitation_text, $replace_count);
if ($replace_count < 1) {
$full_invitation_text = $full_invitation_text . "<br />\r\n<br />\r\n" . $text_link;
}
// Sending the mail
$sender_name = api_get_person_name($_user['firstName'], $_user['lastName'], null, PERSON_NAME_EMAIL_ADDRESS);
$sender_email = $_user['mail'];
$sender_user_id = api_get_user_id();
$replyto = array();
if (api_get_setting('survey.survey_email_sender_noreply') == 'noreply') {
$noreply = api_get_setting('mail.noreply_email_address');
if (!empty($noreply)) {
$replyto['Reply-to'] = $noreply;
$sender_name = $noreply;
$sender_email = $noreply;
$sender_user_id = null;
}
}
// Optionally: finding the e-mail of the course user
if (is_numeric($invitedUser)) {
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$sql = "SELECT firstname, lastname, email FROM {$table_user}\n WHERE user_id='" . Database::escape_string($invitedUser) . "'";
$result = Database::query($sql);
$row = Database::fetch_array($result);
$recipient_email = $row['email'];
$recipient_name = api_get_person_name($row['firstname'], $row['lastname'], null, PERSON_NAME_EMAIL_ADDRESS);
MessageManager::send_message($invitedUser, $invitation_title, $full_invitation_text, [], [], null, null, null, null, $sender_user_id);
} else {
/** @todo check if the address is a valid email */
$recipient_email = $invitedUser;
@api_mail_html($recipient_name, $recipient_email, $invitation_title, $full_invitation_text, $sender_name, $sender_email, $replyto);
}
}
示例5: send_message_simple
/**
* @param int $receiver_user_id
* @param int $subject
* @param string $message
* @param int $sender_id
* @param bool $sendCopyToDrhUsers send copy to related DRH users
* @param bool $directMessage
*
* @return bool
*/
public static function send_message_simple($receiver_user_id, $subject, $message, $sender_id = null, $sendCopyToDrhUsers = false, $directMessage = false)
{
$result = MessageManager::send_message($receiver_user_id, $subject, $message, null, null, null, null, null, null, $sender_id, $directMessage);
if ($sendCopyToDrhUsers) {
$userInfo = api_get_user_info($receiver_user_id);
$drhList = UserManager::getDrhListFromUser($receiver_user_id);
if (!empty($drhList)) {
foreach ($drhList as $drhInfo) {
$message = sprintf(get_lang('CopyOfMessageSentToXUser'), $userInfo['complete_name']) . ' <br />' . $message;
MessageManager::send_message_simple($drhInfo['user_id'], $subject, $message, $sender_id, false, $directMessage);
}
}
}
return $result;
}
示例6: send_message_simple
/**
* A handy way to send message
*/
public static function send_message_simple($receiver_user_id, $subject, $htmlBody, $sender_id = null, $textBody = null)
{
return MessageManager::send_message($receiver_user_id, $subject, $htmlBody, null, null, null, null, null, null, $sender_id, $textBody);
}
示例7: get_lang
$emailbody = get_lang('ApprovalForNewAccount', null, $values['language']) . "\n";
$emailbody .= get_lang('UserName', null, $values['language']) . ': ' . $values['username'] . "\n";
if (api_is_western_name_order()) {
$emailbody .= get_lang('FirstName', null, $values['language']) . ': ' . $values['firstname'] . "\n";
$emailbody .= get_lang('LastName', null, $values['language']) . ': ' . $values['lastname'] . "\n";
} else {
$emailbody .= get_lang('LastName', null, $values['language']) . ': ' . $values['lastname'] . "\n";
$emailbody .= get_lang('FirstName', null, $values['language']) . ': ' . $values['firstname'] . "\n";
}
$emailbody .= get_lang('Email', null, $values['language']) . ': ' . $values['email'] . "\n";
$emailbody .= get_lang('Status', null, $values['language']) . ': ' . $values['status'] . "\n\n";
$url_edit = Display::url(api_get_path(WEB_CODE_PATH) . 'admin/user_edit.php?user_id=' . $user_id, api_get_path(WEB_CODE_PATH) . 'admin/user_edit.php?user_id=' . $user_id);
$emailbody .= get_lang('ManageUser', null, $values['language']) . ": {$url_edit}";
$admins = UserManager::get_all_administrators();
foreach ($admins as $admin_info) {
MessageManager::send_message($admin_info['user_id'], $emailsubject, $emailbody, null, null, null, null, null, null, $user_id);
}
// 3. exit the page
unset($user_id);
Display::display_header($tool_name);
echo Display::page_header($tool_name);
echo $content;
Display::display_footer();
exit;
}
}
}
// Terms & Conditions
if (api_get_setting('registration.allow_terms_conditions') == 'true') {
// Update the terms & conditions.
if (isset($values['legal_accept_type'])) {
示例8: send_mail
/**
* This function sends the mails for the mail notification
*
* @param array
* @param array
* @return void
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version february 2006, dokeos 1.8
*/
function send_mail($user_info = array(), $thread_information = array())
{
$_course = api_get_course_info();
$user_id = api_get_user_id();
$subject = get_lang('NewForumPost') . ' - ' . $_course['official_code'];
if (isset($thread_information) && is_array($thread_information)) {
$thread_link = api_get_path(WEB_CODE_PATH) . 'forum/viewthread.php?' . api_get_cidreq() . '&forum=' . $thread_information['forum_id'] . '&thread=' . $thread_information['thread_id'];
}
$email_body = get_lang('Dear') . ' ' . api_get_person_name($user_info['firstname'], $user_info['lastname'], null, PERSON_NAME_EMAIL_ADDRESS) . ", <br />\n\r";
$email_body .= get_lang('NewForumPost') . "\n";
$email_body .= get_lang('Course') . ': ' . $_course['name'] . ' - [' . $_course['official_code'] . "] - <br />\n";
$email_body .= get_lang('YouWantedToStayInformed') . "<br />\n";
$email_body .= get_lang('ThreadCanBeFoundHere') . " : <br /><a href=\"" . $thread_link . "\">" . $thread_link . "</a>\n";
if ($user_info['user_id'] != $user_id) {
MessageManager::send_message($user_info['user_id'], $subject, $email_body, null, null, null, null, null, null, $user_id);
}
}
示例9: urldecode
$title = urldecode($info_reply[0]);
$content = str_replace("\\", "", urldecode($info_reply[1]));
$user_reply = $info_reply[2];
$user_email_base = str_replace(')', '(', $info_reply[5]);
$user_email_prepare = explode('(', $user_email_base);
if (count($user_email_prepare) == 1) {
$user_email = trim($user_email_prepare[0]);
} elseif (count($user_email_prepare) == 3) {
$user_email = trim($user_email_prepare[1]);
}
$user_id_by_email = MessageManager::get_user_id_by_email($user_email);
if ($info_reply[6] == 'save_form') {
$user_id_by_email = $info_reply[2];
}
if (isset($user_reply) && !is_null($user_id_by_email) && strlen($info_reply[0]) > 0) {
MessageManager::send_message($user_id_by_email, $title, $content);
Display::addFlash(MessageManager::return_message($user_id_by_email, 'confirmation'));
$social_right_content .= MessageManager::inbox_display();
exit;
} elseif (is_null($user_id_by_email)) {
$message_box = get_lang('ErrorSendingMessage');
Display::return_message(api_xml_http_response_encode($message_box), 'error');
$social_right_content .= MessageManager::inbox_display();
exit;
}
} elseif (trim($info_delete[0]) == 'delete') {
for ($i = 1; $i <= $count_delete; $i++) {
MessageManager::delete_message_by_user_receiver(api_get_user_id(), $info_delete[$i]);
}
$message_box = get_lang('SelectedMessagesDeleted');
Display::return_message(api_xml_http_response_encode($message_box));
示例10: send_invitation_friend_user
/**
* Sends invitations to friends
* @author Isaac Flores Paz <isaac.flores.paz@gmail.com>
* @author Julio Montoya <gugli100@gmail.com> Cleaning code
* @param void
* @return string message invitation
*/
public static function send_invitation_friend_user($userfriend_id, $subject_message = '', $content_message = '')
{
global $charset;
$user_info = api_get_user_info($userfriend_id);
$succes = get_lang('MessageSentTo');
$succes .= ' : ' . api_get_person_name($user_info['firstName'], $user_info['lastName']);
if (isset($subject_message) && isset($content_message) && isset($userfriend_id)) {
$send_message = MessageManager::send_message($userfriend_id, $subject_message, $content_message);
if ($send_message) {
Display::addFlash(Display::display_confirmation_message($succes, true, true));
} else {
Display::addFlash(Display::display_error_message(get_lang('ErrorSendingMessage'), true, true));
}
return false;
} elseif (isset($userfriend_id) && !isset($subject_message)) {
$count_is_true = false;
if (isset($userfriend_id) && $userfriend_id > 0) {
$message_title = get_lang('Invitation');
$count_is_true = self::send_invitation_friend(api_get_user_id(), $userfriend_id, $message_title, $content_message);
if ($count_is_true) {
Display::addFlash(Display::display_confirmation_message(api_htmlentities(get_lang('InvitationHasBeenSent'), ENT_QUOTES, $charset), false, true));
} else {
Display::addFlash(Display::display_warning_message(api_htmlentities(get_lang('YouAlreadySentAnInvitation'), ENT_QUOTES, $charset), false, true));
}
}
}
}
示例11: send_message_simple
/**
* A handy way to send message
*/
public static function send_message_simple($receiver_user_id, $subject, $message, $sender_id = null)
{
return MessageManager::send_message($receiver_user_id, $subject, $message, null, null, null, null, null, null, $sender_id);
}
示例12: send_reminder_users_without_publication
/**
* Send reminder to users who have not given the task
*
* @param int
* @return array
* @author cvargas carlos.vargas@beeznest.com cfasanando, christian.fasanado@beeznest.com
*/
function send_reminder_users_without_publication($task_data)
{
global $_course;
$task_id = $task_data['id'];
$task_title = !empty($task_data['title']) ? $task_data['title'] : basename($task_data['url']);
$subject = '[' . api_get_setting('siteName') . '] ';
// The body can be as long as you wish, and any combination of text and variables
$content = get_lang('ReminderToSubmitPendingTask')."\n".get_lang('CourseName').' : '.$_course['name']."\n";
$content .= get_lang('WorkName').' : '.$task_title."\n";
$list_users = get_list_users_without_publication($task_id);
$mails_sent_to = array();
foreach ($list_users as $user) {
$name_user = api_get_person_name($user[1], $user[0], null, PERSON_NAME_EMAIL_ADDRESS);
$dear_line = get_lang('Dear')." ".api_get_person_name($user[1], $user[0]) .", \n\n";
$body = $dear_line.$content;
MessageManager::send_message($user[3], $subject, $body);
$mails_sent_to[] = $name_user;
}
return $mails_sent_to;
}
示例13: send_notifications
/**
* Get all the users who need to receive a notification of a new post (those subscribed to
* the forum or the thread)
*
* @param integer $forum_id the id of the forum
* @param integer $thread_id the id of the thread
* @param integer $post_id the id of the post
* @return bool
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
* @version May 2008, dokeos 1.8.5
* @since May 2008, dokeos 1.8.5
*/
function send_notifications($forum_id = 0, $thread_id = 0, $post_id = 0)
{
global $_user;
$_course = api_get_course_info();
// The content of the mail
$thread_link = api_get_path(WEB_CODE_PATH) . 'forum/viewthread.php?' . api_get_cidreq() . '&forum=' . $forum_id . '&thread=' . $thread_id;
// Users who subscribed to the forum
if ($forum_id != 0) {
$users_to_be_notified_by_forum = get_notifications('forum', $forum_id);
} else {
return false;
}
$current_thread = get_thread_information($thread_id);
$current_forum = get_forum_information($current_thread['forum_id']);
$subject = get_lang('NewForumPost') . ' - ' . $_course['official_code'] . ' - ' . $current_forum['forum_title'] . ' - ' . $current_thread['thread_title'];
// User who subscribed to the thread
if ($thread_id != 0) {
$users_to_be_notified_by_thread = get_notifications('thread', $thread_id);
}
// Merging the two
$users_to_be_notified = array_merge($users_to_be_notified_by_forum, $users_to_be_notified_by_thread);
$sender_id = api_get_user_id();
if (is_array($users_to_be_notified)) {
foreach ($users_to_be_notified as $value) {
if ($value['email'] != $_user['email']) {
$user_info = api_get_user_info($value['user_id']);
$email_body = get_lang('Dear') . ' ' . api_get_person_name($user_info['firstname'], $user_info['lastname'], null, PERSON_NAME_EMAIL_ADDRESS) . ", <br />\n\r";
$email_body .= get_lang('NewForumPost') . ": " . $current_forum['forum_title'] . ' - ' . $current_thread['thread_title'] . " <br />\n";
$email_body .= get_lang('Course') . ': ' . $_course['name'] . ' - [' . $_course['official_code'] . "] <br />\n";
$email_body .= get_lang('YouWantedToStayInformed') . "<br />\n";
$email_body .= get_lang('ThreadCanBeFoundHere') . ': <br /> <a href="' . $thread_link . '">' . $thread_link . "</a>\n";
MessageManager::send_message($value['user_id'], $subject, $email_body, null, null, null, null, null, null, $sender_id);
}
}
}
}
示例14: array
<?php
/* For licensing terms, see /license.txt */
/**
* Responses to AJAX calls
*/
$language_file = array('messages', 'userInfo');
require_once '../global.inc.php';
$action = $_GET['a'];
switch ($action) {
case 'send_message':
$result = MessageManager::send_message($_REQUEST['user_id'], $_REQUEST['subject'], $_REQUEST['content']);
if ($result) {
echo Display::display_confirmation_message(get_lang('MessageHasBeenSent'));
} else {
echo Display::display_error_message(get_lang('ErrorSendingMessage'));
}
break;
case 'send_invitation':
$subject = isset($_REQUEST['subject']) ? $_REQUEST['subject'] : null;
SocialManager::send_invitation_friend_user($_REQUEST['user_id'], $subject, $_REQUEST['content']);
break;
case 'find_users':
if (api_is_anonymous()) {
echo '';
break;
}
$track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
$tbl_my_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_my_user_friend = Database::get_main_table(TABLE_MAIN_USER_REL_USER);
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
示例15: api_not_allowed
$group_id,
$parent_id,
$edit_message_id,
0,
$topic_id
);
} else {
if ($_POST['action'] == 'add_message_group' && !$is_member) {
api_not_allowed();
}
$res = MessageManager::send_message(
0,
$title,
$content,
$_FILES,
'',
$group_id,
$parent_id,
0,
$topic_id
);
}
// display error messages
if (!$res) {
$social_right_content .= Display::return_message(
get_lang('Error'),
'error'
);
}
$topic_id = intval($_GET['topic_id']);