diff --git a/components/ILIAS/Mail/classes/class.ilAccountMail.php b/components/ILIAS/Mail/classes/class.ilAccountMail.php index 21c9bad0776c..c0fc6f57141f 100755 --- a/components/ILIAS/Mail/classes/class.ilAccountMail.php +++ b/components/ILIAS/Mail/classes/class.ilAccountMail.php @@ -171,7 +171,7 @@ public function send(): bool } else { $attachment = $amail->getAttachment($this->irss); if ($attachment !== null) { - $mmail->Attach($attachment[0], '', 'attachment', $attachment[1]); + $mmail->Attach($attachment->getPath(), '', 'attachment', $attachment->getFilename()); } // replace placeholders diff --git a/components/ILIAS/User/src/Settings/Administration/class.SettingsGUI.php b/components/ILIAS/User/src/Settings/Administration/class.SettingsGUI.php index cce4031aa827..db8fb8ba4f03 100644 --- a/components/ILIAS/User/src/Settings/Administration/class.SettingsGUI.php +++ b/components/ILIAS/User/src/Settings/Administration/class.SettingsGUI.php @@ -28,7 +28,7 @@ use ILIAS\UI\Component\Input\Container\Form\Standard as StandardForm; use ILIAS\UI\Component\Input\Field\Section; use ILIAS\Refinery\Factory as Refinery; -use ILIAS\Refinery\Custom\Constraint; +use ILIAS\Refinery\Constraint; use ILIAS\Refinery\Transformation; use ILIAS\Authentication\Password\LocalUserPasswordManager; use Psr\Http\Message\ServerRequestInterface; diff --git a/components/ILIAS/User/src/Settings/ConfigurationRepository.php b/components/ILIAS/User/src/Settings/ConfigurationRepository.php index 56442d575445..1d7a73484fad 100644 --- a/components/ILIAS/User/src/Settings/ConfigurationRepository.php +++ b/components/ILIAS/User/src/Settings/ConfigurationRepository.php @@ -23,7 +23,7 @@ interface ConfigurationRepository { /** - * @return array<\ILIAS\User\Settings\Setting> + * @return list */ public function get(): array; public function getByIdentifier(string $identifier): ?Setting; diff --git a/components/ILIAS/User/src/Settings/DataRepository.php b/components/ILIAS/User/src/Settings/DataRepository.php index 23da1ee94a39..557ce335ade6 100644 --- a/components/ILIAS/User/src/Settings/DataRepository.php +++ b/components/ILIAS/User/src/Settings/DataRepository.php @@ -22,6 +22,9 @@ interface DataRepository { + /** + * @return array + */ public function getFor(int $user_id): array; public function deleteFor(int $user_id): void; public function deleteSingleFor(int $user_id, string $key): void; diff --git a/components/ILIAS/User/src/Settings/DatabaseDataRepository.php b/components/ILIAS/User/src/Settings/DatabaseDataRepository.php index f5e2cf66804c..8ef62ceaf5ba 100644 --- a/components/ILIAS/User/src/Settings/DatabaseDataRepository.php +++ b/components/ILIAS/User/src/Settings/DatabaseDataRepository.php @@ -32,7 +32,7 @@ public function getFor(int $user_id): array { $query = $this->db->queryF( 'SELECT * FROM ' . self::TABLE_NAME . ' WHERE usr_id = %s', - ['integer'], + [\ilDBConstants::T_INTEGER], [$user_id] ); diff --git a/components/ILIAS/User/src/Settings/NewAccountMail/Mail.php b/components/ILIAS/User/src/Settings/NewAccountMail/Mail.php index 5d88cf6c177a..7d5ab877d531 100644 --- a/components/ILIAS/User/src/Settings/NewAccountMail/Mail.php +++ b/components/ILIAS/User/src/Settings/NewAccountMail/Mail.php @@ -30,5 +30,5 @@ public function getBody(): string; public function getSalutationNoneSpecific(): string; public function getSalutationMale(): string; public function getSalutationFemale(): string; - public function getAttachment(ResourceStorage $irss): ?array; + public function getAttachment(ResourceStorage $irss): ?MailAttachment; } diff --git a/components/ILIAS/User/src/Settings/NewAccountMail/MailAttachment.php b/components/ILIAS/User/src/Settings/NewAccountMail/MailAttachment.php new file mode 100644 index 000000000000..7677a4b2440a --- /dev/null +++ b/components/ILIAS/User/src/Settings/NewAccountMail/MailAttachment.php @@ -0,0 +1,40 @@ +path; + } + + public function getFilename(): string + { + return $this->filename; + } +} diff --git a/components/ILIAS/User/src/Settings/NewAccountMail/MailImplementation.php b/components/ILIAS/User/src/Settings/NewAccountMail/MailImplementation.php index 41560cba23a8..295a182a77dc 100644 --- a/components/ILIAS/User/src/Settings/NewAccountMail/MailImplementation.php +++ b/components/ILIAS/User/src/Settings/NewAccountMail/MailImplementation.php @@ -74,7 +74,7 @@ public function getAttachmentRid(): ?string return $this->attachment_rid; } - public function getAttachment(ResourceStorage $irss): ?array + public function getAttachment(ResourceStorage $irss): ?MailAttachment { if ($this->attachment_rid !== null) { $rid = $irss->manage()->find($this->attachment_rid); @@ -82,10 +82,10 @@ public function getAttachment(ResourceStorage $irss): ?array return null; } $this->ensureAttachmentFileExists($irss, $rid); - return [ + return new MailAttachment( $this->temp_file_path . $this->lang_code, $irss->manage()->getCurrentRevision($rid)->getTitle() - ]; + ); } if ($this->legacy_attachment_filename !== null) { @@ -100,7 +100,7 @@ public function getAttachment(ResourceStorage $irss): ?array ) ); - return [$path, $this->legacy_attachment_filename]; + return new MailAttachment($path, $this->legacy_attachment_filename); } return null; @@ -113,6 +113,9 @@ public function deleteAttachmentTempFile(): void } } + /** + * @return array + */ public function toStorage(): array { return [ diff --git a/components/ILIAS/User/src/Settings/Setting.php b/components/ILIAS/User/src/Settings/Setting.php index d2d46356ba23..f69b8894cb49 100644 --- a/components/ILIAS/User/src/Settings/Setting.php +++ b/components/ILIAS/User/src/Settings/Setting.php @@ -116,6 +116,9 @@ public function getLegacyInput( return $input; } + /** + * @return array + */ public function getForm( Language $lng, FieldFactory $ff, @@ -166,7 +169,7 @@ public function persistUserInput( ?\ilPropertyFormGUI $form = null ): \ilObjUser { if (!$context->isSettingAvailable($this)) { - throw \Exception('It is not possible to Change this from here!'); + throw new \DomainException('It is not possible to Change this from here!'); } return $this->definition->persistUserInput($user, $input, $form); } diff --git a/components/ILIAS/User/src/Settings/SettingsImplementation.php b/components/ILIAS/User/src/Settings/SettingsImplementation.php index 57671cbcc14a..d283a6faef2c 100644 --- a/components/ILIAS/User/src/Settings/SettingsImplementation.php +++ b/components/ILIAS/User/src/Settings/SettingsImplementation.php @@ -38,7 +38,8 @@ public function __construct( } /** - * @param array $pages + * @param array $pages + * @return array */ public function buildFormInputs( array $pages, @@ -84,7 +85,7 @@ function (array $c, array $v) use ($pages, $context, $user): array { } /** - * @param array $pages + * @param array $pages */ public function addSectionsToLegacyForm( \ilPropertyFormGUI $form, @@ -117,7 +118,7 @@ public function performAdditionalChecks( * If it is possible to set the preference on the user, this is what will be * done, the user needs to be updated/stored after calling this function. * - * @param array $pages + * @param array $pages */ public function saveForm( \ilPropertyFormGUI|array $form, @@ -183,17 +184,20 @@ public function getSettingValueFor(int $user_id, string $key): ?string return $this->user_settings_data_repository->getFor($user_id)[$key] ?? null; } + /** + * @return list + */ public function getExportableSettings(): array { $context = Context::Export; return array_filter( $this->user_settings_configuration_repository->get(), - fn(Setting $v): bool => $context->isSettingAvailable($v) + static fn(Setting $v): bool => $context->isSettingAvailable($v) ); } /** - * @param array $pages + * @param array $pages */ private function getSettingsForPagesBySections( array $pages @@ -353,7 +357,7 @@ private function filterSettingsInSectionForAvailability( ); } - private function retrieveValuefromInputs( + private function retrieveValueFromInputs( \ilPropertyFormGUI|array $form, Setting $setting ): mixed { diff --git a/components/ILIAS/User/src/Settings/StartingPoint/Repository.php b/components/ILIAS/User/src/Settings/StartingPoint/Repository.php index 5223ebf7ff58..06b62f6e7a26 100755 --- a/components/ILIAS/User/src/Settings/StartingPoint/Repository.php +++ b/components/ILIAS/User/src/Settings/StartingPoint/Repository.php @@ -166,7 +166,7 @@ private function getRolesWithStartingPoint(): array $roles = []; while ($sp = $this->db->fetchAssoc($res)) { - $options = unserialize($sp['rule_options']); + $options = unserialize($sp['rule_options'], ['allowed_classes' => false]); $roles[(int) $options['role_id']] = [ 'id' => (int) $sp['id'], @@ -182,6 +182,9 @@ private function getRolesWithStartingPoint(): array return $roles; } + /** + * @return list + */ public function getGlobalRolesWithoutStartingPoint(): array { $global_roles = $this->rbac_review->getGlobalRoles(); @@ -308,6 +311,10 @@ public function getMaxPosition(): int return $order_val; } + /** + * @param list> $a_items + * @return array> + */ public function reArrangePositions(array $a_items): array { $ord_const = 0; @@ -336,7 +343,10 @@ public function saveOrder(array $a_items): void } } - public function getPossibleStartingPoints(bool $force_all = false): array //checked + /** + * @return array + */ + public function getPossibleStartingPoints(bool $force_all = false): array { $all = []; diff --git a/components/ILIAS/User/src/Settings/StartingPoint/Setting.php b/components/ILIAS/User/src/Settings/StartingPoint/Setting.php index 82e26ab55184..23b7e21a51cb 100644 --- a/components/ILIAS/User/src/Settings/StartingPoint/Setting.php +++ b/components/ILIAS/User/src/Settings/StartingPoint/Setting.php @@ -256,6 +256,9 @@ function (array $v): bool { ); } + /** + * @return array{start: int, ref_id: int|null} + */ public function retrieveValueFromUser(\ilObjUser $user): array { return [ diff --git a/components/ILIAS/User/src/Settings/StartingPoint/class.SettingsGUI.php b/components/ILIAS/User/src/Settings/StartingPoint/class.SettingsGUI.php index afd5f5467793..e6a2785f6bb8 100755 --- a/components/ILIAS/User/src/Settings/StartingPoint/class.SettingsGUI.php +++ b/components/ILIAS/User/src/Settings/StartingPoint/class.SettingsGUI.php @@ -44,12 +44,13 @@ class SettingsGUI private Renderer $ui_renderer; private UserGUIRequest $user_request; private Repository $starting_point_repository; + private \ilErrorHandling $error; private int $parent_ref_id; public function __construct(int $a_parent_ref_id) { - /** @var ILIAS\DI\Container $DIC */ + /** @var \ILIAS\DI\Container $DIC */ global $DIC; $this->log = \ilLoggerFactory::getLogger("user"); @@ -62,6 +63,7 @@ public function __construct(int $a_parent_ref_id) $this->tree = $DIC['tree']; $this->user = $DIC['ilUser']; $this->db = $DIC['ilDB']; + $this->error = $DIC['ilErr']; $this->rbac_review = $DIC['rbacreview']; $this->rbac_system = $DIC['rbacsystem']; $this->ui_factory = $DIC['ui.factory']; diff --git a/components/ILIAS/User/src/Settings/UserSettings.php b/components/ILIAS/User/src/Settings/UserSettings.php index 230841a45e27..797c427e918d 100644 --- a/components/ILIAS/User/src/Settings/UserSettings.php +++ b/components/ILIAS/User/src/Settings/UserSettings.php @@ -25,7 +25,7 @@ interface UserSettings /** * Return all User Settings provided by the component * - * @return array + * @return list> */ public function getSettingConfigurations(): array; }