Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate from the general "default_to_private" setting to granular settings #2206

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
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 application/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Module extends AbstractModule
/**
* This Omeka version.
*/
const VERSION = '4.2.0-alpha';
const VERSION = '4.2.0-alpha.1';

/**
* The vocabulary IRI used to define Omeka application data.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
namespace Omeka\Db\Migrations;

use Doctrine\DBAL\Connection;
use Laminas\ServiceManager\ServiceLocatorInterface;
use Omeka\Db\Migration\ConstructedMigrationInterface;

class MigrateDefaultToPrivateSetting implements ConstructedMigrationInterface
{
private $settings;

public static function create(ServiceLocatorInterface $services)
{
return new self($services->get('Omeka\Settings'));
}

public function __construct($settings)
{
$this->settings = $settings;
}

public function up(Connection $conn)
{
// Migrate from the general "default_to_private" setting to granular settings.
$defaultToPrivate = (bool) $this->settings->get('default_to_private', false);
$this->settings->set('default_to_private_items', $defaultToPrivate);
$this->settings->set('default_to_private_item_sets', $defaultToPrivate);
$this->settings->set('default_to_private_sites', $defaultToPrivate);
$this->settings->set('default_to_private_site_pages', $defaultToPrivate);
$this->settings->delete('default_to_private');
}
}
45 changes: 32 additions & 13 deletions application/src/Form/SettingForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,19 +284,38 @@ public function init()

// Editing element group

$this->add([
'name' => 'default_to_private',
'type' => 'Checkbox',
'options' => [
'element_group' => 'editing',
'label' => 'Default content visibility to Private', // @translate
'info' => 'If checked, all items, item sets and sites newly created will have their visibility set to private by default.', // @translate
],
'attributes' => [
'value' => $this->settings->get('default_to_private'),
'id' => 'default_to_private',
],
]);
$defaultToPrivateElements = [
[
'name' => 'default_to_private_items',
'label' => 'Set default item visibility to private', // @translate
],
[
'name' => 'default_to_private_item_sets',
'label' => 'Set default item set visibility to private', // @translate
],
[
'name' => 'default_to_private_sites',
'label' => 'Set default site visibility to private', // @translate
],
[
'name' => 'default_to_private_site_pages',
'label' => 'Set default site page visibility to private', // @translate
],
];
foreach ($defaultToPrivateElements as $defaultToPrivateElement) {
$this->add([
'type' => 'checkbox',
'name' => $defaultToPrivateElement['name'],
'options' => [
'element_group' => 'editing',
'label' => $defaultToPrivateElement['label'],
],
'attributes' => [
'id' => $defaultToPrivateElement['name'],
'value' => $this->settings->get($defaultToPrivateElement['name'], false),
],
]);
}

$this->add([
'name' => 'value_languages',
Expand Down
2 changes: 1 addition & 1 deletion application/view/omeka/admin/item-set/form.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ $form->prepare();
<input type="hidden" name="o:is_open" value="0">
<?php endif; ?>

<?php if ($itemSet && $itemSet->isPublic() || (!isset($itemSet) && !$this->setting('default_to_private')) ): ?>
<?php if ($itemSet && $itemSet->isPublic() || (!isset($itemSet) && !$this->setting('default_to_private_item_sets')) ): ?>
<?php echo $this->hyperlink('', '#', [
'class' => 'o-icon-public button',
'title' => $translate('Make private'),
Expand Down
2 changes: 1 addition & 1 deletion application/view/omeka/admin/item/form.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ $form->prepare();
</fieldset>

<div id="page-actions">
<?php if ($item && $item->isPublic() || (!isset($item)) && !$this->setting('default_to_private')) : ?>
<?php if ($item && $item->isPublic() || (!isset($item)) && !$this->setting('default_to_private_items')) : ?>
<?php echo $this->hyperlink('', '#', [
'class' => 'o-icon-public button',
'title' => $translate('Make private'),
Expand Down
2 changes: 1 addition & 1 deletion application/view/omeka/site-admin/index/add-page.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ $form->prepare();
<?php echo $this->pageTitle($translate('New page'), 1, $translate('Pages')); ?>
<?php echo $this->form()->openTag($form); ?>
<div id="page-actions">
<?php if ($this->setting('default_to_private')) : ?>
<?php if ($this->setting('default_to_private_site_pages')) : ?>
<?php echo $this->hyperlink('', '#', [
'class' => 'o-icon-private button',
'title' => $translate('Make public'),
Expand Down
2 changes: 1 addition & 1 deletion application/view/omeka/site-admin/index/add.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ $fallbackThumbnailUrl = $this->assetUrl('img/theme.jpg', 'Omeka');
<?php echo $this->form()->openTag($form); ?>

<div id="page-actions">
<?php if ($this->setting('default_to_private')) : ?>
<?php if ($this->setting('default_to_private_sites')) : ?>
<?php echo $this->hyperlink('', '#', [
'class' => 'o-icon-private button',
'title' => $translate('Make public'),
Expand Down
Loading