mirror of
https://github.com/phpbb/phpbb.git
synced 2025-03-14 04:30:29 +01:00
[ticket/10484] Use variables for sql_build_query() calls
It's easier for mods/extensions to extend the arrays. PHPBB3-10484
This commit is contained in:
parent
ff91c037c9
commit
4c77903129
@ -2366,7 +2366,7 @@ function cache_moderators()
|
||||
$ug_id_ary = array_keys($hold_ary);
|
||||
|
||||
// Remove users who have group memberships with DENY moderator permissions
|
||||
$sql = $db->sql_build_query('SELECT', array(
|
||||
$sql_ary = array(
|
||||
'SELECT' => 'a.forum_id, ug.user_id, g.group_id',
|
||||
|
||||
'FROM' => array(
|
||||
@ -2379,8 +2379,8 @@ function cache_moderators()
|
||||
'LEFT_JOIN' => array(
|
||||
array(
|
||||
'FROM' => array(ACL_ROLES_DATA_TABLE => 'r'),
|
||||
'ON' => 'a.auth_role_id = r.role_id'
|
||||
)
|
||||
'ON' => 'a.auth_role_id = r.role_id',
|
||||
),
|
||||
),
|
||||
|
||||
'WHERE' => '(o.auth_option_id = a.auth_option_id OR o.auth_option_id = r.auth_option_id)
|
||||
@ -2392,7 +2392,8 @@ function cache_moderators()
|
||||
AND ' . $db->sql_in_set('ug.user_id', $ug_id_ary) . "
|
||||
AND ug.user_pending = 0
|
||||
AND o.auth_option " . $db->sql_like_expression('m_' . $db->any_char),
|
||||
));
|
||||
);
|
||||
$sql = $db->sql_build_query('SELECT', $sql_ary);
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
@ -2792,18 +2793,18 @@ function update_foes($group_id = false, $user_id = false)
|
||||
if (is_array($group_id) && sizeof($group_id))
|
||||
{
|
||||
// Grab group settings...
|
||||
$sql = $db->sql_build_query('SELECT', array(
|
||||
$sql_ary = array(
|
||||
'SELECT' => 'a.group_id',
|
||||
|
||||
'FROM' => array(
|
||||
ACL_OPTIONS_TABLE => 'ao',
|
||||
ACL_GROUPS_TABLE => 'a'
|
||||
ACL_GROUPS_TABLE => 'a',
|
||||
),
|
||||
|
||||
'LEFT_JOIN' => array(
|
||||
array(
|
||||
'FROM' => array(ACL_ROLES_DATA_TABLE => 'r'),
|
||||
'ON' => 'a.auth_role_id = r.role_id'
|
||||
'ON' => 'a.auth_role_id = r.role_id',
|
||||
),
|
||||
),
|
||||
|
||||
@ -2811,8 +2812,9 @@ function update_foes($group_id = false, $user_id = false)
|
||||
AND ' . $db->sql_in_set('a.group_id', $group_id) . "
|
||||
AND ao.auth_option IN ('a_', 'm_')",
|
||||
|
||||
'GROUP_BY' => 'a.group_id'
|
||||
));
|
||||
'GROUP_BY' => 'a.group_id',
|
||||
);
|
||||
$sql = $db->sql_build_query('SELECT', $sql_ary);
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$groups = array();
|
||||
|
@ -110,7 +110,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
|
||||
$sql_array['SELECT'] .= ', fa.user_id';
|
||||
}
|
||||
|
||||
$sql = $db->sql_build_query('SELECT', array(
|
||||
$sql_ary = array(
|
||||
'SELECT' => $sql_array['SELECT'],
|
||||
'FROM' => $sql_array['FROM'],
|
||||
'LEFT_JOIN' => $sql_array['LEFT_JOIN'],
|
||||
@ -118,8 +118,9 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
|
||||
'WHERE' => $sql_where,
|
||||
|
||||
'ORDER_BY' => 'f.left_id',
|
||||
));
|
||||
);
|
||||
|
||||
$sql = $db->sql_build_query('SELECT', $sql_ary);
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$forum_tracking_info = array();
|
||||
|
@ -1005,7 +1005,7 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id
|
||||
$mode = 'post_review';
|
||||
}
|
||||
|
||||
$sql = $db->sql_build_query('SELECT', array(
|
||||
$sql_ary = array(
|
||||
'SELECT' => 'u.username, u.user_id, u.user_colour, p.*, z.friend, z.foe',
|
||||
|
||||
'FROM' => array(
|
||||
@ -1016,14 +1016,15 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id
|
||||
'LEFT_JOIN' => array(
|
||||
array(
|
||||
'FROM' => array(ZEBRA_TABLE => 'z'),
|
||||
'ON' => 'z.user_id = ' . $user->data['user_id'] . ' AND z.zebra_id = p.poster_id'
|
||||
)
|
||||
'ON' => 'z.user_id = ' . $user->data['user_id'] . ' AND z.zebra_id = p.poster_id',
|
||||
),
|
||||
),
|
||||
|
||||
'WHERE' => $db->sql_in_set('p.post_id', $post_list) . '
|
||||
AND u.user_id = p.poster_id'
|
||||
));
|
||||
AND u.user_id = p.poster_id',
|
||||
);
|
||||
|
||||
$sql = $db->sql_build_query('SELECT', $sql_ary);
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$bbcode_bitfield = '';
|
||||
|
@ -158,7 +158,7 @@ function mcp_front_view($id, $mode, $action)
|
||||
|
||||
if ($total)
|
||||
{
|
||||
$sql = $db->sql_build_query('SELECT', array(
|
||||
$sql_ary = array(
|
||||
'SELECT' => 'r.report_time, p.post_id, p.post_subject, p.post_time, u.username, u.username_clean, u.user_colour, u.user_id, u2.username as author_name, u2.username_clean as author_name_clean, u2.user_colour as author_colour, u2.user_id as author_id, t.topic_id, t.topic_title, f.forum_id, f.forum_name',
|
||||
|
||||
'FROM' => array(
|
||||
@ -166,14 +166,14 @@ function mcp_front_view($id, $mode, $action)
|
||||
REPORTS_REASONS_TABLE => 'rr',
|
||||
TOPICS_TABLE => 't',
|
||||
USERS_TABLE => array('u', 'u2'),
|
||||
POSTS_TABLE => 'p'
|
||||
POSTS_TABLE => 'p',
|
||||
),
|
||||
|
||||
'LEFT_JOIN' => array(
|
||||
array(
|
||||
'FROM' => array(FORUMS_TABLE => 'f'),
|
||||
'ON' => 'f.forum_id = p.forum_id'
|
||||
)
|
||||
'ON' => 'f.forum_id = p.forum_id',
|
||||
),
|
||||
),
|
||||
|
||||
'WHERE' => 'r.post_id = p.post_id
|
||||
@ -185,8 +185,9 @@ function mcp_front_view($id, $mode, $action)
|
||||
AND p.poster_id = u2.user_id
|
||||
AND ' . $db->sql_in_set('p.forum_id', $forum_list),
|
||||
|
||||
'ORDER_BY' => 'p.post_time DESC'
|
||||
));
|
||||
'ORDER_BY' => 'p.post_time DESC',
|
||||
);
|
||||
$sql = $db->sql_build_query('SELECT', $sql_ary);
|
||||
$result = $db->sql_query_limit($sql, 5);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
@ -253,14 +254,14 @@ function mcp_front_view($id, $mode, $action)
|
||||
{
|
||||
include($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx);
|
||||
|
||||
$sql = $db->sql_build_query('SELECT', array(
|
||||
$sql_ary = array(
|
||||
'SELECT' => 'r.report_id, r.report_time, p.msg_id, p.message_subject, p.message_time, p.to_address, p.bcc_address, u.username, u.username_clean, u.user_colour, u.user_id, u2.username as author_name, u2.username_clean as author_name_clean, u2.user_colour as author_colour, u2.user_id as author_id',
|
||||
|
||||
'FROM' => array(
|
||||
REPORTS_TABLE => 'r',
|
||||
REPORTS_REASONS_TABLE => 'rr',
|
||||
USERS_TABLE => array('u', 'u2'),
|
||||
PRIVMSGS_TABLE => 'p'
|
||||
PRIVMSGS_TABLE => 'p',
|
||||
),
|
||||
|
||||
'WHERE' => 'r.pm_id = p.msg_id
|
||||
@ -270,8 +271,9 @@ function mcp_front_view($id, $mode, $action)
|
||||
AND r.user_id = u.user_id
|
||||
AND p.author_id = u2.user_id',
|
||||
|
||||
'ORDER_BY' => 'p.message_time DESC'
|
||||
));
|
||||
'ORDER_BY' => 'p.message_time DESC',
|
||||
);
|
||||
$sql_ary = $db->sql_build_query('SELECT', $sql_ary);
|
||||
$result = $db->sql_query_limit($sql, 5);
|
||||
|
||||
$pm_by_id = $pm_list = array();
|
||||
|
@ -274,19 +274,19 @@ if ($module->is_active('zebra', 'friends'))
|
||||
// Output listing of friends online
|
||||
$update_time = $config['load_online_time'] * 60;
|
||||
|
||||
$sql = $db->sql_build_query('SELECT_DISTINCT', array(
|
||||
$sql_ary = array(
|
||||
'SELECT' => 'u.user_id, u.username, u.username_clean, u.user_colour, MAX(s.session_time) as online_time, MIN(s.session_viewonline) AS viewonline',
|
||||
|
||||
'FROM' => array(
|
||||
USERS_TABLE => 'u',
|
||||
ZEBRA_TABLE => 'z'
|
||||
ZEBRA_TABLE => 'z',
|
||||
),
|
||||
|
||||
'LEFT_JOIN' => array(
|
||||
array(
|
||||
'FROM' => array(SESSIONS_TABLE => 's'),
|
||||
'ON' => 's.session_user_id = z.zebra_id'
|
||||
)
|
||||
'ON' => 's.session_user_id = z.zebra_id',
|
||||
),
|
||||
),
|
||||
|
||||
'WHERE' => 'z.user_id = ' . $user->data['user_id'] . '
|
||||
@ -296,8 +296,9 @@ if ($module->is_active('zebra', 'friends'))
|
||||
'GROUP_BY' => 'z.zebra_id, u.user_id, u.username_clean, u.user_colour, u.username',
|
||||
|
||||
'ORDER_BY' => 'u.username_clean ASC',
|
||||
));
|
||||
);
|
||||
|
||||
$sql = $db->sql_build_query('SELECT_DISTINCT', $sql_ary);
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
|
@ -375,7 +375,7 @@ if ($forum_data['forum_type'] == FORUM_POST)
|
||||
$sql_anounce_array['SELECT'] = $sql_array['SELECT'] . ', f.forum_name';
|
||||
|
||||
// Obtain announcements ... removed sort ordering, sort by time in all cases
|
||||
$sql = $db->sql_build_query('SELECT', array(
|
||||
$sql_ary = array(
|
||||
'SELECT' => $sql_anounce_array['SELECT'],
|
||||
'FROM' => $sql_array['FROM'],
|
||||
'LEFT_JOIN' => $sql_anounce_array['LEFT_JOIN'],
|
||||
@ -386,7 +386,8 @@ if ($forum_data['forum_type'] == FORUM_POST)
|
||||
AND t.topic_type = ' . POST_GLOBAL . ')',
|
||||
|
||||
'ORDER_BY' => 't.topic_time DESC',
|
||||
));
|
||||
);
|
||||
$sql = $db->sql_build_query('SELECT', $sql_ary);
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
|
@ -943,7 +943,7 @@ if (!sizeof($post_list))
|
||||
// We need to grab it because we do reverse ordering sometimes
|
||||
$max_post_time = 0;
|
||||
|
||||
$sql = $db->sql_build_query('SELECT', array(
|
||||
$sql_ary = array(
|
||||
'SELECT' => 'u.*, z.friend, z.foe, p.*',
|
||||
|
||||
'FROM' => array(
|
||||
@ -954,14 +954,15 @@ $sql = $db->sql_build_query('SELECT', array(
|
||||
'LEFT_JOIN' => array(
|
||||
array(
|
||||
'FROM' => array(ZEBRA_TABLE => 'z'),
|
||||
'ON' => 'z.user_id = ' . $user->data['user_id'] . ' AND z.zebra_id = p.poster_id'
|
||||
)
|
||||
'ON' => 'z.user_id = ' . $user->data['user_id'] . ' AND z.zebra_id = p.poster_id',
|
||||
),
|
||||
),
|
||||
|
||||
'WHERE' => $db->sql_in_set('p.post_id', $post_list) . '
|
||||
AND u.user_id = p.poster_id'
|
||||
));
|
||||
AND u.user_id = p.poster_id',
|
||||
);
|
||||
|
||||
$sql = $db->sql_build_query('SELECT', $sql_ary);
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$now = phpbb_gmgetdate(time() + $user->timezone + $user->dst);
|
||||
|
Loading…
x
Reference in New Issue
Block a user