diff --git a/composer.json b/composer.json index fc83182..95b3ebb 100644 --- a/composer.json +++ b/composer.json @@ -12,6 +12,7 @@ ], "require": { "drupal/admin_toolbar": "^3.0", + "drupal/content_lock": "^2.3", "drupal/core": "^10.0", "drupal/gin": "^3.0@alpha", "drupal/gin_login": "^1.0@RC", diff --git a/modules/localgov_content_lock/README.md b/modules/localgov_content_lock/README.md new file mode 100644 index 0000000..01f2128 --- /dev/null +++ b/modules/localgov_content_lock/README.md @@ -0,0 +1,11 @@ +# LocalGov Drupal Content Lock + +Customises the Content Lock module for use with LocalGov Drupal. + +When enabled this module will: + +* Enable the Content Lock and Content Lock Timeout modules. +* Enables content locking for all enabled content types. +* Adds a link to the content lock view to the content admin page and the admin menu. + +The default content lock timeout is left at 30 minutes. This can be changed at /admin/config/content/content_lock/timeout. diff --git a/modules/localgov_content_lock/localgov_content_lock.info.yml b/modules/localgov_content_lock/localgov_content_lock.info.yml new file mode 100644 index 0000000..87602f3 --- /dev/null +++ b/modules/localgov_content_lock/localgov_content_lock.info.yml @@ -0,0 +1,8 @@ +name: LocalGov Content Lock +type: module +description: Customises the Content Lock module for use with LocalGov Drupal +package: LocalGov Drupal +core_version_requirement: ^9 || ^10 +dependencies: + - content_lock:content_lock + - content_lock:content_lock_timeout diff --git a/modules/localgov_content_lock/localgov_content_lock.install b/modules/localgov_content_lock/localgov_content_lock.install new file mode 100644 index 0000000..d9d640c --- /dev/null +++ b/modules/localgov_content_lock/localgov_content_lock.install @@ -0,0 +1,22 @@ +getEditable('content_lock.settings'); + $content_lock_config->set('types.node', ['*' => '*']); + $content_lock_config->save(); +} diff --git a/modules/localgov_content_lock/localgov_content_lock.links.menu.yml b/modules/localgov_content_lock/localgov_content_lock.links.menu.yml new file mode 100644 index 0000000..6d7b238 --- /dev/null +++ b/modules/localgov_content_lock/localgov_content_lock.links.menu.yml @@ -0,0 +1,4 @@ +localgov_content_lock.locked_content: + title: 'Locked content' + parent: system.admin_content + route_name: view.locked_content.page_1 diff --git a/modules/localgov_content_lock/localgov_content_lock.links.task.yml b/modules/localgov_content_lock/localgov_content_lock.links.task.yml new file mode 100644 index 0000000..ab5d773 --- /dev/null +++ b/modules/localgov_content_lock/localgov_content_lock.links.task.yml @@ -0,0 +1,5 @@ +localgov_content_lock.locked_content: + title: 'Locked' + parent_id: system.admin_content + route_name: view.locked_content.page_1 + weight: 100 diff --git a/modules/localgov_content_lock/localgov_content_lock.module b/modules/localgov_content_lock/localgov_content_lock.module new file mode 100644 index 0000000..f1ce5cd --- /dev/null +++ b/modules/localgov_content_lock/localgov_content_lock.module @@ -0,0 +1,6 @@ +drupalCreateUser([], 'test_user', TRUE); + $this->drupalLogin($user); + + // Create a node. + $this->drupalGet('/node/add/localgov_services_page'); + $title = $this->randomMachineName(); + $this->submitForm( + [ + 'title[0][value]' => $title, + 'body[0][summary]' => 'Test content lock', + 'body[0][value]' => 'Test content lock', + ], + 'Save' + ); + $this->assertSession()->pageTextContains('Service page ' . $title . ' has been created.'); + $nid = $this->drupalGetNodeByTitle($title)->id(); + + // Check that the node gets locked when editing. + $this->drupalGet('/node/' . $nid . '/edit'); + $this->assertSession()->pageTextContains('This content is now locked against simultaneous editing.'); + $this->drupalGet('/admin/content/locked-content'); + $this->assertSession()->pageTextContains($title); + } + +}