function &get_section_usage_rows(&$f_usage_rows, &$f_topic_starts_rows)
{
    $section_rows = array();
    $row_count = sizeof($f_usage_rows);
    $j = 0;
    $section_post_count = 0;
    $section_topic_starts = 0;
    $section_watch_count = 0;
    $last_section_id = $row_count > 0 ? $f_usage_rows[0]['parent_id'] : -999;
    $forum_cats = get_root_categories_rows();
    $forum_cats_array = array();
    foreach ($forum_cats as $forum_cat) {
        $forum_cats_array[$forum_cat['forum_id']] = $forum_cat['forum_id'];
    }
    for ($i = 0; $i < $row_count; $i++) {
        /* If the section id has changed, add new row to $section_rows and reset count variables. Otherwise, simply update section data */
        $cur_section_id = $f_usage_rows[$i]['parent_id'];
        // Mighty Gorgon: with the new category system we may just check if the parent is 0!
        $cur_cat_root_parent = in_array($f_usage_rows[$i]['parent_id'], $forum_cats_array) ? true : false;
        $cat_changed = $cur_section_id == $last_section_id ? false : true;
        if ($cur_cat_root_parent && $cat_changed) {
            $section_rows[$j++] = array('section_id' => $last_section_id, 'section_post_count' => $section_post_count, 'section_topic_starts' => $section_topic_starts, 'section_watch_count' => $section_watch_count);
            $section_post_count = 0;
            $section_topic_starts = 0;
            $section_watch_count = 0;
            $last_section_id = $cur_section_id;
        }
        $section_post_count += $f_usage_rows[$i]['forum_post_count'];
        $section_topic_starts += get_forum_topic_starts($f_topic_starts_rows, $f_usage_rows[$i]['forum_id']);
        $section_watch_count += $f_usage_rows[$i]['watch_count'];
    }
    /* Make sure we include the last section */
    $section_rows[$j++] = array('section_id' => $last_section_id, 'section_post_count' => $section_post_count, 'section_topic_starts' => $section_topic_starts, 'section_watch_count' => $section_watch_count);
    /* Return results */
    return $section_rows;
}
Example #2
0
 * list. */
if (!isset($config[BBUS_CONFIGPROP_PRSCALE_NAME])) {
    set_config(BBUS_CONFIGPROP_PRSCALE_NAME, BBUS_CONFIGPROP_PRSCALE_DEFAULT);
    $config[BBUS_CONFIGPROP_PRSCALE_NAME] = BBUS_CONFIGPROP_PRSCALE_DEFAULT;
}
/* If the bb_usage_stats_trscale property is not in the board's configuration,
 * add it and generate the select list.  Otherwise, just generate the select
 * list. */
if (!isset($config[BBUS_CONFIGPROP_TRSCALE_NAME])) {
    set_config(BBUS_CONFIGPROP_TRSCALE_NAME, BBUS_CONFIGPROP_TRSCALE_DEFAULT);
    $config[BBUS_CONFIGPROP_TRSCALE_NAME] = BBUS_CONFIGPROP_TRSCALE_DEFAULT;
}
/* Now, begin the task of constructing the BB Usage Stats data */
if (!empty($show_extra_stats) && $view_bb_usage_allowed) {
    $is_auth = auth(AUTH_READ, AUTH_LIST_ALL, $user->data);
    $forum_cats = get_root_categories_rows();
    $forum_cats_array = array();
    foreach ($forum_cats as $forum_cat) {
        $forum_cats_array[$forum_cat['forum_id']] = $forum_cat['forum_id'];
    }
    /* Retrieve user's forum usage data */
    $forum_usage_rows =& get_forum_usage_rows($profiledata['user_id'], $profiledata['user_posts'], $viewoptions & BBUS_VIEWOPTION_SHOW_ALL_FORUMS);
    /* Retrieve user's topic start data */
    $forum_topic_starts_rows =& get_forum_topic_starts_rows($profiledata['user_id']);
    /* Retrieve section summary information */
    $section_usage_rows =& get_section_usage_rows($forum_usage_rows, $forum_topic_starts_rows);
    /* Set the file handles to include bb_usage_stats.tpl */
    $template->set_filenames(array('bb_usage_stats_template' => 'bb_usage_stats.tpl'));
    $unpruned_post_count = get_unpruned_post_count($profiledata['user_id']);
    $max_columns = 7;
    if (($viewoptions & BBUS_VIEWOPTION_PCTUTUP_COLUMN_VISIBLE) != 0) {