mirror of
https://github.com/standardebooks/web.git
synced 2025-07-05 14:20:29 -04:00
Don't allow the manager or reviewer to be the same as the ebook producer
This commit is contained in:
parent
133c968fc0
commit
ac56d2d896
3 changed files with 38 additions and 7 deletions
|
@ -281,9 +281,17 @@ final class Project{
|
|||
* @throws Exceptions\UserNotFoundException If a manager or reviewer could not be auto-assigned.
|
||||
*/
|
||||
public function Create(): void{
|
||||
// Is this `Project` being produced by one of the editors?
|
||||
try{
|
||||
$producer = User::GetByIdentifier($this->ProducerName);
|
||||
}
|
||||
catch(Exceptions\UserNotFoundException){
|
||||
$producer = null;
|
||||
}
|
||||
|
||||
if(!isset($this->ManagerUserId)){
|
||||
try{
|
||||
$this->Manager = User::GetByAvailableForProjectAssignment(Enums\ProjectRoleType::Manager, null);
|
||||
$this->Manager = User::GetByAvailableForProjectAssignment(Enums\ProjectRoleType::Manager, [$producer->UserId ?? 0]);
|
||||
}
|
||||
catch(Exceptions\UserNotFoundException){
|
||||
throw new Exceptions\UserNotFoundException('Could not auto-assign a suitable manager.');
|
||||
|
@ -294,7 +302,7 @@ final class Project{
|
|||
|
||||
if(!isset($this->ReviewerUserId)){
|
||||
try{
|
||||
$this->Reviewer = User::GetByAvailableForProjectAssignment(Enums\ProjectRoleType::Reviewer, $this->Manager->UserId);
|
||||
$this->Reviewer = User::GetByAvailableForProjectAssignment(Enums\ProjectRoleType::Reviewer, [$this->Manager->UserId, $producer->UserId ?? 0]);
|
||||
}
|
||||
catch(Exceptions\UserNotFoundException){
|
||||
unset($this->Manager);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue