Minor: Format code

pull/4656/head
Angel Fernando Quiroz Campos 3 years ago
parent f8d12645f7
commit b711d610ab
  1. 66
      plugin/oauth2/src/OAuth2.php
  2. 2
      src/Chamilo/CoreBundle/Component/Editor/Driver/CourseDriver.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 * Extends ArrayAccessorTrait::getValueByKey to return a list of values
* $key can contain wild card character * * $key can contain wild card character *
@ -472,37 +505,4 @@ class OAuth2 extends Plugin
error_log("OAuth2 plugin: $key: $content"); 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();
}
} }

@ -397,7 +397,7 @@ class CourseDriver extends Driver implements DriverInterface
return false; return false;
} }
$name= api_replace_dangerous_char($name); $name = api_replace_dangerous_char($name);
$result = parent::mkdir($path, $name); $result = parent::mkdir($path, $name);
if ($result && isset($result['hash'])) { if ($result && isset($result['hash'])) {

Loading…
Cancel
Save