Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
ArchivedEmailMatchingView.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 
43  {
44  protected $cssClasses = array('DetailsView');
45 
49  protected $controllerId;
50 
54  protected $moduleId;
55 
59  protected $emailMessage;
60 
65  protected $selectForm;
66 
70  protected $contact;
71 
75  protected $userCanAccessLeads;
76 
80  protected $userCanAccessContacts;
81 
85  protected $userCanCreateContact;
86 
90  protected $userCanCreateLead;
91 
95  protected $uniqueId;
96 
100  protected $saveActionId;
101 
105  protected $urlParameters;
106 
107  public function __construct(
108  $controllerId,
109  $moduleId,
110  EmailMessage $emailMessage,
111  Contact $contact,
112  $selectForm,
113  $userCanAccessLeads,
114  $userCanAccessContacts,
115  $userCanCreateContact,
116  $userCanCreateLead,
117  $gridSize)
118  {
119  assert('is_string($controllerId)');
120  assert('is_string($moduleId)');
121  assert('$emailMessage->id > 0');
122  assert('$selectForm instanceof AnyContactSelectForm || $selectForm instanceof ContactSelectForm || $selectForm instanceof LeadSelectForm');
123  assert('is_bool($userCanAccessLeads)');
124  assert('is_bool($userCanAccessContacts)');
125  assert('is_bool($userCanCreateContact)');
126  assert('is_bool($userCanCreateLead)');
127  assert('is_int($gridSize)');
128  parent::__construct($gridSize, 1);
129  $this->controllerId = $controllerId;
130  $this->moduleId = $moduleId;
131  $this->emailMessage = $emailMessage;
132  $this->selectForm = $selectForm;
133  $this->contact = $contact;
134  $this->userCanAccessLeads = $userCanAccessLeads;
135  $this->userCanAccessContacts = $userCanAccessContacts;
136  $this->userCanCreateContact = $userCanCreateContact;
137  $this->userCanCreateLead = $userCanCreateLead;
138  $this->gridSize = $gridSize;
139  $this->uniqueId = $emailMessage->id;
140  $this->saveActionId = 'completeMatch';
141  $this->urlParameters = array('id' => $this->emailMessage->id);
142  }
143 
148  protected function renderContent()
149  {
150  $this->renderScriptsContent();
151  $this->setView(new AnyContactSelectForEmailMatchingView($this->controllerId,
152  $this->moduleId,
153  $this->selectForm,
154  $this->uniqueId,
155  $this->saveActionId,
156  $this->urlParameters), 0, 0);
157  $row = 1;
158  // $content = $this->renderEmailMessageContentAndResolveLink();
159  if ($this->userCanCreateContact)
160  {
162  $this->controllerId,
163  $this->moduleId,
164  $this->emailMessage->id,
165  $this->contact,
166  $this->uniqueId,
167  $this->saveActionId,
168  $this->urlParameters), $row, 0);
169  $row++;
170  }
171  if ($this->userCanCreateLead)
172  {
174  $this->controllerId,
175  $this->moduleId,
176  $this->emailMessage->id,
177  $this->contact,
178  $this->uniqueId,
179  $this->saveActionId,
180  $this->urlParameters), $row, 0);
181  }
182  $selectLink = $this->renderSelectLinkContent();
183  $createContactLink = ZurmoHtml::link(Zurmo::t('ContactsModule', 'Create ContactsModuleSingularLabel',
185  array('class' => 'create-link contact-create-link z-action-link'));
186  $createLeadLink = ZurmoHtml::link(Zurmo::t('LeadsModule', 'Create LeadsModuleSingularLabel',
188  array('class' => 'create-link lead-create-link z-action-link'));
189  $deleteLink = $this->renderDeleteLink();
190  $rules = new EmailMessageMashableActivityRules();
191  $content = $rules->renderRelatedModelsByImportanceContent($this->emailMessage);
192  $content .= ZurmoHtml::wrapLabel(strval($this->emailMessage), 'email-subject');
193  $content .= '<div class="matching-actions-and-content"><div class="email-matching-actions">';
194  $content .= $this->renderTitleDivContent($selectLink, $createLeadLink, $createContactLink, $deleteLink);
195  $content .= '</div>';
196  $content .= parent::renderContent() . '</div>';
197  return '<div id="wrapper-' . $this->uniqueId . '" class="email-archive-item">' . $content . '</div>';
198  }
199 
200  public function isUniqueToAPage()
201  {
202  return false;
203  }
204 
205  protected function renderScriptsContent()
206  {
207  Yii::app()->clientScript->registerScript('emailMatchingActions', "
208  $('.select-contact-link').live('click', function ()
209  {
210  $(this).closest('td').find('.z-action-link-active').removeClass('z-action-link-active');
211  $(this).addClass('z-action-link-active');
212  $(this).closest('td').addClass('active-panel');
213  $(this).parent().parent().parent().find('.AnyContactSelectForEmailMatchingView').show();
214  $(this).parent().parent().parent().find('.ContactInlineCreateForArchivedEmailCreateView').hide();
215  $(this).parent().parent().parent().find('.LeadInlineCreateForArchivedEmailCreateView').hide();
216  return false;
217  })
218  $('.contact-create-link').live('click', function ()
219  {
220  $(this).closest('td').find('.z-action-link-active').removeClass('z-action-link-active');
221  $(this).addClass('z-action-link-active');
222  $(this).closest('td').addClass('active-panel');
223  $(this).parent().parent().parent().find('.AnyContactSelectForEmailMatchingView').hide();
224  $(this).parent().parent().parent().find('.ContactInlineCreateForArchivedEmailCreateView').show();
225  $(this).parent().parent().parent().find('.LeadInlineCreateForArchivedEmailCreateView').hide();
226  return false;
227  })
228  $('.lead-create-link').live('click', function ()
229  {
230  $(this).closest('td').find('.z-action-link-active').removeClass('z-action-link-active');
231  $(this).addClass('z-action-link-active');
232  $(this).closest('td').addClass('active-panel');
233  $(this).parent().parent().parent().find('.AnyContactSelectForEmailMatchingView').hide();
234  $(this).parent().parent().parent().find('.ContactInlineCreateForArchivedEmailCreateView').hide();
235  $(this).parent().parent().parent().find('.LeadInlineCreateForArchivedEmailCreateView').show();
236  return false;
237  })
238  ");
239  }
240 
241  protected function renderSelectLinkContent()
242  {
243  if ($this->userCanAccessContacts && $this->userCanAccessLeads)
244  {
245  return ZurmoHtml::link(Zurmo::t('EmailMessagesModule', 'Select ContactsModuleSingularLabel / LeadsModuleSingularLabel',
247  array('class' => 'create-link select-contact-link z-action-link'));
248  }
249  if ($this->userCanAccessContacts)
250  {
251  return ZurmoHtml::link(Zurmo::t('EmailMessagesModule', 'Select ContactsModuleSingularLabel',
253  array('class' => 'create-link select-contact-link z-action-link'));
254  }
255  else
256  {
257  return ZurmoHtml::link(Zurmo::t('EmailMessagesModule', 'Select LeadsModuleSingularLabel',
259  array('class' => 'create-link select-contact-link z-action-link'));
260  }
261  }
262 
263  protected function renderSelectContent()
264  {
265  if ($this->userCanAccessContacts && $this->userCanAccessLeads)
266  {
267  return Zurmo::t('EmailMessagesModule', 'Select ContactsModuleSingularLabel / LeadsModuleSingularLabel',
269  }
270  if ($this->userCanAccessContacts)
271  {
272  return Zurmo::t('EmailMessagesModule', 'Select ContactsModuleSingularLabel',
274  }
275  else
276  {
277  return Zurmo::t('EmailMessagesModule', 'Select LeadsModuleSingularLabel',
279  }
280  }
281 
282  protected function renderTitleDivContent($selectLink, $createLeadLink, $createContactLink, $deleteLink)
283  {
284  assert('is_string($selectLink)');
285  assert('is_string($createLeadLink)');
286  assert('is_string($createContactLink)');
287  assert('is_string($deleteLink)');
288  $content = '<div id="select-title-' . $this->uniqueId . '" class="select-title">';
289  $content .= $selectLink . ' &#183; ';
290  if ($this->userCanCreateContact && $this->userCanCreateLead)
291  {
292  $content .= $createLeadLink . ' &#183; ' . $createContactLink;
293  }
294  elseif ($this->userCanCreateContact)
295  {
296  $content .= $createContactLink;
297  }
298  else
299  {
300  $content .= $createLeadLink;
301  }
302  $content .= $deleteLink;
303  $content .= '</div>';
304  return $content;
305  }
306 
307  protected function renderDeleteLink()
308  {
309  $htmlOptions = $this->getHtmlOptionsForDelete();
310  $route = $this->getDefaultRouteForDelete();
311  $ajaxOptions = $this->getAjaxOptionsForDelete();
312  $content = ' &#183; ' . ZurmoHtml::ajaxLink(Zurmo::t('Core', 'Delete'), $route, $ajaxOptions,
313  $htmlOptions);
314  return $content;
315  }
316 
317  protected function getDefaultRouteForDelete()
318  {
319  $params = array('id' => $this->uniqueId, 'redirect' => false);
320  return Yii::app()->createUrl($this->moduleId . '/' . $this->controllerId . '/delete/', $params);
321  }
322 
323  protected function getAjaxOptionsForDelete()
324  {
325  return array('type' => 'GET',
326  'success' => "function()
327  {
328  $('#wrapper-" . $this->uniqueId . "').parent().parent().remove();
329  $('#" . self::getNotificationBarId() . "').jnotifyAddMessage(
330  {
331  text: '" . Zurmo::t('EmailMessagesModule', 'Deleted successfully') . "',
332  permanent: false,
333  showIcon: true,
334  })
335  if ($('.email-archive-item').length == 0)
336  {
337  window.location.reload();
338  }
339  }
340  ");
341  }
342 
343  protected function getHtmlOptionsForDelete()
344  {
345  $htmlOptions['id'] = 'delete-link-' . $this->uniqueId;
346  $htmlOptions['class'] = 'z-action-link';
347  $htmlOptions['confirm'] = Zurmo::t('EmailMessagesModule', 'Are you sure you want to delete?');
348  $htmlOptions['namespace'] = "emailMatchingView";
349  return $htmlOptions;
350  }
351 
352  protected static function getMatchingListUrl()
353  {
354  return Yii::app()->createUrl('emailMessages/default/matchingList');
355  }
356 
357  protected static function getNotificationBarId()
358  {
359  return 'FlashMessageBar';
360  }
361  }
362 ?>
static wrapLabel($label, $class= 'z-label')
Definition: ZurmoHtml.php:656
static ajaxLink($text, $url, $ajaxOptions=array(), $htmlOptions=array())
Definition: ZurmoHtml.php:328
static getTranslationParamsForAllModules()
Definition: LabelUtil.php:75
setView(View $view, $row, $column)
Definition: GridView.php:94
Generated on Thu Jul 9 2020 07:10:32
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.