‪TYPO3CMS  11.5
StageRecord.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
19 
24 {
28  protected ‪$workspace;
29 
33  protected ‪$internal = false;
34 
38  protected ‪$responsiblePersons;
39 
44 
48  protected ‪$preselectedRecipients;
49 
53  protected ‪$allRecipients;
54 
60  public static function get($uid, ?array ‪$record = null)
61  {
62  if (empty(‪$record)) {
63  ‪$record = static::fetch('sys_workspace_stage', $uid);
64  }
65  return ‪WorkspaceRecord::get(‪$record['parentid'])->‪getStage($uid);
66  }
67 
74  public static function ‪build(‪WorkspaceRecord ‪$workspace, $uid, ?array ‪$record = null)
75  {
76  if (empty(‪$record)) {
77  ‪$record = static::fetch('sys_workspace_stage', $uid);
78  }
79  return new self(‪$workspace, ‪$record);
80  }
81 
87  {
88  parent::__construct(‪$record);
89  $this->workspace = ‪$workspace;
90  }
91 
95  public function ‪getWorkspace()
96  {
98  }
99 
103  public function ‪getPrevious()
104  {
105  return $this->‪getWorkspace()->‪getPreviousStage($this->‪getUid());
106  }
107 
111  public function ‪getNext()
112  {
113  return $this->‪getWorkspace()->‪getNextStage($this->‪getUid());
114  }
115 
120  public function ‪determineOrder(‪StageRecord $stageRecord)
121  {
122  if ($this->‪getUid() === $stageRecord->‪getUid()) {
123  return 0;
124  }
125  if ($this->‪isEditStage() || $stageRecord->‪isExecuteStage() || $this->isPreviousTo($stageRecord)) {
126  return -1;
127  }
128  if ($this->‪isExecuteStage() || $stageRecord->‪isEditStage() || $this->isNextTo($stageRecord)) {
129  return 1;
130  }
131  return 0;
132  }
133 
140  public function ‪isPreviousTo(StageRecord $stageRecord)
141  {
142  $current = $stageRecord;
143  while ($previous = $current->getPrevious()) {
144  if ($this->‪getUid() === $previous->getUid()) {
145  return true;
146  }
147  $current = $previous;
148  }
149  return false;
150  }
151 
158  public function ‪isNextTo(StageRecord $stageRecord)
159  {
160  $current = $stageRecord;
161  while ($next = $current->getNext()) {
162  if ($this->‪getUid() === $next->getUid()) {
163  return true;
164  }
165  $current = $next;
166  }
167  return false;
168  }
169 
173  public function ‪getDefaultComment()
174  {
175  $defaultComment = '';
176  if (isset($this->record['default_mailcomment'])) {
177  $defaultComment = $this->record['default_mailcomment'];
178  }
179  return $defaultComment;
180  }
181 
185  public function ‪setInternal(‪$internal = true)
186  {
187  $this->internal = (bool)‪$internal;
188  }
189 
193  public function ‪isInternal()
194  {
196  }
197 
201  public function ‪isEditStage()
202  {
204  }
205 
209  public function ‪isPublishStage()
210  {
212  }
213 
217  public function ‪isExecuteStage()
218  {
220  }
221 
225  public function ‪isDialogEnabled()
226  {
227  return ((int)$this->record['allow_notificaton_settings'] & 1) > 0;
228  }
229 
233  public function ‪isPreselectionChangeable()
234  {
235  return ((int)$this->record['allow_notificaton_settings'] & 2) > 0;
236  }
237 
241  public function ‪areOwnersPreselected()
242  {
243  return ((int)$this->record['notification_preselection'] & 1) > 0;
244  }
245 
249  public function ‪areMembersPreselected()
250  {
251  return ((int)$this->record['notification_preselection'] & 2) > 0;
252  }
253 
257  public function ‪areEditorsPreselected()
258  {
259  return ((int)$this->record['notification_preselection'] & 4) > 0;
260  }
261 
265  public function ‪areResponsiblePersonsPreselected()
266  {
267  return ((int)$this->record['notification_preselection'] & 8) > 0;
268  }
269 
273  public function ‪hasDefaultRecipients(): bool
274  {
275  return $this->record['notification_defaults'] !== '';
276  }
277 
281  public function ‪hasPreselection()
282  {
283  return
284  $this->‪areOwnersPreselected()
285  || $this->‪areMembersPreselected()
286  || $this->‪areEditorsPreselected()
288  || $this->‪hasDefaultRecipients()
289  ;
290  }
291 
295  public function ‪getResponsiblePersons()
296  {
297  if (!isset($this->responsiblePersons)) {
298  $this->responsiblePersons = [];
299  if (!empty($this->record['responsible_persons'])) {
300  $this->responsiblePersons = $this->‪getStagesService()->‪resolveBackendUserIds($this->record['responsible_persons']);
301  }
302  }
304  }
305 
309  public function ‪getDefaultRecipients()
310  {
311  if (!isset($this->defaultRecipients)) {
312  $this->defaultRecipients = $this->‪getStagesService()->‪resolveBackendUserIds($this->record['notification_defaults']);
313  }
315  }
316 
322  public function ‪getAllRecipients()
323  {
324  if (!isset($this->allRecipients)) {
326 
327  if ($this->‪isInternal() || $this->‪areOwnersPreselected()) {
328  ‪$allRecipients = array_merge(‪$allRecipients, $this->‪getWorkspace()->getOwners());
329  }
330  if ($this->‪isInternal() || $this->‪areMembersPreselected()) {
331  ‪$allRecipients = array_merge(‪$allRecipients, $this->‪getWorkspace()->getMembers());
332  }
333  if (!$this->‪isInternal()) {
335  }
336 
337  $this->allRecipients = array_unique(‪$allRecipients);
338  }
339 
341  }
342 
346  public function ‪getPreselectedRecipients()
347  {
348  if (!isset($this->preselectedRecipients)) {
350 
351  if ($this->‪areOwnersPreselected()) {
352  ‪$preselectedRecipients = array_merge(‪$preselectedRecipients, $this->‪getWorkspace()->getOwners());
353  }
354  if ($this->‪areMembersPreselected()) {
355  ‪$preselectedRecipients = array_merge(‪$preselectedRecipients, $this->‪getWorkspace()->getMembers());
356  }
359  }
360 
361  $this->preselectedRecipients = array_unique(‪$preselectedRecipients);
362  }
363 
365  }
366 
370  public function ‪isAllowed()
371  {
372  return
373  $this->‪isEditStage()
374  || static::getBackendUser()->workspaceCheckStageForCurrent($this->‪getUid())
375  || $this->‪isExecuteStage() && static::getBackendUser()->workspacePublishAccess($this->workspace->getUid())
376  ;
377  }
378 }
‪TYPO3\CMS\Workspaces\Domain\Record\StageRecord\getDefaultRecipients
‪array getDefaultRecipients()
Definition: StageRecord.php:303
‪TYPO3\CMS\Workspaces\Domain\Record\StageRecord\areEditorsPreselected
‪bool areEditorsPreselected()
Definition: StageRecord.php:251
‪TYPO3\CMS\Workspaces\Domain\Record\StageRecord\determineOrder
‪int determineOrder(StageRecord $stageRecord)
Definition: StageRecord.php:114
‪TYPO3\CMS\Workspaces\Domain\Record\StageRecord\hasDefaultRecipients
‪bool hasDefaultRecipients()
Definition: StageRecord.php:267
‪TYPO3\CMS\Workspaces\Domain\Record\AbstractRecord\getUid
‪int getUid()
Definition: AbstractRecord.php:88
‪TYPO3\CMS\Workspaces\Domain\Record\StageRecord\$preselectedRecipients
‪array null $preselectedRecipients
Definition: StageRecord.php:43
‪TYPO3\CMS\Workspaces\Domain\Record\StageRecord\getAllRecipients
‪array getAllRecipients()
Definition: StageRecord.php:316
‪TYPO3\CMS\Workspaces\Domain\Record\StageRecord\$workspace
‪WorkspaceRecord $workspace
Definition: StageRecord.php:27
‪TYPO3\CMS\Workspaces\Domain\Record\StageRecord\getResponsiblePersons
‪array getResponsiblePersons()
Definition: StageRecord.php:289
‪TYPO3\CMS\Workspaces\Domain\Record\WorkspaceRecord\getPreviousStage
‪StageRecord null getPreviousStage($stageId)
Definition: WorkspaceRecord.php:160
‪TYPO3\CMS\Workspaces\Domain\Record\StageRecord\isDialogEnabled
‪bool isDialogEnabled()
Definition: StageRecord.php:219
‪TYPO3\CMS\Workspaces\Domain\Record\StageRecord\build
‪static StageRecord build(WorkspaceRecord $workspace, $uid, ?array $record=null)
Definition: StageRecord.php:68
‪TYPO3\CMS\Workspaces\Domain\Record\StageRecord\isPreviousTo
‪bool isPreviousTo(StageRecord $stageRecord)
Definition: StageRecord.php:134
‪TYPO3\CMS\Workspaces\Domain\Record\StageRecord\$internal
‪bool $internal
Definition: StageRecord.php:31
‪TYPO3\CMS\Workspaces\Domain\Record
Definition: AbstractRecord.php:16
‪TYPO3\CMS\Workspaces\Domain\Record\WorkspaceRecord
Definition: WorkspaceRecord.php:27
‪TYPO3\CMS\Workspaces\Service\StagesService\STAGE_PUBLISH_EXECUTE_ID
‪const STAGE_PUBLISH_EXECUTE_ID
Definition: StagesService.php:35
‪TYPO3\CMS\Workspaces\Domain\Record\StageRecord\areMembersPreselected
‪bool areMembersPreselected()
Definition: StageRecord.php:243
‪TYPO3\CMS\Workspaces\Domain\Record\StageRecord\getPreselectedRecipients
‪int[] getPreselectedRecipients()
Definition: StageRecord.php:340
‪TYPO3\CMS\Workspaces\Domain\Record\WorkspaceRecord\getNextStage
‪StageRecord null getNextStage($stageId)
Definition: WorkspaceRecord.php:179
‪TYPO3\CMS\Workspaces\Service\StagesService\STAGE_PUBLISH_ID
‪const STAGE_PUBLISH_ID
Definition: StagesService.php:37
‪TYPO3\CMS\Workspaces\Domain\Record\StageRecord\$allRecipients
‪array null $allRecipients
Definition: StageRecord.php:47
‪TYPO3\CMS\Workspaces\Domain\Record\StageRecord\getWorkspace
‪WorkspaceRecord getWorkspace()
Definition: StageRecord.php:89
‪TYPO3\CMS\Workspaces\Domain\Record\StageRecord\isEditStage
‪bool isEditStage()
Definition: StageRecord.php:195
‪TYPO3\CMS\Workspaces\Domain\Record\AbstractRecord
Definition: AbstractRecord.php:28
‪TYPO3\CMS\Workspaces\Domain\Record\StageRecord
Definition: StageRecord.php:24
‪TYPO3\CMS\Workspaces\Domain\Record\StageRecord\areOwnersPreselected
‪bool areOwnersPreselected()
Definition: StageRecord.php:235
‪TYPO3\CMS\Workspaces\Domain\Record\StageRecord\$defaultRecipients
‪array null $defaultRecipients
Definition: StageRecord.php:39
‪TYPO3\CMS\Workspaces\Domain\Record\StageRecord\isNextTo
‪bool isNextTo(StageRecord $stageRecord)
Definition: StageRecord.php:152
‪TYPO3\CMS\Workspaces\Domain\Record\AbstractRecord\getStagesService
‪StagesService getStagesService()
Definition: AbstractRecord.php:104
‪TYPO3\CMS\Workspaces\Domain\Record\StageRecord\setInternal
‪setInternal($internal=true)
Definition: StageRecord.php:179
‪TYPO3\CMS\Workspaces\Domain\Record\StageRecord\isPublishStage
‪bool isPublishStage()
Definition: StageRecord.php:203
‪TYPO3\CMS\Workspaces\Domain\Record\StageRecord\isInternal
‪bool isInternal()
Definition: StageRecord.php:187
‪TYPO3\CMS\Workspaces\Domain\Record\StageRecord\isAllowed
‪bool isAllowed()
Definition: StageRecord.php:364
‪TYPO3\CMS\Workspaces\Domain\Record\StageRecord\$responsiblePersons
‪array null $responsiblePersons
Definition: StageRecord.php:35
‪TYPO3\CMS\Workspaces\Service\StagesService\STAGE_EDIT_ID
‪const STAGE_EDIT_ID
Definition: StagesService.php:38
‪TYPO3\CMS\Workspaces\Service\StagesService
Definition: StagesService.php:32
‪TYPO3\CMS\Workspaces\Domain\Record\StageRecord\getNext
‪StageRecord null getNext()
Definition: StageRecord.php:105
‪TYPO3\CMS\Workspaces\Domain\Record\StageRecord\__construct
‪__construct(WorkspaceRecord $workspace, array $record)
Definition: StageRecord.php:80
‪TYPO3\CMS\Workspaces\Domain\Record\StageRecord\hasPreselection
‪bool hasPreselection()
Definition: StageRecord.php:275
‪TYPO3\CMS\Workspaces\Domain\Record\WorkspaceRecord\get
‪static WorkspaceRecord get($uid, ?array $record=null)
Definition: WorkspaceRecord.php:70
‪TYPO3\CMS\Workspaces\Domain\Record\StageRecord\getDefaultComment
‪string getDefaultComment()
Definition: StageRecord.php:167
‪TYPO3\CMS\Workspaces\Domain\Record\StageRecord\areResponsiblePersonsPreselected
‪bool areResponsiblePersonsPreselected()
Definition: StageRecord.php:259
‪TYPO3\CMS\Workspaces\Service\StagesService\resolveBackendUserIds
‪array resolveBackendUserIds($backendUserGroupList)
Definition: StagesService.php:451
‪TYPO3\CMS\Workspaces\Domain\Record\StageRecord\isPreselectionChangeable
‪bool isPreselectionChangeable()
Definition: StageRecord.php:227
‪TYPO3\CMS\Workspaces\Domain\Record\AbstractRecord\$record
‪array $record
Definition: AbstractRecord.php:31
‪TYPO3\CMS\Workspaces\Domain\Record\StageRecord\getPrevious
‪StageRecord null getPrevious()
Definition: StageRecord.php:97
‪TYPO3\CMS\Workspaces\Domain\Record\StageRecord\isExecuteStage
‪bool isExecuteStage()
Definition: StageRecord.php:211
‪TYPO3\CMS\Workspaces\Domain\Record\WorkspaceRecord\getStage
‪StageRecord null getStage($stageId)
Definition: WorkspaceRecord.php:146