Beispiel #1
0
            }
            break;
    }
} else {
    //always give hub logo to anybody
    if ($filetype == HUB_HUBSCREENSHOT_FILE_TYPE) {
        $userdir = "hub/0";
        $filepath = $CFG->dataroot . '/' . $userdir . '/hublogo';
        $imageinfo = getimagesize($filepath, $info);
        //check if the screenshot exists in the requested size
        require_once $CFG->dirroot . "/repository/flickr_public/image.php";
        $newfilepath = $filepath . "_" . HUBLOGOIMAGEWIDTH . "x" . HUBLOGOIMAGEHEIGHT;
        if (!file_exists($newfilepath) or filemtime($filepath) > filemtime($newfilepath)) {
            $image = new moodle_image($filepath);
            //scale to the max width/height dimension
            $imagewidth = $imageinfo[0];
            $imageheight = $imageinfo[1];
            if ($imagewidth > HUBLOGOIMAGEWIDTH) {
                $imagewidth = $imagewidth / ($imagewidth / HUBLOGOIMAGEWIDTH);
                $imageheight = $imageheight / ($imagewidth / HUBLOGOIMAGEWIDTH);
            }
            if ($imageheight > HUBLOGOIMAGEHEIGHT) {
                $imageheight = $imageheight / ($imageheight / HUBLOGOIMAGEWIDTH);
                $imagewidth = $imagewidth / ($imageheight / HUBLOGOIMAGEWIDTH);
            }
            $image->resize($imagewidth, $imageheight);
            $image->saveas($newfilepath);
        }
        send_file($newfilepath, 'image', 'default', 0, false, true, $imageinfo['mime'], false);
    }
}