From: dhawes Date: Sun, 26 Sep 2004 04:57:07 +0000 (+0000) Subject: Converted comments to phpdoc style. Functions require additional documenting. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=99c253167160fe2826149fdbccfd039df7cef083;p=moodle.git Converted comments to phpdoc style. Functions require additional documenting. --- diff --git a/lib/gdlib.php b/lib/gdlib.php index 47f2a99e16..60dcf1d351 100644 --- a/lib/gdlib.php +++ b/lib/gdlib.php @@ -1,13 +1,38 @@ -gdversion >= 2) { + if (function_exists('ImageCopyResampled') and $CFG->gdversion >= 2) { return ImageCopyResampled($dst_img, $src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h); } @@ -46,9 +71,19 @@ function ImageCopyBicubic ($dst_img, $src_img, $dst_x, $dst_y, $src_x, $src_y, $ } } -function save_profile_image($id, $uploadmanager, $dir="users") { -// Given an upload manager with the right settings, this function performs a virus scan, and then scales and crops -// it and saves it in the right place to be a "user" or "group" image. +/** + * Given an upload manager with the right settings, this function performs a virus scan, and then scales and crops + * it and saves it in the right place to be a "user" or "group" image. + * + * @uses $CFG + * @param int $id description? + * @param object $uploadmanager description? + * @param string $dir description? + * @return boolean + * @todo Finish documenting this function + */ +function save_profile_image($id, $uploadmanager, $dir='users') { +// global $CFG; @@ -62,19 +97,19 @@ function save_profile_image($id, $uploadmanager, $dir="users") { umask(0000); - if (!file_exists("$CFG->dataroot/$dir")) { - if (! mkdir("$CFG->dataroot/$dir", $CFG->directorypermissions)) { + if (!file_exists($CFG->dataroot .'/'. $dir)) { + if (! mkdir($CFG->dataroot .'/'. $dir, $CFG->directorypermissions)) { return false; } } - if (!file_exists("$CFG->dataroot/$dir/$id")) { - if (! mkdir("$CFG->dataroot/$dir/$id", $CFG->directorypermissions)) { + if (!file_exists($CFG->dataroot .'/'. $dir .'/'. $id)) { + if (! mkdir($CFG->dataroot .'/'. $dir .'/'. $id, $CFG->directorypermissions)) { return false; } } - $destination = "$CFG->dataroot/$dir/$id"; + $destination = $CFG->dataroot .'/'. $dir .'/'. $id; if (!$uploadmanager->save_files($destination)) { return false; } @@ -94,28 +129,28 @@ function save_profile_image($id, $uploadmanager, $dir="users") { switch ($image->type) { case 1: - if (function_exists("ImageCreateFromGIF")) { + if (function_exists('ImageCreateFromGIF')) { $im = ImageCreateFromGIF($originalfile); } else { - notice("GIF not supported on this server"); + notice('GIF not supported on this server'); unlink($originalfile); return false; } break; case 2: - if (function_exists("ImageCreateFromJPEG")) { + if (function_exists('ImageCreateFromJPEG')) { $im = ImageCreateFromJPEG($originalfile); } else { - notice("JPEG not supported on this server"); + notice('JPEG not supported on this server'); unlink($originalfile); return false; } break; case 3: - if (function_exists("ImageCreateFromPNG")) { + if (function_exists('ImageCreateFromPNG')) { $im = ImageCreateFromPNG($originalfile); } else { - notice("PNG not supported on this server"); + notice('PNG not supported on this server'); unlink($originalfile); return false; } @@ -127,7 +162,7 @@ function save_profile_image($id, $uploadmanager, $dir="users") { unlink($originalfile); - if (function_exists("ImageCreateTrueColor") and $CFG->gdversion >= 2) { + if (function_exists('ImageCreateTrueColor') and $CFG->gdversion >= 2) { $im1 = ImageCreateTrueColor(100,100); $im2 = ImageCreateTrueColor(35,35); } else { @@ -159,10 +194,10 @@ function save_profile_image($id, $uploadmanager, $dir="users") { ImageLine ($im2, 34, 34, 34, 0, $black2); ImageLine ($im2, 34, 0, 0, 0, $black2); - if (ImageJpeg($im1, "$CFG->dataroot/$dir/$id/f1.jpg", 90) and - ImageJpeg($im2, "$CFG->dataroot/$dir/$id/f2.jpg", 95) ) { - @chmod("$CFG->dataroot/$dir/$id/f1.jpg", 0666); - @chmod("$CFG->dataroot/$dir/$id/f2.jpg", 0666); + if (ImageJpeg($im1, $CFG->dataroot .'/'. $dir .'/'. $id .'/f1.jpg', 90) and + ImageJpeg($im2, $CFG->dataroot .'/'. $dir .'/'. $id .'/f2.jpg', 95) ) { + @chmod($CFG->dataroot .'/'. $dir .'/'. $id .'/f1.jpg', 0666); + @chmod($CFG->dataroot .'/'. $dir .'/'. $id .'/f2.jpg', 0666); return 1; } else { return 0; @@ -170,4 +205,4 @@ function save_profile_image($id, $uploadmanager, $dir="users") { } -?> +?> \ No newline at end of file