Commit d17cf3ac authored by Nathan Phillip Brink's avatar Nathan Phillip Brink
Browse files

Merge remote branch 'origin/6.x-2.x' into 7.x-1.x

parents f8123d42 71118fe7
......@@ -2,7 +2,7 @@ The API documentation has moved to using the API documentation
services available at http://drupalcontrib.org/. Please view the
documentation at:
http://drupalcontrib.org/api/drupal/contributions--content_lock--content_lock.api.inc/7
http://drupalcontrib.org/api/drupal/contributions--content_lock--content_lock.api.inc
Alternatively, you may read content_lock.api.inc's Doxygen comments
directly.
/* $Id$ */
-- Fork --
This module is a fork of the module http://drupal.org/project/checkout and has
been nearly completely reweritten since then
content_lock
-- SUMMARY --
This module implements a pessimistic locking strategy, which means that content
will be exclusively locked whenever a user starts editing it. The lock will be
automatically released when the user submits the form or navigates away from
the edit page.
Content locks that have been "forgotten" can be automatically released after a
configurable time span using the bundled content_lock_timeout submodule.
The purpose of this module is to avoid the situation where two people
are editing a single node at the same time. On busy sites with dynamic
content, edit collisions are a problem and may frustrate editors with
an error stating that the node was already modified and can't be
updated. This module implements a pessimistic locking strategy, which
means that content will be exclusively locked whenever a user starts
editing it. The lock will be automatically released when the user
submits the form or navigates away from the edit page.
Content locks that have been "forgotten" can be automatically released
after a configurable time span using the bundled content_lock_timeout
submodule.
For a full description, visit the project page:
http://drupal.org/project/content_lock
Bug reports, feature suggestions, and latest developments:
http://drupal.org/project/issues/content_lock
For integrating modules with content_lock, see:
http://drupalcontrib.org/api/drupal/contributions--content_lock--content_lock.api.inc
-- INSTALLATION --
......@@ -26,14 +29,16 @@ Bug reports, feature suggestions, and latest developments:
2. Configure user permissions at User management >> Permissions:
check out documents - This enables content locking when a user starts
editing it. Note that even without this permission, users are still
able to edit contents, they're just not protected against concurrent
edits.
editing it. Note that even *without* this permission, users are still
able to edit node contents and are *not* protected from concurrent
editing.
administer checked out documents - View and release locked contents of all
users. This enables the administrative tab on Content management >>
Content. Note that even without this permission, users can manage their
own content locks on their profile page.
administer checked out documents - View and release locked contents
of all users. This enables the administrative tab on Content
management >> Content. Note users can manage their own content
locks on their profile page *without* this permission in their
profile page. This is intended for administrators or moderators
only.
3. Configure the module at Site Configuration >> Content lock.
......@@ -59,17 +64,19 @@ Bug reports, feature suggestions, and latest developments:
4. If you want stale locks to time out, enable the content_lock_timeout
("Content Locking (edit lock) timeouts") module. Then return to the
Content Lock settings page.
Content Lock settings page and configure the timeout.
5. View and administer locked nodes Content management >> Content >>
Locked Documents.
-- CREDITS --
Current authors:
Current maintainers:
Eugen Mayer http://drupal.org/user/108406
Nathan Phillip Brink http://drupal.org/user/108406
Nathan Phillip Brink (ohnobinki) http://drupal.org/user/108406
This module is a fork/continuation of
http://drupal.org/project/checkout which was written and maintained
by:
Original authors:
Stefan M. Kudwien
Joël Guesclin
......@@ -22,13 +22,13 @@ function content_lock_timeout_form_content_lock_admin_settings_alter(&$form, &$f
'#title' => t('Lock timeout'),
'#description' => t('The maximum time in minutes that each lock may be kept. To disable breaking locks after a timeout, please !disable the Content Lock Timeout module.',
array('!disable' => l(t('disable'), 'admin/build/modules', array('fragment' => 'edit-status-content-lock-timeout-wrapper')))),
'#default_value' => variable_get('content_lock_timeout_minutes', 120),
'#default_value' => variable_get('content_lock_timeout_minutes', 30),
);
$form['content_lock_timeout']['content_lock_timeout_on_edit'] = array(
'#type' => 'checkbox',
'#title' => t('Break stale locks on edit'),
'#description' => t('By default, stale locks will be broken when cron is run. This option enables checking for stale locks when a user clicks a node\'s Edit link, enabling lower lock timeout values without having to run cron every few minutes.'),
'#default_value' => variable_get('content_lock_timeout_on_edit', FALSE),
'#default_value' => variable_get('content_lock_timeout_on_edit', TRUE),
);
// Apply some form beautification
......@@ -55,7 +55,7 @@ function content_lock_timeout_admin_settings_validate($form, &$form_state) {
* checkout module).
*/
function content_lock_timeout_cron() {
$timeout_minutes = variable_get('content_lock_timeout_minutes', 120);
$timeout_minutes = variable_get('content_lock_timeout_minutes', 30);
$last_valid_time = time() - 60 * $timeout_minutes;
// We call content_lock_release() for each lock so that the
......@@ -88,10 +88,10 @@ function content_lock_timeout_cron() {
*/
function content_lock_timeout_node_prepare($node) {
global $user;
if (!variable_get('content_lock_timeout_on_edit', FALSE)) {
if (!variable_get('content_lock_timeout_on_edit', TRUE)) {
return;
}
$timeout_minutes = variable_get('content_lock_timeout_minutes', 120);
$timeout_minutes = variable_get('content_lock_timeout_minutes', 30);
$last_valid_time = time() - 60 * $timeout_minutes;
if (!empty($node->nid) // This is a new, unsaved node (which thus can't be locked).
......@@ -127,10 +127,10 @@ function content_lock_timeout_node_prepare($node) {
function content_lock_timeout_content_lock_locked($nid, $uid) {
if(_content_lock_verbose()) {
$on_edit = '';
if (variable_get('content_lock_timeout_on_edit', FALSE)) {
if (variable_get('content_lock_timeout_on_edit', TRUE)) {
$on_edit = ' and up for grabs';
}
$time = format_interval(variable_get('content_lock_timeout_minutes', 120) * 60);
$time = format_interval(variable_get('content_lock_timeout_minutes', 30) * 60);
drupal_set_message(t('Your lock will be considered stale' . $on_edit . ' in @time.',
array('@time' => $time)));
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment