示例#1
0
    $webgdCommunityDao = new WebgdCommunityDao();
    if (!$webgdCommunityDao->searchIconeByCommunityByIdByUser($idCommunity, $idIcone, $USER->id)) {
        redirect("{$CFG->wwwroot}/blocks/webgd_community/view.php?community={$idCommunity}&option=2", 'icone não encontrado', 10);
        echo $OUTPUT->footer();
        die;
    } else {
        echo $OUTPUT->heading('Editar Icone');
    }
} else {
    echo $OUTPUT->heading('Cadastrar Icone');
}
$mform = new IconeForm(null, array('community' => $idCommunity, 'glossario' => $idIcone));
if ($data = $mform->get_data()) {
    $msg = "";
    if ($idIcone) {
        $glossary = $webgdCommunityDao->searchIconeByCommunityById($idIcone);
        $glossary->name = $data->nome;
        $glossary->url = $data->link;
        $msg = "Ocorreu um erro ao editar o icone";
        if ($DB->update_record(TableResouces::$TABLE_PAGE_COMMUNITY_LINKS, $glossary)) {
            $msg = "Icone editado com sucesso";
        }
    } else {
        try {
            $transaction = $DB->start_delegated_transaction();
            $post = new stdClass();
            $post->community = $data->community;
            $post->userid = $USER->id;
            $post->time = time();
            $post->type = 'icon';
            $idPost = $webgdDao->insertRecordInTableCommunityPost($post);
示例#2
0
<?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 Icone');
$idGlosario = optional_param('glossario', 0, PARAM_INTEGER);
$idCommunity = optional_param('community', 0, PARAM_INTEGER);
$webgdCommunityDao = new WebgdCommunityDao();
$msg = 'Icone não Encontrado';
if ($webgdCommunityDao->searchIconeByCommunityByIdByUser($idCommunity, $idGlosario, $USER->id)) {
    $icone = $webgdCommunityDao->searchIconeByCommunityById($idGlosario);
    $msg = 'Erro ao excluir icone';
    if ($webgdCommunityDao->deleteIconsByCommunityByIdByuser($icone->id, $USER->id, $icone->post)) {
        $msg = 'Icone deletado com sucesso';
    }
}
redirect("{$CFG->wwwroot}/blocks/webgd_community/view.php?community={$idCommunity}", $msg, 10);
echo $OUTPUT->footer();