| Code Coverage | ||||||||||
| Classes and Traits | Functions and Methods | Lines | ||||||||
| Total |  | 0.00% | 0 / 1 |  | 42.86% | 3 / 7 | CRAP |  | 78.95% | 15 / 19 | 
| PendingState |  | 0.00% | 0 / 1 |  | 42.86% | 3 / 7 | 10.93 |  | 78.95% | 15 / 19 | 
| proceedConfig |  | 100.00% | 1 / 1 | 1 |  | 100.00% | 6 / 6 | |||
| revertConfig |  | 0.00% | 0 / 1 | 2 |  | 0.00% | 0 / 1 | |||
| checkProceedRules |  | 100.00% | 1 / 1 | 3 |  | 100.00% | 1 / 1 | |||
| afterRevert |  | 0.00% | 0 / 1 | 2.06 |  | 75.00% | 3 / 4 | |||
| notifyReset |  | 100.00% | 1 / 1 | 1 |  | 100.00% | 5 / 5 | |||
| checkRevertRules |  | 0.00% | 0 / 1 | 2 |  | 0.00% | 0 / 1 | |||
| afterProceed |  | 0.00% | 0 / 1 | 2 |  | 0.00% | 0 / 1 | |||
| <?php | |
| namespace humhub\modules\tasks\models\state; | |
| use humhub\modules\tasks\activities\TaskResetActivity; | |
| use humhub\modules\tasks\models\Task; | |
| use humhub\modules\tasks\notifications\TaskResetNotification; | |
| use Yii; | |
| class PendingState extends TaskState | |
| { | |
| public static $status = Task::STATUS_PENDING; | |
| public static $defaultProceedStatus = Task::STATUS_IN_PROGRESS; | |
| protected function proceedConfig($user = null) | |
| { | |
| return [ | |
| Task::STATUS_IN_PROGRESS => [ | |
| 'label' => Yii::t('TasksModule.base', 'Begin Task'), | |
| 'icon' => 'fa-play' | |
| ], | |
| Task::STATUS_PENDING_REVIEW => [ | |
| 'label' => Yii::t('TasksModule.base', 'Ready For Review'), | |
| 'icon' => 'fa-eye' | |
| ], | |
| Task::STATUS_COMPLETED => [ | |
| 'label' => Yii::t('TasksModule.base', 'Finish Task'), | |
| 'icon' => 'fa-check-square-o' | |
| ], | |
| ]; | |
| } | |
| protected function revertConfig($user = null) | |
| { | |
| return []; | |
| } | |
| public function checkProceedRules($newStatus = null, $user = null) | |
| { | |
| return $this->task->isTaskResponsible($user) || $this->task->isTaskAssigned($user) || $this->task->canProcess($user); | |
| } | |
| public function afterRevert(TaskState $oldState) | |
| { | |
| if ($this->task->hasItems()) { | |
| $this->task->checklist->resetItems(); | |
| } | |
| $this->notifyReset(); | |
| } | |
| public function notifyReset() | |
| { | |
| $this->task->deleteOldNotifications(); | |
| $user = Yii::$app->user->getIdentity(); | |
| TaskResetNotification::instance()->from($user)->about($this->task)->sendBulk($this->task->users); | |
| TaskResetActivity::instance()->from($user)->about($this->task)->create(); | |
| } | |
| public function checkRevertRules($newStatus = null, $user = null) | |
| { | |
| return false; | |
| } | |
| public function afterProceed(TaskState $oldState) | |
| { | |
| // We can't proceed to a pending state (only revert) | |
| } | |
| } |