本文整理汇总了PHP中constructPageIndex函数的典型用法代码示例。如果您正苦于以下问题:PHP constructPageIndex函数的具体用法?PHP constructPageIndex怎么用?PHP constructPageIndex使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了constructPageIndex函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_sportal_index
/**
* Loads article previews for display with the portal index template
*/
public function action_sportal_index()
{
global $context, $modSettings;
// Showing articles on the index page?
if (!empty($modSettings['sp_articles_index'])) {
require_once SUBSDIR . '/PortalArticle.subs.php';
$context['sub_template'] = 'portal_index';
// Set up the pages
$total_articles = sportal_get_articles_count();
$total = min($total_articles, !empty($modSettings['sp_articles_index_total']) ? $modSettings['sp_articles_index_total'] : 20);
$per_page = min($total, !empty($modSettings['sp_articles_index_per_page']) ? $modSettings['sp_articles_index_per_page'] : 5);
$start = !empty($_REQUEST['articles']) ? (int) $_REQUEST['articles'] : 0;
if ($total > $per_page) {
$context['article_page_index'] = constructPageIndex($context['portal_url'] . '?articles=%1$d', $start, $total, $per_page, true);
}
// If we have some articles
require_once SUBSDIR . '/PortalArticle.subs.php';
$context['articles'] = sportal_get_articles(0, true, true, 'spa.id_article DESC', 0, $per_page, $start);
foreach ($context['articles'] as $article) {
if (empty($modSettings['sp_articles_length']) && ($cutoff = Util::strpos($article['body'], '[cutoff]')) !== false) {
$article['body'] = Util::substr($article['body'], 0, $cutoff);
if ($article['type'] === 'bbc') {
require_once SUBSDIR . '/Post.subs.php';
preparsecode($article['body']);
}
}
$context['articles'][$article['id']]['preview'] = sportal_parse_content($article['body'], $article['type'], 'return');
$context['articles'][$article['id']]['date'] = htmlTime($article['date']);
// Just want a shorter look on the index page
if (!empty($modSettings['sp_articles_length'])) {
$context['articles'][$article['id']]['preview'] = Util::shorten_html($context['articles'][$article['id']]['preview'], $modSettings['sp_articles_length']);
}
}
}
}
示例2: ArcadeMatchList
function ArcadeMatchList()
{
global $scripturl, $txt, $db_prefix, $context, $smcFunc, $user_info, $modSettings;
$request = $smcFunc['db_query']('', '
SELECT COUNT(*)
FROM {db_prefix}arcade_matches AS m
LEFT JOIN {db_prefix}arcade_matches_players AS me ON (me.id_match = m.id_match AND me.id_member = {int:member})
WHERE ({query_see_match})', array('member' => $user_info['id']));
list($matchCount) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);
$context['page_index'] = constructPageIndex($scripturl . '?action=arcade;sa=arena', $_REQUEST['start'], $matchCount, $modSettings['matchesPerPage'], false);
$request = $smcFunc['db_query']('', '
SELECT
m.id_match, m.name, m.private_game, m.created, m.updated, m.status,
m.num_players, m.current_players, m.num_rounds, m.current_round,
IFNULL(me.id_member, 0) AS participation, me.status AS my_state,
mem.id_member, mem.real_name
FROM {db_prefix}arcade_matches AS m
LEFT JOIN {db_prefix}arcade_matches_players AS me ON (me.id_match = m.id_match AND me.id_member = {int:member})
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
WHERE {query_see_match}
ORDER BY me.status = 1 DESC', array('member' => $user_info['id']));
$context['matches'] = array();
$status = array(10 => 'arcade_arena_waiting_players', 11 => 'arcade_arena_waiting_other_players', 20 => 'arcade_arena_started', 21 => 'arcade_arena_not_played', 22 => 'arcade_arena_not_played', 23 => 'arcade_arena_not_other_played', 24 => 'arcade_arena_dropped', 30 => 'arcade_arena_complete', 31 => 'arcade_arena_complete', 32 => 'arcade_arena_complete', 33 => 'arcade_arena_complete', 34 => 'arcade_arena_complete');
while ($row = $smcFunc['db_fetch_assoc']($request)) {
$context['matches'][] = array('id' => $row['id_match'], 'name' => $row['name'], 'link' => '<a href="' . $scripturl . '?action=arcade;sa=viewMatch;match=' . $row['id_match'] . '">' . $row['name'] . '</a>', 'status' => $status[$row['my_state'] + ($row['status'] * 10 + 10)], 'joined' => (bool) $row['participation'], 'my_state' => $row['my_state'], 'is_private' => (bool) $row['private_game'], 'players' => $row['current_players'], 'players_limit' => $row['num_players'], 'round' => $row['current_round'], 'rounds' => $row['num_rounds'], 'starter' => array('id' => $row['id_member'], 'name' => $row['real_name'], 'link' => !empty($row['id_member']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>' : ''));
}
$smcFunc['db_free_result']($request);
// Layout
loadTemplate('ArcadeArena');
$context['sub_template'] = 'arcade_arena_matches';
$context['page_title'] = $txt['arcade_arena'];
// Add Arena to link tree
$context['linktree'][] = array('url' => $scripturl . '?action=arcade;sa=arena', 'name' => $txt['arcade_arena']);
}
示例3: ModifyHolidays
function ModifyHolidays()
{
global $txt, $context, $db_prefix, $scripturl;
loadTemplate('ManageCalendar');
$context['page_title'] = $txt['manage_holidays'];
$context['sub_template'] = 'manage_holidays';
// Submitting something...
if (isset($_REQUEST['delete']) && !empty($_REQUEST['holiday'])) {
checkSession();
foreach ($_REQUEST['holiday'] as $id => $value) {
$_REQUEST['holiday'][$id] = (int) $id;
}
// Now the IDs are "safe" do the delete...
db_query("\n\t\t\tDELETE FROM {$db_prefix}calendar_holidays\n\t\t\tWHERE ID_HOLIDAY IN (" . implode(', ', $_REQUEST['holiday']) . ")\n\t\t\tLIMIT " . count($_REQUEST['holiday']), __FILE__, __LINE__);
updateStats('calendar');
}
// Total amount of holidays... for pagination.
$request = db_query("\n\t\tSELECT COUNT(*)\n\t\tFROM {$db_prefix}calendar_holidays", __FILE__, __LINE__);
list($context['holidayCount']) = mysql_fetch_row($request);
mysql_free_result($request);
$context['page_index'] = constructPageIndex($scripturl . '?action=managecalendar;sa=holidays', $_REQUEST['start'], $context['holidayCount'], 20);
// Now load up all the holidays into a lovely large array.
$request = db_query("\n\t\tSELECT ID_HOLIDAY, YEAR(eventDate) AS year, MONTH(eventDate) AS month, DAYOFMONTH(eventDate) AS day, title\n\t\tFROM {$db_prefix}calendar_holidays\n\t\tORDER BY title\n\t\tLIMIT {$_REQUEST['start']}, 20", __FILE__, __LINE__);
$context['holidays'] = array();
while ($row = mysql_fetch_assoc($request)) {
$context['holidays'][] = array('id' => $row['ID_HOLIDAY'], 'date' => $row['day'] . ' ' . $txt['months'][$row['month']] . ' ' . ($row['year'] == '0004' ? '(' . $txt['every_year'] . ')' : $row['year']), 'title' => $row['title']);
}
mysql_free_result($request);
}
示例4: action_mergeIndex
/**
* Allows to pick a topic to merge the current topic with.
* is accessed with ?action=mergetopics;sa=index
* default sub action for ?action=mergetopics.
* uses 'merge' sub template of the MergeTopics template.
* allows to set a different target board.
*/
public function action_mergeIndex()
{
global $txt, $board, $context, $scripturl, $user_info, $modSettings;
if (!isset($_GET['from'])) {
fatal_lang_error('no_access', false);
}
$_GET['from'] = (int) $_GET['from'];
$_REQUEST['targetboard'] = isset($_REQUEST['targetboard']) ? (int) $_REQUEST['targetboard'] : $board;
$context['target_board'] = $_REQUEST['targetboard'];
// Prepare a handy query bit for approval...
if ($modSettings['postmod_active']) {
$can_approve_boards = !empty($user_info['mod_cache']['ap']) ? $user_info['mod_cache']['ap'] : boardsAllowedTo('approve_posts');
$onlyApproved = $can_approve_boards !== array(0) && !in_array($_REQUEST['targetboard'], $can_approve_boards);
} else {
$onlyApproved = false;
}
// How many topics are on this board? (used for paging.)
require_once SUBSDIR . '/Topic.subs.php';
$topiccount = countTopicsByBoard($_REQUEST['targetboard'], $onlyApproved);
// Make the page list.
$context['page_index'] = constructPageIndex($scripturl . '?action=mergetopics;from=' . $_GET['from'] . ';targetboard=' . $_REQUEST['targetboard'] . ';board=' . $board . '.%1$d', $_REQUEST['start'], $topiccount, $modSettings['defaultMaxTopics'], true);
// Get the topic's subject.
$topic_info = getTopicInfo($_GET['from'], 'message');
// @todo review: double check the logic
if (empty($topic_info) || $topic_info['id_board'] != $board || $onlyApproved && empty($topic_info['approved'])) {
fatal_lang_error('no_board');
}
// Tell the template a few things..
$context['origin_topic'] = $_GET['from'];
$context['origin_subject'] = $topic_info['subject'];
$context['origin_js_subject'] = addcslashes(addslashes($topic_info['subject']), '/');
$context['page_title'] = $txt['merge'];
// Check which boards you have merge permissions on.
$merge_boards = boardsAllowedTo('merge_any');
if (empty($merge_boards)) {
fatal_lang_error('cannot_merge_any', 'user');
}
// Get a list of boards they can navigate to to merge.
require_once SUBSDIR . '/Boards.subs.php';
$boardListOptions = array('not_redirection' => true);
if (!in_array(0, $merge_boards)) {
$boardListOptions['included_boards'] = $merge_boards;
}
$boards_list = getBoardList($boardListOptions, true);
$context['boards'] = array();
foreach ($boards_list as $board) {
$context['boards'][] = array('id' => $board['id_board'], 'name' => $board['board_name'], 'category' => $board['cat_name']);
}
// Get some topics to merge it with.
$context['topics'] = mergeableTopics($_REQUEST['targetboard'], $_GET['from'], $onlyApproved, $_REQUEST['start']);
if (empty($context['topics']) && count($context['boards']) <= 1) {
fatal_lang_error('merge_need_more_topics');
}
$context['sub_template'] = 'merge';
}
示例5: PostSchedulerAdmin
function PostSchedulerAdmin()
{
global $txt, $mbname, $context, $smcFunc, $scripturl;
// Get all the feeds
$context['schedule_posts'] = array();
$context['start'] = (int) $_REQUEST['start'];
$request = $smcFunc['db_query']('', "\n\t\t\tSELECT \n\t\t\t\tCOUNT(*) as total\n\t\t\tFROM {db_prefix}postscheduler\n\t\t\tWHERE hasposted = 0\n\t\t\t");
$totalRow = $smcFunc['db_fetch_assoc']($request);
$request = $smcFunc['db_query']('', "\n\t\t\tSELECT \n\t\t\t\tID_POST, subject, ID_MEMBER, postername, post_time\n\t\t\tFROM {db_prefix}postscheduler\n\t\t\tWHERE hasposted = 0 \n\t\t\tORDER BY post_time ASC LIMIT {$context['start']},10");
while ($row = $smcFunc['db_fetch_assoc']($request)) {
$context['schedule_posts'][] = $row;
}
$smcFunc['db_free_result']($request);
// Setup the paging
$context['page_index'] = constructPageIndex($scripturl . '?action=admin;area=postscheduler;sa=admin', $_REQUEST['start'], $totalRow['total'], 10);
$context['sub_template'] = 'postmain';
// Set the page title
$context['page_title'] = $mbname . ' - ' . $txt['postscheduler_postlist'];
}
示例6: action_sportal_category
/**
* View a specific category, showing all articles it contains
*/
public function action_sportal_category()
{
global $context, $scripturl, $modSettings;
// Basic article support
require_once SUBSDIR . '/PortalArticle.subs.php';
$category_id = !empty($_REQUEST['category']) ? $_REQUEST['category'] : 0;
if (is_int($category_id)) {
$category_id = (int) $category_id;
} else {
$category_id = Util::htmlspecialchars($category_id, ENT_QUOTES);
}
$context['category'] = sportal_get_categories($category_id, true, true);
if (empty($context['category']['id'])) {
fatal_lang_error('error_sp_category_not_found', false);
}
// Set up the pages
$total_articles = sportal_get_articles_in_cat_count($context['category']['id']);
$per_page = min($total_articles, !empty($modSettings['sp_articles_per_page']) ? $modSettings['sp_articles_per_page'] : 10);
$start = !empty($_REQUEST['start']) ? (int) $_REQUEST['start'] : 0;
if ($total_articles > $per_page) {
$context['page_index'] = constructPageIndex($context['category']['href'] . ';start=%1$d', $start, $total_articles, $per_page, true);
}
// Load the articles in this category
$context['articles'] = sportal_get_articles(0, true, true, 'spa.id_article DESC', $context['category']['id'], $per_page, $start);
foreach ($context['articles'] as $article) {
// Cut me mick
if (($cutoff = Util::strpos($article['body'], '[cutoff]')) !== false) {
$article['body'] = Util::substr($article['body'], 0, $cutoff);
if ($article['type'] === 'bbc') {
require_once SUBSDIR . '/Post.subs.php';
preparsecode($article['body']);
}
}
$context['articles'][$article['id']]['preview'] = sportal_parse_content($article['body'], $article['type'], 'return');
$context['articles'][$article['id']]['date'] = htmlTime($article['date']);
}
$context['linktree'][] = array('url' => $scripturl . '?category=' . $context['category']['category_id'], 'name' => $context['category']['name']);
$context['page_title'] = $context['category']['name'];
$context['sub_template'] = 'view_category';
}
示例7: adk_aportes_automaticos
function adk_aportes_automaticos($array = '', $limit_body = '', $limit_query = '')
{
global $context, $scripturl, $txt, $settings, $smcFunc, $boardurl, $adkportal, $current_load;
global $modSettings;
if (empty($array)) {
$array = $adkportal['auto_news_id_boards'];
}
if (empty($limit_body)) {
$limit_body = $adkportal['auto_news_limit_body'];
}
if (empty($limit_query)) {
$limit_query = $adkportal['auto_news_limit_topics'];
}
if (!empty($adkportal['auto_news_size_img'])) {
$size_img = 'style="max-width: ' . $adkportal['auto_news_size_img'] . 'px;"';
}
$context['start'] = isset($_REQUEST['adk']) && !empty($_REQUEST['start']) && !empty($_REQUEST['id']) && $_REQUEST['id'] == $context['block']['id'] ? (int) $_REQUEST['start'] : 0;
$sql = $smcFunc['db_query']('', '
SELECT COUNT(*) AS total
FROM {db_prefix}topics AS t
INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
WHERE ' . (!empty($array) ? 'b.id_board IN ({array_int:boards}) AND' : '') . ' {query_wanna_see_board}', array('boards' => explode(',', $array)));
$row = $smcFunc['db_fetch_assoc']($sql);
$smcFunc['db_free_result']($sql);
$total = $row['total'];
$context['page_index'] = constructPageIndex($scripturl . '?adk;id=' . $context['block']['id'], $context['start'], $total, $limit_query);
$sql = $smcFunc['db_query']('', '
SELECT m.id_topic, m.poster_time, m.id_member, m.poster_name,
m.subject, m.body, m.icon, mg.online_color, t.num_replies, t.num_views, mem.real_name, mem.avatar,
IFNULL(a.id_attach, 0) AS id_attach, a.filename, a.attachment_type
FROM {db_prefix}messages AS m
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = mem.id_member)
LEFT JOIN {db_prefix}membergroups AS mg ON (mg.id_group = CASE WHEN mem.id_group = {int:reg_mem_group} THEN mem.id_post_group ELSE mem.id_group END)
INNER JOIN {db_prefix}topics AS t ON (t.id_first_msg = m.id_msg)
INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)
WHERE ' . (!empty($array) ? 'm.id_board IN ({array_int:boards}) AND' : '') . ' {query_wanna_see_board}
ORDER BY m.id_topic DESC LIMIT {int:uno}, {int:limit} ', array('limit' => $limit_query, 'uno' => $context['start'], 'boards' => explode(',', $array), 'reg_mem_group' => 0));
$img = 'plugin.png';
$topics = array();
while ($row = $smcFunc['db_fetch_assoc']($sql)) {
if (!empty($row['id_member'])) {
$member = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>';
} else {
$member = $row['poster_name'];
}
$body = Adk_truncate(parse_bbc($row['body']), $limit_body, '...', false, true);
if (!empty($size_img)) {
$body = str_replace('class="', 'class="resize_auto_new ', $body);
$body = str_replace('<img ', '<img ' . $size_img . '', $body);
}
$topics[] = array('v' => $row['num_views'], 'r' => $row['num_replies'], 'avatar' => $row['avatar'] == '' ? $row['id_attach'] > 0 ? '<img width="30" height="30" src="' . (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) . '" alt="" border="0" />' : '' : (stristr($row['avatar'], 'http://') ? '<img width="30" height="30" src="' . $row['avatar'] . '" alt="" border="0" />' : '<img width="30" height="30" src="' . $modSettings['avatar_url'] . '/' . $smcFunc['htmlspecialchars']($row['avatar']) . '" alt="" border="0" />'), 'id_topic' => $row['id_topic'], 'img' => '<img style="vertical-align: middle;" src="' . $settings['images_url'] . '/post/' . $row['icon'] . '.gif" alt="" />', 'href' => $row['subject'], 'time' => timeformat($row['poster_time']), 'member' => $member, 'body' => $body);
}
//$averiguar = $avatar2,1,4);
$smcFunc['db_free_result']($sql);
foreach ($topics as $topic) {
$title = '<a href="' . $scripturl . '?topic=' . $topic['id_topic'] . '.0"><b>' . $topic['href'] . '</b></a>';
if (!empty($context['block']['b'])) {
echo '
<span class="clear upperframe">
<span> </span>
</span>
<div class="roundframe">
<div>
' . $topic['img'] . '
<strong>' . $title . '</strong>
<hr />';
} else {
echo '
' . $topic['img'] . '
<strong>' . $title . '</strong>
<hr />';
}
echo '
<div style="height: 40px;">
<div class="smalltext adk_float_r">' . $txt['by'] . ' ' . $topic['member'] . ' - ' . $topic['time'] . '</div>';
if (!empty($topic['avatar'])) {
echo '
<div class="adk_float_l">', $topic['avatar'], '</div>';
}
echo '
</div>
<div class="adk_padding_8">
' . $topic['body'] . '
</div>
<br />';
if (!empty($adkportal['adk_bookmarks_autonews'])) {
adk_bookmarks('right', 'auto_news', $topic['id_topic']);
}
echo '
<div class="smalltext adk_padding_5">
<hr />
<a href="' . $scripturl . '?topic=' . $topic['id_topic'] . '.0"><strong>' . $txt['adkmod_block_readmore'] . '...</strong></a>
<div class="adk_float_r">
' . $txt['views'] . ': ' . $topic['v'] . ' ' . $txt['replies'] . ': ' . $topic['r'] . '
</div>
<br /><br />
//.........这里部分代码省略.........
示例8: createList
function createList($listOptions)
{
global $context, $settings, $options, $txt, $modSettings, $scripturl;
assert(isset($listOptions['id']));
assert(isset($listOptions['columns']));
assert(is_array($listOptions['columns']));
assert(empty($listOptions['items_per_page']) || isset($listOptions['get_count']['function'], $listOptions['base_href']) && is_numeric($listOptions['items_per_page']));
assert(empty($listOptions['default_sort_col']) || isset($listOptions['columns'][$listOptions['default_sort_col']]));
assert(!isset($listOptions['form']) || isset($listOptions['form']['href']));
// All the context data will be easily accessible by using a reference.
$context[$listOptions['id']] = array();
$list_context =& $context[$listOptions['id']];
// Figure out the sort.
if (empty($listOptions['default_sort_col'])) {
$list_context['sort'] = array();
$sort = '1=1';
} else {
$request_var_sort = isset($listOptions['request_vars']['sort']) ? $listOptions['request_vars']['sort'] : 'sort';
$request_var_desc = isset($listOptions['request_vars']['desc']) ? $listOptions['request_vars']['desc'] : 'desc';
if (isset($_REQUEST[$request_var_sort], $listOptions['columns'][$_REQUEST[$request_var_sort]], $listOptions['columns'][$_REQUEST[$request_var_sort]]['sort'])) {
$list_context['sort'] = array('id' => $_REQUEST[$request_var_sort], 'desc' => isset($_REQUEST[$request_var_desc]) && isset($listOptions['columns'][$_REQUEST[$request_var_sort]]['sort']['reverse']));
} else {
$list_context['sort'] = array('id' => $listOptions['default_sort_col'], 'desc' => !empty($listOptions['default_sort_dir']) && $listOptions['default_sort_dir'] == 'desc' || !empty($listOptions['columns'][$listOptions['default_sort_col']]['sort']['default']) && substr($listOptions['columns'][$listOptions['default_sort_col']]['sort']['default'], -4, 4) == 'desc' ? true : false);
}
// Set the database column sort.
$sort = $listOptions['columns'][$list_context['sort']['id']]['sort'][$list_context['sort']['desc'] ? 'reverse' : 'default'];
}
$list_context['start_var_name'] = isset($listOptions['start_var_name']) ? $listOptions['start_var_name'] : 'start';
// In some cases the full list must be shown, regardless of the amount of items.
if (empty($listOptions['items_per_page'])) {
$list_context['start'] = 0;
$list_context['items_per_page'] = 0;
} else {
// First get an impression of how many items to expect.
if (isset($listOptions['get_count']['file'])) {
require_once $listOptions['get_count']['file'];
}
$list_context['total_num_items'] = call_user_func_array($listOptions['get_count']['function'], empty($listOptions['get_count']['params']) ? array() : $listOptions['get_count']['params']);
// Default the start to the beginning...sounds logical.
$list_context['start'] = isset($_REQUEST[$list_context['start_var_name']]) ? (int) $_REQUEST[$list_context['start_var_name']] : 0;
$list_context['items_per_page'] = $listOptions['items_per_page'];
// Then create a page index.
$list_context['page_index'] = constructPageIndex($listOptions['base_href'] . (empty($list_context['sort']) ? '' : ';' . $request_var_sort . '=' . $list_context['sort']['id'] . ($list_context['sort']['desc'] ? ';' . $request_var_desc : '')) . ($list_context['start_var_name'] != 'start' ? ';' . $list_context['start_var_name'] . '=%1$d' : ''), $list_context['start'], $list_context['total_num_items'], $list_context['items_per_page'], $list_context['start_var_name'] != 'start');
}
// Prepare the headers of the table.
$list_context['headers'] = array();
foreach ($listOptions['columns'] as $column_id => $column) {
$list_context['headers'][] = array('id' => $column_id, 'label' => isset($column['header']['eval']) ? eval($column['header']['eval']) : (isset($column['header']['value']) ? $column['header']['value'] : ''), 'href' => empty($listOptions['default_sort_col']) || empty($column['sort']) ? '' : $listOptions['base_href'] . ';' . $request_var_sort . '=' . $column_id . ($column_id === $list_context['sort']['id'] && !$list_context['sort']['desc'] && isset($column['sort']['reverse']) ? ';' . $request_var_desc : '') . (empty($list_context['start']) ? '' : ';' . $list_context['start_var_name'] . '=' . $list_context['start']), 'sort_image' => empty($listOptions['default_sort_col']) || empty($column['sort']) || $column_id !== $list_context['sort']['id'] ? null : ($list_context['sort']['desc'] ? 'down' : 'up'), 'class' => isset($column['header']['class']) ? $column['header']['class'] : '', 'style' => isset($column['header']['style']) ? $column['header']['style'] : '', 'colspan' => isset($column['header']['colspan']) ? $column['header']['colspan'] : '');
}
// We know the amount of columns, might be useful for the template.
$list_context['num_columns'] = count($listOptions['columns']);
$list_context['width'] = isset($listOptions['width']) ? $listOptions['width'] : '0';
// Get the file with the function for the item list.
if (isset($listOptions['get_items']['file'])) {
require_once $listOptions['get_items']['file'];
}
// Call the function and include which items we want and in what order.
$list_items = call_user_func_array($listOptions['get_items']['function'], array_merge(array($list_context['start'], $list_context['items_per_page'], $sort), empty($listOptions['get_items']['params']) ? array() : $listOptions['get_items']['params']));
// Loop through the list items to be shown and construct the data values.
$list_context['rows'] = array();
foreach ($list_items as $item_id => $list_item) {
$cur_row = array();
foreach ($listOptions['columns'] as $column_id => $column) {
$cur_data = array();
// A value straight from the database?
if (isset($column['data']['db'])) {
$cur_data['value'] = $list_item[$column['data']['db']];
} elseif (isset($column['data']['db_htmlsafe'])) {
$cur_data['value'] = htmlspecialchars($list_item[$column['data']['db_htmlsafe']]);
} elseif (isset($column['data']['sprintf'])) {
$params = array();
foreach ($column['data']['sprintf']['params'] as $sprintf_param => $htmlsafe) {
$params[] = $htmlsafe ? htmlspecialchars($list_item[$sprintf_param]) : $list_item[$sprintf_param];
}
$cur_data['value'] = vsprintf($column['data']['sprintf']['format'], $params);
} elseif (isset($column['data']['function'])) {
$cur_data['value'] = $column['data']['function']($list_item);
} elseif (isset($column['data']['eval'])) {
$cur_data['value'] = eval(preg_replace('~%([a-zA-Z0-9\\-_]+)%~', '$list_item[\'$1\']', $column['data']['eval']));
} elseif (isset($column['data']['value'])) {
$cur_data['value'] = $column['data']['value'];
} else {
$cur_data['value'] = '';
}
// Allow for basic formatting.
if (!empty($column['data']['comma_format'])) {
$cur_data['value'] = comma_format($cur_data['value']);
} elseif (!empty($column['data']['timeformat'])) {
$cur_data['value'] = timeformat($cur_data['value']);
}
// Set a style class for this column?
if (isset($column['data']['class'])) {
$cur_data['class'] = $column['data']['class'];
}
// Fully customized styling for the cells in this column only.
if (isset($column['data']['style'])) {
$cur_data['style'] = $column['data']['style'];
}
// Add the data cell properties to the current row.
$cur_row[$column_id] = $cur_data;
//.........这里部分代码省略.........
示例9: Who
function Who()
{
global $context, $scripturl, $user_info, $txt, $modSettings, $memberContext, $smcFunc;
// Permissions, permissions, permissions.
isAllowedTo('who_view');
// You can't do anything if this is off.
if (empty($modSettings['who_enabled'])) {
fatal_lang_error('who_off', false);
}
// Load the 'Who' template.
loadTemplate('Who');
loadLanguage('Who');
// Sort out... the column sorting.
$sort_methods = array('user' => 'mem.real_name', 'time' => 'lo.log_time');
$show_methods = array('members' => '(lo.id_member != 0)', 'guests' => '(lo.id_member = 0)', 'all' => '1=1');
// Store the sort methods and the show types for use in the template.
$context['sort_methods'] = array('user' => $txt['who_user'], 'time' => $txt['who_time']);
$context['show_methods'] = array('all' => $txt['who_show_all'], 'members' => $txt['who_show_members_only'], 'guests' => $txt['who_show_guests_only']);
// Can they see spiders too?
if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] == 2 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) {
$show_methods['spiders'] = '(lo.id_member = 0 AND lo.id_spider > 0)';
$show_methods['guests'] = '(lo.id_member = 0 AND lo.id_spider = 0)';
$context['show_methods']['spiders'] = $txt['who_show_spiders_only'];
} elseif (empty($modSettings['show_spider_online']) && isset($_SESSION['who_online_filter']) && $_SESSION['who_online_filter'] == 'spiders') {
unset($_SESSION['who_online_filter']);
}
// Does the user prefer a different sort direction?
if (isset($_REQUEST['sort']) && isset($sort_methods[$_REQUEST['sort']])) {
$context['sort_by'] = $_SESSION['who_online_sort_by'] = $_REQUEST['sort'];
$sort_method = $sort_methods[$_REQUEST['sort']];
} elseif (isset($_SESSION['who_online_sort_by'])) {
$context['sort_by'] = $_SESSION['who_online_sort_by'];
$sort_method = $sort_methods[$_SESSION['who_online_sort_by']];
} else {
$context['sort_by'] = $_SESSION['who_online_sort_by'] = 'time';
$sort_method = 'lo.log_time';
}
$context['sort_direction'] = isset($_REQUEST['asc']) || isset($_REQUEST['sort_dir']) && $_REQUEST['sort_dir'] == 'asc' ? 'up' : 'down';
$conditions = array();
if (!allowedTo('moderate_forum')) {
$conditions[] = '(IFNULL(mem.show_online, 1) = 1)';
}
// Fallback to top filter?
if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top'])) {
$_REQUEST['show'] = $_REQUEST['show_top'];
}
// Does the user wish to apply a filter?
if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']])) {
$context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show'];
$conditions[] = $show_methods[$_REQUEST['show']];
} elseif (isset($_SESSION['who_online_filter'])) {
$context['show_by'] = $_SESSION['who_online_filter'];
$conditions[] = $show_methods[$_SESSION['who_online_filter']];
} else {
$context['show_by'] = $_SESSION['who_online_filter'] = 'all';
}
// Get the total amount of members online.
$request = $smcFunc['db_query']('', '
SELECT COUNT(*)
FROM {db_prefix}log_online AS lo
LEFT JOIN {db_prefix}members AS mem ON (lo.id_member = mem.id_member)' . (!empty($conditions) ? '
WHERE ' . implode(' AND ', $conditions) : ''), array());
list($totalMembers) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);
// Prepare some page index variables.
$context['page_index'] = constructPageIndex($scripturl . '?action=who;sort=' . $context['sort_by'] . ($context['sort_direction'] == 'up' ? ';asc' : '') . ';show=' . $context['show_by'], $_REQUEST['start'], $totalMembers, $modSettings['defaultMaxMembers']);
$context['start'] = $_REQUEST['start'];
// Look for people online, provided they don't mind if you see they are.
$request = $smcFunc['db_query']('', '
SELECT
lo.log_time, lo.id_member, lo.url, INET_NTOA(lo.ip) AS ip, mem.real_name,
lo.session, mg.online_color, IFNULL(mem.show_online, 1) AS show_online,
lo.id_spider
FROM {db_prefix}log_online AS lo
LEFT JOIN {db_prefix}members AS mem ON (lo.id_member = mem.id_member)
LEFT JOIN {db_prefix}membergroups AS mg ON (mg.id_group = CASE WHEN mem.id_group = {int:regular_member} THEN mem.id_post_group ELSE mem.id_group END)' . (!empty($conditions) ? '
WHERE ' . implode(' AND ', $conditions) : '') . '
ORDER BY {raw:sort_method} {raw:sort_direction}
LIMIT {int:offset}, {int:limit}', array('regular_member' => 0, 'sort_method' => $sort_method, 'sort_direction' => $context['sort_direction'] == 'up' ? 'ASC' : 'DESC', 'offset' => $context['start'], 'limit' => $modSettings['defaultMaxMembers']));
$context['members'] = array();
$member_ids = array();
$url_data = array();
while ($row = $smcFunc['db_fetch_assoc']($request)) {
$actions = @unserialize($row['url']);
if ($actions === false) {
continue;
}
// Send the information to the template.
$context['members'][$row['session']] = array('id' => $row['id_member'], 'ip' => allowedTo('moderate_forum') ? $row['ip'] : '', 'time' => strtr(timeformat($row['log_time']), array($txt['today'] => '', $txt['yesterday'] => '')), 'timestamp' => forum_time(true, $row['log_time']), 'query' => $actions, 'is_hidden' => $row['show_online'] == 0, 'id_spider' => $row['id_spider'], 'color' => empty($row['online_color']) ? '' : $row['online_color']);
$url_data[$row['session']] = array($row['url'], $row['id_member']);
$member_ids[] = $row['id_member'];
}
$smcFunc['db_free_result']($request);
// Load the user data for these members.
loadMemberData($member_ids);
// Load up the guest user.
$memberContext[0] = array('id' => 0, 'name' => $txt['guest_title'], 'group' => $txt['guest_title'], 'href' => '', 'link' => $txt['guest_title'], 'email' => $txt['guest_title'], 'is_guest' => true);
// Are we showing spiders?
$spiderContext = array();
if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] == 2 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) {
//.........这里部分代码省略.........
示例10: JSMembers
/**
* Called by index.php?action=findmember.
* - is used as a popup for searching members.
* - uses sub template find_members of the Help template.
* - also used to add members for PM's sent using wap2/imode protocol.
*/
function JSMembers()
{
global $context, $scripturl, $user_info, $smcFunc;
checkSession('get');
if (WIRELESS) {
$context['sub_template'] = WIRELESS_PROTOCOL . '_pm';
} else {
// Why is this in the Help template, you ask? Well, erm... it helps you. Does that work?
loadTemplate('Help');
$context['template_layers'] = array();
$context['sub_template'] = 'find_members';
}
if (isset($_REQUEST['search'])) {
$context['last_search'] = $smcFunc['htmlspecialchars']($_REQUEST['search'], ENT_QUOTES);
} else {
$_REQUEST['start'] = 0;
}
// Allow the user to pass the input to be added to to the box.
$context['input_box_name'] = isset($_REQUEST['input']) && preg_match('~^[\\w-]+$~', $_REQUEST['input']) === 1 ? $_REQUEST['input'] : 'to';
// Take the delimiter over GET in case it's \n or something.
$context['delimiter'] = isset($_REQUEST['delim']) ? $_REQUEST['delim'] == 'LB' ? "\n" : $_REQUEST['delim'] : ', ';
$context['quote_results'] = !empty($_REQUEST['quote']);
// List all the results.
$context['results'] = array();
// Some buddy related settings ;)
$context['show_buddies'] = !empty($user_info['buddies']);
$context['buddy_search'] = isset($_REQUEST['buddies']);
// If the user has done a search, well - search.
if (isset($_REQUEST['search'])) {
$_REQUEST['search'] = $smcFunc['htmlspecialchars']($_REQUEST['search'], ENT_QUOTES);
$context['results'] = findMembers(array($_REQUEST['search']), true, $context['buddy_search']);
$total_results = count($context['results']);
$context['page_index'] = constructPageIndex($scripturl . '?action=findmember;search=' . $context['last_search'] . ';' . $context['session_var'] . '=' . $context['session_id'] . ';input=' . $context['input_box_name'] . ($context['quote_results'] ? ';quote=1' : '') . ($context['buddy_search'] ? ';buddies' : ''), $_REQUEST['start'], $total_results, 7);
// Determine the navigation context (especially useful for the wireless template).
$base_url = $scripturl . '?action=findmember;search=' . urlencode($context['last_search']) . (empty($_REQUEST['u']) ? '' : ';u=' . $_REQUEST['u']) . ';' . $context['session_var'] . '=' . $context['session_id'];
$context['links'] = array('first' => $_REQUEST['start'] >= 7 ? $base_url . ';start=0' : '', 'prev' => $_REQUEST['start'] >= 7 ? $base_url . ';start=' . ($_REQUEST['start'] - 7) : '', 'next' => $_REQUEST['start'] + 7 < $total_results ? $base_url . ';start=' . ($_REQUEST['start'] + 7) : '', 'last' => $_REQUEST['start'] + 7 < $total_results ? $base_url . ';start=' . floor(($total_results - 1) / 7) * 7 : '', 'up' => $scripturl . '?action=pm;sa=send' . (empty($_REQUEST['u']) ? '' : ';u=' . $_REQUEST['u']));
$context['page_info'] = array('current_page' => $_REQUEST['start'] / 7 + 1, 'num_pages' => floor(($total_results - 1) / 7) + 1);
$context['results'] = array_slice($context['results'], $_REQUEST['start'], 7);
} else {
$context['links']['up'] = $scripturl . '?action=pm;sa=send' . (empty($_REQUEST['u']) ? '' : ';u=' . $_REQUEST['u']);
}
}
示例11: action_display
//.........这里部分代码省略.........
$context['require_verification'] = create_control_verification($verificationOptions);
$context['visual_verification_id'] = $verificationOptions['id'];
}
// Are we showing signatures - or disabled fields?
$context['signature_enabled'] = substr($modSettings['signature_settings'], 0, 1) == 1;
$context['disabled_fields'] = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array();
// Censor the title...
censorText($topicinfo['subject']);
$context['page_title'] = $topicinfo['subject'];
// Is this topic sticky, or can it even be?
$topicinfo['is_sticky'] = empty($modSettings['enableStickyTopics']) ? '0' : $topicinfo['is_sticky'];
// Allow addons access to the topicinfo array
call_integration_hook('integrate_display_topic', array($topicinfo));
// Default this topic to not marked for notifications... of course...
$context['is_marked_notify'] = false;
// Did we report a post to a moderator just now?
$context['report_sent'] = isset($_GET['reportsent']);
if ($context['report_sent']) {
$template_layers->add('report_sent');
}
// Let's get nosey, who is viewing this topic?
if (!empty($settings['display_who_viewing'])) {
require_once SUBSDIR . '/Who.subs.php';
formatViewers($topic, 'topic');
}
// If all is set, but not allowed... just unset it.
$can_show_all = !empty($modSettings['enableAllMessages']) && $context['total_visible_posts'] > $context['messages_per_page'] && $context['total_visible_posts'] < $modSettings['enableAllMessages'];
if (isset($_REQUEST['all']) && !$can_show_all) {
unset($_REQUEST['all']);
} elseif (isset($_REQUEST['all'])) {
$_REQUEST['start'] = -1;
}
// Construct the page index, allowing for the .START method...
$context['page_index'] = constructPageIndex($scripturl . '?topic=' . $topic . '.%1$d', $_REQUEST['start'], $context['total_visible_posts'], $context['messages_per_page'], true, array('all' => $can_show_all, 'all_selected' => isset($_REQUEST['all'])));
$context['start'] = $_REQUEST['start'];
// This is information about which page is current, and which page we're on - in case you don't like the constructed page index. (again, wireles..)
$context['page_info'] = array('current_page' => $_REQUEST['start'] / $context['messages_per_page'] + 1, 'num_pages' => floor(($context['total_visible_posts'] - 1) / $context['messages_per_page']) + 1);
// Figure out all the link to the next/prev
$context['links'] += array('prev' => $_REQUEST['start'] >= $context['messages_per_page'] ? $scripturl . '?topic=' . $topic . '.' . ($_REQUEST['start'] - $context['messages_per_page']) : '', 'next' => $_REQUEST['start'] + $context['messages_per_page'] < $context['total_visible_posts'] ? $scripturl . '?topic=' . $topic . '.' . ($_REQUEST['start'] + $context['messages_per_page']) : '');
// If they are viewing all the posts, show all the posts, otherwise limit the number.
if ($can_show_all && isset($_REQUEST['all'])) {
// No limit! (actually, there is a limit, but...)
$context['messages_per_page'] = -1;
// Set start back to 0...
$_REQUEST['start'] = 0;
}
// Build the link tree.
$context['linktree'][] = array('url' => $scripturl . '?topic=' . $topic . '.0', 'name' => $topicinfo['subject']);
// Build a list of this board's moderators.
$context['moderators'] =& $board_info['moderators'];
$context['link_moderators'] = array();
// Information about the current topic...
$context['is_locked'] = $topicinfo['locked'];
$context['is_sticky'] = $topicinfo['is_sticky'];
$context['is_very_hot'] = $topicinfo['num_replies'] >= $modSettings['hotTopicVeryPosts'];
$context['is_hot'] = $topicinfo['num_replies'] >= $modSettings['hotTopicPosts'];
$context['is_approved'] = $topicinfo['approved'];
$context['is_poll'] = $topicinfo['id_poll'] > 0 && !empty($modSettings['pollMode']) && allowedTo('poll_view');
determineTopicClass($context);
// Did this user start the topic or not?
$context['user']['started'] = $user_info['id'] == $topicinfo['id_member_started'] && !$user_info['is_guest'];
$context['topic_starter_id'] = $topicinfo['id_member_started'];
// Set the topic's information for the template.
$context['subject'] = $topicinfo['subject'];
$context['num_views'] = $topicinfo['num_views'];
$context['num_views_text'] = $context['num_views'] == 1 ? $txt['read_one_time'] : sprintf($txt['read_many_times'], $context['num_views']);
示例12: action_splitSelectTopics
/**
* Allows the user to select the messages to be split.
* is accessed with ?action=splittopics;sa=selectTopics.
* uses 'select' sub template of the SplitTopics template or (for
* XMLhttp) the 'split' sub template of the Xml template.
* supports XMLhttp for adding/removing a message to the selection.
* uses a session variable to store the selected topics.
* shows two independent page indexes for both the selected and
* not-selected messages (;topic=1.x;start2=y).
*/
public function action_splitSelectTopics()
{
global $txt, $scripturl, $topic, $context, $modSettings, $options;
$context['page_title'] = $txt['split_topic'] . ' - ' . $txt['select_split_posts'];
$context['destination_board'] = !empty($_POST['move_to_board']) ? (int) $_POST['move_to_board'] : 0;
// Haven't selected anything have we?
$_SESSION['split_selection'][$topic] = empty($_SESSION['split_selection'][$topic]) ? array() : $_SESSION['split_selection'][$topic];
// This is a special case for split topics from quick-moderation checkboxes
if (isset($_REQUEST['subname_enc'])) {
$this->_new_topic_subject = urldecode($_REQUEST['subname_enc']);
$this->_set_session_values();
}
require_once SUBSDIR . '/Topic.subs.php';
require_once SUBSDIR . '/Messages.subs.php';
$context['not_selected'] = array('num_messages' => 0, 'start' => empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start'], 'messages' => array());
$context['selected'] = array('num_messages' => 0, 'start' => empty($_REQUEST['start2']) ? 0 : (int) $_REQUEST['start2'], 'messages' => array());
$context['topic'] = array('id' => $topic, 'subject' => urlencode($_SESSION['new_topic_subject']));
// Some stuff for our favorite template.
$context['new_subject'] = $_SESSION['new_topic_subject'];
// Using the "select" sub template.
$context['sub_template'] = isset($_REQUEST['xml']) ? 'split' : 'select';
// All of the js for topic split selection is needed
if (!isset($_REQUEST['xml'])) {
loadJavascriptFile('topic.js');
}
// Are we using a custom messages per page?
$context['messages_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages'];
// Get the message ID's from before the move.
if (isset($_REQUEST['xml'])) {
$original_msgs = array('not_selected' => messageAt($context['not_selected']['start'], $topic, array('not_in' => empty($_SESSION['split_selection'][$topic]) ? array() : $_SESSION['split_selection'][$topic], 'only_approved' => !$modSettings['postmod_active'] || !allowedTo('approve_posts'), 'limit' => $context['messages_per_page'])), 'selected' => array());
// You can't split the last message off.
if (empty($context['not_selected']['start']) && count($original_msgs['not_selected']) <= 1 && $_REQUEST['move'] == 'down') {
$_REQUEST['move'] = '';
}
if (!empty($_SESSION['split_selection'][$topic])) {
$original_msgs['selected'] = messageAt($context['selected']['start'], $topic, array('include' => empty($_SESSION['split_selection'][$topic]) ? array() : $_SESSION['split_selection'][$topic], 'only_approved' => !$modSettings['postmod_active'] || !allowedTo('approve_posts'), 'limit' => $context['messages_per_page']));
}
}
// (De)select a message..
if (!empty($_REQUEST['move'])) {
$_REQUEST['msg'] = (int) $_REQUEST['msg'];
if ($_REQUEST['move'] == 'reset') {
$_SESSION['split_selection'][$topic] = array();
} elseif ($_REQUEST['move'] == 'up') {
$_SESSION['split_selection'][$topic] = array_diff($_SESSION['split_selection'][$topic], array($_REQUEST['msg']));
} else {
$_SESSION['split_selection'][$topic][] = $_REQUEST['msg'];
}
}
// Make sure the selection is still accurate.
if (!empty($_SESSION['split_selection'][$topic])) {
$_SESSION['split_selection'][$topic] = messageAt(0, $topic, array('include' => empty($_SESSION['split_selection'][$topic]) ? array() : $_SESSION['split_selection'][$topic], 'only_approved' => !$modSettings['postmod_active'] || !allowedTo('approve_posts'), 'limit' => false));
$selection = $_SESSION['split_selection'][$topic];
} else {
$selection = array();
}
// Get the number of messages (not) selected to be split.
$split_counts = countSplitMessages($topic, !$modSettings['postmod_active'] || allowedTo('approve_posts'), $selection);
foreach ($split_counts as $key => $num_messages) {
$context[$key]['num_messages'] = $num_messages;
}
// Fix an oversized starting page (to make sure both pageindexes are properly set).
if ($context['selected']['start'] >= $context['selected']['num_messages']) {
$context['selected']['start'] = $context['selected']['num_messages'] <= $context['messages_per_page'] ? 0 : $context['selected']['num_messages'] - ($context['selected']['num_messages'] % $context['messages_per_page'] == 0 ? $context['messages_per_page'] : $context['selected']['num_messages'] % $context['messages_per_page']);
}
$page_index_url = $scripturl . '?action=splittopics;sa=selectTopics;subname=' . strtr(urlencode($_SESSION['new_topic_subject']), array('%' => '%%')) . ';topic=' . $topic;
// Build a page list of the not-selected topics...
$context['not_selected']['page_index'] = constructPageIndex($page_index_url . '.%1$d;start2=' . $context['selected']['start'], $context['not_selected']['start'], $context['not_selected']['num_messages'], $context['messages_per_page'], true);
// ...and one of the selected topics.
$context['selected']['page_index'] = constructPageIndex($page_index_url . '.' . $context['not_selected']['start'] . ';start2=%1$d', $context['selected']['start'], $context['selected']['num_messages'], $context['messages_per_page'], true);
// Retrieve the unselected messages.
$context['not_selected']['messages'] = selectMessages($topic, $context['not_selected']['start'], $context['messages_per_page'], empty($_SESSION['split_selection'][$topic]) ? array() : array('excluded' => $_SESSION['split_selection'][$topic]), $modSettings['postmod_active'] && !allowedTo('approve_posts'));
// Now retrieve the selected messages.
if (!empty($_SESSION['split_selection'][$topic])) {
$context['selected']['messages'] = selectMessages($topic, $context['selected']['start'], $context['messages_per_page'], array('included' => $_SESSION['split_selection'][$topic]), $modSettings['postmod_active'] && !allowedTo('approve_posts'));
}
// The XMLhttp method only needs the stuff that changed, so let's compare.
if (isset($_REQUEST['xml'])) {
$changes = array('remove' => array('not_selected' => array_diff($original_msgs['not_selected'], array_keys($context['not_selected']['messages'])), 'selected' => array_diff($original_msgs['selected'], array_keys($context['selected']['messages']))), 'insert' => array('not_selected' => array_diff(array_keys($context['not_selected']['messages']), $original_msgs['not_selected']), 'selected' => array_diff(array_keys($context['selected']['messages']), $original_msgs['selected'])));
$context['changes'] = array();
foreach ($changes as $change_type => $change_array) {
foreach ($change_array as $section => $msg_array) {
if (empty($msg_array)) {
continue;
}
foreach ($msg_array as $id_msg) {
$context['changes'][$change_type . $id_msg] = array('id' => $id_msg, 'type' => $change_type, 'section' => $section);
if ($change_type == 'insert') {
$context['changes']['insert' . $id_msg]['insert_value'] = $context[$section]['messages'][$id_msg];
}
//.........这里部分代码省略.........
示例13: MembergroupMembers
//.........这里部分代码省略.........
$member_query[] = 'id_member IN ({array_int:member_ids})';
$member_parameters['member_ids'] = $member_ids;
}
if (!empty($member_names)) {
$member_query[] = 'LOWER(member_name) IN ({array_string:member_names})';
$member_query[] = 'LOWER(real_name) IN ({array_string:member_names})';
$member_parameters['member_names'] = $member_names;
}
$members = array();
if (!empty($member_query)) {
$request = $smcFunc['db_query']('', '
SELECT id_member
FROM {db_prefix}members
WHERE (' . implode(' OR ', $member_query) . ')
AND id_group != {int:id_group}
AND FIND_IN_SET({int:id_group}, additional_groups) = 0', array_merge($member_parameters, array('id_group' => $_REQUEST['group'])));
while ($row = $smcFunc['db_fetch_assoc']($request)) {
$members[] = $row['id_member'];
}
$smcFunc['db_free_result']($request);
}
// !!! Add $_POST['additional'] to templates!
// Do the updates...
if (!empty($members)) {
require_once $sourcedir . '/Subs-Membergroups.php';
addMembersToGroup($members, $_REQUEST['group'], isset($_POST['additional']) || $context['group']['hidden'] ? 'only_additional' : 'auto', true);
}
}
// Sort out the sorting!
$sort_methods = array('name' => 'real_name', 'email' => allowedTo('moderate_forum') ? 'email_address' : 'hide_email ' . (isset($_REQUEST['desc']) ? 'DESC' : 'ASC') . ', email_address', 'active' => 'last_login', 'registered' => 'date_registered', 'posts' => 'posts');
// They didn't pick one, default to by name..
if (!isset($_REQUEST['sort']) || !isset($sort_methods[$_REQUEST['sort']])) {
$context['sort_by'] = 'name';
$querySort = 'real_name';
} else {
$context['sort_by'] = $_REQUEST['sort'];
$querySort = $sort_methods[$_REQUEST['sort']];
}
$context['sort_direction'] = isset($_REQUEST['desc']) ? 'down' : 'up';
// The where on the query is interesting. Non-moderators should only see people who are in this group as primary.
if ($context['group']['can_moderate']) {
$where = $context['group']['is_post_group'] ? 'id_post_group = {int:group}' : 'id_group = {int:group} OR FIND_IN_SET({int:group}, additional_groups) != 0';
} else {
$where = $context['group']['is_post_group'] ? 'id_post_group = {int:group}' : 'id_group = {int:group}';
}
// Count members of the group.
$request = $smcFunc['db_query']('', '
SELECT COUNT(*)
FROM {db_prefix}members
WHERE ' . $where, array('group' => $_REQUEST['group']));
list($context['total_members']) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);
$context['total_members'] = comma_format($context['total_members']);
// Create the page index.
$context['page_index'] = constructPageIndex($scripturl . '?action=' . ($context['group']['can_moderate'] ? 'moderate;area=viewgroups' : 'groups') . ';sa=members;group=' . $_REQUEST['group'] . ';sort=' . $context['sort_by'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $context['total_members'], $modSettings['defaultMaxMembers']);
$context['start'] = $_REQUEST['start'];
$context['can_moderate_forum'] = allowedTo('moderate_forum');
// Load up all members of this group.
$request = $smcFunc['db_query']('', '
SELECT id_member, member_name, real_name, email_address, member_ip, date_registered, last_login,
hide_email, posts, is_activated, real_name
FROM {db_prefix}members
WHERE ' . $where . '
ORDER BY ' . $querySort . ' ' . ($context['sort_direction'] == 'down' ? 'DESC' : 'ASC') . '
LIMIT ' . $context['start'] . ', ' . $modSettings['defaultMaxMembers'], array('group' => $_REQUEST['group']));
$context['members'] = array();
while ($row = $smcFunc['db_fetch_assoc']($request)) {
$last_online = empty($row['last_login']) ? $txt['never'] : timeformat($row['last_login']);
// Italicize the online note if they aren't activated.
if ($row['is_activated'] % 10 != 1) {
$last_online = '<em title="' . $txt['not_activated'] . '">' . $last_online . '</em>';
}
if (!empty($row['id_member'])) {
$context['MemberColor_ID_MEMBER'][$row['id_member']] = $row['id_member'];
}
$context['members'][] = array('id' => $row['id_member'], 'name' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>', 'email' => $row['email_address'], 'show_email' => showEmailAddress(!empty($row['hide_email']), $row['id_member']), 'ip' => '<a href="' . $scripturl . '?action=trackip;searchip=' . $row['member_ip'] . '">' . $row['member_ip'] . '</a>', 'registered' => timeformat($row['date_registered']), 'last_online' => $last_online, 'posts' => comma_format($row['posts']), 'is_activated' => $row['is_activated'] % 10 == 1);
}
$smcFunc['db_free_result']($request);
//Color the Groups List ;D
if (!empty($modSettings['MemberColorModCenter']) && !empty($context['MemberColor_ID_MEMBER'])) {
$colorDatas = load_onlineColors($context['MemberColor_ID_MEMBER']);
if (!empty($context['group']['moderators'])) {
foreach ($context['group']['moderators'] as $key => $item) {
if (!empty($colorDatas[$item['id']]['colored_link'])) {
$context['group']['moderators'][$key]['name'] = $colorDatas[$item['id']]['colored_name'];
}
}
}
if (!empty($context['members'])) {
foreach ($context['members'] as $key => $item) {
if (!empty($colorDatas[$item['id']]['colored_link'])) {
$context['members'][$key]['name'] = $colorDatas[$item['id']]['colored_link'];
}
}
}
}
// Select the template.
$context['sub_template'] = 'group_members';
$context['page_title'] = $txt['membergroups_members_title'] . ': ' . $context['group']['name'];
}
示例14: MessageSearch2
//.........这里部分代码省略.........
LIMIT ' . $context['start'] . ', ' . $modSettings['search_results_per_page'], array_merge($searchq_parameters, array('current_member' => $user_info['id'], 'not_deleted' => 0)));
$foundMessages = array();
$posters = array();
$head_pms = array();
while ($row = $smcFunc['db_fetch_assoc']($request)) {
$foundMessages[] = $row['id_pm'];
$posters[] = $row['id_member_from'];
$head_pms[$row['id_pm']] = $row['id_pm_head'];
}
$smcFunc['db_free_result']($request);
// Find the real head pms!
if ($context['display_mode'] == 2 && !empty($head_pms)) {
$request = $smcFunc['db_query']('', '
SELECT MAX(pm.id_pm) AS id_pm, pm.id_pm_head
FROM {db_prefix}personal_messages AS pm
INNER JOIN {db_prefix}pm_recipients AS pmr ON (pmr.id_pm = pm.id_pm)
WHERE pm.id_pm_head IN ({array_int:head_pms})
AND pmr.id_member = {int:current_member}
AND pmr.deleted = {int:not_deleted}
GROUP BY pm.id_pm_head
LIMIT {int:limit}', array('head_pms' => array_unique($head_pms), 'current_member' => $user_info['id'], 'not_deleted' => 0, 'limit' => count($head_pms)));
$real_pm_ids = array();
while ($row = $smcFunc['db_fetch_assoc']($request)) {
$real_pm_ids[$row['id_pm_head']] = $row['id_pm'];
}
$smcFunc['db_free_result']($request);
}
// Load the users...
$posters = array_unique($posters);
if (!empty($posters)) {
loadMemberData($posters);
}
// Sort out the page index.
$context['page_index'] = constructPageIndex($scripturl . '?action=pm;sa=search2;params=' . $context['params'], $_GET['start'], $numResults, $modSettings['search_results_per_page'], false);
$context['message_labels'] = array();
$context['message_replied'] = array();
$context['personal_messages'] = array();
if (!empty($foundMessages)) {
// Now get recipients (but don't include bcc-recipients for your inbox, you're not supposed to know :P!)
$request = $smcFunc['db_query']('', '
SELECT
pmr.id_pm, mem_to.id_member AS id_member_to, mem_to.real_name AS to_name,
pmr.bcc, pmr.labels, pmr.is_read
FROM {db_prefix}pm_recipients AS pmr
LEFT JOIN {db_prefix}members AS mem_to ON (mem_to.id_member = pmr.id_member)
WHERE pmr.id_pm IN ({array_int:message_list})', array('message_list' => $foundMessages));
while ($row = $smcFunc['db_fetch_assoc']($request)) {
if ($context['folder'] == 'sent' || empty($row['bcc'])) {
$recipients[$row['id_pm']][empty($row['bcc']) ? 'to' : 'bcc'][] = empty($row['id_member_to']) ? $txt['guest_title'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . '">' . $row['to_name'] . '</a>';
}
if ($row['id_member_to'] == $user_info['id'] && $context['folder'] != 'sent') {
$context['message_replied'][$row['id_pm']] = $row['is_read'] & 2;
$row['labels'] = $row['labels'] == '' ? array() : explode(',', $row['labels']);
// This is a special need for linking to messages.
foreach ($row['labels'] as $v) {
if (isset($context['labels'][(int) $v])) {
$context['message_labels'][$row['id_pm']][(int) $v] = array('id' => $v, 'name' => $context['labels'][(int) $v]['name']);
}
// Here we find the first label on a message - for linking to posts in results
if (!isset($context['first_label'][$row['id_pm']]) && !in_array('-1', $row['labels'])) {
$context['first_label'][$row['id_pm']] = (int) $v;
}
}
}
}
// Prepare the query for the callback!
示例15: upSSI_BoardNews
function upSSI_BoardNews($num_recent = 8, $exclude_boards = null, $include_boards = null, $length, $bkcall = '')
{
global $context, $settings, $scripturl, $txt, $user_info, $modSettings, $smcFunc;
loadLanguage('Stats');
if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) {
$exclude_boards = array($modSettings['recycle_board']);
} else {
$exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards));
}
// Only some boards?.
if (is_array($include_boards) || (int) $include_boards === $include_boards) {
$include_boards = is_array($include_boards) ? $include_boards : array($include_boards);
} elseif ($include_boards != null) {
$output_method = $include_boards;
$include_boards = array();
}
$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon) {
$icon_sources[$icon] = 'images_url';
}
//Prepare the constructPageIndex() function
$start = !empty($_REQUEST['sa']) && $_REQUEST['sa'] == $bkcall . 'boardnews' ? (int) $_REQUEST['start'] : 0;
$db_count = $smcFunc['db_query']('', '
SELECT count(m.id_topic)
FROM {db_prefix}topics AS t
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
INNER JOIN {db_prefix}messages AS ms ON (ms.id_msg = t.id_first_msg)
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = {int:current_member})
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = {int:current_member})' : '') . '
WHERE m.id_topic > 0
' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})') . '
' . (empty($include_boards) ? '' : '
AND b.id_board IN ({array_int:include_boards})') . '
AND {query_wanna_see_board}' . ($modSettings['postmod_active'] ? '
AND t.approved = {int:is_approved}
AND m.approved = {int:is_approved}' : '') . '
ORDER BY t.id_first_msg DESC', array('current_member' => $user_info['id'], 'include_boards' => empty($include_boards) ? '' : $include_boards, 'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards, 'is_approved' => 1));
$numNews = array();
list($numNews) = $smcFunc['db_fetch_row']($db_count);
$smcFunc['db_free_result']($db_count);
$context['page_index'] = constructPageIndex($scripturl . '?sa=' . $bkcall . 'boardnews', $start, $numNews, $num_recent);
// Find all the posts in distinct topics. Newer ones will have higher IDs.
$request = $smcFunc['db_query']('', '
SELECT
m.poster_time, ms.subject, m.id_topic, m.id_member, m.id_msg, b.id_board, b.name AS board_name, t.num_replies, t.num_views,
t.locked,
IFNULL(mem.real_name, m.poster_name) AS poster_name, ' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . ', m.body AS body, m.smileys_enabled, m.icon
FROM {db_prefix}topics AS t
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
INNER JOIN {db_prefix}messages AS ms ON (ms.id_msg = t.id_first_msg)
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = {int:current_member})
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = {int:current_member})' : '') . '
WHERE m.id_topic > 0
' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})') . '
' . (empty($include_boards) ? '' : '
AND b.id_board IN ({array_int:include_boards})') . '
AND {query_wanna_see_board}' . ($modSettings['postmod_active'] ? '
AND t.approved = {int:is_approved}
AND m.approved = {int:is_approved}' : '') . '
ORDER BY t.id_first_msg DESC
' . ($num_recent < 0 ? "" : " LIMIT {int:start}, {int:limit} ") . '', array('current_member' => $user_info['id'], 'include_boards' => empty($include_boards) ? '' : $include_boards, 'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards, 'is_approved' => 1, 'start' => $start, 'limit' => $num_recent));
$return = array();
while ($row = $smcFunc['db_fetch_assoc']($request)) {
// If we want to limit the length of the post.
if (!empty($length) && $smcFunc['strlen']($row['body']) > $length) {
$row['body'] = $smcFunc['substr']($row['body'], 0, $length);
// The first space or line break. (<br />, etc.)
$cutoff = max(strrpos($row['body'], ' '), strrpos($row['body'], '<'));
if ($cutoff !== false) {
$row['body'] = $smcFunc['substr']($row['body'], 0, $cutoff);
}
$row['body'] .= '...';
}
$row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']);
// Censor the subject.
censorText($row['subject']);
censorText($row['body']);
if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']])) {
$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url';
}
// Build the array.
$return[] = array('board' => array('id' => $row['id_board'], 'name' => $row['board_name'], 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', 'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['board_name'] . '</a>'), 'topic' => $row['id_topic'], 'poster' => array('id' => $row['id_member'], 'name' => $row['poster_name'], 'href' => empty($row['id_member']) ? '' : $scripturl . '?action=profile;u=' . $row['id_member'], 'link' => empty($row['id_member']) ? $row['poster_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['poster_name'] . '</a>'), 'subject' => $row['subject'], 'replies' => $row['num_replies'], 'views' => $row['num_views'], 'short_subject' => shorten_subject($row['subject'], 25), 'preview' => $row['body'], 'time' => timeformat($row['poster_time']), 'timestamp' => forum_time(true, $row['poster_time']), 'href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . ';topicseen#new', 'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#new" rel="nofollow">' . $row['subject'] . '</a>', 'new' => !empty($row['is_read']), 'is_new' => empty($row['is_read']), 'new_from' => $row['new_from'], 'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />', 'comment_link' => !empty($row['locked']) ? '' : '<a href="' . $scripturl . '?action=post;topic=' . $row['id_topic'] . '.' . $row['num_replies'] . ';num_replies=' . $row['num_replies'] . '">' . $txt['ssi_write_comment'] . '</a>');
}
$smcFunc['db_free_result']($request);
//ok return now
return $return;
}