Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
Contact.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 Contact extends Person implements StarredInterface
38  {
39  public static function getByName($name)
40  {
41  return ZurmoModelSearch::getModelsByFullName('Contact', $name);
42  }
43 
44  protected static function translatedAttributeLabels($language)
45  {
47  return array_merge(parent::translatedAttributeLabels($language),
48  array(
49  'account' => Zurmo::t('AccountsModule', 'AccountsModuleSingularLabel', $params, null, $language),
50  'companyName' => Zurmo::t('ContactsModule', 'Company Name', array(), null, $language),
51  'description' => Zurmo::t('ZurmoModule', 'Description', array(), null, $language),
52  'industry' => Zurmo::t('ZurmoModule', 'Industry', array(), null, $language),
53  'latestActivityDateTime' => Zurmo::t('ZurmoModule', 'Latest Activity Date Time', array(), null, $language),
54  'meetings' => Zurmo::t('MeetingsModule', 'MeetingsModulePluralLabel', $params, null, $language),
55  'notes' => Zurmo::t('NotesModule', 'NotesModulePluralLabel', $params, null, $language),
56  'opportunities' => Zurmo::t('OpportunitiesModule', 'OpportunitiesModulePluralLabel', $params, null, $language),
57  'secondaryAddress' => Zurmo::t('ContactsModule', 'Secondary Address', array(), null, $language),
58  'secondaryEmail' => Zurmo::t('ZurmoModule', 'Secondary Email', array(), null, $language),
59  'source' => Zurmo::t('ContactsModule', 'Source', $params, null, $language),
60  'state' => Zurmo::t('ZurmoModule', 'Status', $params, null, $language),
61  'tasks' => Zurmo::t('TasksModule', 'TasksModulePluralLabel', $params, null, $language),
62  'website' => Zurmo::t('ZurmoModule', 'Website', array(), null, $language),
63  'twitterId' => Zurmo::t('ContactsModule', 'Twitter ID', array(), null, $language),
64  'facebookId' => Zurmo::t('ContactsModule', 'Facebook ID', array(), null, $language),
65  ),
66  Yii::app()->custom->resolveCustomTranslatedAttributeLabelsByModelClassName(get_called_class(), $language)
67  );
68  }
69 
70  public static function getModuleClassName()
71  {
72  return 'ContactsModule';
73  }
74 
75  public static function canSaveMetadata()
76  {
77  return true;
78  }
79 
80  public static function getDefaultMetadata()
81  {
82  $metadata = parent::getDefaultMetadata();
83  $metadata[__CLASS__] = array(
84  'members' => array(
85  'companyName',
86  'description',
87  'latestActivityDateTime',
88  'website',
89  'googleWebTrackingId',
90  'twitterId',
91  'facebookId',
92  ),
93  'relations' => array(
94  'account' => array(static::HAS_ONE, 'Account'),
95  'accountAffiliations' => array(static::HAS_MANY, 'AccountContactAffiliation',
96  static::OWNED, static::LINK_TYPE_SPECIFIC,
97  'contactAffiliation'),
98  'industry' => array(static::HAS_ONE, 'OwnedCustomField', static::OWNED,
99  static::LINK_TYPE_SPECIFIC, 'industry'),
100  'products' => array(static::HAS_MANY, 'Product'),
101  'opportunities' => array(static::MANY_MANY, 'Opportunity'),
102  'secondaryAddress' => array(static::HAS_ONE, 'Address', static::OWNED,
103  static::LINK_TYPE_SPECIFIC, 'secondaryAddress'),
104  'secondaryEmail' => array(static::HAS_ONE, 'Email', static::OWNED,
105  static::LINK_TYPE_SPECIFIC, 'secondaryEmail'),
106  'source' => array(static::HAS_ONE, 'OwnedCustomField', static::OWNED,
107  static::LINK_TYPE_SPECIFIC, 'source'),
108  'state' => array(static::HAS_ONE, 'ContactState', static::NOT_OWNED,
109  static::LINK_TYPE_SPECIFIC, 'state'),
110  'projects' => array(static::MANY_MANY, 'Project'),
111  'notificationSubscribers' => array(static::HAS_MANY, 'NotificationSubscriber', static::OWNED,
112  static::LINK_TYPE_POLYMORPHIC, 'relatedModel'),
113  'comments' => array(static::HAS_MANY, 'Comment', static::OWNED,
114  static::LINK_TYPE_POLYMORPHIC, 'relatedModel')
115  ),
116  'derivedRelationsViaCastedUpModel' => array(
117  'meetings' => array(static::MANY_MANY, 'Meeting', 'activityItems'),
118  'notes' => array(static::MANY_MANY, 'Note', 'activityItems'),
119  'tasks' => array(static::MANY_MANY, 'Task', 'activityItems'),
120  ),
121  'rules' => array(
122  array('companyName', 'type', 'type' => 'string'),
123  array('companyName', 'length', 'min' => 1, 'max' => 64),
124  array('description', 'type', 'type' => 'string'),
125  array('latestActivityDateTime', 'readOnly'),
126  array('latestActivityDateTime', 'type', 'type' => 'datetime'),
127  array('state', 'required'),
128  array('website', 'url', 'defaultScheme' => 'http'),
129  array('googleWebTrackingId', 'type', 'type' => 'string'),
130  array('twitterId', 'type', 'type' => 'string'),
131  array('facebookId', 'type', 'type' => 'string'),
132  ),
133  'elements' => array(
134  'account' => 'Account',
135  'description' => 'TextArea',
136  'latestActivityDateTime' => 'DateTime',
137  'secondaryEmail' => 'EmailAddressInformation',
138  'secondaryAddress' => 'Address',
139  'state' => 'ContactState',
140  ),
141  'customFields' => array(
142  'industry' => 'Industries',
143  'source' => 'LeadSources',
144  ),
145  'defaultSortAttribute' => 'lastName',
146  'rollupRelations' => array(
147  'opportunities',
148  ),
149  'noAudit' => array(
150  'description',
151  'latestActivityDateTime',
152  'website'
153  ),
154  'indexes' => array(
155  'person_id' => array(
156  'members' => array('person_id'),
157  'unique' => false),
158  ),
159  );
160  return $metadata;
161  }
162 
163  public static function isTypeDeletable()
164  {
165  return true;
166  }
167 
168  public static function getRollUpRulesType()
169  {
170  return 'Contact';
171  }
172 
173  public static function hasReadPermissionsOptimization()
174  {
175  return true;
176  }
177 
178  public static function getGamificationRulesType()
179  {
180  return 'ContactGamification';
181  }
182 
189  protected static function getLabel($language = null)
190  {
191  if (null != $moduleClassName = static::getModuleClassName())
192  {
193  return $moduleClassName::getModuleLabelByTypeAndLanguage('Singular', $language);
194  }
195  return get_called_class();
196  }
197 
204  protected static function getPluralLabel($language = null)
205  {
206  if (null != $moduleClassName = static::getModuleClassName())
207  {
208  return $moduleClassName::getModuleLabelByTypeAndLanguage('Plural', $language);
209  }
210  return static::getLabel($language) . 's';
211  }
212 
213  public static function hasReadPermissionsSubscriptionOptimization()
214  {
215  return true;
216  }
217 
218  public static function supportsQueueing()
219  {
220  return true;
221  }
222 
223  public function setLatestActivityDateTime($dateTime)
224  {
225  assert('is_string($dateTime)');
226  AuditUtil::saveOriginalAttributeValue($this, 'latestActivityDateTime', $dateTime);
227  $this->unrestrictedSet('latestActivityDateTime', $dateTime);
228  }
229 
230  protected function afterDelete()
231  {
232  parent::afterDelete();
234  }
235 
241  public function isAllowedToSetReadOnlyAttribute($attributeName)
242  {
243  if ($this->getScenario() == 'importModel' || $this->getScenario() == 'searchModel')
244  {
245  if ( $attributeName == 'latestActivityDateTime')
246  {
247  return true;
248  }
249  else
250  {
251  return parent::isAllowedToSetReadOnlyAttribute($attributeName);
252  }
253  }
254  }
255 
256  public static function getAllowedCastedUpAttributeNames()
257  {
258  return array('title');
259  }
260 
261  protected function beforeSave()
262  {
263  if (parent::beforeSave())
264  {
266  return true;
267  }
268  else
269  {
270  return false;
271  }
272  }
273 
277  protected function resolveAndSetDefaultSubscribers()
278  {
279  NotificationSubscriberUtil::addSubscriber($this->owner, $this, false);
280  }
281  }
282 ?>
static resolveMarketingListMembersByContact($contact)
static addSubscriber(User $user, OwnedSecurableItem $model, $hasReadLatest=false)
static getModelsByFullName($modelClassName, $fullName)
static getTranslationParamsForAllModules()
Definition: LabelUtil.php:75
static getLabel($language=null)
Definition: Contact.php:189
static saveOriginalAttributeValue($auditableModel, $attributeName, $value)
Definition: AuditUtil.php:66
static getPluralLabel($language=null)
Definition: Contact.php:204
resolveAndSetDefaultSubscribers()
Definition: Contact.php:277
isAllowedToSetReadOnlyAttribute($attributeName)
Definition: Contact.php:241
unrestrictedSet($attributeName, $value)
Generated on Fri Sep 25 2020 07:10:29
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.