Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
Account.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 
37  class Account extends OwnedSecurableItem implements StarredInterface
38  {
39  public static function getByName($name)
40  {
41  return self::getByNameOrEquivalent('name', $name);
42  }
43 
44  public function __toString()
45  {
46  try
47  {
48  if (trim($this->name) == '')
49  {
50  return Zurmo::t('Core', '(Unnamed)');
51  }
52  return $this->name;
53  }
55  {
56  return '';
57  }
58  }
59 
60  public static function getModuleClassName()
61  {
62  return 'AccountsModule';
63  }
64 
65  public static function canSaveMetadata()
66  {
67  return true;
68  }
69 
70  public static function getDefaultMetadata()
71  {
72  $metadata = parent::getDefaultMetadata();
73  $metadata[__CLASS__] = array(
74  'members' => array(
75  'annualRevenue',
76  'description',
77  'employees',
78  'latestActivityDateTime',
79  'name',
80  'officePhone',
81  'officeFax',
82  'website',
83  ),
84  'relations' => array(
85  'account' => array(static::HAS_MANY_BELONGS_TO, 'Account'),
86  'primaryAccountAffiliations' => array(static::HAS_MANY, 'AccountAccountAffiliation',
87  static::OWNED, static::LINK_TYPE_SPECIFIC,
88  'primaryAccountAffiliation'),
89  'secondaryAccountAffiliations' => array(static::HAS_MANY, 'AccountAccountAffiliation',
90  static::OWNED, static::LINK_TYPE_SPECIFIC,
91  'secondaryAccountAffiliation'),
92  'accounts' => array(static::HAS_MANY, 'Account'),
93  'billingAddress' => array(static::HAS_ONE, 'Address', static::OWNED,
94  static::LINK_TYPE_SPECIFIC, 'billingAddress'),
95  'products' => array(static::HAS_MANY, 'Product'),
96  'contactAffiliations' => array(static::HAS_MANY, 'AccountContactAffiliation',
97  static::OWNED, static::LINK_TYPE_SPECIFIC,
98  'accountAffiliation'),
99  'contacts' => array(static::HAS_MANY, 'Contact'),
100  'industry' => array(static::HAS_ONE, 'OwnedCustomField', static::OWNED,
101  static::LINK_TYPE_SPECIFIC, 'industry'),
102  'opportunities' => array(static::HAS_MANY, 'Opportunity'),
103  'primaryEmail' => array(static::HAS_ONE, 'Email', static::OWNED,
104  static::LINK_TYPE_SPECIFIC, 'primaryEmail'),
105  'secondaryEmail' => array(static::HAS_ONE, 'Email', static::OWNED,
106  static::LINK_TYPE_SPECIFIC, 'secondaryEmail'),
107  'shippingAddress' => array(static::HAS_ONE, 'Address', static::OWNED,
108  static::LINK_TYPE_SPECIFIC, 'shippingAddress'),
109  'type' => array(static::HAS_ONE, 'OwnedCustomField', static::OWNED,
110  static::LINK_TYPE_SPECIFIC, 'type'),
111  'projects' => array(static::MANY_MANY, 'Project'),
112  'notificationSubscribers' => array(static::HAS_MANY, 'NotificationSubscriber', static::OWNED,
113  static::LINK_TYPE_POLYMORPHIC, 'relatedModel'),
114  'comments' => array(static::HAS_MANY, 'Comment', static::OWNED,
115  static::LINK_TYPE_POLYMORPHIC, 'relatedModel')
116  ),
117  'derivedRelationsViaCastedUpModel' => array(
118  'meetings' => array(static::MANY_MANY, 'Meeting', 'activityItems'),
119  'notes' => array(static::MANY_MANY, 'Note', 'activityItems'),
120  'tasks' => array(static::MANY_MANY, 'Task', 'activityItems'),
121  ),
122  'rules' => array(
123  array('annualRevenue', 'type', 'type' => 'float'),
124  array('description', 'type', 'type' => 'string'),
125  array('employees', 'type', 'type' => 'integer'),
126  array('latestActivityDateTime', 'readOnly'),
127  array('latestActivityDateTime', 'type', 'type' => 'datetime'),
128  array('name', 'required'),
129  array('name', 'type', 'type' => 'string'),
130  array('name', 'length', 'min' => 1, 'max' => 64),
131  array('officePhone', 'type', 'type' => 'string'),
132  array('officePhone', 'length', 'min' => 1, 'max' => 24),
133  array('officeFax', 'type', 'type' => 'string'),
134  array('officeFax', 'length', 'min' => 1, 'max' => 24),
135  array('website', 'url', 'defaultScheme' => 'http'),
136  ),
137  'elements' => array(
138  'account' => 'Account',
139  'billingAddress' => 'Address',
140  'description' => 'TextArea',
141  'latestActivityDateTime' => 'DateTime',
142  'officePhone' => 'Phone',
143  'officeFax' => 'Phone',
144  'primaryEmail' => 'EmailAddressInformation',
145  'secondaryEmail' => 'EmailAddressInformation',
146  'shippingAddress' => 'Address',
147  ),
148  'customFields' => array(
149  'industry' => 'Industries',
150  'type' => 'AccountTypes',
151  ),
152  'defaultSortAttribute' => 'name',
153  'rollupRelations' => array(
154  'accounts' => array('contacts', 'opportunities'),
155  'contacts',
156  'opportunities'
157  ),
158  'noAudit' => array(
159  'annualRevenue',
160  'description',
161  'employees',
162  'latestActivityDateTime',
163  'website',
164  ),
165  );
166  return $metadata;
167  }
168 
169  public static function isTypeDeletable()
170  {
171  return true;
172  }
173 
174  public static function getRollUpRulesType()
175  {
176  return 'Account';
177  }
178 
179  public static function hasReadPermissionsOptimization()
180  {
181  return true;
182  }
183 
184  public static function getGamificationRulesType()
185  {
186  return 'AccountGamification';
187  }
188 
189  protected static function translatedAttributeLabels($language)
190  {
192  $paramsForAffiliations = $params;
193  $paramsForAffiliations['{primaryAccount}'] = AccountAccountAffiliationsModule::resolveAccountRelationLabel('Singular', 'primary');
194  $paramsForAffiliations['{secondaryAccount}'] = AccountAccountAffiliationsModule::resolveAccountRelationLabel('Singular', 'secondary');
195  return array_merge(parent::translatedAttributeLabels($language),
196  array(
197  'account' => Zurmo::t('AccountsModule', 'Parent AccountsModuleSingularLabel', $params, null, $language),
198  'accounts' => Zurmo::t('AccountsModule', 'AccountsModulePluralLabel', $params, null, $language),
199  'annualRevenue' => Zurmo::t('AccountsModule', 'Annual Revenue', array(), null, $language),
200  'billingAddress' => Zurmo::t('AccountsModule', 'Billing Address', array(), null, $language),
201  'contacts' => Zurmo::t('ContactsModule', 'ContactsModulePluralLabel', $params, null, $language),
202  'description' => Zurmo::t('ZurmoModule', 'Description', array(), null, $language),
203  'employees' => Zurmo::t('AccountsModule', 'Employees', array(), null, $language),
204  'industry' => Zurmo::t('ZurmoModule', 'Industry', array(), null, $language),
205  'latestActivityDateTime' => Zurmo::t('ZurmoModule', 'Latest Activity Date Time', array(), null, $language),
206  'meetings' => Zurmo::t('MeetingsModule', 'MeetingsModulePluralLabel', $params, null, $language),
207  'name' => Zurmo::t('Core', 'Name', array(), null, $language),
208  'notes' => Zurmo::t('NotesModule', 'NotesModulePluralLabel', $params, null, $language),
209  'officePhone' => Zurmo::t('ZurmoModule', 'Office Phone', array(), null, $language),
210  'officeFax' => Zurmo::t('ZurmoModule', 'Office Fax', array(), null, $language),
211  'opportunities' => Zurmo::t('OpportunitiesModule', 'OpportunitiesModulePluralLabel', $params, null, $language),
212  'primaryAccountAffiliations' =>
213  Zurmo::t('AccountAccountAffiliationsModule', '{primaryAccount} Affiliations', $paramsForAffiliations, null, $language),
214  'primaryEmail' => Zurmo::t('ZurmoModule', 'Primary Email', array(), null, $language),
215  'secondaryAccountAffiliations' =>
216  Zurmo::t('AccountAccountAffiliationsModule', '{secondaryAccount} Affiliations', $paramsForAffiliations, null, $language),
217  'secondaryEmail' => Zurmo::t('ZurmoModule', 'Secondary Email', array(), null, $language),
218  'shippingAddress' => Zurmo::t('AccountsModule', 'Shipping Address', array(), null, $language),
219  'tasks' => Zurmo::t('TasksModule', 'TasksModulePluralLabel', $params, null, $language),
220  'type' => Zurmo::t('Core', 'Type', array(), null, $language),
221  'website' => Zurmo::t('ZurmoModule', 'Website', array(), null, $language),
222  )
223  );
224  }
225 
226  public static function hasReadPermissionsSubscriptionOptimization()
227  {
228  return true;
229  }
230 
231  public function setLatestActivityDateTime($dateTime)
232  {
233  assert('is_string($dateTime)');
234  AuditUtil::saveOriginalAttributeValue($this, 'latestActivityDateTime', $dateTime);
235  $this->unrestrictedSet('latestActivityDateTime', $dateTime);
236  }
237 
243  public function isAllowedToSetReadOnlyAttribute($attributeName)
244  {
245  if ($this->getScenario() == 'importModel' || $this->getScenario() == 'searchModel')
246  {
247  if ( $attributeName == 'latestActivityDateTime')
248  {
249  return true;
250  }
251  else
252  {
253  return parent::isAllowedToSetReadOnlyAttribute($attributeName);
254  }
255  }
256  }
257 
258  protected function beforeSave()
259  {
260  if (parent::beforeSave())
261  {
263  Yii::app()->custom->resolveAccountCustomActionsBeforeSave($this);
264  return true;
265  }
266  else
267  {
268  return false;
269  }
270  }
271 
272  protected function afterSave()
273  {
274  if (!$this->isNewModel)
275  {
276  $this->logAuditEventForNameChange();
277  }
278  parent::afterSave();
279  }
280 
281  protected function logAuditEventForNameChange()
282  {
283  if (isset($this->originalAttributeValues['name']) && $this->originalAttributeValues['name'] != $this->name)
284  {
285  $modelClassName = get_class($this);
286  $data = array('oldName' => $this->originalAttributeValues['name'],
287  'newName' => $this->name);
288  AuditEvent::logAuditEvent($modelClassName::getModuleClassName(),
289  ZurmoModule::AUDIT_EVENT_ITEM_NAME_CHANGED, $data, $this);
290  }
291  }
292 
296  protected function resolveAndSetDefaultSubscribers()
297  {
298  NotificationSubscriberUtil::addSubscriber($this->owner, $this, false);
299  }
300  }
301 ?>
static addSubscriber(User $user, OwnedSecurableItem $model, $hasReadLatest=false)
static getTranslationParamsForAllModules()
Definition: LabelUtil.php:75
resolveAndSetDefaultSubscribers()
Definition: Account.php:296
static saveOriginalAttributeValue($auditableModel, $attributeName, $value)
Definition: AuditUtil.php:66
unrestrictedSet($attributeName, $value)
isAllowedToSetReadOnlyAttribute($attributeName)
Definition: Account.php:243
Generated on Fri Sep 25 2020 07:10:28
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.