Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
MarketingListMembersUtil.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  {
48  public static function makeSearchAttributeData($marketingListId, $filterBySubscriptionType, $filterBySearchTerm)
49  {
50  assert('is_int($marketingListId)');
51  $searchAttributeData = array();
52  $searchAttributeData['clauses'] = array(
53  1 => array(
54  'attributeName' => 'marketingList',
55  'relatedAttributeName' => 'id',
56  'operatorType' => 'equals',
57  'value' => $marketingListId,
58  ),
59  );
60  $searchAttributeData['structure'] = 1;
61  if ($filterBySubscriptionType !== null &&
62  $filterBySubscriptionType !== MarketingListMembersConfigurationForm::FILTERED_USER_ALL)
63  {
64  $UnsubscribeFlag = 0;
65  if ($filterBySubscriptionType == MarketingListMembersConfigurationForm::FILTER_USER_UNSUBSCRIBERS)
66  {
67  $UnsubscribeFlag = 1;
68  }
69  $searchAttributeData['clauses'][] = array(
70  'attributeName' => 'unsubscribed',
71  'operatorType' => 'equals',
72  'value' => $UnsubscribeFlag,
73  );
74  $searchAttributeData['structure'] = '(1 and 2)';
75  }
76  if ($filterBySearchTerm)
77  {
78  $searchTermAttributeClauses = array(
79  array( 'attributeName' => 'contact',
80  'relatedAttributeName' => 'firstName',
81  'operatorType' => 'startsWith',
82  'value' => $filterBySearchTerm
83  ),
84  array( 'attributeName' => 'contact',
85  'relatedAttributeName' => 'lastName',
86  'operatorType' => 'startsWith',
87  'value' => $filterBySearchTerm
88  ),
89  array( 'attributeName' => 'contact',
90  'relatedModelData' => array(
91  'concatedAttributeNames' => array('firstName', 'lastName'),
92  'operatorType' => 'contains',
93  'value' => $filterBySearchTerm
94  ),
95  ),
96  array( 'attributeName' => 'contact',
97  'relatedModelData' => array(
98  'attributeName' => 'primaryEmail',
99  'relatedAttributeName' => 'emailAddress',
100  'operatorType' => 'startsWith',
101  'value' => $filterBySearchTerm
102  ),
103  ),
104  array( 'attributeName' => 'contact',
105  'relatedModelData' => array(
106  'attributeName' => 'secondaryEmail',
107  'relatedAttributeName' => 'emailAddress',
108  'operatorType' => 'startsWith',
109  'value' => $filterBySearchTerm
110  ),
111  ),
112  );
113 
114  $clauseStartIndex = count($searchAttributeData['clauses']) + 1;
115  foreach ($searchTermAttributeClauses as $index => $searchTermAttributeClause)
116  {
117  $clauseIndex = $clauseStartIndex + $index;
118  $searchAttributeData['clauses'][$clauseIndex] = $searchTermAttributeClause;
119  if ($clauseIndex == $clauseStartIndex)
120  {
121  $structure = ' and (';
122  }
123  else
124  {
125  $structure = ' or ';
126  }
127  $structure .= $clauseIndex;
128  if ($index == (count($searchTermAttributeClauses) -1))
129  {
130  $structure .= ')';
131  }
132  $searchAttributeData['structure'] = $searchAttributeData['structure'] . $structure;
133  }
134  }
135  return array(array('MarketingListMember' => $searchAttributeData));
136  }
137 
138  public static function makeSortAttributeData()
139  {
140  $sortAttribute = RedBeanModelDataProvider::getSortAttributeName('MarketingListMember');
141  return array('MarketingListMember' => $sortAttribute);
142  }
143 
144  public static function getIsSortDescending()
145  {
146  return true;
147  }
148 
155  public static function makeReportDataProviderAndResolveAttributeName($id, $pageSize, & $attributeName)
156  {
157  assert('is_int($pageSize)');
158  $savedReport = SavedReport::getById($id);
160  foreach ($report->getDisplayAttributes() as $key => $displayAttribute)
161  {
162  if ($displayAttribute->getAttributeIndexOrDerivedType() == 'id')
163  {
165  break;
166  }
167  }
168  if ($attributeName == null)
169  {
170  $moduleClassName = $report->getModuleClassName();
171  $modelClassName = $moduleClassName::getPrimaryModelName();
172  $displayAttribute = new DisplayAttributeForReportForm($moduleClassName,
173  $modelClassName,
174  $report->getType());
175  $displayAttribute->attributeIndexOrDerivedType = 'id';
176  $report->addDisplayAttribute($displayAttribute);
177  $attributeName = ReportResultsRowData::resolveAttributeNameByKey(($key + 1));
178  }
179  return ReportDataProviderFactory::makeByReport($report, $pageSize);
180  }
181 
188  RowsAndColumnsReportDataProvider $reportDataProvider, $attributeName)
189  {
190  $contactIds = array();
191  $reportResultsRowDataItems = $reportDataProvider->getData();
192  foreach ($reportResultsRowDataItems as $reportResultsRowDataItem)
193  {
194  $contact = $reportResultsRowDataItem->getModel($attributeName);
195  $contactIds[] = $contact->id;
196  }
197  return $contactIds;
198  }
199  }
200 ?>
static getContactIdsByReportDataProviderAndAttributeName(RowsAndColumnsReportDataProvider $reportDataProvider, $attributeName)
static resolveAttributeNameByKey($key)
static makeReportDataProviderAndResolveAttributeName($id, $pageSize, &$attributeName)
getData($refresh=false)
static makeReportBySavedReport($savedReport)
static getSortAttributeName($modelClassName)
static makeByReport(Report $report, $pageSize)
static makeSearchAttributeData($marketingListId, $filterBySubscriptionType, $filterBySearchTerm)
static getById($id, $modelClassName=null)
Generated on Sat Aug 15 2020 07:10:32
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.