Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
EmailMessage.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  {
42  protected $isAudited = false;
43 
44  public static function getMashableActivityRulesType()
45  {
46  return 'EmailMessage';
47  }
48 
49  public static function getAllByFolderType($type, $excludePausedCampaignMessages = false)
50  {
51  return static::getByFolderType($type, null, $excludePausedCampaignMessages);
52  }
53 
54  public static function getByFolderType($type, $count = null, $excludePausedCampaignMessages = false)
55  {
56  assert('is_string($type)');
57  $searchAttributeData = array();
58  $searchAttributeData['clauses'] = array(
59  1 => array(
60  'attributeName' => 'folder',
61  'relatedAttributeName' => 'type',
62  'operatorType' => 'equals',
63  'value' => $type,
64  ),
65  );
66  $searchAttributeData['structure'] = '1';
67  if ($excludePausedCampaignMessages)
68  {
69  $searchAttributeData['clauses'][2] = array(
70  'attributeName' => 'campaignItem',
71  'relatedModelData' => array(
72  'attributeName' => 'campaign',
73  'relatedAttributeName' => 'status',
74  'operatorType' => 'doesNotEqual',
75  'value' => Campaign::STATUS_PAUSED
76  ),
77  );
78  $searchAttributeData['clauses'][3] = array(
79  'attributeName' => 'campaignItem',
80  'relatedAttributeName' => 'id',
81  'operatorType' => 'isNull',
82  'value' => null,
83  );
84  $searchAttributeData['structure'] = '1 and (2 or 3)';
85  }
86  $joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('EmailMessage');
87  $where = RedBeanModelDataProvider::makeWhere('EmailMessage', $searchAttributeData, $joinTablesAdapter);
88  return self::getSubset($joinTablesAdapter, null, $count, $where, null);
89  }
90 
91  public static function getByFolderTypeAndCampaignId($type, $campaignId, $count = null)
92  {
93  assert('is_string($type)');
94  $searchAttributeData = array();
95  $searchAttributeData['clauses'] = array(
96  1 => array(
97  'attributeName' => 'folder',
98  'relatedAttributeName' => 'type',
99  'operatorType' => 'equals',
100  'value' => $type,
101  ),
102  2 => array(
103  'attributeName' => 'campaignItem',
104  'relatedModelData' => array(
105  'attributeName' => 'campaign',
106  'relatedAttributeName' => 'id',
107  'operatorType' => 'equals',
108  'value' => intval($campaignId)
109  ),
110  ),
111  );
112  $searchAttributeData['structure'] = '1 and 2';
113  $joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('EmailMessage');
114  $where = RedBeanModelDataProvider::makeWhere('EmailMessage', $searchAttributeData, $joinTablesAdapter);
115  return self::getSubset($joinTablesAdapter, null, $count, $where, null);
116  }
117 
118  public function __toString()
119  {
120  if (trim($this->subject) == '')
121  {
122  return Zurmo::t('Core', '(Unnamed)');
123  }
124  return $this->subject;
125  }
126 
131  protected static function getModifiedSignalAttribute()
132  {
133  return 'subject';
134  }
135 
136  public static function getModuleClassName()
137  {
138  return 'EmailMessagesModule';
139  }
140 
141  public static function canSaveMetadata()
142  {
143  return false;
144  }
145 
146  public static function getDefaultMetadata()
147  {
148  $metadata = parent::getDefaultMetadata();
149  $metadata[__CLASS__] = array(
150  'members' => array(
151  'subject',
152  //'type',
153  'sendAttempts',
154  'sentDateTime',
155  'sendOnDateTime',
156  'headers',
157  'mailerType',
158  'mailerSettings',
159  'contentType',
160  ),
161  'relations' => array(
162  'folder' => array(static::HAS_ONE, 'EmailFolder', static::NOT_OWNED,
163  static::LINK_TYPE_SPECIFIC, 'folder'),
164  'content' => array(static::HAS_ONE, 'EmailMessageContent', static::OWNED,
165  static::LINK_TYPE_SPECIFIC, 'content'),
166  'files' => array(static::HAS_MANY, 'FileModel', static::OWNED,
167  static::LINK_TYPE_POLYMORPHIC, 'relatedModel'),
168  'sender' => array(static::HAS_ONE, 'EmailMessageSender', static::OWNED,
169  static::LINK_TYPE_SPECIFIC, 'sender'),
170  'recipients' => array(static::HAS_MANY, 'EmailMessageRecipient', static::OWNED),
171  'error' => array(static::HAS_ONE, 'EmailMessageSendError' , static::OWNED,
172  static::LINK_TYPE_SPECIFIC, 'error'),
173  'account' => array(static::HAS_ONE, 'EmailAccount', static::NOT_OWNED,
174  static::LINK_TYPE_SPECIFIC, 'account'),
175  'sendGridAccount' => array(static::HAS_ONE, 'SendGridEmailAccount', static::NOT_OWNED,
176  static::LINK_TYPE_SPECIFIC, 'sendGridAccount'),
177  'campaignItem' => array(static::HAS_ONE_BELONGS_TO, 'CampaignItem', static::NOT_OWNED),
178  'contact' => array(static::HAS_ONE, 'Contact', static::NOT_OWNED,
179  static::LINK_TYPE_SPECIFIC, 'contact'),
180  'campaignContent' => array(static::HAS_ONE, 'CampaignEmailMessageContent', static::NOT_OWNED,
181  static::LINK_TYPE_SPECIFIC, 'campaignContent'),
182  'autoresponderContent' => array(static::HAS_ONE, 'AutoresponderEmailMessageContent', static::NOT_OWNED,
183  static::LINK_TYPE_SPECIFIC, 'autoresponderContent'),
184  ),
185  'rules' => array(
186  array('subject', 'required'),
187  array('subject', 'type', 'type' => 'string'),
188  array('subject', 'length', 'min' => 1, 'max' => 255),
189  array('folder', 'required'),
190  array('sender', 'required'),
191  array('sendAttempts', 'type', 'type' => 'integer'),
192  array('sendAttempts', 'numerical', 'min' => 0),
193  array('sentDateTime', 'type', 'type' => 'datetime'),
194  array('sendOnDateTime', 'type', 'type' => 'datetime'),
195  array('headers', 'type', 'type' => 'string'),
196  array('mailerType', 'type', 'type' => 'string'),
197  array('mailerSettings', 'type', 'type' => 'string'),
198  array('contentType', 'type', 'type' => 'string'),
199  array('contentType', 'length', 'min' => 1, 'max' => 255),
200  ),
201  'elements' => array(
202  'sentDateTime' => 'DateTime',
203  'files' => 'Files',
204  'mailerType' => 'Text',
205  'mailerSettings' => 'Text'
206  )
207  );
208  return $metadata;
209  }
210 
211  public static function isTypeDeletable()
212  {
213  return true;
214  }
215 
216  protected function afterDelete()
217  {
218  $emailMessageContactVariableContent = EmailMessageContactVariableContent::getByEmailMessageId($this->id);
219  if (is_object($emailMessageContactVariableContent))
220  {
221  $emailMessageContactVariableContent->delete();
222  }
223  return parent::afterDelete();
224  }
225 
226  public static function hasReadPermissionsOptimization()
227  {
228  return true;
229  }
230 
231  public static function hasRelatedItems()
232  {
233  return true;
234  }
235 
236  protected static function translatedAttributeLabels($language)
237  {
238  return array_merge(parent::translatedAttributeLabels($language),
239  array(
240  'account' => Zurmo::t('EmailMessagesModule', 'Email Account', array(), null, $language),
241  'content' => Zurmo::t('Core', 'Content', array(), null, $language),
242  'error' => Zurmo::t('Core', 'Error', array(), null, $language),
243  'folder' => Zurmo::t('ZurmoModule', 'Folder', array(), null, $language),
244  'files' => Zurmo::t('ZurmoModule', 'Files', array(), null, $language),
245  'recipients' => Zurmo::t('EmailMessagesModule', 'Recipients', array(), null, $language),
246  'sender' => Zurmo::t('EmailMessagesModule', 'Sender', array(), null, $language),
247  'sendAttempts' => Zurmo::t('EmailMessagesModule', 'Send Attempts', array(), null, $language),
248  'sentDateTime' => Zurmo::t('EmailMessagesModule', 'Sent Date Time', array(), null, $language),
249  'subject' => Zurmo::t('Core', 'Subject', array(), null, $language),
250  'sendGridAccount' => Zurmo::t('SendGridModule', 'SendGrid Email Account', array(), null, $language),
251  //'type' => Zurmo::t('Core', 'Type', array(), null, $language),
252  )
253  );
254  }
255 
261  protected static function getLabel($language = null)
262  {
263  return Zurmo::t('EmailMessagesModule', 'Email', array(), null, $language);
264  }
265 
271  protected static function getPluralLabel($language = null)
272  {
273  return Zurmo::t('ZurmoModule', 'Emails', array(), null, $language);
274  }
275 
276  public function hasSendError()
277  {
278  return !($this->error == null || $this->error->id < 0);
279  }
280  }
281 ?>
static getModifiedSignalAttribute()
static getLabel($language=null)
static makeWhere($modelClassName, array $metadata, &$joinTablesAdapter)
static getPluralLabel($language=null)
Generated on Sat Sep 26 2020 07:10:29
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.