示例#1
0
 * @var User
 */
global $current_User;
// Check minimum permission:
$current_User->check_perm('options', 'view', true);
// Memorize this as the last "tab" used in the Global Settings:
$UserSettings->set('pref_glob_settings_tab', $ctrl);
$UserSettings->set('pref_glob_regional_tab', $ctrl);
$UserSettings->dbupdate();
// Set options path:
$AdminUI->set_path('options', 'regional', 'currencies');
// Get action parameter from request:
param_action();
if (param('curr_ID', 'integer', '', true)) {
    // Load currency from cache:
    $CurrencyCache =& get_CurrencyCache();
    if (($edited_Currency =& $CurrencyCache->get_by_ID($curr_ID, false)) === false) {
        unset($edited_Currency);
        forget_param('curr_ID');
        $Messages->add(sprintf(T_('Requested «%s» object does not exist any longer.'), T_('Currency')), 'error');
        $action = 'nil';
    }
}
switch ($action) {
    case 'disable_currency':
    case 'enable_currency':
        // Check that this action request is not a CSRF hacked request:
        $Session->assert_received_crumb('currency');
        // Disable a currency only if it is enabled, and user has edit access.
        $current_User->check_perm('options', 'edit', true);
        // Make sure the currency information was loaded. If not, just exit with error.
}
global $dispatcher;
// Get params from request
$s = param('s', 'string', '', true);
//Create query
$SQL = new SQL();
$SQL->SELECT('*');
$SQL->FROM('T_regional__currency');
if (!empty($s)) {
    // We want to filter on search keyword:
    // Note: we use CONCAT_WS (Concat With Separator) because CONCAT returns NULL if any arg is NULL
    $SQL->WHERE('CONCAT_WS( " ", curr_code, curr_name ) LIKE "%' . $DB->escape($s) . '%"');
}
// Create result set:
$Results = new Results($SQL->get(), 'curr_', '-A');
$Results->Cache =& get_CurrencyCache();
$Results->title = T_('Currencies list') . get_manual_link('currencies_list');
/*
 * STATUS TD:
 */
function curr_td_enabled($curr_enabled, $curr_ID)
{
    global $dispatcher;
    $r = '';
    if ($curr_enabled == true) {
        $r .= action_icon(T_('Disable the currency!'), 'bullet_full', regenerate_url('action', 'action=disable_currency&curr_ID=' . $curr_ID . '&' . url_crumb('currency')));
    } else {
        $r .= action_icon(T_('Enable the currency!'), 'bullet_empty', regenerate_url('action', 'action=enable_currency&curr_ID=' . $curr_ID . '&' . url_crumb('currency')));
    }
    return $r;
}