本文整理汇总了PHP中BeanFactory::newBeanByName方法的典型用法代码示例。如果您正苦于以下问题:PHP BeanFactory::newBeanByName方法的具体用法?PHP BeanFactory::newBeanByName怎么用?PHP BeanFactory::newBeanByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BeanFactory
的用法示例。
在下文中一共展示了BeanFactory::newBeanByName方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: getClassicModuleTitle
} else {
if (!$export && empty($_REQUEST['repair_silent'])) {
if (empty($hideModuleMenu)) {
echo getClassicModuleTitle($mod_strings['LBL_REPAIR_DATABASE'], array($mod_strings['LBL_REPAIR_DATABASE']), true);
}
echo "<h1 id=\"rdloading\">{$mod_strings['LBL_REPAIR_DATABASE_PROCESSING']}</h1>";
ob_flush();
}
$sql = '';
VardefManager::clearVardef();
$repairedTables = array();
foreach ($beanFiles as $bean => $file) {
if (file_exists($file)) {
require_once $file;
unset($GLOBALS['dictionary'][$bean]);
$focus = BeanFactory::newBeanByName($bean);
if ($focus instanceof SugarBean && !isset($repairedTables[$focus->table_name])) {
$sql .= $db->repairTable($focus, $execute);
$repairedTables[$focus->table_name] = true;
}
//Repair Custom Fields
if ($focus instanceof SugarBean && $focus->hasCustomFields() && !isset($repairedTables[$focus->table_name . '_cstm'])) {
$df = new DynamicField($focus->module_dir);
//Need to check if the method exists as during upgrade an old version of Dynamic Fields may be loaded.
if (method_exists($df, "repairCustomFields")) {
$df->bean = $focus;
$sql .= $df->repairCustomFields($execute);
$repairedTables[$focus->table_name . '_cstm'] = true;
}
}
}
示例3: process_page
//.........这里部分代码省略.........
$button .= "<input style='display: none' checked type='checkbox' name='mass[]' value='{$record}'>\n";
}
}
//START:FOR MULTI-SELECT
$multi_select = false;
if (!empty($_REQUEST['mode']) && strtoupper($_REQUEST['mode']) == 'MULTISELECT') {
$multi_select = true;
$button .= "<input type='hidden' name='mode' value='MultiSelect'>";
$button .= "<input type='button' name='button' class='button' onclick=\"send_back_selected('{$currentModule}',document.MassUpdate,'mass[]','" . $app_strings['ERR_NOTHING_SELECTED'] . "', request_data.field_to_name_array);\" title='" . $app_strings['LBL_SELECT_BUTTON_TITLE'] . "' value=' " . $app_strings['LBL_SELECT_BUTTON_LABEL'] . " ' />\n";
}
//END:FOR MULTI-SELECT
if (!$hide_clear_button) {
$button .= "<input type='button' name='button' class='button' onclick=\"send_back('','');\" title='" . $app_strings['LBL_CLEAR_BUTTON_TITLE'] . "' value=' " . $app_strings['LBL_CLEAR_BUTTON_LABEL'] . " ' />\n";
}
$button .= "<input type='submit' name='button' class='button' onclick=\"window.close();\" title='" . $app_strings['LBL_CANCEL_BUTTON_TITLE'] . "' value=' " . $app_strings['LBL_CANCEL_BUTTON_LABEL'] . " ' />\n";
if (isset($this->_popupMeta['templateForm'])) {
$form = new XTemplate($this->_popupMeta['templateForm']);
} else {
$form = new XTemplate('modules/' . $currentModule . '/Popup_picker.html');
}
$form->assign('MOD', $mod_strings);
$form->assign('APP', $app_strings);
$form->assign('THEME', $theme);
$form->assign('MODULE_NAME', $currentModule);
$form->assign('request_data', $request_data);
// CREATE STUFF
if ($this->_create) {
$form->assign('CREATEBUTTON', $createButton);
$form->assign('ADDFORMHEADER', $addformheader);
$form->assign('ADDFORM', $addform);
}
// CREATE STUFF
if (isset($this->_popupMeta['className'])) {
$seed_bean = BeanFactory::newBeanByName($this->_popupMeta['className']);
} else {
$seed_bean = BeanFactory::newBeanByName($this->_popupMeta['moduleMain']);
}
// assign search inputs to xtemplates
foreach (array_keys($searchInputs) as $key) {
if (!empty($_REQUEST[$key]) && (isset($seed_bean->field_name_map[$key]['type']) && $seed_bean->field_name_map[$key]['type'] == 'bool')) {
$form->assign(strtoupper($key), ' checked ');
} else {
$form->assign(strtoupper($key), $searchInputs[$key]);
}
}
if ($this->_create) {
$form->assign('CREATE', 'true');
} else {
$form->assign('CREATE', 'false');
}
// fill any doms
if (isset($this->_popupMeta['selectDoms'])) {
foreach ($this->_popupMeta['selectDoms'] as $key => $value) {
$form->assign($key, get_select_options_with_id($app_list_strings[$value['dom']], $value['searchInput']));
}
}
$form->assign('MULTI_SELECT', !empty($_REQUEST['mode']) ? strtoupper($_REQUEST['mode']) : '');
ob_start();
insert_popup_header($theme);
$output_html .= ob_get_contents();
ob_end_clean();
$output_html .= get_form_header($mod_strings['LBL_SEARCH_FORM_TITLE'], '', false);
$form->parse('main.SearchHeader');
$output_html .= $form->text('main.SearchHeader');
// Reset the sections that are already in the page so that they do not print again later.
$form->reset('main.SearchHeader');
示例4: array
* Copyright (C) SugarCRM Inc. All rights reserved.
*/
global $current_user, $beanList, $beanFiles, $mod_strings;
$installed_classes = array();
$ACLbeanList = $beanList;
// In the event that previous Tracker entries were installed from 510RC, we need to fix the category value
$GLOBALS['db']->query("UPDATE acl_actions set acltype = 'TrackerPerf' where category = 'TrackerPerfs'");
$GLOBALS['db']->query("UPDATE acl_actions set acltype = 'TrackerSession' where category = 'TrackerSessions'");
$GLOBALS['db']->query("UPDATE acl_actions set acltype = 'TrackerQuery' where category = 'TrackerQueries'");
if (is_admin($current_user)) {
foreach ($ACLbeanList as $module => $class) {
if (empty($installed_classes[$class]) && isset($beanFiles[$class])) {
if ($class == 'Tracker') {
ACLAction::addActions('Trackers', 'Tracker');
} else {
$mod = BeanFactory::newBeanByName($class);
$GLOBALS['log']->debug("DOING: {$class}");
if ($mod instanceof SugarBean && $mod->bean_implements('ACL') && empty($mod->acl_display_only)) {
// BUG 10339: do not display messages for upgrade wizard
if (!isset($_REQUEST['upgradeWizard'])) {
echo translate('LBL_ADDING', 'ACL', '') . $mod->module_dir . '<br>';
}
if (!empty($mod->acltype)) {
ACLAction::addActions($mod->getACLCategory(), $mod->acltype);
} else {
ACLAction::addActions($mod->getACLCategory());
}
$installed_classes[$class] = true;
}
}
}
示例5: get_linked_beans
/**
* Returns an array of beans of related data.
*
* For instance, if an account is related to 10 contacts , this function will return an array of contacts beans (10)
* with each bean representing a contact record.
* Method will load the relationship if not done so already.
*
* @param string $field_name relationship to be loaded.
* @param string $bean name class name of the related bean.
* @param array $sort_array optional, unused
* @param int $begin_index Optional, default 0, unused.
* @param int $end_index Optional, default -1
* @param int $deleted Optional, Default 0, 0 adds deleted=0 filter, 1 adds deleted=1 filter.
* @param string $optional_where, Optional, default empty.
*
* Internal function, do not override.
*/
function get_linked_beans($field_name, $bean_name, $sort_array = array(), $begin_index = 0, $end_index = -1, $deleted = 0, $optional_where = "")
{
//if bean_name is Case then use aCase
if ($bean_name == "Case") {
$bean_name = "aCase";
}
if ($this->load_relationship($field_name)) {
if ($this->{$field_name} instanceof Link) {
// some classes are still based on Link, e.g. TeamSetLink
return array_values($this->{$field_name}->getBeans(BeanFactory::newBeanByName($bean_name), $sort_array, $begin_index, $end_index, $deleted, $optional_where));
} else {
// Link2 style
if ($end_index != -1 || !empty($deleted) || !empty($optional_where)) {
return array_values($this->{$field_name}->getBeans(array('where' => $optional_where, 'deleted' => $deleted, 'limit' => $end_index - $begin_index)));
} else {
return array_values($this->{$field_name}->getBeans());
}
}
} else {
return array();
}
}
示例6: _deleteRecord
/**
* Deletes a record in a bean
*
* @param $bean_id
* @param $module
*/
protected function _deleteRecord($bean_id, $module)
{
static $focus;
// load bean
if (!$focus instanceof $module) {
$focus = BeanFactory::newBeanByName($module);
}
$focus->mark_relationships_deleted($bean_id);
$result = $this->db->query("DELETE FROM {$focus->table_name}\n WHERE id = '{$bean_id}'");
if (!$result) {
return false;
}
// Bug 26318: Remove all created e-mail addresses ( from jchi )
$result2 = $this->db->query("SELECT email_address_id\n FROM email_addr_bean_rel\n WHERE email_addr_bean_rel.bean_id='{$bean_id}'\n AND email_addr_bean_rel.bean_module='{$focus->module_dir}'");
$this->db->query("DELETE FROM email_addr_bean_rel\n WHERE email_addr_bean_rel.bean_id='{$bean_id}'\n AND email_addr_bean_rel.bean_module='{$focus->module_dir}'");
while ($row2 = $this->db->fetchByAssoc($result2)) {
if (!$this->db->getOne("SELECT email_address_id\n FROM email_addr_bean_rel\n WHERE email_address_id = '{$row2['email_address_id']}'")) {
$this->db->query("DELETE FROM email_addresses\n WHERE id = '{$row2['email_address_id']}'");
}
}
if ($focus->hasCustomFields()) {
$this->db->query("DELETE FROM {$focus->table_name}_cstm\n WHERE id_c = '{$bean_id}'");
}
}
示例7: get_bean_select_array
function get_bean_select_array($add_blank = true, $bean_name, $display_columns, $where = '', $order_by = '', $blank_is_none = false)
{
$focus = BeanFactory::newBeanByName($bean_name);
$user_array = array();
$key = $bean_name == 'EmailTemplate' ? $bean_name : $bean_name . $display_columns . $where . $order_by;
$user_array = get_register_value('select_array', $key);
if (!$user_array) {
$db = DBManagerFactory::getInstance();
$temp_result = array();
$query = "SELECT {$focus->table_name}.id, {$display_columns} as display from {$focus->table_name} ";
// Bug 36162 - We need to confirm that the user is a member of the team of the item.
$focus->add_team_security_where_clause($query);
$query .= "where ";
if ($where != '') {
$query .= $where . " AND ";
}
$query .= " {$focus->table_name}.deleted=0";
if ($order_by != '') {
$query .= " order by {$focus->table_name}.{$order_by}";
}
$GLOBALS['log']->debug("get_user_array query: {$query}");
$result = $db->query($query, true, "Error filling in user array: ");
if ($add_blank == true) {
// Add in a blank row
if ($blank_is_none == true) {
// set 'blank row' to "--None--"
global $app_strings;
$temp_result[''] = $app_strings['LBL_NONE'];
} else {
$temp_result[''] = '';
}
}
// Get the id and the name.
while ($row = $db->fetchByAssoc($result)) {
$temp_result[$row['id']] = $row['display'];
}
$user_array = $temp_result;
set_register_value('select_array', $key, $temp_result);
}
return $user_array;
}
示例8: rebuildAuditTables
public function rebuildAuditTables()
{
global $mod_strings;
include 'include/modules.php';
//bug 15661
if ($this->show_output) {
echo "<h3> {$mod_strings['LBL_QR_REBUILDAUDIT']}</h3>";
}
if (!in_array(translate('LBL_ALL_MODULES'), $this->module_list) && !empty($this->module_list)) {
foreach ($this->module_list as $module_name) {
$bean = BeanFactory::getBean($module_name);
if (!empty($bean)) {
$this->_rebuildAuditTablesHelper($bean);
}
}
} else {
if (in_array(translate('LBL_ALL_MODULES'), $this->module_list)) {
foreach ($beanFiles as $bean => $file) {
$bean_instance = BeanFactory::newBeanByName($bean);
if (!empty($bean_instance)) {
$this->_rebuildAuditTablesHelper($bean_instance);
}
}
}
}
if ($this->show_output) {
echo $mod_strings['LBL_DONE'];
}
}
示例9: display
/**
* @see SugarView::display()
*/
public function display()
{
global $mod_strings, $app_strings, $current_user, $sugar_config, $current_language;
$this->ss->assign("IMPORT_MODULE", $_REQUEST['import_module']);
$this->ss->assign("TYPE", $_REQUEST['type']);
$this->ss->assign("HEADER", $app_strings['LBL_IMPORT'] . " " . $mod_strings['LBL_MODULE_NAME']);
$this->ss->assign("MODULE_TITLE", $this->getModuleTitle(false));
// lookup this module's $mod_strings to get the correct module name
$module_mod_strings = return_module_language($current_language, $_REQUEST['import_module']);
$this->ss->assign("MODULENAME", $module_mod_strings['LBL_MODULE_NAME']);
// read status file to get totals for records imported, errors, and duplicates
$count = 0;
$errorCount = 0;
$dupeCount = 0;
$createdCount = 0;
$updatedCount = 0;
$fp = sugar_fopen(ImportCacheFiles::getStatusFileName(), 'r');
// Read the data if we successfully opened file
if ($fp !== false) {
// Read rows 1 by 1 and add the info
while ($row = fgetcsv($fp, 8192)) {
$count += (int) $row[0];
$errorCount += (int) $row[1];
$dupeCount += (int) $row[2];
$createdCount += (int) $row[3];
$updatedCount += (int) $row[4];
}
fclose($fp);
}
$this->ss->assign("showUndoButton", FALSE);
if ($createdCount > 0) {
$this->ss->assign("showUndoButton", TRUE);
}
if ($errorCount > 0 && ($createdCount <= 0 && $updatedCount <= 0)) {
$activeTab = 2;
} else {
if ($dupeCount > 0 && ($createdCount <= 0 && $updatedCount <= 0)) {
$activeTab = 1;
} else {
$activeTab = 0;
}
}
$this->ss->assign("JAVASCRIPT", $this->_getJS($activeTab));
$this->ss->assign("errorCount", $errorCount);
$this->ss->assign("dupeCount", $dupeCount);
$this->ss->assign("createdCount", $createdCount);
$this->ss->assign("updatedCount", $updatedCount);
$this->ss->assign("errorFile", ImportCacheFiles::convertFileNameToUrl(ImportCacheFiles::getErrorFileName()));
$this->ss->assign("errorrecordsFile", ImportCacheFiles::convertFileNameToUrl(ImportCacheFiles::getErrorRecordsWithoutErrorFileName()));
$this->ss->assign("dupeFile", ImportCacheFiles::convertFileNameToUrl(ImportCacheFiles::getDuplicateFileName()));
if ($this->bean->object_name == "Prospect") {
$this->ss->assign("PROSPECTLISTBUTTON", $this->_addToProspectListButton());
} else {
$this->ss->assign("PROSPECTLISTBUTTON", "");
}
$resultsTable = "";
foreach (UsersLastImport::getBeansByImport($_REQUEST['import_module']) as $beanname) {
// load bean
if (!$this->bean instanceof $beanname) {
$this->bean = BeanFactory::newBeanByName($beanname);
}
$resultsTable .= $this->getListViewResults();
}
if (empty($resultsTable)) {
$resultsTable = $this->getListViewResults();
}
$this->ss->assign("RESULTS_TABLE", $resultsTable);
$this->ss->assign("ERROR_TABLE", $this->getListViewTableFromFile(ImportCacheFiles::getErrorRecordsFileName(), 'errors'));
$this->ss->assign("DUP_TABLE", $this->getListViewTableFromFile(ImportCacheFiles::getDuplicateFileDisplayName(), 'dup'));
$content = $this->ss->fetch('modules/Import/tpls/last.tpl');
$this->ss->assign("CONTENT", $content);
$this->ss->display('modules/Import/tpls/wizardWrapper.tpl');
}
示例10: create_tables
/**
* create_tables
* Override this method to insert ACLActions for the tracker beans
*
*/
function create_tables()
{
$path = 'modules/Trackers/config.php';
if (defined('TEMPLATE_URL')) {
$path = SugarTemplateUtilities::getFilePath($path);
}
require $path;
foreach ($tracker_config as $key => $configEntry) {
if (isset($configEntry['bean']) && $configEntry['bean'] != 'Tracker') {
$bean = BeanFactory::newBeanByName($configEntry['bean']);
if ($bean->bean_implements('ACL')) {
ACLAction::addActions($bean->getACLCategory(), $configEntry['bean']);
}
}
}
parent::create_tables();
}
示例11: fromLegacySubpanelLayout
/**
* Convert a piece of a subpanel layoutdef to the new style
* @param array $layoutdef old style layout
* @return array new style layout for this piece
*/
public function fromLegacySubpanelLayout(array $layoutdef)
{
$viewdefs = array('layout' => 'subpanel');
// we aren't upgrading collections
if (!empty($layoutdef['collection_list'])) {
return $viewdefs;
}
foreach ($layoutdef as $key => $value) {
if ($key == 'override_subpanel_name') {
$subpanelFileName = $value;
if (substr_count($value, '_') > 1 && stristr($value, 'subpanel')) {
$parts = explode('_subpanel_', $value);
$beanNameParts = explode('_', $parts[0]);
$subPanelBeanName = '';
foreach ($beanNameParts as $part) {
$subPanelBeanName .= ucwords($part);
}
// case is not the actually object name, it's aCase
if ($subPanelBeanName == 'Case') {
$subPanelBeanName = 'aCase';
}
$focus = BeanFactory::newBeanByName($subPanelBeanName);
if ($focus) {
$field = $focus->getFieldDefinition($parts[1]);
if ($field && $field['type'] == 'link') {
// since we have a valid link, we need to test the relationship to see if it's custom relationship
$relationships = new DeployedRelationships($focus->module_name);
$relationship = $relationships->get($parts[1]);
$relDef = array();
if ($relationship) {
$relDef = $relationship->getDefinition();
}
if (!empty($relDef['is_custom']) && !empty($relDef['from_studio']) && (!empty($relDef['name']) || !empty($relDef['relationship_name']))) {
$name = !empty($relDef['name']) ? $relDef['name'] : $relDef['relationship_name'];
$subpanelFileName = "For{$name}";
} else {
$subpanelFileName = "For{$focus->module_name}";
}
} else {
$subpanelFileName = "For{$focus->module_name}";
}
}
}
$viewdefs['override_subpanel_list_view'] = array('view' => $this->fromLegacySubpanelName($subpanelFileName), 'link' => isset($layoutdef['get_subpanel_data']) ? $layoutdef['get_subpanel_data'] : '');
} elseif ($key == 'title_key') {
$viewdefs['label'] = $value;
} elseif ($key == 'get_subpanel_data') {
$viewdefs['context']['link'] = $value;
}
}
return $viewdefs;
}