public function tearDown() { $mbc = new ModuleBuilderController(); $this->currencyFieldDef1['name'] = 'c1_c'; $_REQUEST = $this->currencyFieldDef1; $mbc->action_DeleteField(); $this->currencyFieldDef2['name'] = 'c2_c'; $_REQUEST = $this->currencyFieldDef2; $mbc->action_DeleteField(); SugarTestUserUtilities::removeAllCreatedAnonymousUsers(); unset($GLOBALS['current_user']); unset($GLOBALS['beanList']); unset($GLOBALS['beanFiles']); unset($GLOBALS['app_list_strings']); unset($_REQUEST); }
/** * Test tries to assert that field is not exist after removal it from subpanel * * @group 46196 */ public function testRemoveCustomFieldFromSubpanelForCustomRelation() { $controller = new ModuleBuilderController(); $module_name = 'Accounts'; $_REQUEST['view_module'] = $module_name; $test_field_name = 'testfield_222222'; $_REQUEST['name'] = $test_field_name; $_REQUEST['labelValue'] = 'testfield 222222'; $_REQUEST['label'] = 'LBL_TESTFIELD_222222'; $_REQUEST['type'] = 'varchar'; $controller->action_SaveField(); $_REQUEST['view_module'] = $module_name; $_REQUEST['relationship_type'] = 'many-to-many'; $_REQUEST['lhs_module'] = $module_name; $_REQUEST['lhs_label'] = $module_name; $_REQUEST['rhs_module'] = $module_name; $_REQUEST['rhs_label'] = $module_name; $_REQUEST['lhs_subpanel'] = 'default'; $_REQUEST['rhs_subpanel'] = 'default'; $controller->action_SaveRelationship(); $parser = ParserFactory::getParser('listview', $module_name, null, 'accounts_accounts'); $field = $parser->_fielddefs[$test_field_name . '_c']; $parser->_viewdefs[$test_field_name . '_c'] = $field; $parser->handleSave(false); $_REQUEST['type'] = 'varchar'; $_REQUEST['name'] = $test_field_name . '_c'; $controller->action_DeleteField(); $parser = ParserFactory::getParser('listview', $module_name, null, 'accounts_accounts'); $_REQUEST['relationship_name'] = 'accounts_accounts'; $controller->action_DeleteRelationship(); $this->assertArrayNotHasKey($test_field_name . '_c', $parser->_viewdefs); }
public function setUp() { $this->markTestIncomplete("This test breaks others tests on 644 on CI. Disabling for sanity check"); $GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']); $beanList = array(); $beanFiles = array(); require 'include/modules.php'; $GLOBALS['beanList'] = $beanList; $GLOBALS['beanFiles'] = $beanFiles; $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser(true, 1); $mbc = new ModuleBuilderController(); //Create the new Fields $_REQUEST = $this->currencyFieldDef1; $mbc->action_SaveField(); $_REQUEST = $this->currencyFieldDef2; $mbc->action_SaveField(); }
public function setUp() { $this->markTestIncomplete('causes all sorts of damage downhill'); $GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']); $beanList = array(); $beanFiles = array(); require 'include/modules.php'; $GLOBALS['beanList'] = $beanList; $GLOBALS['beanFiles'] = $beanFiles; $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser(); $GLOBALS['current_user']->is_admin = 1; $mbc = new ModuleBuilderController(); //Create the new Fields $_REQUEST = $this->dateFieldDef; $mbc->action_SaveField(); $_REQUEST = $this->extraFieldDef; $mbc->action_SaveField(); }
/** * Test checks if currency_id field was deleted with the lasr currency field * @group 50768 */ public function testSettedCurrencyIdField() { $mbc = new ModuleBuilderController(); //Create the new Fields $_REQUEST = $this->currencyFieldDef1; $mbc->action_SaveField(); $_REQUEST = $this->currencyFieldDef2; $mbc->action_SaveField(); $this->currencyFieldDef1['name'] = 'c1_c'; $_REQUEST = $this->currencyFieldDef1; // $mbc->action_DeleteField(); $this->currencyFieldDef2['name'] = 'c2_c'; $_REQUEST = $this->currencyFieldDef2; // $mbc->action_DeleteField(); $count = 0; $query = "SELECT * FROM fields_meta_data WHERE custom_module='Accounts' AND type='currency_id' AND deleted = 0"; $result = $GLOBALS['db']->query($query); while ($row = $GLOBALS['db']->fetchByAssoc($result)) { $count++; } $this->assertEquals($count, 0); }
/** * @see SugarView::_getModuleTitleParams() */ protected function _getModuleTitleParams($browserTitle = false) { global $mod_strings; return array(translate('LBL_MODULE_NAME', 'Administration'), ModuleBuilderController::getModuleTitle()); }
function set_custom_field($session, $module_name, $type, $properties, $add_to_layout) { global $current_user; global $beanList, $beanFiles; global $custom_field_meta; $error = new SoapError(); $request_arr = array('action' => 'SaveField', 'is_update' => 'true', 'module' => 'ModuleBuilder', 'view_module' => $module_name, 'view_package' => 'studio'); // ERROR CHECKING if (!validate_authenticated($session)) { $error->set_error('invalid_login'); return $error->get_soap_array(); } if (!is_admin($current_user)) { $error->set_error('no_admin'); return $error->get_soap_array(); } if (empty($beanList[$module_name])) { $error->set_error('no_module'); return $error->get_soap_array(); } if (empty($custom_field_meta[$type])) { $error->set_error('custom_field_type_not_supported'); return $error->get_soap_array(); } $new_properties = array(); foreach ($properties as $value) { $new_properties[$value['name']] = $value['value']; } foreach ($custom_field_meta[$type] as $property) { if (!isset($new_properties[$property])) { $error->set_error('custom_field_property_not_supplied'); return $error->get_soap_array(); } $request_arr[$property] = $new_properties[$property]; } // $request_arr should now contain all the necessary information to create a custom field // merge $request_arr with $_POST/$_REQUEST, where the action_saveField() method expects them $_REQUEST = array_merge($_REQUEST, $request_arr); $_POST = array_merge($_POST, $request_arr); require_once 'modules/ModuleBuilder/controller.php'; require_once 'modules/ModuleBuilder/parsers/ParserFactory.php'; $mbc = new ModuleBuilderController(); $mbc->setup(); $mbc->action_SaveField(); // add the field to the given module's EditView and DetailView layouts if ($add_to_layout == 1) { $layout_properties = array('name' => $new_properties['name'], 'label' => $new_properties['label']); if (isset($new_properties['customCode'])) { $layout_properties['customCode'] = $new_properties['customCode']; } if (isset($new_properties['customLabel'])) { $layout_properties['customLabel'] = $new_properties['customLabel']; } // add the field to the DetailView $parser = ParserFactory::getParser('layoutview', FALSE); $parser->init($module_name, 'DetailView', FALSE); $parser->_addField($layout_properties); $parser->writeWorkingFile(); $parser->handleSave(); unset($parser); // add the field to the EditView $parser = ParserFactory::getParser('layoutview', FALSE); $parser->init($module_name, 'EditView', FALSE); $parser->_addField($layout_properties); $parser->writeWorkingFile(); $parser->handleSave(); } return $error->get_soap_array(); }
/** * testActionBasicSearchViewSave * This method tests to ensure that custom SearchFields are created or updated when a search layout change is made */ public function testActionBasicSearchViewSave() { require_once 'modules/ModuleBuilder/controller.php'; $mbController = new ModuleBuilderController(); $_REQUEST['view_module'] = 'Cases'; $_REQUEST['view'] = 'basic_search'; $mbController->action_searchViewSave(); $this->assertTrue(file_exists('custom/modules/Cases/metadata/SearchFields.php')); require 'custom/modules/Cases/metadata/SearchFields.php'; $this->assertTrue(isset($searchFields['Cases']['range_date_entered'])); $this->assertTrue(isset($searchFields['Cases']['range_date_entered']['enable_range_search'])); $this->assertTrue(isset($searchFields['Cases']['range_date_modified'])); $this->assertTrue(isset($searchFields['Cases']['range_date_modified']['enable_range_search'])); }
/** * @group 51172 * Check that the label custom fields of Employees module was saved also for Users module * * @return void */ public function testSaveLabelForCustomFields() { $_REQUEST = $this->getRequestData(); $mb = new ModuleBuilderController(); $mb->action_SaveLabel(); $mod_strings = return_module_language($GLOBALS['current_language'], $this->add_module); //assert that array $mod_strings Users module contains current label $this->assertArrayHasKey($_REQUEST['label'], $mod_strings); }