本文整理汇总了PHP中BeanFactory::getObjectName方法的典型用法代码示例。如果您正苦于以下问题:PHP BeanFactory::getObjectName方法的具体用法?PHP BeanFactory::getObjectName怎么用?PHP BeanFactory::getObjectName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BeanFactory
的用法示例。
在下文中一共展示了BeanFactory::getObjectName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadACLs
/**
* Load ACLs for module
* @param string $module
* @param array $context
* @return array ACLs list
*/
public static function loadACLs($module, $context = array())
{
if (!isset(self::$acls[$module])) {
self::$acls[$module] = array();
$name = BeanFactory::getObjectName($module);
if (!isset($GLOBALS['dictionary'][$name])) {
if (empty($name) || empty($GLOBALS['beanList'][$module]) || empty($GLOBALS['beanFiles'][$GLOBALS['beanList'][$module]]) || in_array($module, array('Empty'))) {
// try to weed out non-bean modules - these can't have ACLs as they don't have vardefs to keep them
$GLOBALS['log']->debug("Non-bean {$module} - no ACL for you!");
return array();
}
VardefManager::loadVardef($module, $name);
}
$acl_list = isset($GLOBALS['dictionary'][$name]['acls']) ? $GLOBALS['dictionary'][$name]['acls'] : array();
$acl_list = array_merge($acl_list, SugarBean::getDefaultACL());
$GLOBALS['log']->debug("ACLS for {$module}: " . var_export($acl_list, true));
foreach ($acl_list as $klass => $args) {
if ($args === false) {
continue;
}
self::$acls[$module][] = new $klass($args);
}
}
return self::$acls[$module];
}
示例2: createRelationship
private function createRelationship($lhs_module, $rhs_module = null, $relationship_type = 'one-to-many')
{
$rhs_module = $rhs_module == null ? $lhs_module : $rhs_module;
// Adding relation between products and users
$this->relationships = new DeployedRelationships($lhs_module);
$definition = array('lhs_module' => $lhs_module, 'relationship_type' => $relationship_type, 'rhs_module' => $rhs_module, 'lhs_label' => $lhs_module, 'rhs_label' => $rhs_module, 'rhs_subpanel' => 'default');
$this->relationship = RelationshipFactory::newRelationship($definition);
$this->relationships->add($this->relationship);
$this->relationships->save();
$this->relationships->build();
LanguageManager::clearLanguageCache($lhs_module);
// Updating $dictionary by created relation
global $dictionary;
$moduleInstaller = new ModuleInstaller();
$moduleInstaller->silent = true;
$moduleInstaller->rebuild_tabledictionary();
require 'modules/TableDictionary.php';
// Updating vardefs
VardefManager::$linkFields = array();
VardefManager::clearVardef();
VardefManager::refreshVardefs($lhs_module, BeanFactory::getObjectName($lhs_module));
if ($lhs_module != $rhs_module) {
VardefManager::refreshVardefs($rhs_module, BeanFactory::getObjectName($rhs_module));
}
SugarRelationshipFactory::rebuildCache();
}
示例3: getLinkedDefForModuleByRelationship
/**
* Find the link entry for a particular relationship and module.
*
* @param $module
* @return array|bool
*/
public function getLinkedDefForModuleByRelationship($module)
{
$results = VardefManager::getLinkFieldForRelationship($module, BeanFactory::getObjectName($module), $this->name);
//Only a single link was found
if (isset($results['name'])) {
return $results;
} else {
if (is_array($results)) {
$GLOBALS['log']->error("Warning: Multiple links found for relationship {$this->name} within module {$module}");
return $this->getMostAppropriateLinkedDefinition($results);
} else {
return FALSE;
}
}
}
示例4: __construct
public function __construct($def)
{
global $dictionary;
$this->def = $def;
$this->name = $def['name'];
$this->selfReferencing = $def['lhs_module'] == $def['rhs_module'];
$lhsModule = $def['lhs_module'];
$rhsModule = $def['rhs_module'];
if ($this->selfReferencing) {
$links = VardefManager::getLinkFieldForRelationship($lhsModule, BeanFactory::getObjectName($lhsModule), $this->name);
if (empty($links)) {
$GLOBALS['log']->fatal("No Links found for relationship {$this->name}");
} else {
if (!isset($links[0]) && !isset($links['name'])) {
$GLOBALS['log']->fatal("Bad link found for relationship {$this->name}");
} else {
if (!isset($links[1]) && isset($links['name'])) {
$this->lhsLinkDef = $this->rhsLinkDef = $links;
} else {
if (!empty($links[0]) && !empty($links[1])) {
if (!empty($links[0]['side']) && $links[0]['side'] == "right" || !empty($links[0]['link_type']) && $links[0]['link_type'] == "one") {
//$links[0] is the RHS
$this->lhsLinkDef = $links[1];
$this->rhsLinkDef = $links[0];
} else {
//$links[0] is the LHS
$this->lhsLinkDef = $links[0];
$this->rhsLinkDef = $links[1];
}
}
}
}
}
} else {
$this->lhsLinkDef = VardefManager::getLinkFieldForRelationship($lhsModule, BeanFactory::getObjectName($lhsModule), $this->name);
$this->rhsLinkDef = VardefManager::getLinkFieldForRelationship($rhsModule, BeanFactory::getObjectName($rhsModule), $this->name);
if (!isset($this->lhsLinkDef['name']) && isset($this->lhsLinkDef[0])) {
$this->lhsLinkDef = $this->lhsLinkDef[0];
}
if (!isset($this->rhsLinkDef['name']) && isset($this->rhsLinkDef[0])) {
$this->rhsLinkDef = $this->rhsLinkDef[0];
}
}
$this->lhsLink = $this->lhsLinkDef['name'];
$this->rhsLink = $this->rhsLinkDef['name'];
}
示例5: getCompareText
/**
* Generates field equality comparison PHP code
*
* @param WorkFlowTriggerShell $shell_object
* @param bool $is_equal
* @return string
*/
private function getCompareText($shell_object, $is_equal)
{
global $dictionary;
$parentWorkflow = $shell_object->get_workflow_type();
if (empty($parentWorkflow->base_module)) {
$GLOBALS['log']->error("WorkFlowTriggerShell ({$shell_object->id}) " . "parent WorkFlow ({$parentWorkflow->id}) has no base module set.");
}
$useStrict = true;
$moduleName = $parentWorkflow->base_module;
$objectName = BeanFactory::getObjectName($moduleName);
$field = $shell_object->field;
VardefManager::loadVardef($moduleName, $objectName);
if (!empty($dictionary[$objectName]) && !empty($dictionary[$objectName]['fields'][$field])) {
$vardef = $dictionary[$objectName]['fields'][$field];
// Don't use strict for numerical types
if (!empty($vardef['type']) && in_array($vardef['type'], array('currency', 'double', 'int'))) {
$useStrict = false;
}
// Use to_display_date for Date fields
if (!empty($vardef['type']) && in_array($vardef['type'], array('date'))) {
$dateTimeFunction = 'to_display_date';
}
// Use to_display_date_time for DateTime fields
if (!empty($vardef['type']) && in_array($vardef['type'], array('datetime', 'datetimecombo'))) {
$dateTimeFunction = 'to_display_date_time';
}
}
$sep = $is_equal ? '==' : '!=';
if ($useStrict) {
$sep .= '=';
}
$equalityCheck = "\$focus->fetched_row['" . $field . "'] " . $sep . " \$focus->" . $field;
if (!empty($dateTimeFunction)) {
$equalityCheck = "\$GLOBALS['timedate']->{$dateTimeFunction}(\$focus->fetched_row['" . $field . "'])" . " {$sep} " . "\$GLOBALS['timedate']->{$dateTimeFunction}(\$focus->" . $field . ")";
}
// Due to sidecar pushing unchanged fields, we need a check when that happens
if (!$is_equal) {
$equalityCheck .= " && !(\$focus->fetched_row['" . $field . "'] === null && strlen(\$focus->" . $field . ") === 0)";
}
return " (isset(\$focus->" . $field . ") && " . "(empty(\$focus->fetched_row) || array_key_exists('" . $field . "', \$focus->fetched_row)) " . "&& {$equalityCheck}) ";
}
示例6: buildRelationshipCache
protected function buildRelationshipCache()
{
global $beanList, $dictionary, $buildingRelCache;
if ($buildingRelCache) {
return;
}
$buildingRelCache = true;
include_once "modules/TableDictionary.php";
if (empty($beanList)) {
include "include/modules.php";
}
//Reload ALL the module vardefs....
foreach ($beanList as $moduleName => $beanName) {
VardefManager::loadVardef($moduleName, BeanFactory::getObjectName($moduleName));
}
$relationships = array();
//Grab all the relationships from the dictionary.
foreach ($dictionary as $key => $def) {
if (!empty($def['relationships'])) {
foreach ($def['relationships'] as $relKey => $relDef) {
if ($key == $relKey) {
//Relationship only entry, we need to capture everything
$relationships[$key] = array_merge(array('name' => $key), $def, $relDef);
} else {
$relationships[$relKey] = array_merge(array('name' => $relKey), $relDef);
if (!empty($relationships[$relKey]['join_table']) && empty($relationships[$relKey]['fields']) && isset($dictionary[$relationships[$relKey]['join_table']]['fields'])) {
$relationships[$relKey]['fields'] = $dictionary[$relationships[$relKey]['join_table']]['fields'];
}
}
}
}
}
//Save it out
sugar_mkdir(dirname($this->getCacheFile()), null, true);
$out = "<?php \n \$relationships=" . var_export($relationships, true) . ";";
sugar_file_put_contents($this->getCacheFile(), $out);
$this->relationships = $relationships;
$buildingRelCache = false;
}
示例7: getVarDef
/**
* Gets vardef info for a given module.
*
* @param string $moduleName The name of the module to collect vardef information about.
* @return array The vardef's $dictonary array.
*/
public function getVarDef($moduleName)
{
require_once 'data/BeanFactory.php';
$obj = BeanFactory::getObjectName($moduleName);
if ($obj) {
require_once 'include/SugarObjects/VardefManager.php';
global $dictionary;
VardefManager::loadVardef($moduleName, $obj);
if (isset($dictionary[$obj])) {
$data = $dictionary[$obj];
}
// vardefs are missing something, for consistency let's populate some arrays
if (!isset($data['fields'])) {
$data['fields'] = array();
}
if (!isset($data['relationships'])) {
$data['relationships'] = array();
}
if (!isset($data['fields'])) {
$data['fields'] = array();
}
}
// Bug 56505 - multiselect fields default value wrapped in '^' character
if (!empty($data['fields'])) {
$data['fields'] = $this->getMetaDataHacks()->normalizeFieldDefs($data);
}
if (!isset($data['relationships'])) {
$data['relationships'] = array();
}
return $data;
}
示例8: get_fields_influencing_linked_bean_calc_fields
/**
* Returns array of linked bean's calculated fields which use relation to
* the current bean in their formulas
*
* @param string $linkName Name of current bean's link
* @return array
*/
protected function get_fields_influencing_linked_bean_calc_fields($linkName)
{
global $dictionary;
$result = array();
if (!$this->load_relationship($linkName)) {
return $result;
}
/** @var Link2 $link */
$link = $this->{$linkName};
$relatedModuleName = $link->getRelatedModuleName();
$relatedBeanName = BeanFactory::getObjectName($relatedModuleName);
$relatedLinkName = $link->getRelatedModuleLinkName();
if (empty($relatedBeanName) || empty($dictionary[$relatedBeanName])) {
$GLOBALS['log']->fatal("Cannot load field defs for {$relatedBeanName}");
return $result;
}
// iterate over related bean fields
foreach ($dictionary[$relatedBeanName]['fields'] as $def) {
if (!empty($def['formula'])) {
$expr = Parser::evaluate($def['formula'], $this);
$fields = $this->get_formula_related_fields($expr, $relatedLinkName);
$result = array_merge($result, $fields);
}
}
return array_unique($result);
}
示例9: fetch
function fetch($ac = false)
{
$fv = new FieldViewer();
if (empty($_REQUEST['field']) && !empty($_REQUEST['name'])) {
$_REQUEST['field'] = $_REQUEST['name'];
}
$field_name = '';
if (!empty($this->view_object_map['field_name'])) {
$field_name = $this->view_object_map['field_name'];
} elseif (!empty($_REQUEST['field'])) {
$field_name = $_REQUEST['field'];
} else {
$field_name = '';
}
$action = 'saveField';
// tyoung bug 17606: default action is to save as a dynamic field; but for standard OOB
// fields we override this so don't create a new dynamic field instead of updating the existing field
$isClone = false;
if (!empty($this->view_object_map['is_clone']) && $this->view_object_map['is_clone'] && strcmp($field_name, "name") != 0) {
$isClone = true;
}
/*
$field_types = array('varchar'=>'YourField', 'int'=>'Integer', 'float'=>'Decimal','bool'=>'Checkbox','enum'=>'DropDown',
'date'=>'Date', 'phone' => 'Phone', 'currency' => 'Currency', 'html' => 'HTML', 'radioenum' => 'Radio',
'relate' => 'Relate', 'address' => 'Address', 'text' => 'TextArea', 'url' => 'Link');
*/
$field_types = $GLOBALS['mod_strings']['fieldTypes'];
if (isset($field_types['encrypt'])) {
unset($field_types['encrypt']);
}
$field_name_exceptions = array('ADD', 'EXCEPT', 'PERCENT', 'ALL', 'EXEC', 'PLAN', 'ALTER', 'EXECUTE', 'PRECISION', 'AND', 'EXISTS', 'PRIMARY', 'ANY', 'EXIT', 'PRINT', 'AS', 'FETCH', 'PROC', 'ASC', 'FILE', 'PROCEDURE', 'AUTHORIZATION', 'FILLFACTOR', 'PUBLIC', 'BACKUP', 'FOR', 'RAISERROR', 'BEGIN', 'FOREIGN', 'READ', 'BETWEEN', 'FREETEXT', 'READTEXT', 'BREAK', 'FREETEXTTABLE', 'RECONFIGURE', 'BROWSE', 'FROM', 'REFERENCES', 'BULK', 'FULL', 'REPLICATION', 'BY', 'FUNCTION', 'RESTORE', 'CASCADE', 'GOTO', 'RESTRICT', 'CASE', 'GRANT', 'RETURN', 'CHECK', 'GROUP', 'REVOKE', 'CHECKPOINT', 'HAVING', 'RIGHT', 'CLOSE', 'HOLDLOCK', 'ROLLBACK', 'CLUSTERED', 'IDENTITY', 'ROWCOUNT', 'COALESCE', 'IDENTITY_INSERT', 'ROWGUIDCOL', 'COLLATE', 'IDENTITYCOL', 'RULE', 'COLUMN', 'IF', 'SAVE', 'COMMIT', 'IN', 'SCHEMA', 'COMPUTE', 'INDEX', 'SELECT', 'CONSTRAINT', 'INNER', 'SESSION_USER', 'CONTAINS', 'INSERT', 'SET', 'CONTAINSTABLE', 'INTERSECT', 'SETUSER', 'CONTINUE', 'INTO', 'SHUTDOWN', 'CONVERT', 'IS', 'SOME', 'CREATE', 'JOIN', 'STATISTICS', 'CROSS', 'KEY', 'SYSTEM_USER', 'CURRENT', 'KILL', 'TABLE', 'CURRENT_DATE', 'LEFT', 'TEXTSIZE', 'CURRENT_TIME', 'LIKE', 'THEN', 'CURRENT_TIMESTAMP', 'LINENO', 'TO', 'CURRENT_USER', 'LOAD', 'TOP', 'CURSOR', 'NATIONAL', 'TRAN', 'DATABASE', 'NOCHECK', 'TRANSACTION', 'DBCC', 'NONCLUSTERED', 'TRIGGER', 'DEALLOCATE', 'NOT', 'TRUNCATE', 'DECLARE', 'NULL', 'TSEQUAL', 'DEFAULT', 'NULLIF', 'UNION', 'DELETE', 'OF', 'UNIQUE', 'DENY', 'OFF', 'UPDATE', 'DESC', 'OFFSETS', 'UPDATETEXT', 'DISK', 'ON', 'USE', 'DISTINCT', 'OPEN', 'USER', 'DISTRIBUTED', 'OPENCONNECTOR', 'VALUES', 'DOUBLE', 'OPENQUERY', 'VARYING', 'DROP', 'OPENROWSET', 'VIEW', 'DUMMY', 'OPENXML', 'WAITFOR', 'DUMP', 'OPTION', 'WHEN', 'ELSE', 'OR', 'WHERE', 'END', 'ORDER', 'WHILE', 'ERRLVL', 'OUTER', 'WITH', 'ESCAPE', 'OVER', 'WRITETEXT', 'ANALYZE', 'ASENSITIVE', 'BEFORE', 'BIGINT', 'BINARY', 'BOTH', 'CALL', 'CHANGE', 'CHARACTER', 'CONDITION', 'DATABASES', 'DAY_HOUR', 'DAY_MICROSECOND', 'DAY_MINUTE', 'DAY_SECOND', 'DEC', 'DECIMAL', 'DELAYED', 'DESCRIBE', 'DETERMINISTIC', 'DISTINCTROW', 'DIV', 'DUAL', 'EACH', 'ELSEIF', 'ENCLOSED', 'ESCAPED', 'EXPLAIN', 'FALSE', 'FLOAT', 'FLOAT4', 'FLOAT8', 'FORCE', 'FULLTEXT', 'HIGH_PRIORITY', 'HOUR_MICROSECOND', 'HOUR_MINUTE', 'HOUR_SECOND', 'IGNORE', 'INFILE', 'INOUT', 'INSENSITIVE', 'INT', 'INT1', 'INT2', 'INT3', 'INT4', 'INT8', 'INTEGER', 'ITERATE', 'KEYS', 'LEADING', 'LEAVE', 'LIMIT', 'LINES', 'LOCALTIME', 'LOCALTIMESTAMP', 'LOCK', 'LONGBLOB', 'LONGTEXT', 'LOOP', 'LOW_PRIORITY', 'MATCH', 'MEDIUMBLOB', 'MEDIUMINT', 'MEDIUMTEXT', 'MIDDLEINT', 'MINUTE_MICROSECOND', 'MINUTE_SECOND', 'MOD', 'MODIFIES', 'NATURAL', 'NO_WRITE_TO_BINLOG', 'NUMERIC', 'OPTIMIZE', 'OPTIONALLY', 'OUT', 'OUTFILE', 'PURGE', 'READS', 'REAL', 'REGEXP', 'RELEASE', 'RENAME', 'REPEAT', 'REPLACE', 'REQUIRE', 'RLIKE', 'SCHEMAS', 'SECOND_MICROSECOND', 'SENSITIVE', 'SEPARATOR', 'SHOW', 'SMALLINT', 'SONAME', 'SPATIAL', 'SPECIFIC', 'SQL', 'SQLEXCEPTION', 'SQLSTATE', 'SQLWARNING', 'SQL_BIG_RESULT', 'SQL_CALC_FOUND_ROWS', 'SQL_SMALL_RESULT', 'SSL', 'STARTING', 'STRAIGHT_JOIN', 'TERMINATED', 'TINYBLOB', 'TINYINT', 'TINYTEXT', 'TRAILING', 'TRUE', 'UNDO', 'UNLOCK', 'UNSIGNED', 'USAGE', 'USING', 'UTC_DATE', 'UTC_TIME', 'UTC_TIMESTAMP', 'VARBINARY', 'VARCHARACTER', 'WRITE', 'XOR', 'YEAR_MONTH', 'ZEROFILL', 'CONNECTION', 'LABEL', 'UPGRADE', 'DATE', 'VARCHAR', 'VARCHAR2', 'NVARCHAR2', 'CHAR', 'NCHAR', 'NUMBER', 'PLS_INTEGER', 'BINARY_INTEGER', 'LONG', 'TIMESTAMP', 'INTERVAL', 'RAW', 'ROWID', 'UROWID', 'MLSLABEL', 'CLOB', 'NCLOB', 'BLOB', 'BFILE', 'XMLTYPE', 'ID', 'ID_C', 'PARENT_NAME', 'PARENT_ID');
//C.L. - Add support to mark related module id columns as reserved keywords
require_once 'modules/ModuleBuilder/parsers/relationships/DeployedRelationships.php';
$relatedModules = array_keys(DeployedRelationships::findRelatableModules());
global $beanList, $current_language;
foreach ($relatedModules as $relModule) {
if (isset($beanList[$relModule])) {
$field_name_exceptions[] = strtoupper($beanList[$relModule]) . '_ID';
}
}
if (empty($_REQUEST['view_package']) || $_REQUEST['view_package'] == 'studio') {
$moduleName = $_REQUEST['view_module'];
$objectName = BeanFactory::getObjectName($moduleName);
$module = BeanFactory::getBean($moduleName);
VardefManager::loadVardef($moduleName, $objectName, true);
global $dictionary;
// Fix for issue #1177 - when trying to add or edit fields in a module an error message is shown:
// "Warning: Creating default object from empty value"
if (!isset($module->mbvardefs) || is_null($module->mbvardefs)) {
$module->mbvardefs = new stdClass();
}
$module->mbvardefs->vardefs = $dictionary[$objectName];
$module->name = $moduleName;
if (!$ac) {
$ac = new AjaxCompose();
}
$vardef = !empty($module->mbvardefs->vardefs['fields'][$field_name]) ? $module->mbvardefs->vardefs['fields'][$field_name] : array();
if ($isClone) {
unset($vardef['name']);
}
if (empty($vardef['name'])) {
if (!empty($_REQUEST['type'])) {
$vardef['type'] = $_REQUEST['type'];
}
$fv->ss->assign('hideLevel', 0);
} elseif (isset($vardef['custom_module'])) {
$fv->ss->assign('hideLevel', 2);
} else {
$action = 'saveSugarField';
// tyoung - for OOB fields we currently only support modifying the label
$fv->ss->assign('hideLevel', 3);
}
if ($isClone && isset($vardef['type']) && $vardef['type'] == 'datetime') {
$vardef['type'] = 'datetimecombo';
}
require_once 'modules/DynamicFields/FieldCases.php';
$tf = get_widget(empty($vardef['type']) ? "" : $vardef['type']);
$tf->module = $module;
$tf->populateFromRow($vardef);
$vardef = array_merge($vardef, $tf->get_field_def());
// $GLOBALS['log']->debug('vardefs after loading = '.print_r($vardef,true));
//Check if autoincrement fields are allowed
$allowAutoInc = true;
$enumFields = array();
foreach ($module->field_defs as $field => $def) {
if (!empty($def['type']) && $def['type'] == "int" && !empty($def['auto_increment'])) {
$allowAutoInc = false;
continue;
}
if (!empty($def['type']) && $def['type'] == "enum" && $field != $vardef['name']) {
if (!empty($def['studio']) && $def['studio'] == "false") {
continue;
}
//bug51866
$enumFields[$field] = translate($def['vname'], $moduleName);
if (substr($enumFields[$field], -1) == ":") {
$enumFields[$field] = substr($enumFields[$field], 0, strlen($enumFields[$field]) - 1);
}
}
}
//.........这里部分代码省略.........
示例10: processAfterCreateOperations
/**
* Process all after create operations:
* copy_rel_from - Copies relationships from a specified record. The relationship that should be copied is specified
* in the vardef.
*
* @param $args
* @param SugarBean $bean
*/
protected function processAfterCreateOperations($args, SugarBean $bean)
{
$this->requireArgs($args, array('module'));
global $dictionary;
$afterCreateKey = 'after_create';
$copyRelationshipsFromKey = 'copy_rel_from';
$module = $args['module'];
$objectName = BeanFactory::getObjectName($module);
if (array_key_exists($afterCreateKey, $args) && array_key_exists($copyRelationshipsFromKey, $args[$afterCreateKey]) && array_key_exists($afterCreateKey, $dictionary[$objectName]) && array_key_exists($copyRelationshipsFromKey, $dictionary[$objectName][$afterCreateKey])) {
$relationshipsToCopy = $dictionary[$objectName][$afterCreateKey][$copyRelationshipsFromKey];
$beanCopiedFrom = BeanFactory::getBean($module, $args[$afterCreateKey][$copyRelationshipsFromKey]);
foreach ($relationshipsToCopy as $linkName) {
$bean->load_relationship($linkName);
$beanCopiedFrom->load_relationship($linkName);
$beanCopiedFrom->{$linkName}->getBeans();
$bean->{$linkName}->add($beanCopiedFrom->{$linkName}->beans);
}
}
}
示例11: process_editview
function process_editview()
{
if (isset($this->bean->{$this->value_name}['secondaries'])) {
$this->numFields = count($this->bean->{$this->value_name}['secondaries']) + 1;
}
if (!isset($this->displayParams['readOnly'])) {
$this->displayParams['readOnly'] = '';
} else {
$this->displayParams['readOnly'] = $this->displayParams['readOnly'] == false ? '' : 'READONLY';
}
// If there is extra field to show.
if (isset($this->displayParams['collection_field_list'])) {
$relatedObject = BeanFactory::getObjectName($this->related_module);
vardefmanager::loadVardef($this->related_module, $relatedObject);
foreach ($this->displayParams['collection_field_list'] as $k => $v) {
$javascript = '';
$collection_field_vardef = $GLOBALS['dictionary'][$relatedObject]['fields'][$v['name']];
// For each extra field the params which are not displayParams will be consider as params to override the vardefs values.
foreach ($v as $k_override => $v_override) {
if ($k_override != 'displayParams') {
$collection_field_vardef[$k_override] = $v_override;
}
}
// If relate field : enable quick search by creating the sqs_object array.
if ($collection_field_vardef['type'] == 'relate') {
require_once 'include/TemplateHandler/TemplateHandler.php';
$tph = new TemplateHandler();
$javascript = $tph->createQuickSearchCode(array($collection_field_vardef['name'] => $collection_field_vardef), array($v), $this->form_name);
$javascript = str_replace('<script language="javascript">' . "if(typeof sqs_objects == 'undefined'){var sqs_objects = new Array;}sqs_objects['{$collection_field_vardef['name']}']=", "", $javascript);
$javascript = substr($javascript, 0, -10);
//remove ";</script>"
$javascriptPHP = $this->json->decode($javascript);
foreach ($javascriptPHP['populate_list'] as $kk => $vv) {
$javascriptPHP['populate_list'][$kk] .= "_" . $this->vardef['name'] . "_collection_extra_0";
}
foreach ($javascriptPHP['required_list'] as $kk => $vv) {
$javascriptPHP['required_list'][$kk] .= "_" . $this->vardef['name'] . "_collection_extra_0";
}
foreach ($javascriptPHP['field_list'] as $kk => $vv) {
if ($vv == 'id') {
$javascriptPHP['populate_list'][$kk];
}
}
$javascript = $this->json->encode($javascriptPHP);
$javascript = "<script language='javascript'>if(typeof sqs_objects == 'undefined'){var sqs_objects = new Array;}sqs_objects['{$collection_field_vardef['name']}_" . $this->vardef['name'] . "_collection_extra_0']=" . $javascript . ';</script>';
}
$collection_field_vardef['name'] .= "_" . $this->vardef['name'] . "_collection_extra_0";
if (isset($collection_field_vardef['id_name'])) {
$collection_field_vardef['id_name'] .= "_" . $this->vardef['name'] . "_collection_extra_0";
}
if (isset($this->displayParams['allow_update']) && ($this->displayParams['allow_update'] === false || $this->displayParams['allow_update'] === 'false')) {
$this->displayParams['allow_update'] = 'false';
$v['displayParams']['field']['disabled'] = '';
} else {
$this->displayParams['allow_update'] = 'true';
if (!isset($v['displayParams'])) {
$v['displayParams'] = array();
}
}
// Wireless view for Enum type because the wireless view retrieve and translate the list on real time.
if ($collection_field_vardef['type'] == 'enum') {
//TODO Change to an other view
$viewtype = 'WirelessEditView';
} else {
$viewtype = 'EditView';
}
$name = $collection_field_vardef['name'];
// Rearranging the array with name as key instaead of number. This is required for displaySmarty() to assign the good variable.
$this->displayParams['collection_field_list'][$name]['vardefName'] = $this->displayParams['collection_field_list'][$k]['name'];
$this->displayParams['collection_field_list'][$name]['name'] = $name;
if ($collection_field_vardef['type'] == 'relate') {
$this->displayParams['collection_field_list'][$name]['id_name'] = $collection_field_vardef['id_name'];
$this->displayParams['collection_field_list'][$name]['module'] = $collection_field_vardef['module'];
}
$this->displayParams['collection_field_list'][$name]['label'] = "{sugar_translate label='{$collection_field_vardef['vname']}' module='{$this->related_module}'}";
//translate($collection_field_vardef['vname'], $this->related_module);
$this->displayParams['collection_field_list'][$name]['field'] = $sfh->displaySmarty('displayParams.collection_field_list', $collection_field_vardef, $viewtype, $v['displayParams'], 1);
$this->displayParams['collection_field_list'][$name]['field'] .= '{literal}' . $javascript;
// Handle update_field array ONCHANGE
$this->displayParams['collection_field_list'][$name]['field'] .= <<<FRA
<script language='javascript'>
var oldonchange = '';
if(typeof(document.getElementById('{$collection_field_vardef['name']}').attributes.onchange) != 'undefined')
{
oldonchange=document.getElementById('{$collection_field_vardef['name']}').attributes.onchange.value;
}
FRA;
$this->displayParams['collection_field_list'][$name]['field'] .= "eval(\"document.getElementById('{$collection_field_vardef['name']}').onchange = function onchange(event){collection['{$this->vardef['name']}'].update_fields.{$collection_field_vardef['name']}=true;";
if ($collection_field_vardef['type'] == 'relate') {
// If relate add the ID field to the array
$this->displayParams['collection_field_list'][$name]['field'] .= "collection['{$this->vardef['name']}'].update_fields.{$collection_field_vardef['id_name']}=true;";
}
$this->displayParams['collection_field_list'][$name]['field'] .= "document.getElementById('update_fields_{$this->vardef['name']}_collection').value = YAHOO.lang.JSON.stringify(collection['{$this->vardef['name']}'].update_fields);\" + oldonchange + \"};\");</script>{/literal}";
//we need to get rid of the old value;
unset($this->displayParams['collection_field_list'][$k]);
}
}
if (!isset($this->displayParams['class'])) {
$this->displayParams['class'] = '';
}
//.........这里部分代码省略.........
示例12: getModules
static function getModules()
{
$modules = array();
foreach ($GLOBALS['beanList'] as $module => $object) {
$object = BeanFactory::getObjectName($module);
VardefManager::loadVardef($module, $object);
if (empty($GLOBALS['dictionary'][$object]['fields'])) {
continue;
}
$modules[] = $module;
}
sort($modules);
return $modules;
}
示例13: getLinkFieldsForModule
/**
* @static
* @param $module
* @param $object
* @return array|bool returns a list of all fields in the module of type 'link'.
*/
protected static function getLinkFieldsForModule($module, $object)
{
global $dictionary;
//Some modules like cases have a bean name that doesn't match the object name
if (empty($dictionary[$object])) {
$newName = BeanFactory::getObjectName($module);
$object = $newName != false ? $newName : $object;
}
if (empty($dictionary[$object])) {
self::loadVardef($module, $object, false, array('ignore_rel_calc_fields' => true));
}
if (empty($dictionary[$object])) {
$GLOBALS['log']->debug("Failed to load vardefs for {$module}:{$object} in linkFieldsForModule<br/>");
return false;
}
//Cache link fields for this call in a static variable
if (!isset(self::$linkFields)) {
self::$linkFields = array();
}
if (isset(self::$linkFields[$object])) {
return self::$linkFields[$object];
}
$vardef = $dictionary[$object];
$links = array();
foreach ($vardef['fields'] as $name => $def) {
//Look through all link fields for related modules that have calculated fields that use that relationship
if (!empty($def['type']) && $def['type'] == 'link' && !empty($def['relationship'])) {
$links[$name] = $def;
}
}
self::$linkFields[$object] = $links;
return $links;
}
示例14: fetch
function fetch($ac = false)
{
$fv = new FieldViewer();
if (empty($_REQUEST['field']) && !empty($_REQUEST['name'])) {
$_REQUEST['field'] = $_REQUEST['name'];
}
$field_name = '';
if (!empty($this->view_object_map['field_name'])) {
$field_name = $this->view_object_map['field_name'];
} elseif (!empty($_REQUEST['field'])) {
$field_name = $_REQUEST['field'];
}
// If this is a new field mark it as such
$isNew = empty($field_name) || !empty($_REQUEST['is_new']);
$action = 'saveField';
// tyoung bug 17606: default action is to save as a dynamic field; but for standard OOB
// fields we override this so don't create a new dynamic field instead of updating the existing field
$isClone = false;
if (!empty($this->view_object_map['is_clone']) && $this->view_object_map['is_clone'] && strcmp($field_name, "name") != 0) {
$isClone = true;
}
/*
$field_types = array('varchar'=>'YourField', 'int'=>'Integer', 'float'=>'Decimal','bool'=>'Checkbox','enum'=>'DropDown',
'date'=>'Date', 'phone' => 'Phone', 'currency' => 'Currency', 'html' => 'HTML', 'radioenum' => 'Radio',
'relate' => 'Relate', 'address' => 'Address', 'text' => 'TextArea', 'url' => 'Link');
*/
$field_types = $GLOBALS['mod_strings']['fieldTypes'];
//bug 22264: Field name must not be an SQL keyword.
$field_name_exceptions = array_merge(array_keys($GLOBALS['db']->getReservedWords()), array('ID', 'ID_C', 'PARENT_NAME', 'PARENT_ID'));
//C.L. - Add support to mark related module id columns as reserved keywords
require_once 'modules/ModuleBuilder/parsers/relationships/DeployedRelationships.php';
$relatedModules = array_keys(DeployedRelationships::findRelatableModules());
global $beanList, $current_language;
foreach ($relatedModules as $relModule) {
if (isset($beanList[$relModule])) {
$field_name_exceptions[] = strtoupper($beanList[$relModule]) . '_ID';
}
}
if (empty($_REQUEST['view_package']) || $_REQUEST['view_package'] == 'studio') {
$moduleName = $_REQUEST['view_module'];
$objectName = BeanFactory::getObjectName($moduleName);
$module = BeanFactory::getBean($moduleName);
VardefManager::loadVardef($moduleName, $objectName, true);
global $dictionary;
if (empty($module->mbvardefs)) {
$module->mbvardefs = new stdClass();
}
$module->mbvardefs->vardefs = $dictionary[$objectName];
$module->name = $moduleName;
if (!$ac) {
$ac = new AjaxCompose();
}
$vardef = !empty($module->mbvardefs->vardefs['fields'][$field_name]) ? $module->mbvardefs->vardefs['fields'][$field_name] : array();
if ($isClone) {
unset($vardef['name']);
}
// If this is a new field but we are loading this form a second time,
// like from coming back from a dropdown create on a new field, then
// keep the 'name' field open to allow the create field process to
// continue like normal
if (empty($vardef['name']) || $isNew) {
if (!empty($_REQUEST['type'])) {
$vardef['type'] = $_REQUEST['type'];
}
$fv->ss->assign('hideLevel', 0);
} elseif (isset($vardef['custom_module'])) {
$fv->ss->assign('hideLevel', 2);
} else {
$action = 'saveSugarField';
// tyoung - for OOB fields we currently only support modifying the label
$fv->ss->assign('hideLevel', 3);
}
if ($isClone && isset($vardef['type']) && $vardef['type'] == 'datetime') {
$vardef['type'] = 'datetimecombo';
}
require_once 'modules/DynamicFields/FieldCases.php';
$tf = get_widget(empty($vardef['type']) ? "" : $vardef['type']);
$tf->module = $module;
$tf->populateFromRow($vardef);
$vardef = array_merge($vardef, $tf->get_field_def());
// $GLOBALS['log']->debug('vardefs after loading = '.print_r($vardef,true));
//Check if autoincrement fields are allowed
$allowAutoInc = true;
$enumFields = array();
foreach ($module->field_defs as $field => $def) {
if (!empty($def['type']) && $def['type'] == "int" && !empty($def['auto_increment'])) {
$allowAutoInc = false;
continue;
}
if (!empty($def['type']) && $def['type'] == "enum" && $field != $vardef['name']) {
if (!empty($def['studio']) && $def['studio'] == "false") {
continue;
}
//bug51866
$enumFields[$field] = translate($def['vname'], $moduleName);
if (substr($enumFields[$field], -1) == ":") {
$enumFields[$field] = substr($enumFields[$field], 0, strlen($enumFields[$field]) - 1);
}
}
}
//.........这里部分代码省略.........
示例15: setUp_relation
/**
* Cleaning caches and refreshing vardefs
*
* @static
* @param string $lhs_module left module from relation
* @param string $rhs_module right module from relation
* @return bool are caches refreshed or not
*/
protected static function setUp_relation(array $params)
{
if (empty($params[0]) || empty($params[1])) {
throw new SugarTestHelperException('setUp("relation") requires two parameters');
}
list($lhs_module, $rhs_module) = $params;
self::$registeredVars['relation'] = true;
self::$cleanModules[] = $lhs_module;
LanguageManager::clearLanguageCache($lhs_module);
if ($lhs_module != $rhs_module) {
self::$cleanModules[] = $rhs_module;
LanguageManager::clearLanguageCache($rhs_module);
}
self::setUp('dictionary');
VardefManager::$linkFields = array();
VardefManager::clearVardef();
VardefManager::refreshVardefs($lhs_module, BeanFactory::getObjectName($lhs_module));
if ($lhs_module != $rhs_module) {
VardefManager::refreshVardefs($rhs_module, BeanFactory::getObjectName($rhs_module));
}
SugarRelationshipFactory::rebuildCache();
return true;
}