All Data Structures Functions Variables Pages
Person.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 Person extends OwnedSecurableItem
38  {
39  public function __toString()
40  {
41  try
42  {
43  $fullName = $this->getFullName();
44  if ($fullName == '')
45  {
46  return Zurmo::t('Core', '(Unnamed)');
47  }
48  return $fullName;
49  }
51  {
52  return '';
53  }
54  }
55 
60  protected static function getModifiedSignalAttribute()
61  {
62  return 'lastName';
63  }
64 
65  public function getFullName()
66  {
67  $fullName = array();
68  if ($this->firstName != '')
69  {
70  $fullName[] = $this->firstName;
71  }
72  if ($this->lastName != '')
73  {
74  $fullName[] = $this->lastName;
75  }
76  return join(' ' , $fullName);
77  }
78 
85  public static function getTranslatedAttributeLabels($language)
86  {
87  return static::translatedAttributeLabels($language);
88  }
89 
90  protected static function translatedAttributeLabels($language)
91  {
92  return array_merge(parent::translatedAttributeLabels($language),
93  array(
94  'department' => Zurmo::t('ZurmoModule', 'Department', array(), null, $language),
95  'firstName' => Zurmo::t('ZurmoModule', 'First Name', array(), null, $language),
96  'fullName' => Zurmo::t('Core', 'Name', array(), null, $language),
97  'jobTitle' => Zurmo::t('ZurmoModule', 'Job Title', array(), null, $language),
98  'lastName' => Zurmo::t('ZurmoModule', 'Last Name', array(), null, $language),
99  'mobilePhone' => Zurmo::t('ZurmoModule', 'Mobile Phone', array(), null, $language),
100  'officePhone' => Zurmo::t('ZurmoModule', 'Office Phone', array(), null, $language),
101  'officeFax' => Zurmo::t('ZurmoModule', 'Office Fax', array(), null, $language),
102  'primaryAddress' => Zurmo::t('ZurmoModule', 'Primary Address', array(), null, $language),
103  'primaryEmail' => Zurmo::t('ZurmoModule', 'Primary Email', array(), null, $language),
104  'title' => Zurmo::t('ZurmoModule', 'Salutation', array(), null, $language)
105  )
106  );
107  }
108 
114  protected static function getLabel($language = null)
115  {
116  return Zurmo::t('ZurmoModule', 'Person', array(), null, $language);
117  }
118 
124  protected static function getPluralLabel($language = null)
125  {
126  return Zurmo::t('ZurmoModule', 'People', array(), null, $language);
127  }
128 
129  public static function getDefaultMetadata()
130  {
131  $metadata = parent::getDefaultMetadata();
132  $metadata[__CLASS__] = array(
133  'members' => array(
134  'department',
135  'firstName',
136  'jobTitle',
137  'lastName',
138  'mobilePhone',
139  'officePhone',
140  'officeFax',
141  ),
142  'relations' => array(
143  'primaryAddress' => array(static::HAS_ONE, 'Address', static::OWNED,
144  static::LINK_TYPE_SPECIFIC, 'primaryAddress'),
145  'primaryEmail' => array(static::HAS_ONE, 'Email', static::OWNED,
146  static::LINK_TYPE_SPECIFIC, 'primaryEmail'),
147  'title' => array(static::HAS_ONE, 'OwnedCustomField', static::OWNED,
148  static::LINK_TYPE_SPECIFIC, 'title'),
149  ),
150  'rules' => array(
151  array('department', 'type', 'type' => 'string'),
152  array('department', 'length', 'min' => 1, 'max' => 64),
153  array('firstName', 'type', 'type' => 'string'),
154  array('firstName', 'length', 'min' => 1, 'max' => 32),
155  array('jobTitle', 'type', 'type' => 'string'),
156  array('jobTitle', 'length', 'min' => 1, 'max' => 64),
157  array('lastName', 'required'),
158  array('lastName', 'type', 'type' => 'string'),
159  array('lastName', 'length', 'min' => 1, 'max' => 32),
160  array('mobilePhone', 'type', 'type' => 'string'),
161  array('mobilePhone', 'length', 'min' => 1, 'max' => 24),
162  array('officePhone', 'type', 'type' => 'string'),
163  array('officePhone', 'length', 'min' => 1, 'max' => 24),
164  array('officeFax', 'type', 'type' => 'string'),
165  array('officeFax', 'length', 'min' => 1, 'max' => 24),
166  ),
167  'elements' => array(
168  'mobilePhone' => 'Phone',
169  'officePhone' => 'Phone',
170  'officeFax' => 'Phone',
171  'primaryEmail' => 'EmailAddressInformation',
172  'primaryAddress' => 'Address',
173  ),
174  'customFields' => array(
175  'title' => 'Titles',
176  ),
177  'indexes' => array(
178  'ownedsecurableitem_id' => array(
179  'members' => array('ownedsecurableitem_id'),
180  'unique' => false),
181  ),
182  );
183  return $metadata;
184  }
185 
186  public static function isTypeDeletable()
187  {
188  return false;
189  }
190 
194  public static function getSortAttributesByAttribute($attribute)
195  {
196  if ($attribute == 'firstName')
197  {
198  return array('firstName', 'lastName');
199  }
200  return parent::getSortAttributesByAttribute($attribute);
201  }
202 
203  public static function getModuleClassName()
204  {
205  return 'ZurmoModule';
206  }
207  }
208 ?>
static getModifiedSignalAttribute()
Definition: Person.php:60
static getTranslatedAttributeLabels($language)
Definition: Person.php:85
static getSortAttributesByAttribute($attribute)
Definition: Person.php:194
static getLabel($language=null)
Definition: Person.php:114
static getPluralLabel($language=null)
Definition: Person.php:124
Generated on Thu May 28 2020 07:10:35