Skip to content
Merged
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 lib/Activity/ActivityManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use OCP\Share\IShare;

class ActivityManager {

public function __construct(
protected string $appName,
private ?string $userId,
Expand Down
6 changes: 3 additions & 3 deletions lib/Controller/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,9 @@

// Don't allow to change params id, hash, ownerId, created, lastUpdated, fileId
if (
key_exists('id', $keyValuePairs) || key_exists('hash', $keyValuePairs) ||
key_exists('ownerId', $keyValuePairs) || key_exists('created', $keyValuePairs) ||
isset($keyValuePairs['fileId']) || key_exists('lastUpdated', $keyValuePairs)
key_exists('id', $keyValuePairs) || key_exists('hash', $keyValuePairs)
|| key_exists('ownerId', $keyValuePairs) || key_exists('created', $keyValuePairs)
|| isset($keyValuePairs['fileId']) || key_exists('lastUpdated', $keyValuePairs)

Check warning on line 315 in lib/Controller/ApiController.php

View check run for this annotation

Codecov / codecov/patch

lib/Controller/ApiController.php#L313-L315

Added lines #L313 - L315 were not covered by tests
) {
$this->logger->info('Not allowed to update id, hash, ownerId, created, fileId or lastUpdated');
throw new OCSForbiddenException('Not allowed to update id, hash, ownerId, created, fileId or lastUpdated');
Expand Down
2 changes: 1 addition & 1 deletion lib/Db/FormMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct(
parent::__construct($db, 'forms_v2_forms', Form::class);
}


/**
* @param Entity $entity
* @psalm-param Form $entity
Expand Down
6 changes: 3 additions & 3 deletions lib/FormsMigrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ public function export(IUser $user, IExportDestination $exportDestination, Outpu
// Mark userIds with instance.
foreach ($formData['submissions'] as $sKey => $submission) {
// Anonymous submission or already migrated, just keep it.
if (substr($submission['userId'], 0, 10) === 'anon-user-' ||
substr($submission['userId'], 0, 8) === 'unknown~') {
if (substr($submission['userId'], 0, 10) === 'anon-user-'
|| substr($submission['userId'], 0, 8) === 'unknown~') {
continue;
}

Expand Down Expand Up @@ -148,7 +148,7 @@ public function import(IUser $user, IImportSource $importSource, OutputInterface
$form->setSubmitMultiple($formData['submitMultiple']);
$form->setAllowEditSubmissions($formData['allowEditSubmissions']);
$form->setShowExpiration($formData['showExpiration']);

$this->formMapper->insert($form);

$questionIdMap = [];
Expand Down
2 changes: 1 addition & 1 deletion lib/Migration/Version020300Date20210406114130.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt

return $schema;
}

return null;
}

Expand Down
6 changes: 3 additions & 3 deletions lib/Migration/Version020300Date20210406133704.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ class Version020300Date20210406133704 extends SimpleMigrationStep {
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();

$table = $schema->getTable('forms_v2_questions');

if ($table->hasColumn('mandatory') && $table->hasColumn('is_required')) {
$table->dropColumn('mandatory');

return $schema;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Migration/Version030000Date20220414203511.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt

return $schema;
}

return null;
}
}
2 changes: 1 addition & 1 deletion lib/Migration/Version030000Date20220705192811.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt

return $schema;
}

return null;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Migration/Version030000Date20220707130109.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
$schema = $schemaClosure();

$table = $schema->getTable('forms_v2_forms');

if ($table->hasColumn('submit_once') && $table->hasColumn('submit_multiple')) {
$table->dropColumn('submit_once');
return $schema;
Expand Down
2 changes: 1 addition & 1 deletion lib/Migration/Version030000Date20220831195000.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt

return $schema;
}

return null;
}
}
2 changes: 1 addition & 1 deletion lib/Migration/Version030100Date20221231100426.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt

return $schema;
}

return null;
}
}
2 changes: 1 addition & 1 deletion lib/Migration/Version030100Date20230123182700.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt

return $schema;
}

return null;
}
}
2 changes: 1 addition & 1 deletion lib/Migration/Version040200Date20240402200139.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function postSchemaChange(IOutput $output, Closure $schemaClosure, array
$qbUpdate->update('forms_v2_forms')
->set('access_enum', $qbUpdate->createParameter('access_enum'))
->where($qbUpdate->expr()->eq('id', $qbUpdate->createParameter('id')));

// Fetch Forms...
$cursor = $qbFetch->executeQuery();

Expand Down
2 changes: 1 addition & 1 deletion lib/Migration/Version040200Date20240402224725.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
$schema = $schemaClosure();

$table = $schema->getTable('forms_v2_forms');

if ($table->hasColumn('access_json') && $table->hasColumn('access_enum')) {
$table->dropColumn('access_json');
return $schema;
Expand Down
2 changes: 1 addition & 1 deletion lib/Migration/Version050000Date20241005173955.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct(
protected IDBConnection $db,
) {
}

/**
* @param IOutput $output
* @param Closure(): ISchemaWrapper $schemaClosure
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/ConfigService.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

class ConfigService {
private ?IUser $currentUser;

public function __construct(
protected string $appName,
private IConfig $config,
Expand Down
22 changes: 11 additions & 11 deletions lib/Service/FormsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@
if ($this->isFormArchived($form)) {
return false;
}

// Allow deleting results if the current user has the "results_delete" permission
if (in_array(Constants::PERMISSION_RESULTS_DELETE, $this->getPermissions($form))) {
return true;
Expand Down Expand Up @@ -387,8 +387,8 @@

// Refuse access, if submitMultiple is not set and user already has taken part.
if (
!$form->getSubmitMultiple() &&
$this->submissionMapper->hasFormSubmissionsByUser($form, $this->currentUser->getUID())
!$form->getSubmitMultiple()
&& $this->submissionMapper->hasFormSubmissionsByUser($form, $this->currentUser->getUID())
) {
return false;
}
Expand Down Expand Up @@ -480,10 +480,10 @@
}

// Shown if permitAll and showToAll are both set.
if ($form->getAccess()['permitAllUsers'] &&
$form->getAccess()['showToAllUsers'] &&
$this->configService->getAllowPermitAll() &&
$this->configService->getAllowShowToAll()) {
if ($form->getAccess()['permitAllUsers']
&& $form->getAccess()['showToAllUsers']
&& $this->configService->getAllowPermitAll()
&& $this->configService->getAllowShowToAll()) {

Check warning on line 486 in lib/Service/FormsService.php

View check run for this annotation

Codecov / codecov/patch

lib/Service/FormsService.php#L483-L486

Added lines #L483 - L486 were not covered by tests

return true;
}
Expand Down Expand Up @@ -585,9 +585,9 @@
'Error while publishing new share activity',
[$e]
);

}

}

/**
Expand Down Expand Up @@ -806,8 +806,8 @@
// Special handling of linear scale validation
} elseif ($questionType === Constants::ANSWER_TYPE_LINEARSCALE) {
// Ensure limits are sane
if (isset($extraSettings['optionsLowest']) && ($extraSettings['optionsLowest'] < 0 || $extraSettings['optionsLowest'] > 1) ||
isset($extraSettings['optionsHighest']) && ($extraSettings['optionsHighest'] < 2 || $extraSettings['optionsHighest'] > 10)) {
if (isset($extraSettings['optionsLowest']) && ($extraSettings['optionsLowest'] < 0 || $extraSettings['optionsLowest'] > 1)
|| isset($extraSettings['optionsHighest']) && ($extraSettings['optionsHighest'] < 2 || $extraSettings['optionsHighest'] > 10)) {
return false;
}
}
Expand Down
22 changes: 11 additions & 11 deletions lib/Service/SubmissionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,8 @@ public function getSubmissionsData(Form $form, string $fileFormat, ?File $file =
function (array $carry, Answer $answer) use ($questionPerQuestionId) {
$questionId = $answer->getQuestionId();

if (isset($questionPerQuestionId[$questionId]) &&
$questionPerQuestionId[$questionId]->getType() === Constants::ANSWER_TYPE_FILE) {
if (isset($questionPerQuestionId[$questionId])
&& $questionPerQuestionId[$questionId]->getType() === Constants::ANSWER_TYPE_FILE) {
if (array_key_exists($questionId, $carry)) {
$carry[$questionId]['label'] .= "; \n" . $answer->getText();
} else {
Expand Down Expand Up @@ -373,17 +373,17 @@ public function validateSubmission(array $questions, array $answers, string $for
$questionAnswered = array_key_exists($questionId, $answers);

// Check if all required questions have an answer
if ($question['isRequired'] &&
(!$questionAnswered ||
!array_filter($answers[$questionId], static function (string|array $value): bool {
if ($question['isRequired']
&& (!$questionAnswered
|| !array_filter($answers[$questionId], static function (string|array $value): bool {
// file type
if (is_array($value)) {
return !empty($value['uploadedFileId']);
}

return $value !== '';
}) ||
(!empty($question['extraSettings']['allowOtherAnswer']) && !array_filter($answers[$questionId], fn ($value) => $value !== Constants::QUESTION_EXTRASETTINGS_OTHER_PREFIX)))
})
|| (!empty($question['extraSettings']['allowOtherAnswer']) && !array_filter($answers[$questionId], fn ($value) => $value !== Constants::QUESTION_EXTRASETTINGS_OTHER_PREFIX)))
) {
throw new \InvalidArgumentException(sprintf('Question "%s" is required.', $question['text']));
}
Expand Down Expand Up @@ -505,10 +505,10 @@ private function validateDateTime(array $answers, string $format, ?string $text
$previousDate = $d;

if ($extraSettings) {
if ((isset($extraSettings['dateMin']) && $d < (new DateTime())->setTimestamp($extraSettings['dateMin'])) ||
(isset($extraSettings['dateMax']) && $d > (new DateTime())->setTimestamp($extraSettings['dateMax'])) ||
(isset($extraSettings['timeMin']) && $d < DateTime::createFromFormat($format, $extraSettings['timeMin'])) ||
(isset($extraSettings['timeMax']) && $d > DateTime::createFromFormat($format, $extraSettings['timeMax']))
if ((isset($extraSettings['dateMin']) && $d < (new DateTime())->setTimestamp($extraSettings['dateMin']))
|| (isset($extraSettings['dateMax']) && $d > (new DateTime())->setTimestamp($extraSettings['dateMax']))
|| (isset($extraSettings['timeMin']) && $d < DateTime::createFromFormat($format, $extraSettings['timeMin']))
|| (isset($extraSettings['timeMax']) && $d > DateTime::createFromFormat($format, $extraSettings['timeMax']))
) {
throw new \InvalidArgumentException(sprintf('Date/time is not in the allowed range for question "%s".', $text));
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Activity/ActivityManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function testPublishNewGroupShare() {
$form->setTitle('TestForm-Title');
$form->setHash('abcdefg12345');
$groupId = 'sharedGroup';

$group = $this->createMock(IGroup::class);
$user = $this->createMock(IUser::class);

Expand Down Expand Up @@ -154,7 +154,7 @@ public function testPublishNewCircleShare() {

public function testPublishNewCircleShare_circlesDisabled() {
$form = $this->createMock(Form::class);

$this->circlesService->expects($this->once())
->method('getCircleUsers')
->with('circle')
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Activity/ProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function setUp(): void {
$this->l10nFactory = $this->createMock(IFactory::class);
$this->validator = $this->createMock(IValidator::class);
$this->circlesService = $this->createMock(CirclesService::class);

$this->urlGenerator->expects($this->any())
->method('linkToRouteAbsolute')
->with('forms.page.index')
Expand Down
Loading
Loading