本文整理汇总了PHP中SugarModule类的典型用法代码示例。如果您正苦于以下问题:PHP SugarModule类的具体用法?PHP SugarModule怎么用?PHP SugarModule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SugarModule类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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';
//.........这里部分代码省略.........
示例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;
}
示例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;
}
示例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;
示例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);
}
}