Exemplo n.º 1
0
/**
 * builds a post (including its children)
 *
 * @param int $postindex the index of the post
 * @param string $parentsubject the subject of the parent
 * @param array $posts the posts in the topic
 *
 * @returns string the html for the post
 */
function buildpost($postindex, $parentsubject, &$posts)
{
    global $moderator, $topic, $groupadmins;
    $localposts = $posts;
    if ($posts[$postindex]->subject) {
        $parentsubject = $posts[$postindex]->subject;
    } else {
        $posts[$postindex]->subject = get_string('re', 'interaction.forum', $parentsubject);
    }
    $children = array();
    foreach ($localposts as $index => $post) {
        if ($posts[$index]->parent == $posts[$postindex]->id) {
            $children[] = buildpost($index, $parentsubject, $posts);
        }
    }
    $membership = user_can_access_forum((int) $topic->forumid);
    $smarty = smarty_core();
    $smarty->assign('post', $posts[$postindex]);
    $smarty->assign('groupadmins', $groupadmins);
    $smarty->assign('children', $children);
    $smarty->assign('moderator', $moderator);
    $smarty->assign('membership', $membership);
    $smarty->assign('closed', $topic->closed);
    return $smarty->fetch('interaction:forum:post.tpl');
}
Exemplo n.º 2
0
/**
 * Sorts children posts into their parent
 * 
 * @param int $postindex the index of the post
 * @param array $posts the posts in the topic
 *
 * @returns array the html for the post
 */
function buildpost($postindex, &$posts)
{
    global $moderator, $topic, $groupadmins;
    $localposts = $posts;
    $children = array();
    foreach ($localposts as $index => $post) {
        if ($posts[$index]->parent == $posts[$postindex]->id) {
            $children[] = buildpost($index, $posts);
        }
    }
    $posts[$postindex]->children = $children;
    return $posts[$postindex];
}