Skip to content

Commit

Permalink
Merge pull request #2060 from nextcloud/fix/access_migration
Browse files Browse the repository at this point in the history
fix: `legacyLink` access handling
  • Loading branch information
susnux committed Apr 15, 2024
2 parents 1ba3a14 + 52916f6 commit 3f82fb1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/Db/Form.php
Expand Up @@ -133,7 +133,7 @@ public function setAccess(array $access) {
}

// If legacyLink add 3
if (isset($access['legacyLink'])) {
if (isset($access['legacyLink']) && $access['legacyLink']) {
$value += Constants::FORM_ACCESS_LEGACYLINK;
}

Expand Down
13 changes: 7 additions & 6 deletions lib/Migration/Version040200Date20240402200139.php
Expand Up @@ -27,6 +27,7 @@
namespace OCA\Forms\Migration;

use Closure;
use OCA\Forms\Constants;
use OCP\DB\ISchemaWrapper;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\DB\Types;
Expand Down Expand Up @@ -95,22 +96,22 @@ public function postSchemaChange(IOutput $output, Closure $schemaClosure, array
// Decode access to array (param assoc=true)
$access = json_decode($row['access_json'], true);

$value = 0;
$value = Constants::FORM_ACCESS_NOPUBLICSHARE;

// No further permissions -> 0
// Permit all users, but don't show in navigation -> 1
// Permit all users and show in navigation -> 2
if (!$access['permitAllUsers'] && !$access['showToAllUsers']) {
$value = 0;
$value = Constants::FORM_ACCESS_NOPUBLICSHARE;
} elseif ($access['permitAllUsers'] && !$access['showToAllUsers']) {
$value = 1;
$value = Constants::FORM_ACCESS_PERMITALLUSERS;
} else {
$value = 2;
$value = Constants::FORM_ACCESS_SHOWTOALLUSERS;
}

// If legacyLink add 3
if ($access['legacyLink']) {
$value += 3;
if (isset($access['legacyLink']) && $access['legacyLink']) {
$value += Constants::FORM_ACCESS_LEGACYLINK;
}

$qbUpdate->setParameter('id', $row['id'], IQueryBuilder::PARAM_INT)
Expand Down

0 comments on commit 3f82fb1

Please sign in to comment.