Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
AccountContactAffiliation.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 
38  {
43  public static function getByName($name)
44  {
45  throw new NotSupportedException();
46  }
47 
48  public static function getModuleClassName()
49  {
50  return 'AccountContactAffiliationsModule';
51  }
52 
58  protected static function getLabel($language = null)
59  {
60  return Zurmo::t('AccountContactAffiliationsModule',
61  'Account to Contact Affiliation', array(), null, $language);
62  }
63 
69  protected static function getPluralLabel($language = null)
70  {
71  return Zurmo::t('AccountContactAffiliationsModule',
72  'Account to Contact Affiliations', array(), null, $language);
73  }
74 
75  public static function getPrimaryByAccountIdAndContactId($accountId, $contactId)
76  {
77  assert('is_int($accountId)');
78  assert('is_int($contactId)');
79  $searchAttributeData = array();
80  $searchAttributeData['clauses'] = array(
81  1 => array(
82  'attributeName' => 'account',
83  'operatorType' => 'equals',
84  'value' => $accountId
85  ),
86  2 => array(
87  'attributeName' => 'contact',
88  'operatorType' => 'equals',
89  'value' => $contactId
90  ),
91  );
92  $searchAttributeData['structure'] = '(1 and 2)';
93  $joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('AccountContactAffiliation');
94  $where = RedBeanModelDataProvider::makeWhere('AccountContactAffiliation', $searchAttributeData, $joinTablesAdapter);
97  $where .= " and {$q}{$tableName}{$q}.{$q}primary{$q} = '1'";
98  return self::getSubset($joinTablesAdapter, null, null, $where);
99  }
100 
101  public static function getByAccountAndContact(Account $account, Contact $contact)
102  {
103  assert('$account->id > 0');
104  assert('$contact->id > 0');
105  $searchAttributeData = array();
106  $searchAttributeData['clauses'] = array(
107  1 => array(
108  'attributeName' => 'account',
109  'operatorType' => 'equals',
110  'value' => $account->id
111  ),
112  2 => array(
113  'attributeName' => 'contact',
114  'operatorType' => 'equals',
115  'value' => $contact->id
116  ),
117  );
118  $searchAttributeData['structure'] = '(1 and 2)';
119  $joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('AccountContactAffiliation');
120  $where = RedBeanModelDataProvider::makeWhere('AccountContactAffiliation', $searchAttributeData, $joinTablesAdapter);
121  return self::getSubset($joinTablesAdapter, null, null, $where);
122  }
123 
124  public static function getDefaultMetadata()
125  {
126  $metadata = parent::getDefaultMetadata();
127  $metadata[__CLASS__] = array(
128  'members' => array(
129  'primary',
130  ),
131  'rules' => array(
132  array('primary', 'boolean'),
133  array('primary', 'readOnly'),
134  array('primary', 'default', 'value' => false),
135  array('account', 'required'),
136  array('contact', 'required'),
137 
138  ),
139  'relations' => array(
140  'role' => array(static::HAS_ONE, 'OwnedCustomField', static::OWNED,
141  static::LINK_TYPE_SPECIFIC, 'role'),
142  'account' => array(static::HAS_ONE, 'Account', static::NOT_OWNED, static::LINK_TYPE_SPECIFIC,
143  'accountAffiliation'),
144  'contact' => array(static::HAS_ONE, 'Contact', static::NOT_OWNED, static::LINK_TYPE_SPECIFIC,
145  'contactAffiliation'),
146  ),
147  'elements' => array(
148  ),
149  'elements' => array(
150  'account' => 'Account',
151  'contact' => 'Contact',
152  'primary' => 'CheckBox',
153  ),
154  'customFields' => array(
155  'role' => 'AccountContactAffiliationRoles',
156  ),
157  'noAudit' => array(
158  'primary',
159  'account',
160  'contact'
161  ),
162  );
163  return $metadata;
164  }
165 
166  public static function isTypeDeletable()
167  {
168  return true;
169  }
170 
171  public static function canSaveMetadata()
172  {
173  return true;
174  }
175 
176  protected static function translatedAttributeLabels($language)
177  {
179  return array_merge(parent::translatedAttributeLabels($language),
180  array(
181  'account' => Zurmo::t('AccountsModule', 'AccountsModuleSingularLabel', $params, null, $language),
182  'contact' => Zurmo::t('ContactsModule', 'ContactsModuleSingularLabel', $params, null, $language),
183  'role' => Zurmo::t('ZurmoModule', 'Role', null, null, $language),
184  'primary' => Zurmo::t('AccountContactAffiliationsModule', 'Primary Relationship', null, null, $language),
185  )
186  );
187  }
188 
189  public function __toString()
190  {
191  try
192  {
193  return strval($this->account) . ' - ' . strval($this->contact);
194  }
196  {
197  return '';
198  }
199  }
200 
204  public function isAllowedToSetReadOnlyAttribute($attributeName)
205  {
206  if ( in_array($attributeName, array('primary')))
207  {
208  return true;
209  }
210  else
211  {
212  return parent::isAllowedToSetReadOnlyAttribute($attributeName);
213  }
214  }
215  }
216 ?>
static getTranslationParamsForAllModules()
Definition: LabelUtil.php:75
static makeWhere($modelClassName, array $metadata, &$joinTablesAdapter)
static getPluralLabel($language=null)
Definition: Item.php:37
static getTableName()
Generated on Tue Jul 7 2020 07:10:30
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.