Skip to content

Commit cfcf8b6

Browse files
authored
Admin Articles View - Execute transition button permissions fixed (joomla#39490)
* Admin Articles View - Transition button fixed * fixed drone claim ---------
1 parent 874f231 commit cfcf8b6

File tree

2 files changed

+29
-21
lines changed

2 files changed

+29
-21
lines changed

administrator/components/com_content/src/View/Articles/HtmlView.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ protected function addToolbar()
190190

191191
$childBar = $dropdown->getChildToolbar();
192192

193-
if (\count($this->transitions)) {
193+
if ($canDo->get('core.execute.transition') && \count($this->transitions)) {
194194
$childBar->separatorButton('transition-headline')
195195
->text('COM_CONTENT_RUN_TRANSITIONS')
196196
->buttonClass('text-center py-2 h3');

administrator/components/com_content/tmpl/articles/default.php

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -152,23 +152,39 @@
152152
endif; ?>>
153153
<?php foreach ($this->items as $i => $item) :
154154
$item->max_ordering = 0;
155-
$canEdit = $user->authorise('core.edit', 'com_content.article.' . $item->id);
156-
$canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $userId || is_null($item->checked_out);
157-
$canEditOwn = $user->authorise('core.edit.own', 'com_content.article.' . $item->id) && $item->created_by == $userId;
158-
$canChange = $user->authorise('core.edit.state', 'com_content.article.' . $item->id) && $canCheckin;
159-
$canEditCat = $user->authorise('core.edit', 'com_content.category.' . $item->catid);
160-
$canEditOwnCat = $user->authorise('core.edit.own', 'com_content.category.' . $item->catid) && $item->category_uid == $userId;
161-
$canEditParCat = $user->authorise('core.edit', 'com_content.category.' . $item->parent_category_id);
162-
$canEditOwnParCat = $user->authorise('core.edit.own', 'com_content.category.' . $item->parent_category_id) && $item->parent_category_uid == $userId;
155+
$canEdit = $user->authorise('core.edit', 'com_content.article.' . $item->id);
156+
$canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $userId || is_null($item->checked_out);
157+
$canEditOwn = $user->authorise('core.edit.own', 'com_content.article.' . $item->id) && $item->created_by == $userId;
158+
$canChange = $user->authorise('core.edit.state', 'com_content.article.' . $item->id) && $canCheckin;
159+
$canExecuteTransition = $user->authorise('core.execute.transition', 'com_content.article.' . $item->id);
160+
$canEditCat = $user->authorise('core.edit', 'com_content.category.' . $item->catid);
161+
$canEditOwnCat = $user->authorise('core.edit.own', 'com_content.category.' . $item->catid) && $item->category_uid == $userId;
162+
$canEditParCat = $user->authorise('core.edit', 'com_content.category.' . $item->parent_category_id);
163+
$canEditOwnParCat = $user->authorise('core.edit.own', 'com_content.category.' . $item->parent_category_id) && $item->parent_category_uid == $userId;
163164

164-
$transitions = ContentHelper::filterTransitions($this->transitions, (int) $item->stage_id, (int) $item->workflow_id);
165+
// Transition button options
166+
$options = [
167+
'title' => Text::_($item->stage_title),
168+
'tip_content' => Text::sprintf('JWORKFLOW', Text::_($item->workflow_title)),
169+
'id' => 'workflow-' . $item->id,
170+
'task' => 'articles.runTransition',
171+
'disabled' => !$canExecuteTransition,
172+
];
165173

166-
$transition_ids = ArrayHelper::getColumn($transitions, 'value');
167-
$transition_ids = ArrayHelper::toInteger($transition_ids);
174+
if ($canExecuteTransition) {
175+
$transitions = ContentHelper::filterTransitions($this->transitions, (int) $item->stage_id, (int) $item->workflow_id);
176+
177+
$transition_ids = ArrayHelper::getColumn($transitions, 'value');
178+
$transition_ids = ArrayHelper::toInteger($transition_ids);
179+
180+
$dataTransitionsAttribute = 'data-transitions="' . implode(',', $transition_ids) . '"';
181+
182+
$options = array_merge($options, ['transitions' => $transitions]);
183+
}
168184

169185
?>
170186
<tr class="row<?php echo $i % 2; ?>" data-draggable-group="<?php echo $item->catid; ?>"
171-
data-transitions="<?php echo implode(',', $transition_ids); ?>"
187+
<?php echo $dataTransitionsAttribute ?? '' ?>
172188
>
173189
<td class="text-center">
174190
<?php echo HTMLHelper::_('grid.id', $i, $item->id, false, 'cid', 'cb', $item->title); ?>
@@ -192,14 +208,6 @@
192208
<?php if ($workflow_enabled) : ?>
193209
<td class="article-stage text-center">
194210
<?php
195-
$options = [
196-
'transitions' => $transitions,
197-
'title' => Text::_($item->stage_title),
198-
'tip_content' => Text::sprintf('JWORKFLOW', Text::_($item->workflow_title)),
199-
'id' => 'workflow-' . $item->id,
200-
'task' => 'articles.runTransition'
201-
];
202-
203211
echo (new TransitionButton($options))
204212
->render(0, $i);
205213
?>

0 commit comments

Comments
 (0)