public function definition() { global $CFG, $DB, $USER; $mform = $this->_form; // Don't forget the underscore! $multiSelect = new MultiSelectHelper('users[]', 'users'); $webgdCommunityDao = new WebgdCommunityDao(); $mform->addElement('text', 'nome', get_string('labelNome', 'block_webgd_community')); $mform->addRule('nome', get_string('labelValidacaoNome', 'block_webgd_community'), 'required', null, 'client'); $mform->setType('nome', PARAM_TEXT); if ($this->_customdata['community']) { $mform->addElement('hidden', 'id', $this->_customdata['community']); $communityDao = $webgdCommunityDao->findCommunityById($this->_customdata['community']); $mform->setDefault('nome', $communityDao->name); //preciso ainda ler os dados da comunidade para inserir aqui quando for edição } else { $mform->addElement('hidden', 'id'); $mform->setType('id', PARAM_NOTAGS); } $formCheckbox = $mform->createElement('advcheckbox', 'close_community', 'Comunidade fechada', array('group' => 1), array(0, 1)); if ($this->_customdata['community']) { $communityDao = $webgdCommunityDao->findCommunityById($this->_customdata['community']); if ($communityDao->close_community == 1) { $formCheckbox->setChecked(true); } else { $formCheckbox->setChecked(false); } } else { $formCheckbox->setChecked(false); } $mform->addElement($formCheckbox); //$mform->addElement('advcheckbox', 'close_community', 'Comunidade fechada','' , array('group' => 1), array(0, 1)); $mform->addElement('filepicker', 'video', "Vídeo", null, array('accepted_types' => array('*'))); $records = $webgdCommunityDao->getListNameUser($USER->id); foreach ($records as $record) { $selected = false; if ($this->_customdata['community']) { if ($webgdCommunityDao->participanteInCommunity($record->id, $this->_customdata['community'])) { $selected = true; } } $multiSelect->addElement($record->firstname, $record->id, $selected); } $radioarray = array(); $radioarray[] =& $mform->createElement('html', ''); $radioarray[] =& $mform->createElement('html', ''); $mform->addGroup($radioarray, 'radioar', 'Participante', array(' '), false); $mform->addElement('html', $multiSelect->printMultiSelect()); $mform->addElement('textarea', 'conteudo', get_string('labelDescricao', 'block_webgd_community'), null); $mform->addHelpButton('conteudo', 'coursesummary'); $mform->setType('conteudo', PARAM_RAW); if ($this->_customdata['community']) { $mform->setDefault('conteudo', $communityDao->description); } $buttonarray = array(); $buttonarray[] =& $mform->createElement('submit', 'submitbutton', get_string('savechanges')); $buttonarray[] =& $mform->createElement('button', 'cancelar', get_string('cancelar', 'block_webgd_community'), 'onclick=location.href="' . $CFG->wwwroot . '/blocks/webgd_community/index.php"'); $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); $mform->closeHeaderBefore('buttonar'); }
<?php require_once dirname(__FILE__) . '/../../config.php'; require_once $CFG->dirroot . '/blocks/webgd_community/lib/class/dao/WebgdCommunityDao.php'; require_login(1); $idFile = optional_param('file', 0, PARAM_INTEGER); $webgdDao = new WebgdCommunityDao(); $fileBd = $webgdDao->findCommunityById($idFile); $path = $fileBd->video; $aux = explode('.', $path); $extensao = $aux[sizeof($aux) - 1]; $size = filesize($path); $fm = @fopen($path, 'rb'); if (!$fm) { // You can also redirect here header("HTTP/1.0 404 Not Found"); die; } $begin = 0; $end = $size; if (isset($_SERVER['HTTP_RANGE'])) { if (preg_match('/bytes=\\h*(\\d+)-(\\d*)[\\D.*]?/i', $_SERVER['HTTP_RANGE'], $matches)) { $begin = intval($matches[0]); if (!empty($matches[1])) { $end = intval($matches[1]); } } } if ($begin > 0 || $end < $size) { header('HTTP/1.0 206 Partial Content'); } else {
require_once $CFG->dirroot . '/blocks/webgd_community/form/GlossaryForm.php'; require_once $CFG->dirroot . '/blocks/webgd_community/commons/TableResouces.php'; require_once $CFG->dirroot . '/blocks/webgd_community/lib/class/dao/WebgdCommunityDao.php'; require_once $CFG->dirroot . '/blocks/webgd_community/lib/class/JsResources.php'; require_once $CFG->dirroot . '/blocks/webgd_community/lib/class/CssResources.php'; require_once $CFG->dirroot . '/blocks/webgd_community/lib/class/CssResources.php'; require_login(1); global $USER; $PAGE->requires->css(CssResources::HOME_COMMUNITY); $PAGE->set_url('/course/index.php'); $PAGE->set_context(context_system::instance()); $PAGE->set_pagelayout('standard'); $webgdCommunityDao = new WebgdCommunityDao(); $idCommunity = optional_param('community', 0, PARAM_INTEGER); $idGlossario = optional_param('glossario', 0, PARAM_INTEGER); $community = $webgdCommunityDao->findCommunityById($idCommunity); $url = $CFG->wwwroot . '/blocks/webgd_community/view.php?community=' . $idCommunity; echo $OUTPUT->header('themeselector'); if ($idGlossario) { $webgdCommunityDao = new WebgdCommunityDao(); if (!$webgdCommunityDao->searchGlossaryByCommunityById($idCommunity, $idGlossario, $USER->id)) { redirect("{$CFG->wwwroot}/blocks/webgd_community/view.php?community={$idCommunity}&option=8", 'Glossario não encontrado', 10); echo $OUTPUT->footer(); die; } else { echo $OUTPUT->heading('<span class="titulo_list">' . '<a href="' . $url . '" >' . $OUTPUT->heading($community->name, 2, 'titulo_comunidade') . '</a></span><br/>'); echo "<div class='subTitle'>Editar Termo</div><br/>"; } } else { echo $OUTPUT->heading('<span class="titulo_list">' . '<a href="' . $url . '" >' . $OUTPUT->heading($community->name, 2, 'titulo_comunidade') . '</a></span><br/>'); echo "<div class='subTitle'>Cadastrar Termo</div><br/>";
$PAGE->set_context(context_system::instance()); $PAGE->set_pagelayout('standard'); $PAGE->requires->css(CssResources::HOME_COMMUNITY); $idCommunity = optional_param('community', 0, PARAM_INTEGER); echo $OUTPUT->header(''); $mform = new ModuleForm(null, array('community' => $idCommunity)); if ($data = $mform->get_data()) { if ($data->id) { echo $OUTPUT->heading("Editar Comunidade"); } else { echo $OUTPUT->heading(get_string('adicionarComunidade', 'block_webgd_community')); } if ($data->id) { $msg = get_string('msgErro', 'block_webgd_community'); $webgdDao = new WebgdCommunityDao(); if ($communityDao = $webgdDao->findCommunityById($data->id)) { $communityDao->name = $data->nome; $communityDao->description = $data->conteudo; $communityDao->close_community = $data->close_community; $realfilename = $mform->get_new_filename('video'); // this gets the name of the file $random = rand(); // generate some random number $new_file = $random . '_' . $realfilename; //add some random string to the file $dst = $CFG->dataroot . "/blocks/webgd_community/{$new_file}"; // directory name+ new filename if ($mform->save_file('video', $dst, true)) { $communuty->video = $dst; } if ($id = $DB->update_record(TableResouces::$TABLE_PAGE_COMMUNITY, $communityDao)) {