From b711d610ab060fed1c440174de3c635fac3d908b Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Wed, 22 Mar 2023 08:54:35 -0500 Subject: [PATCH] Minor: Format code --- plugin/oauth2/redirect_info.php | 2 +- plugin/oauth2/src/OAuth2.php | 66 +++++++++---------- .../Component/Editor/Driver/CourseDriver.php | 2 +- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/plugin/oauth2/redirect_info.php b/plugin/oauth2/redirect_info.php index 4518c6fa57..33e8efdb09 100644 --- a/plugin/oauth2/redirect_info.php +++ b/plugin/oauth2/redirect_info.php @@ -34,4 +34,4 @@ $content = '
$template = new Template(); $template->assign('content', $content); -$template->display_one_col_template(); \ No newline at end of file +$template->display_one_col_template(); diff --git a/plugin/oauth2/src/OAuth2.php b/plugin/oauth2/src/OAuth2.php index cbbf891b81..20e300f984 100644 --- a/plugin/oauth2/src/OAuth2.php +++ b/plugin/oauth2/src/OAuth2.php @@ -337,6 +337,39 @@ class OAuth2 extends Plugin ); } + public static function isFirstLoginAfterAuthSource(int $userId): bool + { + $em = Database::getManager(); + + $lastLogin = $em + ->getRepository(TrackELogin::class) + ->findOneBy( + ['loginUserId' => $userId], + ['loginDate' => 'DESC'] + ) + ; + + if (!$lastLogin) { + return false; + } + + $objExtraField = new ExtraField('user'); + $field = $objExtraField->getHandlerEntityByFieldVariable(self::EXTRA_FIELD_OAUTH2_ID); + + $fieldValue = $em + ->getRepository(ExtraFieldValues::class) + ->findOneBy( + ['itemId' => $userId, 'field' => $field] + ) + ; + + if (!$fieldValue) { + return false; + } + + return $fieldValue->getCreatedAt() >= $lastLogin->getLoginDate(); + } + /** * Extends ArrayAccessorTrait::getValueByKey to return a list of values * $key can contain wild card character * @@ -472,37 +505,4 @@ class OAuth2 extends Plugin error_log("OAuth2 plugin: $key: $content"); } } - - public static function isFirstLoginAfterAuthSource(int $userId): bool - { - $em = Database::getManager(); - - $lastLogin = $em - ->getRepository(TrackELogin::class) - ->findOneBy( - ['loginUserId' => $userId], - ['loginDate' => 'DESC'] - ) - ; - - if (!$lastLogin) { - return false; - } - - $objExtraField = new ExtraField('user'); - $field = $objExtraField->getHandlerEntityByFieldVariable(self::EXTRA_FIELD_OAUTH2_ID); - - $fieldValue = $em - ->getRepository(ExtraFieldValues::class) - ->findOneBy( - ['itemId' => $userId, 'field' => $field] - ) - ; - - if (!$fieldValue) { - return false; - } - - return $fieldValue->getCreatedAt() >= $lastLogin->getLoginDate(); - } } diff --git a/src/Chamilo/CoreBundle/Component/Editor/Driver/CourseDriver.php b/src/Chamilo/CoreBundle/Component/Editor/Driver/CourseDriver.php index f8026b8ddc..b71763d339 100644 --- a/src/Chamilo/CoreBundle/Component/Editor/Driver/CourseDriver.php +++ b/src/Chamilo/CoreBundle/Component/Editor/Driver/CourseDriver.php @@ -397,7 +397,7 @@ class CourseDriver extends Driver implements DriverInterface return false; } - $name= api_replace_dangerous_char($name); + $name = api_replace_dangerous_char($name); $result = parent::mkdir($path, $name); if ($result && isset($result['hash'])) {