/** * This checks to see if the only thing that has changed is the quota, if it is, then don't update the date * modified * * @param ForecastManagerWorksheet $worksheet The Bean * @param string $event Which event is being fired * @param array $params Extra Params */ public static function draftRecordQuotaOnlyCheck(ForecastManagerWorksheet $worksheet, $event, $params = array()) { // this should only run on before_save and when the worksheet is a draft record // and the draft_save_type is assign_quota if ($event == 'before_save' && $worksheet->draft == 1 && $worksheet->draft_save_type == 'assign_quota') { $mm = MetadataManager::getManager(); $views = $mm->getModuleViews($worksheet->module_name); $fields = $views['list']['meta']['panels'][0]['fields']; $onlyQuotaChanged = true; foreach ($fields as $field) { if ($field['type'] == 'currency' && preg_match('#\\.[\\d]{6}$#', $worksheet->{$field}['name']) === 0) { $worksheet->{$field}['name'] = SugarMath::init($worksheet->{$field}['name'], 6)->result(); } if ($worksheet->fetched_row[$field['name']] !== $worksheet->{$field}['name']) { if ($field['name'] !== 'quota') { $onlyQuotaChanged = false; break; } } } if ($onlyQuotaChanged === true) { $worksheet->update_date_modified = false; } } }
protected function _validPerform($request, $response) { $datasource = Limb::toolkit()->getDatasource('RequestedObjectDatasource'); $datasource->setRequest($request); $object_data = $datasource->fetch(); MetadataManager::saveMetadata($object_data['id'], $this->dataspace->get('keywords'), $this->dataspace->get('description')); $request->setStatus(Request::STATUS_FORM_SUBMITTED); }
function testSave() { $result_id = MetadataManager::saveMetadata(1, 'keywords', 'description'); $this->assertNotNull($result_id); $sys_metadata_db_table = DbTableFactory::create('SysMetadata'); $metadata_row = $sys_metadata_db_table->getRowById($result_id); $this->assertTrue(is_array($metadata_row)); $this->assertTrue(isset($metadata_row['object_id'])); $this->assertTrue(isset($metadata_row['keywords'])); $this->assertTrue(isset($metadata_row['description'])); $this->assertEqual($metadata_row['object_id'], 1); $this->assertEqual($metadata_row['keywords'], 'keywords'); $this->assertEqual($metadata_row['description'], 'description'); }
function action_Save() { require_once 'include/OutboundEmail/OutboundEmail.php'; require_once 'modules/Configurator/Configurator.php'; $configurator = new Configurator(); global $sugar_config; global $current_user, $mod_strings; if (!is_admin($current_user) && !is_admin_for_module($GLOBALS['current_user'], 'Emails') && !is_admin_for_module($GLOBALS['current_user'], 'Campaigns')) { sugar_die($mod_strings['LBL_UNAUTH_ACCESS']); } //Do not allow users to spoof for sendmail if the config flag is not set. if (!isset($sugar_config['allow_sendmail_outbound']) || !$sugar_config['allow_sendmail_outbound']) { $_REQUEST['mail_sendtype'] = "SMTP"; } // save Outbound settings #Bug 20033 Ensure data for Outbound email exists before trying to update the system mailer. if (isset($_REQUEST['mail_sendtype']) && empty($_REQUEST['campaignConfig'])) { $oe = new OutboundEmail(); $oe->populateFromPost(); $oe->saveSystem(); } $focus = BeanFactory::getBean('Administration'); if (isset($_POST['tracking_entities_location_type'])) { if ($_POST['tracking_entities_location_type'] != '2') { unset($_POST['tracking_entities_location']); unset($_POST['tracking_entities_location_type']); } } // cn: handle mail_smtpauth_req checkbox on/off (removing double reference in the form itself if (!isset($_POST['mail_smtpauth_req'])) { $_POST['mail_smtpauth_req'] = 0; if (empty($_POST['campaignConfig'])) { $_POST['notify_allow_default_outbound'] = 0; // If smtp auth is disabled ensure outbound is disabled. } } $focus->saveConfig(); // mark user metadata changed so the user preferences get refreshed // (user preferences contain email client preference) $mm = MetadataManager::getManager(); $mm->setUserMetadataHasChanged($current_user); // save User defaults for emails $configurator->config['email_default_delete_attachments'] = isset($_REQUEST['email_default_delete_attachments']) ? true : false; /////////////////////////////////////////////////////////////////////////////// //// SECURITY $security = array(); if (isset($_REQUEST['applet'])) { $security['applet'] = 'applet'; } if (isset($_REQUEST['base'])) { $security['base'] = 'base'; } if (isset($_REQUEST['embed'])) { $security['embed'] = 'embed'; } if (isset($_REQUEST['form'])) { $security['form'] = 'form'; } if (isset($_REQUEST['frame'])) { $security['frame'] = 'frame'; } if (isset($_REQUEST['frameset'])) { $security['frameset'] = 'frameset'; } if (isset($_REQUEST['iframe'])) { $security['iframe'] = 'iframe'; } if (isset($_REQUEST['import'])) { $security['import'] = '\\?import'; } if (isset($_REQUEST['layer'])) { $security['layer'] = 'layer'; } if (isset($_REQUEST['link'])) { $security['link'] = 'link'; } if (isset($_REQUEST['object'])) { $security['object'] = 'object'; } if (isset($_REQUEST['style'])) { $security['style'] = 'style'; } if (isset($_REQUEST['xmp'])) { $security['xmp'] = 'xmp'; } $security['script'] = 'script'; $configurator->config['email_xss'] = base64_encode(serialize($security)); //// SECURITY /////////////////////////////////////////////////////////////////////////////// ksort($sugar_config); $configurator->handleOverride(); }
/** * In using the config, the only values that should be stored are one that are for registered platforms. * * As such if the passed in platform is not registered, then it will return `base` * * @param string $platform The Platfrom from $api->platform * @return string */ protected function getPlatform($platform) { // if the platform is not a valid registered platform, default it back to base $platforms = MetadataManager::getPlatformList(); if (!in_array($platform, $platforms)) { $platform = 'base'; } return $platform; }
public function setWorksheetColumns($platform, $worksheetColumns, $forecastBy) { if (!is_array($worksheetColumns)) { return false; } SugarAutoLoader::load('modules/ModuleBuilder/parsers/ParserFactory.php'); $listDefsParser = ParserFactory::getParser(MB_LISTVIEW, 'ForecastWorksheets', null, null, $platform); $listDefsParser->resetPanelFields(); // get the proper order from the admin panel, where we defined what is displayed, in the order that we want it $mm = MetadataManager::getManager(); $views = $mm->getModuleViews('Forecasts'); $fields = $views['config-worksheet-columns']['meta']['panels'][0]['fields']; /* @var $forecastWorksheet ForecastWorksheet */ $forecastWorksheet = BeanFactory::getBean('ForecastWorksheets'); // sort the fields correctly usort($fields, function ($a, $b) { if ($a['order'] === $b['order']) { return 0; } return $a['order'] < $b['order'] ? -1 : 1; }); $cteable = array('commit_stage', 'worst_case', 'likely_case', 'best_case', 'date_closed', 'sales_stage'); $currency_fields = array('worst_case', 'likely_case', 'best_case', 'list_price', 'cost_price', 'discount_price', 'discount_amount', 'total_amount'); foreach ($fields as $field) { if (!in_array($field['name'], $worksheetColumns)) { continue; } $column = $field['name']; $additionalDefs = array(); // set the label for the parent_name field, depending on what we are forecasting by if ($column == 'parent_name') { $label = $forecastBy == 'Opportunities' ? 'LBL_OPPORTUNITY_NAME' : 'LBL_REVENUELINEITEM_NAME'; $additionalDefs = array_merge($additionalDefs, array('label' => $label)); } if (in_array($column, $cteable)) { $additionalDefs = array_merge($additionalDefs, array('click_to_edit' => true)); } if (in_array($column, $currency_fields)) { $additionalDefs = array_merge($additionalDefs, array('convertToBase' => true, 'showTransactionalAmount' => true)); } // make sure sortable matches what is in the vardefs $fieldVarDefs = $forecastWorksheet->getFieldDefinition($column); if (isset($fieldVarDefs['sortable'])) { $additionalDefs['sortable'] = $fieldVarDefs['sortable']; } $listDefsParser->addField($column, $additionalDefs); } // save the file, but we don't need to load the the $_REQUEST, so pass false $listDefsParser->handleSave(false); }
/** * Add and Remove fields from all the list views * * @param array $fieldMap How are we going to change the fields * @return array The Modules which had their subpanels affected */ public function processListViews(array $fieldMap) { // get the views for the module $mm = MetadataManager::getManager(); $views = $mm->getModuleViews('Opportunities'); // fix the selected-list view $this->processSelectedListView($fieldMap); // fix the dupecheck-list view $this->processDupeCheckListView($fieldMap); // get the generic list view $this->processListView($fieldMap); // get the mobile list view now $this->processMobileListView($fieldMap); $subpanel_modules = array('Opportunities'); $links = $this->bean->get_linked_fields(); foreach ($links as $link => $def) { if ($this->bean->load_relationship($link) && $this->bean->{$link} instanceof Link2) { $linkname = $this->bean->{$link}->getRelatedModuleLinkName(); if (!empty($linkname)) { $this->processListView($fieldMap, $this->bean->{$link}->getRelatedModuleName(), $linkname); $subpanel_modules[] = $this->bean->{$link}->getRelatedModuleName(); } } } return $subpanel_modules; }