| @@ 92-112 (lines=21) @@ | ||
| 89 | * |
|
| 90 | * @return boolean True if successful |
|
| 91 | */ |
|
| 92 | public function deploy() { |
|
| 93 | // Check permission |
|
| 94 | if(!$this->canTriggerDeploy()) { |
|
| 95 | return Security::permissionFailure( |
|
| 96 | null, |
|
| 97 | _t("TriggerDeployStep.DENYTRIGGERDEPLOY", |
|
| 98 | "You do not have permission to deploy this pipeline") |
|
| 99 | ); |
|
| 100 | } |
|
| 101 | ||
| 102 | if($this->Status == 'Queued') { |
|
| 103 | $this->start(); |
|
| 104 | } |
|
| 105 | // Trigger deployment |
|
| 106 | $this->Deployed = SS_Datetime::now()->Rfc2822(); |
|
| 107 | $this->log(_t('TriggerDeployStep.BEINGDEPLOYED', |
|
| 108 | "{$this->Title} is being deployed")); |
|
| 109 | $this->ResponderID = Member::currentUserID(); |
|
| 110 | $this->finish(); |
|
| 111 | return true; |
|
| 112 | } |
|
| 113 | ||
| 114 | /** |
|
| 115 | * Initiate the deployment process |
|
| @@ 182-201 (lines=20) @@ | ||
| 179 | * |
|
| 180 | * @return boolean True if successful |
|
| 181 | */ |
|
| 182 | public function approve() { |
|
| 183 | // Check permission |
|
| 184 | if(!$this->canApprove()) { |
|
| 185 | return Security::permissionFailure( |
|
| 186 | null, |
|
| 187 | _t("UserConfirmationStep.DENYAPPROVE", "You do not have permission to approve this deployment") |
|
| 188 | ); |
|
| 189 | } |
|
| 190 | ||
| 191 | // Skip subsequent approvals if already approved / rejected |
|
| 192 | if($this->hasResponse()) { |
|
| 193 | return; |
|
| 194 | } |
|
| 195 | ||
| 196 | // Approve |
|
| 197 | $this->Approval = 'Approved'; |
|
| 198 | $this->log("{$this->Title} has been approved"); |
|
| 199 | $this->ResponderID = Member::currentUserID(); |
|
| 200 | $this->finish(); |
|
| 201 | $this->sendMessage(self::ALERT_APPROVE); |
|
| 202 | return true; |
|
| 203 | } |
|
| 204 | ||
| @@ 210-229 (lines=20) @@ | ||
| 207 | * |
|
| 208 | * @return boolean True if successful |
|
| 209 | */ |
|
| 210 | public function reject() { |
|
| 211 | // Check permission |
|
| 212 | if(!$this->canApprove()) { |
|
| 213 | return Security::permissionFailure( |
|
| 214 | null, |
|
| 215 | _t("UserConfirmationStep.DENYREJECT", "You do not have permission to reject this deployment") |
|
| 216 | ); |
|
| 217 | } |
|
| 218 | ||
| 219 | // Skip subsequent approvals if already approved / rejected |
|
| 220 | if($this->hasResponse()) { |
|
| 221 | return; |
|
| 222 | } |
|
| 223 | ||
| 224 | // Reject |
|
| 225 | $this->Approval = 'Rejected'; |
|
| 226 | $this->log("{$this->Title} has been rejected"); |
|
| 227 | $this->ResponderID = Member::currentUserID(); |
|
| 228 | $this->markFailed(false); |
|
| 229 | $this->sendMessage(self::ALERT_REJECT); |
|
| 230 | return true; |
|
| 231 | } |
|
| 232 | ||