From e79c49801770e63c1922bc47ec834902cefd3906 Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Tue, 12 Dec 2017 13:56:04 +0100 Subject: [PATCH] Minor - fix php warnings --- main/inc/lib/certificate.lib.php | 16 ++++++++++++---- main/mySpace/myStudents.php | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/main/inc/lib/certificate.lib.php b/main/inc/lib/certificate.lib.php index 6bf4d85d06..1dbd042df4 100755 --- a/main/inc/lib/certificate.lib.php +++ b/main/inc/lib/certificate.lib.php @@ -624,7 +624,11 @@ class Certificate extends Model $extraFieldValue = new ExtraFieldValue('user'); $value = $extraFieldValue->get_values_by_handler_and_field_variable($this->user_id, 'legal_accept'); - list($id, $id2, $termsValidationDate) = explode(':', $value['value']); + + $termsValidationDate = ''; + if (isset($value) && !empty($value['value'])) { + list($id, $id2, $termsValidationDate) = explode(':', $value['value']); + } $sessions = SessionManager::get_sessions_by_user($this->user_id); $sessionsApproved = []; @@ -672,7 +676,8 @@ class Certificate extends Model $skill = new Skill(); $skills = $skill->getStudentSkills($this->user_id); - $time = api_time_to_hms(Tracking::get_time_spent_on_the_platform($this->user_id)); + $timeInSeconds = Tracking::get_time_spent_on_the_platform($this->user_id); + $time = api_time_to_hms($timeInSeconds); $tplContent = new Template(null, false, false, false, false, false); @@ -680,10 +685,13 @@ class Certificate extends Model $tplContent->assign('complete_name', $userInfo['complete_name']); $tplContent->assign('time_in_platform', $time); $tplContent->assign('certificate_generated_date', api_get_local_time($myCertificate['created_at'])); - $tplContent->assign('terms_validation_date', api_get_local_time($termsValidationDate)); + if (!empty($termsValidationDate)) { + $termsValidationDate = api_get_local_time($termsValidationDate); + } + $tplContent->assign('terms_validation_date', $termsValidationDate); // Ofaj - $tplContent->assign('time_in_platform_in_hours', round($time/3600, 1)); + $tplContent->assign('time_in_platform_in_hours', round($timeInSeconds/3600, 1)); $tplContent->assign( 'certificate_generated_date_no_time', api_get_local_time( diff --git a/main/mySpace/myStudents.php b/main/mySpace/myStudents.php index d09d7f1409..d861978671 100755 --- a/main/mySpace/myStudents.php +++ b/main/mySpace/myStudents.php @@ -698,7 +698,7 @@ $userGroups = $userGroupManager->getNameListByUser( 'legal_accept' ); $icon = Display::return_icon('accept_na.png'); - if (isset($value['value'])) { + if (isset($value['value']) && !empty($value['value'])) { list($legalId, $legalLanguageId, $legalTime) = explode(':', $value['value']); $icon = Display::return_icon('accept.png').' '.api_get_local_time($legalTime); $icon .= ' '.Display::url(