Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
ReportRules.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  abstract class ReportRules extends ModelToComponentRules
42  {
43  public static function getRulesName()
44  {
45  return 'ReportRules';
46  }
47 
55  public function relationIsReportedAsAttribute(RedBeanModel $model, $relation)
56  {
57  assert('is_string($relation)');
58  $modelClassName = $model->getAttributeModelClassName($relation);
59  $metadata = static::getMetadata();
60  if (isset($metadata[$modelClassName]) && isset($metadata[$modelClassName]['relationsReportedAsAttributes']) &&
61  in_array($relation, $metadata[$modelClassName]['relationsReportedAsAttributes']))
62  {
63  return true;
64  }
65 
66  if (in_array($model->getRelationModelClassName($relation),
67  array('OwnedCustomField',
68  'CustomField',
69  'OwnedMultipleValuesCustomField',
70  'MultipleValuesCustomField',
71  'CurrencyValue')))
72  {
73  return true;
74  }
75  return false;
76  }
77 
83  public function attributeIsReportable(RedBeanModel $model, $attribute)
84  {
85  assert('is_string($attribute)');
86  $modelClassName = $model->getAttributeModelClassName($attribute);
87  $metadata = static::getMetadata();
88  if (isset($metadata[$modelClassName]) && isset($metadata[$modelClassName]['nonReportable']) &&
89  in_array($attribute, $metadata[$modelClassName]['nonReportable']))
90  {
91  return false;
92  }
93  return true;
94  }
95 
101  public function getFilterValueElementType(RedBeanModel $model, $attribute)
102  {
103  assert('is_string($attribute)');
104  if ($attribute == 'id')
105  {
106  $modelClassName = get_class($model);
107  }
108  else
109  {
110  $modelClassName = $model->getAttributeModelClassName($attribute);
111  }
112  $metadata = static::getMetadata();
113  if (isset($metadata[$modelClassName]) && isset($metadata[$modelClassName]['filterValueElementTypes']) &&
114  isset($attribute, $metadata[$modelClassName]['filterValueElementTypes'][$attribute]))
115  {
116  return $metadata[$modelClassName]['filterValueElementTypes'][$attribute];
117  }
118  return null;
119  }
120 
128  {
129  assert('is_string($relation)');
130  $modelClassName = $model->getAttributeModelClassName($relation);
131  $metadata = static::getMetadata();
132  if (isset($metadata[$modelClassName]) && isset($metadata[$modelClassName]['relationsReportedAsAttributes']) &&
133  in_array($relation, $metadata[$modelClassName]['relationsReportedAsAttributes']))
134  {
135  if (isset($metadata[$modelClassName]['relationsReportedAsAttributesSortAttributes'][$relation]))
136  {
137  return $metadata[$modelClassName]['relationsReportedAsAttributesSortAttributes'][$relation];
138  }
139  else
140  {
141  throw new NotSupportedException('Relations that report as attributes must also have a defined sort attribute');
142  }
143  }
144  if (in_array($model->getRelationModelClassName($relation),
145  array('OwnedCustomField',
146  'CustomField',
147  'OwnedMultipleValuesCustomField',
148  'MultipleValuesCustomField',
149  'CurrencyValue')))
150  {
151  return 'value';
152  }
153  throw new NotSupportedException();
154  }
155 
163  {
164  assert('is_string($relation)');
165  $modelClassName = $model->getAttributeModelClassName($relation);
166  $metadata = static::getMetadata();
167  if (isset($metadata[$modelClassName]) && isset($metadata[$modelClassName]['relationsReportedAsAttributes']) &&
168  in_array($relation, $metadata[$modelClassName]['relationsReportedAsAttributes']))
169  {
170  if (isset($metadata[$modelClassName]['relationsReportedAsAttributesGroupByAttributes'][$relation]))
171  {
172  return $metadata[$modelClassName]['relationsReportedAsAttributesGroupByAttributes'][$relation];
173  }
174  else
175  {
176  return null;
177  }
178  }
179  if (in_array($model->getRelationModelClassName($relation),
180  array( 'OwnedCustomField',
181  'CustomField',
182  'OwnedMultipleValuesCustomField',
183  'MultipleValuesCustomField',
184  'CurrencyValue')))
185  {
186  return 'value';
187  }
188  throw new NotSupportedException();
189  }
190 
197  {
198  assert('is_string($relation)');
199  $modelClassName = $model->getAttributeModelClassName($relation);
200  $metadata = static::getMetadata();
201  if (isset($metadata[$modelClassName]) && isset($metadata[$modelClassName]['relationsReportedAsAttributes']) &&
202  in_array($relation, $metadata[$modelClassName]['relationsReportedAsAttributes']))
203  {
204  if (isset($metadata[$modelClassName]['relationsReportedAsAttributesGroupByAttributes'][$relation]))
205  {
206  return $metadata[$modelClassName]['relationsReportedAsAttributesGroupByAttributes'][$relation];
207  }
208  }
209  }
210 
217  {
218  $derivedAttributeTypesData = parent::getDerivedAttributeTypesData($model);
219  $derivedAttributeTypesData['UniqueIdentifier'] = array('label' => UniqueIdentifierElement::getDisplayName(),
220  'derivedAttributeType' => 'UniqueIdentifier');
221  return $derivedAttributeTypesData;
222  }
223  }
224 ?>
getSortAttributeForRelationReportedAsAttribute(RedBeanModel $model, $relation)
relationIsReportedAsAttribute(RedBeanModel $model, $relation)
Definition: ReportRules.php:55
static getAttributeModelClassName($attributeName)
Definition: BeanModel.php:208
getDerivedAttributeTypesData(RedBeanModel $model)
getGroupByRelatedAttributeForRelationReportedAsAttribute(RedBeanModel $model, $relation)
attributeIsReportable(RedBeanModel $model, $attribute)
Definition: ReportRules.php:83
getRawValueRelatedAttributeForRelationReportedAsAttribute(RedBeanModel $model, $relation)
static getRelationModelClassName($relationName)
Definition: BeanModel.php:256
getFilterValueElementType(RedBeanModel $model, $attribute)
Generated on Tue Jul 7 2020 07:10:35
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.