本文整理汇总了PHP中SugarModule类的典型用法代码示例。如果您正苦于以下问题:PHP SugarModule类的具体用法?PHP SugarModule怎么用?PHP SugarModule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SugarModule类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: testloadBean
public function testloadBean()
{
//test for invalid input
$sugarmodule = new SugarModule('');
$result = $sugarmodule->loadBean();
$this->assertFalse($result);
//test for valid input
$sugarmodule_user = new SugarModule('Users');
$result = $sugarmodule_user->loadBean();
$this->assertInstanceOf('User', $result);
}
开发者ID:sacredwebsite,项目名称:SuiteCRM,代码行数:11,代码来源:SugarModuleTest.php
示例2: action_search
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;
}
开发者ID:rgauss,项目名称:sugarcrm_dev,代码行数:59,代码来源:controller.php
示例3: testQueryDoesNotContainDuplicateUsersLastImportClauses
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();
}
开发者ID:jgera,项目名称:sugarcrm_dev,代码行数:12,代码来源:Bug48496Test.php
示例4: checkDashletDisplay
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;
}
开发者ID:switcode,项目名称:SuiteCRM,代码行数:15,代码来源:MySugar.php
示例5: bpminbox_get_username_by_id
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;
}
}
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:16,代码来源:PMSEFieldsUtils.php
示例6: checkForDuplicates
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;
}
开发者ID:omusico,项目名称:sugar_work,代码行数:46,代码来源:RealtyFormBase.php
示例7: loadImportBean
/**
* 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;
}
开发者ID:aldridged,项目名称:gtg-sugar,代码行数:27,代码来源:Forms.php
示例8: _loadQuickCreateModules
/**
* 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;
}
开发者ID:NALSS,项目名称:SuiteCRM,代码行数:21,代码来源:EmailUI.php
示例9: get_list_view_data
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;
}
开发者ID:jgera,项目名称:sugarcrm_dev,代码行数:28,代码来源:EmailMan.php
示例10: replaceImageByRegex
/**
* 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);
}
开发者ID:omusico,项目名称:sugar_work,代码行数:49,代码来源:SugarPHPMailer.php
示例11: _performSearch
/**
* _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';
//.........这里部分代码省略.........
开发者ID:netconstructor,项目名称:sugarcrm_dev,代码行数:101,代码来源:SugarSpot.php
示例12: postData
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;
}
开发者ID:omusico,项目名称:sugar_work,代码行数:29,代码来源:ExternalAPIBase.php
示例13: _getModulesForACL
/**
* 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;
}
开发者ID:omusico,项目名称:windcrm,代码行数:41,代码来源:User.php
示例14: explode
* 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;
开发者ID:MexinaD,项目名称:SuiteCRM,代码行数:31,代码来源:index.php
示例15: saveEmailText
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);
}
}
开发者ID:delkyd,项目名称:sugarcrm_dev,代码行数:13,代码来源:Email.php
示例16: buildActionsLink
/**
* 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;
}
开发者ID:aldridged,项目名称:gtg-sugar,代码行数:66,代码来源:ListViewDisplay.php
示例17: convertInlineImageToEmbeddedImage
/**
* 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);
}
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:58,代码来源:EmailFormatter.php
示例18: getRawResults
/**
* 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;
}
开发者ID:delkyd,项目名称:sugarcrm_dev,代码行数:22,代码来源:QuickSearch.php
示例19: testModuleImplimentsWhenModuleDoesNotImplimentTemplate
public function testModuleImplimentsWhenModuleDoesNotImplimentTemplate()
{
$this->assertFalse(SugarModule::get('Accounts')->moduleImplements('Person'));
}
开发者ID:delkyd,项目名称:sugarcrm_dev,代码行数:4,代码来源:SugarModuleTest.php
示例20: getNamePlusEmailAddressesForCompose
/**
* 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));
}
开发者ID:rgauss,项目名称:sugarcrm_dev,代码行数:53,代码来源:Email.php
注:本文中的SugarModule类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论