Esempio n. 1
0
 function get_content()
 {
     global $USER, $CFG, $DB, $OUTPUT;
     if ($this->content !== NULL) {
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->text = '';
     $this->content->footer = '';
     if (empty($this->instance)) {
         return $this->content;
     }
     if ($USER->id) {
         $timetoshowusers = 500;
         //Seconds default
         $now = time();
         $timefrom = $now - 3600;
         // $timefrom = 100 * floor(($now - $timetoshowusers) / 100);
         $params = array();
         $userfields = user_picture::fields('u', array('username'));
         $params['now'] = $now;
         $params['timefrom'] = $timefrom;
         $params['id'] = $USER->id;
         $sql = "SELECT {$userfields}\n                          FROM {user} u\n                         WHERE u.lastaccess > :timefrom\n                               AND u.lastaccess <= :now\n                               AND u.deleted = 0\n                               AND u.id <> :id";
         if ($users = $DB->get_records_sql($sql, $params, 0, 50)) {
             foreach ($users as $user) {
                 $users[$user->id]->fullname = fullname($user);
             }
         } else {
             $users = array();
         }
         $this->content->text .= '<div id="contatos">';
         if (!empty($users)) {
             $this->content->text .= "<ul class='list'>\n";
             foreach ($users as $user) {
                 $this->content->text .= '<li class="listentry">';
                 $this->content->text .= '<div class="user">';
                 $this->content->text .= '<a href="javascript:void(0);"  id="' . $user->id . '" nome="' . $user->fullname . '" class="comecar">';
                 $this->content->text .= $OUTPUT->user_picture($user, array('size' => 16, 'alttext' => false, 'link' => false)) . $user->fullname . '</a></div>';
                 $this->content->text .= "</li>\n";
             }
             $this->content->text .= '</ul><div class="clearer"><!-- --></div>';
         } else {
             $this->content->text .= "<div class=\"info\">" . get_string("none") . "</div>";
         }
         $chatDao = new ChatWebgdDao();
         $listaGrupos = $chatDao->findGroupUser($USER->id);
         $this->content->text .= '<hr /><img src="' . $CFG->wwwroot . '/blocks/chat_webgd/pix/chat_grupo.png" width="40">&nbsp;&nbsp;' . get_string('meusGrupos', 'block_chat_webgd') . ' <a href="' . $CFG->wwwroot . '/blocks/chat_webgd/index.php" class="criar-grupo-chat"> + </a><ul class="list">';
         foreach ($listaGrupos as $grupo) {
             $this->content->text .= '<li class="listentry">';
             $this->content->text .= '<div class="user">';
             $this->content->text .= '<a href="javascript:void(0);" class="comecarGrupo" nome="' . $grupo->nome . '" id="' . $grupo->id . '_grupo">';
             $this->content->text .= $grupo->nome . '</a></div>';
             $this->content->text .= "</li>";
         }
         $this->content->text .= "</ul>";
         $this->content->text .= '</div>';
         $this->content->text .= '<script type="text/javascript" src="' . $CFG->wwwroot . '/blocks/chat_webgd/js/jquery.js"></script>
          <script type="text/javascript" src="' . $CFG->wwwroot . '/blocks/chat_webgd/js/functions.js"></script>
          <script type="text/javascript" src="' . $CFG->wwwroot . '/blocks/chat_webgd/js/chat.js"></script>
          <link href="' . $CFG->wwwroot . '/blocks/chat_webgd/styles.css" type="text/css" rel="stylesheet">';
     }
     return $this->content;
 }
Esempio n. 2
0
     $retorno = "<ul class='list'>\n";
     if (!empty($users)) {
         foreach ($users as $user) {
             $retorno .= '<li class="listentry">';
             $retorno .= '<div class="user">';
             $retorno .= '<a href="javascript:void(0);"  id="' . $user->id . '" nome="' . $user->fullname . '" class="comecar">';
             $retorno .= $OUTPUT->user_picture($user, array('size' => 16, 'alttext' => false, 'link' => false));
             $retorno .= $user->fullname . '</a></div>';
             $retorno .= "</li>\n";
         }
     } else {
         $retorno .= "<li class=\"info\">" . get_string("none") . "</li>";
     }
     $retorno .= "</ul><div class='clearer'><!-- --></div>";
     $chatDao = new ChatWebgdDao();
     $listaGrupos = $chatDao->findGroupUser($USER->id);
     $retorno .= '<hr /><img src="' . $CFG->wwwroot . '/blocks/chat_webgd/pix/chat_grupo.png" width="40">&nbsp;&nbsp;' . get_string('meusGrupos', 'block_chat_webgd') . ' <a href="' . $CFG->wwwroot . '/blocks/chat_webgd/index.php" class="criar-grupo-chat"> + </a><ul class="list">';
     foreach ($listaGrupos as $grupo) {
         $retorno .= '<li class="listentry">';
         $retorno .= '<div class="user">';
         $retorno .= '<a href="javascript:void(0);" class="comecarGrupo" nome="' . $grupo->nome . '" id="' . $grupo->id . '_grupo">';
         $retorno .= $grupo->nome . '</a></div>';
         $retorno .= "</li>";
     }
     $retorno .= "</ul>";
     $retorno .= '</div>';
     echo $retorno;
     break;
 case 'historico':
     $id = optional_param('id', 0, PARAM_INT);
     $mensagem = '';
Esempio n. 3
0
<?php

require_once dirname(__FILE__) . '../../../config.php';
require_once $CFG->libdir . '/adminlib.php';
require_once $CFG->dirroot . '/blocks/chat_webgd/form/ChatForm.php';
require_once $CFG->dirroot . '/blocks/chat_webgd/class/ChatWebgdDao.php';
global $CFG, $DB, $USER;
require_login(1);
echo $OUTPUT->header('themeselector');
echo $OUTPUT->heading(get_string('sairGrupo', 'block_chat_webgd'));
$chatDao = new ChatWebgdDao();
$id = optional_param('id', null, PARAM_INT);
$aux = explode("_", $id);
if (!$aux[0]) {
    $id = $aux;
} else {
    $id = $aux[0];
}
$grupo = $chatDao->findGroupUser($USER->id, $id);
if ($grupo) {
    if ($chatDao->desativarUsuario($id, $USER->id)) {
        echo get_string('voceSaiuGrupo', 'block_chat_webgd');
    } else {
        echo get_string('ErroAoEfetuarAcao', 'block_chat_webgd');
    }
} else {
    echo get_string('ErroGrupoNaoEncontrado', 'block_chat_webgd');
}
echo $OUTPUT->footer();