Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupalorg
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupalorg
Merge requests
!356
Add checking for view unpublished … content
Code
Review changes
Check out branch
Open in Workspace
Download
Patches
Plain diff
Expand sidebar
Merged
Add checking for view unpublished … content
issue/drupalorg-3529649:3529649-check-view-unpublished
into
1.0.x
Overview
2
Commits
7
Pipelines
8
Changes
3
All threads resolved!
Hide all comments
Merged
Add checking for view unpublished … content
Neil Drumm
requested to merge
issue/drupalorg-3529649:3529649-check-view-unpublished
into
1.0.x
2 months ago
Overview
2
Commits
7
Pipelines
8
Changes
3
All threads resolved!
Hide all comments
Closes
#3529649
0
0
Merge request reports
Compare
1.0.x
version 7
ca87cc52
2 months ago
version 6
437a2818
2 months ago
version 5
676ecd1c
2 months ago
version 4
0f8e62d3
2 months ago
version 3
277073c8
2 months ago
version 2
6479350b
2 months ago
version 1
35a1e2de
2 months ago
1.0.x (base)
and
latest version
latest version
ca87cc52
7 commits,
2 months ago
version 7
ca87cc52
7 commits,
2 months ago
version 6
437a2818
6 commits,
2 months ago
version 5
676ecd1c
5 commits,
2 months ago
version 4
0f8e62d3
4 commits,
2 months ago
version 3
277073c8
3 commits,
2 months ago
version 2
6479350b
2 commits,
2 months ago
version 1
35a1e2de
1 commit,
2 months ago
3 files
+
81
−
7
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
src/Plugin/views/filter/DrupalOrgNodeStatus.php
0 → 100644
+
66
−
0
View file @ ca87cc52
Edit in single-file editor
Open in Web IDE
<?php
declare
(
strict_types
=
1
);
namespace
Drupal\drupalorg\Plugin\views\filter
;
use
Drupal\Core\Plugin\ContainerFactoryPluginInterface
;
use
Drupal\Core\Session\AccountInterface
;
use
Drupal\node\Entity\NodeType
;
use
Drupal\node\Plugin\views\filter\Status
;
use
Drupal\views\Attribute\ViewsFilter
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
/**
* Filter by published status.
*
* @ingroup views_filter_handlers
*/
#[ViewsFilter("drupalorg_node_status")]
class
DrupalOrgNodeStatus
extends
Status
implements
ContainerFactoryPluginInterface
{
/**
* {@inheritdoc}
*/
public
static
function
create
(
ContainerInterface
$container
,
array
$configuration
,
$plugin_id
,
$plugin_definition
)
{
return
new
static
(
$configuration
,
$plugin_id
,
$plugin_definition
,
$container
->
get
(
'current_user'
),
);
}
/**
* {@inheritdoc}
*/
public
function
__construct
(
array
$configuration
,
$plugin_id
,
$plugin_definition
,
private
readonly
AccountInterface
$currentUser
)
{
parent
::
__construct
(
$configuration
,
$plugin_id
,
$plugin_definition
);
}
/**
* {@inheritdoc}
*/
public
function
query
()
{
$table
=
$this
->
ensureMyTable
();
$snippet
=
"
$table
.status = 1 OR (
$table
.uid = ***CURRENT_USER*** AND ***CURRENT_USER*** <> 0 AND ***VIEW_OWN_UNPUBLISHED_NODES*** = 1) OR ***BYPASS_NODE_ACCESS*** = 1"
;
if
(
$this
->
moduleHandler
->
moduleExists
(
'content_moderation'
))
{
$snippet
.
=
' OR ***VIEW_ANY_UNPUBLISHED_NODES*** = 1'
;
}
$args
=
[
':unpublished_type_access[]'
=>
[],
];
foreach
(
array_keys
(
NodeType
::
loadMultiple
())
as
$node_type_id
)
{
if
(
$this
->
currentUser
->
hasPermission
(
"view any unpublished
$node_type_id
content"
))
{
$args
[
':unpublished_type_access[]'
][]
=
$node_type_id
;
}
}
if
(
!
empty
(
$args
[
':unpublished_type_access[]'
]))
{
$snippet
.
=
' OR '
.
$table
.
'.type IN (:unpublished_type_access[])'
;
}
$this
->
query
->
addWhereExpression
(
$this
->
options
[
'group'
],
$snippet
,
$args
);
}
}
Loading