예제 #1
0
        $has_access = $doc->is_accessible();
        if (!$has_access) {
            Response::not_found();
        }
        event_download(Uri::here());
        DocumentManager::file_send_for_download($doc);
        exit;
    }
}
/**
 * Several files requested. In this case we zip them together.
 */
$files = array();
$folders = array();
foreach ($ids as $id) {
    $doc = Document::get_by_id($course, $id);
    if (!$doc->is_accessible()) {
        break;
    }
    if ($doc->is_file()) {
        $files[] = $doc;
    }
    if ($doc->is_folder()) {
        $folders[] = $doc;
    }
}
$requested_folders = $folders;
/**
 * Note that if a parent folder is hidden children should not be accesible
 * even if they are visible. It is therefore not sufficient to check document
 * visibility.
예제 #2
0
    public function run()
    {
        if (!$this->accept()) {
            return false;
        }

        $course = Course::current();

        $pathes = Request::get('path');
        $pathes = is_array($pathes) ? $pathes : array($pathes);

        $ids = array();
        foreach ($pathes as $path) {
            $doc = Document::get_by_path($course, $path);
            if ($doc) {
                $ids[] = $doc->get_id();
            }
        }
        if (empty($ids)) {
            return false;
        }

        $user = new \Portfolio\User();
        $user->email = Chamilo::user()->email();

        $artefact = new Portfolio\Artefact();
        $artefact->url = Portfolio::download_url($ids);

        $portfolio = $this->get_portfolio();
        $result = $portfolio->send($user, $artefact);
        return $result;
    }