Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
ActivityMashableActivityRules.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  {
46  public function resolveSearchAttributesDataByRelatedItemId($relationItemId)
47  {
48  assert('is_int($relationItemId)');
49  $searchAttributeData['clauses'] = array(
50  1 => array(
51  'attributeName' => 'activityItems',
52  'relatedAttributeName' => 'id',
53  'operatorType' => 'equals',
54  'value' => $relationItemId,
55  )
56  );
57  $searchAttributeData['structure'] = '1';
58  return $searchAttributeData;
59  }
60 
65  public function resolveSearchAttributesDataByRelatedItemIds($relationItemIds)
66  {
67  assert('is_array($relationItemIds)');
68  $searchAttributeData['clauses'] = array(
69  1 => array(
70  'attributeName' => 'activityItems',
71  'relatedAttributeName' => 'id',
72  'operatorType' => 'oneOf',
73  'value' => $relationItemIds,
74  )
75  );
76  $searchAttributeData['structure'] = '1';
77  return $searchAttributeData;
78  }
79 
84  public function resolveSearchAttributeDataForLatestActivities($searchAttributeData)
85  {
86  assert('is_array($searchAttributeData)');
87  return $searchAttributeData;
88  }
89 
90  public function getLatestActivitiesOrderByAttributeName()
91  {
92  return 'latestDateTime';
93  }
94 
99  {
100  }
101 
110  {
111  if ($model->activityItems->count() == 0)
112  {
113  return;
114  }
115  $stringContent = self::getActivityItemsStringContentByModelClassName($model, 'Account');
116  if ($stringContent != null)
117  {
118  return Zurmo::t('ActivitiesModule', 'for {relatedModelsStringContent}', array('{relatedModelsStringContent}' => $stringContent));
119  }
120  $stringContent = self::getActivityItemsStringContentByModelClassName($model, 'Contact', 'ContactsStateMetadataAdapter');
121  if ($stringContent != null)
122  {
123  return Zurmo::t('ActivitiesModule', 'with {relatedContactsStringContent}', array('{relatedContactsStringContent}' => $stringContent));
124  }
125  $stringContent = self::getActivityItemsStringContentByModelClassName($model, 'Opportunity');
126  if ($stringContent != null)
127  {
128  return Zurmo::t('ActivitiesModule', 'for {relatedModelsStringContent}', array('{relatedModelsStringContent}' => $stringContent));
129  }
130  $metadata = Activity::getMetadata();
131  $stringContent = self::getFirstActivityItemStringContent($metadata['Activity']['activityItemsModelClassNames'], $model);
132  if ($stringContent != null)
133  {
134  return Zurmo::t('ActivitiesModule', 'for {relatedModelsStringContent}', array('{relatedModelsStringContent}' => $stringContent));
135  }
136  }
137 
144  $castDownModelClassName, $stateMetadataAdapter = 'StateMetadataAdapter')
145  {
146  assert('is_string($castDownModelClassName)');
147  assert('is_string($stateMetadataAdapter)');
148  $existingModels = array();
149  $modelDerivationPathToItem = RuntimeUtil::getModelDerivationPathToItem($castDownModelClassName);
150  foreach ($model->activityItems as $item)
151  {
152  try
153  {
154  $castedDownModel = $item->castDown(array($modelDerivationPathToItem));
155  if (get_class($castedDownModel) == $castDownModelClassName)
156  {
157  if (strval($castedDownModel) != null)
158  {
159  $params = array('label' => strval($castedDownModel), 'wrapLabel' => false);
160  $moduleClassName = $stateMetadataAdapter::getModuleClassNameByModel($castedDownModel);
161  $moduleId = $moduleClassName::getDirectoryName();
162  $element = new DetailsLinkActionElement('default', $moduleId,
163  $castedDownModel->id, $params);
164  $existingModels[] = $element->render();
165  }
166  }
167  }
168  catch (NotFoundException $e)
169  {
170  //do nothing
171  }
172  }
173  return self::resolveStringValueModelsDataToStringContent($existingModels);
174  }
175 
181  protected static function getFirstActivityItemStringContent($relationModelClassNames, RedBeanModel $model)
182  {
183  assert('is_array($relationModelClassNames)');
184  foreach ($relationModelClassNames as $relationModelClassName)
185  {
186  //ASSUMES ONLY A SINGLE ATTACHED ACTIVITYITEM PER RELATION TYPE.
187  foreach ($model->activityItems as $item)
188  {
189  try
190  {
191  $modelDerivationPathToItem = RuntimeUtil::getModelDerivationPathToItem($relationModelClassName);
192  $castedDownModel = $item->castDown(array($modelDerivationPathToItem));
193  return strval($castedDownModel);
194  }
195  catch (NotFoundException $e)
196  {
197  //do nothing
198  }
199  }
200  }
201  }
202  }
203 ?>
resolveSearchAttributesDataByRelatedItemIds($relationItemIds)
static getFirstActivityItemStringContent($relationModelClassNames, RedBeanModel $model)
static getActivityItemsStringContentByModelClassName(RedBeanModel $model, $castDownModelClassName, $stateMetadataAdapter= 'StateMetadataAdapter')
static getModelDerivationPathToItem($modelClassName)
Definition: RuntimeUtil.php:79
resolveSearchAttributeDataForLatestActivities($searchAttributeData)
renderRelatedModelsByImportanceContent(RedBeanModel $model)
static getMetadata()
Generated on Sat Jul 11 2020 07:10:27
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.