From cd3ac55b195c8c20e49a5d46115a819c45f2f33f Mon Sep 17 00:00:00 2001 From: Moritz Strohm Date: Thu, 4 Jul 2024 11:25:13 +0200 Subject: renamed class --- lib/classes/LTI13a/Identity.class.php | 93 ----------------------------------- lib/classes/LTI13a/Identity.php | 93 +++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 93 deletions(-) delete mode 100644 lib/classes/LTI13a/Identity.class.php create mode 100644 lib/classes/LTI13a/Identity.php diff --git a/lib/classes/LTI13a/Identity.class.php b/lib/classes/LTI13a/Identity.class.php deleted file mode 100644 index 92435d8..0000000 --- a/lib/classes/LTI13a/Identity.class.php +++ /dev/null @@ -1,93 +0,0 @@ -user = $user; - - $privacy_settings = \LtiDeploymentPrivacySettings::findOneBySQL( - '`deployment_id` = :deployment_id AND `user_id` = :user_id', - ['deployment_id' => $deployment->id, 'user_id' => $user->id] - ); - if ($privacy_settings) { - $this->allowed_optional_fields = explode(',', $privacy_settings->allowed_optional_fields); - } - } - - #[\Override] public function getIdentifier(): string - { - return $this->user->id; - } - - #[\Override] public function getName(): ?string - { - return $this->user->getFullName(); - } - - #[\Override] public function getEmail(): ?string - { - return $this->user->email; - } - - #[\Override] public function getGivenName(): ?string - { - return $this->user->vorname; - } - - #[\Override] public function getFamilyName(): ?string - { - return $this->user->nachname; - } - - #[\Override] public function getMiddleName(): ?string - { - return ''; - } - - #[\Override] public function getLocale(): ?string - { - if (!in_array('lang', $this->allowed_optional_fields)) { - return ''; - } - return $this->user->preferred_language; - } - - #[\Override] public function getPicture(): ?string - { - if (!in_array('avatar_url', $this->allowed_optional_fields)) { - return ''; - } - return \Avatar::getAvatar($this->user->id)->getURL(\Avatar::MEDIUM); - } - - #[\Override] public function getAdditionalProperties(): CollectionInterface - { - return []; - } - - #[\Override] public function normalize(): array - { - return [ - MessagePayloadInterface::CLAIM_SUB => $this->getIdentifier(), - MessagePayloadInterface::CLAIM_USER_NAME => $this->getName(), - MessagePayloadInterface::CLAIM_USER_EMAIL => $this->getEmail(), - MessagePayloadInterface::CLAIM_USER_GIVEN_NAME => $this->getGivenName(), - MessagePayloadInterface::CLAIM_USER_FAMILY_NAME => $this->getFamilyName(), - MessagePayloadInterface::CLAIM_USER_MIDDLE_NAME => $this->getMiddleName(), - MessagePayloadInterface::CLAIM_USER_LOCALE => $this->getLocale(), - MessagePayloadInterface::CLAIM_USER_PICTURE => $this->getPicture() - ]; - } -} diff --git a/lib/classes/LTI13a/Identity.php b/lib/classes/LTI13a/Identity.php new file mode 100644 index 0000000..92435d8 --- /dev/null +++ b/lib/classes/LTI13a/Identity.php @@ -0,0 +1,93 @@ +user = $user; + + $privacy_settings = \LtiDeploymentPrivacySettings::findOneBySQL( + '`deployment_id` = :deployment_id AND `user_id` = :user_id', + ['deployment_id' => $deployment->id, 'user_id' => $user->id] + ); + if ($privacy_settings) { + $this->allowed_optional_fields = explode(',', $privacy_settings->allowed_optional_fields); + } + } + + #[\Override] public function getIdentifier(): string + { + return $this->user->id; + } + + #[\Override] public function getName(): ?string + { + return $this->user->getFullName(); + } + + #[\Override] public function getEmail(): ?string + { + return $this->user->email; + } + + #[\Override] public function getGivenName(): ?string + { + return $this->user->vorname; + } + + #[\Override] public function getFamilyName(): ?string + { + return $this->user->nachname; + } + + #[\Override] public function getMiddleName(): ?string + { + return ''; + } + + #[\Override] public function getLocale(): ?string + { + if (!in_array('lang', $this->allowed_optional_fields)) { + return ''; + } + return $this->user->preferred_language; + } + + #[\Override] public function getPicture(): ?string + { + if (!in_array('avatar_url', $this->allowed_optional_fields)) { + return ''; + } + return \Avatar::getAvatar($this->user->id)->getURL(\Avatar::MEDIUM); + } + + #[\Override] public function getAdditionalProperties(): CollectionInterface + { + return []; + } + + #[\Override] public function normalize(): array + { + return [ + MessagePayloadInterface::CLAIM_SUB => $this->getIdentifier(), + MessagePayloadInterface::CLAIM_USER_NAME => $this->getName(), + MessagePayloadInterface::CLAIM_USER_EMAIL => $this->getEmail(), + MessagePayloadInterface::CLAIM_USER_GIVEN_NAME => $this->getGivenName(), + MessagePayloadInterface::CLAIM_USER_FAMILY_NAME => $this->getFamilyName(), + MessagePayloadInterface::CLAIM_USER_MIDDLE_NAME => $this->getMiddleName(), + MessagePayloadInterface::CLAIM_USER_LOCALE => $this->getLocale(), + MessagePayloadInterface::CLAIM_USER_PICTURE => $this->getPicture() + ]; + } +} -- cgit v1.0