Exemplo n.º 1
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 Foto');
$idFile = optional_param('file', 0, PARAM_INTEGER);
$idCommunity = optional_param('community', 0, PARAM_INTEGER);
$webgdCommunityDao = new WebgdCommunityDao();
$msg = 'Foto não encontrada';
if ($webgdCommunityDao->searchPhotoCommunityById($idCommunity, $idFile)) {
    $file = $webgdCommunityDao->searchPhotoById($idFile);
    if ($webgdCommunityDao->deletePhotoByCommunityByIdByuser($file->id, $USER->id, $file->post)) {
        $msg = 'Foto excluida com sucesso';
        unlink($file->path);
    }
}
redirect("{$CFG->wwwroot}/blocks/webgd_community/view.php?community={$idCommunity}", $msg, 10);
echo $OUTPUT->footer();
Exemplo n.º 2
0
<?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);
$webgdDao = new WebgdCommunityDao();
$fileBd = $webgdDao->searchPhotoById($idFile);
if ($fileBd) {
    $file = $fileBd->path;
    $aux = explode('.', $file);
    $extensao = $aux[sizeof($aux) - 1];
    header('Content-Type: image/' . $extensao);
    //header('Content-Disposition: attachment; filename="'.basename($file).'"');
    header('Content-Length: ' . filesize($file));
    readfile($file);
} else {
    echo 'Arquivo nao encontrado';
}
Exemplo n.º 3
0
        redirect("{$CFG->wwwroot}/blocks/webgd_community/view.php?community={$idCommunity}&option=6", 'Foto 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 Foto</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 Foto</div><br/>";
}
$mform = new CadastrarArquivoForm(null, array('community' => $idCommunity, 'file' => $idFile));
if ($data = $mform->get_data()) {
    if ($idFile) {
        $msg = get_string('msgErro', 'block_webgd_community');
        if ($arquivo = $webgdCommunityDao->searchPhotoById($idFile)) {
            $arquivo->name = $data->nome;
            if ($id = $DB->update_record(TableResouces::$TABLE_PAGE_COMMUNITY_MEDIA, $arquivo)) {
                $msg = 'Foto editado com sucesso';
            }
        }
    } else {
        $name = $mform->get_new_filename('attachment');
        $random = rand();
        $name = $random . '_' . $name;
        $path = "{$CFG->dataroot}/webgd_community/{$name}";
        $msg = get_string('msgErro', 'block_webgd_community');
        if ($mform->save_file('attachment', $path, true)) {
            try {
                $transaction = $DB->start_delegated_transaction();
                $post = new stdClass();