Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/ILIAS/Mail/classes/class.ilAccountMail.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
interface ConfigurationRepository
{
/**
* @return array<\ILIAS\User\Settings\Setting>
* @return list<Setting>
*/
public function get(): array;
public function getByIdentifier(string $identifier): ?Setting;
Expand Down
3 changes: 3 additions & 0 deletions components/ILIAS/User/src/Settings/DataRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@

interface DataRepository
{
/**
* @return array<string, string|null>
*/
public function getFor(int $user_id): array;
public function deleteFor(int $user_id): void;
public function deleteSingleFor(int $user_id, string $key): void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
);

Expand Down
2 changes: 1 addition & 1 deletion components/ILIAS/User/src/Settings/NewAccountMail/Mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
*
* ILIAS is licensed with the GPL-3.0,
* see https://www.gnu.org/licenses/gpl-3.0.en.html
* You should have received a copy of said license along with the
* source code, too.
*
* If this is not the case or you just want to try ILIAS, you'll find
* us at:
* https://www.ilias.de
* https://github.com/ILIAS-eLearning
*
*********************************************************************/

declare(strict_types=1);

namespace ILIAS\User\Settings\NewAccountMail;

final readonly class MailAttachment
{
public function __construct(
private string $path,
private string $filename
) {
}

public function getPath(): string
{
return $this->path;
}

public function getFilename(): string
{
return $this->filename;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,18 @@ 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);
if ($rid === null) {
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) {
Expand All @@ -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;
Expand All @@ -113,6 +113,9 @@ public function deleteAttachmentTempFile(): void
}
}

/**
* @return array<string, array{0: string, 1: mixed}>
*/
public function toStorage(): array
{
return [
Expand Down
5 changes: 4 additions & 1 deletion components/ILIAS/User/src/Settings/Setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ public function getLegacyInput(
return $input;
}

/**
* @return array<string, Input>
*/
public function getForm(
Language $lng,
FieldFactory $ff,
Expand Down Expand Up @@ -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);
}
Expand Down
16 changes: 10 additions & 6 deletions components/ILIAS/User/src/Settings/SettingsImplementation.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public function __construct(
}

/**
* @param array<ILIAS\User\Settings\AvailablePages> $pages
* @param array<AvailablePages> $pages
* @return array<string, \ILIAS\UI\Component\Input\Input>
*/
public function buildFormInputs(
array $pages,
Expand Down Expand Up @@ -84,7 +85,7 @@ function (array $c, array $v) use ($pages, $context, $user): array {
}

/**
* @param array<ILIAS\User\Settings\AvailablePages> $pages
* @param array<AvailablePages> $pages
*/
public function addSectionsToLegacyForm(
\ilPropertyFormGUI $form,
Expand Down Expand Up @@ -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<ILIAS\User\Settings\AvailablePages> $pages
* @param array<AvailablePages> $pages
*/
public function saveForm(
\ilPropertyFormGUI|array $form,
Expand Down Expand Up @@ -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<Setting>
*/
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<ILIAS\User\Settings\AvailablePages> $pages
* @param array<AvailablePages> $pages
*/
private function getSettingsForPagesBySections(
array $pages
Expand Down Expand Up @@ -353,7 +357,7 @@ private function filterSettingsInSectionForAvailability(
);
}

private function retrieveValuefromInputs(
private function retrieveValueFromInputs(
\ilPropertyFormGUI|array $form,
Setting $setting
): mixed {
Expand Down
14 changes: 12 additions & 2 deletions components/ILIAS/User/src/Settings/StartingPoint/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand All @@ -182,6 +182,9 @@ private function getRolesWithStartingPoint(): array
return $roles;
}

/**
* @return list<array{id: int, title: string}>
*/
public function getGlobalRolesWithoutStartingPoint(): array
{
$global_roles = $this->rbac_review->getGlobalRoles();
Expand Down Expand Up @@ -308,6 +311,10 @@ public function getMaxPosition(): int
return $order_val;
}

/**
* @param list<array<string, mixed>> $a_items
* @return array<int, array<string, mixed>>
*/
public function reArrangePositions(array $a_items): array
{
$ord_const = 0;
Expand Down Expand Up @@ -336,7 +343,10 @@ public function saveOrder(array $a_items): void
}
}

public function getPossibleStartingPoints(bool $force_all = false): array //checked
/**
* @return array<int, string>
*/
public function getPossibleStartingPoints(bool $force_all = false): array
{
$all = [];

Expand Down
3 changes: 3 additions & 0 deletions components/ILIAS/User/src/Settings/StartingPoint/Setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ function (array $v): bool {
);
}

/**
* @return array{start: int, ref_id: int|null}
*/
public function retrieveValueFromUser(\ilObjUser $user): array
{
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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'];
Expand Down
2 changes: 1 addition & 1 deletion components/ILIAS/User/src/Settings/UserSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ interface UserSettings
/**
* Return all User Settings provided by the component
*
* @return array<string>
* @return list<class-string<SettingDefinition>>
*/
public function getSettingConfigurations(): array;
}
Loading