예제 #1
0
 function action_saveadminwizard()
 {
     global $current_user;
     if (!is_admin($current_user)) {
         sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']);
     }
     $focus = new Administration();
     $focus->retrieveSettings();
     $focus->saveConfig();
     $configurator = new Configurator();
     $configurator->populateFromPost();
     $configurator->handleOverride();
     $configurator->parseLoggerSettings();
     $configurator->saveConfig();
     // Bug 37310 - Delete any existing currency that matches the one we've just set the default to during the admin wizard
     $currency = new Currency();
     $currency->retrieve($currency->retrieve_id_by_name($_REQUEST['default_currency_name']));
     if (!empty($currency->id) && $currency->symbol == $_REQUEST['default_currency_symbol'] && $currency->iso4217 == $_REQUEST['default_currency_iso4217']) {
         $currency->deleted = 1;
         $currency->save();
     }
     SugarApplication::redirect('index.php?module=Users&action=Wizard&skipwelcome=1');
 }
예제 #2
0
    $sugar_config['default_date_format'] = $_SESSION['default_time_format'];
}
if (!empty($_SESSION['default_language'])) {
    $sugar_config['default_language'] = $_SESSION['default_language'];
}
if (!empty($_SESSION['default_locale_name_format'])) {
    $sugar_config['default_locale_name_format'] = $_SESSION['default_locale_name_format'];
}
//$configurator->handleOverride();
installLog('saveConfig');
$configurator->saveConfig();
// Bug 37310 - Delete any existing currency that matches the one we've just set the default to during the admin wizard
installLog('new Currency');
$currency = new Currency();
installLog('retrieve');
$currency->retrieve($currency->retrieve_id_by_name($_REQUEST['default_currency_name']));
if (!empty($currency->id) && $currency->symbol == $_REQUEST['default_currency_symbol'] && $currency->iso4217 == $_REQUEST['default_currency_iso4217']) {
    $currency->deleted = 1;
    installLog('DBG: save currency');
    $currency->save();
}
installLog('Save user settings..');
//      <------------------------------------------------
//          from UsersController->action_saveuserwizard()
//          ---------------------------------------------------------->
// set all of these default parameters since the Users save action will undo the defaults otherwise
// load admin
$current_user = new User();
$current_user->retrieve(1);
$current_user->is_admin = '1';
$sugar_config = get_sugar_config_defaults();
 private function getProductCatalogVariables($productCatalog)
 {
     $rootCategoriesSmarty = $this->getSmartyCategories($productCatalog->getAllCategories());
     $this->insertProducts($rootCategoriesSmarty);
     $description = htmlToLatex(from_html($productCatalog->description));
     //1.7.6 TODO create error handling here
     if ($description == null) {
         $GLOBALS['log']->error('OQC: Product catalog description is null!');
         //return null;
     }
     global $timedate;
     $validfrom = $timedate->to_display_date($productCatalog->validfrom);
     $validto = $timedate->to_display_date($productCatalog->validto);
     $frontpage = null;
     $attachment = null;
     if ($productCatalog->frontpage_id != null || $productCatalog->attachment_id != null) {
         $doc = new Document();
         if ($doc->retrieve($productCatalog->frontpage_id)) {
             $frontpage = str_replace("\\", '/', TMP_DIR . DIRECTORY_SEPARATOR . $doc->document_revision_id . '.pdf');
             copy(getcwd() . DIRECTORY_SEPARATOR . getDocumentFilename($doc->document_revision_id), $frontpage);
         }
         if ($doc->retrieve($productCatalog->attachment_id)) {
             $attachment = str_replace("\\", '/', TMP_DIR . DIRECTORY_SEPARATOR . $doc->document_revision_id . '.pdf');
             copy(getcwd() . DIRECTORY_SEPARATOR . getDocumentFilename($doc->document_revision_id), $attachment);
         }
     }
     //ProductCatalog currency setup
     $currencyArray = array();
     $currency = new Currency();
     $currency_id = $currency->retrieve_id_by_name($productCatalog->currency_id);
     //$GLOBALS['log']->error('Contract variables: currency: '. var_export($currency_id,true));
     if ($currency_id) {
         $currency->retrieve($currency_id);
         $currencyArray['currency_id'] = $currency->iso4217;
         $currencyArray['currency_symbol'] = $currency->symbol;
         $currencyArray['currency_ratio'] = $currency->conversion_rate;
     } else {
         $currencyArray['currency_id'] = $currency->getDefaultISO4217();
         $currencyArray['currency_symbol'] = $currency->getDefaultCurrencySymbol();
         $currencyArray['currency_ratio'] = 1.0;
     }
     $currencyArray['currency_symbol'] = str_replace("€", '\\euro{}', $currencyArray['currency_symbol']);
     $currencyArray['currency_symbol'] = str_replace('$', '\\$', $currencyArray['currency_symbol']);
     $currencyArray['currency_symbol'] = str_replace("£", '{\\pounds}', $currencyArray['currency_symbol']);
     $currencyArray['currency_symbol'] = str_replace("¥", '{Y\\hspace*{-1.4ex}--}', $currencyArray['currency_symbol']);
     $productCatalogVariables = array('name' => $productCatalog->name, 'validfrom' => $validfrom, 'validto' => $validto, 'graphicsDir' => LATEX_GRAPHICS_DIR, 'categoriesAndProducts' => $rootCategoriesSmarty, 'description' => $description, 'frontpage' => $frontpage, 'attachment' => $attachment, 'year' => date('Y'), 'currency' => $currencyArray, 'discount' => 1.0 - $productCatalog->oqc_catalog_discount / 100);
     //$GLOBALS['log']->error('Product Catalog variables: '. var_export($productCatalogVariables,true));
     return $productCatalogVariables;
 }
예제 #4
0
 function action_saveadminwizard()
 {
     global $current_user;
     if (!is_admin($current_user)) {
         sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']);
     }
     $focus = new Administration();
     $focus->retrieveSettings();
     $focus->saveConfig();
     $configurator = new Configurator();
     $configurator->populateFromPost();
     $configurator->handleOverride();
     $configurator->parseLoggerSettings();
     $configurator->saveConfig();
     //The save of the admin wizard stops the post silent install from re-showing the admin wizard on each login
     $postSilentInstallAdminWizardCompleted = $current_user->getPreference('postSilentInstallAdminWizardCompleted');
     if (isset($postSilentInstallAdminWizardCompleted) && !$postSilentInstallAdminWizardCompleted) {
         $current_user->setPreference('postSilentInstallAdminWizardCompleted', true);
     }
     // Bug 37310 - Delete any existing currency that matches the one we've just set the default to during the admin wizard
     $currency = new Currency();
     $currency->retrieve($currency->retrieve_id_by_name($_REQUEST['default_currency_name']));
     if (!empty($currency->id) && $currency->symbol == $_REQUEST['default_currency_symbol'] && $currency->iso4217 == $_REQUEST['default_currency_iso4217']) {
         $currency->deleted = 1;
         $currency->save();
     }
     //Only process the scenario item for admin users!
     if ($current_user->isAdmin()) {
         //Process the scenarios selected in the wizard
         require_once 'install/suite_install/enabledTabs.php';
         //We need to load the tabs so that we can remove those which are scenario based and un-selected
         //Remove the custom tabConfig as this overwrites the complete list containined in the include/tabConfig.php
         if (file_exists('custom/include/tabConfig.php')) {
             unlink('custom/include/tabConfig.php');
         }
         require_once 'include/tabConfig.php';
         //Remove the custom dashlet so that we can use the complete list of defaults to filter by category
         if (file_exists('custom/modules/Home/dashlets.php')) {
             unlink('custom/modules/Home/dashlets.php');
         }
         //Check if the folder is in place
         if (!file_exists('custom/modules/Home')) {
             sugar_mkdir('custom/modules/Home', 0775);
         }
         //Check if the folder is in place
         if (!file_exists('custom/include')) {
             sugar_mkdir('custom/include', 0775);
         }
         require_once 'modules/Home/dashlets.php';
         require_once 'install/suite_install/scenarios.php';
         foreach ($installation_scenarios as $scenario) {
             //If the item is not in $_SESSION['scenarios'], then unset them as they are not required
             if (!in_array($scenario['key'], $_REQUEST['scenarios'])) {
                 foreach ($scenario['modules'] as $module) {
                     if (($removeKey = array_search($module, $enabled_tabs)) !== false) {
                         unset($enabled_tabs[$removeKey]);
                     }
                 }
                 //Loop through the dashlets to remove from the default home page based on this scenario
                 foreach ($scenario['dashlets'] as $dashlet) {
                     //if (($removeKey = array_search($dashlet, $defaultDashlets)) !== false) {
                     //    unset($defaultDashlets[$removeKey]);
                     // }
                     if (isset($defaultDashlets[$dashlet])) {
                         unset($defaultDashlets[$dashlet]);
                     }
                 }
                 //If the scenario has an associated group tab, remove accordingly (by not adding to the custom tabconfig.php
                 if (isset($scenario['groupedTabs'])) {
                     unset($GLOBALS['tabStructure'][$scenario['groupedTabs']]);
                 }
             }
         }
         //Have a 'core' options, with accounts / contacts if no other scenario is selected
         if (!is_null($_SESSION['scenarios'])) {
             unset($GLOBALS['tabStructure']['LBL_TABGROUP_DEFAULT']);
         }
         //Write the tabstructure to custom so that the grouping are not shown for the un-selected scenarios
         $fp = sugar_fopen('custom/include/tabConfig.php', 'w');
         $fileContents = "<?php \n" . '$GLOBALS["tabStructure"] =' . var_export($GLOBALS['tabStructure'], true) . ';';
         fwrite($fp, $fileContents);
         fclose($fp);
         //Write the dashlets to custom so that the dashlets are not shown for the un-selected scenarios
         $fp = sugar_fopen('custom/modules/Home/dashlets.php', 'w');
         $fileContents = "<?php \n" . '$defaultDashlets =' . var_export($defaultDashlets, true) . ';';
         fwrite($fp, $fileContents);
         fclose($fp);
         // End of the scenario implementations
     }
     SugarApplication::redirect('index.php?module=Users&action=Wizard&skipwelcome=1');
 }
예제 #5
0
 public function testretrieve_id_by_name()
 {
     $currency = new Currency();
     $this->assertEquals('', $currency->retrieve_id_by_name(''));
     $this->assertEquals('', $currency->retrieve_id_by_name('US Dollars'));
 }
function getContractVariables($contract)
{
    $contractData = sanatizeBeanArrayForLatex($contract->toArray(true));
    $clientContact = new Contact();
    if ($clientContact->retrieve($contract->clientcontact_id)) {
        $contractData['clientContact'] = sanatizeBeanArrayForLatex($clientContact->toArray(true));
        // Gets data from DB only
        $clientAccount = new Account();
        if ($clientAccount->retrieve($clientContact->account_id)) {
            //$GLOBALS['log']->error('Account variables: variables transferred to latex template: '. var_export($clientAccount->toArray(true),true));
            $contractData['clientContact']['account'] = sanatizeBeanArrayForLatex($clientAccount->toArray(true));
        }
        //gets data from DB only
    }
    // only date is needed (not time) and we have to convert it to the user format
    global $timedate;
    //$GLOBALS['log']->error('Contract variables: date_modified: '. var_export($contract->date_modified,true));
    //$contractData['date_modified'] = $timedate->to_display_date($contract->date_modified);
    $contractData['date_modified'] = $timedate->getDatePart($contract->date_modified);
    //$contractData['startdate'] = $timedate->to_display_date($contract->startdate);
    //$contractData['enddate'] = $timedate->to_display_date($contract->enddate);
    //$contractData['deadline'] = $timedate->to_display_date($contract->deadline);
    // translate
    global $app_list_strings;
    if (isset($contractData['periodofnotice'])) {
        $contractData['periodofnotice'] = $app_list_strings['periodofnotice_list'][$contractData['periodofnotice']];
    }
    //contract currency setup
    $currency = new Currency();
    $currency_id = $currency->retrieve_id_by_name($contract->currency_id);
    //$GLOBALS['log']->error('Contract variables: currency: '. var_export($currency_id,true));
    if ($currency_id) {
        $currency->retrieve($currency_id);
        $contractData['currency_id'] = $currency->iso4217;
        $contractData['currency_symbol'] = $currency->symbol;
    } else {
        $contractData['currency_id'] = $currency->getDefaultISO4217();
        $contractData['currency_symbol'] = $currency->getDefaultCurrencySymbol();
    }
    $contractData['currency_symbol'] = str_replace("€", '\\euro{}', $contractData['currency_symbol']);
    $contractData['currency_symbol'] = str_replace('$', '\\$', $contractData['currency_symbol']);
    $contractData['currency_symbol'] = str_replace("£", '{\\pounds}', $contractData['currency_symbol']);
    $contractData['currency_symbol'] = str_replace("¥", '{Y\\hspace*{-1.4ex}--}', $contractData['currency_symbol']);
    // Get Sugar user information
    $userData = oqc_getUserVariables();
    $contractData = array_merge($contractData, $userData);
    $outputData = array('contract' => $contractData, 'graphicsDir' => LATEX_GRAPHICS_DIR);
    //$GLOBALS['log']->error('Contract variables: variables transferred to latex template: '. var_export($contractData,true));
    return $outputData;
}