/**
  * Create a relationship
  *
  * Params should be passed in as this:
  *
  * array(
  *       'relationship_type' => 'one-to-many',
  *       'lhs_module' => 'Accounts',
  *       'rhs_module' => 'Accounts',
  *   )
  *
  * @static
  * @param array $relationship_def
  * @return ActivitiesRelationship|bool|ManyToManyRelationship|ManyToOneRelationship|OneToManyRelationship|OneToOneRelationship
  */
 public static function createRelationship(array $relationship_def)
 {
     if (!self::checkRequiredFields($relationship_def)) {
         return false;
     }
     $relationships = new DeployedRelationships($relationship_def['lhs_module']);
     if (!isset($relationship_def['view_module'])) {
         $relationship_def['view_module'] = $relationship_def['lhs_module'];
     }
     $REQUEST_Backup = $_REQUEST;
     $_REQUEST = $relationship_def;
     $relationship = $relationships->addFromPost();
     $relationships->save();
     $relationships->build();
     LanguageManager::clearLanguageCache($relationship_def['lhs_module']);
     SugarRelationshipFactory::rebuildCache();
     // rebuild the dictionary to make sure that it has the new relationship in it
     SugarTestHelper::setUp('dictionary');
     // reset the link fields since we added one
     VardefManager::$linkFields = array();
     $_REQUEST = $REQUEST_Backup;
     unset($REQUEST_Backup);
     self::$_relsAdded[] = $relationship->getDefinition();
     return $relationship;
 }
 protected function repairDictionary()
 {
     $this->df->buildCache($this->modulename);
     VardefManager::clearVardef();
     VardefManager::refreshVardefs($this->modulename, $this->objectname);
     $this->seed->field_defs = $GLOBALS['dictionary'][$this->objectname]['fields'];
 }
    public function setUp()
    {
        global $beanList, $beanFiles, $dictionary;
        //Add entries to simulate custom module
        $beanList['Bug44030_TestPerson'] = 'Bug44030_TestPerson';
        $beanFiles['Bug44030_TestPerson'] = 'modules/Bug44030_TestPerson/Bug44030_TestPerson.php';
        VardefManager::loadVardef('Contacts', 'Contact');
        $dictionary['Bug44030_TestPerson'] = $dictionary['Contact'];
        //Copy over custom SearchFields.php file
        if (!file_exists('custom/modules/Bug44030_TestPerson/metadata')) {
            mkdir_recursive('custom/modules/Bug44030_TestPerson/metadata');
        }
        if ($fh = @fopen('custom/modules/Bug44030_TestPerson/metadata/SearchFields.php', 'w+')) {
            $string = <<<EOQ
<?php
\$searchFields['Bug44030_TestPerson']['email'] = array(
'query_type' => 'default',
'operator' => 'subquery',
'subquery' => 'SELECT eabr.bean_id FROM email_addr_bean_rel eabr JOIN email_addresses ea ON (ea.id = eabr.email_address_id) WHERE eabr.deleted=0 AND ea.email_address LIKE',
'db_field' => array('id',),
'vname' =>'LBL_ANY_EMAIL',
);
?>
EOQ;
            fputs($fh, $string);
            fclose($fh);
        }
        //Remove the cached unified_search_modules.php file
        $this->unified_search_modules_file = $GLOBALS['sugar_config']['cache_dir'] . 'modules/unified_search_modules.php';
        if (file_exists($this->unified_search_modules_file)) {
            copy($this->unified_search_modules_file, $this->unified_search_modules_file . '.bak');
            unlink($this->unified_search_modules_file);
        }
    }
Exemple #4
0
 public function setUp()
 {
     global $dictionary;
     $this->_view = 'editview';
     VardefManager::loadVardef('Contacts', 'Contact');
     $this->def = $dictionary['Contact']['fields']['email1'];
 }
Exemple #5
0
 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();
 }
Exemple #6
0
 public function tearDown()
 {
     global $dictionary, $bean_list;
     $dictionary = $this->old_dictionary;
     $bean_list = $this->old_bean_list;
     VardefManager::clearVardef('Accounts', 'Account');
     VardefManager::refreshVardefs('Accounts', 'Account');
 }
Exemple #7
0
 /**
  * @param  $linkName String name of a link field in the module's vardefs
  * @param  $bean SugarBean focus bean for this link (one half of a relationship)
  * @param  $linkDef Array Optional vardef for the link in case it can't be found in the passed in bean for the global dictionary
  * @return void
  *
  */
 function __construct($linkName, $bean, $linkDef = false)
 {
     $this->focus = $bean;
     //Try to load the link vardef from the beans field defs. Otherwise start searching
     if (empty($bean->field_defs) || empty($bean->field_defs[$linkName]) || empty($bean->field_defs[$linkName]['relationship'])) {
         if (empty($linkDef)) {
             //Assume $linkName is really relationship_name, and find the link name with the vardef manager
             $this->def = VardefManager::getLinkFieldForRelationship($bean->module_dir, $bean->object_name, $linkName);
         } else {
             $this->def = $linkDef;
         }
         //Check if multiple links were found for a given relationship
         if (is_array($this->def) && !isset($this->def['name'])) {
             //More than one link found, we need to figure out if we are currently on the LHS or RHS
             //default to lhs for now
             if (isset($this->def[0]['side']) && $this->def[0]['side'] == 'left') {
                 $this->def = $this->def[0];
             } else {
                 if (isset($this->def[1]['side']) && $this->def[1]['side'] == 'left') {
                     $this->def = $this->def[1];
                 } else {
                     $this->def = $this->def[0];
                 }
             }
         }
         if (empty($this->def['name'])) {
             $GLOBALS['log']->fatal("failed to find link for {$linkName}");
             return false;
         }
         $this->name = $this->def['name'];
     } else {
         //Linkdef was found in the bean (this is the normal expectation)
         $this->def = $bean->field_defs[$linkName];
         $this->name = $linkName;
     }
     //Instantiate the relationship for this link.
     $this->relationship = SugarRelationshipFactory::getInstance()->getRelationship($this->def['relationship']);
     // Fix to restore functionality from Link.php that needs to be rewritten but for now this will do.
     $this->relationship_fields = !empty($this->def['rel_fields']) ? $this->def['rel_fields'] : array();
     if (!$this->loadedSuccesfully()) {
         global $app_strings;
         $GLOBALS['log']->error(string_format($app_strings['ERR_DATABSE_RELATIONSHIP_QUERY'], array($this->name, $this->def['relationship'])));
     }
     //Following behavior is tied to a property(ignore_role) value in the vardef. It alters the values of 2 properties, ignore_role_filter and add_distinct.
     //the property values can be altered again before any requests are made.
     if (!empty($this->def) && is_array($this->def)) {
         if (isset($this->def['ignore_role'])) {
             if ($this->def['ignore_role']) {
                 $this->ignore_role_filter = true;
                 $this->add_distinct = true;
             }
         }
         if (!empty($this->def['primary_only'])) {
             $this->relationship->primaryOnly = true;
         }
     }
 }
 /**
  * The constructor
  * @param string $subpanelName
  * @param string $loadedModule - Accounts
  * @param string $client - base
  */
 public function __construct($subpanelName, $loadedModule, $client = 'base')
 {
     $GLOBALS['log']->debug(get_class($this) . "->__construct({$subpanelName} , {$loadedModule})");
     $this->mdc = new MetaDataConverter();
     $this->loadedModule = $loadedModule;
     $this->setViewClient($client);
     $linkName = $this->linkName = $this->getLinkName($subpanelName, $loadedModule);
     // get the link and the related module name as the module we need the subpanel from
     $bean = BeanFactory::getBean($loadedModule);
     // Get the linkdef, but make sure to tell VardefManager to use name instead by passing true
     $linkDef = VardefManager::getLinkFieldForRelationship($bean->module_dir, $bean->object_name, $subpanelName, true);
     if ($bean->load_relationship($linkName)) {
         $link = $bean->{$linkName};
     } else {
         $link = new Link2($linkName, $bean);
     }
     $this->_moduleName = $link->getRelatedModuleName();
     $this->bean = BeanFactory::getBean($this->_moduleName);
     $subpanelFixed = true;
     if (empty($this->bean)) {
         $subpanelFixed = $this->fixUpSubpanel();
     }
     if (empty($linkDef['name']) && (!$subpanelFixed && isModuleBWC($this->loadedModule))) {
         $GLOBALS['log']->error("Cannot find a link for {$subpanelName} on {$loadedModule}");
         return true;
     }
     // Handle validation up front that will throw exceptions
     if (empty($this->bean) && !$subpanelFixed) {
         throw new Exception("No valid parent bean found for {$this->linkName} on {$this->loadedModule}");
     }
     $this->setUpSubpanelViewDefFileInfo();
     include $this->loadedSubpanelFileName;
     // Prepare to load the history file. This will be available in cases when
     // a layout is restored.
     $this->historyPathname = 'custom/history/modules/' . $this->_moduleName . '/clients/' . $this->getViewClient() . '/views/' . $this->sidecarSubpanelName . '/' . self::HISTORYFILENAME;
     $this->_history = new History($this->historyPathname);
     if (file_exists($this->historyPathname)) {
         // load in the subpanelDefOverride from the history file
         $GLOBALS['log']->debug(get_class($this) . ": loading from history");
         require $this->historyPathname;
     }
     $this->_viewdefs = !empty($viewdefs) ? $this->getNewViewDefs($viewdefs) : array();
     $this->_fielddefs = $this->bean->field_defs;
     $this->_mergeFielddefs($this->_fielddefs, $this->_viewdefs);
     $this->_language = '';
     // don't attempt to access the template_instance property if our subpanel represents a collection, as it won't be there - the sub-sub-panels get this value instead
     if (isset($this->_viewdefs['type']) && $this->_viewdefs['type'] != 'collection') {
         $this->_language = $this->bean->module_dir;
     }
     // Make sure the paneldefs are proper if there are any
     $this->_paneldefs = isset($this->_viewdefs['panels']) ? $this->_viewdefs['panels'] : array();
 }
 public function testSaveUsersVardefs()
 {
     global $dictionary;
     $dynamicField = new DynamicField('Users');
     VardefManager::loadVardef('Users', 'User');
     $dynamicField->saveToVardef('Users', $dictionary['User']['fields']);
     //Test that we have refreshed the Employees vardef
     $this->assertTrue(file_exists('cache/modules/Employees/Employeevardefs.php'), 'cache/modules/Employees/Emloyeevardefs.php file not created');
     //Test that status is not set to be required
     $this->assertFalse($dictionary['Employee']['fields']['status']['required'], 'status field set to required');
     //Test that the studio attribute is set to false for status field
     $this->assertFalse($dictionary['Employee']['fields']['status']['studio'], 'status field studio not set to false');
 }
Exemple #10
0
 /**
  * @param  $linkName String name of a link field in the module's vardefs
  * @param  $bean SugarBean focus bean for this link (one half of a relationship)
  * @param  $linkDef Array Optional vardef for the link in case it can't be found in the passed in bean for the global dictionary
  * @return void
  *
  */
 function __construct($linkName, $bean, $linkDef = false)
 {
     $this->focus = $bean;
     //Try to load the link vardef from the beans field defs. Otherwise start searching
     if (empty($bean->field_defs) || empty($bean->field_defs[$linkName]) || empty($bean->field_defs[$linkName]['relationship'])) {
         if (empty($linkDef)) {
             //Assume $linkName is really relationship_name, and find the link name with the vardef manager
             $this->def = VardefManager::getLinkFieldForRelationship($bean->module_dir, $bean->object_name, $linkName);
         } else {
             $this->def = $linkDef;
         }
         //Check if multiple links were found for a given relationship
         if (is_array($this->def) && !isset($this->def['name'])) {
             //More than one link found, we need to figure out if we are currently on the LHS or RHS
             //default to lhs for now
             if (isset($this->def[0]['side']) && $this->def[0]['side'] == 'left') {
                 $this->def = $this->def[0];
             } else {
                 if (isset($this->def[1]['side']) && $this->def[1]['side'] == 'left') {
                     $this->def = $this->def[1];
                 } else {
                     $this->def = $this->def[0];
                 }
             }
         }
         if (empty($this->def['name'])) {
             $GLOBALS['log']->fatal("failed to find link for {$linkName}");
             return false;
         }
         $this->name = $this->def['name'];
     } else {
         //Linkdef was found in the bean (this is the normal expectation)
         $this->def = $bean->field_defs[$linkName];
         $this->name = $linkName;
     }
     //Instantiate the relationship for this link.
     $this->relationship = SugarRelationshipFactory::getInstance()->getRelationship($this->def['relationship']);
     if (!$this->loadedSuccesfully()) {
         $GLOBALS['log']->fatal("{$this->name} for {$this->def['relationship']} failed to load\n");
     }
     //Following behavior is tied to a property(ignore_role) value in the vardef. It alters the values of 2 properties, ignore_role_filter and add_distinct.
     //the property values can be altered again before any requests are made.
     if (!empty($this->def) && is_array($this->def)) {
         if (array_key_exists('ignore_role', $this->def)) {
             if ($this->def['ignore_role']) {
                 $this->ignore_role_filter = true;
                 $this->add_distinct = true;
             }
         }
     }
 }
 public function setUp()
 {
     $beanList = array();
     $beanFiles = array();
     require 'include/modules.php';
     $GLOBALS['beanList'] = $beanList;
     $GLOBALS['beanFiles'] = $beanFiles;
     $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
     $GLOBALS['current_user']->status = 'Active';
     $GLOBALS['current_user']->is_admin = 1;
     $GLOBALS['current_user']->save();
     $this->field = get_widget('varchar');
     $this->field->id = 'Accountstest_custom_c';
     $this->field->name = 'test_custom_c';
     $this->field->vanme = 'LBL_TEST_CUSTOM_C';
     $this->field->comments = NULL;
     $this->field->help = NULL;
     $this->field->custom_module = 'Accounts';
     $this->field->type = 'varchar';
     $this->field->label = 'LBL_TEST_CUSTOM_C';
     $this->field->len = 255;
     $this->field->required = 0;
     $this->field->default_value = NULL;
     $this->field->date_modified = '2009-09-14 02:23:23';
     $this->field->deleted = 0;
     $this->field->audited = 0;
     $this->field->massupdate = 0;
     $this->field->duplicate_merge = 0;
     $this->field->reportable = 1;
     $this->field->importable = 'true';
     $this->field->ext1 = NULL;
     $this->field->ext2 = NULL;
     $this->field->ext3 = NULL;
     $this->field->ext4 = NULL;
     $this->df = new DynamicField('Accounts');
     $this->mod = new Account();
     $this->df->setup($this->mod);
     $this->df->addFieldObject($this->field);
     $this->df->buildCache('Accounts');
     VardefManager::clearVardef();
     VardefManager::refreshVardefs('Accounts', 'Account');
     $this->mod->field_defs = $GLOBALS['dictionary']['Account']['fields'];
     $this->_contact = SugarTestContactUtilities::createContact();
     $this->_account = SugarTestAccountUtilities::createAccount();
     $this->_contact->load_relationship('accounts');
     $this->_contact->accounts->add($this->_account->id);
     $this->_account->test_custom_c = 'Custom Field';
     $this->_account->save();
     $GLOBALS['db']->commit();
     // Making sure we commit any changes
 }
 /**
  * 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;
         }
     }
 }
 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'];
 }
Exemple #14
0
    public function createCustom()
    {
        //create new varchar widget and associate with Accounts
        $this->custField = get_widget('varchar');
        $this->custField->id = 'Accounts' . $this->custFieldName;
        $this->custField->name = $this->custFieldName;
        $this->custField->type = 'varchar';
        $this->custField->label = 'LBL_' . strtoupper($this->custFieldName);
        $this->custField->vname = 'LBL_' . strtoupper($this->custFieldName);
        $this->custField->len = 255;
        $this->custField->custom_module = 'Accounts';
        $this->custField->required = 0;
        $this->custField->default = 'goofy';
        $this->acc = new Account();
        $this->df = new DynamicField('Accounts');
        $this->df->setup($this->acc);
        $this->df->addFieldObject($this->custField);
        $this->df->buildCache('Accounts');
        $this->custField->save($this->df);
        VardefManager::clearVardef();
        VardefManager::refreshVardefs('Accounts', 'Account');
        //Now create the meta files to make this a Calculated Field.
        $fn = $this->custFieldName;
        $extensionContent = <<<EOQ
<?php
\$dictionary['Account']['fields']['{$fn}']['duplicate_merge_dom_value']=0;
\$dictionary['Account']['fields']['{$fn}']['calculated']='true';
\$dictionary['Account']['fields']['{$fn}']['formula']='related(\$assigned_user_link,"name")';
\$dictionary['Account']['fields']['{$fn}']['enforced']='true';
\$dictionary['Account']['fields']['{$fn}']['dependency']='';
\$dictionary['Account']['fields']['{$fn}']['type']='varchar';
\$dictionary['Account']['fields']['{$fn}']['name']='{$fn}';


EOQ;
        //create custom field file
        $this->custFileDirPath = create_custom_directory($this->custFileDirPath);
        $fileLoc = $this->custFileDirPath . 'sugarfield_' . $this->custFieldName . '.php';
        file_put_contents($fileLoc, $extensionContent);
        //run repair and clear to make sure the meta gets picked up
        $_REQUEST['repair_silent'] = 1;
        $rc = new RepairAndClear();
        $rc->repairAndClearAll(array("clearAll", "rebuildExtensions"), array("Accounts"), false, false);
        $fn = $this->custFieldName;
    }
 public function tearDown()
 {
     $GLOBALS['db']->dropTableName($this->_tablename . '_cstm');
     $GLOBALS['db']->query("DELETE FROM fields_meta_data WHERE id in ('Accountsbug34993_test_c', 'Accountsbug34993_test2_c')");
     if (isset($this->_old_installing)) {
         $GLOBALS['installing'] = $this->_old_installing;
     } else {
         unset($GLOBALS['installing']);
     }
     if (file_exists('custom/Extension/modules/Accounts/Ext/Vardefs/sugarfield_bug34993_test_c.php')) {
         unlink('custom/Extension/modules/Accounts/Ext/Vardefs/sugarfield_bug34993_test_c.php');
     }
     if (file_exists('custom/Extension/modules/Accounts/Ext/Vardefs/sugarfield_bug34993_test2_c.php')) {
         unlink('custom/Extension/modules/Accounts/Ext/Vardefs/sugarfield_bug34993_test2_c.php');
     }
     VardefManager::clearVardef('Accounts', 'Account');
     VardefManager::refreshVardefs('Accounts', 'Account');
 }
Exemple #16
0
 public function setUp()
 {
     $this->_soapURL = $GLOBALS['sugar_config']['site_url'] . '/service/v2/soap.php';
     SugarTestHelper::setUp('beanFiles');
     SugarTestHelper::setUp('beanList');
     SugarTestHelper::setUp('current_user', array(true, 1));
     $this->field = get_widget('varchar');
     $this->field->id = 'Accountstest_custom_c';
     $this->field->name = 'test_custom_c';
     $this->field->vanme = 'LBL_TEST_CUSTOM_C';
     $this->field->comments = NULL;
     $this->field->help = NULL;
     $this->field->custom_module = 'Accounts';
     $this->field->type = 'varchar';
     $this->field->label = 'LBL_TEST_CUSTOM_C';
     $this->field->len = 255;
     $this->field->required = 0;
     $this->field->default_value = NULL;
     $this->field->date_modified = '2009-09-14 02:23:23';
     $this->field->deleted = 0;
     $this->field->audited = 0;
     $this->field->massupdate = 0;
     $this->field->duplicate_merge = 0;
     $this->field->reportable = 1;
     $this->field->importable = 'true';
     $this->field->ext1 = NULL;
     $this->field->ext2 = NULL;
     $this->field->ext3 = NULL;
     $this->field->ext4 = NULL;
     $this->df = new DynamicField('Accounts');
     $this->mod = new Account();
     $this->df->setup($this->mod);
     $this->df->addFieldObject($this->field);
     $this->df->buildCache('Accounts');
     VardefManager::clearVardef();
     VardefManager::refreshVardefs('Accounts', 'Account');
     $this->mod->field_defs = $GLOBALS['dictionary']['Account']['fields'];
     $this->_account = SugarTestAccountUtilities::createAccount();
     $this->_account->test_custom_c = 'Custom Field';
     $this->_account->save();
     $GLOBALS['db']->commit();
     // Making sure we commit any changes
     parent::setUp();
 }
Exemple #17
0
 /**
  * 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}) ";
 }
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     global $beanList;
     foreach ($beanList as $bean => $class) {
         $this->modules[strtolower($bean)] = $bean;
     }
     $needClearCache = false;
     foreach ($beanList as $bean => $class) {
         VardefManager::refreshVardefs($bean, $class);
         $seed = BeanFactory::getBean($bean);
         if ($seed instanceof SugarBean) {
             if (!$this->checkBean($seed)) {
                 SugarRelationshipFactory::rebuildCache();
                 $needClearCache = true;
             }
         }
     }
     if ($needClearCache) {
         $this->cleanCache();
     }
 }
Exemple #19
0
 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License along with
 * this program; if not, see http://www.gnu.org/licenses or write to the Free
 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301 USA.
 *
 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
 *
 * The interactive user interfaces in modified source and object code versions
 * of this program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU Affero General Public License version 3.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
 * these Appropriate Legal Notices must retain the display of the "Powered by
 * SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not
 * reasonably feasible for  technical reasons, the Appropriate Legal Notices must
 * display the words  "Powered by SugarCRM" and "Supercharged by SuiteCRM".
 ********************************************************************************/
$dictionary['AOK_KnowledgeBase'] = array('table' => 'aok_knowledgebase', 'audited' => true, 'duplicate_merge' => true, 'fields' => array('name' => array('name' => 'name', 'vname' => 'LBL_NAME', 'type' => 'name', 'link' => true, 'dbType' => 'varchar', 'len' => '255', 'unified_search' => false, 'full_text_search' => array('boost' => 3), 'required' => true, 'importable' => 'required', 'duplicate_merge' => 'disabled', 'merge_filter' => 'disabled', 'massupdate' => 0, 'no_default' => false, 'comments' => '', 'help' => '', 'duplicate_merge_dom_value' => '0', 'audited' => false, 'reportable' => true, 'size' => '20'), 'status' => array('required' => false, 'name' => 'status', 'vname' => 'LBL_STATUS', 'type' => 'enum', 'massupdate' => 0, 'default' => 'Draft', 'no_default' => false, 'comments' => '', 'help' => '', 'importable' => 'true', 'duplicate_merge' => 'disabled', 'duplicate_merge_dom_value' => '0', 'audited' => false, 'reportable' => true, 'unified_search' => false, 'merge_filter' => 'disabled', 'len' => 100, 'size' => '20', 'options' => 'aok_status_list', 'studio' => 'visible', 'dependency' => false), 'revision' => array('required' => false, 'name' => 'revision', 'vname' => 'LBL_REVISION', 'type' => 'varchar', 'massupdate' => 0, 'no_default' => false, 'comments' => '', 'help' => '', 'importable' => 'true', 'duplicate_merge' => 'disabled', 'duplicate_merge_dom_value' => '0', 'audited' => false, 'reportable' => true, 'unified_search' => false, 'merge_filter' => 'disabled', 'len' => '255', 'size' => '20'), 'description' => array('name' => 'description', 'vname' => 'LBL_DESCRIPTION', 'type' => 'text', 'comment' => 'Full text of the note', 'rows' => '6', 'cols' => '80', 'required' => false, 'massupdate' => 0, 'no_default' => false, 'comments' => 'Full text of the note', 'help' => '', 'importable' => 'true', 'duplicate_merge' => 'disabled', 'duplicate_merge_dom_value' => '0', 'audited' => false, 'reportable' => true, 'unified_search' => false, 'merge_filter' => 'disabled', 'size' => '20', 'studio' => 'visible'), 'additional_info' => array('name' => 'additional_info', 'vname' => 'LBL_ADDITIONAL_INFO', 'type' => 'text', 'comment' => 'Full text of the note', 'rows' => '6', 'cols' => '80', 'required' => false, 'massupdate' => 0, 'no_default' => false, 'comments' => 'Full text of the note', 'help' => '', 'importable' => 'true', 'duplicate_merge' => 'disabled', 'duplicate_merge_dom_value' => '0', 'audited' => false, 'reportable' => true, 'unified_search' => false, 'merge_filter' => 'disabled', 'size' => '20', 'studio' => 'visible'), 'user_id_c' => array('required' => false, 'name' => 'user_id_c', 'vname' => 'LBL_AUTHOR_USER_ID', 'type' => 'id', 'massupdate' => 0, 'no_default' => false, 'comments' => '', 'help' => '', 'importable' => 'true', 'duplicate_merge' => 'disabled', 'duplicate_merge_dom_value' => 0, 'audited' => false, 'reportable' => false, 'unified_search' => false, 'merge_filter' => 'disabled', 'len' => 36, 'size' => '20'), 'author' => array('required' => true, 'source' => 'non-db', 'name' => 'author', 'vname' => 'LBL_AUTHOR', 'type' => 'relate', 'massupdate' => 0, 'no_default' => false, 'comments' => '', 'help' => '', 'importable' => 'true', 'duplicate_merge' => 'disabled', 'duplicate_merge_dom_value' => '0', 'audited' => false, 'reportable' => true, 'unified_search' => false, 'merge_filter' => 'disabled', 'len' => '255', 'size' => '20', 'id_name' => 'user_id_c', 'ext2' => 'Users', 'module' => 'Users', 'rname' => 'name', 'quicksearch' => 'enabled', 'studio' => 'visible'), 'user_id1_c' => array('required' => false, 'name' => 'user_id1_c', 'vname' => 'LBL_APPROVER_USER_ID', 'type' => 'id', 'massupdate' => 0, 'no_default' => false, 'comments' => '', 'help' => '', 'importable' => 'true', 'duplicate_merge' => 'disabled', 'duplicate_merge_dom_value' => 0, 'audited' => false, 'reportable' => false, 'unified_search' => false, 'merge_filter' => 'disabled', 'len' => 36, 'size' => '20'), 'approver' => array('required' => false, 'source' => 'non-db', 'name' => 'approver', 'vname' => 'LBL_APPROVER', 'type' => 'relate', 'massupdate' => 0, 'no_default' => false, 'comments' => '', 'help' => '', 'importable' => 'true', 'duplicate_merge' => 'disabled', 'duplicate_merge_dom_value' => '0', 'audited' => false, 'reportable' => true, 'unified_search' => false, 'merge_filter' => 'disabled', 'len' => '255', 'size' => '20', 'id_name' => 'user_id1_c', 'ext2' => 'Users', 'module' => 'Users', 'rname' => 'name', 'quicksearch' => 'enabled', 'studio' => 'visible'), 'aok_knowledgebase_categories' => array('name' => 'aok_knowledgebase_categories', 'type' => 'link', 'relationship' => 'aok_knowledgebase_categories', 'source' => 'non-db', 'module' => 'AOK_Knowledge_Base_Categories', 'bean_name' => false, 'vname' => 'LBL_AOK_KB_CATEGORIES_TITLE')), 'relationships' => array(), 'optimistic_locking' => true, 'unified_search' => true);
if (!class_exists('VardefManager')) {
    require_once 'include/SugarObjects/VardefManager.php';
}
VardefManager::createVardef('AOK_KnowledgeBase', 'AOK_KnowledgeBase', array('basic', 'assignable', 'security_groups'));
Exemple #20
0
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License along with
 * this program; if not, see http://www.gnu.org/licenses or write to the Free
 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301 USA.
 *
 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
 *
 * The interactive user interfaces in modified source and object code versions
 * of this program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU Affero General Public License version 3.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
 * these Appropriate Legal Notices must retain the display of the "Powered by
 * SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not
 * reasonably feasible for  technical reasons, the Appropriate Legal Notices must
 * display the words  "Powered by SugarCRM" and "Supercharged by SuiteCRM".
 ********************************************************************************/
$dictionary['Call'] = array('table' => 'calls', 'comment' => 'A Call is an activity representing a phone call', 'unified_search' => true, 'full_text_search' => true, 'unified_search_default_enabled' => true, 'fields' => array('name' => array('name' => 'name', 'vname' => 'LBL_SUBJECT', 'dbType' => 'varchar', 'type' => 'name', 'len' => '50', 'comment' => 'Brief description of the call', 'unified_search' => true, 'full_text_search' => array('boost' => 3), 'required' => true, 'importable' => 'required'), 'duration_hours' => array('name' => 'duration_hours', 'vname' => 'LBL_DURATION_HOURS', 'type' => 'int', 'len' => '2', 'comment' => 'Call duration, hours portion', 'required' => true), 'duration_minutes' => array('name' => 'duration_minutes', 'vname' => 'LBL_DURATION_MINUTES', 'type' => 'int', 'function' => array('name' => 'getDurationMinutesOptions', 'returns' => 'html', 'include' => 'modules/Calls/CallHelper.php'), 'len' => '2', 'group' => 'duration_hours', 'importable' => 'required', 'comment' => 'Call duration, minutes portion'), 'date_start' => array('name' => 'date_start', 'vname' => 'LBL_DATE', 'type' => 'datetimecombo', 'dbType' => 'datetime', 'comment' => 'Date in which call is schedule to (or did) start', 'importable' => 'required', 'required' => true, 'enable_range_search' => true, 'options' => 'date_range_search_dom'), 'date_end' => array('name' => 'date_end', 'vname' => 'LBL_DATE_END', 'type' => 'datetimecombo', 'dbType' => 'datetime', 'massupdate' => false, 'comment' => 'Date is which call is scheduled to (or did) end', 'enable_range_search' => true, 'options' => 'date_range_search_dom'), 'parent_type' => array('name' => 'parent_type', 'vname' => 'LBL_PARENT_TYPE', 'type' => 'parent_type', 'dbType' => 'varchar', 'required' => false, 'group' => 'parent_name', 'options' => 'parent_type_display', 'len' => 255, 'comment' => 'The Sugar object to which the call is related'), 'parent_name' => array('name' => 'parent_name', 'parent_type' => 'record_type_display', 'type_name' => 'parent_type', 'id_name' => 'parent_id', 'vname' => 'LBL_LIST_RELATED_TO', 'type' => 'parent', 'group' => 'parent_name', 'source' => 'non-db', 'options' => 'parent_type_display'), 'status' => array('name' => 'status', 'vname' => 'LBL_STATUS', 'type' => 'enum', 'len' => 100, 'options' => 'call_status_dom', 'comment' => 'The status of the call (Held, Not Held, etc.)', 'required' => true, 'importable' => 'required', 'default' => 'Planned', 'studio' => array('detailview' => false)), 'direction' => array('name' => 'direction', 'vname' => 'LBL_DIRECTION', 'type' => 'enum', 'len' => 100, 'options' => 'call_direction_dom', 'comment' => 'Indicates whether call is inbound or outbound'), 'parent_id' => array('name' => 'parent_id', 'vname' => 'LBL_LIST_RELATED_TO_ID', 'type' => 'id', 'group' => 'parent_name', 'reportable' => false, 'comment' => 'The ID of the parent Sugar object identified by parent_type'), 'reminder_checked' => array('name' => 'reminder_checked', 'vname' => 'LBL_REMINDER', 'type' => 'bool', 'source' => 'non-db', 'comment' => 'checkbox indicating whether or not the reminder value is set (Meta-data only)', 'massupdate' => false), 'reminder_time' => array('name' => 'reminder_time', 'vname' => 'LBL_REMINDER_TIME', 'type' => 'enum', 'dbType' => 'int', 'options' => 'reminder_time_options', 'reportable' => false, 'massupdate' => false, 'default' => -1, 'comment' => 'Specifies when a reminder alert should be issued; -1 means no alert; otherwise the number of seconds prior to the start'), 'email_reminder_checked' => array('name' => 'email_reminder_checked', 'vname' => 'LBL_EMAIL_REMINDER', 'type' => 'bool', 'source' => 'non-db', 'comment' => 'checkbox indicating whether or not the email reminder value is set (Meta-data only)', 'massupdate' => false), 'email_reminder_time' => array('name' => 'email_reminder_time', 'vname' => 'LBL_EMAIL_REMINDER_TIME', 'type' => 'enum', 'dbType' => 'int', 'options' => 'reminder_time_options', 'reportable' => false, 'massupdate' => false, 'default' => -1, 'comment' => 'Specifies when a email reminder alert should be issued; -1 means no alert; otherwise the number of seconds prior to the start'), 'email_reminder_sent' => array('name' => 'email_reminder_sent', 'vname' => 'LBL_EMAIL_REMINDER_SENT', 'default' => 0, 'type' => 'bool', 'comment' => 'Whether email reminder is already sent', 'studio' => false, 'massupdate' => false), 'outlook_id' => array('name' => 'outlook_id', 'vname' => 'LBL_OUTLOOK_ID', 'type' => 'varchar', 'len' => '255', 'reportable' => false, 'comment' => 'When the Sugar Plug-in for Microsoft Outlook syncs an Outlook appointment, this is the Outlook appointment item ID'), 'accept_status' => array('name' => 'accept_status', 'vname' => 'LBL_ACCEPT_STATUS', 'dbType' => 'varchar', 'type' => 'varchar', 'len' => '20', 'source' => 'non-db'), 'set_accept_links' => array('name' => 'accept_status', 'vname' => 'LBL_ACCEPT_LINK', 'dbType' => 'varchar', 'type' => 'varchar', 'len' => '20', 'source' => 'non-db'), 'contact_name' => array('name' => 'contact_name', 'rname' => 'last_name', 'db_concat_fields' => array(0 => 'first_name', 1 => 'last_name'), 'id_name' => 'contact_id', 'massupdate' => false, 'vname' => 'LBL_CONTACT_NAME', 'type' => 'relate', 'link' => 'contacts', 'table' => 'contacts', 'isnull' => 'true', 'module' => 'Contacts', 'join_name' => 'contacts', 'dbType' => 'varchar', 'source' => 'non-db', 'len' => 36, 'importable' => 'false', 'studio' => array('required' => false, 'listview' => true, 'visible' => false)), 'opportunities' => array('name' => 'opportunities', 'type' => 'link', 'relationship' => 'opportunity_calls', 'source' => 'non-db', 'link_type' => 'one', 'vname' => 'LBL_OPPORTUNITY'), 'leads' => array('name' => 'leads', 'type' => 'link', 'relationship' => 'calls_leads', 'source' => 'non-db', 'vname' => 'LBL_LEADS'), 'project' => array('name' => 'project', 'type' => 'link', 'relationship' => 'projects_calls', 'source' => 'non-db', 'vname' => 'LBL_PROJECTS'), 'case' => array('name' => 'case', 'type' => 'link', 'relationship' => 'case_calls', 'source' => 'non-db', 'link_type' => 'one', 'vname' => 'LBL_CASE'), 'accounts' => array('name' => 'accounts', 'type' => 'link', 'relationship' => 'account_calls', 'module' => 'Accounts', 'bean_name' => 'Account', 'source' => 'non-db', 'vname' => 'LBL_ACCOUNT'), 'contacts' => array('name' => 'contacts', 'type' => 'link', 'relationship' => 'calls_contacts', 'source' => 'non-db', 'vname' => 'LBL_CONTACTS'), 'users' => array('name' => 'users', 'type' => 'link', 'relationship' => 'calls_users', 'source' => 'non-db', 'vname' => 'LBL_USERS'), 'notes' => array('name' => 'notes', 'type' => 'link', 'relationship' => 'calls_notes', 'module' => 'Notes', 'bean_name' => 'Note', 'source' => 'non-db', 'vname' => 'LBL_NOTES'), 'created_by_link' => array('name' => 'created_by_link', 'type' => 'link', 'relationship' => 'calls_created_by', 'vname' => 'LBL_CREATED_BY_USER', 'link_type' => 'one', 'module' => 'Users', 'bean_name' => 'User', 'source' => 'non-db'), 'modified_user_link' => array('name' => 'modified_user_link', 'type' => 'link', 'relationship' => 'calls_modified_user', 'vname' => 'LBL_MODIFIED_BY_USER', 'link_type' => 'one', 'module' => 'Users', 'bean_name' => 'User', 'source' => 'non-db'), 'assigned_user_link' => array('name' => 'assigned_user_link', 'type' => 'link', 'relationship' => 'calls_assigned_user', 'vname' => 'LBL_ASSIGNED_TO_USER', 'link_type' => 'one', 'module' => 'Users', 'bean_name' => 'User', 'source' => 'non-db'), 'contact_id' => array('name' => 'contact_id', 'type' => 'id', 'source' => 'non-db'), 'repeat_type' => array('name' => 'repeat_type', 'vname' => 'LBL_REPEAT_TYPE', 'type' => 'enum', 'len' => 36, 'options' => 'repeat_type_dom', 'comment' => 'Type of recurrence', 'importable' => 'false', 'massupdate' => false, 'reportable' => false, 'studio' => 'false'), 'repeat_interval' => array('name' => 'repeat_interval', 'vname' => 'LBL_REPEAT_INTERVAL', 'type' => 'int', 'len' => 3, 'default' => 1, 'comment' => 'Interval of recurrence', 'importable' => 'false', 'massupdate' => false, 'reportable' => false, 'studio' => 'false'), 'repeat_dow' => array('name' => 'repeat_dow', 'vname' => 'LBL_REPEAT_DOW', 'type' => 'varchar', 'len' => 7, 'comment' => 'Days of week in recurrence', 'importable' => 'false', 'massupdate' => false, 'reportable' => false, 'studio' => 'false'), 'repeat_until' => array('name' => 'repeat_until', 'vname' => 'LBL_REPEAT_UNTIL', 'type' => 'date', 'comment' => 'Repeat until specified date', 'importable' => 'false', 'massupdate' => false, 'reportable' => false, 'studio' => 'false'), 'repeat_count' => array('name' => 'repeat_count', 'vname' => 'LBL_REPEAT_COUNT', 'type' => 'int', 'len' => 7, 'comment' => 'Number of recurrence', 'importable' => 'false', 'massupdate' => false, 'reportable' => false, 'studio' => 'false'), 'repeat_parent_id' => array('name' => 'repeat_parent_id', 'vname' => 'LBL_REPEAT_PARENT_ID', 'type' => 'id', 'len' => 36, 'comment' => 'Id of the first element of recurring records', 'importable' => 'false', 'massupdate' => false, 'reportable' => false, 'studio' => 'false'), 'recurring_source' => array('name' => 'recurring_source', 'vname' => 'LBL_RECURRING_SOURCE', 'type' => 'varchar', 'len' => 36, 'comment' => 'Source of recurring call', 'importable' => false, 'massupdate' => false, 'reportable' => false, 'studio' => false)), 'indices' => array(array('name' => 'idx_call_name', 'type' => 'index', 'fields' => array('name')), array('name' => 'idx_status', 'type' => 'index', 'fields' => array('status')), array('name' => 'idx_calls_date_start', 'type' => 'index', 'fields' => array('date_start')), array('name' => 'idx_calls_par_del', 'type' => 'index', 'fields' => array('parent_id', 'parent_type', 'deleted')), array('name' => 'idx_calls_assigned_del', 'type' => 'index', 'fields' => array('deleted', 'assigned_user_id'))), 'relationships' => array('calls_assigned_user' => array('lhs_module' => 'Users', 'lhs_table' => 'users', 'lhs_key' => 'id', 'rhs_module' => 'Calls', 'rhs_table' => 'calls', 'rhs_key' => 'assigned_user_id', 'relationship_type' => 'one-to-many'), 'calls_modified_user' => array('lhs_module' => 'Users', 'lhs_table' => 'users', 'lhs_key' => 'id', 'rhs_module' => 'Calls', 'rhs_table' => 'calls', 'rhs_key' => 'modified_user_id', 'relationship_type' => 'one-to-many'), 'calls_created_by' => array('lhs_module' => 'Users', 'lhs_table' => 'users', 'lhs_key' => 'id', 'rhs_module' => 'Calls', 'rhs_table' => 'calls', 'rhs_key' => 'created_by', 'relationship_type' => 'one-to-many'), 'calls_notes' => array('lhs_module' => 'Calls', 'lhs_table' => 'calls', 'lhs_key' => 'id', 'rhs_module' => 'Notes', 'rhs_table' => 'notes', 'rhs_key' => 'parent_id', 'relationship_type' => 'one-to-many', 'relationship_role_column' => 'parent_type', 'relationship_role_column_value' => 'Calls')), 'optimistic_locking' => true);
VardefManager::createVardef('Calls', 'Call', array('default', 'assignable'));
<?php

/**
 * Products, Quotations & Invoices modules.
 * Extensions to SugarCRM
 * @package Advanced OpenSales for SugarCRM
 * @subpackage Products
 * @copyright SalesAgility Ltd http://www.salesagility.com
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
 * along with this program; if not, see http://www.gnu.org/licenses
 * or write to the Free Software Foundation,Inc., 51 Franklin Street,
 * Fifth Floor, Boston, MA 02110-1301  USA
 *
 * @author Salesagility Ltd <*****@*****.**>
 */
$dictionary['AOS_PDF_Templates'] = array('table' => 'aos_pdf_templates', 'audited' => true, 'fields' => array('type' => array('required' => '1', 'name' => 'type', 'vname' => 'LBL_TYPE', 'type' => 'enum', 'massupdate' => 0, 'default' => 'Quotes', 'comments' => '', 'help' => '', 'importable' => 'true', 'duplicate_merge' => 'disabled', 'duplicate_merge_dom_value' => '0', 'audited' => 1, 'reportable' => 0, 'len' => 100, 'options' => 'pdf_template_type_dom', 'studio' => 'visible'), 'sample' => array('required' => '0', 'name' => 'sample', 'vname' => 'LBL_SAMPLE', 'source' => 'non-db', 'type' => 'enum', 'massupdate' => 0, 'default' => '', 'comments' => '', 'help' => '', 'importable' => 'true', 'duplicate_merge' => 'disabled', 'duplicate_merge_dom_value' => '0', 'audited' => 1, 'reportable' => 0, 'len' => 100, 'options' => 'pdf_template_sample_dom', 'studio' => 'visible'), 'pdfheader' => array('required' => false, 'name' => 'pdfheader', 'vname' => 'LBL_HEADER', 'type' => 'text', 'massupdate' => 0, 'comments' => '', 'help' => '', 'importable' => 'true', 'duplicate_merge' => 'disabled', 'duplicate_merge_dom_value' => '0', 'audited' => false, 'reportable' => true, 'size' => '20', 'studio' => 'visible', 'rows' => '4', 'cols' => '20'), 'pdffooter' => array('required' => false, 'name' => 'pdffooter', 'vname' => 'LBL_FOOTER', 'type' => 'text', 'massupdate' => 0, 'comments' => '', 'help' => '', 'importable' => 'true', 'duplicate_merge' => 'disabled', 'duplicate_merge_dom_value' => '0', 'audited' => false, 'reportable' => true, 'size' => '20', 'studio' => 'visible', 'rows' => '4', 'cols' => '20')), 'relationships' => array(), 'optimistic_lock' => true);
require_once 'include/SugarObjects/VardefManager.php';
VardefManager::createVardef('AOS_PDF_Templates', 'AOS_PDF_Templates', array('basic', 'assignable'));
Exemple #22
0
/**
 * This function retrieves a module's language file and returns the array of strings included.
 *
 * @param string $language specific language to load
 * @param string $module module name to load strings for
 * @param bool $refresh optional, true if you want to rebuild the language strings
 * @return array lang strings
 */
function return_module_language($language, $module, $refresh = false)
{
    global $mod_strings;
    global $sugar_config;
    global $currentModule;
    // Jenny - Bug 8119: Need to check if $module is not empty
    if (empty($module)) {
        $stack = debug_backtrace();
        $GLOBALS['log']->warn("Variable module is not in return_module_language " . var_export($stack, true));
        return array();
    }
    if (!$refresh) {
        $cache_key = LanguageManager::getLanguageCacheKey($module, $language);
        // Check for cached value
        $cache_entry = sugar_cache_retrieve($cache_key);
        if (!empty($cache_entry)) {
            return $cache_entry;
        }
    }
    // Store the current mod strings for later
    $temp_mod_strings = $mod_strings;
    $loaded_mod_strings = array();
    $language_used = $language;
    $default_language = $sugar_config['default_language'];
    if (empty($language)) {
        $language = $default_language;
    }
    // Bug 21559 - So we can get all the strings defined in the template, refresh
    // the vardefs file if the cached language file doesn't exist.
    if (!file_exists($GLOBALS['sugar_config']['cache_dir'] . 'modules/' . $module . '/language/' . $language . '.lang.php') && !empty($GLOBALS['beanList'][$module])) {
        $object = $GLOBALS['beanList'][$module];
        if ($object == 'aCase') {
            $object = 'Case';
        }
        VardefManager::refreshVardefs($module, $object);
    }
    $loaded_mod_strings = LanguageManager::loadModuleLanguage($module, $language, $refresh);
    // cn: bug 6048 - merge en_us with requested language
    if ($language != $sugar_config['default_language']) {
        $loaded_mod_strings = sugarArrayMerge(LanguageManager::loadModuleLanguage($module, $sugar_config['default_language'], $refresh), $loaded_mod_strings);
    }
    // Load in en_us strings by default
    if ($language != 'en_us' && $sugar_config['default_language'] != 'en_us') {
        $loaded_mod_strings = sugarArrayMerge(LanguageManager::loadModuleLanguage($module, 'en_us', $refresh), $loaded_mod_strings);
    }
    // If we are in debug mode for translating, turn on the prefix now!
    if ($sugar_config['translation_string_prefix']) {
        foreach ($loaded_mod_strings as $entry_key => $entry_value) {
            $loaded_mod_strings[$entry_key] = $language_used . ' ' . $entry_value;
        }
    }
    $return_value = $loaded_mod_strings;
    if (!isset($mod_strings)) {
        $mod_strings = $return_value;
    } else {
        $mod_strings = $temp_mod_strings;
    }
    $cache_key = LanguageManager::getLanguageCacheKey($module, $language);
    sugar_cache_put($cache_key, $return_value);
    return $return_value;
}
 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License along with
 * this program; if not, see http://www.gnu.org/licenses or write to the Free
 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301 USA.
 *
 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
 *
 * The interactive user interfaces in modified source and object code versions
 * of this program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU Affero General Public License version 3.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
 * these Appropriate Legal Notices must retain the display of the "Powered by
 * SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not
 * reasonably feasible for  technical reasons, the Appropriate Legal Notices must
 * display the words  "Powered by SugarCRM" and "Supercharged by SuiteCRM".
 ********************************************************************************/
$dictionary['My_Custom_File'] = array('table' => 'my_custom_file', 'audited' => true, 'inline_edit' => true, 'fields' => array(), 'relationships' => array(), 'optimistic_locking' => true, 'unified_search' => true);
if (!class_exists('VardefManager')) {
    require_once 'include/SugarObjects/VardefManager.php';
}
VardefManager::createVardef('My_Custom_File', 'My_Custom_File', array('basic', 'assignable', 'security_groups', 'file'));
Exemple #24
0
 public function setUp()
 {
     SugarTestHelper::setUp('current_user', array(true, 1));
     SugarTestHelper::setUp('beanFiles');
     SugarTestHelper::setUp('beanList');
     SugarTestHelper::setUp('app_list_strings');
     SugarTestHelper::setUp('app_strings');
     $_REQUEST = $this->keys;
     $_REQUEST['view_module'] = "Accounts";
     $_REQUEST['lhs_module'] = "Accounts";
     $_REQUEST['rhs_module'] = "Contacts";
     $_REQUEST['lhs_label'] = "Accounts";
     $_REQUEST['rhs_label'] = "Contacts";
     $relationAccountContact = new DeployedRelationships($_REQUEST['view_module']);
     $this->relationAccountContact = $relationAccountContact->addFromPost();
     $relationAccountContact->save();
     $relationAccountContact->build();
     $_REQUEST['view_module'] = "Contacts";
     $_REQUEST['lhs_module'] = "Contacts";
     $_REQUEST['rhs_module'] = "Accounts";
     $_REQUEST['lhs_label'] = "Contacts";
     $_REQUEST['rhs_label'] = "Accounts";
     $relationContactAccount = new DeployedRelationships($_REQUEST['view_module']);
     $this->relationContactAccount = $relationContactAccount->addFromPost();
     $relationContactAccount->save();
     $relationContactAccount->build();
     SugarTestHelper::setUp('relation', array('Contacts', 'Accounts'));
     //create a new field for accounts
     $this->field = get_widget('varchar');
     $this->field->id = 'Accountstest_45339333_c';
     $this->field->name = 'test_45339333_c';
     $this->field->vname = 'LBL_TEST_CUSTOM_C';
     $this->field->help = NULL;
     $this->field->custom_module = 'Accounts';
     $this->field->type = 'varchar';
     $this->field->label = 'LBL_TEST_CUSTOM_C';
     $this->field->len = 255;
     $this->field->required = 0;
     $this->field->default_value = NULL;
     $this->field->date_modified = '2012-10-31 02:23:23';
     $this->field->deleted = 0;
     $this->field->audited = 0;
     $this->field->massupdate = 0;
     $this->field->duplicate_merge = 0;
     $this->field->reportable = 1;
     $this->field->importable = 'true';
     $this->field->ext1 = NULL;
     $this->field->ext2 = NULL;
     $this->field->ext3 = NULL;
     $this->field->ext4 = NULL;
     //add field to metadata
     $this->df = new DynamicField('Accounts');
     $this->df->setup(new Account());
     $this->df->addFieldObject($this->field);
     $this->df->buildCache('Accounts');
     VardefManager::clearVardef();
     VardefManager::refreshVardefs('Accounts', 'Account');
     $this->mbPackage = new Bug45339MBPackageMock($this->packName);
 }
Exemple #25
0
check_now(get_sugarbeat());
ob_end_clean();
logThis('End Updating the license ', $path);
set_upgrade_progress('end', 'done');
logThis('Cleaning up the session.  Goodbye.');
unlinkUWTempFiles();
logThis('Cleaning up the session.  Goodbye.');
resetUwSession();
// flag to say upgrade has completed
$_SESSION['upgrade_complete'] = true;
//Clear any third party caches
sugar_cache_reset_full();
//add the clean vardefs here
if (!class_exists('VardefManager')) {
}
VardefManager::clearVardef();
require_once 'include/TemplateHandler/TemplateHandler.php';
TemplateHandler::clearAll();
//also add the cache cleaning here.
if (function_exists('deleteCache')) {
    deleteCache();
}
global $mod_strings;
global $current_language;
if (!isset($current_language) || $current_language == null) {
    $current_language = 'en_us';
}
if (isset($GLOBALS['current_language']) && $GLOBALS['current_language'] != null) {
    $current_language = $GLOBALS['current_language'];
}
$mod_strings = return_module_language($current_language, 'UpgradeWizard');
Exemple #26
0
 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU Affero General Public License along with
 * this program; if not, see http://www.gnu.org/licenses or write to the Free
 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301 USA.
 * 
 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
 * 
 * The interactive user interfaces in modified source and object code versions
 * of this program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU Affero General Public License version 3.
 * 
 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
 * these Appropriate Legal Notices must retain the display of the "Powered by
 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
 * technical reasons, the Appropriate Legal Notices must display the words
 * "Powered by SugarCRM".
 ********************************************************************************/
$dictionary['sel_Selkirk_Approvals_01'] = array('table' => 'sel_selkirk_approvals_01', 'audited' => true, 'duplicate_merge' => true, 'fields' => array('name' => array('name' => 'name', 'vname' => 'LBL_NAME', 'type' => 'name', 'link' => true, 'dbType' => 'varchar', 'len' => '255', 'unified_search' => false, 'full_text_search' => array('boost' => 3), 'required' => true, 'importable' => 'required', 'duplicate_merge' => 'disabled', 'merge_filter' => 'disabled', 'massupdate' => 0, 'no_default' => false, 'comments' => '', 'help' => '', 'duplicate_merge_dom_value' => '0', 'audited' => true, 'reportable' => true, 'size' => '20'), 'date_approved' => array('required' => false, 'name' => 'date_approved', 'vname' => 'LBL_DATE_APPROVED', 'type' => 'date', 'massupdate' => 0, 'no_default' => false, 'comments' => '', 'help' => '', 'importable' => 'true', 'duplicate_merge' => 'disabled', 'duplicate_merge_dom_value' => '0', 'audited' => false, 'reportable' => true, 'unified_search' => false, 'merge_filter' => 'disabled', 'size' => '20', 'enable_range_search' => false, 'display_default' => 'now'), 'description' => array('name' => 'description', 'vname' => 'LBL_DESCRIPTION', 'type' => 'text', 'comment' => 'Full text of the note', 'rows' => '6', 'cols' => '80', 'required' => false, 'massupdate' => 0, 'no_default' => false, 'comments' => 'Full text of the note', 'help' => '', 'importable' => 'true', 'duplicate_merge' => 'disabled', 'duplicate_merge_dom_value' => '0', 'audited' => false, 'reportable' => true, 'unified_search' => false, 'merge_filter' => 'disabled', 'size' => '20', 'studio' => 'visible'), 'title' => array('required' => false, 'name' => 'title', 'vname' => 'LBL_TITLE', 'type' => 'enum', 'massupdate' => 0, 'default' => 'president_CEO', 'no_default' => false, 'comments' => '', 'help' => '', 'importable' => 'true', 'duplicate_merge' => 'disabled', 'duplicate_merge_dom_value' => '0', 'audited' => false, 'reportable' => true, 'unified_search' => false, 'merge_filter' => 'disabled', 'len' => 100, 'size' => '20', 'options' => 'selkirk_person_title_list', 'studio' => 'visible', 'dependency' => false)), 'relationships' => array(), 'optimistic_locking' => true, 'unified_search' => true);
if (!class_exists('VardefManager')) {
    require_once 'include/SugarObjects/VardefManager.php';
}
VardefManager::createVardef('sel_Selkirk_Approvals_01', 'sel_Selkirk_Approvals_01', array('basic', 'assignable'));
Exemple #27
0
 function getRelatedFields($module, $id, $fields, $return_array = false)
 {
     if (empty($GLOBALS['beanList'][$module])) {
         return '';
     }
     $object = $GLOBALS['beanList'][$module];
     if ($object == 'aCase') {
         $object = 'Case';
     }
     VardefManager::loadVardef($module, $object);
     if (empty($GLOBALS['dictionary'][$object]['table'])) {
         return '';
     }
     $table = $GLOBALS['dictionary'][$object]['table'];
     $query = 'SELECT id';
     foreach ($fields as $field => $alias) {
         if (!empty($GLOBALS['dictionary'][$object]['fields'][$field]['db_concat_fields'])) {
             $query .= ' ,' . db_concat($table, $GLOBALS['dictionary'][$object]['fields'][$field]['db_concat_fields']) . ' as ' . $alias;
         } else {
             if (!empty($GLOBALS['dictionary'][$object]['fields'][$field]) && (empty($GLOBALS['dictionary'][$object]['fields'][$field]['source']) || $GLOBALS['dictionary'][$object]['fields'][$field]['source'] != "non-db")) {
                 $query .= ' ,' . $table . '.' . $field . ' as ' . $alias;
             }
         }
         if (!$return_array) {
             $this->{$alias} = '';
         }
     }
     if ($query == 'SELECT id' || empty($id)) {
         return '';
     }
     if (isset($GLOBALS['dictionary'][$object]['fields']['assigned_user_id'])) {
         $query .= " , " . $table . ".assigned_user_id owner";
     } else {
         if (isset($GLOBALS['dictionary'][$object]['fields']['created_by'])) {
             $query .= " , " . $table . ".created_by owner";
         }
     }
     $query .= ' FROM ' . $table . ' WHERE deleted=0 AND id=';
     $result = $GLOBALS['db']->query($query . "'{$id}'");
     $row = $GLOBALS['db']->fetchByAssoc($result);
     if ($return_array) {
         return $row;
     }
     $owner = empty($row['owner']) ? '' : $row['owner'];
     foreach ($fields as $alias) {
         $this->{$alias} = !empty($row[$alias]) ? $row[$alias] : '';
         $alias = $alias . '_owner';
         $this->{$alias} = $owner;
         $a_mod = $alias . '_mod';
         $this->{$a_mod} = $module;
     }
 }
Exemple #28
0
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU Affero General Public License along with
 * this program; if not, see http://www.gnu.org/licenses or write to the Free
 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301 USA.
 * 
 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
 * 
 * The interactive user interfaces in modified source and object code versions
 * of this program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU Affero General Public License version 3.
 * 
 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
 * these Appropriate Legal Notices must retain the display of the "Powered by
 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
 * technical reasons, the Appropriate Legal Notices must display the words
 * "Powered by SugarCRM".
 ********************************************************************************/
$dictionary['SchedulersJob'] = array('table' => 'job_queue', 'comment' => 'Job queue keeps the list of the jobs executed by this instance', 'fields' => array('id' => array('name' => 'id', 'vname' => 'LBL_NAME', 'type' => 'id', 'len' => '36', 'required' => true, 'reportable' => false), 'name' => array('name' => 'name', 'vname' => 'LBL_NAME', 'type' => 'name', 'link' => true, 'dbType' => 'varchar', 'len' => 255, 'required' => true), 'deleted' => array('name' => 'deleted', 'vname' => 'LBL_DELETED', 'type' => 'bool', 'required' => true, 'default' => '0', 'reportable' => false), 'date_entered' => array('name' => 'date_entered', 'vname' => 'LBL_DATE_ENTERED', 'type' => 'datetime', 'required' => true), 'date_modified' => array('name' => 'date_modified', 'vname' => 'LBL_DATE_MODIFIED', 'type' => 'datetime', 'required' => true), 'scheduler_id' => array('name' => 'scheduler_id', 'vname' => 'LBL_SCHEDULER', 'type' => 'id', 'required' => false, 'reportable' => false), 'execute_time' => array('name' => 'execute_time', 'vname' => 'LBL_EXECUTE_TIME', 'type' => 'datetime', 'required' => true), 'status' => array('name' => 'status', 'vname' => 'LBL_STATUS', 'type' => 'enum', 'options' => 'schedulers_times_dom', 'len' => 20, 'required' => true, 'reportable' => true, 'readonly' => true), 'resolution' => array('name' => 'resolution', 'vname' => 'LBL_RESOLUTION', 'type' => 'enum', 'options' => 'schedulers_resolution_dom', 'len' => 20, 'required' => true, 'reportable' => true, 'readonly' => true), 'message' => array('name' => 'message', 'vname' => 'LBL_MESSAGE', 'type' => 'text', 'required' => false, 'reportable' => false), 'target' => array('name' => 'target', 'vname' => 'LBL_TARGET', 'type' => 'varchar', 'len' => 255, 'required' => true, 'reportable' => true), 'data' => array('name' => 'data', 'vname' => 'LBL_DATA', 'type' => 'text', 'required' => false, 'reportable' => true), 'requeue' => array('name' => 'requeue', 'vname' => 'LBL_REQUEUE', 'type' => 'bool', 'default' => 0, 'required' => false, 'reportable' => true), 'retry_count' => array('name' => 'retry_count', 'vname' => 'LBL_RETRY_COUNT', 'type' => 'tinyint', 'required' => false, 'reportable' => true), 'failure_count' => array('name' => 'failure_count', 'vname' => 'LBL_FAIL_COUNT', 'type' => 'tinyint', 'required' => false, 'reportable' => true, 'readonly' => true), 'job_delay' => array('name' => 'job_delay', 'vname' => 'LBL_INTERVAL', 'type' => 'int', 'required' => false, 'reportable' => false), 'client' => array('name' => 'client', 'vname' => 'LBL_CLIENT', 'type' => 'varchar', 'len' => 255, 'required' => true, 'reportable' => true), 'percent_complete' => array('name' => 'percent_complete', 'vname' => 'LBL_PERCENT', 'type' => 'int', 'required' => false), 'schedulers' => array('name' => 'schedulers', 'vname' => 'LBL_SCHEDULER_ID', 'type' => 'link', 'relationship' => 'schedulers_jobs_rel', 'source' => 'non-db', 'link_type' => 'one')), 'indices' => array(array('name' => 'job_queuepk', 'type' => 'primary', 'fields' => array('id')), array('name' => 'idx_status_scheduler', 'type' => 'index', 'fields' => array('status', 'scheduler_id')), array('name' => 'idx_status_time', 'type' => 'index', 'fields' => array('status', 'execute_time', 'date_entered')), array('name' => 'idx_status_entered', 'type' => 'index', 'fields' => array('status', 'date_entered')), array('name' => 'idx_status_modified', 'type' => 'index', 'fields' => array('status', 'date_modified'))));
VardefManager::createVardef('SchedulersJobs', 'SchedulersJob', array('assignable'));
 /**
  * Generate unifed search fields for a particular module even if the module does not participate in the unified search.
  *
  * @param string $moduleName
  * @return array An array of fields to be searched against.
  */
 function generateUnifiedSearchFields($moduleName)
 {
     global $beanList, $beanFiles, $dictionary;
     if (!isset($beanList[$moduleName])) {
         return array();
     }
     $beanName = $beanList[$moduleName];
     if (!isset($beanFiles[$beanName])) {
         return array();
     }
     $beanName = BeanFactory::getObjectName($moduleName);
     $manager = new VardefManager();
     $manager->loadVardef($moduleName, $beanName);
     // obtain the field definitions used by generateSearchWhere (duplicate code in view.list.php)
     if (file_exists('custom/modules/' . $moduleName . '/metadata/metafiles.php')) {
         require 'custom/modules/' . $moduleName . '/metadata/metafiles.php';
     } elseif (file_exists('modules/' . $moduleName . '/metadata/metafiles.php')) {
         require 'modules/' . $moduleName . '/metadata/metafiles.php';
     }
     if (!empty($metafiles[$moduleName]['searchfields'])) {
         require $metafiles[$moduleName]['searchfields'];
     } elseif (file_exists("modules/{$moduleName}/metadata/SearchFields.php")) {
         require "modules/{$moduleName}/metadata/SearchFields.php";
     }
     $fields = array();
     foreach ($dictionary[$beanName]['fields'] as $field => $def) {
         if (strpos($field, 'email') !== false) {
             $field = 'email';
         }
         //bug: 38139 - allow phone to be searched through Global Search
         if (strpos($field, 'phone') !== false) {
             $field = 'phone';
         }
         if (isset($def['unified_search']) && $def['unified_search'] && isset($searchFields[$moduleName][$field])) {
             $fields[$field] = $searchFields[$moduleName][$field];
         }
     }
     //If no fields with the unified flag have been set then lets add a default field.
     if (empty($fields)) {
         if (isset($dictionary[$beanName]['fields']['name']) && isset($searchFields[$moduleName]['name'])) {
             $fields['name'] = $searchFields[$moduleName]['name'];
         } else {
             if (isset($dictionary[$beanName]['fields']['first_name']) && isset($searchFields[$moduleName]['first_name'])) {
                 $fields['first_name'] = $searchFields[$moduleName]['first_name'];
             }
             if (isset($dictionary[$beanName]['fields']['last_name']) && isset($searchFields[$moduleName]['last_name'])) {
                 $fields['last_name'] = $searchFields[$moduleName]['last_name'];
             }
         }
     }
     return $fields;
 }
 function buildCache()
 {
     global $beanList, $beanFiles, $dictionary;
     $supported_modules = array();
     foreach ($beanList as $moduleName => $beanName) {
         if (!isset($beanFiles[$beanName])) {
             continue;
         }
         $beanName = BeanFactory::getObjectName($moduleName);
         $manager = new VardefManager();
         $manager->loadVardef($moduleName, $beanName);
         // obtain the field definitions used by generateSearchWhere (duplicate code in view.list.php)
         if (file_exists('custom/modules/' . $moduleName . '/metadata/metafiles.php')) {
             require 'custom/modules/' . $moduleName . '/metadata/metafiles.php';
         } elseif (file_exists('modules/' . $moduleName . '/metadata/metafiles.php')) {
             require 'modules/' . $moduleName . '/metadata/metafiles.php';
         }
         if (!empty($metafiles[$moduleName]['searchfields'])) {
             require $metafiles[$moduleName]['searchfields'];
         } else {
             if (file_exists("modules/{$moduleName}/metadata/SearchFields.php")) {
                 require "modules/{$moduleName}/metadata/SearchFields.php";
             }
         }
         //Load custom SearchFields.php if it exists
         if (file_exists("custom/modules/{$moduleName}/metadata/SearchFields.php")) {
             require "custom/modules/{$moduleName}/metadata/SearchFields.php";
         }
         //If there are $searchFields are empty, just continue, there are no search fields defined for the module
         if (empty($searchFields[$moduleName])) {
             continue;
         }
         $isCustomModule = preg_match('/^([a-z0-9]{1,5})_([a-z0-9_]+)$/i', $moduleName);
         //If the bean supports unified search or if it's a custom module bean and unified search is not defined
         if (!empty($dictionary[$beanName]['unified_search']) || $isCustomModule) {
             $fields = array();
             foreach ($dictionary[$beanName]['fields'] as $field => $def) {
                 // We cannot enable or disable unified_search for email in the vardefs as we don't actually have a vardef entry for 'email'
                 // the searchFields entry for 'email' doesn't correspond to any vardef entry. Instead it contains SQL to directly perform the search.
                 // So as a proxy we allow any field in the vardefs that has a name starting with 'email...' to be tagged with the 'unified_search' parameter
                 if (strpos($field, 'email') !== false) {
                     $field = 'email';
                 }
                 //bug: 38139 - allow phone to be searched through Global Search
                 if (strpos($field, 'phone') !== false) {
                     $field = 'phone';
                 }
                 if (!empty($def['unified_search']) && isset($searchFields[$moduleName][$field])) {
                     $fields[$field] = $searchFields[$moduleName][$field];
                 }
             }
             foreach ($searchFields[$moduleName] as $field => $def) {
                 if (isset($def['force_unifiedsearch']) and $def['force_unifiedsearch']) {
                     $fields[$field] = $def;
                 }
             }
             if (count($fields) > 0) {
                 $supported_modules[$moduleName]['fields'] = $fields;
                 if (isset($dictionary[$beanName]['unified_search_default_enabled']) && $dictionary[$beanName]['unified_search_default_enabled'] === TRUE) {
                     $supported_modules[$moduleName]['default'] = true;
                 } else {
                     $supported_modules[$moduleName]['default'] = false;
                 }
             }
         }
     }
     ksort($supported_modules);
     write_array_to_file('unified_search_modules', $supported_modules, $this->cache_search);
 }