1
|
|
|
<?php |
2
|
|
|
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
3
|
|
|
/********************************************************************************* |
4
|
|
|
* SugarCRM Community Edition is a customer relationship management program developed by |
5
|
|
|
* SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
6
|
|
|
|
7
|
|
|
* SuiteCRM is an extension to SugarCRM Community Edition developed by Salesagility Ltd. |
8
|
|
|
* Copyright (C) 2011 - 2014 Salesagility Ltd. |
9
|
|
|
* |
10
|
|
|
* This program is free software; you can redistribute it and/or modify it under |
11
|
|
|
* the terms of the GNU Affero General Public License version 3 as published by the |
12
|
|
|
* Free Software Foundation with the addition of the following permission added |
13
|
|
|
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK |
14
|
|
|
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY |
15
|
|
|
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS. |
16
|
|
|
* |
17
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT |
18
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
19
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more |
20
|
|
|
* details. |
21
|
|
|
* |
22
|
|
|
* You should have received a copy of the GNU Affero General Public License along with |
23
|
|
|
* this program; if not, see http://www.gnu.org/licenses or write to the Free |
24
|
|
|
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
25
|
|
|
* 02110-1301 USA. |
26
|
|
|
* |
27
|
|
|
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road, |
28
|
|
|
* SW2-130, Cupertino, CA 95014, USA. or at email address [email protected]. |
29
|
|
|
* |
30
|
|
|
* The interactive user interfaces in modified source and object code versions |
31
|
|
|
* of this program must display Appropriate Legal Notices, as required under |
32
|
|
|
* Section 5 of the GNU Affero General Public License version 3. |
33
|
|
|
* |
34
|
|
|
* In accordance with Section 7(b) of the GNU Affero General Public License version 3, |
35
|
|
|
* these Appropriate Legal Notices must retain the display of the "Powered by |
36
|
|
|
* SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not |
37
|
|
|
* reasonably feasible for technical reasons, the Appropriate Legal Notices must |
38
|
|
|
* display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". |
39
|
|
|
********************************************************************************/ |
40
|
|
|
|
41
|
|
|
|
42
|
|
|
|
43
|
|
|
|
44
|
|
|
|
45
|
|
|
|
46
|
|
|
class SugarWidgetSubPanelTopComposeEmailButton extends SugarWidgetSubPanelTopButton |
47
|
|
|
{ |
48
|
|
|
var $form_value = ''; |
49
|
|
|
|
50
|
|
|
public function getWidgetId($buttonSuffix = true) |
51
|
|
|
{ |
52
|
|
|
global $app_strings; |
53
|
|
|
$this->form_value = $app_strings['LBL_COMPOSE_EMAIL_BUTTON_LABEL']; |
54
|
|
|
return parent::getWidgetId(); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
function display($defines, $additionalFormFields = NULL, $nonbutton = false) |
58
|
|
|
{ |
59
|
|
|
if((ACLController::moduleSupportsACL($defines['module']) && !ACLController::checkAccess($defines['module'], 'edit', true) || |
60
|
|
|
$defines['module'] == "Activities" & !ACLController::checkAccess("Emails", 'edit', true))){ |
|
|
|
|
61
|
|
|
$temp = ''; |
62
|
|
|
return $temp; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
global $app_strings,$current_user,$sugar_config,$beanList,$beanFiles; |
66
|
|
|
$title = $app_strings['LBL_COMPOSE_EMAIL_BUTTON_TITLE']; |
67
|
|
|
//$accesskey = $app_strings['LBL_COMPOSE_EMAIL_BUTTON_KEY']; |
68
|
|
|
$value = $app_strings['LBL_COMPOSE_EMAIL_BUTTON_LABEL']; |
69
|
|
|
$parent_type = $defines['focus']->module_dir; |
70
|
|
|
$parent_id = $defines['focus']->id; |
71
|
|
|
|
72
|
|
|
//martin Bug 19660 |
73
|
|
|
$userPref = $current_user->getPreference('email_link_type'); |
74
|
|
|
$defaultPref = $sugar_config['email_default_client']; |
75
|
|
|
if($userPref != '') { |
76
|
|
|
$client = $userPref; |
77
|
|
|
} else { |
78
|
|
|
$client = $defaultPref; |
79
|
|
|
} |
80
|
|
|
if($client != 'sugar') { |
81
|
|
|
$bean = $defines['focus']; |
82
|
|
|
// awu: Not all beans have emailAddress property, we must account for this |
83
|
|
|
if (isset($bean->emailAddress)){ |
84
|
|
|
$to_addrs = $bean->emailAddress->getPrimaryAddress($bean); |
85
|
|
|
$button = "<input class='button' type='button' value='$value' id='". $this->getWidgetId() . "' name='".preg_replace('[ ]', '', $value)."' title='$title' onclick=\"location.href='mailto:$to_addrs';return false;\" />"; |
86
|
|
|
} |
87
|
|
|
else{ |
88
|
|
|
$button = "<input class='button' type='button' value='$value' id='". $this->getWidgetId() ."' name='".preg_replace('[ ]', '', $value)."' title='$title' onclick=\"location.href='mailto:';return false;\" />"; |
89
|
|
|
} |
90
|
|
|
} else { |
91
|
|
|
//Generate the compose package for the quick create options. |
92
|
|
|
$composeData = array("parent_id" => $parent_id, "parent_type"=>$parent_type); |
93
|
|
|
require_once('modules/Emails/EmailUI.php'); |
94
|
|
|
$eUi = new EmailUI(); |
95
|
|
|
$j_quickComposeOptions = $eUi->generateComposePackageForQuickCreate($composeData, http_build_query($composeData), false, $defines['focus']); |
96
|
|
|
|
97
|
|
|
$button = "<input title='$title' id='". $this->getWidgetId()."' onclick='SUGAR.quickCompose.init($j_quickComposeOptions);' class='button' type='submit' name='".preg_replace('[ ]', '', $value)."_button' value='$value' />"; |
98
|
|
|
} |
99
|
|
|
return $button; |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|
When comparing the result of a bit operation, we suggest to add explicit parenthesis and not to rely on PHP’s built-in operator precedence to ensure the code behaves as intended and to make it more readable.
Let’s take a look at these examples: