/**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     unset($map);
     if (get_forum_type() != 'ocf') {
         return new ocp_tempcode();
     }
     if (is_guest()) {
         return new ocp_tempcode();
     }
     require_css('side_blocks');
     ocf_require_all_forum_stuff();
     require_code('ocf_notifications');
     // Only show what's new in week. Some forums may want to tweak this, but forums themselves only mark unread topics for a week.
     $rows = ocf_get_pp_rows();
     //		if (count($rows)==0) return new ocp_tempcode();
     require_lang('ocf');
     $out = new ocp_tempcode();
     foreach ($rows as $topic) {
         $topic_url = build_url(array('page' => 'topicview', 'id' => $topic['id'], 'type' => 'findpost'), get_module_zone('topicview'));
         $topic_url->attach('#post_' . strval($topic['id']));
         $title = $topic['t_cache_first_title'];
         $date = get_timezoned_date($topic['t_cache_last_time'], true);
         $username = $topic['t_cache_last_username'];
         $member_link = $GLOBALS['OCF_DRIVER']->member_profile_url($topic['t_cache_last_member_id'], false, true);
         $num_posts = $topic['t_cache_num_posts'];
         $out->attach(do_template('TOPIC_LIST', array('_GUID' => '55ae21a9f8d67ba6237c118a18b9657b', 'USER_LINK' => $member_link, 'TOPIC_LINK' => $topic_url, 'TITLE' => $title, 'DATE' => $date, 'DATE_RAW' => strval($topic['t_cache_last_time']), 'USERNAME' => $username, 'NUM_POSTS' => integer_format($num_posts))));
     }
     $send_url = build_url(array('page' => 'topics', 'type' => 'new_pt', 'redirect' => SELF_REDIRECT), get_module_zone('topics'));
     if (!ocf_may_make_personal_topic()) {
         $send_url = new ocp_tempcode();
     }
     $view_url = build_url(array('page' => 'members', 'type' => 'view', 'id' => get_member()), get_module_zone('members'), NULL, true, false, false, 'tab__pts');
     return do_template('BLOCK_SIDE_OCF_PERSONAL_TOPICS', array('_GUID' => '9376cd47884a78f3d1914c176b67ee28', 'SEND_URL' => $send_url, 'VIEW_URL' => $view_url, 'CONTENT' => $out, 'FORUM_NAME' => do_lang_tempcode('PERSONAL_TOPICS')));
 }
Пример #2
0
 /**
  * Standard modular run function for RSS hooks.
  *
  * @param  string			A list of categories we accept from
  * @param  TIME			Cutoff time, before which we do not show results from
  * @param  string			Prefix that represents the template set we use
  * @set    RSS_ ATOM_
  * @param  string			The standard format of date to use for the syndication type represented in the prefix
  * @param  integer		The maximum number of entries to return, ordering by date
  * @return ?array			A pair: The main syndication section, and a title (NULL: error)
  */
 function run($_filters, $cutoff, $prefix, $date_string, $max)
 {
     if (get_forum_type() != 'ocf') {
         return NULL;
     }
     if (is_guest()) {
         return NULL;
     }
     $member_id = get_member();
     if (get_forum_type() != 'ocf') {
         return NULL;
     }
     if (!has_actual_page_access($member_id, 'forumview')) {
         return NULL;
     }
     if (is_guest()) {
         return NULL;
     }
     require_code('ocf_notifications');
     $rows = ocf_get_pp_rows($max);
     $content = new ocp_tempcode();
     foreach ($rows as $row) {
         $id = strval($row['p_id']);
         $author = $row['t_cache_first_username'];
         $news_date = date($date_string, $row['t_cache_first_time']);
         $edit_date = date($date_string, $row['t_cache_last_time']);
         if ($edit_date == $news_date) {
             $edit_date = '';
         }
         $news_title = xmlentities($row['t_cache_first_title']);
         $_summary = get_translated_tempcode($row['t_cache_first_post'], $GLOBALS['FORUM_DB']);
         $summary = xmlentities($_summary->evaluate());
         $news = '';
         $category = do_lang('NA');
         $category_raw = '';
         $_view_url = build_url(array('page' => 'topicview', 'id' => $row['t_id']), get_module_zone('forumview'));
         $view_url = $_view_url->evaluate();
         $view_url .= '#' . strval($row['p_id']);
         if ($prefix == 'RSS_') {
             $if_comments = do_template('RSS_ENTRY_COMMENTS', array('COMMENT_URL' => $view_url, 'ID' => strval($row['p_id'])));
         } else {
             $if_comments = new ocp_tempcode();
         }
         $content->attach(do_template($prefix . 'ENTRY', array('VIEW_URL' => $view_url, 'SUMMARY' => $summary, 'EDIT_DATE' => $edit_date, 'IF_COMMENTS' => $if_comments, 'TITLE' => $news_title, 'CATEGORY_RAW' => $category_raw, 'CATEGORY' => $category, 'AUTHOR' => $author, 'ID' => $id, 'NEWS' => $news, 'DATE' => $news_date)));
     }
     require_lang('ocf');
     return array($content, do_lang('PERSONAL_TOPICS'));
 }
Пример #3
0
/**
 * Calculate OCF notifications and render.
 *
 * @param  string		Cache identifier that we'll use.
 * @return array		A pair: Number of notifications, Rendered notifications.
 */
function generate_notifications($cache_identifier)
{
    $nql_backup = $GLOBALS['NO_QUERY_LIMIT'];
    $GLOBALS['NO_QUERY_LIMIT'] = true;
    $unread_pps = ocf_get_pp_rows();
    $notifications = new ocp_tempcode();
    $num_unread_pps = 0;
    foreach ($unread_pps as $unread_pp) {
        $by_id = is_null($unread_pp['t_cache_first_member_id']) || !is_null($unread_pp['t_forum_id']) ? $unread_pp['p_poster'] : $unread_pp['t_cache_first_member_id'];
        $by = $GLOBALS['OCF_DRIVER']->get_username($by_id);
        if (is_null($by)) {
            $by = do_lang('UNKNOWN');
        }
        $u_title = $unread_pp['t_cache_first_title'];
        if (is_null($unread_pp['t_forum_id'])) {
            $type = do_lang_tempcode($unread_pp['t_cache_first_post_id'] == $unread_pp['id'] ? 'NEW_PT_NOTIFICATION' : 'NEW_PP_NOTIFICATION');
            $num_unread_pps++;
            $reply_url = build_url(array('page' => 'topics', 'type' => 'new_post', 'id' => $unread_pp['p_topic_id'], 'quote' => $unread_pp['id']), get_module_zone('topics'));
            $additional_posts = $GLOBALS['FORUM_DB']->query_value_null_ok_full('SELECT COUNT(*) AS cnt FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts WHERE p_topic_id=' . strval($unread_pp['p_topic_id']) . ' AND id>' . strval($unread_pp['id']));
        } else {
            $type = do_lang_tempcode('ADD_INLINE_PERSONAL_POST');
            if ($unread_pp['p_title'] != '') {
                $u_title = $unread_pp['p_title'];
            }
            $reply_url = build_url(array('page' => 'topics', 'type' => 'new_post', 'id' => $unread_pp['p_topic_id'], 'quote' => $unread_pp['id'], 'intended_solely_for' => $unread_pp['p_poster']), get_module_zone('topics'));
            $additional_posts = 0;
        }
        $time_raw = $unread_pp['p_time'];
        $time = get_timezoned_date($unread_pp['p_time']);
        $topic = $GLOBALS['OCF_DRIVER']->post_url($unread_pp['id'], NULL);
        $post = get_translated_tempcode($unread_pp['p_post'], $GLOBALS['FORUM_DB']);
        $description = $unread_pp['t_description'];
        if ($description != '') {
            $description = ' (' . $description . ')';
        }
        $profile_link = is_guest($by_id) ? new ocp_tempcode() : $GLOBALS['OCF_DRIVER']->member_profile_url($by_id, false, true);
        $redirect = get_self_url(true, true);
        $ignore_url = build_url(array('page' => 'topics', 'type' => 'mark_read_topic', 'id' => $unread_pp['p_topic_id'], 'redirect' => $redirect), get_module_zone('topics'));
        $ignore_url_2 = build_url(array('page' => 'topics', 'type' => 'mark_read_topic', 'id' => $unread_pp['p_topic_id'], 'redirect' => $redirect, 'ajax' => 1), get_module_zone('topics'));
        require_javascript('javascript_ajax');
        $notifications->attach(do_template('OCF_NOTIFICATION', array('_GUID' => '3b224ea3f4da2f8f869a505b9756970a', 'ADDITIONAL_POSTS' => integer_format($additional_posts), '_ADDITIONAL_POSTS' => strval($additional_posts), 'ID' => strval($unread_pp['id']), 'U_TITLE' => $u_title, 'IGNORE_URL' => $ignore_url, 'IGNORE_URL_2' => $ignore_url_2, 'REPLY_URL' => $reply_url, 'TOPIC_URL' => $topic, 'POST' => $post, 'DESCRIPTION' => $description, 'TIME' => $time, 'TIME_RAW' => strval($time_raw), 'BY' => $by, 'PROFILE_LINK' => $profile_link, 'TYPE' => $type)));
    }
    require_code('caches2');
    put_into_cache('_new_pp', 60 * 60 * 24, $cache_identifier, array($notifications->to_assembly(), $num_unread_pps));
    $GLOBALS['NO_QUERY_LIMIT'] = $nql_backup;
    return array($notifications, $num_unread_pps);
}