$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); $map = new stdClass(); $map->post = $idPost; $map->name = $data->nome; $map->url = $data->link; $DB->insert_record(TableResouces::$TABLE_PAGE_COMMUNITY_LINKS, $map); $transaction->allow_commit(); $msg = "Link registrado com sucesso"; } catch (Exception $e) { $transaction->rollback($e); $msg = "Ocorreu um erro ao salvar o link"; } } redirect("{$CFG->wwwroot}/blocks/webgd_community/view.php?community={$idCommunity}&suboption=1", $msg, 10); } else { $mform->display(); } echo $OUTPUT->footer();