Last active
August 29, 2015 14:20
-
-
Save matthewpoer/ea9c480741a5ad5cefd9 to your computer and use it in GitHub Desktop.
if you upgrade a 7.5 to a 7.6 Sugar system you may need this to enable the Opportunities config screen and allow the use of RLIs again. Place the file in your root Sugar directory and run it from CLI like you would cron, e.g. "php -f 76_rli_fix.php"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (!defined('sugarEntry')) define('sugarEntry', true); | |
chdir(dirname(__FILE__)); | |
define('ENTRY_POINT_TYPE', 'api'); | |
require_once('include/entryPoint.php'); | |
$sapi_type = php_sapi_name(); | |
if (substr($sapi_type, 0, 3) != 'cli') { | |
sugar_die("cron.php is CLI only."); | |
} | |
if (empty($current_language)) { | |
$current_language = $sugar_config['default_language']; | |
} | |
$app_list_strings = return_app_list_strings_language($current_language); | |
$app_strings = return_application_language($current_language); | |
global $current_user; | |
$current_user = BeanFactory::getBean('Users'); | |
$current_user->getSystemUser(); | |
/** | |
* config, mostly ripped from OpportunitiesConfigApi::configSave() and it's | |
* parent ConfigModuleApi::configSave() | |
*/ | |
$args = array( | |
'opps_view_by' => 'RevenueLineItems', | |
'__sugar_url' => 'v10/Opportunities/config', | |
'module' => 'Opportunities', | |
); | |
$module = $args['module']; | |
$admin = BeanFactory::getBean('Administration'); | |
foreach ($args as $name => $value) { | |
if (is_array($value)) { | |
$admin->saveSetting($module, $name, json_encode($value), 'base'); | |
} else { | |
$admin->saveSetting($module, $name, $value, 'base'); | |
} | |
} | |
/* | |
* do conversion to this | |
*/ | |
require_once 'modules/Opportunities/include/OpportunityWithRevenueLineItem.php'; | |
$converter = new OpportunityWithRevenueLineItem(); | |
// actually trigger the conversion here | |
// do metadata first | |
$converter->doMetadataConvert(); | |
// then do data | |
$converter->doDataConvert(); | |
require_once('modules/Home/UnifiedSearchAdvanced.php'); | |
register_shutdown_function(array('UnifiedSearchAdvanced', 'clearCache')); | |
// we need to refresh the cache but do it in the shutdown for this process | |
register_shutdown_function(array('MetaDataManager', 'refreshCache')); | |
$exit_on_cleanup = true; | |
sugar_cleanup(false); | |
// some jobs have annoying habit of calling sugar_cleanup(), and it can be called only once | |
// but job results can be written to DB after job is finished, so we have to disconnect here again | |
// just in case we couldn't call cleanup | |
if (class_exists('DBManagerFactory')) { | |
$db = DBManagerFactory::getInstance(); | |
$db->disconnect(); | |
} | |
// If we have a session left over, destroy it | |
if (session_id()) { | |
session_destroy(); | |
} | |
if ($exit_on_cleanup) exit(0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment