public function configSave(ServiceBase $api, $args)
 {
     $module = 'dm_Duplicates';
     unset($args['__sugar_url']);
     //acl check, only allow if they are module admin
     if (!$api->user->isAdmin() && !$api->user->isDeveloperForModule($module)) {
         // No create access so we construct an error message and throw the exception
         $failed_module_strings = return_module_language($GLOBALS['current_language'], $module);
         $moduleName = $failed_module_strings['LBL_MODULE_NAME'];
         $args = null;
         if (!empty($moduleName)) {
             $args = array('moduleName' => $moduleName);
         }
         throw new SugarApiExceptionNotAuthorized($GLOBALS['app_strings']['EXCEPTION_CHANGE_MODULE_CONFIG_NOT_AUTHORIZED'], $args);
     }
     $admin = BeanFactory::getBean('Administration');
     $platform = 'base';
     foreach ($args as $name => $value) {
         if (is_array($value)) {
             $admin->saveSetting($module, $name, json_encode($value), $platform);
         } else {
             $admin->saveSetting($module, $name, $value, $platform);
         }
     }
     if ($this->skipMetadataRefresh === false) {
         MetaDataManager::refreshModulesCache(array($module));
     }
     return $admin->getConfigForModule($module, $platform, true);
 }
Esempio n. 2
0
 /**
  * This function allows a user with Forecasts admin rights to reset the Forecasts settings so that the Forecasts wizard
  * dialog will appear once again.
  *
  */
 public function action_resetSettings()
 {
     global $current_user;
     if ($current_user->isAdminForModule('Forecasts')) {
         $db = DBManagerFactory::getInstance();
         $db->query("UPDATE config SET value = '0' WHERE category = 'Forecasts' and name in ('is_setup', 'has_commits')");
         MetaDataManager::refreshModulesCache(array('Forecasts'));
         MetaDataManager::refreshSectionCache(array(MetaDataManager::MM_CONFIG));
         echo '<script>' . navigateToSidecar(buildSidecarRoute("Forecasts")) . ';</script>';
         exit;
     }
     $this->view = 'noaccess';
 }
Esempio n. 3
0
 function __construct()
 {
     parent::SugarView();
     global $current_user;
     if (!$current_user->isDeveloperForModule("Leads")) {
         die("Unauthorized Access to Administration");
     }
     $this->jsonHelper = getJSONobj();
     $this->parser = new ConvertLayoutMetadataParser("Contacts");
     if (isset($_REQUEST['updateConvertDef']) && $_REQUEST['updateConvertDef'] && !empty($_REQUEST['data'])) {
         $this->parser->updateConvertDef(object_to_array_recursive($this->jsonHelper->decode(html_entity_decode_utf8($_REQUEST['data']))));
         // clear the cache for this module only
         MetaDataManager::refreshModulesCache(array('Leads'));
     }
 }
Esempio n. 4
0
 /**
  * Save the Individual Worksheet
  *
  * @return ForecastWorksheet
  * @throws SugarApiException
  */
 public function save()
 {
     require_once 'include/SugarFields/SugarFieldHandler.php';
     /* @var $seed ForecastWorksheet */
     $seed = BeanFactory::getBean("ForecastWorksheets");
     $seed->loadFromRow($this->args);
     $sfh = new SugarFieldHandler();
     foreach ($seed->field_defs as $properties) {
         $fieldName = $properties['name'];
         if (!isset($this->args[$fieldName])) {
             continue;
         }
         if (!$seed->ACLFieldAccess($fieldName, 'save')) {
             // No write access to this field, but they tried to edit it
             global $app_strings;
             throw new SugarApiException(string_format($app_strings['SUGAR_API_EXCEPTION_NOT_AUTHORIZED'], array($fieldName, $this->args['module'])));
         }
         $type = !empty($properties['custom_type']) ? $properties['custom_type'] : $properties['type'];
         $field = $sfh->getSugarField($type);
         if (!is_null($field)) {
             $field->save($seed, $this->args, $fieldName, $properties);
         }
     }
     // Check if this is the first commit, then save has_commits true to the config table
     $admin = BeanFactory::getBean('Administration');
     $settings = $admin->getConfigForModule('Forecasts');
     if (!isset($settings['has_commits']) || !$settings['has_commits']) {
         $admin->saveSetting('Forecasts', 'has_commits', true, 'base');
         MetaDataManager::refreshModulesCache(array('Forecasts'));
     }
     $seed->setWorksheetArgs($this->args);
     // we need to set the parent_type and parent_id so it finds it when we try and retrieve the old records
     $seed->parent_type = $this->getArg('parent_type');
     $seed->parent_id = $this->getArg('parent_id');
     $seed->saveWorksheet();
     // we have the id, just retrieve the record again
     $seed = BeanFactory::getBean("ForecastWorksheets", $this->getArg('record'));
     return $seed;
 }
Esempio n. 5
0
 /**
  * @param Administration $admin
  * @param array $forecastsSettings
  * @param RestService $api
  * @throws SugarApiExceptionInvalidHash
  */
 protected function compareSettingsToDefaults(Administration $admin, $forecastsSettings, $api)
 {
     $defaultConfig = ForecastsDefaults::getDefaults();
     $missing_config = array_diff(array_keys($defaultConfig), array_keys($forecastsSettings));
     if (!empty($missing_config)) {
         foreach ($missing_config as $config) {
             $val = $defaultConfig[$config];
             if (is_array($val)) {
                 $val = json_encode($val);
             }
             $admin->saveSetting('Forecasts', $config, $val, $api->platform);
         }
         MetaDataManager::refreshModulesCache(array("Forecasts"));
         MetaDataManager::refreshSectionCache(array(MetaDataManager::MM_CONFIG));
         throw new SugarApiExceptionInvalidHash();
     }
 }
Esempio n. 6
0
 /**
  * Save any committed values
  *
  * @return array|mixed
  */
 public function save()
 {
     global $current_user;
     $args = $this->getArgs();
     $db = DBManagerFactory::getInstance();
     if (!isset($args['timeperiod_id']) || empty($args['timeperiod_id'])) {
         $args['timeperiod_id'] = TimePeriod::getCurrentId();
     }
     $commit_type = strtolower($this->getArg('commit_type'));
     /* @var $mgr_worksheet ForecastManagerWorksheet */
     $mgr_worksheet = BeanFactory::getBean('ForecastManagerWorksheets');
     /* @var $worksheet ForecastWorksheet */
     $worksheet = BeanFactory::getBean('ForecastWorksheets');
     $field_ext = '_case';
     if ($commit_type == "manager") {
         $worksheet_totals = $mgr_worksheet->worksheetTotals($current_user->id, $args['timeperiod_id']);
         // we don't need the *_case values so lets make them the same as the *_adjusted values
         $field_ext = '_adjusted';
     } else {
         $worksheet_totals = $worksheet->worksheetTotals($args['timeperiod_id'], $current_user->id);
         // set likely
         $worksheet_totals['likely_case'] = SugarMath::init($worksheet_totals['amount'], 6)->add($worksheet_totals['includedClosedAmount'])->result();
         $worksheet_totals['best_case'] = SugarMath::init($worksheet_totals['best_case'], 6)->add($worksheet_totals['includedClosedBest'])->result();
         $worksheet_totals['worst_case'] = SugarMath::init($worksheet_totals['worst_case'], 6)->add($worksheet_totals['includedClosedWorst'])->result();
     }
     /* @var $forecast Forecast */
     $forecast = BeanFactory::getBean('Forecasts');
     $forecast->user_id = $current_user->id;
     $forecast->timeperiod_id = $args['timeperiod_id'];
     $forecast->best_case = $worksheet_totals['best' . $field_ext];
     $forecast->likely_case = $worksheet_totals['likely' . $field_ext];
     $forecast->worst_case = $worksheet_totals['worst' . $field_ext];
     $forecast->forecast_type = $args['forecast_type'];
     $forecast->opp_count = $worksheet_totals['included_opp_count'];
     $forecast->currency_id = '-99';
     $forecast->base_rate = '1';
     //If we are committing a rep forecast, calculate things.  Otherwise, for a manager, just use what is passed in.
     if ($args['commit_type'] == 'sales_rep') {
         $forecast->calculatePipelineData($worksheet_totals['includedClosedAmount'], $worksheet_totals['includedClosedCount']);
         //push the pipeline numbers back into the args
         $args['pipeline_opp_count'] = $forecast->pipeline_opp_count;
         $args['pipeline_amount'] = $forecast->pipeline_amount;
         $worksheet_totals['closed_amount'] = $forecast->closed_amount;
     } else {
         $forecast->pipeline_opp_count = $worksheet_totals['pipeline_opp_count'];
         $forecast->pipeline_amount = $worksheet_totals['pipeline_amount'];
         $forecast->closed_amount = $worksheet_totals['closed_amount'];
     }
     if ($worksheet_totals['likely_case'] != 0 && $worksheet_totals['included_opp_count'] != 0) {
         $forecast->opp_weigh_value = $worksheet_totals['likely_case'] / $worksheet_totals['included_opp_count'];
     }
     $forecast->save();
     // roll up the committed forecast to that person manager view
     // copy the object so we can set some needed values
     $mgr_rollup_data = $worksheet_totals;
     $mgr_rollup_data['forecast_type'] = $args['forecast_type'];
     // pass same timeperiod as the other data to the manager's rollup
     $mgr_rollup_data['timeperiod_id'] = $args['timeperiod_id'];
     $mgr_worksheet->reporteeForecastRollUp($current_user, $mgr_rollup_data);
     if ($this->getArg('commit_type') == "sales_rep") {
         $worksheet->commitWorksheet($current_user->id, $args['timeperiod_id']);
     } elseif ($this->getArg('commit_type') == "manager") {
         $mgr_worksheet->commitManagerForecast($current_user, $args['timeperiod_id']);
     }
     //TODO-sfa remove this once the ability to map buckets when they get changed is implemented (SFA-215).
     $admin = BeanFactory::getBean('Administration');
     $settings = $admin->getConfigForModule('Forecasts');
     if (!isset($settings['has_commits']) || !$settings['has_commits']) {
         $admin->saveSetting('Forecasts', 'has_commits', true, 'base');
         MetaDataManager::refreshModulesCache(array('Forecasts'));
     }
     $forecast->date_entered = $this->convertDateTimeToISO($db->fromConvert($forecast->date_entered, 'datetime'));
     $forecast->date_modified = $this->convertDateTimeToISO($db->fromConvert($forecast->date_modified, 'datetime'));
     return $worksheet_totals;
 }
Esempio n. 7
0
 public function action_listViewSave()
 {
     $GLOBALS['log']->info("action_listViewSave");
     if (isset($_REQUEST['PORTAL'])) {
         $this->view = 'portallistview';
         $parser = ParserFactory::getParser($this->view, $_REQUEST['view_module'], null, null, MB_PORTAL);
         //$parser->init ( $_REQUEST [ 'view_module' ] ) ; // removed init because MetaDataParsers don't use it
     } else {
         $packageName = isset($_REQUEST['view_package']) && strtolower($_REQUEST['view_package']) != 'studio' ? $_REQUEST['view_package'] : null;
         $subpanelName = !empty($_REQUEST['subpanel']) ? $_REQUEST['subpanel'] : null;
         $parser = ParserFactory::getParser($_REQUEST['view'], $_REQUEST['view_module'], $packageName, $subpanelName);
         $this->view = 'listView';
         // To make sure that dashlets can render customized list views on BWC
         // modules, we need to save list customizations for BWC modules in
         // the new style as well.
         if (isModuleBWC($_REQUEST['view_module']) && empty($packageName) && empty($subpanelName)) {
             $sidecarListParser = new SidecarListLayoutMetaDataParser(MB_SIDECARLISTVIEW, $_REQUEST['view_module'], null, 'base');
             $sidecarListParser->handleSave();
         }
     }
     // for backwards compatibility we need to parse the subpanel the old way as well
     // TODO: Remove this when all BWC Modules are converted
     if ($parser instanceof SidecarSubpanelLayoutMetaDataParser) {
         require_once 'modules/ModuleBuilder/parsers/views/SubpanelMetaDataParser.php';
         $oldSubpanelParser = new SubpanelMetaDataParser($subpanelName, $_REQUEST['view_module'], $packageName);
         $oldSubpanelParser->handleSave();
         unset($oldSubpanelParser);
     }
     $parser->handleSave();
     if (empty($packageName) && !empty($subpanelName)) {
         $rr = new RepairAndClear();
         $rr->show_output = false;
         $rr->rebuildExtensions();
     }
     // clear the cache for the linked module and requested module
     MetaDataManager::refreshModulesCache($parser->getAffectedModules());
 }
 /**
  * Clears mobile and portal metadata caches that have been created by the API
  * to allow immediate rendering of changes at the client
  */
 protected function _clearCaches()
 {
     if ($this->implementation->isDeployed()) {
         MetaDataFiles::clearModuleClientCache($this->_moduleName, 'view');
         // Clear out the cache just for the platform we are on
         $client = empty($this->client) ? 'base' : $this->client;
         MetaDataManager::refreshModulesCache(array($this->_moduleName), array($client), $this->implementation->getParams());
         parent::_clearCaches();
     }
 }
Esempio n. 9
0
 /**
  * Update the metadata depending on what we are forecasting on
  *
  * @param String $forecast_by The Module that we are currently forecasting by
  */
 public function updateConfigWorksheetColumnsMetadata($forecast_by)
 {
     if ($forecast_by === 'RevenueLineItems') {
         $contents = "<?php\n\n";
         $key = "viewdefs['Forecasts']['base']['view']['config-worksheet-columns']['panels'][0]['fields']";
         foreach ($this->rli_worksheet_columns as $val) {
             $contents .= override_value_to_string_recursive2($key, $val['name'], $val, false);
         }
         sugar_file_put_contents($this->module_ext_path . DIRECTORY_SEPARATOR . $this->columns_ext_file, $contents);
     } else {
         if (SugarAutoLoader::fileExists($this->module_ext_path . DIRECTORY_SEPARATOR . $this->columns_ext_file)) {
             SugarAutoLoader::unlink($this->module_ext_path . DIRECTORY_SEPARATOR . $this->columns_ext_file);
         }
     }
     $this->runRebuildExtensions(array('Forecasts'));
     MetaDataManager::refreshModulesCache('Forecasts');
 }
 function build()
 {
     $modulesToBuild = array();
     if (!isset($this->relationships[$this->newRelationshipName])) {
         $GLOBALS['log']->fatal("Could not find a relationship by the name of {$this->newRelationshipName}, you will have to quick repair and rebuild to get the new relationship added.");
     } else {
         $newRel = $this->relationships[$this->newRelationshipName];
         $newRelDef = $newRel->getDefinition();
         $modulesToBuild[$newRelDef['rhs_module']] = true;
         $modulesToBuild[$newRelDef['lhs_module']] = true;
     }
     $basepath = "custom/Extension/modules";
     $this->activitiesToAdd = false;
     // and mark all as built so that the next time we come through we'll know and won't build again
     foreach ($this->relationships as $name => $relationship) {
         if ($relationship->readonly()) {
             continue;
         }
         $definition = $relationship->getDefinition();
         // activities will always appear on the rhs only - lhs will be always be this module in MB
         if (strtolower($definition['rhs_module']) == 'activities') {
             $this->activitiesToAdd = true;
             $relationshipName = $definition['relationship_name'];
             foreach (self::$activities as $activitiesSubModuleLower => $activitiesSubModuleName) {
                 $definition['rhs_module'] = $activitiesSubModuleName;
                 $definition['for_activities'] = true;
                 $definition['relationship_name'] = $relationshipName . '_' . $activitiesSubModuleLower;
                 $this->relationships[$definition['relationship_name']] = RelationshipFactory::newRelationship($definition);
             }
             unset($this->relationships[$name]);
         }
     }
     $GLOBALS['log']->info(get_class($this) . "->build(): installing relationships");
     $MBModStrings = $GLOBALS['mod_strings'];
     $adminModStrings = return_module_language('', 'Administration');
     // required by ModuleInstaller
     foreach ($this->relationships as $name => $relationship) {
         if ($relationship->readonly()) {
             continue;
         }
         $relationship->setFromStudio();
         $GLOBALS['mod_strings'] = $MBModStrings;
         $installDefs = parent::build($basepath, "<basepath>", array($name => $relationship));
         // and mark as built so that the next time we come through we'll know and won't build again
         $relationship->setReadonly();
         $this->relationships[$name] = $relationship;
         // now install the relationship - ModuleInstaller normally only does this as part of a package load where it installs the relationships defined in the manifest. However, we don't have a manifest or a package, so...
         // If we were to chose to just use the Extension mechanism, without using the ModuleInstaller install_...() methods, we must :
         // 1)   place the information for each side of the relationship in the appropriate Ext directory for the module, which means specific $this->save...() methods for DeployedRelationships, and
         // 2)   we must also manually add the relationship into the custom/application/Ext/TableDictionary/tabledictionary.ext.php file as install_relationship doesn't handle that (install_relationships which requires the manifest however does)
         //      Relationships must be in tabledictionary.ext.php for the Admin command Rebuild Relationships to reliably work:
         //      Rebuild Relationships looks for relationships in the modules vardefs.php, in custom/modules/<modulename>/Ext/vardefs/vardefs.ext.php, and in modules/TableDictionary.php and custom/application/Ext/TableDictionary/tabledictionary.ext.php
         //      if the relationship is not defined in one of those four places it could be deleted during a rebuilt, or during a module installation (when RebuildRelationships.php deletes all entries in the Relationships table)
         // So instead of doing this, we use common save...() methods between DeployedRelationships and UndeployedRelationships that will produce installDefs,
         // and rather than building a full manifest file to carry them, we manually add these installDefs to the ModuleInstaller, and then
         // individually call the appropriate ModuleInstaller->install_...() methods to take our relationship out of our staging area and expand it out to the individual module Ext areas
         $GLOBALS['mod_strings'] = $adminModStrings;
         require_once 'ModuleInstall/ModuleInstaller.php';
         $mi = new ModuleInstaller();
         $mi->id_name = 'custom' . $name;
         // provide the moduleinstaller with a unique name for this relationship - normally this value is set to the package key...
         $mi->installdefs = $installDefs;
         $mi->base_dir = $basepath;
         $mi->silent = true;
         VardefManager::clearVardef();
         $mi->install_relationships();
         $mi->install_languages();
         $mi->install_vardefs();
         $mi->install_layoutdefs();
         $mi->install_extensions();
         $mi->install_client_files();
     }
     $GLOBALS['mod_strings'] = $MBModStrings;
     // finally, restore the ModuleBuilder mod_strings
     // Anything that runs in-process needs to reload their vardefs
     $GLOBALS['reload_vardefs'] = true;
     // save out the updated definitions so that we keep track of the change in built status
     // sending false so we don't rebuild relationshsips for a third time.
     $this->save(false);
     $mi = new ModuleInstaller();
     $mi->silent = true;
     $mi->rebuild_relationships($modulesToBuild);
     // now clear all caches so that our changes are visible
     require_once 'modules/Administration/QuickRepairAndRebuild.php';
     $rac = new RepairAndClear();
     $rac->module_list = $modulesToBuild;
     $rac->clearJsFiles();
     $rac->clearVardefs();
     $rac->clearJsLangFiles();
     $rac->clearLanguageCache();
     $rac->rebuildExtensions(array_keys($modulesToBuild));
     $rac->clearVardefs();
     foreach ($rac->module_list as $moduleName => $ignore) {
         // Now rebuild the vardefs in memory
         $bean = BeanFactory::newBean($moduleName);
         VardefManager::loadVardef($bean->module_dir, $bean->object_name, true, array('bean' => $bean));
     }
     foreach (array_keys($modulesToBuild) as $module) {
         unset($GLOBALS['dictionary'][BeanFactory::getObjectName($module)]);
     }
     SugarRelationshipFactory::rebuildCache();
     MetaDataManager::refreshLanguagesCache(array($GLOBALS['current_language']));
     MetaDataManager::refreshSectionCache(array(MetaDataManager::MM_RELATIONSHIPS));
     MetaDataManager::refreshModulesCache(array_keys($modulesToBuild));
     $GLOBALS['log']->info(get_class($this) . "->build(): finished relationship installation");
 }
 /**
  * Clears mobile and portal metadata caches that have been created by the API
  * to allow immediate rendering of changes at the client
  */
 protected function _clearCaches()
 {
     if ($this->implementation->isDeployed()) {
         // Installing and trying to refresh the modules cache is bad juju
         if (!empty($GLOBALS['installing'])) {
             // Use the clear NOW method so that if there is a cache it is wiped
             MetaDataManager::clearAPICache(true, true);
         } else {
             MetaDataManager::refreshModulesCache(array($this->_moduleName));
         }
         parent::_clearCaches();
     }
 }
 public function deploy($defs)
 {
     // We are saving to the custom file
     $savefile = $this->getMetadataFilename(MB_CUSTOMMETADATALOCATION);
     // Simple validation and sanity checking
     if (!is_dir(dirname($savefile))) {
         if (!sugar_mkdir(dirname($savefile), null, true)) {
             throw new Exception("Cannot create directory for {$savefile}");
         }
     }
     // Handle history
     if ($this->loadedMetadataFile === MB_HISTORYMETADATALOCATION) {
         $types = array(MB_WORKINGMETADATALOCATION, MB_CUSTOMMETADATALOCATION, MB_BASEMETADATALOCATION);
         foreach ($types as $type) {
             $file = $this->getMetadataFilename($type);
             if (file_exists($file)) {
                 $this->_history->append($file);
                 break;
             }
         }
     } else {
         $this->_history->append($this->loadedMetadataFile);
     }
     $this->_viewdefs = $defs;
     // Now save the actual data
     write_array_to_file("viewdefs['{$this->_moduleName}']['{$this->_viewClient}']['filter']['default']", $this->_viewdefs, $savefile);
     // Delete the working file if exists as we do in DeployedMetaDataImplementation
     $workingFilename = $this->getMetadataFilename(MB_WORKINGMETADATALOCATION);
     if (file_exists($workingFilename)) {
         SugarAutoLoader::unlink($workingFilename);
     }
     // clear the cache for this module
     MetaDataManager::refreshModulesCache(array($this->_moduleName));
 }
 /**
  * Resets user specific metadata to default
  */
 public function resetToDefault()
 {
     if (count($this->params) > 0) {
         $fileName = $this->getFileNameNoDefault($this->_view, $this->_moduleName);
         if (file_exists($fileName)) {
             $this->saveHistory();
             SugarAutoLoader::unlink($fileName, true);
             MetaDataFiles::clearModuleClientCache($this->_moduleName, 'view');
             // Clear out the cache just for the platform we are on
             $client = empty($this->client) ? 'base' : $this->client;
             MetaDataManager::refreshModulesCache(array($this->_moduleName), array($client), $this->params);
         }
     }
 }
Esempio n. 14
0
 /**
  * Adds a custom field using a field object
  *
  * @param Field Object $field
  * @return boolean
  */
 public function addFieldObject(&$field)
 {
     $GLOBALS['log']->debug('adding field');
     $object_name = $this->module;
     $db_name = $field->name;
     $fmd = BeanFactory::getBean('EditCustomFields');
     $id = $fmd->retrieve($object_name . $db_name, true, false);
     $is_update = false;
     $label = strtoupper($field->label);
     if (!empty($id)) {
         $is_update = true;
     } else {
         $db_name = $this->getDBName($field->name);
         $field->name = $db_name;
     }
     $this->createCustomTable();
     $fmd->id = $object_name . $db_name;
     $fmd->custom_module = $object_name;
     $fmd->name = $db_name;
     $fmd->vname = $label;
     $fmd->type = $field->type;
     $fmd->help = $field->help;
     if (!empty($field->len)) {
         $fmd->len = $field->len;
     }
     // tyoung bug 15407 - was being set to $field->size so changes weren't being saved
     $fmd->required = $field->required ? 1 : 0;
     $fmd->default_value = $field->default;
     $fmd->ext1 = $field->ext1;
     $fmd->ext2 = $field->ext2;
     $fmd->ext3 = $field->ext3;
     $fmd->ext4 = isset($field->ext4) ? $field->ext4 : '';
     $fmd->comments = $field->comment;
     $fmd->massupdate = $field->massupdate;
     $fmd->importable = isset($field->importable) ? $field->importable : null;
     $fmd->duplicate_merge = $field->duplicate_merge;
     $fmd->audited = $field->audited;
     $fmd->reportable = $field->reportable ? 1 : 0;
     if (!$is_update) {
         $fmd->new_with_id = true;
     }
     if ($field) {
         if (!$is_update) {
             //Do two SQL calls here in this case
             //The first is to create the column in the custom table without the default value
             //The second is to modify the column created in the custom table to set the default value
             //We do this so that the existing entries in the custom table don't have the default value set
             $field->default = '';
             $field->default_value = '';
             // resetting default and default_value does not work for multienum and causes trouble for mssql
             // so using a temporary variable here to indicate that we don't want default for this query
             $field->no_default = 1;
             $query = $field->get_db_add_alter_table($this->bean->table_name . '_cstm');
             // unsetting temporary member variable
             unset($field->no_default);
             if (!empty($query)) {
                 $GLOBALS['db']->query($query, true, "Cannot create column");
                 $field->default = $fmd->default_value;
                 $field->default_value = $fmd->default_value;
                 $query = $field->get_db_modify_alter_table($this->bean->table_name . '_cstm');
                 if (!empty($query)) {
                     $GLOBALS['db']->query($query, true, "Cannot set default");
                 }
             }
         } else {
             $query = $field->get_db_modify_alter_table($this->bean->table_name . '_cstm');
             if (!empty($query)) {
                 $GLOBALS['db']->query($query, true, "Cannot modify field");
             }
         }
         $fmd->save();
         $this->buildCache($this->module);
         $this->saveExtendedAttributes($field, array_keys($fmd->field_defs));
         MetaDataManager::refreshModulesCache(array($this->module));
         MetaDataManager::refreshSectionCache(array(MetaDataManager::MM_LABELS, MetaDataManager::MM_ORDEREDLABELS));
     }
     return true;
 }
 /**
  * Cleans out current metadata cache and rebuilds it for
  * each platform and visibility
  */
 public function repairMetadataAPICache($section = '')
 {
     // Refresh metadata for selected modules only if there selected modules
     if (is_array($this->module_list) && !empty($this->module_list) && !in_array(translate('LBL_ALL_MODULES'), $this->module_list)) {
         MetaDataFiles::clearModuleClientCache($this->module_list);
         MetaDataManager::refreshModulesCache($this->module_list);
     }
     // If there is a section named (like 'fields') refresh that section
     if (!empty($section)) {
         MetaDataManager::refreshSectionCache($section);
     } else {
         // Otherwise if the section is not a false nuke all caches and rebuild
         // the base metadata cache
         if ($section !== false) {
             MetaDataManager::clearAPICache(true, true);
             MetaDataManager::setupMetadata();
         }
     }
 }
 public function deploy($defs)
 {
     // Make a viewdefs variable for saving
     $varname = "viewdefs['{$this->_moduleName}']['{$this->_viewClient}']['view']['{$this->sidecarSubpanelName}']";
     if (!empty($this->historyPathname)) {
         // first sort out the historical record...
         write_array_to_file($varname, $this->_viewdefs, $this->historyPathname);
         $this->_history->append($this->historyPathname);
     }
     $this->_viewdefs = $defs;
     // Now move on to the viewdefs proper
     if (!is_dir(dirname($this->sidecarFile))) {
         if (!mkdir(dirname($this->sidecarFile), 0755, true)) {
             throw new Exception(sprintf("Cannot create directory %s", $this->sidecarFile));
         }
     }
     // always set the type to subpanel-list for the client
     if (strpos($this->sidecarSubpanelName, 'subpanel-for-') !== false) {
         $this->_viewdefs['type'] = 'subpanel-list';
     }
     write_array_to_file($varname, $this->_viewdefs, $this->sidecarFile);
     $this->saveSidecarSubpanelDefOverride();
     // clear the cache for this modules only
     MetaDataManager::refreshModulesCache(array($this->loadedModule, $this->_moduleName));
 }
Esempio n. 17
0
 /**
  * Refresh the metadata cache for a given list of modules
  *
  * @param array $modules Which modules to refresh, if left empty it wil only do `Opportunities`
  */
 protected function refreshMetadataCache(array $modules = array())
 {
     // if empty, default it to Opportunities
     if (empty($modules)) {
         $modules[] = $this->bean->module_name;
     }
     MetaDataManager::refreshModulesCache($modules);
 }