Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
UserWorkflowActionAttributeForm.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 
41  {
42  const TYPE_DYNAMIC_CREATED_BY_USER = 'DynamicCreatedByUser';
43 
44  const TYPE_DYNAMIC_MODIFIED_BY_USER = 'DynamicModifiedByUser';
45 
46  const TYPE_DYNAMIC_TRIGGERED_BY_USER = 'DynamicTriggeredByUser';
47 
48  const TYPE_DYNAMIC_OWNER_OF_TRIGGERED_MODEL = 'OwnerOfTriggeredModel';
49 
50  public function getValueElementType()
51  {
52  return 'UserNameId';
53  }
54 
59  public function validateValue()
60  {
61  if (parent::validateValue())
62  {
63  if ($this->type == self::TYPE_STATIC)
64  {
65  $validator = CValidator::createValidator('type', $this, 'value', array('type' => 'integer'));
66  $validator->allowEmpty = false;
67  $validator->validate($this);
68  return !$this->hasErrors();
69  }
70  else
71  {
72  if ($this->value != null)
73  {
74  $this->addError('value', Zurmo::t('WorkflowsModule', 'Value cannot be set'));
75  return false;
76  }
77  return true;
78  }
79  }
80  return false;
81  }
82 
83  public function getStringifiedModelForValue()
84  {
85  if ($this->value != null)
86  {
87  try
88  {
89  return strval(User::getById((int)$this->value));
90  }
91  catch (NotFoundException $e)
92  {
93  }
94  }
95  }
96 
104  {
105  assert('is_string($attribute)');
106  if ($this->type == WorkflowActionAttributeForm::TYPE_STATIC)
107  {
108  $adapter->getModel()->{$attribute} = User::getById((int)$this->value);
109  }
110  elseif ($this->type == self::TYPE_DYNAMIC_OWNER_OF_TRIGGERED_MODEL)
111  {
112  if ($adapter->getTriggeredModel() instanceof OwnedSecurableItem)
113  {
114  $adapter->getModel()->{$attribute} = $adapter->getTriggeredModel()->owner;
115  }
116  }
117  elseif ($this->type == self::TYPE_DYNAMIC_CREATED_BY_USER)
118  {
119  $adapter->getModel()->{$attribute} = $adapter->getTriggeredModel()->createdByUser;
120  }
121  elseif ($this->type == self::TYPE_DYNAMIC_MODIFIED_BY_USER)
122  {
123  $adapter->getModel()->{$attribute} = $adapter->getTriggeredModel()->modifiedByUser;
124  }
125  elseif ($this->type == self::TYPE_DYNAMIC_TRIGGERED_BY_USER)
126  {
127  $adapter->getModel()->{$attribute} = $adapter->getTriggeredByUser();
128  }
129  else
130  {
131  throw new NotSupportedException();
132  }
133  }
134 
135  protected function makeTypeValuesAndLabels($isCreatingNewModel, $isRequired)
136  {
137  $data = array();
138  $data[static::TYPE_STATIC] = Zurmo::t('WorkflowsModule', 'As');
139  $modelClassName = $this->modelClassName;
140  if ($isCreatingNewModel)
141  {
142  if (is_subclass_of($modelClassName, 'OwnedSecurableItem'))
143  {
144  $data[self::TYPE_DYNAMIC_OWNER_OF_TRIGGERED_MODEL] =
145  Zurmo::t('WorkflowsModule', 'As user who owns triggered record');
146  }
147  }
148  else
149  {
150  $data[self::TYPE_DYNAMIC_CREATED_BY_USER] =
151  Zurmo::t('WorkflowsModule', 'As user who created triggered record');
152  $data[self::TYPE_DYNAMIC_MODIFIED_BY_USER] =
153  Zurmo::t('WorkflowsModule', 'As user who last modified triggered record');
154  $data[self::TYPE_DYNAMIC_TRIGGERED_BY_USER] =
155  Zurmo::t('WorkflowsModule', 'As user who triggered action');
156  }
157  return $data;
158  }
159  }
160 ?>
resolveValueAndSetToModel(WorkflowActionProcessingModelAdapter $adapter, $attribute)
static getById($id, $modelClassName=null)
Generated on Tue Aug 4 2020 07:10:34
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.