本文整理汇总了PHP中messenger::save_queue方法的典型用法代码示例。如果您正苦于以下问题:PHP messenger::save_queue方法的具体用法?PHP messenger::save_queue怎么用?PHP messenger::save_queue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类messenger
的用法示例。
在下文中一共展示了messenger::save_queue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: notify_using_messenger
/**
* Notify using phpBB messenger
*
* @param int $notify_method Notify method for messenger (e.g. NOTIFY_IM)
* @param string $template_dir_prefix Base directory to prepend to the email template name
*
* @return null
*/
protected function notify_using_messenger($notify_method, $template_dir_prefix = '')
{
if (empty($this->queue)) {
return;
}
// Load all users we want to notify (we need their email address)
$user_ids = $users = array();
foreach ($this->queue as $notification) {
$user_ids[] = $notification->user_id;
}
// We do not send emails to banned users
if (!function_exists('phpbb_get_banned_user_ids')) {
include $this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext;
}
$banned_users = phpbb_get_banned_user_ids($user_ids);
// Load all the users we need
$this->user_loader->load_users($user_ids);
// Load the messenger
if (!class_exists('messenger')) {
include $this->phpbb_root_path . 'includes/functions_messenger.' . $this->php_ext;
}
$messenger = new \messenger();
$board_url = generate_board_url();
// Time to go through the queue and send emails
foreach ($this->queue as $notification) {
if ($notification->get_email_template() === false) {
continue;
}
$user = $this->user_loader->get_user($notification->user_id);
if ($user['user_type'] == USER_IGNORE || $user['user_type'] == USER_INACTIVE && $user['user_inactive_reason'] == INACTIVE_MANUAL || in_array($notification->user_id, $banned_users)) {
continue;
}
$messenger->template($template_dir_prefix . $notification->get_email_template(), $user['user_lang']);
$messenger->set_addresses($user);
$messenger->assign_vars(array_merge(array('USERNAME' => $user['username'], 'U_NOTIFICATION_SETTINGS' => generate_board_url() . '/ucp.' . $this->php_ext . '?i=ucp_notifications'), $notification->get_email_template_variables()));
$messenger->send($notify_method);
}
// Save the queue in the messenger class (has to be called or these emails could be lost?)
$messenger->save_queue();
// We're done, empty the queue
$this->empty_queue();
}
示例2: 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;
}
示例3: 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);
unset($recipients[ANONYMOUS], $recipients[$user->data['user_id']]);
if (!sizeof($recipients)) {
return;
}
// Get banned User ID's
$sql = 'SELECT ban_userid
FROM ' . BANLIST_TABLE . '
WHERE ' . $db->sql_in_set('ban_userid', array_map('intval', array_keys($recipients))) . '
AND ban_exclude = 0';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
unset($recipients[$row['ban_userid']]);
}
$db->sql_freeresult($result);
if (!sizeof($recipients)) {
return;
}
$sql = 'SELECT user_id, username, user_email, user_lang, user_notify_pm, user_notify_type, user_jabber
FROM ' . USERS_TABLE . '
WHERE ' . $db->sql_in_set('user_id', array_map('intval', array_keys($recipients)));
$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();
foreach ($msg_list_ary as $pos => $addr) {
$messenger->template('privmsg_notify', $addr['lang']);
$messenger->to($addr['email'], $addr['name']);
$messenger->im($addr['jabber'], $addr['name']);
$messenger->assign_vars(array('SUBJECT' => htmlspecialchars_decode($subject), 'AUTHOR_NAME' => htmlspecialchars_decode($author), 'USERNAME' => htmlspecialchars_decode($addr['name']), 'U_INBOX' => generate_board_url() . "/ucp.{$phpEx}?i=pm&folder=inbox"));
$messenger->send($addr['method']);
}
unset($msg_list_ary);
$messenger->save_queue();
unset($messenger);
}
示例4: 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
$result = user_get_id_name($user_id_ary, $username_ary);
if (!sizeof($user_id_ary) || $result !== false) {
return 'NO_USERS';
}
if (!$group_name) {
$group_name = get_group_name($group_id);
}
switch ($action) {
case 'demote':
case 'promote':
$sql = 'SELECT user_id FROM ' . USER_GROUP_TABLE . "\n\t\t\t\tWHERE group_id = {$group_id}\n\t\t\t\t\tAND user_pending = 1\n\t\t\t\t\tAND " . $db->sql_in_set('user_id', $user_id_ary);
$result = $db->sql_query_limit($sql, 1);
$not_empty = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($not_empty) {
return 'NO_VALID_USERS';
}
$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_pending = 0\n\t\t\t\t\tAND " . $db->sql_in_set('user_id', $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.username_clean, 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 ' . $db->sql_in_set('ug.user_id', $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 " . $db->sql_in_set('user_id', $user_id_ary);
$db->sql_query($sql);
// Send approved email to users...
include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
$messenger = new messenger();
foreach ($email_users as $row) {
$messenger->template('group_approved', $row['user_lang']);
$messenger->to($row['user_email'], $row['username']);
$messenger->im($row['user_jabber'], $row['username']);
$messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($row['username']), 'GROUP_NAME' => htmlspecialchars_decode($group_name), 'U_GROUP' => generate_board_url() . "/ucp.{$phpEx}?i=groups&mode=membership"));
$messenger->send($row['user_notify_type']);
}
$messenger->save_queue();
$log = 'LOG_USERS_APPROVED';
break;
case 'default':
$sql = 'SELECT user_id, group_id FROM ' . USERS_TABLE . '
WHERE ' . $db->sql_in_set('user_id', $user_id_ary, false, true);
$result = $db->sql_query($sql);
$groups = array();
while ($row = $db->sql_fetchrow($result)) {
if (!isset($groups[$row['group_id']])) {
$groups[$row['group_id']] = array();
}
$groups[$row['group_id']][] = $row['user_id'];
}
$db->sql_freeresult($result);
foreach ($groups as $gid => $uids) {
remove_default_rank($gid, $uids);
remove_default_avatar($gid, $uids);
}
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));
group_update_listings($group_id);
return false;
}
示例5: main
//.........这里部分代码省略.........
if ($row) {
if ($row['user_pending']) {
trigger_error($user->lang['ALREADY_IN_GROUP_PENDING'] . $return_page);
}
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();
$sql = 'SELECT u.username, u.username_clean, 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->to($row['user_email'], $row['username']);
$messenger->im($row['user_jabber'], $row['username']);
$messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($row['username']), 'GROUP_NAME' => htmlspecialchars_decode($group_row[$group_id]['group_name']), 'REQUEST_USERNAME' => $user->data['username'], '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']);
}
$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
FROM ' . GROUPS_TABLE . ' g, ' . USER_GROUP_TABLE . ' ug
WHERE ug.user_id = ' . $user->data['user_id'] . '
AND g.group_id = ug.group_id
示例6: main
//.........这里部分代码省略.........
$email_list[$j][$i]['name'] = $row['username'];
$email_list[$j][$i]['jabber'] = $row['user_jabber'];
$i++;
}
} while ($row = $db->sql_fetchrow($result));
$db->sql_freeresult($result);
// Send the messages
include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
include_once $phpbb_root_path . 'includes/functions_user.' . $phpEx;
$messenger = new messenger($use_queue);
$errored = false;
$email_template = 'admin_send_email';
$template_data = array('CONTACT_EMAIL' => phpbb_get_board_contact($config, $phpEx), 'MESSAGE' => htmlspecialchars_decode($message));
$generate_log_entry = true;
/**
* Modify email template data before the emails are sent
*
* @event core.acp_email_send_before
* @var string email_template The template to be used for sending the email
* @var string subject The subject of the email
* @var array template_data Array with template data assigned to email template
* @var bool generate_log_entry If false, no log entry will be created
* @var array usernames Usernames which will be displayed in log entry, if it will be created
* @var int group_id The group this email will be sent to
* @var bool use_queue If true, email queue will be used for sending
* @var int priority Priority of sent emails
* @since 3.1.3-RC1
*/
$vars = array('email_template', 'subject', 'template_data', 'generate_log_entry', 'usernames', 'group_id', 'use_queue', 'priority');
extract($phpbb_dispatcher->trigger_event('core.acp_email_send_before', compact($vars)));
for ($i = 0, $size = sizeof($email_list); $i < $size; $i++) {
$used_lang = $email_list[$i][0]['lang'];
$used_method = $email_list[$i][0]['method'];
for ($j = 0, $list_size = sizeof($email_list[$i]); $j < $list_size; $j++) {
$email_row = $email_list[$i][$j];
$messenger->{sizeof($email_list[$i]) == 1 ? 'to' : 'bcc'}($email_row['email'], $email_row['name']);
$messenger->im($email_row['jabber'], $email_row['name']);
}
$messenger->template($email_template, $used_lang);
$messenger->anti_abuse_headers($config, $user);
$messenger->subject(htmlspecialchars_decode($subject));
$messenger->set_mail_priority($priority);
$messenger->assign_vars($template_data);
if (!$messenger->send($used_method)) {
$errored = true;
}
}
unset($email_list);
$messenger->save_queue();
if ($generate_log_entry) {
if (!empty($usernames)) {
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_MASS_EMAIL', false, array(implode(', ', utf8_normalize_nfc($usernames))));
} else {
if ($group_id) {
$group_name = get_group_name($group_id);
} else {
// Not great but the logging routine doesn't cope well with localising on the fly
$group_name = $user->lang['ALL_USERS'];
}
$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_MASS_EMAIL', false, array($group_name));
}
}
if (!$errored) {
$message = $use_queue ? $user->lang['EMAIL_SENT_QUEUE'] : $user->lang['EMAIL_SENT'];
trigger_error($message . adm_back_link($this->u_action));
} else {
$message = sprintf($user->lang['EMAIL_SEND_ERROR'], '<a href="' . append_sid("{$phpbb_admin_path}index.{$phpEx}", 'i=logs&mode=critical') . '">', '</a>');
trigger_error($message . adm_back_link($this->u_action), E_USER_WARNING);
}
}
}
// Exclude bots and guests...
$sql = 'SELECT group_id
FROM ' . GROUPS_TABLE . "\n\t\t\tWHERE group_name IN ('BOTS', 'GUESTS')";
$result = $db->sql_query($sql);
$exclude = array();
while ($row = $db->sql_fetchrow($result)) {
$exclude[] = $row['group_id'];
}
$db->sql_freeresult($result);
$select_list = '<option value="0"' . (!$group_id ? ' selected="selected"' : '') . '>' . $user->lang['ALL_USERS'] . '</option>';
$select_list .= group_select_options($group_id, $exclude);
$s_priority_options = '<option value="' . MAIL_LOW_PRIORITY . '">' . $user->lang['MAIL_LOW_PRIORITY'] . '</option>';
$s_priority_options .= '<option value="' . MAIL_NORMAL_PRIORITY . '" selected="selected">' . $user->lang['MAIL_NORMAL_PRIORITY'] . '</option>';
$s_priority_options .= '<option value="' . MAIL_HIGH_PRIORITY . '">' . $user->lang['MAIL_HIGH_PRIORITY'] . '</option>';
$template_data = array('S_WARNING' => sizeof($error) ? true : false, 'WARNING_MSG' => sizeof($error) ? implode('<br />', $error) : '', 'U_ACTION' => $this->u_action, 'S_GROUP_OPTIONS' => $select_list, 'USERNAMES' => implode("\n", $usernames), 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=searchuser&form=acp_email&field=usernames'), 'SUBJECT' => $subject, 'MESSAGE' => $message, 'S_PRIORITY_OPTIONS' => $s_priority_options);
/**
* Modify custom email template data before we display the form
*
* @event core.acp_email_display
* @var array template_data Array with template data assigned to email template
* @var array exclude Array with groups which are excluded from group selection
* @var array usernames Usernames which will be displayed in form
*
* @since 3.1.4-RC1
*/
$vars = array('template_data', 'exclude', 'usernames');
extract($phpbb_dispatcher->trigger_event('core.acp_email_display', compact($vars)));
$template->assign_vars($template_data);
}
示例7: user_notification
//.........这里部分代码省略.........
$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 = " . NOTIFY_YES . '
AND 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 = " . NOTIFY_YES . '
AND 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();
$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'];
$msg_list_ary[$row['template']][$pos]['user_id'] = $row['user_id'];
}
unset($msg_users);
foreach ($msg_list_ary as $email_template => $email_list) {
foreach ($email_list as $addr) {
$messenger->template($email_template, $addr['lang']);
$messenger->to($addr['email'], $addr['name']);
$messenger->im($addr['jabber'], $addr['name']);
$messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($addr['name']), 'TOPIC_TITLE' => htmlspecialchars_decode($topic_title), 'FORUM_NAME' => htmlspecialchars_decode($forum_name), 'U_FORUM' => generate_board_url() . "/viewforum.{$phpEx}?f={$forum_id}", 'U_TOPIC' => generate_board_url() . "/viewtopic.{$phpEx}?f={$forum_id}&t={$topic_id}", '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}?uid={$addr['user_id']}&f={$forum_id}&t={$topic_id}&unwatch=topic", 'U_STOP_WATCHING_FORUM' => generate_board_url() . "/viewforum.{$phpEx}?uid={$addr['user_id']}&f={$forum_id}&unwatch=forum"));
$messenger->send($addr['method']);
}
}
unset($msg_list_ary);
$messenger->save_queue();
}
// Handle the DB updates
$db->sql_transaction('begin');
if (!empty($update_notification['topic'])) {
$sql = 'UPDATE ' . TOPICS_WATCH_TABLE . '
SET notify_status = ' . NOTIFY_NO . "\n\t\t\tWHERE topic_id = {$topic_id}\n\t\t\t\tAND " . $db->sql_in_set('user_id', $update_notification['topic']);
$db->sql_query($sql);
}
if (!empty($update_notification['forum'])) {
$sql = 'UPDATE ' . FORUMS_WATCH_TABLE . '
SET notify_status = ' . NOTIFY_NO . "\n\t\t\tWHERE forum_id = {$forum_id}\n\t\t\t\tAND " . $db->sql_in_set('user_id', $update_notification['forum']);
$db->sql_query($sql);
}
// Now delete the user_ids not authorised to receive notifications on this topic/forum
if (!empty($delete_ids['topic'])) {
$sql = 'DELETE FROM ' . TOPICS_WATCH_TABLE . "\n\t\t\tWHERE topic_id = {$topic_id}\n\t\t\t\tAND " . $db->sql_in_set('user_id', $delete_ids['topic']);
$db->sql_query($sql);
}
if (!empty($delete_ids['forum'])) {
$sql = 'DELETE FROM ' . FORUMS_WATCH_TABLE . "\n\t\t\tWHERE forum_id = {$forum_id}\n\t\t\t\tAND " . $db->sql_in_set('user_id', $delete_ids['forum']);
$db->sql_query($sql);
}
$db->sql_transaction('commit');
}
示例8: user_justification_activate
/**
* Activate user
*
* @param object $event The event object
* @return null
* @access public
*/
private function user_justification_activate()
{
$user = $this->data;
if (!function_exists('user_active_flip')) {
include $this->root_path . 'includes/functions_user.' . $this->php_ext;
}
if (!class_exists('messenger')) {
include $this->root_path . 'includes/functions_messenger.' . $this->php_ext;
}
user_active_flip('activate', $user['user_id']);
$messenger = new \messenger(false);
$messenger->template('admin_welcome_activated', $user['user_lang']);
$messenger->to($user['user_email'], $user['username']);
$messenger->anti_abuse_headers($this->config, $this->user);
$messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($user['username'])));
$messenger->send(NOTIFY_EMAIL);
$messenger->save_queue();
$this->log->add('user', $this->user->data['user_id'], $this->user->ip, 'LOG_USER_ACTIVE', time(), array($user['username']));
}
示例9: 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);
}
//.........这里部分代码省略.........
示例10: sprintf
$presence_img = '<img src="http://web.icq.com/whitepages/online?icq=' . $row[$sql_field] . '&img=5" width="18" height="18" border="0" alt="" />';
break;
case 'jabber':
if ($submit && @extension_loaded('xml')) {
// Add class loader
require_once $site_file_root . 'includes/forums/functions_messenger.php';
$subject = sprintf($_CLASS['core_user']->lang['IM_JABBER_SUBJECT'], $_CLASS['core_user']->data['username'], $config['server_name']);
$message = $_POST['message'];
$messenger = new messenger();
$messenger->template('profile_send_email', $row['user_lang']);
$messenger->subject($subject);
$messenger->replyto($_CLASS['core_user']->data['user_email']);
$messenger->im($row['user_jabber'], $row['username']);
$messenger->assign_vars(array('SITENAME' => $_CORE_CONFIG['global']['site_name'], 'BOARD_EMAIL' => $config['board_contact'], 'FROM_USERNAME' => $_CLASS['core_user']->data['username'], 'TO_USERNAME' => $row['username'], 'MESSAGE' => $message));
$messenger->send(NOTIFY_IM);
$messenger->save_queue();
$s_select = 'S_SENT_JABBER';
}
break;
}
$_CLASS['core_template']->assign_array(array('CONTACT_NAME' => $row[$sql_field], 'IM_CONTACT' => $row[$sql_field], 'USERNAME' => addslashes($row['username']), 'EMAIL' => $row['user_email'], 'SITENAME' => addslashes($_CORE_CONFIG['global']['site_name']), 'PRESENCE_IMG' => $presence_img, 'L_SEND_IM_EXPLAIN' => $_CLASS['core_user']->lang['IM_' . $lang], 'L_IM_SENT_JABBER' => sprintf($_CLASS['core_user']->lang['IM_SENT_JABBER'], $row['username']), $s_select => true, 'S_IM_ACTION' => $s_action));
break;
case 'viewprofile':
// Display a profile
if ($user_id == ANONYMOUS) {
trigger_error('NO_USER');
}
// We left join on the session table to see if the user is currently online
$sql = 'SELECT username, user_id, user_type, user_status, user_group, user_colour, user_permissions, user_sig,
user_sig_bbcode_uid, user_sig_bbcode_bitfield, user_allow_viewemail, user_posts, user_reg_date, user_rank,
user_from, user_occ, user_interests, user_website, user_email, user_icq, user_aim, user_yim, user_msnm,
示例11: sprintf
/**
* Notify users about karma's changes (via PM/email/jabber)
*/
function user_notification($data)
{
global $user, $db;
$forum_id = $data['forum_id'];
$topic_id = $data['topic_id'];
$post_id = $data['post_id'];
$user_id = $data['user_id'];
$sql = 'SELECT user_karma_notify_pm, user_karma_notify_email, user_karma_notify_jabber
FROM ' . USERS_TABLE . '
WHERE user_id = ' . $user_id;
$result = $db->sql_query($sql);
$to_user = $db->sql_fetchrow($result);
$notifications['pm'] = $this->config['notify_pm'] && $to_user['user_karma_notify_pm'];
$notifications['email'] = $this->config['notify_email'] && $to_user['user_karma_notify_email'];
$notifications['jabber'] = $this->config['notify_jabber'] && $to_user['user_karma_notify_jabber'];
$from_user_id = $user->data['user_id'];
$from_username = $user->data['username'];
// Select template for messenger, subject and message
if ($data['action'] == 'increase') {
$subject = 'KARMA_NOTIFY_INCREASE_SUBJECT';
$message = 'KARMA_NOTIFY_INCREASE_MESSAGE';
$notify_tpl = 'karma_notify_increase';
if ($this->config['anonym_increase']) {
$message .= '_ANONYM';
$notify_tpl .= '_anonym';
$from_user_id = $data['user_id'];
$from_username = $user->lang['KARMA_NOTIFY_HIDDEN_SENDER'];
}
} else {
$subject = 'KARMA_NOTIFY_DECREASE_SUBJECT';
$message = 'KARMA_NOTIFY_DECREASE_MESSAGE';
$notify_tpl = 'karma_notify_decrease';
if ($this->config['anonym_decrease']) {
$message .= '_ANONYM';
$notify_tpl .= '_anonym';
$from_user_id = $data['user_id'];
$from_username = $user->lang['KARMA_NOTIFY_HIDDEN_SENDER'];
}
}
if ($this->config['power_show']) {
$message .= '_POWERED';
$notify_tpl .= '_powered';
}
if ($notifications['pm']) {
global $config, $phpbb_root_path, $phpEx;
$subject = $user->lang[$subject];
$message = sprintf($user->lang[$message], $user->data['username'], $data['karma_power']);
$message .= !empty($data['comment']) ? "\r\n" . sprintf($user->lang['KARMA_NOTIFY_MESSAGE_COMMENTS'], $user->data['username']) . "\r\n\r\n" . $data['comment'] : '';
$message .= "\r\n\r\n" . $this->generate_backlink($forum_id, $topic_id, $post_id, $user_id);
include $phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx;
$message_parser = new parse_message();
$message = utf8_normalize_nfc($message);
$options = '';
generate_text_for_storage($message, $data['bbcode_uid'], $data['bbcode_bitfield'], $options, true, true, true);
$icon_id = $data['icon_id'];
// Always attach signature status
$enable_sig = !$config['allow_sig'] || !$config['allow_sig_pm'] ? false : ($user->optionget('attachsig') ? true : false);
// Store message, sync counters
$pm_data = array('from_user_id' => $from_user_id, 'from_user_ip' => $user->data['user_ip'], 'from_username' => $from_username, 'icon_id' => (int) $icon_id, 'enable_sig' => (bool) $enable_sig, 'enable_bbcode' => $data['enable_bbcode'], 'enable_smilies' => $data['enable_smilies'], 'enable_urls' => $data['enable_urls'], 'bbcode_bitfield' => $data['bbcode_bitfield'], 'bbcode_uid' => $data['bbcode_uid'], 'author_id' => $user->data['user_id'], 'message' => $message, 'address_list' => array('u' => array($data['user_id'] => 'to')));
unset($message_parser);
submit_pm('post', $subject, $pm_data, false);
}
if ($notifications['email'] || $notifications['jabber']) {
if ($notifications['email'] && $notifications['jabber'] && $config['email_enable'] && $config['jab_enable']) {
$method = NOTIFY_BOTH;
} else {
if ($notifications['email'] && $config['email_enable']) {
$method = NOTIFY_EMAIL;
} else {
if ($notifications['jabber'] && $config['jab_enable']) {
$method = NOTIFY_IM;
} else {
return;
}
}
}
$comment = '';
if ($this->config['comments'] && $data['comment']) {
$comment = $data['comment'];
// make list items visible as such
if ($data['bbcode_uid']) {
$comment = str_replace('[*:' . $data['bbcode_uid'] . ']', '⋅ ', $comment);
// no BBCode in comment
strip_bbcode($comment, $data['bbcode_uid']);
}
$comment = "\r\n" . $user->lang['KARMA_NOTIFY_MESSAGE_COMMENTS'] . "\r\n" . $comment . "\r\n";
}
// Now, we are able to really send out notifications
global $db, $phpbb_root_path, $phpEx;
include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
$messenger = new messenger();
$messenger->template($notify_tpl, $user->data['user_lang']);
$messenger->to($user->data['user_email'], $user->data['username']);
$messenger->im($user->data['user_jabber'], $user->data['username']);
$messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($data['username']), 'AUTHOR_NAME' => htmlspecialchars_decode($user->data['username']), 'POWER' => $data['karma_power'], 'BACKLINK' => $this->generate_backlink($forum_id, $topic_id, $post_id, $user_id), 'COMMENT' => $comment));
$messenger->send($method);
$messenger->save_queue();
//.........这里部分代码省略.........
示例12: main
function main($id, $mode)
{
global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx;
$user->add_lang('posting');
$preview = !empty($_POST['preview']) ? true : false;
$submit = !empty($_POST['submit']) ? true : false;
$delete = !empty($_POST['delete']) ? true : false;
$error = $data = array();
$s_hidden_fields = '';
switch ($mode) {
case 'reg_details':
if ($submit) {
$var_ary = array('username' => $user->data['username'], 'email' => $user->data['user_email'], 'email_confirm' => (string) '', 'new_password' => (string) '', 'cur_password' => (string) '', 'password_confirm' => (string) '');
foreach ($var_ary as $var => $default) {
$data[$var] = request_var($var, $default);
}
$var_ary = array('password_confirm' => array('string', true, $config['min_pass_chars'], $config['max_pass_chars']), 'new_password' => array('string', true, $config['min_pass_chars'], $config['max_pass_chars']), 'cur_password' => array('string', true, $config['min_pass_chars'], $config['max_pass_chars']), 'email' => array(array('string', false, 6, 60), array('email', $data['email'])), 'email_confirm' => array('string', true, 6, 60));
if ($auth->acl_get('u_chgname') && $config['allow_namechange']) {
$var_ary['username'] = array(array('string', false, $config['min_name_chars'], $config['max_name_chars']), array('username', $data['username']));
}
$error = validate_data($data, $var_ary);
extract($data);
unset($data);
if ($auth->acl_get('u_chgpasswd') && $new_password && $password_confirm != $new_password) {
$error[] = 'NEW_PASSWORD_ERROR';
}
if (($new_password || $auth->acl_get('u_chgemail') && $email != $user->data['user_email'] || $username != $user->data['username'] && $auth->acl_get('u_chgname') && $config['allow_namechange']) && md5($cur_password) != $user->data['user_password']) {
$error[] = 'CUR_PASSWORD_ERROR';
}
if ($auth->acl_get('u_chgemail') && $email != $user->data['user_email'] && $email_confirm != $email) {
$error[] = 'NEW_EMAIL_ERROR';
}
if (!sizeof($error)) {
$sql_ary = array('username' => $auth->acl_get('u_chgname') && $config['allow_namechange'] ? $username : $user->data['username'], 'user_email' => $auth->acl_get('u_chgemail') ? $email : $user->data['user_email'], 'user_email_hash' => $auth->acl_get('u_chgemail') ? crc32(strtolower($email)) . strlen($email) : $user->data['user_email_hash'], 'user_password' => $auth->acl_get('u_chgpasswd') && $new_password ? md5($new_password) : $user->data['user_password'], 'user_passchg' => $auth->acl_get('u_chgpasswd') && $new_password ? time() : 0);
if ($auth->acl_get('u_chgname') && $config['allow_namechange'] && $username != $user->data['username']) {
add_log('user', $user->data['user_id'], 'LOG_USER_UPDATE_NAME', $user->data['username'], $username);
}
if ($auth->acl_get('u_chgpasswd') && $new_password && md5($new_password) != $user->data['user_password']) {
$user->reset_login_keys();
add_log('user', $user->data['user_id'], 'LOG_USER_NEW_PASSWORD', $username);
}
if ($auth->acl_get('u_chgemail') && $email != $user->data['user_email']) {
add_log('user', $user->data['user_id'], 'LOG_USER_UPDATE_EMAIL', $username, $user->data['user_email'], $email);
}
if ($config['email_enable'] && $email != $user->data['user_email'] && ($config['require_activation'] == USER_ACTIVATION_SELF || $config['require_activation'] == USER_ACTIVATION_ADMIN)) {
include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
$server_url = generate_board_url();
$user_actkey = gen_rand_string(10);
$key_len = 54 - strlen($server_url);
$key_len = $key_len > 6 ? $key_len : 6;
$user_actkey = substr($user_actkey, 0, $key_len);
$messenger = new messenger();
$template_file = $config['require_activation'] == USER_ACTIVATION_ADMIN ? 'user_activate_inactive' : 'user_activate';
$messenger->template($template_file, $user->data['user_lang']);
$messenger->replyto($config['board_contact']);
$messenger->to($email, $username);
$messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']);
$messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
$messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']);
$messenger->headers('X-AntiAbuse: User IP - ' . $user->ip);
$messenger->assign_vars(array('SITENAME' => $config['sitename'], 'USERNAME' => html_entity_decode($username), 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']), 'U_ACTIVATE' => "{$server_url}/ucp.{$phpEx}?mode=activate&u={$user->data['user_id']}&k={$user_actkey}"));
$messenger->send(NOTIFY_EMAIL);
if ($config['require_activation'] == USER_ACTIVATION_ADMIN) {
// Grab an array of user_id's with a_user permissions
$admin_ary = $auth->acl_get_list(false, 'a_user', false);
$sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type
FROM ' . USERS_TABLE . '
WHERE user_id IN (' . implode(', ', $admin_ary[0]['a_user']) . ')';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
$messenger->template('admin_activate', $row['user_lang']);
$messenger->replyto($config['board_contact']);
$messenger->to($row['user_email'], $row['username']);
$messenger->im($row['user_jabber'], $row['username']);
$messenger->assign_vars(array('USERNAME' => html_entity_decode($username), 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']), 'U_ACTIVATE' => "{$server_url}/ucp.{$phpEx}?mode=activate&u={$user->data['user_id']}&k={$user_actkey}"));
$messenger->send($row['user_notify_type']);
}
$db->sql_freeresult($result);
}
$messenger->save_queue();
$sql_ary += array('user_type' => USER_INACTIVE, 'user_actkey' => $user_actkey);
}
if (sizeof($sql_ary)) {
$sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
WHERE user_id = ' . $user->data['user_id'];
$db->sql_query($sql);
}
// Need to update config, forum, topic, posting, messages, etc.
if ($username != $user->data['username'] && $auth->acl_get('u_chgname') && $config['allow_namechange']) {
user_update_name($user->data['username'], $username);
}
meta_refresh(3, $this->u_action);
$message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
trigger_error($message);
}
// Replace "error" strings with their real, localised form
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
}
$user_char_ary = array('.*' => 'USERNAME_CHARS_ANY', '[\\w]+' => 'USERNAME_ALPHA_ONLY', '[\\w_\\+\\. \\-\\[\\]]+' => 'USERNAME_ALPHA_SPACERS');
//.........这里部分代码省略.........
示例13: meet_notification
public function meet_notification($author, $recipients, $subject, $message, $group_id, $info, $meeting_type)
{
global $db, $user, $config, $phpbb_root_path, $phpEx, $auth;
$subject = censor_text($subject);
if (!sizeof($recipients)) {
return;
}
if (!in_array(-1, $group_id) && !in_array(-2, $group_id)) {
return;
} else {
if (in_array(-2, $group_id)) {
$array_user_id = array_map('intval', array_keys($recipients));
$sql2 = "SELECT * FROM " . ZEBRA_TABLE . "\n\t\t\t\tWHERE user_id = " . $user->data['user_id'] . "\n\t\t\t\tAND " . $db->sql_in_set('zebra_id', array_map('intval', array_keys($recipients))) . "\n\t\t\t\tAND friend = 1";
$result2 = $db->sql_query($sql2);
unset($recipients);
while ($row2 = $db->sql_fetchrow($result2)) {
$recipients[$row2['zebra_id']] = $row2['zebra_id'];
}
$db->sql_freeresult($result2);
}
}
unset($recipients[ANONYMOUS], $recipients[$user->data['user_id']]);
if (!sizeof($recipients)) {
return;
}
$sql = 'SELECT user_id, username, user_email, user_lang, user_notify_pm, user_notify_type, user_jabber
FROM ' . USERS_TABLE . '
WHERE ' . $db->sql_in_set('user_id', array_map('intval', array_keys($recipients)));
$result = $db->sql_query($sql);
$msg_list_ary = array();
while ($row = $db->sql_fetchrow($result)) {
if (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)) {
//trigger_error('No msg list');
return;
}
if ($user->data['user_id'] == 3) {
//trigger_error($msg_list_ary[0]['name'] . $msg_list_ary[1]['name']);
}
include_once $phpbb_root_path . 'includes/functions_messenger.' . $phpEx;
$messenger = new messenger();
foreach ($msg_list_ary as $pos => $addr) {
$messenger->template('meeting_notify', $addr['lang']);
$messenger->to($addr['email'], $addr['name']);
$messenger->im($addr['jabber'], $addr['name']);
$messenger->assign_vars(array('INFO' => $info, 'TYPE' => $meeting_type, 'SUBJECT' => htmlspecialchars_decode($subject), 'AUTHOR_NAME' => htmlspecialchars_decode($author), 'USERNAME' => htmlspecialchars_decode($addr['name']), 'U_INBOX' => generate_board_url() . $message));
$messenger->send($addr['method']);
}
unset($msg_list_ary);
$messenger->save_queue();
unset($messenger);
return;
}
示例14: send_mail_notify_comment
function send_mail_notify_comment($user_lang, $user_email, $username, $user_jabber, $ad_id, $user_notify_type)
{
global $messenger, $config, $phpEx;
$messenger = new messenger();
$messenger->template('cl_comment', $user_lang);
$messenger->to($user_email, $username);
$messenger->im($user_jabber, $username);
$messenger->assign_vars(array('USERNAME' => $username, 'SITE_NAME' => $config['sitename'], 'AD_LINK' => generate_board_url() . "/" . CL_DIRECTORY . "/single_ad.{$phpEx}" . "?ad_id=" . $ad_id, 'SIGNATURE' => $config['board_email_sig']));
$messenger->send($user_notify_type);
$messenger->save_queue();
}
示例15: 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';
}
//.........这里部分代码省略.........