Example #1
0
function homePage($webgbDao, $idCommunity, $cam)
{
    global $CFG, $USER, $OUTPUT;
    if ($cam) {
        include_once $CFG->dirroot . '/blocks/webgd_community/lib/camera/index.php';
    }
    $linkCam = $CFG->wwwroot . "/blocks/webgd_community/view.php?community={$idCommunity}&cam=1";
    echo '<div id="camera"></div>
    <form id="form" method="post" role="form" enctype="multipart/form-data" class="facebook-share-box">
        <input type="hidden" name="community" value="' . $idCommunity . '">
        <div class="arrow"></div>
        <div class="panel panel-default">
            <div class="panel-heading">
                <i class="fa fa-file"></i> ' . get_string('atualizarStatus', 'block_webgd_community') . '
            </div>
            <div class="panel-body">
                <div class="">
                    <textarea name="message" cols="30" rows="10" id="status_message"
                              class="form-control message"
                              style="height: 62px; width: 95%; overflow: hidden;"
                              placeholder="' . get_string('escrevaSeuPost', 'block_webgd_community') . '"></textarea>
                </div>
            </div>
            <div class="panel-footer">
                <div class="row">
                    <div class="col-md-5">
                        <input type="button" name="submit" value="' . get_string('enviar', 'block_webgd_community') . '"
                              style="margin-left: 50px"
                               class="btn btn-primary" onclick="salvar()">
                    </div>
                </div>
            </div>
        </div>
    </form>
    <div id="posts">';
    $ultimo_post = 0;
    if ($communities = $webgbDao->getAllCommunityPost($idCommunity)) {
        $images = Commons::imageById($USER->id);
        foreach ($communities as $community) {
            if ($USER->id == $community->userid) {
                Commons::printListPost($community, 1, $idCommunity);
            } else {
                Commons::printListPost($community, 0, $idCommunity);
            }
            echo '&nbsp;<span style="color:#41627F;">' . get_string('responder', 'block_webgd_community') . '</span><div class="comentarios">';
            Commons::printTimelineComments($community->id);
            echo '<form method="post" enctype="multipart/form-data" id="form-comment-' . $community->id . '" class="form-comment" onsubmit="enviaComentario(' . $community->id . '); return false;">
                    <input type="hidden" name="post_id_comment" value="' . $community->id . '">
                    <div style="line-height:25px;">';
            foreach ($images as $img) {
                echo $OUTPUT->user_picture($img, array('size' => 25, 'alttext' => false, 'link' => false));
            }
            echo '<input style="margin:4px 0 0 5px; width:75%;" type="text" name="comment" class="comment" placeholder="">
                    </div>
                    </form></div>';
            if ($ultimo_post == 0) {
                $ultimo_post = $community->id;
            }
        }
    } else {
        echo get_string('nenhumComentario', 'block_webgd_community');
    }
    echo "<input type='hidden' id='ultimo_post' value='" . $ultimo_post . "'>";
    echo "<input type='hidden' id='comunidade_id' value='" . $idCommunity . "'>";
    echo '</div>';
}