public function action_search() { //set ajax view $this->view = 'ajax'; //get the module $module = !empty($_REQUEST['qModule']) ? $_REQUEST['qModule'] : ''; //lowercase module name $lmodule = strtolower($module); //get the search term $term = !empty($_REQUEST['term']) ? $GLOBALS['db']->quote($_REQUEST['term']) : ''; //in the case of Campaigns we need to use the related module $relModule = !empty($_REQUEST['rel_module']) ? $_REQUEST['rel_module'] : null; $max = !empty($_REQUEST['max']) ? $_REQUEST['max'] : 10; $order_by = !empty($_REQUEST['order_by']) ? $_REQUEST['order_by'] : $lmodule . ".name"; $offset = !empty($_REQUEST['offset']) ? $_REQUEST['offset'] : 0; $response = array(); if (!empty($module)) { $where = ''; $deleted = '0'; $using_cp = false; if (!empty($term)) { if ($module == 'Contacts' || $module == 'Leads') { $where = $lmodule . ".first_name like '%" . $term . "%' OR " . $lmodule . ".last_name like '%" . $term . "%'"; $order_by = $lmodule . ".last_name"; } else { if ($module == 'CampaignProspects') { $using_cp = true; $lmodule = strtolower($relModule); $campign_where = $_SESSION['MAILMERGE_WHERE']; $where = $lmodule . ".first_name like '%" . $term . "%' OR " . $lmodule . ".last_name like '%" . $term . "%'"; if ($campign_where) { $where .= " AND " . $campign_where; } $where .= " AND related_type = #" . $lmodule . "#"; $module = 'Prospects'; } else { $where = $lmodule . ".name like '" . $term . "%'"; } } } $seed = SugarModule::get($module)->loadBean(); if ($using_cp) { $fields = array('id', 'first_name', 'last_name'); $dataList = $seed->retrieveTargetList($where, $fields, $offset, -1, $max, $deleted); } else { $dataList = $seed->get_list($order_by, $where, $offset, -1, $max, $deleted); } $list = $dataList['list']; $row_count = $dataList['row_count']; $output_list = array(); foreach ($list as $value) { $output_list[] = get_return_value($value, $module); } $response['result'] = array('result_count' => $row_count, 'entry_list' => $output_list); } $json = getJSONobj(); $json_response = $json->encode($response, true); print $json_response; }
public function testget() { //test for invalid input $sugarmodule = SugarModule::get(''); $this->assertInstanceOf('SugarModule', $sugarmodule); $this->assertAttributeEquals(null, '_moduleName', $sugarmodule); //test for valid input $sugarmodule_user = SugarModule::get('User'); $this->assertInstanceOf('SugarModule', $sugarmodule_user); $this->assertAttributeEquals('User', '_moduleName', $sugarmodule_user); }
public function testQueryDoesNotContainDuplicateUsersLastImportClauses() { global $current_user; $params = array('custom_from' => ', users_last_import', 'custom_where' => " AND users_last_import.assigned_user_id = '{$current_user->id}'\n AND users_last_import.bean_type = 'Account'\n AND users_last_import.bean_id = accounts.id\n AND users_last_import.deleted = 0\n AND accounts.deleted = 0"); $seed = SugarModule::get('Accounts')->loadBean(); $lvfMock = $this->getMock('ListViewFacade', array('setup', 'display', 'build'), array($seed, 'Accounts')); $lvfMock->expects($this->any())->method('setup')->with($this->anything(), '', $params, $this->anything(), $this->anything(), $this->anything(), $this->anything(), $this->anything(), $this->anything(), $this->anything()); $viewLast = new ImportViewLastWrap(); $viewLast->init($seed); $viewLast->lvf = $lvfMock; $viewLast->publicGetListViewResults(); }
function checkDashletDisplay() { if (!in_array($this->type, $GLOBALS['moduleList']) && !in_array($this->type, $GLOBALS['modInvisList']) && !in_array('Activities', $GLOBALS['moduleList'])) { $displayDashlet = false; } elseif (ACLController::moduleSupportsACL($this->type)) { $bean = SugarModule::get($this->type)->loadBean(); if (!ACLController::checkAccess($this->type, 'list', true, $bean->acltype)) { $displayDashlet = false; } $displayDashlet = true; } else { $displayDashlet = true; } return $displayDashlet; }
function bpminbox_get_username_by_id($userid) { if (empty($userid)) { return false; } $user = SugarModule::get('Users')->loadBean(); $user->retrieve($userid); if ($userid != $user->id) { return false; } if (showFullName()) { return $user->full_name; } else { return $user->user_name; } }
function checkForDuplicates($prefix) { parent::checkForDuplicates($prefix); require_once 'include/formbase.php'; require_once 'include/MVC/SugarModule.php'; $focus = SugarModule::get($this->moduleName)->loadBean(); $query = $this->getDuplicateQuery($focus, $prefix); if (empty($query)) { return null; } $rows = array(); global $db; $result = $db->query($query); //Loop through the results and store while (($row = $db->fetchByAssoc($result)) != null) { if (!isset($rows[$row['id']])) { $rows[] = $row; } } //Now check for duplicates using email values supplied $count = 0; $emails = array(); $emailStr = ''; while (isset($_POST["{$this->moduleName}{$count}emailAddress{$count}"])) { $emailStr .= ",'" . strtoupper(trim($_POST["{$this->moduleName}{$count}emailAddress" . $count++])) . "'"; } //while if (!empty($emailStr)) { $emailStr = substr($emailStr, 1); $query = 'SELECT DISTINCT er.bean_id AS id FROM email_addr_bean_rel er, ' . 'email_addresses ea WHERE ea.id = er.email_address_id ' . 'AND ea.deleted = 0 AND er.deleted = 0 AND er.bean_module = \'' . $this->moduleName . '\' ' . 'AND email_address_caps IN (' . $emailStr . ') AND er.bean_id != "' . $_REQUEST['record'] . '"'; $result = $db->query($query); while (($row = $db->fetchByAssoc($result)) != null) { if (!isset($rows[$row['id']])) { $query2 = "SELECT id, name FROM {$focus->table_name} WHERE deleted=0 AND id = '" . $row['id'] . "'"; $result2 = $db->query($query2); $r = $db->fetchByAssoc($result2); if (isset($r['id'])) { $rows[] = $r; } } //if } } //if return !empty($rows) ? $rows : null; }
/** * Returns the bean object of the given module * * @param string $module * @return object */ function loadImportBean($module) { $focus = SugarModule::get($module)->loadBean(); if ($focus) { if (!$focus->importable) { return false; } if ($module == 'Users' && !is_admin($GLOBALS['current_user']) && !is_admin_for_module($GLOBALS['current_user'], 'Users')) { return false; } if ($focus->bean_implements('ACL')) { if (!ACLController::checkAccess($focus->module_dir, 'import', true)) { ACLController::displayNoAccess(); sugar_die(''); } } } else { return false; } return $focus; }
/** * Load the modules from the metadata file and include in a custom one if it exists * * @return array */ protected function _loadQuickCreateModules() { $QCAvailableModules = array(); $QCModules = array(); include 'modules/Emails/metadata/qcmodulesdefs.php'; if (file_exists('custom/modules/Emails/metadata/qcmodulesdefs.php')) { include 'custom/modules/Emails/metadata/qcmodulesdefs.php'; } foreach ($QCModules as $module) { $seed = SugarModule::get($module)->loadBean(); if ($seed instanceof SugarBean && $seed->ACLAccess('edit')) { $QCAvailableModules[] = $module; } } return $QCAvailableModules; }
function get_list_view_data() { global $locale, $current_user; $temp_array = parent::get_list_view_array(); $related_type = $temp_array['RELATED_TYPE']; $related_id = $temp_array['RELATED_ID']; $is_person = SugarModule::get($related_type)->moduleImplements('Person'); if ($is_person) { $query = "SELECT first_name, last_name FROM " . strtolower($related_type) . " WHERE id ='" . $related_id . "'"; } else { $query = "SELECT name FROM " . strtolower($related_type) . " WHERE id ='" . $related_id . "'"; } $result = $this->db->query($query); $row = $this->db->fetchByAssoc($result); if ($row) { $temp_array['RECIPIENT_NAME'] = $is_person ? $locale->getLocaleFormattedName($row['first_name'], $row['last_name'], '') : $row['name']; } //also store the recipient_email address $query = "SELECT addr.email_address FROM email_addresses addr,email_addr_bean_rel eb WHERE eb.deleted=0 AND addr.id=eb.email_address_id AND bean_id ='" . $related_id . "' AND primary_address = '1'"; $result = $this->db->query($query); $row = $this->db->fetchByAssoc($result); if ($row) { $temp_array['RECIPIENT_EMAIL'] = $row['email_address']; } $this->email1 = $temp_array['RECIPIENT_EMAIL']; $temp_array['EMAIL1_LINK'] = $current_user->getEmailLink('email1', $this, '', '', 'ListView'); return $temp_array; }
/** * Replace images with locations specified by regex with cid: images * and attach needed files * @param string $regex Regular expression * @param string $local_prefix Prefix where local files are stored * @param bool $object Use attachment object */ public function replaceImageByRegex($regex, $local_prefix, $object = false) { preg_match_all("#<img[^>]*[\\s]+src[^=]*=[\\s]*[\"']({$regex})(.+?)[\"']#si", $this->Body, $matches); $i = 0; foreach ($matches[2] as $match) { $filename = urldecode($match); $cid = $filename; $file_location = $local_prefix . $filename; if (!file_exists($file_location)) { continue; } if ($object) { if (preg_match('#&(?:amp;)?type=([\\w]+)#i', $matches[0][$i], $typematch)) { switch (strtolower($typematch[1])) { case 'documents': $beanname = 'DocumentRevisions'; break; case 'notes': $beanname = 'Notes'; break; } } $mime_type = "application/octet-stream"; if (isset($beanname)) { $bean = SugarModule::get($beanname)->loadBean(); $bean->retrieve($filename); if (!empty($bean->id)) { $mime_type = $bean->file_mime_type; $filename = $bean->filename; } } } else { $mime_type = "image/" . strtolower(pathinfo($filename, PATHINFO_EXTENSION)); } $this->AddEmbeddedImage($file_location, $cid, $filename, 'base64', $mime_type); $i++; } //replace references to cache with cid tag $this->Body = preg_replace("|\"{$regex}|i", '"cid:', $this->Body); // remove bad img line from outbound email $this->Body = preg_replace('#<img[^>]+src[^=]*=\\"\\/([^>]*?[^>]*)>#sim', '', $this->Body); }
/** * _performSearch * * Performs the search from the global search field. * * @param $query string what we are searching for * @param $modules array modules we are searching in * @param $offset int search result offset * @return array */ protected function _performSearch($query, $modules, $offset = -1) { //Return an empty array if no query string is given if (empty($query)) { return array(); } $primary_module = ''; $results = array(); require_once 'include/SearchForm/SearchForm2.php'; $where = ''; $searchEmail = preg_match('/^([^%]|%)*@([^%]|%)*$/', $query); $limit = !empty($GLOBALS['sugar_config']['max_spotresults_initial']) ? $GLOBALS['sugar_config']['max_spotresults_initial'] : 5; if ($offset !== -1) { $limit = !empty($GLOBALS['sugar_config']['max_spotresults_more']) ? $GLOBALS['sugar_config']['max_spotresults_more'] : 20; } $totalCounted = empty($GLOBALS['sugar_config']['disable_count_query']); global $current_user; foreach ($modules as $moduleName) { if (empty($primary_module)) { $primary_module = $moduleName; } $searchFields = SugarSpot::getSearchFields($moduleName); //Continue on to the next module if no search fields found for module if (empty($searchFields[$moduleName])) { continue; } $return_fields = array(); $seed = SugarModule::get($moduleName)->loadBean(); //Continue on to next module if we don't have ListView ACLAccess for module if (!$seed->ACLAccess('ListView')) { continue; } $class = $seed->object_name; foreach ($searchFields[$moduleName] as $k => $v) { $keep = false; $searchFields[$moduleName][$k]['value'] = $query; //If force_unifiedsearch flag is true, we are essentially saying this field must be searched on (e.g. search_name in SearchFields.php file) if (!empty($searchFields[$moduleName][$k]['force_unifiedsearch'])) { continue; } if (!empty($GLOBALS['dictionary'][$class]['unified_search'])) { if (empty($GLOBALS['dictionary'][$class]['fields'][$k]['unified_search'])) { if (isset($searchFields[$moduleName][$k]['db_field'])) { foreach ($searchFields[$moduleName][$k]['db_field'] as $field) { if (!empty($GLOBALS['dictionary'][$class]['fields'][$field]['unified_search'])) { if (isset($GLOBALS['dictionary'][$class]['fields'][$field]['type'])) { if (!$this->filterSearchType($GLOBALS['dictionary'][$class]['fields'][$field]['type'], $query)) { unset($searchFields[$moduleName][$k]); continue; } } else { $keep = true; } } } //foreach } if (!$keep) { if (strpos($k, 'email') === false || !$searchEmail) { unset($searchFields[$moduleName][$k]); } } } else { if ($GLOBALS['dictionary'][$class]['fields'][$k]['type'] == 'int' && !is_numeric($query)) { unset($searchFields[$moduleName][$k]); } } } else { if (empty($GLOBALS['dictionary'][$class]['fields'][$k])) { //If module did not have unified_search defined, then check the exception for an email search before we unset if (strpos($k, 'email') === false || !$searchEmail) { unset($searchFields[$moduleName][$k]); } } else { if (!$this->filterSearchType($GLOBALS['dictionary'][$class]['fields'][$k]['type'], $query)) { unset($searchFields[$moduleName][$k]); } } } } //foreach //If no search field criteria matched then continue to next module if (empty($searchFields[$moduleName])) { continue; } //Variable used to store the "name" field displayed in results $name_field = null; if (isset($seed->field_defs['name'])) { $return_fields['name'] = $seed->field_defs['name']; $name_field = 'name'; } foreach ($seed->field_defs as $k => $v) { if (isset($seed->field_defs[$k]['type']) && $seed->field_defs[$k]['type'] == 'name' && !isset($return_fields[$k])) { $return_fields[$k] = $seed->field_defs[$k]; } } if (!isset($return_fields['name'])) { // if we couldn't find any name fields, try search fields that have name in it foreach ($searchFields[$moduleName] as $k => $v) { if (strpos($k, 'name') != -1 && isset($seed->field_defs[$k]) && !isset($seed->field_defs[$k]['source'])) { $return_fields[$k] = $seed->field_defs[$k]; $name_field = $k; break; } } } if (!isset($return_fields['name'])) { // last resort - any fields that have 'name' in their name foreach ($seed->field_defs as $k => $v) { if (strpos($k, 'name') != -1 && isset($seed->field_defs[$k]) && !isset($seed->field_defs[$k]['source'])) { $return_fields[$k] = $seed->field_defs[$k]; $name_field = $k; break; } } } if (empty($name_field)) { // FAIL: couldn't find a name field to display a result label $GLOBALS['log']->error("Unable to find name field for module {$moduleName}"); continue; } if (isset($return_fields['name']['fields'])) { // some names are composite name fields (e.g. last_name, first_name), add these to return list foreach ($return_fields['name']['fields'] as $field) { $return_fields[$field] = $seed->field_defs[$field]; } } $searchForm = new SearchForm($seed, $moduleName); $searchForm->setup(array($moduleName => array()), $searchFields, '', 'saved_views'); $where_clauses = $searchForm->generateSearchWhere(); if (empty($where_clauses)) { continue; } if (count($where_clauses) > 1) { $query_parts = array(); $ret_array_start = $seed->create_new_list_query('', '', $return_fields, array(), 0, '', true, $seed, true); $search_keys = array_keys($searchFields[$moduleName]); foreach ($where_clauses as $n => $clause) { $allfields = $return_fields; $skey = $search_keys[$n]; if (isset($seed->field_defs[$skey])) { // Joins for foreign fields aren't produced unless the field is in result, hence the merge $allfields[$skey] = $seed->field_defs[$skey]; } $ret_array = $seed->create_new_list_query('', $clause, $allfields, array(), 0, '', true, $seed, true); $query_parts[] = $ret_array_start['select'] . $ret_array['from'] . $ret_array['where'] . $ret_array['order_by']; } $main_query = "(" . join(") UNION (", $query_parts) . ")"; } else { foreach ($searchFields[$moduleName] as $k => $v) { if (isset($seed->field_defs[$k])) { $return_fields[$k] = $seed->field_defs[$k]; } } $ret_array = $seed->create_new_list_query('', $where_clauses[0], $return_fields, array(), 0, '', true, $seed, true); $main_query = $ret_array['select'] . $ret_array['from'] . $ret_array['where'] . $ret_array['order_by']; } $totalCount = null; if ($limit < -1) { $result = $seed->db->query($main_query); } else { if ($limit == -1) { $limit = $GLOBALS['sugar_config']['list_max_entries_per_page']; } if ($offset == 'end') { $totalCount = $this->_getCount($seed, $main_query); if ($totalCount) { $offset = floor(($totalCount - 1) / $limit) * $limit; } else { $offset = 0; } } $result = $seed->db->limitQuery($main_query, $offset, $limit + 1); } $data = array(); $count = 0; while ($count < $limit && ($row = $seed->db->fetchByAssoc($result))) { $temp = clone $seed; $temp->setupCustomFields($temp->module_dir); $temp->loadFromRow($row); $data[] = $temp->get_list_view_data($return_fields); $count++; } $nextOffset = -1; $prevOffset = -1; $endOffset = -1; if ($count >= $limit) { $nextOffset = $offset + $limit; } if ($offset > 0) { $prevOffset = $offset - $limit; if ($prevOffset < 0) { $prevOffset = 0; } } if ($count >= $limit && $totalCounted) { if (!isset($totalCount)) { $totalCount = $this->_getCount($seed, $main_query); } } else { $totalCount = $count + $offset; } $pageData['offsets'] = array('current' => $offset, 'next' => $nextOffset, 'prev' => $prevOffset, 'end' => $endOffset, 'total' => $totalCount, 'totalCounted' => $totalCounted); $pageData['bean'] = array('objectName' => $seed->object_name, 'moduleDir' => $seed->module_dir); $readAccess = true; $results[$moduleName] = array("data" => $data, "pageData" => $pageData, "readAccess" => $readAccess); } //foreach return $results; }
protected function postData($url, $postfields, $headers) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $proxy_config = SugarModule::get('Administration')->loadBean(); $proxy_config->retrieveSettings('proxy'); if (!empty($proxy_config) && !empty($proxy_config->settings['proxy_on']) && $proxy_config->settings['proxy_on'] == 1) { curl_setopt($ch, CURLOPT_PROXY, $proxy_config->settings['proxy_host']); curl_setopt($ch, CURLOPT_PROXYPORT, $proxy_config->settings['proxy_port']); if (!empty($proxy_settings['proxy_auth'])) { curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxy_settings['proxy_username'] . ':' . $proxy_settings['proxy_password']); } } if (is_array($postfields) && count($postfields) == 0 || empty($postfields)) { curl_setopt($ch, CURLOPT_POST, false); } else { curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); } curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); $GLOBALS['log']->debug("ExternalAPIBase->postData Where: " . $url); $GLOBALS['log']->debug("Headers:\n" . print_r($headers, true)); // $GLOBALS['log']->debug("Postfields:\n".print_r($postfields,true)); $rawResponse = curl_exec($ch); $GLOBALS['log']->debug("Got:\n" . print_r($rawResponse, true)); return $rawResponse; }
/** * Helper function that enumerates the list of modules and checks if they are an admin/dev. * The code was just too similar to copy and paste. * * @return array */ protected function _getModulesForACL($type = 'dev') { $isDev = $type == 'dev'; $isAdmin = $type == 'admin'; global $beanList; $myModules = array(); if (!is_array($beanList)) { return $myModules; } // These modules don't take kindly to the studio trying to play about with them. static $ignoredModuleList = array('iFrames', 'Feeds', 'Home', 'Dashboard', 'Calendar', 'Activities', 'Reports'); $actions = ACLAction::getUserActions($this->id); foreach ($beanList as $module => $val) { // Remap the module name $module = $this->_fixupModuleForACL($module); if (in_array($module, $myModules)) { // Already have the module in the list continue; } if (in_array($module, $ignoredModuleList)) { // You can't develop on these modules. continue; } $focus = SugarModule::get($module)->loadBean(); if ($focus instanceof SugarBean) { $key = $focus->acltype; } else { $key = 'module'; } if ($this->isAdmin() && isset($actions[$module][$key])) { $myModules[] = $module; } } return $myModules; }
* In accordance with Section 7(b) of the GNU Affero General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by * SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not * reasonably feasible for technical reasons, the Appropriate Legal Notices must * display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". ********************************************************************************/ /********************************************************************************* * Description: TODO: To be written. * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. * All Rights Reserved. * Contributor(s): ______________________________________.. ********************************************************************************/ if (isset($_REQUEST['uid'])) { $merge_ids = explode(',', $_REQUEST['uid']); // Bug 18852 - Check to make sure we have ACL Edit privledges on both records involved in the merge before proceeding if (($bean1 = SugarModule::get($_REQUEST['action_module'])->loadBean()) !== false && ($bean2 = SugarModule::get($_REQUEST['action_module'])->loadBean()) !== false) { $bean1->retrieve($merge_ids[0]); $bean2->retrieve($merge_ids[1]); if (!$bean1->ACLAccess('edit') || !$bean2->ACLAccess('edit')) { ACLController::displayNoAccess(); sugar_die(''); } } //redirect to step3. $_REQUEST['record'] = $merge_ids[0]; $_REQUEST['merge_module'] = $_REQUEST['action_module']; unset($merge_ids[0]); $_REQUEST['mass'] = $merge_ids; } else { global $beanList; global $beanFiles;
protected function saveEmailText() { $text = SugarModule::get("EmailText")->loadBean(); foreach ($this->email_to_text as $textfield => $mailfield) { $text->{$textfield} = $this->{$mailfield}; } $text->email_id = $this->id; if (!$this->new_with_id) { $this->db->update($text); } else { $this->db->insert($text); } }
/** * Display the actions link * * @param string $id link id attribute, defaults to 'actions_link' * @return string HTML source */ protected function buildActionsLink($id = 'actions_link') { global $app_strings; $closeText = "<img border=0 src=" . SugarThemeRegistry::current()->getImageURL('close_inline.gif') . " />"; $moreDetailImage = SugarThemeRegistry::current()->getImageURL('MoreDetail.png'); $menuItems = ''; // delete if (ACLController::checkAccess($this->seed->module_dir, 'delete', true) && $this->delete) { $menuItems .= $this->buildDeleteLink(); } // compose email if (isset($_REQUEST['module']) && $_REQUEST['module'] != 'Users' && $_REQUEST['module'] != 'Employees' && (SugarModule::get($_REQUEST['module'])->moduleImplements('Company') || SugarModule::get($_REQUEST['module'])->moduleImplements('Person'))) { $menuItems .= $this->buildComposeEmailLink($this->data['pageData']['offsets']['total']); } // mass update $mass = new MassUpdate(); $mass->setSugarBean($this->seed); if (ACLController::checkAccess($this->seed->module_dir, 'edit', true) && $this->showMassupdateFields && $mass->doMassUpdateFieldsExistForFocus()) { $menuItems .= $this->buildMassUpdateLink(); } // merge if ($this->mailMerge) { $menuItems .= $this->buildMergeLink(); } if ($this->mergeduplicates) { $menuItems .= $this->buildMergeDuplicatesLink(); } // add to target list if (isset($_REQUEST['module']) && in_array($_REQUEST['module'], array('Contacts', 'Prospects', 'Leads', 'Accounts'))) { $menuItems .= $this->buildTargetList(); } // export if (ACLController::checkAccess($this->seed->module_dir, 'export', true) && $this->export) { $menuItems .= $this->buildExportLink(); } foreach ($this->actionsMenuExtraItems as $item) { $menuItems .= $item; } $menuItems = str_replace('"', '\\"', $menuItems); if (empty($menuItems)) { return ''; } return <<<EOHTML <script type="text/javascript"> <!-- function actions_overlib() { return overlib("{$menuItems}", CENTER, '', STICKY, MOUSEOFF, 3000, CLOSETEXT, "{$closeText}", WIDTH, 150, CLOSETITLE, "{$app_strings['LBL_ADDITIONAL_DETAILS_CLOSE_TITLE']}", CLOSECLICK, FGCLASS, 'olOptionsFgClass', CGCLASS, 'olOptionsCgClass', BGCLASS, 'olBgClass', TEXTFONTCLASS, 'olFontClass', CAPTIONFONTCLASS, 'olOptionsCapFontClass', CLOSEFONTCLASS, 'olOptionsCloseFontClass'); } --> </script> <a id='{$id}' onclick='return actions_overlib();' href="#"> {$app_strings['LBL_LINK_ACTIONS']} <img src='{$moreDetailImage}' border='0' /> </a> EOHTML; }
/** * Replace images with locations specified by regex with cid: images and attach needed files. * * @access protected * @param string $body * @param string $regex Regular expression * @param string $localPrefix Prefix where local files are stored * @param bool $object Use attachment object * @return array body=String with the applicable modifications. images=Array of EmbeddedImage objects. */ protected function convertInlineImageToEmbeddedImage($body, $regex, $localPrefix, $object = false) { $embeddedImages = array(); $i = 0; $foundImages = array(); $src = "[\"']({$regex})([^&\"']+).*?[\"']"; preg_match_all("#<img[^>]*[\\s]+src[^=]*=[\\s]*{$src}#si", $body, $foundImages); foreach ($foundImages[2] as $image) { $filename = urldecode($image); $cid = $filename; $fileLocation = $localPrefix . $filename; if (file_exists($fileLocation)) { $mimeType = ""; if ($object) { $mimeType = "application/octet-stream"; $objectType = array(); if (preg_match("#&(?:amp;)?type=([\\w]+)#i", $foundImages[0][$i], $objectType)) { $beanName = null; switch (strtolower($objectType[1])) { case "documents": $beanName = "DocumentRevisions"; break; case "notes": $beanName = "Notes"; break; } } if (!is_null($beanName)) { $bean = SugarModule::get($beanName)->loadBean(); $bean->retrieve($filename); if (!empty($bean->id)) { $mimeType = $bean->file_mime_type; $filename = $bean->filename; } } } else { $mimeType = "image/" . strtolower(pathinfo($filename, PATHINFO_EXTENSION)); } $embeddedImages[] = new EmbeddedImage($cid, $fileLocation, $filename, Encoding::Base64, $mimeType); $i++; } } // replace references to cache with cid tag $body = preg_replace("|{$src}|i", '"cid:$2"', $body); // remove bad img line from outbound email $body = preg_replace('#<img[^>]+src[^=]*=\\"\\/([^>]*?[^>]*)>#sim', "", $body); return array("body" => $body, "images" => $embeddedImages); }
/** * Returns raw search results. Filters should be applied later. * * @param array $args * @param boolean $singleSelect * @return array */ protected function getRawResults($args, $singleSelect = false) { $orderBy = !empty($args['order']) ? $args['order'] : ''; $limit = !empty($args['limit']) ? intval($args['limit']) : ''; $data = array(); foreach ($args['modules'] as $module) { $focus = SugarModule::get($module)->loadBean(); $orderBy = $focus->db->getValidDBName($args['order_by_name'] && $focus instanceof Person && $args['order'] == 'name' ? 'last_name' : $orderBy); if ($focus->ACLAccess('ListView', true)) { $where = $this->constructWhere($focus, $args); $data = $this->updateData($data, $focus, $orderBy, $where, $limit, $singleSelect); } } return $data; }
public function testModuleImplimentsWhenModuleDoesNotImplimentTemplate() { $this->assertFalse(SugarModule::get('Accounts')->moduleImplements('Person')); }
/** * Generates a comma sperated name and addresses to be used in compose email screen for contacts or leads * from listview * * @param $module string module name * @param $idsArray array of record ids to get the email address for * @return string comma delimited list of email addresses */ public function getNamePlusEmailAddressesForCompose($module, $idsArray) { global $locale; global $db; $table = SugarModule::get($module)->loadBean()->table_name; $returndata = array(); $idsString = ""; foreach ($idsArray as $id) { if ($idsString != "") { $idsString = $idsString . ","; } // if $idsString = $idsString . "'" . $id . "'"; } // foreach $where = "({$table}.deleted = 0 AND {$table}.id in ({$idsString}))"; if ($module == 'Users' || $module == 'Employees') { $selectColumn = "{$table}.first_name, {$table}.last_name, {$table}.title"; } elseif (SugarModule::get($module)->moduleImplements('Person')) { $selectColumn = "{$table}.first_name, {$table}.last_name, {$table}.salutation, {$table}.title"; } else { $selectColumn = "{$table}.name"; } $query = "SELECT {$table}.id, {$selectColumn}, eabr.primary_address, ea.email_address"; $query .= " FROM {$table} "; $query .= "JOIN email_addr_bean_rel eabr ON ({$table}.id = eabr.bean_id and eabr.deleted=0) "; $query .= "JOIN email_addresses ea ON (eabr.email_address_id = ea.id) "; $query .= " WHERE ({$where}) ORDER BY eabr.primary_address DESC"; $r = $this->db->query($query); while ($a = $this->db->fetchByAssoc($r)) { if (!isset($returndata[$a['id']])) { if ($module == 'Users' || $module == 'Employees') { $full_name = from_html($locale->getLocaleFormattedName($a['first_name'], $a['last_name'], '', $a['title'])); $returndata[$a['id']] = "{$full_name} <" . from_html($a['email_address']) . ">"; } elseif (SugarModule::get($module)->moduleImplements('Person')) { $full_name = from_html($locale->getLocaleFormattedName($a['first_name'], $a['last_name'], $a['salutation'], $a['title'])); $returndata[$a['id']] = "{$full_name} <" . from_html($a['email_address']) . ">"; } else { $returndata[$a['id']] = from_html($a['name']) . " <" . from_html($a['email_address']) . ">"; } // else } } return join(",", array_values($returndata)); }
/** * Fetch URL with OAuth * @param string $url * @param string $params Query params * @param string $method HTTP method * @param array $headers HTTP headers * @return string */ public function fetch($url, $params = null, $method = 'GET', $headers = null) { $acc = $this->makeAccessToken(); if (strpos($url, '?')) { list($clean_url, $query) = explode('?', $url); if ($query) { $url = $clean_url; parse_str($query, $query_params); $params = array_merge($params ? $params : array(), $query_params); } } $client = $acc->getHttpClient($this->_oauth_config, $url); Zend_Loader::loadClass('Zend_Http_Client_Adapter_Proxy'); $proxy_config = SugarModule::get('Administration')->loadBean(); $proxy_config->retrieveSettings('proxy'); if (!empty($proxy_config) && !empty($proxy_config->settings['proxy_on']) && $proxy_config->settings['proxy_on'] == 1) { $proxy_settings = array(); $proxy_settings['proxy_host'] = $proxy_config->settings['proxy_host']; $proxy_settings['proxy_port'] = $proxy_config->settings['proxy_port']; if (!empty($proxy_config->settings['proxy_auth'])) { $proxy_settings['proxy_user'] = $proxy_config->settings['proxy_username']; $proxy_settings['proxy_pass'] = $proxy_config->settings['proxy_password']; } $adapter = new Zend_Http_Client_Adapter_Proxy(); $adapter->setConfig($proxy_settings); $client->setAdapter($adapter); } $client->setMethod($method); if (!empty($headers)) { $client->setHeaders($headers); } if (!empty($params)) { if ($method == 'GET') { $client->setParameterGet($params); } else { $client->setParameterPost($params); } } $this->_last = $resp = $client->request(); $this->_lastReq = $client->getLastRequest(); return $resp->getBody(); }
/** * Returns the bean object of the given module * * @deprecated use SugarModule::loadBean() instead * @param string $module * @return object */ function loadBean($module) { return SugarModule::get($module)->loadBean(); }
/** * Returns the DashletGenericChart::_seedBean object. Designed to allow lazy loading the object * when it's needed. * * @return object */ protected function getSeedBean() { if (!$this->_seedBean instanceof SugarBean) { $this->_seedBean = SugarModule::get($this->_seedName)->loadBean(); } return $this->_seedBean; }