本文整理汇总了PHP中BeanFactory::getBean方法的典型用法代码示例。如果您正苦于以下问题:PHP BeanFactory::getBean方法的具体用法?PHP BeanFactory::getBean怎么用?PHP BeanFactory::getBean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BeanFactory
的用法示例。
在下文中一共展示了BeanFactory::getBean方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUserQuota
/**
* Return the quota for the current user and time period
*
* @return mixed
*/
protected function getUserQuota()
{
/* @var $quota_bean Quota */
$quota_bean = BeanFactory::getBean('Quotas');
$quota = $quota_bean->getRollupQuota($this->getArg('timeperiod_id'), $this->getArg('user_id'));
return SugarCurrency::convertAmountToBase($quota['amount'], $quota['currency_id']);
}
示例2: process
function process()
{
global $current_user, $timedate, $app_list_strings, $current_language, $mod_strings;
$mod_strings = return_module_language($current_language, 'Contracts');
parent::process();
if ($this->viaAJAX) {
// override for ajax call
$this->ss->assign('saveOnclick', "onclick='if(check_form(\"contractsQuickCreate\")) return SUGAR.subpanelUtils.inlineSave(this.form.id, \"contracts\"); else return false;'");
$this->ss->assign('cancelOnclick', "onclick='return SUGAR.subpanelUtils.cancelCreate(\"subpanel_contracts\")';");
}
$this->ss->assign('viaAJAX', $this->viaAJAX);
$this->javascript = new javascript();
$this->javascript->setFormName('contractsQuickCreate');
$focus = BeanFactory::getBean('Contracts');
$this->javascript->setSugarBean($focus);
$this->javascript->addAllFields('');
$status_options = isset($focus->status) ? get_select_options_with_id($app_list_strings['contract_status_dom'], $focus->status) : get_select_options_with_id($app_list_strings['contract_status_dom'], '');
$this->ss->assign('STATUS_OPTIONS', $status_options);
$json = getJSONobj();
$popup_request_data = array('call_back_function' => 'set_return', 'form_name' => 'contractsQuickCreate', 'field_to_name_array' => array('id' => 'account_id', 'name' => 'account_name'));
$encoded_popup_request_data = $json->encode($popup_request_data);
$this->ss->assign('encoded_popup_request_data', $encoded_popup_request_data);
$popup_request_data = array('call_back_function' => 'set_return', 'form_name' => 'contractsQuickCreate', 'field_to_name_array' => array('id' => 'team_id', 'name' => 'team_name'));
$this->ss->assign('encoded_team_popup_request_data', $json->encode($popup_request_data));
$this->ss->assign('additionalScripts', $this->javascript->getScript(false));
}
示例3: setUp
public function setUp()
{
SugarTestHelper::setUp('beanList');
SugarTestHelper::setUp('beanFiles');
SugarTestHelper::setUp('current_user');
$this->case = BeanFactory::getBean('Cases');
}
示例4: process
public function process()
{
// fetch the data from the filter end point
$file = 'modules/ForecastWorksheets/clients/base/api/ForecastWorksheetsFilterApi.php';
$klass = 'ForecastWorksheetsFilterApi';
SugarAutoLoader::requireWithCustom('include/api/RestService.php');
SugarAutoLoader::requireWithCustom($file);
$klass = SugarAutoLoader::customClass($klass);
/* @var $obj ForecastWorksheetsFilterApi */
$obj = new $klass();
$api = new RestService();
$api->user = $GLOBALS['current_user'];
$data = $obj->forecastWorksheetsGet($api, array('module' => 'ForecastWorksheets', 'timeperiod_id' => $this->getArg('timeperiod_id'), 'user_id' => $this->getArg('user_id')));
$fields_array = array('date_closed' => 'date_closed', 'sales_stage' => 'sales_stage', 'name' => 'name', 'commit_stage' => 'commit_stage', 'probability' => 'probability');
$admin = BeanFactory::getBean('Administration');
$settings = $admin->getConfigForModule('Forecasts');
if ($settings['show_worksheet_best']) {
$fields_array['best_case'] = 'best_case';
}
if ($settings['show_worksheet_likely']) {
$fields_array['likely_case'] = 'likely_case';
}
if ($settings['show_worksheet_worst']) {
$fields_array['worst_case'] = 'worst_case';
}
$seed = BeanFactory::getBean('ForecastWorksheets');
return $this->getContent($data['records'], $seed, $fields_array, 'commit_stage', $this->getArg('filters'));
}
示例5: run
public function run()
{
// this always needs to be ran
// get the get_widget helper and the StandardField Helper
require_once 'modules/DynamicFields/FieldCases.php';
require_once 'modules/ModuleBuilder/parsers/StandardField.php';
// we are working with opportunities
$bean = BeanFactory::getBean('Opportunities');
// get the field defs
$field_defs = $bean->getFieldDefinition('sales_stage');
// load the field type up
$f = get_widget($field_defs['type']);
// populate the row from the vardefs that were loaded
$f->populateFromRow($field_defs);
$this->log('Current Sales Stage Default is: ' . var_export($f->default, true));
// lets always make sure that the default is in the list of options
if (isset($f->options) && isset($GLOBALS['app_list_strings'][$f->options])) {
if (!in_array($f->default, array_keys($GLOBALS['app_list_strings'][$f->options]))) {
$this->log(var_export($f->default, true) . ' Is Not In The List Of Options');
$f->default = array_shift(array_keys($GLOBALS['app_list_strings'][$f->options]));
$f->default_value = array_shift(array_keys($GLOBALS['app_list_strings'][$f->options]));
$this->log('New Sales Stage Default Is: ' . var_export($f->default, true));
// save the changes to the field
$df = new StandardField($bean->module_name);
$df->setup($bean);
$f->module = $bean;
$f->save($df);
}
}
}
示例6: validate_authenticated
/**
* Validate the provided session information is correct and current. Load the session.
*
* @param String $session_id -- The session ID that was returned by a call to login.
* @return true -- If the session is valid and loaded.
* @return false -- if the session is not valid.
*/
function validate_authenticated($session_id)
{
$GLOBALS['log']->info('Begin: SoapHelperWebServices->validate_authenticated');
if (!empty($session_id)) {
// only initialize session once in case this method is called multiple times
if (!session_id()) {
session_id($session_id);
session_start();
}
if (!empty($_SESSION['is_valid_session']) && $this->is_valid_ip_address('ip_address') && $_SESSION['type'] == 'user') {
global $current_user;
require_once 'modules/Users/User.php';
$current_user = BeanFactory::getBean('Users', $_SESSION['user_id']);
$this->login_success();
$GLOBALS['log']->info('Begin: SoapHelperWebServices->validate_authenticated - passed');
$GLOBALS['log']->info('End: SoapHelperWebServices->validate_authenticated');
return true;
}
$GLOBALS['log']->debug("calling destroy");
session_destroy();
}
LogicHook::initialize();
$GLOBALS['logic_hook']->call_custom_logic('Users', 'login_failed');
$GLOBALS['log']->info('End: SoapHelperWebServices->validate_authenticated - validation failed');
return false;
}
示例7: save_lines
function save_lines(array $post, AOR_Report $bean, $postKey)
{
$seenIds = array();
if (isset($post[$postKey . 'id'])) {
foreach ($post[$postKey . 'id'] as $key => $id) {
if ($id) {
$aorChart = BeanFactory::getBean('AOR_Charts', $id);
} else {
$aorChart = BeanFactory::newBean('AOR_Charts');
}
$aorChart->name = $post[$postKey . 'title'][$key];
$aorChart->type = $post[$postKey . 'type'][$key];
$aorChart->x_field = $post[$postKey . 'x_field'][$key];
$aorChart->y_field = $post[$postKey . 'y_field'][$key];
$aorChart->aor_report_id = $bean->id;
$aorChart->save();
$seenIds[] = $aorChart->id;
}
}
//Any beans that exist but aren't in $seenIds must have been removed.
foreach ($bean->get_linked_beans('aor_charts', 'AOR_Charts') as $chart) {
if (!in_array($chart->id, $seenIds)) {
$chart->mark_deleted($chart->id);
}
}
}
示例8: process
function process()
{
global $current_user, $timedate, $app_list_strings, $current_language, $mod_strings;
$mod_strings = return_module_language($current_language, 'Opportunities');
$json = getJSONobj();
parent::process();
list($num_grp_sep, $dec_sep) = get_number_seperators();
$this->ss->assign('NUM_GRP_SEP', $num_grp_sep);
$this->ss->assign('DEC_SEP', $dec_sep);
$this->ss->assign('CURRENCY_ID', $current_user->getPreference('currency'));
$this->ss->assign("SALES_STAGE_OPTIONS", get_select_options_with_id($app_list_strings['sales_stage_dom'], ''));
$this->ss->assign("LEAD_SOURCE_OPTIONS", get_select_options_with_id($app_list_strings['lead_source_dom'], ''));
$this->ss->assign('prob_array', $json->encode($app_list_strings['sales_probability_dom']));
if ($this->viaAJAX) {
// override for ajax call
$this->ss->assign('saveOnclick', "onclick='if(check_form(\"opportunitiesQuickCreate\")) return SUGAR.subpanelUtils.inlineSave(this.form.id, \"opportunities\"); else return false;'");
$this->ss->assign('cancelOnclick', "onclick='return SUGAR.subpanelUtils.cancelCreate(\"subpanel_opportunities\")';");
}
$this->ss->assign('viaAJAX', $this->viaAJAX);
$this->javascript = new javascript();
$this->javascript->setFormName('opportunitiesQuickCreate');
$focus = BeanFactory::getBean('Opportunities');
$this->javascript->setSugarBean($focus);
$this->javascript->addAllFields('');
$this->ss->assign('additionalScripts', $this->javascript->getScript(false));
}
示例9: addRecordsToProspectList
/**
* Add records to a specific prospect list
*
* @param $moduleName the module name for the records that will be associated to the prospect list
* @param $prospectListId the id of the prospect list
* @param $recordIds Array of record ids to be added to the prospect list
* @return $results Associative array containing status for each record.
*/
public function addRecordsToProspectList($moduleName, $prospectListId, $recordIds)
{
$prospectList = BeanFactory::getBean("ProspectLists", $prospectListId, array('strict_retrieve' => true));
if (empty($prospectList)) {
return false;
}
$bean = BeanFactory::newBean($moduleName);
$results = array();
$relationship = '';
foreach ($bean->get_linked_fields() as $field => $def) {
if ($bean->load_relationship($field)) {
if ($bean->{$field}->getRelatedModuleName() == 'ProspectLists') {
$relationship = $field;
break;
}
}
}
if ($relationship != '') {
foreach ($recordIds as $id) {
$retrieveResult = $bean->retrieve($id);
if ($retrieveResult === null) {
$results[$id] = false;
} else {
$bean->load_relationship($relationship);
$bean->prospect_lists->add($prospectListId);
$results[$id] = true;
}
}
}
return $results;
}
示例10: process
function process()
{
global $current_user, $timedate, $app_list_strings, $current_language, $mod_strings;
$mod_strings = return_module_language($current_language, 'ProjectTask');
parent::process();
if ($this->viaAJAX) {
// override for ajax call
$this->ss->assign('saveOnclick', "onclick='if(check_form(\"projectTaskQuickCreate\")) return SUGAR.subpanelUtils.inlineSave(this.form.id, \"projecttask\"); else return false;'");
$this->ss->assign('cancelOnclick', "onclick='return SUGAR.subpanelUtils.cancelCreate(\"subpanel_projecttask\")';");
}
$this->ss->assign('viaAJAX', $this->viaAJAX);
$this->javascript = new javascript();
$this->javascript->setFormName('projectTaskQuickCreate');
$focus = BeanFactory::getBean('ProjectTask');
$this->javascript->setSugarBean($focus);
$this->javascript->addAllFields('');
$this->ss->assign('additionalScripts', $this->javascript->getScript(false));
$json = getJSONobj();
///////////////////////////////////////
///
/// SETUP PARENT POPUP
$popup_request_data = array('call_back_function' => 'set_return', 'form_name' => 'projectTypeQuickCreate', 'field_to_name_array' => array('id' => 'parent_id', 'name' => 'parent_name'));
$encoded_parent_popup_request_data = $json->encode($popup_request_data);
$this->ss->assign('encoded_parent_popup_request_data', $encoded_parent_popup_request_data);
$popup_request_data = array('call_back_function' => 'set_return', 'form_name' => 'projectTaskQuickCreate', 'field_to_name_array' => array('id' => 'account_id', 'name' => 'account_name'));
$encoded_popup_request_data = $json->encode($popup_request_data);
$this->ss->assign('encoded_popup_request_data', $encoded_popup_request_data);
$popup_request_data = array('call_back_function' => 'set_return', 'form_name' => 'projectTaskQuickCreate', 'field_to_name_array' => array('id' => 'team_id', 'name' => 'team_name'));
$this->ss->assign('encoded_team_popup_request_data', $json->encode($popup_request_data));
}
示例11: run
public function run()
{
if (!($this->from_flavor == 'ce' && $this->toFlavor('pro'))) {
return;
}
$result = $this->db->query("SELECT id, contents, assigned_user_id FROM user_preferences WHERE deleted = 0 AND category = 'Home'");
if (empty($result)) {
return $this->fail("Unable to upgrade dashlets");
}
while ($row = $this->db->fetchByAssoc($result)) {
$content = unserialize(base64_decode($row['contents']));
$assigned_user_id = $row['assigned_user_id'];
$record_id = $row['id'];
$current_user = BeanFactory::getBean('Users', $row['assigned_user_id']);
if (!empty($content['dashlets']) && !empty($content['pages'])) {
$originalDashlets = $content['dashlets'];
foreach ($originalDashlets as $key => $ds) {
if (!empty($ds['options']['url']) && stristr($ds['options']['url'], 'http://www.sugarcrm.com/crm/product/gopro')) {
unset($originalDashlets[$key]);
}
}
$current_user->setPreference('dashlets', $originalDashlets, 0, 'Home');
}
}
}
示例12: createRecord
/**
* Create the bug record and optionally perform post-save actions for Portal
*/
public function createRecord($api, $args)
{
//create the bug using the ModuleApi
$contact = null;
if (isset($_SESSION['type']) && $_SESSION['type'] == 'support_portal') {
$contact = BeanFactory::getBean('Contacts', $_SESSION['contact_id'], array('strict_retrieve' => true));
if (!empty($contact)) {
$args['assigned_user_id'] = $contact->assigned_user_id;
$args['team_id'] = $contact->fetched_row['team_id'];
$args['team_set_id'] = $contact->fetched_row['team_set_id'];
}
}
$data = parent::createRecord($api, $args);
$bugId = null;
if (isset($data['id']) && !empty($data['id'])) {
$bugId = $data['id'];
} else {
//bug not created, can't do post-processes - bail out
return $data;
}
if (!empty($bugId) && !empty($contact)) {
$bug = BeanFactory::getBean('Bugs', $bugId);
$bug->load_relationship('contacts');
$bug->contacts->add($contact->id);
$bug->load_relationship('accounts');
$bug->accounts->add($contact->account_id);
}
return $data;
}
示例13: action_save
public function action_save()
{
$item = BeanFactory::getBean('xInventories');
if ($this->bean->new_with_id == true) {
// new bean want to update xinventory must be implemented in xInventoryRecord bean class;
} else {
if ($this->pre_operation != $this->bean->operation || $this->pre_quantity != $this->bean->quantity || $this->pre_xinventory_id != $this->bean->xinventory_id) {
if ($this->pre_xinventory_id == $this->bean->xinventory_id) {
if ($item->retrieve($this->bean->xinventory_id) != null) {
if ($this->pre_operation == $this->bean->operation) {
$diff = $this->bean->quantity - $this->pre_quantity;
if ($this->bean->operation == 'in') {
$item->quantity += $diff;
} else {
$item->quantity -= $diff;
}
} else {
// operation changed
if ($this->pre_operation == 'in') {
$item->quantity -= $this->pre_quantity;
$item->quantity -= $this->bean->quantity;
} else {
$item->quantity += $this->pre_quantity;
$item->quantity += $this->bean->quantity;
}
}
if ($item->quantity < 0) {
$item->quantity = 0;
}
$item->save();
}
} else {
// xinventory id changed
if ($item->retrieve($this->pre_xinventory_id) != null) {
if ($this->pre_operation == 'in') {
$item->quantity -= $this->pre_quantity;
if ($item->quantity < 0) {
$item->quantity = 0;
}
} else {
$item->quantity += $this->pre_quantity;
}
$item->save();
}
if ($item->retrieve($this->bean->xinventory_id) != null) {
if ($this->bean->operation == 'in') {
$item->quantity += $this->bean->quantity;
} else {
$item->quantity -= $this->bean->quantity;
if ($item->quantity < 0) {
$item->quantity = 0;
}
}
$item->save();
}
}
}
}
parent::action_save();
}
示例14: fill_in_additional_detail_fields
function fill_in_additional_detail_fields()
{
$kbdoc = BeanFactory::getBean('KBDocuments', $this->kbdocument_id);
if (!empty($kbdoc->id)) {
$this->kbdocument_name = $kbdoc->kbdocument_name;
}
}
示例15: customCaseAssignment
public function customCaseAssignment($bean, $event, $args)
{
// if the email is related to a case, it is inbound and unread
if (!empty($bean->parent_id) && !empty($bean->fetched_row) && $bean->parent_type == 'Cases' && $bean->type == 'inbound' && $bean->status == 'unread' && $bean->fetched_row['parent_type'] != 'Cases' && $bean->fetched_row['parent_id'] != $bean->parent_id) {
$case = BeanFactory::getBean('Cases', $bean->parent_id);
if (!empty($case->id)) {
// find if our default inbound empty team exists...
$inbound_team = BeanFactory::getBean('Teams');
$inbound_team->retrieve_by_string_fields(array('name' => $this->inbound_cases_team));
$assignment_team = BeanFactory::getBean('Teams');
$assignment_team->retrieve_by_string_fields(array('name' => $this->assignment_cases_team));
if (!empty($inbound_team->id) && !empty($case->team_id) && $inbound_team->id == $case->team_id && !empty($assignment_team->id)) {
$GLOBALS['log']->debug('inboundEmailsLogic->customCaseAssignment - Routing appropriately case ' . $case->id);
// START - CUSTOM ASSIGNMENT LOGIC GOES HERE!
// assign both the email and the case to the correct team (who can see the case/email?)
$bean->team_id = $bean->team_set_id = $assignment_team->id;
$case->team_id = $case->team_set_id = $assignment_team->id;
// now complete the custom case routing...
if ($case->assigned_user_id == '') {
// as an example let's assign the email and the case to a specific user (who needs to handle the case?)
// let's route to the Sugar default Admin
$case->assigned_user_id = '1';
$bean->assigned_user_id = '1';
}
// END - CUSTOM ASSIGNMENT LOGIC GOES HERE!
$GLOBALS['log']->debug('inboundEmailsLogic->customCaseAssignment - Case ' . $case->id . ' routed');
$case->save();
}
}
}
}