예제 #1
0
 public function setUp()
 {
     SugarTestHelper::setUp('beanList');
     SugarTestHelper::setUp('beanFiles');
     SugarTestHelper::setUp('app_strings');
     SugarTestHelper::setUp('app_list_strings');
     SugarTestHelper::setUp('mod_strings', array('ModuleBuilder'));
     SugarTestHelper::setUp('current_user', array(true, 1));
     $_POST = $_REQUEST = $this->getPostData();
     $this->accountFieldWidget = get_widget($_REQUEST['type']);
     $this->accountFieldWidget->populateFromPost();
     $module = $_REQUEST['view_module'];
     $this->accountField = new DynamicField($module);
     $class_name = $GLOBALS['beanList'][$module];
     require_once $GLOBALS['beanFiles'][$class_name];
     $mod = new $class_name();
     $this->accountField->setup($mod);
     $this->accountFieldWidget->save($this->accountField);
     $_POST['view_module'] = $_REQUEST['view_module'] = 'Opportunities';
     $this->opportunityFieldWidget = get_widget($_REQUEST['type']);
     $this->opportunityFieldWidget->populateFromPost();
     $module = $_REQUEST['view_module'];
     $this->opportunityField = new DynamicField($module);
     $class_name = $GLOBALS['beanList'][$module];
     require_once $GLOBALS['beanFiles'][$class_name];
     $mod = new $class_name();
     $this->opportunityField->setup($mod);
     $this->opportunityFieldWidget->save($this->opportunityField);
     $repair = new RepairAndClear();
     $repair->repairAndClearAll(array('rebuildExtensions', 'clearVardefs'), array($GLOBALS['beanList']['Accounts'], $GLOBALS['beanList']['Opportunities']), true, false);
 }
예제 #2
0
 /**
  * Adds a custom field using a field object
  *
  * @param Field Object $field
  * @return boolean
  */
 function addFieldObject(&$field)
 {
     global $dictionary, $beanList;
     if (empty($beanList[$this->module])) {
         return false;
     }
     $bean_name = get_valid_bean_name($this->module);
     if (empty($dictionary[$bean_name]) || empty($dictionary[$bean_name]["fields"][$field->name])) {
         return false;
     }
     $currdef = $dictionary[$bean_name]["fields"][$field->name];
     $this->loadCustomDef($field->name);
     $newDef = $field->get_field_def();
     require_once 'modules/DynamicFields/FieldCases.php';
     $this->baseField = get_widget($field->type);
     foreach ($field->vardef_map as $property => $fmd_col) {
         if ($property == "action" || $property == "label_value" || $property == "label" || substr($property, 0, 3) == 'ext' && strlen($property) == 4) {
             continue;
         }
         // Bug 37043 - Avoid writing out vardef defintions that are the default value.
         if (isset($newDef[$property]) && (!isset($currdef[$property]) && !$this->isDefaultValue($property, $newDef[$property], $this->baseField) || isset($currdef[$property]) && $currdef[$property] != $newDef[$property])) {
             $this->custom_def[$property] = is_string($newDef[$property]) ? htmlspecialchars_decode($newDef[$property], ENT_QUOTES) : $newDef[$property];
         }
         if (isset($this->custom_def[$property]) && !isset($newDef[$property])) {
             unset($this->custom_def[$property]);
         }
     }
     if (isset($this->custom_def["duplicate_merge_dom_value"]) && !isset($this->custom_def["duplicate_merge"])) {
         unset($this->custom_def["duplicate_merge_dom_value"]);
     }
     $this->writeVardefExtension($bean_name, $field, $this->custom_def);
 }
예제 #3
0
 /**
  * Creating new field, account, contact with filled custom field, relationship between them
  */
 public function setUp()
 {
     SugarTestHelper::setUp('beanList');
     SugarTestHelper::setUp('beanFiles');
     SugarTestHelper::setUp('current_user', array(true, true));
     $this->field = get_widget('varchar');
     $this->field->id = 'Contactstest_c';
     $this->field->name = 'test_c';
     $this->field->type = 'varchar';
     $this->field->len = 255;
     $this->field->importable = 'true';
     $this->field->label = '';
     $this->module = new Contact();
     $this->dynamicField = new DynamicField('Contacts');
     $this->dynamicField->setup($this->module);
     $this->dynamicField->addFieldObject($this->field);
     SugarTestHelper::setUp('dictionary');
     $GLOBALS['reload_vardefs'] = true;
     $this->account = SugarTestAccountUtilities::createAccount();
     $this->contact = SugarTestContactUtilities::createContact();
     $this->contact->account_id = $this->account->id;
     $this->contact->test_c = 'test value';
     $this->contact->load_relationship('accounts');
     $this->contact->accounts->add($this->account->id);
     $this->contact->save();
     $GLOBALS['db']->commit();
 }
 public function run()
 {
     // this always needs to be ran
     // get the get_widget helper and the StandardField Helper
     require_once 'modules/DynamicFields/FieldCases.php';
     require_once 'modules/ModuleBuilder/parsers/StandardField.php';
     // we are working with opportunities
     $bean = BeanFactory::getBean('Opportunities');
     // get the field defs
     $field_defs = $bean->getFieldDefinition('sales_stage');
     // load the field type up
     $f = get_widget($field_defs['type']);
     // populate the row from the vardefs that were loaded
     $f->populateFromRow($field_defs);
     $this->log('Current Sales Stage Default is: ' . var_export($f->default, true));
     // lets always make sure that the default is in the list of options
     if (isset($f->options) && isset($GLOBALS['app_list_strings'][$f->options])) {
         if (!in_array($f->default, array_keys($GLOBALS['app_list_strings'][$f->options]))) {
             $this->log(var_export($f->default, true) . ' Is Not In The List Of Options');
             $f->default = array_shift(array_keys($GLOBALS['app_list_strings'][$f->options]));
             $f->default_value = array_shift(array_keys($GLOBALS['app_list_strings'][$f->options]));
             $this->log('New Sales Stage Default Is: ' . var_export($f->default, true));
             // save the changes to the field
             $df = new StandardField($bean->module_name);
             $df->setup($bean);
             $f->module = $bean;
             $f->save($df);
         }
     }
 }
예제 #5
0
 public function setUp()
 {
     $this->field = get_widget('url');
     $this->field->id = $this->_modulename . 'foo_c';
     $this->field->name = 'foo_c';
     $this->field->vanme = 'LBL_Foo';
     $this->field->comments = NULL;
     $this->field->help = NULL;
     $this->field->custom_module = $this->_modulename;
     $this->field->type = 'url';
     $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;
 }
 public function run()
 {
     if (!$this->toFlavor('ent') && !$this->toFlavor('ult') || !version_compare($this->from_version, '7.0', '<')) {
         return;
     }
     $settings = Opportunity::getSettings();
     if ($settings['opps_view_by'] !== 'RevenueLineItems') {
         $this->log('Not using Revenue Line Items; Skipping Upgrade Script');
         return;
     }
     // get the get_widget helper and the StandardField Helper
     require_once 'modules/DynamicFields/FieldCases.php';
     require_once 'modules/ModuleBuilder/parsers/StandardField.php';
     // we are working with opportunities
     $module = 'Opportunities';
     $bean = BeanFactory::getBean('Opportunities');
     // the field set we need
     $fields = array('best_case', 'amount', 'worst_case', 'date_closed');
     // loop over each field
     foreach ($fields as $field) {
         // get the field defs
         $field_defs = $bean->getFieldDefinition($field);
         // load the field type up
         $f = get_widget($field_defs['type']);
         // populate the row from the vardefs that were loaded
         $f->populateFromRow($field_defs);
         // lets make sure that the calculated is true
         $f->calculated = true;
         // now lets save, since these are OOB field, we use StandardField
         $df = new StandardField($module);
         $df->setup($bean);
         $f->module = $bean;
         $f->save($df);
     }
 }
 protected function fixRollupFormulas()
 {
     $oldFormula = 'rollupCurrencySum($revenuelineitems, "{{field}}")';
     $newFormula = 'rollupConditionalSum($revenuelineitems, "{{field}}", "sales_stage", forecastSalesStages(true, false))';
     // the field set we need
     $fields = array('best_case' => 'best_case', 'amount' => 'likely_case', 'worst_case' => 'worst_case');
     // get the get_widget helper and the StandardField Helper
     SugarAutoLoader::load('modules/DynamicFields/FieldCases.php');
     SugarAutoLoader::load('modules/ModuleBuilder/parsers/StandardField.php');
     // we are working with opportunities
     $bean = BeanFactory::getBean('Opportunities');
     // loop over each field
     foreach ($fields as $field => $rollup_field) {
         // get the field defs
         $field_defs = $bean->getFieldDefinition($field);
         // load the field type up
         $f = get_widget($field_defs['type']);
         // populate the row from the vardefs that were loaded
         $f->populateFromRow($field_defs);
         if ($f->formula == str_replace('{{field}}', $rollup_field, $oldFormula)) {
             $f->formula = str_replace('{{field}}', $rollup_field, $newFormula);
             // now lets save, since these are OOB field, we use StandardField
             $df = new StandardField($bean->module_name);
             $df->setup($bean);
             $f->module = $bean;
             $f->save($df);
         }
     }
     // lets fix up the data now to excluded closed lost
     $this->fixRollupAmountsToExcludeClosedLostValues();
 }
 public function setUp()
 {
     // Set Original Global dbType
     $this->_originaldbType = $GLOBALS['db']->dbType;
     $this->field = get_widget('currency');
     $this->field->id = $this->_modulename . 'foofighter_c';
     $this->field->name = 'foofighter_c';
     $this->field->vanme = 'LBL_Foo';
     $this->field->comments = NULL;
     $this->field->help = NULL;
     $this->field->custom_module = $this->_modulename;
     $this->field->type = 'currency';
     $this->field->len = 18;
     $this->field->precision = 6;
     $this->field->required = 0;
     $this->field->default_value = NULL;
     $this->field->date_modified = '2010-12-22 01:01:01';
     $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;
 }
예제 #9
0
 public function setUp()
 {
     $this->markTestIncomplete("Skipping for now...");
     $this->field = get_widget('varchar');
     $this->field->id = $this->modulename . 'foo_c';
     $this->field->name = 'foo_c';
     $this->field->vanme = 'LBL_Foo';
     $this->field->comments = NULL;
     $this->field->help = NULL;
     $this->field->custom_module = $this->modulename;
     $this->field->type = 'varchar';
     $this->field->label = 'LBL_FOO';
     $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->seed = new Account();
     $this->df = new DynamicField($this->modulename);
     $this->df->setup($this->seed);
     $this->field->save($this->df);
     $this->db = $GLOBALS['db'];
     $this->repairDictionary();
 }
예제 #10
0
 /**
  * Adds a custom field using a field object
  *
  * @param Field Object $field
  * @return boolean
  */
 function addFieldObject(&$field)
 {
     global $dictionary, $beanList;
     if (empty($beanList[$this->module])) {
         return false;
     }
     $bean_name = get_valid_bean_name($this->module);
     if (empty($dictionary[$bean_name]) || empty($dictionary[$bean_name]["fields"][$field->name])) {
         return false;
     }
     $currdef = $dictionary[$bean_name]["fields"][$field->name];
     // set $field->unified_search=true if field supports unified search
     // regarding #51427
     if ($field->supports_unified_search) {
         if (isset($dictionary[$bean_name]['unified_search_default_enabled']) && isset($dictionary[$bean_name]['unified_search']) && $dictionary[$bean_name]['unified_search_default_enabled'] && $dictionary[$bean_name]['unified_search']) {
             $currdef['unified_search'] = $field->unified_search = isset($currdef['unified_search']) ? $currdef['unified_search'] : true;
         }
     }
     // end #51427
     $this->loadCustomDef($field->name);
     $this->loadBaseDef($field->name);
     $newDef = $field->get_field_def();
     require_once 'modules/DynamicFields/FieldCases.php';
     $this->baseField = get_widget($field->type);
     foreach ($field->vardef_map as $property => $fmd_col) {
         if ($property == "action" || $property == "label_value" || $property == "label" || substr($property, 0, 3) == 'ext' && strlen($property) == 4) {
             continue;
         }
         // Bug 37043 - Avoid writing out vardef defintions that are the default value.
         if (isset($newDef[$property]) && (!isset($currdef[$property]) && !$this->isDefaultValue($property, $newDef[$property], $this->baseField) || isset($currdef[$property]) && $currdef[$property] !== $newDef[$property])) {
             $this->custom_def[$property] = is_string($newDef[$property]) ? htmlspecialchars_decode($newDef[$property], ENT_QUOTES) : $newDef[$property];
         }
         //Remove any orphaned entries
         if (isset($this->custom_def[$property]) && !isset($newDef[$property])) {
             unset($this->custom_def[$property]);
         }
         //Handle overrides of out of the box definitions with empty
         if (!empty($this->base_def[$property]) && !isset($newDef[$property])) {
             //Switch on type of the property to find what the correct 'empty' is.
             if (is_string($this->base_def[$property])) {
                 $this->custom_def[$property] = "";
             } else {
                 if (is_array($this->base_def[$property])) {
                     $this->custom_def[$property] = array();
                 } else {
                     if (is_bool($this->base_def[$property])) {
                         $this->custom_def[$property] = false;
                     } else {
                         $this->custom_def[$property] = null;
                     }
                 }
             }
         }
     }
     if (isset($this->custom_def["duplicate_merge_dom_value"]) && !isset($this->custom_def["duplicate_merge"])) {
         unset($this->custom_def["duplicate_merge_dom_value"]);
     }
     $this->writeVardefExtension($bean_name, $field, $this->custom_def);
 }
예제 #11
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);
 }
예제 #12
0
 /**
  * @group bug35265
  */
 public function testFloatPrecisionMapping()
 {
     $_REQUEST = array('precision' => 2, 'type' => 'float');
     require_once 'modules/DynamicFields/FieldCases.php';
     $field = get_widget($_REQUEST['type']);
     $field->populateFromPost();
     $this->assertEquals($field->ext1, 2, 'Asserting that the ext1 value was set to the proper precision');
     $this->assertEquals($field->precision, 2, 'Asserting that the precision value was set to the proper precision');
 }
예제 #13
0
 /**
  * Test gets query for boolean field which should not contains default part
  * @dataProvider getDefaults
  * @group 52610
  * @return void
  */
 public function testDefaultInQuery($default)
 {
     $field = get_widget('bool');
     $field->name = 'bug52610_c';
     $field->type = 'bool';
     $field->default = $default;
     $field->default_value = '';
     $field->no_default = 1;
     $query = $field->get_db_add_alter_table('bug52610_cstm');
     $this->assertNotContains(" DEFAULT ", $query, "DEFAULT part is present in query");
 }
예제 #14
0
 public function setUp()
 {
     global $dictionary, $bean_list;
     $this->old_dictionary = $dictionary;
     $this->old_bean_list = $bean_list;
     $this->test_standart_field = new TestStandardField();
     $this->test_standart_field->module = 'Accounts';
     loadBean($this->test_standart_field->module);
     $this->test_field = get_widget('varchar');
     $this->test_field->name = 'name';
     $this->bean_name = get_valid_bean_name($this->test_standart_field->module);
 }
예제 #15
0
 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
 }
예제 #16
0
 private function addField($name)
 {
     $labelName = 'LBL_' . strtoupper($name);
     $field = get_widget('relate');
     $field->audited = 0;
     $field->view = 'edit';
     $field->name = $name;
     $field->vname = $labelName;
     $field->label = $labelName;
     $field->ext2 = 'Opportunities';
     $field->label_value = $name;
     $field->save($this->dynamicField);
     $this->fields[] = $field;
 }
예제 #17
0
 private function addField($name)
 {
     $labelName = 'LBL_' . strtoupper($name);
     $field = get_widget('relate');
     $field->audited = 0;
     $field->view = 'edit';
     $field->name = $name;
     $field->vname = $labelName;
     $field->label = $labelName;
     $field->ext2 = $this->relatedModule;
     $field->label_value = $name;
     $field->save(self::$dynamicField);
     self::$field = $field;
 }
예제 #18
0
 /**
  * @dataProvider provider
  */
 public function testPopulateFromPost($type, $request_data, $expected)
 {
     $tested_key = null;
     foreach ($request_data as $_key => $_data) {
         $_REQUEST[$_key] = $_data;
         $tested_key = $_key;
     }
     $field = get_widget($type);
     $field->populateFromPost();
     if (isset($field->{$tested_key})) {
         $this->assertEquals($expected, $field->{$tested_key});
     } else {
         $this->markTestSkipped();
     }
 }
예제 #19
0
 /**
  * Create the custom field with type 'relate'
  */
 protected function createCustomField()
 {
     $field = get_widget('relate');
     $field->id = 'Contacts' . $this->field_name_c;
     $field->name = $this->field_name_c;
     $field->type = 'relate';
     $field->label = 'LBL_' . strtoupper($this->field_name_c);
     $field->ext2 = 'Accounts';
     $field->view_module = 'Contacts';
     $this->relateField = $field;
     $this->bean = BeanFactory::getBean('Contacts');
     $this->df = new DynamicField($this->bean->module_name);
     $this->df->setup($this->bean);
     $field->save($this->df);
     $this->rc = new RepairAndClear();
     $this->rc->repairAndClearAll(array("rebuildExtensions", "clearVardefs"), array('Contact'), false, false);
 }
예제 #20
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;
    }
예제 #21
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();
 }
/**
 * Smarty {widget} function plugin
 *
 * Type:     function<br>
 * Name:     widget<br>
 * Purpose:  echo widget data<br>
 * @author Porokhnya Dmitry <*****@*****.**>
 */
function smarty_function_widget($params, &$smarty)
{
    $arr_keys = array_keys($params);
    // регистрируем все переданные параметры в движке, чтобы шаблон имел возможность ими оперировать
    foreach ($params as $key => $val) {
        if ($key != 'name' && $key != 'number') {
            $smarty->assign($key, $val);
        }
    }
    if (!in_array('name', $arr_keys)) {
        $smarty->trigger_error("widget: missing 'name' parameter");
        return "";
    }
    if (!in_array('number', $arr_keys)) {
        $smarty->trigger_error("widget: missing 'number' parameter");
        return "";
    }
    return get_widget($params['name'], $params['number']);
}
예제 #23
0
 public function setUp()
 {
     $this->session['use_cookies'] = ini_get('session.use_cookies');
     $this->session['cache_limiter'] = ini_get('session.session.cache_limiter');
     ini_set('session.use_cookies', false);
     ini_set('session.cache_limiter', false);
     SugarTestHelper::setUp('beanList');
     SugarTestHelper::setUp('beanFiles');
     $_SERVER['REMOTE_ADDR'] = '0.0.0.0';
     $this->_setupTestUser();
     $this->_field = get_widget('varchar');
     $this->_field->id = $this->_moduleName . $this->_customFieldName;
     $this->_field->name = $this->_customFieldName;
     $this->_field->vanme = 'LBL_' . strtoupper($this->_customFieldName);
     $this->_field->comments = NULL;
     $this->_field->help = NULL;
     $this->_field->custom_module = $this->_moduleName;
     $this->_field->type = 'varchar';
     $this->_field->label = 'LBL_' . strtoupper($this->_customFieldName);
     $this->_field->len = 255;
     $this->_field->required = 0;
     $this->_field->default_value = '';
     $this->_field->date_modified = '2012-03-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;
     $className = $beanList[$this->_moduleName];
     require_once $beanFiles[$className];
     $this->_module = new $className();
     $this->_df = new DynamicField($this->_moduleName);
     $this->_df->setup($this->_module);
     $this->_df->addFieldObject($this->_field);
 }
예제 #24
0
            if ($col != 'id_c') {
                if (trim($the_field->get_db_type()) != trim($type)) {
                    echo "Fixing Column Type for {$col} changing {$type} to " . $the_field->get_db_type() . "<br>";
                    if (!$simulate) {
                        $db->query($the_field->get_db_modify_alter_table($mod->table_name . '_cstm'));
                    }
                }
            }
            unset($fields[$col]);
        }
    }
    echo sizeof($fields) . " field(s) missing from {$mod->table_name}" . "_cstm<br>";
    foreach ($fields as $field) {
        echo "Adding Column {$field} to {$mod->table_name}" . "_cstm<br>";
        if (!$simulate) {
            $the_field = $mod->getFieldDefinition($field);
            $field = get_widget($the_field['type']);
            $field->set($the_field);
            $query = $field->get_db_add_alter_table($mod->table_name . '_cstm');
            echo $query;
            if (!empty($query)) {
                $mod->db->query($query);
            }
        }
    }
}
DynamicField::deleteCache();
echo '<br>Done<br>';
if ($simulate) {
    echo '<a href="index.php?module=Administration&action=UpgradeFields&run=true">Execute non-simulation mode</a>';
}
예제 #25
0
     break;
 case 'list_history':
     //get_header($title);
     $table_id = get_isset($_GET['table_id']);
     $check_table = check_table($table_id);
     if ($check_table > 0) {
         $query_history = select_history($table_id);
         include '../views/transaction/history_order.php';
     }
     //get_footer();
     break;
 case 'form_widget':
     $menu_id = $_GET['menu_id'];
     $jumlah = $_GET['jumlah'];
     $table_id = $_GET['table_id'];
     $get_widget = get_widget($menu_id, $table_id);
     if ($jumlah == 0) {
         delete_config("widget_tmp", "menu_id = '{$menu_id}' and user_id = '" . $_SESSION['user_id'] . "' and table_id = '{$table_id}'");
     } else {
         if ($get_widget == 0) {
             $data = "'',\n\t\t\t\t\t\t'" . $_SESSION['user_id'] . "',\n\t\t\t\t\t\t'{$menu_id}',\n\t\t\t\t\t\t'{$jumlah}',\n\t\t\t\t\t\t'{$table_id}',\n\t\t\t\t\t\t'',\n\t\t\t\t\t\t'0'\n\t\t\t\t\t\t\t";
             create_config("widget_tmp", $data);
         } else {
             $data = "jumlah = '{$jumlah}'\n\t\t\t\t\t\t\t\t\t\t";
             update_config2("widget_tmp", $data, "menu_id = '{$menu_id}' and user_id = '" . $_SESSION['user_id'] . "' and table_id = '{$table_id}'");
         }
     }
     include '../views/transaction/widget.php';
     break;
 case 'delete_widget':
     $id = get_isset($_GET['id']);
예제 #26
0
 function install_custom_fields($fields)
 {
     global $beanList, $beanFiles;
     include 'include/modules.php';
     require_once 'modules/DynamicFields/FieldCases.php';
     foreach ($fields as $field) {
         $installed = false;
         if (isset($beanList[$field['module']])) {
             $class = $beanList[$field['module']];
             if (!isset($field['ext4'])) {
                 $field['ext4'] = '';
             }
             if (!isset($field['mass_update'])) {
                 $field['mass_update'] = 0;
             }
             if (!isset($field['duplicate_merge'])) {
                 $field['duplicate_merge'] = 0;
             }
             if (!isset($field['help'])) {
                 $field['help'] = '';
             }
             //Merge contents of the sugar field extension if we copied one over
             if (file_exists("custom/Extension/modules/{$field['module']}/Ext/Vardefs/sugarfield_{$field['name']}.php")) {
                 $dictionary = array();
                 include "custom/Extension/modules/{$field['module']}/Ext/Vardefs/sugarfield_{$field['name']}.php";
                 $obj = BeanFactory::getObjectName($field['module']);
                 if (!empty($dictionary[$obj]['fields'][$field['name']])) {
                     $field = array_merge($dictionary[$obj]['fields'][$field['name']], $field);
                 }
             }
             if (file_exists($beanFiles[$class])) {
                 require_once $beanFiles[$class];
                 $mod = new $class();
                 $installed = true;
                 $fieldObject = get_widget($field['type']);
                 $fieldObject->populateFromRow($field);
                 $mod->custom_fields->use_existing_labels = true;
                 $mod->custom_fields->addFieldObject($fieldObject);
             }
         }
         if (!$installed) {
             $GLOBALS['log']->debug('Could not install custom field ' . $field['name'] . ' for module ' . $field['module'] . ': Module does not exist');
         }
     }
 }
예제 #27
0
<?php

if (count($this->ttBottomWidgets) < 0) {
    foreach ($this->ttBottomWidgets as $w) {
        get_widget('bottom', $w['TITLE'], $w['CONTENT'], $w['TYPE']);
    }
}
예제 #28
0
 function action_DeleteField()
 {
     require_once 'modules/DynamicFields/FieldCases.php';
     $field = get_widget($_POST['type']);
     $field->name = $_REQUEST['name'];
     if (!isset($_REQUEST['view_package'])) {
         if (!empty($_REQUEST['name']) && !empty($_REQUEST['view_module'])) {
             require_once 'modules/DynamicFields/DynamicField.php';
             $moduleName = $_REQUEST['view_module'];
             $class_name = $GLOBALS['beanList'][$moduleName];
             require_once $GLOBALS['beanFiles'][$class_name];
             $seed = new $class_name();
             $df = new DynamicField($moduleName);
             $df->setup($seed);
             //Need to load the entire field_meta_data for some field types
             $field = $df->getFieldWidget($moduleName, $field->name);
             $field->delete($df);
             require_once 'modules/ModuleBuilder/Module/StudioModule.php';
             $module = new StudioModule($moduleName);
         }
     } else {
         $mb = new ModuleBuilder();
         $module =& $mb->getPackageModule($_REQUEST['view_package'], $_REQUEST['view_module']);
         $field->delete($module);
         $mb->save();
     }
     $module->removeFieldFromLayouts($field->name);
     $this->view = 'modulefields';
 }
예제 #29
0
 /**
  * Returns a TemplateField object by name
  * Returns a TemplateField object by name or null if field not exists. If type not set use text type as default
  *
  * @param string $name
  * @return TemplateField|null
  *
  */
 public function getField($name)
 {
     $field = null;
     $varDefs = $this->getVardefs();
     if (isset($varDefs['fields'][$name])) {
         $fieldVarDefs = $varDefs['fields'][$name];
         if (!isset($fieldVarDefs['type'])) {
             $fieldVarDefs['type'] = 'varchar';
         }
         $field = get_widget($fieldVarDefs['type']);
         foreach ($fieldVarDefs as $key => $opt) {
             $field->{$key} = $opt;
         }
     }
     return $field;
 }
예제 #30
0
 function action_DeleteField()
 {
     require_once 'modules/DynamicFields/FieldCases.php';
     $field = get_widget($_REQUEST['type']);
     $field->name = $_REQUEST['name'];
     if (!isset($_REQUEST['view_package'])) {
         if (!empty($_REQUEST['name']) && !empty($_REQUEST['view_module'])) {
             require_once 'modules/DynamicFields/DynamicField.php';
             $moduleName = $_REQUEST['view_module'];
             // bug 51325 make sure we make this switch or delete will not work
             if ($moduleName == 'Employees') {
                 $moduleName = 'Users';
             }
             $class_name = $GLOBALS['beanList'][$moduleName];
             require_once $GLOBALS['beanFiles'][$class_name];
             $seed = new $class_name();
             $df = new DynamicField($moduleName);
             $df->setup($seed);
             //Need to load the entire field_meta_data for some field types
             $field = $df->getFieldWidget($moduleName, $field->name);
             $field->delete($df);
             $GLOBALS['mod_strings']['LBL_ALL_MODULES'] = 'all_modules';
             $_REQUEST['execute_sql'] = true;
             include_once 'modules/Administration/QuickRepairAndRebuild.php';
             $repair = new RepairAndClear();
             $repair->repairAndClearAll(array('rebuildExtensions', 'clearVardefs', 'clearTpls'), array($class_name), true, false);
             require_once 'modules/ModuleBuilder/Module/StudioModuleFactory.php';
             $module = StudioModuleFactory::getStudioModule($moduleName);
         }
     } else {
         $mb = new ModuleBuilder();
         $module =& $mb->getPackageModule($_REQUEST['view_package'], $_REQUEST['view_module']);
         $field = $module->getField($field->name);
         $field->delete($module);
         $mb->save();
     }
     $module->removeFieldFromLayouts($field->name);
     $this->view = 'modulefields';
     if (isset($GLOBALS['current_language']) && isset($_REQUEST['label']) && isset($_REQUEST['labelValue']) && isset($_REQUEST['view_module'])) {
         $this->DeleteLabel($GLOBALS['current_language'], $_REQUEST['label'], $_REQUEST['labelValue'], $_REQUEST['view_module']);
     }
 }