Exemplo n.º 1
0
 function set_language($code)
 {
     global $path_to_root, $installed_languages, $GetText;
     $lang = array_search_value($code, $installed_languages, 'code');
     $changed = $this->code != $code || $this->version != @$lang['version'];
     if ($lang && $changed) {
         // flush cache as we can use several languages in one account
         flush_dir(company_path() . '/js_cache');
         $this->name = $lang['name'];
         $this->code = $lang['code'];
         $this->encoding = $lang['encoding'];
         $this->version = @$lang['version'];
         $this->dir = isset($lang['rtl']) && $lang['rtl'] === true ? 'rtl' : 'ltr';
         $locale = $path_to_root . "/lang/" . $this->code . "/locale.inc";
         $this->is_locale_file = file_exists($locale);
     }
     $GetText->set_language($this->code, $this->encoding);
     $GetText->add_domain($this->code, $path_to_root . "/lang", $this->version);
     // Necessary for ajax calls. Due to bug in php 4.3.10 for this
     // version set globally in php.ini
     ini_set('default_charset', $this->encoding);
     if (isset($_SESSION['App']) && $changed) {
         $_SESSION['App']->init();
     }
     // refresh menu
 }
Exemplo n.º 2
0
function handle_delete()
{
    global $def_coy, $db_connections, $comp_subdirs, $path_to_root;
    $id = (int) $_GET['id'];
    // First make sure all company directories from the one under removal are writable.
    // Without this after operation we end up with changed per-company owners!
    for ($i = $id; $i < count($db_connections); $i++) {
        $comp_path = company_path($i);
        if (!is_dir($comp_path) || !is_writable($comp_path)) {
            display_error(_('Broken company subdirectories system. You have to remove this company manually.'));
            return;
        }
    }
    // make sure config file is writable
    if (!is_writeable($path_to_root . "/config_db.php")) {
        display_error(_("The configuration file ") . $path_to_root . "/config_db.php" . _(" is not writable. Change its permissions so it is, then re-run the operation."));
        return;
    }
    // rename directory to temporary name to ensure all
    // other subdirectories will have right owners even after
    // unsuccessfull removal.
    $cdir = company_path($id);
    $tmpname = company_path('/old_' . $id);
    if (!@rename($cdir, $tmpname)) {
        display_error(_('Cannot rename subdirectory to temporary name.'));
        return;
    }
    // 'shift' company directories names
    for ($i = $id + 1; $i < count($db_connections); $i++) {
        if (!rename(company_path($i), company_path($i - 1))) {
            display_error(_("Cannot rename company subdirectory"));
            return;
        }
    }
    $err = remove_connection($id);
    if ($err == 0) {
        display_error(_("Error removing Database: ") . $dbase . _(", please remove it manually"));
    }
    if ($def_coy == $id) {
        $def_coy = 0;
    }
    $error = write_config_db();
    if ($error == -1) {
        display_error(_("Cannot open the configuration file - ") . $path_to_root . "/config_db.php");
    } else {
        if ($error == -2) {
            display_error(_("Cannot write to the configuration file - ") . $path_to_root . "/config_db.php");
        } else {
            if ($error == -3) {
                display_error(_("The configuration file ") . $path_to_root . "/config_db.php" . _(" is not writable. Change its permissions so it is, then re-run the operation."));
            }
        }
    }
    if ($error != 0) {
        @rename($tmpname, $cdir);
        return;
    }
    // finally remove renamed company directory
    @flush_dir($tmpname, true);
    if (!@rmdir($tmpname)) {
        display_error(_("Cannot remove temporary renamed company data directory ") . $tmpname);
        return;
    }
    display_notification(_("Selected company has been deleted"));
}
Exemplo n.º 3
0
    if (!is_numeric($_POST['query_size']) || $_POST['query_size'] < 1) {
        display_error($_POST['query_size']);
        display_error(_("Query size must be integer and greater than zero."));
        set_focus('query_size');
    } else {
        $_POST['theme'] = clean_file_name($_POST['theme']);
        $chg_theme = user_theme() != $_POST['theme'];
        $chg_lang = $_SESSION['language']->code != $_POST['language'];
        $chg_date_format = user_date_format() != $_POST['date_format'];
        $chg_date_sep = user_date_sep() != $_POST['date_sep'];
        set_user_prefs(get_post(array('prices_dec', 'qty_dec', 'rates_dec', 'percent_dec', 'date_format', 'date_sep', 'tho_sep', 'dec_sep', 'print_profile', 'theme', 'page_size', 'language', 'startup_tab', 'show_gl' => 0, 'show_codes' => 0, 'show_hints' => 0, 'rep_popup' => 0, 'graphic_links' => 0, 'sticky_doc_date' => 0, 'query_size' => 10.0)));
        if ($chg_lang) {
            $_SESSION['language']->set_language($_POST['language']);
        }
        // refresh main menu
        flush_dir(company_path() . '/js_cache');
        if ($chg_theme && $allow_demo_mode) {
            $_SESSION["wa_current_user"]->prefs->theme = $_POST['theme'];
        }
        if ($chg_theme || $chg_lang || $chg_date_format || $chg_date_sep) {
            meta_forward($_SERVER['PHP_SELF']);
        }
        if ($allow_demo_mode) {
            display_warning(_("Display settings have been updated. Keep in mind that changed settings are restored on every login in demo mode."));
        } else {
            display_notification_centered(_("Display settings have been updated."));
        }
    }
}
start_form();
start_outer_table(TABLESTYLE2);
Exemplo n.º 4
0
        $db = $_SESSION["wa_current_user"]->set_db_connection($n);
        $sql = "UPDATE {$conn['tbpref']}users SET theme='default' WHERE theme='{$theme}'";
        if (!db_query($sql, 'Cannot update user theme settings')) {
            return false;
        }
    }
    $db = $_SESSION["wa_current_user"]->set_db_connection($comp);
    $_SESSION['wa_current_user']->prefs->theme = 'default';
    return true;
}
if (($id = find_submit('Delete', false)) && clean_user_themes($id)) {
    $extensions = get_company_extensions();
    $theme = $extensions[$id]['package'];
    if (uninstall_package($theme)) {
        $dirname = $path_to_root . '/themes/' . $theme;
        flush_dir($dirname, true);
        rmdir($dirname);
        unset($extensions[$id]);
        if (update_extensions($extensions)) {
            display_notification(_("Selected theme has been successfully deleted"));
            meta_forward($_SERVER['PHP_SELF']);
        }
    }
}
if ($id = find_submit('Update', false)) {
    install_extension($id);
}
//---------------------------------------------------------------------------------------------
start_form(true);
div_start('ext_tbl');
start_table(TABLESTYLE);
Exemplo n.º 5
0
function handle_delete()
{
    global $comp_path, $def_coy, $db_connections, $comp_subdirs;
    $id = $_GET['id'];
    $err = remove_connection($id);
    if ($err == 0) {
        display_error(tr("Error removing Database: ") . $dbase . tr(", please remove it manuallly"));
    }
    if ($def_coy == $id) {
        $def_coy = 0;
    }
    $error = write_config_db();
    if ($error == -1) {
        display_error(tr("Cannot open the configuration file - ") . $path_to_root . "/config_db.php");
    } else {
        if ($error == -2) {
            display_error(tr("Cannot write to the configuration file - ") . $path_to_root . "/config_db.php");
        } else {
            if ($error == -3) {
                display_error(tr("The configuration file ") . $path_to_root . "/config_db.php" . tr(" is not writable. Change its permissions so it is, then re-run the operation."));
            }
        }
    }
    if ($error != 0) {
        return;
    }
    $cdir = $comp_path . '/' . $id;
    flush_dir($cdir);
    if (!rmdir($cdir)) {
        display_error(tr("Cannot remove company data directory ") . $cdir);
        return;
    }
    meta_forward($_SERVER['PHP_SELF']);
}
Exemplo n.º 6
0
function handle_delete($id)
{
    global $path_to_root, $installed_languages, $dflt_lang;
    $lang = $installed_languages[$id]['code'];
    if ($installed_languages[$id]['package']) {
        if (!uninstall_package($installed_languages[$id]['package'])) {
            return;
        }
    }
    if ($lang == $dflt_lang) {
        // on delete set default to current.
        $dflt_lang = $_SESSION['language']->code;
    }
    unset($installed_languages[$id]);
    $installed_languages = array_values($installed_languages);
    if (!write_lang()) {
        return;
    }
    $dirname = "{$path_to_root}/lang/{$lang}";
    if ($lang && is_dir($dirname)) {
        // remove nonstadard language dir
        flush_dir($dirname, true);
        rmdir($dirname);
    }
}
Exemplo n.º 7
0
<?php

$page_security = 10;
$path_to_root = "..";
include $path_to_root . "/includes/session.inc";
page(tr("Display Setup"));
include_once $path_to_root . "/includes/date_functions.inc";
include_once $path_to_root . "/includes/ui.inc";
include_once $path_to_root . "/admin/db/company_db.inc";
//-------------------------------------------------------------------------------------------------
if (isset($_POST['setprefs'])) {
    $theme = user_theme();
    set_user_prefs($_POST['prices'], $_POST['Quantities'], $_POST['Rates'], $_POST['Percent'], check_value('show_gl'), check_value('show_codes'), $_POST['date_format'], $_POST['date_sep'], $_POST['tho_sep'], $_POST['dec_sep'], $_POST['theme'], $_POST['page_size']);
    language::set_language($_POST['language']);
    flush_dir($comp_path . '/' . user_company() . '/js_cache');
    if (user_theme() != $theme) {
        reload_page("");
    }
    display_notification_centered(tr("Display settings have been updated."));
}
start_form();
start_table($table_style2);
table_section_title(tr("Decimal Places"));
text_row_ex(tr("Prices/Amounts:"), 'prices', 5, 5, user_price_dec());
text_row_ex(tr("Quantities:"), 'Quantities', 5, 5, user_qty_dec());
text_row_ex(tr("Exchange Rates:"), 'Rates', 5, 5, user_exrate_dec());
text_row_ex(tr("Percentages:"), 'Percent', 5, 5, user_percent_dec());
table_section_title(tr("Dateformat and Separators"));
dateformats_list_row(tr("Dateformat:"), "date_format", user_date_format());
dateseps_list_row(tr("Date Separator:"), "date_sep", user_date_sep());
/* The array $dateseps is set up in config.php for modifications