private function buildStatistics($board) { $board_statistics = $board->getBoardStatistics(); $statistics = array(); $statistics['title'] = $board->get_title(); $statistics['description'] = $board->get_description(); $statistics['type'] = $board->get_type() . " board"; $statistics['created_at'] = $board->get_created_at(); switch ($board->get_type()) { case PaForumBoard::network_board: $net_id = $board->get_owner_id(); if ($net_id == 1) { // mother network - owner_id always is '1' ! $owner_id = 1; } else { $owner_id = Network::get_network_owner((int) $board->get_owner_id()); } break; case PaForumBoard::group_board: $owner_id = Group::get_owner_id((int) $board->get_owner_id()); break; case PaForumBoard::personal_board: $owner_id = $board->get_owner_id(); break; } $user = new User(); $user->load((int) $owner_id); $statistics['owner'] = $user; $statistics['nb_categories'] = $board_statistics['nb_categories']; $nb_forums = 0; $nb_threads = 0; $nb_posts = 0; $threads = array(); $last_posts = array(); foreach ($board_statistics['categories'] as $category) { if ($category->statistics['nb_forums'] > 0) { $nb_forums += $category->statistics['nb_forums']; foreach ($category->statistics['forums'] as $forum) { if (!empty($forum->statistics['threads']) and count($forum->statistics['threads']) > 0) { foreach ($forum->statistics['threads'] as &$thr) { $thr->forum = $forum; } $threads = array_merge($threads, $forum->statistics['threads']); $nb_threads += $forum->statistics['nb_threads']; $nb_posts += $forum->statistics['nb_posts']; if (!empty($forum->statistics['last_post'])) { $last_posts[] = $forum->statistics['last_post']; } } } } } if (count($threads) > 1) { usort($threads, "cmpThreadCreated"); } $statistics['threads'] = $threads; $statistics['nb_forums'] = $nb_forums; $statistics['nb_threads'] = $nb_threads; $statistics['nb_posts'] = $nb_posts; $statistics['last_posts'] = $last_posts; $statistics['nb_users'] = PaForumsUsers::countPaForumsUsers("board_id = " . $board->get_id()); return $statistics; }