Beispiel #1
0
function notification($memID)
{
    global $txt, $scripturl, $user_profile, $context, $modSettings, $sourcedir;
    // Gonna want this for the list.
    require_once $sourcedir . '/lib/Subs-List.php';
    EoS_Smarty::loadTemplate('profile/profile_base');
    EoS_Smarty::getConfigInstance()->registerHookTemplate('profile_content_area', 'profile/notifications');
    // Fine, start with the board list.
    $listOptions = array('id' => 'board_notification_list', 'width' => '100%', 'no_items_label' => $txt['notifications_boards_none'] . '<br /><br />' . $txt['notifications_boards_howto'], 'no_items_align' => 'left', 'base_href' => $scripturl . '?action=profile;u=' . $memID . ';area=notification', 'default_sort_col' => 'board_name', 'get_items' => array('function' => 'list_getBoardNotifications', 'params' => array($memID)), 'columns' => array('board_name' => array('header' => array('value' => $txt['notifications_boards'], 'class' => 'lefttext first_th'), 'data' => array('function' => create_function('$board', '
						global $settings, $txt;

						$link = $board[\'link\'];

						if ($board[\'new\'])
							$link .= \' <a href="\' . $board[\'href\'] . \'"><img src="\' . $settings[\'images_url\'] . \'/new.png" alt="\' . $txt[\'new\'] . \'" /></a>\';

						return $link;
					')), 'sort' => array('default' => 'name', 'reverse' => 'name DESC')), 'delete' => array('header' => array('value' => '<input type="checkbox" class="input_check" onclick="invertAll(this, this.form);" />', 'style' => 'width: 4%;'), 'data' => array('sprintf' => array('format' => '<input type="checkbox" name="notify_boards[]" value="%1$d" class="input_check" />', 'params' => array('id' => false)), 'style' => 'text-align: center;'))), 'form' => array('href' => $scripturl . '?action=profile;area=notification;save', 'include_sort' => true, 'include_start' => true, 'hidden_fields' => array('u' => $memID, 'sa' => $context['menu_item_selected'], $context['session_var'] => $context['session_id'])), 'additional_rows' => array(array('position' => 'bottom_of_list', 'value' => '<input type="submit" name="edit_notify_boards" value="' . $txt['notifications_update'] . '" class="button_submit" />', 'align' => 'right')));
    // Create the board notification list.
    createList($listOptions);
    $context['topiclist'] = array('form' => array('href' => $scripturl . '?action=profile;area=notification;save', 'id' => 'topic_notifications', 'method' => 'post', 'submit_name' => 'edit_notify_topics', 'submit_label' => $txt['notifications_update'], 'hidden_fields' => array(array('name' => 'u', 'value' => $memID), array('name' => 'sa', 'value' => $context['menu_item_selected']), array('name' => $context['session_var'], 'value' => $context['session_id']), array('name' => 'sort', 'value' => isset($_REQUEST['sort']) ? $_REQUEST['sort'] : 'last_post'))), 'sort' => array('last_post' => array('default' => 'ml.id_msg DESC', 'reverse' => 'ml.id_msg'), 'subject' => array('default' => 'ms.subject', 'reverse' => 'ms.subject DESC'), 'started_by' => array('default' => 'real_name_col', 'reverse' => 'real_name_col DESC'), 'replies' => array('default' => 't.num_replies DESC', 'reverse' => 't.num_replies'), 'views' => array('default' => 't.num_views DESC', 'reverse' => 't.num_views')), 'item_count' => list_getTopicNotificationCount($memID), 'items_per_page' => $modSettings['defaultMaxMessages'], 'baseurl' => $scripturl . '?action=profile;area=notification', 'title' => $txt['active_topic_subscriptions']);
    $context['sort_by'] = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : 'last_post';
    $sort_order = isset($_REQUEST['desc']) ? 'reverse' : 'default';
    $context['sort_direction'] = isset($_REQUEST['desc']) ? 'up' : 'down';
    $context['start'] = isset($_REQUEST['start']) ? $_REQUEST['start'] : 0;
    $context['topiclist']['pages'] = constructPageIndex($context['topiclist']['baseurl'] . ';sort=' . $context['sort_by'], $context['start'], $context['topiclist']['item_count'], $modSettings['defaultMaxMessages']);
    $context['can_approve_posts'] = false;
    $context['can_quick_mod'] = true;
    // we always want the checkboxes to select topics to unsubscribe. no permissions needed here...
    $db = list_getTopicNotifications($context['start'], $modSettings['defaultMaxMessages'], $context['topiclist']['sort'][$context['sort_by']][$sort_order], $memID);
    $context['cb_name'] = 'notify_topics[]';
    $_t = new Topiclist($db, $context['topiclist']['item_count']);
    $context['topiclist']['items'] = $_t->getResult();
    mysql_free_result($db);
    $context['member'] += array('notify_announcements' => $user_profile[$memID]['notify_announcements'], 'notify_send_body' => $user_profile[$memID]['notify_send_body'], 'notify_types' => $user_profile[$memID]['notify_types'], 'notify_regularity' => $user_profile[$memID]['notify_regularity']);
    loadThemeOptions($memID);
}
Beispiel #2
0
/**
 * fetch new threads (all of them, read status doesn't matter)
 *
 * todo: respect ignored boards
 */
function WhatsNew()
{
    global $context, $modSettings, $txt, $user_info, $scripturl;
    $cutoff_days = !empty($modSettings['whatsNewCutoffDays']) ? $modSettings['whatsNewCutoffDays'] : 30;
    $context['current_action'] = 'whatsnew';
    $start = isset($_REQUEST['start']) ? $_REQUEST['start'] : 0;
    $context['topics_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics'];
    // find the first post that is newer than our cutoff time...
    $request = smf_db_query('SELECT m.id_msg from {db_prefix}messages AS m 
			LEFT JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic) 
			LEFT JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board) 
			WHERE {query_wanna_see_board} AND m.approved = 1 AND m.poster_time > unix_timestamp(now()) - ({int:days_cutoff} * 86400) limit 1', array('days_cutoff' => $cutoff_days));
    EoS_Smarty::loadTemplate('recent');
    $context['template_functions'] = 'unread_topics';
    $context['can_approve_posts'] = allowedTo('approve_posts');
    $context['page_title'] = $context['page_header'] = sprintf($txt['whatsnew_title'], $cutoff_days);
    $context['subject_sort_header'] = $txt['subject'];
    $context['views_sort_header'] = $txt['views'];
    $context['lastpost_sort_header'] = $txt['last_post'];
    $context['querystring_board_limits'] = '';
    $context['linktree'][] = array('url' => URL::parse($scripturl . '?action=whatsnew'), 'name' => $context['page_title']);
    if (0 == mysql_num_rows($request)) {
        mysql_free_result($request);
        return;
    }
    list($first_msg) = mysql_fetch_row($request);
    mysql_free_result($request);
    $request = smf_db_query('SELECT DISTINCT(t.id_topic), COUNT(t.id_topic) FROM {db_prefix}topics AS t 
			LEFT JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
			WHERE {query_wanna_see_board} AND t.id_last_msg >= {int:first_msg} limit 1', array('first_msg' => $first_msg));
    list($id, $count) = mysql_fetch_row($request);
    mysql_free_result($request);
    $total = $count;
    $base_url = URL::parse($scripturl . '?action=whatsnew');
    $context['page_index'] = constructPageIndex($base_url . ';start=%1$d', $start, $total, $context['topics_per_page'], true);
    $topic_ids = array();
    $request = smf_db_query('SELECT DISTINCT t.id_topic FROM {db_prefix}topics AS t
			LEFT JOIN {db_prefix}boards AS b ON(b.id_board = t.id_board)
			WHERE {query_wanna_see_board} AND t.id_last_msg >= {int:first_msg} ORDER BY t.id_last_msg DESC LIMIT {int:start}, {int:perpage}', array('first_msg' => $first_msg, 'start' => $start, 'perpage' => $context['topics_per_page']));
    while ($row = mysql_fetch_assoc($request)) {
        $topic_ids[] = $row['id_topic'];
    }
    mysql_free_result($request);
    $request = smf_db_query('SELECT	t.id_topic, IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from, b.id_board, b.name AS board_name, t.num_replies, t.locked, t.num_views, t.is_sticky, t.approved, t.unapproved_posts, t.id_first_msg, t.id_last_msg,
				ms.subject, ml.subject AS last_subject, ms.id_member, IFNULL(mem.real_name, ms.poster_name) AS first_member_name, ms.poster_time AS first_poster_time, ms.icon AS first_icon,
				ml.id_msg_modified, ml.poster_time, ml.id_member AS id_member_updated,
				IFNULL(mem2.real_name, ml.poster_name) AS last_real_name, ml.poster_time AS last_post_time
				FROM {db_prefix}topics AS t 
				INNER JOIN {db_prefix}messages AS ms ON (ms.id_msg = t.id_first_msg)
				INNER JOIN {db_prefix}messages AS ml ON (ml.id_msg = t.id_last_msg)
				LEFT JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
				LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = ms.id_member)
				LEFT JOIN {db_prefix}members AS mem2 ON (mem2.id_member = ml.id_member)
				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 = t.id_board AND lmr.id_member = {int:current_member})
				LEFT JOIN {db_prefix}prefixes AS p ON (p.id_prefix = t.id_prefix)
				WHERE t.id_topic IN({array_int:topic_ids}) ORDER BY t.id_last_msg DESC', array('start' => $start, 'perpage' => $context['topics_per_page'], 'first_msg' => $first_msg, 'current_member' => $user_info['id'], 'topic_ids' => $topic_ids));
    $topiclist = new Topiclist($request, $total, true);
    mysql_free_result($request);
    $context['showing_all_topics'] = true;
    $context['topics'] = $topiclist->getResult();
}