Minor: Format code

pull/4722/head
Angel Fernando Quiroz Campos 2 years ago
parent 8be357f593
commit 7508b66e67
  1. 2
      main/course_info/infocours.php
  2. 2
      main/inc/lib/banner.lib.php
  3. 206
      main/inc/lib/course.lib.php
  4. 1
      main/inc/lib/exercise.lib.php
  5. 1
      main/inc/lib/template.lib.php
  6. 10
      main/inc/lib/webservices/Rest.php
  7. 1
      main/wiki/wiki.inc.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']);

@ -226,7 +226,7 @@ function return_logo($theme = '', $responsive = true)
[
'title' => $course['name'],
'class' => $class,
'id' => 'header-logo',
'id' => 'header-logo',
]
);

@ -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;
}
}

@ -7055,7 +7055,6 @@ EOT;
continue;
}
api_mail_html(
null,
$email,

@ -2075,7 +2075,6 @@ class Template
$portalImageMeta .= '<meta property="twitter:image:alt" content="'.$imageAlt.'" />'."\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();

@ -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

@ -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)];

Loading…
Cancel
Save