Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix batch #57

Merged
merged 10 commits into from
Apr 21, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

use Joomla\CMS\Factory;
use Joomla\CMS\Layout\LayoutHelper;
use Joomla\CMS\Component\ComponentHelper;

$params = ComponentHelper::getParams('com_content');

$published = $this->state->get('filter.published');

Expand Down Expand Up @@ -42,7 +45,7 @@
<?php echo LayoutHelper::render('joomla.html.batch.tag', []); ?>
</div>
</div>
<?php if ($user->authorise('core.admin', 'com_content')) : ?>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's the wrong approach, you should ask the service if the workflow is enabled for this view. Also as example for other developer

<?php if ($user->authorise('core.admin', 'com_content') && $params->get('workflows_enable', 1)) : ?>
<div class="form-group col-md-6">
<div class="controls">
<?php echo LayoutHelper::render('joomla.html.batch.workflowstage', ['extension' => 'com_content']); ?>
Expand Down
8 changes: 4 additions & 4 deletions libraries/src/MVC/Model/WorkflowBehaviorTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,10 @@ protected function getStageForNewItem(Form $form, $data)
*
* @since 4.0.0
*/
public function batchWorkflowStage(int $value, array $pks, array $contexts) {

public function batchWorkflowStage(int $value, array $pks, array $contexts)
{
$user = Factory::getApplication()->getIdentity();
/** @var $workflow */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't there be the class name?


$workflow = Factory::getApplication()->bootComponent('com_workflow');

if (!$user->authorise('core.admin', $this->option))
Expand All @@ -429,7 +429,7 @@ public function batchWorkflowStage(int $value, array $pks, array $contexts) {
}

// Get workflow stage information
$stage = $workflow->createTable('Stage', 'Administrator');
$stage = $workflow->getMVCFactory()->createTable('Stage', 'Administrator');

if (empty($value) || !$stage->load($value))
{
Expand Down