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

Can a Review send to Publisher direct eg skipping the editor #176

Open
green17 opened this issue Dec 7, 2022 · 6 comments
Open

Can a Review send to Publisher direct eg skipping the editor #176

green17 opened this issue Dec 7, 2022 · 6 comments
Labels
question Further information is requested

Comments

@green17
Copy link

green17 commented Dec 7, 2022

Question

Can a Review send to Publisher direct eg skipping the editor?

An example setup would be:

  • Editor - Staff
  • Review - Manager
  • Publisher - Communication/PR department

So the Review could start a Review to the Publisher?

Additional context

No response

@green17 green17 added the question Further information is requested label Dec 7, 2022
@engram-design
Copy link
Member

I believe that should be fine, so long as the reviewer is also part of the nominated Editors user group.

@green17
Copy link
Author

green17 commented Dec 8, 2022

Hi @engram-design, it does not seem to show the button to review in an entry even if they are in the editor's user group

@green17
Copy link
Author

green17 commented Dec 8, 2022

Am sure there is maybe more to this @engram-design but could something like this work to sort this?

So that if a user is an editor and a reviewer it shows the panel to approve if there is something to approve. Would need to be fixed if there is more than one reviewer...

vendor/verbb/workflow/src/services/Service.php

    public function renderEntrySidebar(DefineHtmlEvent $event): void
    {
        $entry = $event->sender;

        $settings = Workflow::$plugin->getSettings();
        $currentUser = Craft::$app->getUser()->getIdentity();

        $editorGroup = $settings->getEditorUserGroup($entry->site);
        $publisherGroup = $settings->getPublisherUserGroup($entry->site);
        **$reviewerGroup = $settings->getReviewerUserGroups($entry->site)[0];**

        if (!$editorGroup || !$publisherGroup) {
            Workflow::log('Editor and Publisher groups not set in settings.');

            return;
        }

        if (!$currentUser) {
            Workflow::log('No current user.');

            return;
        }

        // If the user is in _both_ editor and publisher groups, work it out.
        if ($currentUser->isInGroup($editorGroup) && $currentUser->isInGroup($publisherGroup)) {
            // Are there any submissions pending for any users but this one?
            $submissions = $this->_getSubmissionsFromContext($entry);

            $pendingSubmissions = ArrayHelper::where($submissions, function($submission) use ($currentUser) {
                return $submission->status === 'pending' && $submission->editorId != $currentUser->id;
            }, true, true, false);

            if ($pendingSubmissions) {
                $event->html .= $this->_renderEntrySidebarPanel($entry, 'publisher-pane');
                return;
            }

            $event->html .= $this->_renderEntrySidebarPanel($entry, 'editor-pane');
            return;
        }

        **// Show the sidebar submission button for editors or if in review and editor so review if there are reviews
        if ($currentUser->isInGroup($editorGroup) and $currentUser->isInGroup($reviewerGroup)) {
            $event->html .= $this->_renderEntrySidebarPanel($entry, 'reviewer-pane');
            return;
        }elseif($currentUser->isInGroup($editorGroup)){
           $event->html .= $this->_renderEntrySidebarPanel($entry, 'editor-pane');
           return;
        }**

@engram-design
Copy link
Member

Hmmm, I'll have to give this some further thought, as there's things that would happen where a reviewer could approve their own submission.

So right now, answer is - everything starts with an Editor.

@green17
Copy link
Author

green17 commented Dec 13, 2022

Thanks Josh, something we really need for a client with lots of users and sometimes things get stuck in a state as an admin makes a change etc and sometimes a review needs to be both to edit and review.

After a bit of testing for our case, this seems to work, is there any clean way for us to override this until you maybe come out with an upgrade?

        // If the user is in _both_ editor and revirew groups, work it out.
        if ($currentUser->isInGroup($editorGroup) && $currentUser->isInGroup($reviewerGroup)) {
            // Are there any submissions pending for any users but this one?
            $submissions = $this->_getSubmissionsFromContext($entry);

            $pendingSubmissions = ArrayHelper::where($submissions, function($submission) use ($currentUser) {
                return $submission->status === 'pending' && $submission->editorId != $currentUser->id;
            }, true, true, false);

            if ($pendingSubmissions) {
                $event->html .= $this->_renderEntrySidebarPanel($entry, 'reviewer-pane');
                return;
            }

            $event->html .= $this->_renderEntrySidebarPanel($entry, 'editor-pane');
            return;
        }

        // Show the sidebar submission button for editors or if in review and editor so review if there are reviews
        if ($currentUser->isInGroup($editorGroup) and $currentUser->isInGroup($reviewerGroup)) {
            $event->html .= $this->_renderEntrySidebarPanel($entry, 'reviewer-pane');
            return;
        }elseif($currentUser->isInGroup($editorGroup)){
           $event->html .= $this->_renderEntrySidebarPanel($entry, 'editor-pane');
           return;
        }

@engram-design
Copy link
Member

Probably not a clean way to do that - without forking the plugin (which you're welcome to do). But I'll look at this in the next few released I'd say.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants