From 7508b66e6738d089a07a0b3cbe6072d818d6ad09 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Wed, 24 May 2023 10:35:06 -0500 Subject: [PATCH] Minor: Format code --- main/course_info/infocours.php | 2 - main/inc/lib/banner.lib.php | 2 +- main/inc/lib/course.lib.php | 206 +++++++++++++++--------------- main/inc/lib/exercise.lib.php | 1 - main/inc/lib/template.lib.php | 1 - main/inc/lib/webservices/Rest.php | 10 +- main/wiki/wiki.inc.php | 1 - 7 files changed, 110 insertions(+), 113 deletions(-) diff --git a/main/course_info/infocours.php b/main/course_info/infocours.php index dd74013beb..97c5c4a485 100755 --- a/main/course_info/infocours.php +++ b/main/course_info/infocours.php @@ -174,7 +174,6 @@ $form->addRule( ); $form->addElement('checkbox', 'delete_picture', null, get_lang('DeletePicture')); - // Email Picture $form->addFile( 'email_picture', @@ -191,7 +190,6 @@ $form->addRule( ); $form->addElement('checkbox', 'delete_email_picture', null, get_lang('DeleteEmailPicture')); - if (api_get_setting('pdf_export_watermark_by_course') === 'true') { $url = PDF::get_watermark($course_code); $form->addText('pdf_export_watermark_text', get_lang('PDFExportWatermarkTextTitle'), false, ['size' => '60']); diff --git a/main/inc/lib/banner.lib.php b/main/inc/lib/banner.lib.php index 500603e62f..bf1cad05de 100755 --- a/main/inc/lib/banner.lib.php +++ b/main/inc/lib/banner.lib.php @@ -226,7 +226,7 @@ function return_logo($theme = '', $responsive = true) [ 'title' => $course['name'], 'class' => $class, - 'id' => 'header-logo', + 'id' => 'header-logo', ] ); diff --git a/main/inc/lib/course.lib.php b/main/inc/lib/course.lib.php index bba643b106..a73328ab80 100755 --- a/main/inc/lib/course.lib.php +++ b/main/inc/lib/course.lib.php @@ -7325,6 +7325,108 @@ class CourseManager return $coursesCode; } + /** + * Update course email picture. + * + * @param string $sourceFile the full system name of the image from which course picture will be created + * @param string $cropParameters Optional string that contents "x,y,width,height" of a cropped image format + * + * @return bool Returns the resulting. In case of internal error or negative validation returns FALSE. + */ + public static function updateCourseEmailPicture( + array $courseInfo, + string $sourceFile = null, + string $cropParameters = null + ): bool { + if (empty($courseInfo)) { + return false; + } + + // Course path + $store_path = api_get_path(SYS_COURSE_PATH).$courseInfo['path']; + // Image name for courses + $course_image = $store_path.'/course-email-pic.png'; + $course_medium_image = $store_path.'/course-email-pic-cropped.png'; + + if (file_exists($course_image)) { + unlink($course_image); + } + if (file_exists($course_medium_image)) { + unlink($course_medium_image); + } + + //Crop the image to adjust 4:3 ratio + $image = new Image($sourceFile); + $image->crop($cropParameters); + + //Resize the images in two formats + $medium = new Image($sourceFile); + $medium->resize(85); + $medium->send_image($course_medium_image, -1, 'png'); + $normal = new Image($sourceFile); + $normal->resize(250); + $normal->send_image($course_image, -1, 'png'); + + return $medium && $normal; //if both ops were ok, return true, otherwise false + } + + /** + * Deletes the course email picture. + */ + public static function deleteCourseEmailPicture(string $courseCode): void + { + $course_info = api_get_course_info($courseCode); + // course path + $storePath = api_get_path(SYS_COURSE_PATH).$course_info['path']; + // image name for courses + $courseImage = $storePath.'/course-email-pic.png'; + $courseMediumImage = $storePath.'/course-email-pic-cropped.png'; + + if (file_exists($courseImage)) { + unlink($courseImage); + } + if (file_exists($courseMediumImage)) { + unlink($courseMediumImage); + } + } + + /** + * Get the course logo. + * + * @param array $course array containing course info, @see api_get_course_info() + * @param array $attributes Array containing extra attributes for the image tag + * + * @return string|null + */ + public static function getCourseEmailPicture($course, $attributes = null) + { + $logo = null; + if (!empty($course) + && !empty($course['course_email_image_large_source']) + && file_exists($course['course_email_image_large_source']) + ) { + if (is_null($attributes)) { + $attributes = [ + 'title' => $course['name'], + 'class' => 'img-responsive', + 'id' => 'header-logo', + 'width' => 250, + ]; + } + + $logo = \Display::url( + \Display::img( + $course['course_email_image_large'], + $course['name'], + $attributes + ), + api_get_path(WEB_PATH).'index.php' + ); + } + + return $logo; + } + /** * Check if a specific access-url-related setting is a problem or not. * @@ -7403,108 +7505,4 @@ class CourseManager $courseFieldValue = new ExtraFieldValue('course'); $courseFieldValue->saveFieldValues($params); } - /** - * Update course email picture. - * - * @param array $courseInfo - * @param string $sourceFile the full system name of the image from which course picture will be created - * @param string $cropParameters Optional string that contents "x,y,width,height" of a cropped image format - * - * @return bool Returns the resulting. In case of internal error or negative validation returns FALSE. - */ - public static function updateCourseEmailPicture( - array $courseInfo, - string $sourceFile = null, - string $cropParameters = null - ): bool { - if (empty($courseInfo)) { - return false; - } - - // Course path - $store_path = api_get_path(SYS_COURSE_PATH).$courseInfo['path']; - // Image name for courses - $course_image = $store_path.'/course-email-pic.png'; - $course_medium_image = $store_path.'/course-email-pic-cropped.png'; - - if (file_exists($course_image)) { - unlink($course_image); - } - if (file_exists($course_medium_image)) { - unlink($course_medium_image); - } - - //Crop the image to adjust 4:3 ratio - $image = new Image($sourceFile); - $image->crop($cropParameters); - - //Resize the images in two formats - $medium = new Image($sourceFile); - $medium->resize(85); - $medium->send_image($course_medium_image, -1, 'png'); - $normal = new Image($sourceFile); - $normal->resize(250); - $normal->send_image($course_image, -1, 'png'); - - return $medium && $normal; //if both ops were ok, return true, otherwise false - } - - /** - * Deletes the course email picture. - * - * @param string $courseCode - */ - public static function deleteCourseEmailPicture(string $courseCode): void - { - $course_info = api_get_course_info($courseCode); - // course path - $storePath = api_get_path(SYS_COURSE_PATH).$course_info['path']; - // image name for courses - $courseImage = $storePath.'/course-email-pic.png'; - $courseMediumImage = $storePath.'/course-email-pic-cropped.png'; - - if (file_exists($courseImage)) { - unlink($courseImage); - } - if (file_exists($courseMediumImage)) { - unlink($courseMediumImage); - } - } - - /** - * Get the course logo - * - * @param array $course array containing course info, @see api_get_course_info() - * @param array $attributes Array containing extra attributes for the image tag - * - * @return string|null - */ - public static function getCourseEmailPicture($course, $attributes = null) - { - $logo = null; - if (!empty($course) - && !empty($course['course_email_image_large_source']) - && file_exists($course['course_email_image_large_source']) - ) { - if (is_null($attributes)) { - $attributes = [ - 'title' => $course['name'], - 'class' => 'img-responsive', - 'id' => 'header-logo', - 'width' => 250, - ]; - } - - $logo = \Display::url( - \Display::img( - $course['course_email_image_large'], - $course['name'], - $attributes - ), - api_get_path(WEB_PATH) . 'index.php' - ); - } - - return $logo; - } } diff --git a/main/inc/lib/exercise.lib.php b/main/inc/lib/exercise.lib.php index f23764c3c7..b18445ce2b 100644 --- a/main/inc/lib/exercise.lib.php +++ b/main/inc/lib/exercise.lib.php @@ -7055,7 +7055,6 @@ EOT; continue; } - api_mail_html( null, $email, diff --git a/main/inc/lib/template.lib.php b/main/inc/lib/template.lib.php index 00195fa2fe..2f3a86ac56 100755 --- a/main/inc/lib/template.lib.php +++ b/main/inc/lib/template.lib.php @@ -2075,7 +2075,6 @@ class Template $portalImageMeta .= ''."\n"; } } else { - if (api_get_configuration_value('mail_header_from_custom_course_logo') == true) { // check if current page is a course page $courseId = api_get_course_int_id(); diff --git a/main/inc/lib/webservices/Rest.php b/main/inc/lib/webservices/Rest.php index 39ccf80707..95846c24db 100644 --- a/main/inc/lib/webservices/Rest.php +++ b/main/inc/lib/webservices/Rest.php @@ -1156,9 +1156,11 @@ class Rest extends WebService /** * Get the list of users from extra field. - * @param string $fieldName The name of the extra_field (as in extra_field.variable) we want to filter on. + * + * @param string $fieldName The name of the extra_field (as in extra_field.variable) we want to filter on. * @param string $fieldValue The value of the extra_field we want to filter on. If a user doesn't have the given extra_field set to that value, it will not be returned. - * @param int $active Additional filter. If 1, only return active users. Otherwise, return them all. + * @param int $active Additional filter. If 1, only return active users. Otherwise, return them all. + * * @throws Exception */ public function getUsersProfilesByExtraField(string $fieldName, string $fieldValue, int $active = 0): array @@ -1585,8 +1587,10 @@ class Rest extends WebService } /** - * Returns an array of users with id, firstname, lastname, email and username + * Returns an array of users with id, firstname, lastname, email and username. + * * @param array $params An array of parameters to filter the results (currently only supports 'status' and 'id_campus') + * * @throws Exception */ public function getUsersCampus(array $params): array diff --git a/main/wiki/wiki.inc.php b/main/wiki/wiki.inc.php index 82fad96904..4de475f95e 100755 --- a/main/wiki/wiki.inc.php +++ b/main/wiki/wiki.inc.php @@ -2253,7 +2253,6 @@ class Wiki } ///make and send email if ($allow_send_mail) { - $extraParameters = []; if (api_get_configuration_value('mail_header_from_custom_course_logo') == true) { $extraParameters = ['logo' => CourseManager::getCourseEmailPicture($_course)];