예제 #1
0
 * Note this script enables key authentication so access with a key token is possible.
 *
 * @package chamilo.document
 * @license see /license.txt
 * @author Laurent Opprecht <*****@*****.**> for the Univesity of Geneva
 */
KeyAuth::enable();
require_once __DIR__ . '/../inc/global.inc.php';
$has_access = api_protect_course_script();
if (!$has_access) {
    exit;
}
session_cache_limiter('none');
$ids = Request::get('id', '');
$ids = $ids ? explode(',', $ids) : array();
$course = Course::current();
/**
 * No files requested. We make sure we return 404 error to tell the client
 * that the call failed.
 */
if (count($ids) == 0 || empty($course)) {
    Response::not_found();
}
/**
 * One file requested. In this case we return the file itself.
 */
if (count($ids) == 1) {
    $id = reset($ids);
    $doc = Document::get_by_id($course, $id);
    if (empty($doc)) {
        Response::not_found();
예제 #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;
    }