1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-10 18:54:08 +02:00

Let's break lots of things

git-svn-id: file:///svn/phpbb/trunk@4578 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Paul S. Owen
2003-10-12 11:59:23 +00:00
parent 3bd4218780
commit eeb4907112
21 changed files with 353 additions and 334 deletions

View File

@@ -175,6 +175,7 @@ if ($sql != '')
prepare_data($message_parser->attachment_data[$pos]['real_filename'], TRUE);
prepare_data($message_parser->attachment_data[$pos]['extension'], TRUE);
prepare_data($message_parser->attachment_data[$pos]['mimetype'], TRUE);
$message_parser->attachment_data[$pos]['filesize'] = (int) $message_parser->attachment_data[$pos]['filesize'];
$message_parser->attachment_data[$pos]['filetime'] = (int) $message_parser->attachment_data[$pos]['filetime'];
$message_parser->attachment_data[$pos]['attach_id'] = (int) $message_parser->attachment_data[$pos]['attach_id'];
@@ -211,8 +212,8 @@ if ($sql != '')
if (!in_array($mode, array('quote', 'edit', 'delete')))
{
$enable_sig = ($config['allow_sig'] && $user->optionget('attachsig')) ? TRUE : FALSE;
$enable_smilies = ($config['allow_smilies'] && $user->optionget('allowsmile')) ? TRUE : FALSE;
$enable_bbcode = ($config['allow_bbcode'] && $user->optionget('allowbbcode')) ? TRUE : FALSE;
$enable_smilies = ($config['allow_smilies'] && $user->optionget('smile')) ? TRUE : FALSE;
$enable_bbcode = ($config['allow_bbcode'] && $user->optionget('bbcode')) ? TRUE : FALSE;
$enable_urls = TRUE;
}
@@ -1134,7 +1135,7 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id
$notify_rows = array();
// -- get forum_userids || topic_userids
$sql = 'SELECT u.user_id, u.username, u.user_email, u.user_lang
$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) . "
AND w.user_id NOT IN ($sql_ignore_users)
@@ -1148,9 +1149,11 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id
'user_id' => $row['user_id'],
'username' => $row['username'],
'user_email' => $row['user_email'],
'user_lang' => $row['user_lang'],
'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
);
}
@@ -1164,7 +1167,7 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id
$sql_ignore_users .= ', ' . implode(', ', array_keys($notify_rows));
}
$sql = 'SELECT u.user_id, u.username, u.user_email, u.user_lang
$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
WHERE fw.forum_id = $forum_id
AND fw.user_id NOT IN ($sql_ignore_users)
@@ -1178,9 +1181,11 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id
'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
);
}
@@ -1192,112 +1197,101 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id
return;
}
// We have all users informations we want, now check if they are actually permitted to receive a notification
$sql = 'SELECT a.user_id
FROM ' . ACL_OPTIONS_TABLE . ' ao, ' . ACL_USERS_TABLE . ' a
WHERE a.user_id IN (' . implode(', ', array_keys($notify_rows)) . ")
AND ao.auth_option_id = a.auth_option_id
AND ao.auth_option = 'f_read'
AND a.forum_id = $forum_id";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
$perms = array();
/* foreach (discover_auth(array_keys($notify_rows), array('f_read'), $forum_id) as $user_id => $forum_ary)
{
$notify_rows[$row['user_id']]['allowed'] = true;
}
$db->sql_freeresult($result);
// Now grab group settings...
$sql = 'SELECT ug.user_id, MIN(a.auth_setting) as min_setting
FROM ' . USER_GROUP_TABLE . ' ug, ' . ACL_OPTIONS_TABLE . ' ao, ' . ACL_GROUPS_TABLE . ' a
WHERE ug.user_id IN (' . implode(', ', array_keys($notify_rows)) . ")
AND a.group_id = ug.group_id
AND ao.auth_option_id = a.auth_option_id
AND ao.auth_option = 'f_read'
AND a.forum_id = $forum_id
GROUP BY ug.user_id";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
if ($row['min_setting'] == 1)
foreach ($forum_ary as $forum_id => $option_ary)
{
$notify_rows[$row['user_id']]['allowed'] = true;
if (array_sum(array_values($option_ary)))
{
echo array_sum(array_values($option_ary));
echo " >> ";
// $perms[] = $user_id;
// break;
}
}
print_r($forum_ary);
}
$db->sql_freeresult($result);
*/
// Now, we have to do a little step before really sending, we need to distinguish our users a little bit. ;)
$email_users = $delete_ids = $update_notification = array();
foreach ($notify_rows as $user_id => $row)
{
if (!$row['allowed'] || trim($row['user_email']) == '')
if (!$row['allowed'] || !trim($row['user_email']))
{
$delete_ids[$row['notify_type']][] = $row['user_id'];
}
else
{
$email_users[] = $row;
$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($email_users) && $config['email_enable'])
if (sizeof($msg_users))
{
@set_time_limit(60);
include_once($phpbb_root_path . 'includes/functions_messenger.'.$phpEx);
$messenger = new messenger();
include($phpbb_root_path . 'includes/emailer.'.$phpEx);
$emailer = new emailer(TRUE); // use queue
$email_sig = str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']);
$email_list_ary = array();
foreach ($email_users as $row)
$msg_list_ary = array();
foreach ($msg_users as $row)
{
$pos = sizeof($email_list_ary[$row['template']]);
$email_list_ary[$row['template']][$pos]['email'] = $row['user_email'];
$email_list_ary[$row['template']][$pos]['name'] = $row['username'];
$email_list_ary[$row['template']][$pos]['lang'] = $row['user_lang'];
$pos = 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]['user_jabber'] = $row['user_jabber'];
$msg_list_ary[$row['template']][$pos]['name'] = $row['username'];
$msg_list_ary[$row['template']][$pos]['lang'] = $row['user_lang'];
}
unset($email_users);
foreach ($email_list_ary as $email_template => $email_list)
foreach ($msg_list_ary as $email_template => $email_list)
{
foreach ($email_list as $addr)
{
$emailer->template($email_template, $addr['lang']);
$messenger->template($email_template, $addr['lang']);
$emailer->replyto($config['board_email']);
$emailer->to($addr['email'], $addr['name']);
$messenger->replyto($config['board_email']);
$messenger->to($addr['email'], $addr['name']);
$emailer->assign_vars(array(
'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']),
$messenger->assign_vars(array(
'EMAIL_SIG' => $email_sig,
'SITENAME' => $config['sitename'],
'TOPIC_TITLE' => trim($topic_title),
'FORUM_NAME' => trim($forum_name),
'TOPIC_TITLE' => $topic_title,
'FORUM_NAME' => $forum_name,
'U_NEWEST_POST' => generate_board_url() . '/viewtopic.'.$phpEx . '?e=1&t=' . $topic_id . '&p=' . $post_id . '#' . $post_id,
'U_TOPIC' => generate_board_url() . '/viewtopic.'.$phpEx . '?e=1&t=' . $topic_id,
'U_FORUM' => generate_board_url() . '/viewforum.'.$phpEx . '?e=1&f=' . $forum_id,
'U_STOP_WATCHING_TOPIC' => generate_board_url() . '/viewtopic.'.$phpEx . '?t=' . $topic_id . '&unwatch=topic',
'U_STOP_WATCHING_FORUM' => generate_board_url() . '/viewforum.'.$phpEx . '?f=' . $forum_id . '&unwatch=forum')
);
'U_FORUM' => generate_board_url() . "/viewforum.$phpEx?f=$forum_id&e=1",
'U_TOPIC' => generate_board_url() . "/viewtopic.$phpEx?f=$forum_id&t=$topic_id&e=1",
'U_NEWEST_POST' => generate_board_url() . "/viewtopic.$phpEx?f=$forum_id&t=$topic_id&p=$post_id&e=1#$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",
));
$emailer->send();
$emailer->reset();
$messenger->send($addr['method']);
$messenger->reset();
}
}
unset($email_list_ary);
$emailer->mail_queue->save();
}
$messenger->queue->save();
// Handle the DB updates
$db->sql_transaction();
// Now update the notification status
if (sizeof($update_notification['topic']))
{
$sql = "UPDATE " . TOPICS_WATCH_TABLE . "
$sql = 'UPDATE ' . TOPICS_WATCH_TABLE . "
SET notify_status = 1
WHERE topic_id = $topic_id
AND user_id IN (" . implode(', ', $update_notification['topic']) . ")";
@@ -1306,7 +1300,7 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id
if (sizeof($update_notification['forum']))
{
$sql = "UPDATE " . FORUMS_WATCH_TABLE . "
$sql = 'UPDATE ' . FORUMS_WATCH_TABLE . "
SET notify_status = 1
WHERE forum_id = $forum_id
AND user_id IN (" . implode(', ', $update_notification['forum']) . ")";
@@ -1316,7 +1310,7 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id
// Now delete the user_ids not authorized to receive notifications on this topic/forum
if (sizeof($delete_ids['topic']))
{
$sql = "DELETE FROM " . TOPICS_WATCH_TABLE . "
$sql = 'DELETE FROM ' . TOPICS_WATCH_TABLE . "
WHERE topic_id = $topic_id
AND user_id IN (" . implode(', ', $delete_ids['topic']) . ")";
$db->sql_query($sql);
@@ -1324,7 +1318,7 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id
if (sizeof($delete_ids['forum']))
{
$sql = "DELETE FROM " . FORUMS_WATCH_TABLE . "
$sql = 'DELETE FROM ' . FORUMS_WATCH_TABLE . "
WHERE forum_id = $forum_id
AND user_id IN (" . implode(', ', $delete_ids['forum']) . ")";
$db->sql_query($sql);