Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order by #1206

Merged
merged 14 commits into from Jan 3, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion SSI.php
Expand Up @@ -979,7 +979,7 @@ function ssi_boardStats($output_method = 'echo')
'members' => $modSettings['totalMembers'],
'posts' => $modSettings['totalMessages'],
'topics' => $modSettings['totalTopics'],
'boards' => fetchBoardsInfo('all', array('count' => true)),
'boards' => countBoards(),
'categories' => numCategories(),
);

Expand Down
3 changes: 2 additions & 1 deletion sources/Subs.php
Expand Up @@ -2349,7 +2349,8 @@ function parsesmileys(&$message)
{
$result = $db->query('', '
SELECT code, filename, description
FROM {db_prefix}smileys',
FROM {db_prefix}smileys
ORDER BY LENGTH(code) DESC',
array(
)
);
Expand Down
39 changes: 24 additions & 15 deletions sources/admin/ManageSmileys.controller.php
Expand Up @@ -1121,7 +1121,7 @@ public function action_editicon()
require_once(SUBSDIR . '/MessageIcons.subs.php');

// Get a list of icons.
$context['icons'] = getMessageIcons();
$context['icons'] = fetchMessageIconsDetails();

// Submitting a form?
if (isset($_POST['icons_save']))
Expand Down Expand Up @@ -1216,18 +1216,19 @@ public function action_editicon()
'title' => $txt['icons_edit_message_icons'],
'base_href' => $scripturl . '?action=admin;area=smileys;sa=editicons',
'get_items' => array(
'function' => 'list_getMessageIcons',
'function' => array($this, 'list_fetchMessageIconsDetails'),
),
'no_items_label' => $txt['icons_no_entries'],
'columns' => array(
'icon' => array(
'data' => array(
'function' => create_function('$rowData', '
global $settings;

$images_url = $settings[file_exists(sprintf(\'%1$s/images/post/%2$s.png\', $settings[\'theme_dir\'], $rowData[\'filename\'])) ? \'actual_images_url\' : \'default_images_url\'];
return sprintf(\'<img src="%1$s/post/%2$s.png" alt="%3$s" />\', $images_url, $rowData[\'filename\'], htmlspecialchars($rowData[\'title\'], ENT_COMPAT, \'UTF-8\'));
'),
'sprintf' => array(
'format' => '<img src="%1$s" alt="%2$s" />',
'params' => array(
'image_url' => false,
'filename' => true,
),
),
'class' => 'centertext',
),
),
Expand Down Expand Up @@ -1257,11 +1258,7 @@ public function action_editicon()
'value' => $txt['icons_board'],
),
'data' => array(
'function' => create_function('$rowData', '
global $txt;

return empty($rowData[\'board_name\']) ? $txt[\'icons_edit_icons_all_boards\'] : $rowData[\'board_name\'];
'),
'db' => 'board',
),
),
'modify' => array(
Expand All @@ -1272,7 +1269,7 @@ public function action_editicon()
'sprintf' => array(
'format' => '<a href="' . $scripturl . '?action=admin;area=smileys;sa=editicon;icon=%1$s">' . $txt['smileys_modify'] . '</a>',
'params' => array(
'id_icon' => false,
'id' => false,
),
),
),
Expand All @@ -1286,7 +1283,7 @@ public function action_editicon()
'sprintf' => array(
'format' => '<input type="checkbox" name="checked_icons[]" value="%1$d" class="input_check" />',
'params' => array(
'id_icon' => false,
'id' => false,
),
),
'class' => 'centertext',
Expand Down Expand Up @@ -1693,4 +1690,16 @@ public function importSmileys($smileyPath)
cache_put_data('posting_smileys', null, 480);
}
}

/**
* Callback function for createList().
*
* @param int $start
* @param int $items_per_page
* @param string $sort
*/
public function list_fetchMessageIconsDetails($start, $items_per_page, $sort)
{
return fetchMessageIconsDetails();
}
}
33 changes: 9 additions & 24 deletions sources/controllers/MessageIndex.controller.php
Expand Up @@ -787,7 +787,7 @@ public function action_quickmod()
if ($countPosts[$topic] != $cp)
{
// If the board being moved to does count the posts then the other one doesn't so add to their post count.
$topicRecounts[$topic] = $cp ? '+' : '-';
$topicRecounts[$topic] = $cp ? 1 : -1;
}
}
}
Expand All @@ -797,32 +797,17 @@ public function action_quickmod()
$members = array();

// Get all the members who have posted in the moved topics.
$request = $db->query('', '
SELECT id_member, id_topic
FROM {db_prefix}messages
WHERE id_topic IN ({array_int:moved_topic_ids})',
array(
'moved_topic_ids' => array_keys($topicRecounts),
)
);

while ($row = $db->fetch_assoc($request))
$posters = topicsPosters(array_keys($topicRecounts));
foreach ($posters as $id_member => $topics)
{
if (!isset($members[$row['id_member']]))
$members[$row['id_member']] = 0;
$post_adj = 0;
foreach ($topics as $id_topic)
$post_adj += $topicRecounts[$id_topic];

if ($topicRecounts[$row['id_topic']] === '+')
$members[$row['id_member']] += 1;
else
$members[$row['id_member']] -= 1;
// And now update that member's post counts
if (!empty($post_adj))
updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj));
}

$db->free_result($request);

// And now update them member's post counts
foreach ($members as $id_member => $post_adj)
updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj));

}
}
}
Expand Down
2 changes: 1 addition & 1 deletion sources/controllers/News.controller.php
Expand Up @@ -140,7 +140,7 @@ public function action_showfeed()
$this->_query_this_board = 'b.id_board = ' . $board;

// Try to look through just a few messages, if at all possible.
if ($boards_data['num_posts'] > 80 && $boards_data['num_posts'] > $modSettings['totalMessages'] / 10)
if ($boards_data[$board]['num_posts'] > 80 && $boards_data[$board]['num_posts'] > $modSettings['totalMessages'] / 10)
$context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 600 - $this->limit * 5);
}
else
Expand Down
4 changes: 2 additions & 2 deletions sources/controllers/Recent.controller.php
Expand Up @@ -132,14 +132,14 @@ function action_recent()
$query_parameters['board'] = $board;

// If this board has a significant number of posts in it...
if ($board_data['num_posts'] > 80 && $board_data['num_posts'] > $modSettings['totalMessages'] / 10)
if ($board_data[$board]['num_posts'] > 80 && $board_data[$board]['num_posts'] > $modSettings['totalMessages'] / 10)
{
$query_this_board .= '
AND m.id_msg >= {int:max_id_msg}';
$query_parameters['max_id_msg'] = max(0, $modSettings['maxMsgID'] - 600 - $_REQUEST['start'] * 10);
}

$context['page_index'] = constructPageIndex($scripturl . '?action=recent;board=' . $board . '.%1$d', $_REQUEST['start'], min(100, $board_data['num_posts']), 10, true);
$context['page_index'] = constructPageIndex($scripturl . '?action=recent;board=' . $board . '.%1$d', $_REQUEST['start'], min(100, $board_data[$board]['num_posts']), 10, true);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion sources/controllers/Search.controller.php
Expand Up @@ -492,7 +492,7 @@ public function action_plushsearch2()
else
{
require_once(SUBSDIR . '/Boards.subs.php');
$search_params['brd'] = array_keys(fetchBoardsInfo(array('boards' => $query_boards), array('exclude_recycle' => true, 'exclude_redirects' => true, 'wanna_see_board' => empty($search_params['advanced']))));
$search_params['brd'] = array_keys(fetchBoardsInfo(array('boards' => $query_boards), array('include_recycle' => false, 'include_redirects' => false, 'wanna_see_board' => empty($search_params['advanced']))));

// This error should pro'bly only happen for hackers.
if (empty($search_params['brd']))
Expand Down
4 changes: 3 additions & 1 deletion sources/controllers/Stats.controller.php
Expand Up @@ -130,6 +130,8 @@ public function loadGeneralStatistics()
{
global $scripturl, $modSettings, $context;

require_once(SUBSDIR . '/Boards.subs.php');

// Get averages...
$averages = getAverages();
// This would be the amount of time the forum has been up... in days...
Expand Down Expand Up @@ -187,7 +189,7 @@ public function loadGeneralStatistics()
'average_posts' => comma_format(round($averages['posts'] / $total_days_up, 2)),
'average_topics' => comma_format(round($averages['topics'] / $total_days_up, 2)),
// Statistics such as number of boards, categories, etc.
'total_boards' => comma_format(numBoards()),
'total_boards' => comma_format(countBoards('all', array('include_redirects' => false))),
'latest_member' => &$context['common_stats']['latest_member'],
'average_online' => comma_format(round($averages['most_on'] / $total_days_up, 2)),
'gender_ratio' => $context['gender']['ratio'],
Expand Down
27 changes: 1 addition & 26 deletions sources/database/Db-postgresql.class.php
Expand Up @@ -288,16 +288,7 @@ function query($identifier, $db_string, $db_values = array(), $connection = null

// Special queries that need processing.
$replacements = array(
'alter_table_boards' => array(
'~(.+)~' => '',
),
'alter_table_icons' => array(
'~(.+)~' => '',
),
'alter_table_smileys' => array(
'~(.+)~' => '',
),
'alter_table_spiders' => array(
'alter_table' => array(
'~(.+)~' => '',
),
'ban_suggest_error_ips' => array(
Expand All @@ -322,7 +313,6 @@ function query($identifier, $db_string, $db_values = array(), $connection = null
),
'boardindex_fetch_boards' => array(
'~IFNULL\(lb.id_msg, 0\) >= b.id_msg_updated~' => 'CASE WHEN IFNULL(lb.id_msg, 0) >= b.id_msg_updated THEN 1 ELSE 0 END',
'~(.)$~' => '$1 ORDER BY b.board_order',
),
'get_random_number' => array(
'~RAND~' => 'RANDOM',
Expand All @@ -336,12 +326,6 @@ function query($identifier, $db_string, $db_values = array(), $connection = null
'insert_log_search_results_subject' => array(
'~NOT RLIKE~' => '!~',
),
'messageindex_fetch_boards' => array(
'~(.)$~' => '$1 ORDER BY b.board_order',
),
'select_message_icons' => array(
'~(.)$~' => '$1 ORDER BY icon_order',
),
'set_character_set' => array(
'~SET\\s+NAMES\\s([a-zA-Z0-9\\-_]+)~' => 'SET NAMES \'$1\'',
),
Expand All @@ -351,21 +335,12 @@ function query($identifier, $db_string, $db_values = array(), $connection = null
'top_topic_starters' => array(
'~ORDER BY FIND_IN_SET\(id_member,(.+?)\)~' => 'ORDER BY STRPOS(\',\' || $1 || \',\', \',\' || id_member|| \',\')',
),
'order_by_board_order' => array(
'~(.)$~' => '$1 ORDER BY b.board_order',
),
'spider_check' => array(
'~(.)$~' => '$1 ORDER BY LENGTH(user_agent) DESC',
),
'unread_replies' => array(
'~SELECT\\s+DISTINCT\\s+t.id_topic~' => 'SELECT t.id_topic, {raw:sort}',
),
'profile_board_stats' => array(
'~COUNT\(\*\) \/ MAX\(b.num_posts\)~' => 'CAST(COUNT(*) AS DECIMAL) / CAST(b.num_posts AS DECIMAL)',
),
'set_smiley_order' => array(
'~(.+)~' => '',
),
);

if (isset($replacements[$identifier]))
Expand Down
3 changes: 2 additions & 1 deletion sources/subs/BoardIndex.subs.php
Expand Up @@ -73,7 +73,8 @@ function getBoardIndex($boardIndexOptions)
LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = m.id_member AND a.id_member != 0)' : '') . '
WHERE {query_see_board}' . (empty($boardIndexOptions['countChildPosts']) ? (empty($boardIndexOptions['base_level']) ? '' : '
AND b.child_level >= {int:child_level}') : '
AND b.child_level BETWEEN ' . $boardIndexOptions['base_level'] . ' AND ' . ($boardIndexOptions['base_level'] + 1)),
AND b.child_level BETWEEN ' . $boardIndexOptions['base_level'] . ' AND ' . ($boardIndexOptions['base_level'] + 1)) . '
ORDER BY board_order',
array(
'current_member' => $user_info['id'],
'child_level' => $boardIndexOptions['base_level'],
Expand Down