* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require_once dirname(__FILE__) . '/../../config.php'; require_once $CFG->libdir . '/adminlib.php'; require_once $CFG->dirroot . '/blocks/webgd_community/form/ModuleForm.php'; require_once $CFG->dirroot . '/blocks/webgd_community/commons/TableResouces.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(''); echo $OUTPUT->heading(get_string('adicionarComunidade', 'block_webgd_community')); $mform = new ModuleForm(); if ($data = $mform->get_data()) { $realfilename = $mform->get_new_filename('file'); // 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 $communuty = new stdClass(); $communuty->name = $data->nome; $communuty->close_community = $data->close_community; $communuty->description = $data->conteudo['text']; $communuty->userid = $USER->id; $communuty->timecreated = time(); $msg = get_string('msgErroComunidadeEdicao', 'block_webgd_community'); try {
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)) { $msg = 'Comunidade editada com sucesso'; $communityParticipants = $webgdDao->findCommunityParticipantsById($data->id); foreach ($communityParticipants as $participantes => $pt) { if ($pt->id != $USER->id) {