Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
Autoresponder.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 Autoresponder extends Item
38  {
39  const OPERATION_SUBSCRIBE = 1;
40 
41  const OPERATION_UNSUBSCRIBE = 2;
42 
43  public static function getByName($name)
44  {
45  return static::getByNameOrEquivalent('subject', $name);
46  }
47 
48  public static function getModuleClassName()
49  {
50  return 'AutorespondersModule';
51  }
52 
53  public static function getOperationTypeDropDownArray()
54  {
55  return array(
56  self::OPERATION_SUBSCRIBE => Zurmo::t('AutorespondersModule', 'Subscription to list'),
57  self::OPERATION_UNSUBSCRIBE => Zurmo::t('AutorespondersModule', 'Unsubscribed from list'),
58  );
59  }
60 
66  protected static function getLabel($language = null)
67  {
68  return Zurmo::t('AutorespondersModule', 'Autoresponder', array(), null, $language);
69  }
70 
76  protected static function getPluralLabel($language = null)
77  {
78  return Zurmo::t('AutorespondersModule', 'Autoresponders', array(), null, $language);
79  }
80 
81  public static function getDefaultMetadata()
82  {
83  $metadata = parent::getDefaultMetadata();
84  $metadata[__CLASS__] = array(
85  'members' => array(
86  'subject',
87  'htmlContent',
88  'textContent',
89  'fromOperationDurationInterval',
90  'fromOperationDurationType',
91  'operationType',
92  'enableTracking',
93  ),
94  'rules' => array(
95  array('subject', 'required'),
96  array('subject', 'type', 'type' => 'string'),
97  array('subject', 'length', 'min' => 1, 'max' => 255),
98  array('htmlContent', 'type', 'type' => 'string'),
99  array('textContent', 'type', 'type' => 'string'),
100  array('htmlContent', 'StripDummyHtmlContentFromOtherwiseEmptyFieldValidator'),
101  array('textContent', 'AtLeastOneContentAreaRequiredValidator'),
102  array('htmlContent', 'AutoresponderMergeTagsValidator'),
103  array('textContent', 'AutoresponderMergeTagsValidator'),
104  array('fromOperationDurationInterval', 'type', 'type' => 'integer'),
105  array('fromOperationDurationInterval', 'numerical', 'min' => 0),
106  array('fromOperationDurationInterval', 'required'),
107  array('fromOperationDurationType', 'type', 'type' => 'string'),
108  array('fromOperationDurationType', 'required'),
109  array('operationType', 'required'),
110  array('operationType', 'type', 'type' => 'integer'),
111  array('operationType', 'numerical'),
112  array('enableTracking', 'boolean'),
113  array('enableTracking', 'default', 'value' => false),
114 
115  ),
116  'relations' => array(
117  'autoresponderItems' => array(static::HAS_MANY, 'AutoresponderItem'),
118  'marketingList' => array(static::HAS_ONE, 'MarketingList', static::NOT_OWNED),
119  'files' => array(static::HAS_MANY, 'FileModel', static::OWNED,
120  static::LINK_TYPE_POLYMORPHIC, 'relatedModel'),
121  ),
122  'elements' => array(
123  'htmlContent' => 'TextArea',
124  'textContent' => 'TextArea',
125  'enableTracking' => 'CheckBox',
126  ),
127  'defaultSortAttribute' => 'fromOperationDurationInterval',
128  );
129  return $metadata;
130  }
131 
132  public static function isTypeDeletable()
133  {
134  return true;
135  }
136 
137  public static function canSaveMetadata()
138  {
139  return true;
140  }
141 
142  public static function getByOperationType($operationType, $pageSize = null)
143  {
144  assert('is_int($operationType)');
145  $searchAttributeData = array();
146  $searchAttributeData['clauses'] = array(
147  1 => array(
148  'attributeName' => 'operationType',
149  'operatorType' => 'equals',
150  'value' => $operationType,
151  ),
152  );
153  $searchAttributeData['structure'] = '1';
154  $joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter(get_called_class());
155  $where = RedBeanModelDataProvider::makeWhere(get_called_class(), $searchAttributeData, $joinTablesAdapter);
156  return self::getSubset($joinTablesAdapter, null, $pageSize, $where);
157  }
158 
159  public static function getByOperationTypeAndMarketingListId($operationType, $marketingListId, $pageSize = null)
160  {
161  assert('is_int($operationType)');
162  assert('is_int($marketingListId)');
163  $searchAttributeData = array();
164  $searchAttributeData['clauses'] = array(
165  1 => array(
166  'attributeName' => 'operationType',
167  'operatorType' => 'equals',
168  'value' => $operationType,
169  ),
170  2 => array(
171  'attributeName' => 'marketingList',
172  'relatedAttributeName' => 'id',
173  'operatorType' => 'equals',
174  'value' => $marketingListId,
175  ),
176  );
177  $searchAttributeData['structure'] = '(1 and 2)';
178  $joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter(get_called_class());
179  $where = RedBeanModelDataProvider::makeWhere(get_called_class(), $searchAttributeData, $joinTablesAdapter);
180  return self::getSubset($joinTablesAdapter, null, $pageSize, $where);
181  }
182 
183  protected static function translatedAttributeLabels($language)
184  {
185  return array_merge(parent::translatedAttributeLabels($language),
186  array(
187  'subject' => Zurmo::t('Core', 'Subject', null, null, $language),
188  'operationType' => Zurmo::t('Core', 'Triggered By', null, null, $language),
189  'fromOperationDurationInterval' => Zurmo::t('Core', 'Send After', null, null, $language),
190  'htmlContent' => Zurmo::t('EmailMessagesModule', 'Html Content', null, null, $language),
191  'textContent' => Zurmo::t('EmailMessagesModule', 'Text Content', null, null, $language),
192  'enableTracking' => Zurmo::t('ZurmoModule', 'Enable Tracking', null, null, $language),
193  )
194  );
195  }
196 
201  public function resolveNewTimeStampForDuration($initialTimeStamp)
202  {
203  assert('is_int($initialTimeStamp)');
204  return TimeDurationUtil::resolveNewTimeStampForDuration($initialTimeStamp, (int)$this->fromOperationDurationInterval,
205  TimeDurationUtil::DURATION_SIGN_POSITIVE, $this->fromOperationDurationType);
206  }
207 
208  public function __toString()
209  {
210  return strval($this->subject);
211  }
212 
213  protected function afterDelete()
214  {
215  foreach ($this->autoresponderItems as $item)
216  {
217  $item->delete();
218  }
219  $autoresponderEmailMessageContent = AutoresponderEmailMessageContent::getByAutoresponderId($this->id);
220  if (is_object($autoresponderEmailMessageContent))
221  {
222  $autoresponderEmailMessageContent->delete();
223  }
224  return parent::afterDelete();
225  }
226  }
227 ?>
resolveNewTimeStampForDuration($initialTimeStamp)
static makeWhere($modelClassName, array $metadata, &$joinTablesAdapter)
static getPluralLabel($language=null)
Definition: Item.php:37
static resolveNewTimeStampForDuration($initialTimeStamp, $durationInterval, $durationSign, $durationType)
static getLabel($language=null)
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.