public function definition() { global $CFG; $question = null; $mform = $this->_form; // Don't forget the underscore! $this->dateIntervalScript(); $this->questionScript(); $namePage = 'Cadastrar Enquete'; if ($this->_customdata['question']) { $namePage = 'Editar Enquete'; $webgdCommunityDao = new WebgdCommunityDao(); $question = $webgdCommunityDao->searchQuestionByCommunityById($this->_customdata['question']); } $mform->addElement('hidden', 'path_arquivos', $CFG->dataroot . '/blocks/webgd_community' . '/', array('id' => 'path_arquivos')); $mform->addElement('hidden', 'community', $this->_customdata['community']); $mform->addElement('text', 'nome', "Pergunta"); $mform->addRule('nome', get_string('labelValidacaoNome', 'block_webgd_community'), 'required', null, 'client'); $mform->addElement('text', 'from', 'Data Inicio', array("id" => "from")); $mform->addRule('from', null, 'required', null, 'client'); $mform->addElement('text', 'to', 'Data Fim', array("id" => "to")); $mform->addRule('to', null, 'required', null, 'client'); $options = array('1' => 'Sim', '0' => 'Não'); $mform->addElement('select', 'enable', 'Habilitado', $options); $mform->addElement('filepicker', 'attachmentQuestion', 'Pergunta em Libras', null, array('accepted_types' => '*')); $nameButton = 'Salvar'; $mform->addElement("html", "<div style='background: #f5f5f5; margin-bottom:-30px;'>"); $mform->addElement('file', 'attachmentAnswer', 'Respostas em Libras', null, array('accepted_types' => '*')); $mform->addElement('hidden', 'video', array("id" => "video_hidden")); $mform->addElement("html", "</div>"); $buttonarray = array(); $buttonarray[] =& $mform->createElement('text', 'pergunta', 'Adicionar Resposta', array("id" => "nome_pergunta")); $buttonarray[] =& $mform->createElement('button', 'bt_pergunta', 'Adicionar', array("id" => "bt_pergunta")); $mform->addGroup($buttonarray, 'buttonar', 'Adicionar Resposta', array(' '), false); if (!empty($question)) { $nameButton = 'Salvar'; $mform->setDefault("nome", $question->name); $mform->setDefault("from", date("d/m/Y", $question->startdate)); $mform->setDefault("to", date("d/m/Y", $question->enddate)); $mform->setDefault("enable", $question->enabled); $mform->addElement('hidden', 'question', $this->_customdata['question']); $answers = $webgdCommunityDao->searchAskQuestionByCommunityById($question->id); $mform->addElement("html", "<div id='perfuntas'>"); foreach ($answers as $dataAnswer) { $rand = rand(); $mform->addElement("html", "<div id=" . $rand . " >Resposta: " . $dataAnswer->name_question . " <a href='#' onclick=\"remover('" . $rand . "')\"><input type=\"hidden\" value='" . $dataAnswer->name_question . "' name=\"pergunta[]\"><input type=\"hidden\" value='" . $dataAnswer->video . "' name=\"video[]\"> remover</a><br></div>"); } $mform->addElement("html", "</div>"); } else { $mform->addElement("html", "<div id='perfuntas'></div>"); } $buttonarray = array(); $buttonarray[] =& $mform->createElement('submit', 'submitbutton', $nameButton); //$buttonarray[] = &$mform->createElement('reset', 'resetbutton', get_string('revert')); $buttonarray[] =& $mform->createElement('button', 'cancelar', 'Cancelar', 'onclick=location.href="' . $CFG->wwwroot . '/blocks/webgd_community/view.php?community=' . $this->_customdata['community'] . '"'); $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); $mform->closeHeaderBefore('buttonar'); }
<?php require_once dirname(__FILE__) . '/../../../../config.php'; require_once $CFG->dirroot . '/blocks/webgd_community/commons/TableResouces.php'; require_once $CFG->dirroot . '/blocks/webgd_community/lib/class/dao/WebgdCommunityDao.php'; global $USER; require_login(1); $PAGE->set_url('/course/index.php'); $PAGE->set_context(context_system::instance()); $PAGE->set_pagelayout('standard'); echo $OUTPUT->header('themeselector'); echo $OUTPUT->heading('Deletar Enquete'); $idQuestion = optional_param('question', 0, PARAM_INTEGER); $idCommunity = optional_param('community', 0, PARAM_INTEGER); $webgdCommunityDao = new WebgdCommunityDao(); $msg = 'Enquete não Encontrado'; if ($question = $webgdCommunityDao->searchQuestionByCommunityById($idQuestion)) { $msg = 'Erro ao excluir enquete'; if ($webgdCommunityDao->deleteQuestionByCommunityById($question->id, $USER->id, $question->post)) { $msg = 'Enquete deletada com sucesso'; } } redirect("{$CFG->wwwroot}/blocks/webgd_community/view.php?community={$idCommunity}", $msg, 10); echo $OUTPUT->footer();
<?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); $q = optional_param('q', 0, PARAM_INTEGER); $webgdCommunityDao = new WebgdCommunityDao(); if ($q) { $fileBd = $webgdCommunityDao->searchQuestionByCommunityById($idFile); $path = $fileBd->attachmentquestion; } else { $fileBd = $webgdCommunityDao->searchAnswerById($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]);