本文整理汇总了PHP中loadBean函数的典型用法代码示例。如果您正苦于以下问题:PHP loadBean函数的具体用法?PHP loadBean怎么用?PHP loadBean使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了loadBean函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadBean
/**
* @see SugarController::loadBean()
*/
public function loadBean()
{
global $mod_strings;
$this->importModule = isset($_REQUEST['import_module']) ? $_REQUEST['import_module'] : '';
$this->bean = loadBean($this->importModule);
if ($this->bean) {
if (!$this->bean->importable) {
$this->bean = false;
} elseif ($_REQUEST['import_module'] == 'Users' && !is_admin($GLOBALS['current_user'])) {
$this->bean = false;
} elseif ($this->bean->bean_implements('ACL')) {
if (!ACLController::checkAccess($this->bean->module_dir, 'import', true)) {
ACLController::displayNoAccess();
sugar_die('');
}
}
}
if (!$this->bean && $this->importModule != "Administration") {
$_REQUEST['message'] = $mod_strings['LBL_ERROR_IMPORTS_NOT_SET_UP'];
$this->view = 'error';
$this->_processed = true;
} else {
$GLOBALS['FOCUS'] = $this->bean;
}
}
示例2: remove_zero
function remove_zero(SugarBean $bean, $event, $arguments)
{
if ($bean->number_of_floor == '' || $bean->number_of_floor == 0) {
$bean->number_of_floor = '';
}
if ($bean->floor == '' || $bean->floor == 0) {
$bean->floor = '';
}
if ($bean->rooms_quantity == '' || $bean->rooms_quantity == 0) {
$bean->rooms_quantity = '';
}
if ($bean->living_square == '' || $bean->living_square == 0) {
$bean->living_square = '';
}
if ($event == 'process_record') {
// из какой заявки(интересующая недвижимость для контактов)
if ($_REQUEST['module'] == 'Contacts' && $_REQUEST['action'] == 'DetailView') {
global $db;
$q = "SELECT rrit.request_id as id, r.name as name\n\t\t\t\t\tFROM realty_requests_interest_table AS rrit\n\t\t\t\t\tLEFT JOIN request as r ON r.id = rrit.request_id\n\t\t\t\t\tWHERE \n\t\t\t\t\t\trrit.realty_id = '{$bean->id}'\n\t\t\t\t\t\tAND rrit.deleted = 0\n\t\t\t\t\t\tAND r.deleted = 0";
$res = $db->query($q);
if ($r = $db->fetchByAssoc($res)) {
$bean->request = "<a href='index.php?module=Request&action=DetailView&record={$r['id']}'>{$r['name']}</a>";
}
}
//
if ($_REQUEST['action'] == 'index') {
$realty = loadBean('Realty');
$realty->retrieve($bean->id);
if ($realty->reserved) {
//бронь
$bean->name .= "<img style='display:none;' src='themes/default/images/help.gif' width='0' height='0' onload=\"this.parentNode.parentNode.parentNode.parentNode.style.backgroundColor = '#ccc';\" />";
}
}
}
}
示例3: testDateTimeImport
/**
* @dataProvider providerCsvData
*/
public function testDateTimeImport($content_idx, $expected_datetime, $date_format, $time_format)
{
$file = $GLOBALS['sugar_config']['upload_dir'] . 'test.csv';
$ret = file_put_contents($file, self::$CsvContent[$content_idx]);
$this->assertGreaterThan(0, $ret, 'Failed to write to ' . $file . ' for content ' . $content_idx);
$importSource = new ImportFile($file, ',', '"');
$bean = loadBean($this->_importModule);
$_REQUEST['columncount'] = 2;
$_REQUEST['colnum_0'] = 'date_entered';
$_REQUEST['colnum_1'] = 'last_name';
$_REQUEST['import_module'] = 'Contacts';
$_REQUEST['importlocale_charset'] = 'UTF-8';
$_REQUEST['importlocale_dateformat'] = $date_format;
$_REQUEST['importlocale_timeformat'] = $time_format;
$_REQUEST['importlocale_timezone'] = 'GMT';
$_REQUEST['importlocale_default_currency_significant_digits'] = '2';
$_REQUEST['importlocale_currency'] = '-99';
$_REQUEST['importlocale_dec_sep'] = '.';
$_REQUEST['importlocale_currency'] = '-99';
$_REQUEST['importlocale_default_locale_name_format'] = 's f l';
$_REQUEST['importlocale_num_grp_sep'] = ',';
$importer = new Importer($importSource, $bean);
$importer->import();
$query = "SELECT date_entered from contacts where created_by='{$GLOBALS['current_user']->id}'";
$result = $GLOBALS['db']->query($query);
$row = $GLOBALS['db']->fetchByAssoc($result);
$this->assertEquals($expected_datetime, $GLOBALS['db']->fromConvert($row['date_entered'], 'datetime'), 'Got incorrect date_entered.');
}
示例4: ejecutar
public function ejecutar($focus, $string_parametros)
{
$this->procesar_parametros($string_parametros);
$alarma = loadBean('gcoop_alarmas');
$alarma->parent_type = $focus->module_dir;
$alarma->parent_id = $focus->id;
$alarma->destinatario = $this->destinatario;
$alarma->notificacion = $this->notificacion;
$alarma->parametro = $this->parametro;
$alarma->valor = $this->valor;
#sumarle dias no fin de semana!
$fecha = new DateTime();
$dia = new DateInterval('P1D');
while ($this->cantidad_dias > 0) {
$fecha->add($dia);
if ($fecha->format('N') < 6) {
$this->cantidad_dias -= 1;
}
}
$timedate = TimeDate::getInstance();
$alarma->fecha_disparo = $timedate->asDb($fecha);
$alarma->save();
if (method_exists($focus, 'notificar')) {
$focus->notificar("Se creó alarama con fecha de disparo {$alarma->fecha_disparo}", 'Alarma');
}
}
示例5: testProcessFullListQuery
public function testProcessFullListQuery()
{
$loadedContact = loadBean('Contacts');
$loadedContact->disable_row_level_security = true;
$contactList = $loadedContact->get_full_list();
$exampleContact = array_pop($contactList);
$this->assertNotNull($exampleContact->fetched_row['last_name']);
}
示例6: changeUserTitle
function changeUserTitle(SugarBean $bean, $event, $arguments)
{
if ($bean->fetched_row['assigned_user_id'] != $bean->assigned_user_id) {
$user = loadBean('Users');
$user->retrieve($bean->assigned_user_id);
$user->title = 'branch';
$user->save();
}
}
示例7: echo_module_fields
function echo_module_fields($module)
{
global $current_language, $app_list_strings;
$bean = loadBean($module);
$mod_strings = return_module_language($current_language, $bean->module_dir);
echo "<div class='container' style='font-size:110%;'><center style='font-weight:bold;'>Поля модуля {$app_list_strings['moduleList'][$module]}:</center>\r\n\t\t<br/><table style='width:100%;font-size:100%;'>";
foreach ($bean->field_defs as $field) {
echo "<tr><td style='background-color:#596971;color:#fff;text-align:right;padding-right:5px;' width='60%'>\r\n\t\t\t<b>{$mod_strings[$field['vname']]}</b> [{$field['type']}]:</td>\r\n\t\t<td style='background-color:#FFF'>\r\n\t\t\t{$field['name']}</td></tr>";
}
echo "</table></div>";
}
示例8: setUp
public function setUp()
{
global $dictionary, $bean_list;
$this->old_dictionary = $dictionary;
$this->old_bean_list = $bean_list;
$this->test_standart_field = new TestStandardField();
$this->test_standart_field->module = 'Accounts';
loadBean($this->test_standart_field->module);
$this->test_field = get_widget('varchar');
$this->test_field->name = 'name';
$this->bean_name = get_valid_bean_name($this->test_standart_field->module);
}
示例9: get_new_record_form
function get_new_record_form()
{
$module = !empty($GLOBALS['QCModule']) ? $GLOBALS['QCModule'] : $GLOBALS['module'];
$focus = loadBean($module);
if (!$focus->ACLAccess('save')) {
return;
}
$view_sqc = new ViewFactory();
//avoid ViewFactory::_loadConfig() undefined value
$view_sqc->module = '';
$view_sqc->action = '';
$view_sqc = $view_sqc->loadView('sidequickcreate', $module);
$view_sqc->module = $module;
if ($view_sqc->preDisplay()) {
return $view_sqc->display();
}
}
示例10: action_delete
protected function action_delete()
{
if ($_REQUEST['record'] != $GLOBALS['current_user']->id && $GLOBALS['current_user']->isAdminForModule('Users')) {
$u = new User();
$u->retrieve($_REQUEST['record']);
$u->status = 'Inactive';
$u->deleted = 1;
$u->employee_status = 'Terminated';
$u->save();
$GLOBALS['log']->info("User id: {$GLOBALS['current_user']->id} deleted user record: {$_REQUEST['record']}");
$eapm = loadBean('EAPM');
$eapm->delete_user_accounts($_REQUEST['record']);
$GLOBALS['log']->info("Removing user's External Accounts");
SugarApplication::redirect("index.php?module=Users&action=index");
} else {
sugar_die("Unauthorized access to administration.");
}
}
示例11: process_relate
private function process_relate($field)
{
$id_name = $this->bean->field_defs[$field]['id_name'];
$link = $this->bean->field_defs[$field]['link'];
$relationship = $this->bean->field_defs[$link]['relationship'];
$id_list = array();
if (isset($_REQUEST[$id_name]) && !empty($_REQUEST[$id_name]) || isset($this->bean->{$id_name}) && !empty($this->bean->{$id_name})) {
$parent_id = empty($this->bean->id) ? $_REQUEST[$id_name] : $this->bean->{$id_name};
$parent_bean = loadBean($this->bean->field_defs[$field]['module']);
$parent_bean->retrieve($parent_id);
foreach ($parent_bean->field_defs as $parent_field => $defs) {
if ($defs['type'] == 'link' && $defs['relationship'] == $relationship) {
$parent_bean->load_relationship($parent_field);
$id_list = $parent_bean->{$parent_field}->get();
}
}
}
return $id_list;
}
示例12: afterSave
function afterSave(&$bean)
{
if (isset($bean->realty_id) && $bean->realty_id != '') {
$realty = new Realty();
$realty->retrieve($bean->realty_id);
if (isset($realty->last_contact)) {
$realty->last_contact = date('Y-m-d');
$realty->save();
}
}
if (isset($bean->parent_id) && $bean->parent_id != '') {
$client = loadBean($bean->parent_type);
$client->retrieve($bean->parent_id);
if (isset($client->last_contact)) {
$client->last_contact = date('Y-m-d');
$client->save();
}
}
}
示例13: testParentsAreRelatedDuringImport
public function testParentsAreRelatedDuringImport()
{
$file = 'upload://test50438.csv';
$ret = file_put_contents($file, $this->fileArr);
$this->assertGreaterThan(0, $ret, 'Failed to write to ' . $file . ' for content ' . var_export($this->fileArr, true));
$importSource = new ImportFile($file, ',', '"');
$bean = loadBean('Calls');
$_REQUEST['columncount'] = 5;
$_REQUEST['colnum_0'] = 'id';
$_REQUEST['colnum_1'] = 'subject';
$_REQUEST['colnum_2'] = 'status';
$_REQUEST['colnum_3'] = 'parent_type';
$_REQUEST['colnum_4'] = 'parent_id';
$_REQUEST['import_module'] = 'Contacts';
$_REQUEST['importlocale_charset'] = 'UTF-8';
$_REQUEST['importlocale_timezone'] = 'GMT';
$_REQUEST['importlocale_default_currency_significant_digits'] = '2';
$_REQUEST['importlocale_currency'] = '-99';
$_REQUEST['importlocale_dec_sep'] = '.';
$_REQUEST['importlocale_currency'] = '-99';
$_REQUEST['importlocale_default_locale_name_format'] = 's f l';
$_REQUEST['importlocale_num_grp_sep'] = ',';
$_REQUEST['importlocale_dateformat'] = 'm/d/y';
$_REQUEST['importlocale_timeformat'] = 'h:i:s';
$importer = new Importer($importSource, $bean);
$importer->import();
//fetch the bean using the passed in id and get related contacts
require_once 'modules/Calls/Call.php';
$call = new Call();
$call->retrieve($this->call_id);
$call->load_relationship('contacts');
$related_contacts = $call->contacts->get();
//test that the contact id is in the array of related contacts.
$this->assertContains($this->contact->id, $related_contacts, ' Contact was not related during simulated import despite being set in related parent id');
unset($call);
/*
if (is_file($file)) {
unlink($file);
}
*/
}
示例14: preDisplay
/**
* @see SugarView::preDisplay()
*/
public function preDisplay()
{
if (!empty($_REQUEST['source_module']) && $_REQUEST['source_module'] != 'undefined' && !empty($_REQUEST['record'])) {
$this->bean = loadBean($_REQUEST['source_module']);
if ($this->bean instanceof SugarBean && !in_array($this->bean->object_name, array('EmailMan'))) {
$this->bean->retrieve($_REQUEST['record']);
if (!empty($this->bean->id)) {
$_REQUEST['parent_id'] = $this->bean->id;
}
if (!empty($this->bean->module_dir)) {
$_REQUEST['parent_type'] = $this->bean->module_dir;
}
if (!empty($this->bean->name)) {
$_REQUEST['parent_name'] = $this->bean->name;
}
if (!empty($this->bean->id)) {
$_REQUEST['return_id'] = $this->bean->id;
}
if (!empty($this->bean->module_dir)) {
$_REQUEST['return_module'] = $this->bean->module_dir;
}
//Now preload any related fields
if (isset($_REQUEST['module'])) {
$target_bean = loadBean($_REQUEST['module']);
foreach ($target_bean->field_defs as $fields) {
if ($fields['type'] == 'relate' && isset($fields['module']) && $fields['module'] == $_REQUEST['source_module'] && isset($fields['rname'])) {
$rel_name = $fields['rname'];
if (isset($this->bean->{$rel_name})) {
$_REQUEST[$fields['name']] = $this->bean->{$rel_name};
}
if (!empty($_REQUEST['record']) && !empty($fields['id_name'])) {
$_REQUEST[$fields['id_name']] = $_REQUEST['record'];
}
}
}
}
}
$this->_isDCForm = true;
}
}
示例15: handleSave
/**
* Saves a new Contact as well as any related items passed in.
*
* @return null
*/
protected function handleSave()
{
require_once 'modules/Campaigns/utils.php';
require_once "include/formbase.php";
$lead = false;
if (!empty($_REQUEST['record'])) {
$lead = new Lead();
$lead->retrieve($_REQUEST['record']);
}
global $beanList;
$this->loadDefs();
$beans = array();
$selectedBeans = array();
$selects = array();
// Make sure the contact object is availible for relationships.
$beans['Contacts'] = new Contact();
// Contacts
if (!empty($_REQUEST['selectedContact'])) {
$beans['Contacts']->retrieve($_REQUEST['selectedContact']);
if (!empty($beans['Contacts']->id)) {
$beans['Contacts']->new_with_id = false;
unset($_REQUEST["convert_create_Contacts"]);
unset($_POST["convert_create_Contacts"]);
}
} elseif (!empty($_REQUEST["convert_create_Contacts"]) && $_REQUEST["convert_create_Contacts"] != "false" && !isset($_POST['ContinueContact'])) {
require_once 'modules/Contacts/ContactFormBase.php';
$contactForm = new ContactFormBase();
$duplicateContacts = $contactForm->checkForDuplicates('Contacts');
if (isset($duplicateContacts)) {
echo $contactForm->buildTableForm($duplicateContacts, 'Contacts');
return;
}
$this->new_contact = true;
} elseif (isset($_POST['ContinueContact'])) {
$this->new_contact = true;
}
// Accounts
if (!empty($_REQUEST['selectedAccount'])) {
$_REQUEST['account_id'] = $_REQUEST['selectedAccount'];
unset($_REQUEST["convert_create_Accounts"]);
unset($_POST["convert_create_Accounts"]);
} elseif (!empty($_REQUEST["convert_create_Accounts"]) && $_REQUEST["convert_create_Accounts"] != "false" && empty($_POST['ContinueAccount'])) {
require_once 'modules/Accounts/AccountFormBase.php';
$accountForm = new AccountFormBase();
$duplicateAccounts = $accountForm->checkForDuplicates('Accounts');
if (isset($duplicateAccounts)) {
echo $accountForm->buildTableForm($duplicateAccounts);
return;
}
}
foreach ($this->defs as $module => $vdef) {
//Create a new record if "create" was selected
if (!empty($_REQUEST["convert_create_{$module}"]) && $_REQUEST["convert_create_{$module}"] != "false") {
//Save the new record
$bean = $beanList[$module];
if (empty($beans[$module])) {
$beans[$module] = new $bean();
}
$this->populateNewBean($module, $beans[$module], $beans['Contacts'], $lead);
// when creating a new contact, create the id for linking with other modules
// and do not populate it with lead's old account_id
if ($module == 'Contacts') {
$beans[$module]->id = create_guid();
$beans[$module]->new_with_id = true;
$beans[$module]->account_id = '';
}
} else {
if (!empty($vdef['ConvertLead']['select'])) {
//Save the new record
$select = $vdef['ConvertLead']['select'];
$fieldDef = $beans['Contacts']->field_defs[$select];
if (!empty($fieldDef['id_name']) && !empty($_REQUEST[$fieldDef['id_name']])) {
$beans['Contacts']->{$fieldDef}['id_name'] = $_REQUEST[$fieldDef['id_name']];
$selects[$module] = $_REQUEST[$fieldDef['id_name']];
if (!empty($_REQUEST[$select])) {
$beans['Contacts']->{$select} = $_REQUEST[$select];
}
// Bug 39268 - Add the existing beans to a list of beans we'll potentially add the lead's activities to
$bean = loadBean($module);
$bean->retrieve($_REQUEST[$fieldDef['id_name']]);
$selectedBeans[$module] = $bean;
// If we selected the Contact, just overwrite the $beans['Contacts']
if ($module == 'Contacts') {
$beans[$module] = $bean;
}
}
}
}
}
$this->handleActivities($lead, $beans);
// Bug 39268 - Add the lead's activities to the selected beans
$this->handleActivities($lead, $selectedBeans);
//link selected account to lead if it exists
if (!empty($selectedBeans['Accounts'])) {
$lead->account_id = $selectedBeans['Accounts']->id;
//.........这里部分代码省略.........