本文整理汇总了PHP中BeanFactory类的典型用法代码示例。如果您正苦于以下问题:PHP BeanFactory类的具体用法?PHP BeanFactory怎么用?PHP BeanFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BeanFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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));
}
示例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: testGetLinkedBeans
public function testGetLinkedBeans()
{
//Test the accounts_leads relationship
$account = BeanFactory::newBean("Accounts");
$account->name = "GetLinkedBeans Test Account";
$account->save();
$this->createdBeans[] = $account;
$case = BeanFactory::newBean("Cases");
$case->name = "GetLinkedBeans Test Cases";
$case->save();
$this->createdBeans[] = $case;
$this->assertTrue($account->load_relationship("cases"));
$this->assertInstanceOf("Link2", $account->cases);
$this->assertTrue($account->cases->loadedSuccesfully());
$account->cases->add($case);
$account->save();
$where = array('lhs_field' => 'id', 'operator' => ' LIKE ', 'rhs_value' => "{$case->id}");
$cases = $account->get_linked_beans('cases', 'Case', array(), 0, 10, 0, $where);
$this->assertEquals(1, count($cases), 'Assert that we have found the test case linked to the test account');
$contact = BeanFactory::newBean("Contacts");
$contact->first_name = "First Name GetLinkedBeans Test Contacts";
$contact->last_name = "First Name GetLinkedBeans Test Contacts";
$contact->save();
$this->createdBeans[] = $contact;
$this->assertTrue($account->load_relationship("contacts"));
$this->assertInstanceOf("Link2", $account->contacts);
$this->assertTrue($account->contacts->loadedSuccesfully());
$account->contacts->add($contact);
$where = array('lhs_field' => 'id', 'operator' => ' LIKE ', 'rhs_value' => "{$contact->id}");
$contacts = $account->get_linked_beans('contacts', 'Contact', array(), 0, -1, 0, $where);
$this->assertEquals(1, count($contacts), 'Assert that we have found the test contact linked to the test account');
}
示例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: 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);
}
}
}
示例7: 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'));
}
示例8: init
function init($module_name, $subPanelName)
{
$GLOBALS['log']->debug("in ParserModifySubPanel: module_name={$module_name} child_module={$subPanelName}");
$this->moduleName = $module_name;
$this->subPanelName = $subPanelName;
global $beanList;
// Sometimes we receive a module name which is not in the correct CamelCase, so shift to lower case for all beanList lookups
$beanListLower = array_change_key_case($beanList);
// Retrieve the definitions for all the available subpanels for this module
$module = BeanFactory::newBeanByName($beanListLower[strtolower($this->moduleName)]);
require_once 'include/SubPanel/SubPanelDefinitions.php';
$spd = new SubPanelDefinitions($module);
// Get the lists of fields already in the subpanel and those that can be added in
// Get the fields lists from an aSubPanel object describing this subpanel from the SubPanelDefinitions object
$this->originalListViewDefs = array();
if (array_key_exists(strtolower($this->subPanelName), $spd->layout_defs['subpanel_setup'])) {
$originalPanel = $spd->load_subpanel($this->subPanelName, true);
$this->originalListViewDefs = $originalPanel->get_list_fields();
$this->panel = $spd->load_subpanel($subPanelName, false);
$this->listViewDefs = $this->panel->get_list_fields();
// Retrieve a copy of the bean for the parent module of this subpanel - so we can find additional fields for the layout
$subPanelParentModuleName = $this->panel->get_module_name();
$this->subPanelParentModule = null;
if (!empty($subPanelParentModuleName) && isset($beanListLower[strtolower($subPanelParentModuleName)])) {
$this->subPanelParentModule = BeanFactory::newBeanByName($beanListLower[strtolower($subPanelParentModuleName)]);
}
}
$this->language_module = $this->panel->template_instance->module_dir;
}
示例9: displayList
function displayList($layout_def)
{
global $app_strings;
global $subpanel_item_count;
$unique_id = $layout_def['subpanel_id'] . "_edit_" . $subpanel_item_count;
//bug 51512
if ($layout_def['EditView']) {
// @see SugarWidgetSubPanelTopButtonQuickCreate::get_subpanel_relationship_name()
$relationship_name = '';
if (!empty($layout_def['linked_field'])) {
$relationship_name = $layout_def['linked_field'];
$bean = BeanFactory::getBean($layout_def['module']);
if (!empty($bean->field_defs[$relationship_name]['relationship'])) {
$relationship_name = $bean->field_defs[$relationship_name]['relationship'];
}
}
$handler = 'subp_nav(\'' . $layout_def['module'] . '\', \'' . $layout_def['fields']['ID'] . '\', \'e\', this';
if (!empty($relationship_name)) {
$handler .= ', \'' . $relationship_name . '\'';
}
$handler .= ');';
return '<a href="#" onmouseover="' . $handler . '" onfocus="' . $handler . '" class="listViewTdToolsS1" id="' . $unique_id . '">' . $app_strings['LNK_EDIT'] . '</a>';
}
return '';
}
示例10: display
/**
* @see SugarView::display()
*/
public function display()
{
$ss = new Sugar_Smarty();
$ss->assign("MOD", $GLOBALS['mod_strings']);
$ss->assign("INSTRUCTION", "<h1>Retrieve seller list from ebay</h1>");
$bean = BeanFactory::getBean('xeBayAccounts');
$resp = $bean->get_list("", "ebay_auth_token<>''", 0, -1, -1, 0, false, array('name'));
if ($resp['row_count'] > 0) {
$ebay_account_options = "<select name='ebay_account_name' id='ebay_account_name' title=''>";
if ($resp['row_count'] > 1) {
$ebay_account_options .= "<option value='All'>All</option>";
}
foreach ($resp['list'] as &$account) {
$name = $account->name;
$ebay_account_options .= "<option value='{$name}'>{$name}</option>";
}
$ebay_account_options .= "</select>";
$ss->assign("EBAY_ACCOUNT_OPTIONS", $ebay_account_options);
}
$javascript = <<<EOQ
function ImportConfirm()
{
\t\treturn confirm("Do you want to retrieve seller list now ?");
}
EOQ;
$ss->assign("JAVASCRIPT", $javascript);
echo $ss->fetch("modules/xeBaySellerLists/tpls/import.tpl");
}
示例11: __construct
/**
*
* @global type $locale
* @codeCoverageIgnore
*/
public function __construct()
{
global $locale;
$this->locale = $locale;
$this->eventDefinitionBean = BeanFactory::getBean('pmse_BpmEventDefinition');
parent::__construct();
}
示例12: 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;
}
示例13: 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));
}
示例14: 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');
}
}
}
示例15: saveProjectData
/**
* Method to save record in database
* @param $projectData
* @return bool
*/
public function saveProjectData($projectData)
{
$source_definition = json_decode($projectData['rst_source_definition']);
if (isset($projectData[$this->suffix . 'name']) && !empty($projectData[$this->suffix . 'name'])) {
$name = $this->getNameWithSuffix($projectData[$this->suffix . 'name']);
} else {
$name = $this->getNameWithSuffix($projectData[$this->name]);
}
$projectData['rst_uid'] = PMSEEngineUtils::generateUniqueID();
$source_definition->name = $name;
$source_definition->id = $projectData['rst_uid'];
$projectData['rst_source_definition'] = json_encode($source_definition);
unset($projectData[$this->id]);
unset($projectData['rst_uid']);
$new_uid = parent::saveProjectData($projectData);
if ($new_uid) {
// Update new id into 'rst_source_definition' field
$br_bean = BeanFactory::getBean('pmse_Business_Rules', $new_uid);
$def = json_decode($br_bean->rst_source_definition);
$def->id = $new_uid;
$br_bean->rst_source_definition = json_encode($def);
$br_bean->save();
return $new_uid;
} else {
return false;
}
}