本文整理汇总了PHP中messenger::reset方法的典型用法代码示例。如果您正苦于以下问题:PHP messenger::reset方法的具体用法?PHP messenger::reset怎么用?PHP messenger::reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类messenger
的用法示例。
在下文中一共展示了messenger::reset方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pm_notification
/**
* PM Notification
*/
function pm_notification($mode, $author, $recipients, $subject, $message)
{
global $db, $user, $config, $phpbb_root_path, $phpEx, $auth;
$subject = censor_text($subject);
// Get banned User ID's
$sql = 'SELECT ban_userid
FROM ' . BANLIST_TABLE;
$result = $db->sql_query($sql);
unset($recipients[ANONYMOUS], $recipients[$user->data['user_id']]);
while ($row = $db->sql_fetchrow($result)) {
if (isset($row['ban_userid'])) {
unset($recipients[$row['ban_userid']]);
}
}
$db->sql_freeresult($result);
if (!sizeof($recipients)) {
return;
}
$recipient_list = implode(', ', array_keys($recipients));
$sql = 'SELECT user_id, username, user_email, user_lang, user_notify_pm, user_notify_type, user_jabber
FROM ' . USERS_TABLE . "\n\t\tWHERE user_id IN ({$recipient_list})";
$result = $db->sql_query($sql);
$msg_list_ary = array();
while ($row = $db->sql_fetchrow($result)) {
if ($row['user_notify_pm'] == 1 && trim($row['user_email'])) {
$msg_list_ary[] = array('method' => $row['user_notify_type'], 'email' => $row['user_email'], 'jabber' => $row['user_jabber'], 'name' => $row['username'], 'lang' => $row['user_lang']);
}
}
$db->sql_freeresult($result);
if (!sizeof($msg_list_ary)) {
return;
}
include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
$messenger = new messenger();
$email_sig = str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']);
foreach ($msg_list_ary as $pos => $addr) {
$messenger->template('privmsg_notify', $addr['lang']);
$messenger->replyto($config['board_email']);
$messenger->to($addr['email'], $addr['name']);
$messenger->im($addr['jabber'], $addr['name']);
$messenger->assign_vars(array('EMAIL_SIG' => $email_sig, 'SITENAME' => $config['sitename'], 'SUBJECT' => html_entity_decode($subject), 'AUTHOR_NAME' => html_entity_decode($author), 'USERNAME' => html_entity_decode($addr['name']), 'U_INBOX' => generate_board_url() . "/ucp.{$phpEx}?i=pm&folder=inbox"));
$messenger->send($addr['method']);
$messenger->reset();
}
unset($msg_list_ary);
$messenger->save_queue();
unset($messenger);
}
示例2: disapprove_post
function disapprove_post($post_id_list)
{
global $_CLASS, $_CORE_CONFIG, $config;
if (!($forum_id = check_ids($post_id_list, POSTS_TABLE, 'post_id', 'm_approve'))) {
trigger_error('NOT_AUTHORIZED');
}
$redirect = request_var('redirect', $_CLASS['core_user']->data['session_page']);
$reason = request_var('reason', '');
$reason_id = request_var('reason_id', 0);
$success_msg = $additional_msg = '';
$s_hidden_fields = build_hidden_fields(array('post_id_list' => $post_id_list, 'f' => $forum_id, 'mode' => 'disapprove', 'redirect' => $redirect));
$notify_poster = isset($_REQUEST['notify_poster']) ? true : false;
if ($reason_id) {
$sql = 'SELECT reason_name
FROM ' . REASONS_TABLE . " \n\t\t\tWHERE reason_id = {$reason_id}";
$result = $_CLASS['core_db']->query($sql);
if (!($row = $_CLASS['core_db']->fetch_row_assoc($result)) || !$reason && $row['reason_name'] == 'other') {
$additional_msg = 'Please give an appropiate reason for disapproval';
unset($_POST['confirm']);
} else {
$disapprove_reason = $row['reason_name'] != 'other' ? $_CLASS['core_user']->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_name'])] : '';
$disapprove_reason .= $reason ? "\n\n" . $_REQUEST['reason'] : '';
unset($reason);
}
$_CLASS['core_db']->free_result($result);
}
if (confirm_box(true)) {
$post_info = get_post_data($post_id_list, 'm_approve');
// If Topic -> forum_topics_real -= 1
// If Post -> topic_replies_real -= 1
$forum_topics_real = 0;
$topic_replies_real_sql = $post_disapprove_sql = $topic_id_list = array();
foreach ($post_info as $post_id => $post_data) {
$topic_id_list[$post_data['topic_id']] = 1;
// Topic or Post. ;)
if ($post_data['topic_first_post_id'] == $post_id && $post_data['topic_last_post_id'] == $post_id) {
if ($post_data['forum_id']) {
$forum_topics_real++;
}
} else {
if (!isset($topic_replies_real_sql[$post_data['topic_id']])) {
$topic_replies_real_sql[$post_data['topic_id']] = 1;
} else {
$topic_replies_real_sql[$post_data['topic_id']]++;
}
}
$post_disapprove_sql[] = $post_id;
}
if ($forum_topics_real) {
$sql = 'UPDATE ' . FORUMS_TABLE . "\n\t\t\t\tSET forum_topics_real = forum_topics_real - {$forum_topics_real}\n\t\t\t\tWHERE forum_id = {$forum_id}";
$_CLASS['core_db']->query($sql);
}
if (sizeof($topic_replies_real_sql)) {
foreach ($topic_replies_real_sql as $topic_id => $num_replies) {
$sql = 'UPDATE ' . TOPICS_TABLE . "\n\t\t\t\t\tSET topic_replies_real = topic_replies_real - {$num_replies}\n\t\t\t\t\tWHERE topic_id = {$topic_id}";
$_CLASS['core_db']->query($sql);
}
}
if (sizeof($post_disapprove_sql)) {
// We do not check for permissions here, because the moderator allowed approval/disapproval should be allowed to delete the disapproved posts
delete_posts('post_id', $post_disapprove_sql);
}
unset($post_disapprove_sql, $topic_replies_real_sql);
update_post_information('topic', array_keys($topic_id_list));
update_post_information('forum', $forum_id);
unset($topic_id_list);
$messenger = new messenger();
// Notify Poster?
if ($notify_poster) {
$email_sig = str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']);
foreach ($post_info as $post_id => $post_data) {
if ($post_data['poster_id'] == ANONYMOUS) {
continue;
}
$email_template = $post_data['post_id'] == $post_data['topic_first_post_id'] && $post_data['post_id'] == $post_data['topic_last_post_id'] ? 'topic_disapproved' : 'post_disapproved';
$messenger->template($email_template, $post_data['user_lang']);
$messenger->replyto($config['board_email']);
$messenger->to($post_data['user_email'], $post_data['username']);
$messenger->im($post_data['user_jabber'], $post_data['username']);
$messenger->assign_vars(array('EMAIL_SIG' => $email_sig, 'SITENAME' => $_CORE_CONFIG['global']['sitename'], 'USERNAME' => $post_data['username'], 'REASON' => stripslashes($disapprove_reason), 'POST_SUBJECT' => censor_text($post_data['post_subject']), 'TOPIC_TITLE' => censor_text($post_data['topic_title'])));
$messenger->send($post_data['user_notify_type']);
$messenger->reset();
}
$messenger->save_queue();
}
unset($post_info, $disapprove_reason);
if ($forum_topics_real) {
$success_msg = $forum_topics_real == 1 ? 'TOPIC_DISAPPROVED_SUCCESS' : 'TOPICS_DISAPPROVED_SUCCESS';
} else {
$success_msg = sizeof($post_id_list) == 1 ? 'POST_DISAPPROVED_SUCCESS' : 'POSTS_DISAPPROVED_SUCCESS';
}
} else {
$sql = 'SELECT *
FROM ' . REASONS_TABLE . '
ORDER BY reason_priority ASC';
$result = $_CLASS['core_db']->query($sql);
while ($row = $_CLASS['core_db']->fetch_row_assoc($result)) {
$row['reason_name'] = strtoupper($row['reason_name']);
$reason_title = !empty($_CLASS['core_user']->lang['report_reasons']['TITLE'][$row['reason_name']]) ? $_CLASS['core_user']->lang['report_reasons']['TITLE'][$row['reason_name']] : ucwords(str_replace('_', ' ', $row['reason_name']));
$reason_desc = !empty($_CLASS['core_user']->lang['report_reasons']['DESCRIPTION'][$row['reason_name']]) ? $_CLASS['core_user']->lang['report_reasons']['DESCRIPTION'][$row['reason_name']] : $row['reason_desc'];
//.........这里部分代码省略.........
示例3: disapprove_post
/**
* Disapprove Post/Topic
*/
function disapprove_post($post_id_list, $mode)
{
global $db, $template, $user, $config;
global $phpEx, $phpbb_root_path;
if (!($forum_id = check_ids($post_id_list, POSTS_TABLE, 'post_id', 'm_approve'))) {
trigger_error('NOT_AUTHORIZED');
}
$redirect = request_var('redirect', build_url(array('t', 'mode')) . '&mode=unapproved_topics');
$reason = request_var('reason', '', true);
$reason_id = request_var('reason_id', 0);
$success_msg = $additional_msg = '';
$s_hidden_fields = build_hidden_fields(array('i' => 'queue', 'mode' => $mode, 'post_id_list' => $post_id_list, 'f' => $forum_id, 'action' => 'disapprove', 'redirect' => $redirect));
$notify_poster = isset($_REQUEST['notify_poster']) ? true : false;
$disapprove_reason = '';
if ($reason_id) {
$sql = 'SELECT reason_title, reason_description
FROM ' . REPORTS_REASONS_TABLE . "\n\t\t\tWHERE reason_id = {$reason_id}";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (!$row || !$reason && $row['reason_title'] == 'other') {
$additional_msg = $user->lang['NO_REASON_DISAPPROVAL'];
unset($_POST['confirm']);
} else {
// If the reason is defined within the language file, we will use the localized version, else just use the database entry...
$disapprove_reason = $row['reason_title'] != 'other' ? isset($user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])]) ? $user->lang['report_reasons']['DESCRIPTION'][strtoupper($row['reason_title'])] : $row['reason_description'] : '';
$disapprove_reason .= $reason ? "\n\n" . $reason : '';
}
}
if (confirm_box(true)) {
$post_info = get_post_data($post_id_list, 'm_approve');
// If Topic -> forum_topics_real -= 1
// If Post -> topic_replies_real -= 1
$forum_topics_real = 0;
$topic_replies_real_sql = $post_disapprove_sql = $topic_id_list = array();
foreach ($post_info as $post_id => $post_data) {
$topic_id_list[$post_data['topic_id']] = 1;
// Topic or Post. ;)
if ($post_data['topic_first_post_id'] == $post_id && $post_data['topic_last_post_id'] == $post_id) {
if ($post_data['forum_id']) {
$forum_topics_real++;
}
} else {
if (!isset($topic_replies_real_sql[$post_data['topic_id']])) {
$topic_replies_real_sql[$post_data['topic_id']] = 1;
} else {
$topic_replies_real_sql[$post_data['topic_id']]++;
}
}
$post_disapprove_sql[] = $post_id;
}
if ($forum_topics_real) {
$sql = 'UPDATE ' . FORUMS_TABLE . "\n\t\t\t\tSET forum_topics_real = forum_topics_real - {$forum_topics_real}\n\t\t\t\tWHERE forum_id = {$forum_id}";
$db->sql_query($sql);
}
if (sizeof($topic_replies_real_sql)) {
foreach ($topic_replies_real_sql as $topic_id => $num_replies) {
$sql = 'UPDATE ' . TOPICS_TABLE . "\n\t\t\t\t\tSET topic_replies_real = topic_replies_real - {$num_replies}\n\t\t\t\t\tWHERE topic_id = {$topic_id}";
$db->sql_query($sql);
}
}
if (sizeof($post_disapprove_sql)) {
if (!function_exists('delete_posts')) {
include_once $phpbb_root_path . 'includes/functions_admin.' . $phpEx;
}
// We do not check for permissions here, because the moderator allowed approval/disapproval should be allowed to delete the disapproved posts
delete_posts('post_id', $post_disapprove_sql);
}
unset($post_disapprove_sql, $topic_replies_real_sql);
update_post_information('topic', array_keys($topic_id_list));
update_post_information('forum', $forum_id);
unset($topic_id_list);
$messenger = new messenger();
// Notify Poster?
if ($notify_poster) {
$email_sig = str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']);
foreach ($post_info as $post_id => $post_data) {
if ($post_data['poster_id'] == ANONYMOUS) {
continue;
}
$email_template = $post_data['post_id'] == $post_data['topic_first_post_id'] && $post_data['post_id'] == $post_data['topic_last_post_id'] ? 'topic_disapproved' : 'post_disapproved';
$messenger->template($email_template, $post_data['user_lang']);
$messenger->replyto($config['board_email']);
$messenger->to($post_data['user_email'], $post_data['username']);
$messenger->im($post_data['user_jabber'], $post_data['username']);
$messenger->assign_vars(array('EMAIL_SIG' => $email_sig, 'SITENAME' => $config['sitename'], 'USERNAME' => html_entity_decode($post_data['username']), 'REASON' => html_entity_decode($disapprove_reason), 'POST_SUBJECT' => html_entity_decode(censor_text($post_data['post_subject'])), 'TOPIC_TITLE' => html_entity_decode(censor_text($post_data['topic_title']))));
$messenger->send($post_data['user_notify_type']);
$messenger->reset();
}
$messenger->save_queue();
}
unset($post_info, $disapprove_reason);
if ($forum_topics_real) {
$success_msg = $forum_topics_real == 1 ? 'TOPIC_DISAPPROVED_SUCCESS' : 'TOPICS_DISAPPROVED_SUCCESS';
} else {
$success_msg = sizeof($post_id_list) == 1 ? 'POST_DISAPPROVED_SUCCESS' : 'POSTS_DISAPPROVED_SUCCESS';
}
//.........这里部分代码省略.........
示例4: array
function notify_subscribers($digest_notify_list, $email_template = '')
{
// This function parses $digest_notify_list, an array of user_ids that represent users that had their digest subscriptions changed, and sends them an email
// letting them know an action has occurred.
global $phpbb_root_path, $phpEx, $config, $user, $db, $phpbb_log;
$emails_sent = 0;
if (isset($digest_notify_list) && sizeof($digest_notify_list) > 0) {
if (!class_exists('messenger')) {
include $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
// Used to send emails
}
$sql_array = array('SELECT' => 'username, user_email, user_lang, user_digest_type, user_digest_format', 'FROM' => array(USERS_TABLE => 'u'), 'WHERE' => $db->sql_in_set('user_id', $digest_notify_list));
$sql = $db->sql_build_query('SELECT', $sql_array);
$result = $db->sql_query($sql);
$rowset = $db->sql_fetchrowset($result);
foreach ($rowset as $row) {
// E-mail setup
$messenger = new \messenger();
switch ($email_template) {
case 'digests_subscription_edited':
$digest_notify_template = $email_template;
$digest_email_subject = $user->lang('DIGESTS_SUBSCRIBE_EDITED');
break;
default:
// Mass subscribe/unsubscribe
$digest_notify_template = $config['phpbbservices_digests_subscribe_all'] ? 'digests_subscribe' : 'digests_unsubscribe';
$digest_email_subject = $config['phpbbservices_digests_subscribe_all'] ? $user->lang('DIGESTS_SUBSCRIBE_SUBJECT') : $user->lang('DIGESTS_UNSUBSCRIBE_SUBJECT');
break;
}
// Set up associations between digest types as constants and their language equivalents
switch ($row['user_digest_type']) {
case constants::DIGESTS_DAILY_VALUE:
$digest_type_text = strtolower($user->lang('DIGESTS_DAILY'));
break;
case constants::DIGESTS_WEEKLY_VALUE:
$digest_type_text = strtolower($user->lang('DIGESTS_WEEKLY'));
break;
case constants::DIGESTS_MONTHLY_VALUE:
$digest_type_text = strtolower($user->lang('DIGESTS_MONTHLY'));
break;
case constants::DIGESTS_NONE_VALUE:
$digest_type_text = strtolower($user->lang('DIGESTS_NONE'));
break;
default:
$digest_type_text = strtolower($user->lang('DIGESTS_DAILY'));
break;
}
// Set up associations between digest formats as constants and their language equivalents
switch ($row['user_digest_format']) {
case constants::DIGESTS_HTML_VALUE:
$digest_format_text = $user->lang('DIGESTS_FORMAT_HTML');
break;
case constants::DIGESTS_HTML_CLASSIC_VALUE:
$digest_format_text = $user->lang('DIGESTS_FORMAT_HTML_CLASSIC');
break;
case constants::DIGESTS_PLAIN_VALUE:
$digest_format_text = $user->lang('DIGESTS_FORMAT_PLAIN');
break;
case constants::DIGESTS_PLAIN_CLASSIC_VALUE:
$digest_format_text = $user->lang('DIGESTS_FORMAT_PLAIN_CLASSIC');
break;
case constants::DIGESTS_TEXT_VALUE:
$digest_format_text = strtolower($user->lang('DIGESTS_FORMAT_TEXT'));
break;
default:
$digest_format_text = $user->lang('DIGESTS_FORMAT_HTML');
break;
}
$messenger->template('@phpbbservices_digests/' . $digest_notify_template, $row['user_lang']);
$messenger->to($row['user_email']);
$from_addr = $config['phpbbservices_digests_from_email_address'] == '' ? $config['board_email'] : $config['phpbbservices_digests_from_email_address'];
$from_name = $config['phpbbservices_digests_from_email_name'] == '' ? $config['board_contact'] : $config['phpbbservices_digests_from_email_name'];
// SMTP delivery must strip text names due to likely bug in messenger class
if ($config['smtp_delivery']) {
$messenger->from($from_addr);
} else {
$messenger->from($from_addr . ' <' . $from_name . '>');
}
$messenger->replyto($from_addr);
$messenger->subject($digest_email_subject);
$messenger->assign_vars(array('DIGESTS_FORMAT' => $digest_format_text, 'DIGESTS_TYPE' => $digest_type_text, 'DIGESTS_UCP_LINK' => generate_board_url() . '/' . 'ucp.' . $phpEx, 'FORUM_NAME' => $config['sitename'], 'USERNAME' => $row['username']));
$mail_sent = $messenger->send(NOTIFY_EMAIL, false);
if (!$mail_sent) {
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_CONFIG_DIGESTS_NOTIFICATION_ERROR', false, array($row['user_email']));
} else {
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_CONFIG_DIGESTS_NOTIFICATION_SENT', false, array($row['user_email'], $row['username']));
$emails_sent++;
}
$messenger->reset();
}
$db->sql_freeresult($result);
// Query be gone!
}
return $emails_sent;
}
示例5: close_report
/**
* Closes a report
*/
function close_report($post_id_list, $mode, $action)
{
global $db, $template, $user, $config;
global $phpEx, $phpbb_root_path;
if (!($forum_id = check_ids($post_id_list, POSTS_TABLE, 'post_id', 'm_report'))) {
trigger_error('NOT_AUTHORIZED');
}
if ($action == 'delete' && strpos($user->data['session_page'], 'mode=report_details') !== false) {
$redirect = request_var('redirect', build_url(array('mode')) . '&mode=reports');
} else {
$redirect = request_var('redirect', $user->data['session_page']);
}
$success_msg = '';
$s_hidden_fields = build_hidden_fields(array('i' => 'reports', 'mode' => $mode, 'post_id_list' => $post_id_list, 'f' => $forum_id, 'action' => $action, 'redirect' => $redirect));
if (confirm_box(true)) {
$post_info = get_post_data($post_id_list, 'm_report');
$sql = 'SELECT r.post_id, r.report_closed, r.user_id, r.user_notify, u.username, u.user_email, u.user_jabber, u.user_lang, u.user_notify_type
FROM ' . REPORTS_TABLE . ' r, ' . USERS_TABLE . ' u
WHERE r.post_id IN (' . implode(',', array_keys($post_info)) . ')
' . ($action == 'close' ? 'AND r.report_closed = 0' : '') . '
AND r.user_id = u.user_id';
$result = $db->sql_query($sql);
$reports = array();
while ($report = $db->sql_fetchrow($result)) {
$reports[$report['post_id']] = $report;
}
$db->sql_freeresult($result);
$close_report_posts = $close_report_topics = $notify_reporters = array();
foreach ($post_info as $post_id => $post_data) {
if (isset($reports[$post_id])) {
$close_report_posts[] = $post_id;
$close_report_topics[] = $post_data['topic_id'];
if ($reports[$post_id]['user_notify'] && !$reports[$post_id]['report_closed']) {
$notify_reporters[$post_id] = $reports[$post_id];
}
}
}
if (sizeof($close_report_posts)) {
$close_report_topics = array_unique($close_report_topics);
// Get a list of topics that still contain reported posts
$sql = 'SELECT DISTINCT topic_id
FROM ' . POSTS_TABLE . '
WHERE topic_id IN (' . implode(', ', $close_report_topics) . ')
AND post_reported = 1
AND post_id NOT IN (' . implode(', ', $close_report_posts) . ')';
$result = $db->sql_query($sql);
$keep_report_topics = array();
while ($row = $db->sql_fetchrow($result)) {
$keep_report_topics[] = $row['topic_id'];
}
$db->sql_freeresult($result);
$close_report_topics = array_diff($close_report_topics, $keep_report_topics);
unset($keep_report_topics);
$db->sql_transaction('begin');
if ($action == 'close') {
$sql = 'UPDATE ' . REPORTS_TABLE . '
SET report_closed = 1
WHERE post_id IN (' . implode(', ', $close_report_posts) . ')';
} else {
$sql = 'DELETE FROM ' . REPORTS_TABLE . '
WHERE post_id IN (' . implode(', ', $close_report_posts) . ')';
}
$db->sql_query($sql);
$sql = 'UPDATE ' . POSTS_TABLE . '
SET post_reported = 0
WHERE post_id IN (' . implode(', ', $close_report_posts) . ')';
$db->sql_query($sql);
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_reported = 0
WHERE topic_id IN (' . implode(', ', $close_report_topics) . ')';
$db->sql_query($sql);
$db->sql_transaction('commit');
}
unset($close_report_posts, $close_report_topics);
$messenger = new messenger();
// Notify reporters
if (sizeof($notify_reporters)) {
$email_sig = str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']);
foreach ($notify_reporters as $post_id => $reporter) {
if ($reporter['user_id'] == ANONYMOUS) {
continue;
}
$messenger->template('report_' . $action . 'd', $reporter['user_lang']);
$messenger->replyto($config['board_email']);
$messenger->to($reporter['user_email'], $reporter['username']);
$messenger->im($reporter['user_jabber'], $reporter['username']);
$messenger->assign_vars(array('EMAIL_SIG' => $email_sig, 'SITENAME' => $config['sitename'], 'USERNAME' => html_entity_decode($reporter['username']), 'CLOSER_NAME' => html_entity_decode($user->data['username']), 'POST_SUBJECT' => html_entity_decode(censor_text($post_info[$post_id]['post_subject'])), 'TOPIC_TITLE' => html_entity_decode(censor_text($post_info[$post_id]['topic_title']))));
$messenger->send($reporter['user_notify_type']);
$messenger->reset();
}
$messenger->save_queue();
}
unset($notify_reporters, $post_info);
$success_msg = sizeof($post_id_list) == 1 ? 'REPORT_' . strtoupper($action) . 'D_SUCCESS' : 'REPORTS_' . strtoupper($action) . 'D_SUCCESS';
} else {
confirm_box(false, $user->lang[strtoupper($action) . '_REPORT' . (sizeof($post_id_list) == 1 ? '' : 'S') . '_CONFIRM'], $s_hidden_fields);
}
//.........这里部分代码省略.........
示例6: main
//.........这里部分代码省略.........
}
break;
case 'join':
if (group_memberships($group_id, $user->data['user_id'], true)) {
trigger_error($user->lang['ALREADY_IN_GROUP'] . $return_page);
}
// Check permission to join (open group or request)
if ($group_row[$group_id]['group_type'] != GROUP_OPEN && $group_row[$group_id]['group_type'] != GROUP_FREE) {
trigger_error($user->lang['CANNOT_JOIN_GROUP'] . $return_page);
}
if (confirm_box(true)) {
if ($group_row[$group_id]['group_type'] == GROUP_FREE) {
group_user_add($group_id, $user->data['user_id']);
$email_template = 'group_added';
} else {
group_user_add($group_id, $user->data['user_id'], false, false, false, 0, 1);
$email_template = 'group_request';
}
include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
$messenger = new messenger();
$email_sig = str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']);
$sql = 'SELECT u.username, u.user_email, u.user_notify_type, u.user_jabber, u.user_lang
FROM ' . USER_GROUP_TABLE . ' ug, ' . USERS_TABLE . ' u
WHERE ug.user_id = u.user_id
AND ' . ($group_row[$group_id]['group_type'] == GROUP_FREE ? "ug.user_id = {$user->data['user_id']}" : 'ug.group_leader = 1') . "\n\t\t\t\t\t\t\t\t\t\tAND ug.group_id = {$group_id}";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
$messenger->template($email_template, $row['user_lang']);
$messenger->replyto($config['board_email']);
$messenger->to($row['user_email'], $row['username']);
$messenger->im($row['user_jabber'], $row['username']);
$messenger->assign_vars(array('EMAIL_SIG' => $email_sig, 'SITENAME' => $config['sitename'], 'USERNAME' => html_entity_decode($row['username']), 'GROUP_NAME' => html_entity_decode($group_row[$group_id]['group_name']), 'U_PENDING' => generate_board_url() . "/ucp.{$phpEx}?i=groups&mode=manage&action=list&g={$group_id}", 'U_GROUP' => generate_board_url() . "/memberlist.{$phpEx}?mode=group&g={$group_id}"));
$messenger->send($row['user_notify_type']);
$messenger->reset();
}
$db->sql_freeresult($result);
$messenger->save_queue();
add_log('user', $user->data['user_id'], 'LOG_USER_GROUP_JOIN' . ($group_row[$group_id]['group_type'] == GROUP_FREE ? '' : '_PENDING'), $group_row[$group_id]['group_name']);
meta_refresh(3, $this->u_action);
trigger_error($user->lang[$group_row[$group_id]['group_type'] == GROUP_FREE ? 'GROUP_JOINED' : 'GROUP_JOINED_PENDING'] . $return_page);
} else {
$s_hidden_fields = array('selected' => $group_id, 'action' => 'join', 'submit' => true);
confirm_box(false, $group_row[$group_id]['group_type'] == GROUP_FREE ? 'GROUP_JOIN' : 'GROUP_JOIN_PENDING', build_hidden_fields($s_hidden_fields));
}
break;
case 'demote':
if (!($row = group_memberships($group_id, $user->data['user_id']))) {
trigger_error($user->lang['NOT_MEMBER_OF_GROUP'] . $return_page);
}
list(, $row) = each($row);
if (!$row['group_leader']) {
trigger_error($user->lang['NOT_LEADER_OF_GROUP'] . $return_page);
}
if (confirm_box(true)) {
group_user_attributes('demote', $group_id, $user->data['user_id']);
add_log('user', $user->data['user_id'], 'LOG_USER_GROUP_DEMOTE', $group_row[$group_id]['group_name']);
meta_refresh(3, $this->u_action);
trigger_error($user->lang['USER_GROUP_DEMOTED'] . $return_page);
} else {
$s_hidden_fields = array('selected' => $group_id, 'action' => 'demote', 'submit' => true);
confirm_box(false, 'USER_GROUP_DEMOTE', build_hidden_fields($s_hidden_fields));
}
break;
}
}
$sql = 'SELECT g.*, ug.group_leader, ug.user_pending
示例7: user_notification
/**
* User Notification
*/
function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id, $topic_id, $post_id)
{
global $db, $user, $config, $phpbb_root_path, $phpEx, $auth;
$topic_notification = $mode == 'reply' || $mode == 'quote';
$forum_notification = $mode == 'post';
if (!$topic_notification && !$forum_notification) {
trigger_error('WRONG_NOTIFICATION_MODE');
}
if (!$config['allow_topic_notify']) {
return;
}
$topic_title = $topic_notification ? $topic_title : $subject;
$topic_title = censor_text($topic_title);
// Get banned User ID's
$sql = 'SELECT ban_userid
FROM ' . BANLIST_TABLE;
$result = $db->sql_query($sql);
$sql_ignore_users = ANONYMOUS . ', ' . $user->data['user_id'];
while ($row = $db->sql_fetchrow($result)) {
if (isset($row['ban_userid'])) {
$sql_ignore_users .= ', ' . $row['ban_userid'];
}
}
$db->sql_freeresult($result);
$notify_rows = array();
// -- get forum_userids || topic_userids
$sql = 'SELECT u.user_id, u.username, u.user_email, u.user_lang, u.user_notify_type, u.user_jabber
FROM ' . ($topic_notification ? TOPICS_WATCH_TABLE : FORUMS_WATCH_TABLE) . ' w, ' . USERS_TABLE . ' u
WHERE w.' . ($topic_notification ? 'topic_id' : 'forum_id') . ' = ' . ($topic_notification ? $topic_id : $forum_id) . "\n\t\t\tAND w.user_id NOT IN ({$sql_ignore_users})\n\t\t\tAND w.notify_status = 0\n\t\t\tAND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')
AND u.user_id = w.user_id';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
$notify_rows[$row['user_id']] = array('user_id' => $row['user_id'], 'username' => $row['username'], 'user_email' => $row['user_email'], 'user_jabber' => $row['user_jabber'], 'user_lang' => $row['user_lang'], 'notify_type' => $topic_notification ? 'topic' : 'forum', 'template' => $topic_notification ? 'topic_notify' : 'newtopic_notify', 'method' => $row['user_notify_type'], 'allowed' => false);
}
$db->sql_freeresult($result);
// forum notification is sent to those not already receiving topic notifications
if ($topic_notification) {
if (sizeof($notify_rows)) {
$sql_ignore_users .= ', ' . implode(', ', array_keys($notify_rows));
}
$sql = 'SELECT u.user_id, u.username, u.user_email, u.user_lang, u.user_notify_type, u.user_jabber
FROM ' . FORUMS_WATCH_TABLE . ' fw, ' . USERS_TABLE . " u\n\t\t\tWHERE fw.forum_id = {$forum_id}\n\t\t\t\tAND fw.user_id NOT IN ({$sql_ignore_users})\n\t\t\t\tAND fw.notify_status = 0\n\t\t\t\tAND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')
AND u.user_id = fw.user_id';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
$notify_rows[$row['user_id']] = array('user_id' => $row['user_id'], 'username' => $row['username'], 'user_email' => $row['user_email'], 'user_jabber' => $row['user_jabber'], 'user_lang' => $row['user_lang'], 'notify_type' => 'forum', 'template' => 'forum_notify', 'method' => $row['user_notify_type'], 'allowed' => false);
}
$db->sql_freeresult($result);
}
if (!sizeof($notify_rows)) {
return;
}
// Make sure users are allowed to read the forum
foreach ($auth->acl_get_list(array_keys($notify_rows), 'f_read', $forum_id) as $forum_id => $forum_ary) {
foreach ($forum_ary as $auth_option => $user_ary) {
foreach ($user_ary as $user_id) {
$notify_rows[$user_id]['allowed'] = true;
}
}
}
// Now, we have to do a little step before really sending, we need to distinguish our users a little bit. ;)
$msg_users = $delete_ids = $update_notification = array();
foreach ($notify_rows as $user_id => $row) {
if (!$row['allowed'] || !trim($row['user_email'])) {
$delete_ids[$row['notify_type']][] = $row['user_id'];
} else {
$msg_users[] = $row;
$update_notification[$row['notify_type']][] = $row['user_id'];
}
}
unset($notify_rows);
// Now, we are able to really send out notifications
if (sizeof($msg_users)) {
include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
$messenger = new messenger();
$email_sig = str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']);
$msg_list_ary = array();
foreach ($msg_users as $row) {
$pos = !isset($msg_list_ary[$row['template']]) ? 0 : sizeof($msg_list_ary[$row['template']]);
$msg_list_ary[$row['template']][$pos]['method'] = $row['method'];
$msg_list_ary[$row['template']][$pos]['email'] = $row['user_email'];
$msg_list_ary[$row['template']][$pos]['jabber'] = $row['user_jabber'];
$msg_list_ary[$row['template']][$pos]['name'] = $row['username'];
$msg_list_ary[$row['template']][$pos]['lang'] = $row['user_lang'];
}
unset($msg_users);
foreach ($msg_list_ary as $email_template => $email_list) {
foreach ($email_list as $addr) {
$messenger->template($email_template, $addr['lang']);
$messenger->replyto($config['board_email']);
$messenger->to($addr['email'], $addr['name']);
$messenger->im($addr['jabber'], $addr['name']);
$messenger->assign_vars(array('EMAIL_SIG' => $email_sig, 'SITENAME' => html_entity_decode($config['sitename']), 'USERNAME' => html_entity_decode($addr['name']), 'TOPIC_TITLE' => html_entity_decode($topic_title), 'FORUM_NAME' => html_entity_decode($forum_name), 'U_FORUM' => generate_board_url() . "/viewforum.{$phpEx}?f={$forum_id}&e=0", 'U_TOPIC' => generate_board_url() . "/viewtopic.{$phpEx}?f={$forum_id}&t={$topic_id}&e=0", 'U_NEWEST_POST' => generate_board_url() . "/viewtopic.{$phpEx}?f={$forum_id}&t={$topic_id}&p={$post_id}&e={$post_id}", 'U_STOP_WATCHING_TOPIC' => generate_board_url() . "/viewtopic.{$phpEx}?f={$forum_id}&t={$topic_id}&unwatch=topic", 'U_STOP_WATCHING_FORUM' => generate_board_url() . "/viewforum.{$phpEx}?f={$forum_id}&unwatch=forum"));
$messenger->send($addr['method']);
$messenger->reset();
}
}
//.........这里部分代码省略.........
示例8: group_user_attributes
/**
* This is used to promote (to leader), demote or set as default a member/s
*/
function group_user_attributes($action, $group_id, $user_id_ary = false, $username_ary = false, $group_name = false, $group_attributes = false)
{
global $db, $auth, $phpbb_root_path, $phpEx, $config;
// We need both username and user_id info
user_get_id_name($user_id_ary, $username_ary);
if (!sizeof($user_id_ary)) {
return false;
}
if (!$group_name) {
$group_name = get_group_name($group_id);
}
switch ($action) {
case 'demote':
case 'promote':
$sql = 'UPDATE ' . USER_GROUP_TABLE . '
SET group_leader = ' . ($action == 'promote' ? 1 : 0) . "\n\t\t\t\tWHERE group_id = {$group_id}\n\t\t\t\t\tAND user_id IN (" . implode(', ', $user_id_ary) . ')';
$db->sql_query($sql);
$log = $action == 'promote' ? 'LOG_GROUP_PROMOTED' : 'LOG_GROUP_DEMOTED';
break;
case 'approve':
// Make sure we only approve those which are pending ;)
$sql = 'SELECT u.user_id, u.user_email, u.username, u.user_notify_type, u.user_jabber, u.user_lang
FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . ' ug
WHERE ug.group_id = ' . $group_id . '
AND ug.user_pending = 1
AND ug.user_id = u.user_id
AND ug.user_id IN (' . implode(', ', $user_id_ary) . ')';
$result = $db->sql_query($sql);
$user_id_ary = $email_users = array();
while ($row = $db->sql_fetchrow($result)) {
$user_id_ary[] = $row['user_id'];
$email_users[] = $row;
}
$db->sql_freeresult($result);
if (!sizeof($user_id_ary)) {
return false;
}
$sql = 'UPDATE ' . USER_GROUP_TABLE . "\n\t\t\t\tSET user_pending = 0\n\t\t\t\tWHERE group_id = {$group_id}\n\t\t\t\t\tAND user_id IN (" . implode(', ', $user_id_ary) . ')';
$db->sql_query($sql);
// Send approved email to users...
include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
$messenger = new messenger();
$email_sig = str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']);
foreach ($email_users as $row) {
$messenger->template('group_approved', $row['user_lang']);
$messenger->replyto($config['board_email']);
$messenger->to($row['user_email'], $row['username']);
$messenger->im($row['user_jabber'], $row['username']);
$messenger->assign_vars(array('EMAIL_SIG' => $email_sig, 'SITENAME' => $config['sitename'], 'USERNAME' => html_entity_decode($row['username']), 'GROUP_NAME' => html_entity_decode($group_name), 'U_GROUP' => generate_board_url() . "/ucp.{$phpEx}?i=groups&mode=membership"));
$messenger->send($row['user_notify_type']);
$messenger->reset();
}
$messenger->save_queue();
$log = 'LOG_USERS_APPROVED';
break;
case 'default':
group_set_user_default($group_id, $user_id_ary, $group_attributes);
$log = 'LOG_GROUP_DEFAULTS';
break;
}
// Clear permissions cache of relevant users
$auth->acl_clear_prefetch($user_id_ary);
add_log('admin', $log, $group_name, implode(', ', $username_ary));
return true;
}
示例9: report_notification
function report_notification($notify_user, $report_post, $report_data)
{
global $config, $site_file_root;
require_once $site_file_root . 'includes/forums/functions_messenger.php';
require_once $site_file_root . 'includes/forums/functions_privmsgs.php';
$messenger = new messenger();
$email_sig = str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']);
$email_template = $report_post ? 'new_report_post' : 'new_report_pm';
$view_report_url = $report_post ? generate_link('Forums&file=mcp&i=queue&r=' . $report_data['report_id'], array('full' => true, 'sid' => false)) : generate_link('Forums&file=mcp&i=pm&p=' . $report_data['id'] . '&r=' . $report_data['report_id'], array('full' => true, 'sid' => false));
foreach ($notify_user as $user_id => $notify_row) {
// Send notification by email
if (!$notify_row['pm']) {
$messenger->to($notify_row['email'], $notify_row['name']);
$messenger->im($notify_row['jabber'], $notify_row['name']);
$messenger->replyto($config['board_email']);
$messenger->template($email_template, $notify_row['lang']);
$messenger->assign_vars(array('EMAIL_SIG' => $email_sig, 'SITENAME' => $config['sitename'], 'USERNAME' => $notify_row['name'], 'SUBJECT' => $report_data['subject'], 'REPORTER' => $report_data['reporter'], 'REPORT_REASON' => $report_data['reason'], 'REPORT_TEXT' => $report_data['text'], 'U_VIEW_REPORT' => $view_report_url, 'U_VIEW_POST' => generate_board_url() . '/' . $report_data['view_post']));
$messenger->send($notify_row['notify_type']);
$messenger->reset();
$messenger->save_queue();
} else {
// Use messenger for getting the correct message, we use the email template
$messenger->template($email_template, $notify_row['lang']);
$messenger->assign_vars(array('EMAIL_SIG' => $email_sig, 'SITENAME' => $config['sitename'], 'USERNAME' => $notify_row['name'], 'SUBJECT' => $report_data['subject'], 'REPORTER' => $report_data['reporter'], 'REPORT_REASON' => $report_data['reason'], 'REPORT_TEXT' => $report_data['text'], 'U_VIEW_REPORT' => generate_board_url() . '/' . $view_report_url));
// break the sending process...
$messenger->send(false, true);
$messenger->reset();
// do not put in reporters outbox
submit_pm('post', $report_data['subject'], '', array(), array(), array('address_list' => array('u' => array($user_id => 'to')), 'icon_id' => 0, 'enable_bbcode' => 0, 'enable_html' => 0, 'enable_smilies' => 0, 'enable_magic_url' => 1, 'enable_sig' => 0, 'message_md5' => md5($messenger->msg), 'bbcode_bitfield' => 0, 'bbcode_uid' => 0, 'attachment_data' => array(), 'filename_data' => array(), 'message' => $messenger->msg), true, false);
}
}
unset($messenger);
}
示例10: pm_notification
function pm_notification($mode, $author, $recipients, $subject, $message)
{
global $_CLASS, $config;
return;
$subject = censor_text($subject);
// Get banned User ID's
$sql = 'SELECT ban_userid
FROM ' . BANLIST_TABLE;
$result = $_CLASS['core_db']->query($sql);
unset($recipients[ANONYMOUS], $recipients[$_CLASS['core_user']->data['user_id']]);
while ($row = $_CLASS['core_db']->fetch_row_assoc($result)) {
if (isset($row['ban_userid'])) {
unset($recipients[$row['ban_userid']]);
}
}
$_CLASS['core_db']->free_result($result);
if (!sizeof($recipients)) {
return;
}
$recipient_list = implode(', ', array_keys($recipients));
$sql = 'SELECT user_id, username, user_email, user_lang, user_notify_pm, user_notify_type, user_jabber
FROM ' . USERS_TABLE . "\r\n\t\tWHERE user_id IN ({$recipient_list})";
$result = $_CLASS['core_db']->query($sql);
$msg_list_ary = array();
while ($row = $_CLASS['core_db']->fetch_row_assoc($result)) {
if ($row['user_notify_pm'] == 1 && trim($row['user_email'])) {
$msg_list_ary[] = array('method' => $row['user_notify_type'], 'email' => $row['user_email'], 'jabber' => $row['user_jabber'], 'name' => $row['username'], 'lang' => $row['user_lang']);
}
}
$_CLASS['core_db']->free_result($result);
if (!sizeof($msg_list_ary)) {
return;
}
require_once 'includes/forums/functions_messenger.php';
$messenger = new messenger();
$email_sig = str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']);
foreach ($msg_list_ary as $pos => $addr) {
$messenger->template('privmsg_notify', $addr['lang']);
$messenger->replyto($config['board_email']);
$messenger->to($addr['email'], $addr['name']);
$messenger->im($addr['jabber'], $addr['name']);
$messenger->assign_vars(array('EMAIL_SIG' => $email_sig, 'SITENAME' => $config['sitename'], 'SUBJECT' => $subject, 'AUTHOR_NAME' => $author, 'USERNAME' => $addr['name'], 'U_INBOX' => generate_link('Control_Panel&i=pm&mode=unread', array('full' => true, 'sid' => true))));
$messenger->send($addr['method']);
$messenger->reset();
}
unset($msg_list_ary);
if ($messenger->queue) {
$messenger->save_queue();
}
unset($messenger);
}