function display($defines)
 {
     if (ACLController::moduleSupportsACL($defines['module']) && !ACLController::checkAccess($defines['module'], 'edit', true) || $defines['module'] == "Activities" & !ACLController::checkAccess("Emails", 'edit', true)) {
         $temp = '';
         return $temp;
     }
     /**
      * if module is hidden or subpanel for the module is hidden - doesn't show quick create button
      */
     if (SugarWidget::isModuleHidden('Emails')) {
         return '';
     }
     global $app_strings, $current_user, $sugar_config, $beanList, $beanFiles;
     $title = $app_strings['LBL_COMPOSE_EMAIL_BUTTON_TITLE'];
     //$accesskey = $app_strings['LBL_COMPOSE_EMAIL_BUTTON_KEY'];
     $value = $app_strings['LBL_COMPOSE_EMAIL_BUTTON_LABEL'];
     $parent_type = $defines['focus']->module_dir;
     $parent_id = $defines['focus']->id;
     //martin Bug 19660
     $userPref = $current_user->getPreference('email_link_type');
     $defaultPref = $sugar_config['email_default_client'];
     if ($userPref != '') {
         $client = $userPref;
     } else {
         $client = $defaultPref;
     }
     if ($client != 'sugar') {
         $bean = $defines['focus'];
         // awu: Not all beans have emailAddress property, we must account for this
         if (isset($bean->emailAddress)) {
             $to_addrs = $bean->emailAddress->getPrimaryAddress($bean);
             $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;\" />";
         } else {
             $button = "<input class='button' type='button'  value='{$value}'  id='" . $this->getWidgetId() . "'  name='" . preg_replace('[ ]', '', $value) . "'  title='{$title}' onclick=\"location.href='mailto:';return false;\" />";
         }
     } else {
         //Generate the compose package for the quick create options.
         $composeData = array("parent_id" => $parent_id, "parent_type" => $parent_type);
         require_once 'modules/Emails/EmailUI.php';
         $eUi = new EmailUI();
         $j_quickComposeOptions = $eUi->generateComposePackageForQuickCreate($composeData, http_build_query($composeData), false, $defines['focus']);
         $button = "<input title='{$title}'  id='" . $this->getWidgetId() . "'  onclick='SUGAR.quickCompose.init({$j_quickComposeOptions});' class='button' type='submit' name='" . preg_replace('[ ]', '', $value) . "_button' value='{$value}' />";
     }
     return $button;
 }
 function display($defines)
 {
     global $app_strings;
     global $currentModule;
     $title = $app_strings['LBL_NEW_BUTTON_TITLE'];
     //$accesskey = $app_strings['LBL_NEW_BUTTON_KEY'];
     $value = $app_strings['LBL_NEW_BUTTON_LABEL'];
     $this->module = 'Contacts';
     /**
      * if module is hidden or subpanel for the module is hidden - doesn't show select button
      */
     if (SugarWidget::isModuleHidden($this->module)) {
         return '';
     }
     if (ACLController::moduleSupportsACL($defines['module']) && !ACLController::checkAccess($defines['module'], 'edit', true)) {
         $button = "<input title='{$title}'class='button' type='button' name='button' value='  {$value}  ' disabled/>\n";
         return $button;
     }
     $additionalFormFields = array();
     if (isset($defines['focus']->billing_address_street)) {
         $additionalFormFields['primary_address_street'] = $defines['focus']->billing_address_street;
     }
     if (isset($defines['focus']->billing_address_city)) {
         $additionalFormFields['primary_address_city'] = $defines['focus']->billing_address_city;
     }
     if (isset($defines['focus']->billing_address_state)) {
         $additionalFormFields['primary_address_state'] = $defines['focus']->billing_address_state;
     }
     if (isset($defines['focus']->billing_address_country)) {
         $additionalFormFields['primary_address_country'] = $defines['focus']->billing_address_country;
     }
     if (isset($defines['focus']->billing_address_postalcode)) {
         $additionalFormFields['primary_address_postalcode'] = $defines['focus']->billing_address_postalcode;
     }
     if (isset($defines['focus']->phone_office)) {
         $additionalFormFields['phone_work'] = $defines['focus']->phone_office;
     }
     $button = $this->_get_form($defines, $additionalFormFields);
     $button .= "<input title='{$title}' class='button' type='submit' name='{$this->getWidgetId()}' id='{$this->getWidgetId()}' value='  {$value}  '/>\n";
     $button .= "</form>";
     return $button;
 }
 function display($defines)
 {
     global $app_strings;
     if (ACLController::moduleSupportsACL($defines['module']) && !ACLController::checkAccess($defines['module'], 'edit', true) || $defines['module'] == "History" & !ACLController::checkAccess("Emails", 'edit', true)) {
         $temp = '';
         return $temp;
     }
     // if module is hidden or subpanel for the module is hidden - doesn't show quick create button
     if (SugarWidget::isModuleHidden('Emails')) {
         return '';
     }
     $title = $app_strings['LBL_TRACK_EMAIL_BUTTON_TITLE'];
     $value = $app_strings['LBL_TRACK_EMAIL_BUTTON_LABEL'];
     $this->module = 'Emails';
     if (ACLController::moduleSupportsACL($defines['module']) && !ACLController::checkAccess($defines['module'], 'edit', true)) {
         $button = "<input id='" . preg_replace('[ ]', '', $value) . "_button'  title='{$title}' class='button' type='button' name='" . preg_replace('[ ]', '', strtolower($value)) . "_button' value='{$value}' disabled/>\n";
     } else {
         $button = "<input id='" . preg_replace('[ ]', '', $value) . "_button' title='{$title}' class='button' type='button' onClick=\"javascript:subp_archive_email();\" name='" . preg_replace('[ ]', '', strtolower($value)) . "_button' value='{$value}'/>\n";
     }
     return $button;
 }
 public function getWidgetId($buttonSuffix = true)
 {
     $widgetID = parent::getWidgetId() . '_' . preg_replace('[ ]', '', mb_strtolower($this->form_value, 'UTF-8'));
     if ($buttonSuffix) {
         $widgetID .= '_button';
     }
     return $widgetID;
 }
 function SugarWidgetField(&$layout_manager)
 {
     parent::SugarWidget($layout_manager);
 }
 function __construct(&$layout_manager)
 {
     parent::__construct($layout_manager);
 }
 function display(&$widget_data)
 {
     global $app_strings;
     /**
      * if module is hidden or subpanel for the module is hidden - doesn't show select button
      */
     if (SugarWidget::isModuleHidden($widget_data['module'])) {
         return '';
     }
     $initial_filter = '';
     $this->title = $this->getTitle();
     $this->accesskey = $this->getAccesskey();
     $this->value = $this->getDisplayName();
     if (is_array($this->button_properties)) {
         if (isset($this->button_properties['title'])) {
             $this->title = $app_strings[$this->button_properties['title']];
         }
         if (isset($this->button_properties['accesskey'])) {
             $this->accesskey = $app_strings[$this->button_properties['accesskey']];
         }
         if (isset($this->button_properties['form_value'])) {
             $this->value = $app_strings[$this->button_properties['form_value']];
         }
         if (isset($this->button_properties['module'])) {
             $this->module_name = $this->button_properties['module'];
         }
     }
     $focus = $widget_data['focus'];
     if (ACLController::moduleSupportsACL($widget_data['module']) && !ACLController::checkAccess($widget_data['module'], 'list', true)) {
         $button = ' <input type="button" name="' . $this->getWidgetId() . '" id="' . $this->getWidgetId() . '" class="button"' . "\n" . ' title="' . $this->title . '"' . ' value="' . $this->value . "\"\n" . ' disabled />';
         return $button;
     }
     //refresh the whole page after end of action?
     $refresh_page = 0;
     if (!empty($widget_data['subpanel_definition']->_instance_properties['refresh_page'])) {
         $refresh_page = 1;
     }
     $subpanel_definition = $widget_data['subpanel_definition'];
     $button_definition = $subpanel_definition->get_buttons();
     $subpanel_name = $subpanel_definition->get_name();
     if (empty($this->module_name)) {
         $this->module_name = $subpanel_definition->get_module_name();
     }
     $link_field_name = $subpanel_definition->get_data_source_name(true);
     $popup_mode = 'Single';
     if (isset($widget_data['mode'])) {
         $popup_mode = $widget_data['mode'];
     }
     if (isset($widget_data['initial_filter_fields'])) {
         if (is_array($widget_data['initial_filter_fields'])) {
             foreach ($widget_data['initial_filter_fields'] as $value => $alias) {
                 if (isset($focus->{$value}) and !empty($focus->{$value})) {
                     $initial_filter .= "&" . $alias . '=' . urlencode($focus->{$value});
                 }
             }
         }
     }
     $create = "true";
     if (isset($widget_data['create'])) {
         $create = $widget_data['create'];
     }
     $return_module = $_REQUEST['module'];
     $return_action = 'SubPanelViewer';
     $return_id = $_REQUEST['record'];
     //field_to_name_array
     $fton_array = array('id' => 'subpanel_id');
     if (isset($widget_data['field_to_name_array']) && is_array($widget_data['field_to_name_array'])) {
         $fton_array = array_merge($fton_array, $widget_data['field_to_name_array']);
     }
     $return_url = "index.php?module={$return_module}&action={$return_action}&subpanel={$subpanel_name}&record={$return_id}&sugar_body_only=1";
     $popup_request_data = array('call_back_function' => 'set_return_and_save_background', 'form_name' => 'DetailView', 'field_to_name_array' => $fton_array, 'passthru_data' => array('child_field' => $subpanel_name, 'return_url' => urlencode($return_url), 'link_field_name' => $link_field_name, 'module_name' => $subpanel_name, 'refresh_page' => $refresh_page));
     // bugfix #57850 add marketing_id to the request data to allow filtering based on it
     if (!empty($_REQUEST['mkt_id'])) {
         $popup_request_data['passthru_data']['marketing_id'] = $_REQUEST['mkt_id'];
     }
     if (is_array($this->button_properties) && !empty($this->button_properties['add_to_passthru_data'])) {
         $popup_request_data['passthru_data'] = array_merge($popup_request_data['passthru_data'], $this->button_properties['add_to_passthru_data']);
     }
     if (is_array($this->button_properties) && !empty($this->button_properties['add_to_passthru_data']['return_type'])) {
         if ($this->button_properties['add_to_passthru_data']['return_type'] == 'report') {
             $initial_filter = "&module_name=" . urlencode($widget_data['module']);
         }
     }
     //acl_roles_users_selectuser_button
     $json_encoded_php_array = $this->_create_json_encoded_popup_request($popup_request_data);
     return ' <input type="button" name="' . $this->getWidgetId() . '" id="' . $this->getWidgetId() . '" class="button"' . "\n" . ' title="' . $this->title . '"' . ' value="' . $this->value . "\"\n" . " onclick='open_popup(\"{$this->module_name}\",600,400,\"{$initial_filter}\",true,true,{$json_encoded_php_array},\"{$popup_mode}\",{$create});' />\n";
 }
 /** This default function is used to create the HTML for a simple button */
 function display($defines, $additionalFormFields = null, $nonbutton = false)
 {
     $temp = '';
     $inputID = $this->getWidgetId();
     if (!empty($this->acl) && ACLController::moduleSupportsACL($defines['module']) && !ACLController::checkAccess($defines['module'], $this->acl, true)) {
         return $temp;
     }
     /**
      * if module is hidden or subpanel for the module is hidden - doesn't show quick create button
      */
     if (SugarWidget::isModuleHidden(!empty($this->module) ? $this->module : $defines['module'])) {
         return '';
     }
     global $app_strings;
     if (isset($_REQUEST['layout_def_key']) && $_REQUEST['layout_def_key'] == 'UserEAPM') {
         // Subpanels generally don't go on the editview, so we have to handle this special
         $megaLink = $this->_get_form($defines, $additionalFormFields, true);
         $button = "<input title='{$this->title}' accesskey='{$this->access_key}' class='button' type='submit' name='{$inputID}' id='{$inputID}' value='{$this->form_value}' onclick='javascript:document.location=\"index.php?" . $megaLink . "\"; return false;'/>";
     } else {
         $button = $this->_get_form($defines, $additionalFormFields);
         // $this->sidecar is set in _get_form_sidecar()
         if ($this->sidecar !== true) {
             $button .= "<input title='{$this->title}' accesskey='{$this->access_key}' class='button' type='submit' name='{$inputID}' id='{$inputID}' value='{$this->form_value}' />\n";
         }
         $button .= "</form>";
     }
     if ($nonbutton) {
         $button = "<a onclick=''>{$this->form_value}";
     }
     return $button;
 }