public function definition() { global $CFG; $question = null; $mform = $this->_form; // Don't forget the underscore! $namePage = 'Cadastrar Mapa Mental'; $nameButton = 'Salvar'; if ($this->_customdata['map']) { $namePage = 'Editar Mapa Mental'; $nameButton = 'Editar'; } $mform->addElement('hidden', 'community', $this->_customdata['community']); $mform->addElement('text', 'nome', get_string('labelNome', 'block_webgd_community')); $mform->addRule('nome', get_string('labelValidacaoNome', 'block_webgd_community'), 'required', null, 'client'); $mform->addElement('text', 'link', 'Url do link (com http://)'); $mform->addRule('link', 'Campo em branco', 'required', null, 'client'); if ($this->_customdata['map']) { $webgdCommunityDao = new WebgdCommunityDao(); $map = $webgdCommunityDao->searchMentalMapByCommunityById($this->_customdata['community'], $this->_customdata['map']); $mform->setDefault('nome', $map->name); $mform->setDefault('link', $map->url); $mform->addElement('hidden', 'map', $this->_customdata['map']); } $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 Mapa mental'); $idQuestion = optional_param('map', 0, PARAM_INTEGER); $idCommunity = optional_param('community', 0, PARAM_INTEGER); $webgdCommunityDao = new WebgdCommunityDao(); $msg = 'Mapa mental não Encontrado'; if ($webgdCommunityDao->searchMentalMapByCommunityByIdByUser($idCommunity, $idQuestion, $USER->id)) { $map = $webgdCommunityDao->searchMentalMapByCommunityById($idQuestion); $msg = 'Erro ao excluir mapa mental'; if ($webgdCommunityDao->deleteMentalMapByCommunityByIdByuser($map->id, $USER->id, $map->post)) { $msg = 'Mapa mental deletado com sucesso'; } } redirect("{$CFG->wwwroot}/blocks/webgd_community/view.php?community={$idCommunity}&suboption=1", $msg, 10); echo $OUTPUT->footer();
redirect("{$CFG->wwwroot}/blocks/webgd_community/view.php?community={$idCommunity}&option=2&suboption=1", 'Mapa mental 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 Mapa mental</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 Atividade</div><br/>"; } $mform = new MapForm(null, array('community' => $idCommunity, 'map' => $idMap)); if ($data = $mform->get_data()) { $msg = ""; if ($idMap) { $map = $webgdCommunityDao->searchMentalMapByCommunityById($idMap); $map->name = $data->nome; $map->url = $data->link; $msg = "Ocorreu um erro ao editar o link"; if ($DB->update_record(TableResouces::$TABLE_PAGE_COMMUNITY_LINKS, $map)) { $msg = "Link editado com sucesso"; } } else { try { $transaction = $DB->start_delegated_transaction(); $post = new stdClass(); $post->community = $idCommunity; $post->userid = $USER->id; $post->time = time(); $post->type = 'map'; $idPost = $webgdDao->insertRecordInTableCommunityPost($post);