diff --git a/config/optional/views.view.locked_content.yml b/config/optional/views.view.locked_content.yml index c27bd90..1a5db20 100644 --- a/config/optional/views.view.locked_content.yml +++ b/config/optional/views.view.locked_content.yml @@ -167,6 +167,18 @@ display: custom_date_format: '' timezone: '' plugin_id: date + langcode: + id: langcode + table: content_lock + field: langcode + plugin_id: langcode + exclude: false + form_op: + id: form_op + table: content_lock + field: form_op + plugin_id: string + exclude: false is_locked: id: is_locked table: content_lock diff --git a/content_lock.module b/content_lock.module index 875f900..8fa3410 100644 --- a/content_lock.module +++ b/content_lock.module @@ -229,10 +229,14 @@ function content_lock_views_data() { 'left_field' => $definition->getKey('id'), 'field' => 'entity_id', 'extra' => [ - 0 => [ + [ 'field' => 'entity_type', 'value' => $type, ], + [ + 'left_field' => $definition->getKey('langcode'), + 'field' => 'langcode', + ] ], ]; @@ -274,6 +278,41 @@ function content_lock_views_data() { ], ]; + $data['content_lock']['langcode'] = [ + 'title' => t('Lock Language'), + 'help' => t('Language of the lock'), + 'field' => [ + 'id' => 'language', + ], + 'sort' => [ + 'id' => 'standard', + ], + 'filter' => [ + 'id' => 'language', + ], + 'argument' => [ + 'id' => 'language', + ], + 'entity field' => 'langcode' + ]; + + $data['content_lock']['form_op'] = [ + 'title' => t('Lock Form Operation'), + 'help' => t('Form operation of the lock'), + 'field' => [ + 'id' => 'standard', + ], + 'sort' => [ + 'id' => 'standard', + ], + 'filter' => [ + 'id' => 'string' + ], + 'argument' => [ + 'id' => 'string' + ] + ]; + $data['content_lock']['is_locked'] = [ 'title' => t('Is Locked'), 'help' => t('Whether the node is currently locked'), diff --git a/src/Plugin/views/field/ContentLockBreak.php b/src/Plugin/views/field/ContentLockBreak.php index eb9abf5..3335375 100644 --- a/src/Plugin/views/field/ContentLockBreak.php +++ b/src/Plugin/views/field/ContentLockBreak.php @@ -31,7 +31,11 @@ class ContentLockBreak extends FieldPluginBase { $entity = $this->getEntity($values); $url = Url::fromRoute( 'content_lock.break_lock.' . $entity->getEntityTypeId(), - ['entity' => $entity->id()] + [ + 'entity' => $entity->id(), + 'langcode' => $entity->language()->getId(), + 'form_op' => isset($values->content_lock_form_op) ? $values->content_lock_form_op : '*', + ] ); $break_link = Link::fromTextAndUrl('Break lock', $url); diff --git a/src/Plugin/views/filter/ContentLockFilter.php b/src/Plugin/views/filter/ContentLockFilter.php index 46f938f..edd0743 100644 --- a/src/Plugin/views/filter/ContentLockFilter.php +++ b/src/Plugin/views/filter/ContentLockFilter.php @@ -19,10 +19,10 @@ class ContentLockFilter extends BooleanOperator { public function query() { $this->ensureMyTable(); if (empty($this->value)) { - $this->query->addWhere($this->options['group'], $this->tableAlias . ".timestamp", 0, BooleanOperator::EQUAL); + $this->query->addWhere($this->options['group'], $this->tableAlias . ".timestamp", 0, BooleanOperator::EQUAL); } else { - $this->query->addWhere($this->options['group'], $this->tableAlias . ".timestamp", 0, BooleanOperator::NOT_EQUAL); + $this->query->addWhere($this->options['group'], $this->tableAlias . ".timestamp", 0, BooleanOperator::NOT_EQUAL); } }