Open green17 opened 1 year ago
I believe that should be fine, so long as the reviewer is also part of the nominated Editors user group.
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
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;
}**
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.
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;
}
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.
Question
Can a Review send to Publisher direct eg skipping the editor?
An example setup would be:
So the Review could start a Review to the Publisher?
Additional context
No response