require_login(1); global $USER, $DB, $CFG; $PAGE->set_url('/course/index.php'); $PAGE->set_context(context_system::instance()); $PAGE->set_pagelayout('standard'); $PAGE->requires->css(CssResources::LIST_HOME_COMMUNITY); echo $OUTPUT->header('themeselector'); $webgdCommunityDao = new WebgdCommunityDao(); if ($listCommunity = $webgdCommunityDao->getListCommunity()) { echo '<span class="titulo_list">' . $OUTPUT->heading(get_string('comunidades', 'block_webgd_community')) . '</span>'; echo '<div class="lista_home">'; echo '<span class="titulo_list"></span>'; foreach ($listCommunity as $community) { $participar = ""; $fechada = 0; if (!$webgdCommunityDao->findUserInCommunityById($community->id, $USER->id)) { if ($community->close_community == 1) { $participar = "<img class='botao_comunidade' src='" . $CFG->wwwroot . ImageResources::COMUNIDADE_FECHADA . "'>"; $fechada = 1; } else { $participar = "<div>" . html_writer::tag('a', "<img class='botao_comunidade' src='" . $CFG->wwwroot . ImageResources::PARTICIPAR_COMUNIDADE . "'>", array('href' => "view.php?community={$community->id}&confirm=1")) . "</div>"; } } else { if ($community->close_community == 1) { $participar = "<img class='botao_comunidade' src='" . $CFG->wwwroot . ImageResources::COMUNIDADE_FECHADA . "'>"; } } Commons::printListHomeCommunity($community, $participar, $fechada); } echo '<div>'; } else {
$communutyUser = new stdClass(); $communutyUser->community = $idCommunity; $communutyUser->userid = $USER->id; $msg = get_string('msgErroParticiparComunidade', 'block_webgd_community') . $community->name; if ($DB->insert_record(TableResouces::$TABLE_PAGE_COMMUNITY_USER, $communutyUser, true)) { $msg = get_string('msgParticiparComunidade', 'block_webgd_community') . $community->name; } redirect($url, $msg, 10); } elseif ($confirm == 2) { $DB->execute("DELETE FROM {$CFG->prefix}" . TableResouces::$TABLE_PAGE_COMMUNITY_USER . " WHERE community = {$community->id} AND userid = {$USER->id}"); redirect($url, get_string('msgSairDaComunidade', 'block_webgd_community') . $community->name, 10); } else { $value = 1; $comunidadeImg = $CFG->wwwroot . ImageResources::PARTICIPAR_COMUNIDADE; $comunidadeSair = $CFG->wwwroot . ImageResources::SAIR_COMUNIDADE; if ($webgdDao->findUserInCommunityById($idCommunity, $USER->id)) { $value = 2; echo '<div class="btn-group" style="float:right"> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> ... </button> <ul class="dropdown-menu">'; if ($USER->id == $community->userid) { echo '<li><a href="' . $CFG->wwwroot . '/blocks/webgd_community/module.php?community=' . $idCommunity . '" >' . get_string('editarComunidade', 'block_webgd_community') . '</a></li>'; } echo '<li><a href="#" onClick="open_participantes()">' . get_string('mostrarMembros', 'block_webgd_community') . '</a></li> <li><a href="https://mail.google.com/mail/?view=cm&fs=1&to=' . $emaillist . '" target="_wblank">' . get_string('enviarEmail', 'block_webgd_community') . '</a></li>' . '<li>' . '<span class="titulo_list">' . html_writer::tag('a', "<img class='botao_comunidade' src='" . $comunidadeSair . "' alt='" . get_string('sair', 'block_webgd_community') . "'>", array('onClick' => 'return confirm("Tem certeza que deseja sair da comunidade?");', 'title' => get_string('sair', 'block_webgd_community'), 'class' => 'participar', 'href' => "view.php?community={$community->id}&confirm=2")) . '</span><div style="clear:both"></div>' . '</li>'; '<li role="separator" class="divider"></li>'; echo '<div id="modal_participantes"> <div class="modal_header"><span>Participantes</span></div> <div class="modal_content"> <ul>'; foreach ($communityParticipants as $participant => $pt) {