Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
Workflow.php
1 <?php
2  /*********************************************************************************
3  * Zurmo is a customer relationship management program developed by
4  * Zurmo, Inc. Copyright (C) 2017 Zurmo Inc.
5  *
6  * Zurmo is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License version 3 as published by the
8  * Free Software Foundation with the addition of the following permission added
9  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10  * IN WHICH THE COPYRIGHT IS OWNED BY ZURMO, ZURMO DISCLAIMS THE WARRANTY
11  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12  *
13  * Zurmo is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Affero General Public License along with
19  * this program; if not, see http://www.gnu.org/licenses or write to the Free
20  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  * 02110-1301 USA.
22  *
23  * You can contact Zurmo, Inc. with a mailing address at 27 North Wacker Drive
24  * Suite 370 Chicago, IL 60606. or at email address contact@zurmo.com.
25  *
26  * The interactive user interfaces in original and modified versions
27  * of this program must display Appropriate Legal Notices, as required under
28  * Section 5 of the GNU Affero General Public License version 3.
29  *
30  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31  * these Appropriate Legal Notices must retain the display of the Zurmo
32  * logo and Zurmo copyright notice. If the display of the logo is not reasonably
33  * feasible for technical reasons, the Appropriate Legal Notices must display the words
34  * "Copyright Zurmo Inc. 2017. All rights reserved".
35  ********************************************************************************/
36 
44  class Workflow extends CComponent
45  {
46  const TYPE_ON_SAVE = 'OnSave';
47 
48  const TYPE_BY_TIME = 'ByTime';
49 
50  const TRIGGER_ON_NEW = 'New';
51 
52  const TRIGGER_ON_NEW_AND_EXISTING = 'NewAndExisting';
53 
54  const TRIGGER_ON_EXISTING = 'Existing';
55 
56  private $description;
57 
62  private $id;
63 
68  private $isActive;
69 
73  private $moduleClassName;
74 
78  private $name;
79 
84  private $order;
85 
90  private $triggerOn;
91 
96  private $type;
97 
101  private $triggersStructure;
102 
107  private $timeTriggerAttribute;
108 
112  private $timeTrigger;
113 
117  private $triggers = array();
118 
122  private $actions = array();
123 
127  private $emailMessages = array();
128 
132  private $timeTriggerRequireChangeToProcess = true;
133 
137  public static function getTypeDropDownArray()
138  {
139  return array(self::TYPE_ON_SAVE => Zurmo::t('WorkflowsModule', 'On-Save'),
140  self::TYPE_BY_TIME => Zurmo::t('WorkflowsModule', 'Time-Based'));
141  }
142 
149  {
150  $moduleClassNamesAndLabels = array();
151  $modules = Module::getModuleObjects();
152  foreach (self::getWorkflowSupportedModulesClassNamesCurrentUserHasAccessTo() as $moduleClassName)
153  {
154  if ($moduleClassName::getStateMetadataAdapterClassName() != null)
155  {
156  $workflowRules = WorkflowRules::makeByModuleClassName($moduleClassName);
157  $label = $workflowRules->getVariableStateModuleLabel(Yii::app()->user->userModel);
158  }
159  else
160  {
161  $label = $moduleClassName::getModuleLabelByTypeAndLanguage('Plural');
162  }
163  if ($label != null)
164  {
165  $moduleClassNamesAndLabels[$moduleClassName] = $label;
166  }
167  }
168  return $moduleClassNamesAndLabels;
169  }
170 
175  {
176  $moduleClassNames = array();
177  $modules = Module::getModuleObjects();
178  foreach ($modules as $module)
179  {
180  if ($module::canHaveWorkflow())
181  {
183  {
184  $moduleClassNames[] = get_class($module);
185  }
186  }
187  }
188  return $moduleClassNames;
189  }
190 
194  public function __toString()
195  {
196  if (trim($this->name) == '')
197  {
198  return Yii::t('Core', '(Unnamed)');
199  }
200  return $this->name;
201  }
202 
206  public function getDescription()
207  {
208  return $this->description;
209  }
210 
214  public function setDescription($description)
215  {
216  assert('is_string($description)');
217  $this->description = $description;
218  }
219 
223  public function getIsActive()
224  {
225  return $this->isActive;
226  }
227 
231  public function setIsActive($isActive)
232  {
233  assert('is_bool($isActive)');
234  $this->isActive = $isActive;
235  }
236 
240  public function getModuleClassName()
241  {
242  return $this->moduleClassName;
243  }
244 
248  public function setModuleClassName($moduleClassName)
249  {
250  assert('is_string($moduleClassName)');
251  $this->moduleClassName = $moduleClassName;
252  }
253 
257  public function getOrder()
258  {
259  return $this->order;
260  }
261 
265  public function setOrder($order)
266  {
267  assert('is_int($order)');
268  $this->order = $order;
269  }
270 
274  public function getTriggerOn()
275  {
276  return $this->triggerOn;
277  }
278 
282  public function setTriggerOn($triggerOn)
283  {
284  assert('$triggerOn == self::TRIGGER_ON_NEW || $triggerOn == self::TRIGGER_ON_NEW_AND_EXISTING ||
285  $triggerOn == self::TRIGGER_ON_EXISTING');
286  $this->triggerOn = $triggerOn;
287  }
288 
292  public function setTriggersStructure($triggersStructure)
293  {
294  assert('is_string($triggersStructure)');
295  $this->triggersStructure = $triggersStructure;
296  }
297 
301  public function getTriggersStructure()
302  {
303  return $this->triggersStructure;
304  }
305 
309  public function getId()
310  {
311  return $this->id;
312  }
313 
317  public function setId($id)
318  {
319  assert('is_int($id)');
320  $this->id = $id;
321  }
322 
326  public function getName()
327  {
328  return $this->name;
329  }
330 
334  public function setName($name)
335  {
336  assert('is_string($name)');
337  $this->name = $name;
338  }
339 
343  public function getType()
344  {
345  return $this->type;
346  }
347 
351  public function setType($type)
352  {
353  assert('$type == self::TYPE_ON_SAVE || $type == self::TYPE_BY_TIME');
354  $this->type = $type;
355  }
356 
360  public function isNew()
361  {
362  if ($this->id > 0)
363  {
364  return false;
365  }
366  return true;
367  }
368 
372  public function setTimeTriggerAttribute($timeTriggerAttribute)
373  {
374  assert('is_string($timeTriggerAttribute)');
375  $this->timeTriggerAttribute = $timeTriggerAttribute;
376  }
377 
381  public function getTimeTriggerAttribute()
382  {
383  return $this->timeTriggerAttribute;
384  }
385 
389  public function getTimeTrigger()
390  {
391  return $this->timeTrigger;
392  }
393 
397  public function setTimeTrigger(TimeTriggerForWorkflowForm $timeTrigger)
398  {
399  $this->timeTrigger = $timeTrigger;
400  }
401 
405  public function removeTimeTrigger()
406  {
407  $this->timeTrigger = null;
408  }
409 
413  public function getTriggers()
414  {
415  return $this->triggers;
416  }
417 
421  public function addTrigger(TriggerForWorkflowForm $trigger)
422  {
423  $this->triggers[] = $trigger;
424  }
425 
429  public function removeAllTriggers()
430  {
431  $this->triggers = array();
432  }
433 
437  public function getActions()
438  {
439  return $this->actions;
440  }
441 
445  public function addAction(ActionForWorkflowForm $action)
446  {
447  $this->actions[] = $action;
448  }
449 
453  public function removeAllActions()
454  {
455  $this->actions = array();
456  }
457 
461  public function getEmailMessages()
462  {
463  return $this->emailMessages;
464  }
465 
469  public function addEmailMessage(EmailMessageForWorkflowForm $emailMessage)
470  {
471  $this->emailMessages[] = $emailMessage;
472  }
473 
477  public function removeAllEmailMessages()
478  {
479  $this->emailMessages = array();
480  }
481 
486  {
487  return $this->timeTriggerRequireChangeToProcess;
488  }
489 
495  {
496  $this->timeTriggerRequireChangeToProcess = false;
497  }
498  }
499 ?>
setOrder($order)
Definition: Workflow.php:265
setId($id)
Definition: Workflow.php:317
getTriggersStructure()
Definition: Workflow.php:301
addEmailMessage(EmailMessageForWorkflowForm $emailMessage)
Definition: Workflow.php:469
removeAllTriggers()
Definition: Workflow.php:429
removeAllActions()
Definition: Workflow.php:453
static getWorkflowSupportedModulesClassNamesCurrentUserHasAccessTo()
Definition: Workflow.php:174
getIsActive()
Definition: Workflow.php:223
setTriggerOn($triggerOn)
Definition: Workflow.php:282
getTimeTriggerAttribute()
Definition: Workflow.php:381
doesTimeTriggerRequireChangeToProcess()
Definition: Workflow.php:485
setDescription($description)
Definition: Workflow.php:214
getTimeTrigger()
Definition: Workflow.php:389
setTriggersStructure($triggersStructure)
Definition: Workflow.php:292
static getModuleObjects()
Definition: Module.php:51
addAction(ActionForWorkflowForm $action)
Definition: Workflow.php:445
getModuleClassName()
Definition: Workflow.php:240
setTimeTriggerRequireChangeToProcessToFalse()
Definition: Workflow.php:494
removeAllEmailMessages()
Definition: Workflow.php:477
static canCurrentUserCanAccessModule($moduleClassName)
__toString()
Definition: Workflow.php:194
setType($type)
Definition: Workflow.php:351
addTrigger(TriggerForWorkflowForm $trigger)
Definition: Workflow.php:421
static getTypeDropDownArray()
Definition: Workflow.php:137
setIsActive($isActive)
Definition: Workflow.php:231
static getWorkflowSupportedModulesAndLabelsForCurrentUser()
Definition: Workflow.php:148
setTimeTriggerAttribute($timeTriggerAttribute)
Definition: Workflow.php:372
static makeByModuleClassName($moduleClassName)
removeTimeTrigger()
Definition: Workflow.php:405
setName($name)
Definition: Workflow.php:334
getTriggers()
Definition: Workflow.php:413
getEmailMessages()
Definition: Workflow.php:461
getTriggerOn()
Definition: Workflow.php:274
setTimeTrigger(TimeTriggerForWorkflowForm $timeTrigger)
Definition: Workflow.php:397
getOrder()
Definition: Workflow.php:257
getActions()
Definition: Workflow.php:437
setModuleClassName($moduleClassName)
Definition: Workflow.php:248
getDescription()
Definition: Workflow.php:206
Generated on Sun Jul 12 2020 07:10:35
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.