***********************************************************************/ $page_security = 'SA_CREATEMODULES'; $path_to_root = ".."; include_once $path_to_root . "/includes/session.inc"; include_once $path_to_root . "/includes/packages.inc"; if ($use_popup_windows) { $js = get_js_open_window(900, 500); } page(_($help_context = "Install Charts of Accounts"), false, false, '', $js); include_once $path_to_root . "/includes/date_functions.inc"; include_once $path_to_root . "/admin/db/company_db.inc"; include_once $path_to_root . "/admin/db/maintenance_db.inc"; include_once $path_to_root . "/includes/ui.inc"; //--------------------------------------------------------------------------------------------- if ($id = find_submit('Delete', false)) { $extensions = get_company_extensions(); if ($extensions[$id]['type'] == 'chart' && uninstall_package($extensions[$id]['package'])) { unset($extensions[$id]); if (update_extensions($extensions)) { display_notification(_("Selected chart 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);
function handle_submit() { global $db_connections, $def_coy, $tb_pref_counter, $db, $comp_subdirs, $path_to_root, $selected_id; $error = false; if (!check_data()) { return false; } if ($selected_id == -1) { $selected_id = count($db_connections); } $new = !isset($db_connections[$selected_id]); if ((bool) $_POST['def'] == true) { $def_coy = $selected_id; } $db_connections[$selected_id]['name'] = $_POST['name']; if ($new) { $db_connections[$selected_id]['host'] = $_POST['host']; $db_connections[$selected_id]['dbuser'] = $_POST['dbuser']; $db_connections[$selected_id]['dbpassword'] = $_POST['dbpassword']; $db_connections[$selected_id]['dbname'] = $_POST['dbname']; if (is_numeric($_POST['tbpref'])) { $db_connections[$selected_id]['tbpref'] = $_POST['tbpref'] == 1 ? $tb_pref_counter . "_" : ''; } else { if ($_POST['tbpref'] != "") { $db_connections[$selected_id]['tbpref'] = $_POST['tbpref']; } else { $db_connections[$selected_id]['tbpref'] = ""; } } $conn = $db_connections[$selected_id]; if (($db = db_create_db($conn)) == 0) { display_error(_("Error creating Database: ") . $conn['dbname'] . _(", Please create it manually")); $error = true; } else { if (!db_import($path_to_root . '/sql/' . get_post('coa'), $conn, $selected_id)) { display_error(_('Cannot create new company due to bugs in sql file.')); $error = true; } else { if (!isset($_POST['admpassword']) || $_POST['admpassword'] == "") { $_POST['admpassword'] = "******"; } update_admin_password($conn, md5($_POST['admpassword'])); } } set_global_connection(); if ($error) { remove_connection($selected_id); return false; } } $error = write_config_db($new); 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) { return false; } if ($new) { create_comp_dirs(company_path($selected_id), $comp_subdirs); } $exts = get_company_extensions(); write_extensions($exts, $selected_id); display_notification($new ? _('New company has been created.') : _('Company has been updated.')); return true; }
function company_extensions($id) { start_table(TABLESTYLE); $th = array(_("Extension"), _("Modules provided"), _("Options provided"), _("Active")); $mods = get_company_extensions(); $exts = get_company_extensions($id); foreach ($mods as $key => $ins) { foreach ($exts as $ext) { if ($ext['name'] == $ins['name']) { $mods[$key]['active'] = @$ext['active']; continue 2; } } } $mods = array_natsort($mods, null, 'name'); table_header($th); $k = 0; foreach ($mods as $i => $mod) { if ($mod['type'] != 'extension') { continue; } alt_table_row_color($k); label_cell($mod['name']); $entries = fmt_titles(@$mod['entries']); $tabs = fmt_titles(@$mod['tabs']); label_cell($tabs); label_cell($entries); check_cells(null, 'Active' . $i, @$mod['active'] ? 1 : 0, false, false, "align='center'"); end_row(); } end_table(1); submit_center('Refresh', _('Update'), true, false, 'default'); }
function fix_extensions() { global $path_to_root, $next_extension_id, $installed_languages; $lang_chd = false; foreach ($installed_languages as $i => $lang) { if (!isset($lang['path'])) { $code = $lang['code']; $installed_languages[$i]['path'] = 'lang/' . $code; $installed_languages[$i]['package'] = $code; $lang_chd = true; } } if ($lang_chd) { write_lang(); } $installed_extensions = get_company_extensions(); if (!isset($next_extension_id)) { $next_extension_id = 1; } $new_exts = array(); /* Old extension modules are uninstalled - they need manual porting after heavy changes in extension system in FA2.3 foreach($installed_extensions as $i => $ext) { if (isset($ext['title'])) // old type entry { if ($ext['type'] == 'module') { $new['type'] = 'extension'; $new['tabs'][] = array( 'url' => $ext['filename'], 'access' => isset($ext['access']) ? $ext['access'] : 'SA_OPEN', 'tab_id' => $ext['tab'], 'title' => $ext['title'] ); $new['path'] = $ext['path']; } else // plugin { $new['type'] = 'extension'; $new['tabs'] = array(); $new['path'] = 'modules/'.$ext['path']; $new['entries'][] = array( 'url' => $ext['filename'], 'access' => isset($ext['access']) ? $ext['access'] : 'SA_OPEN', 'tab_id' => $ext['tab'], 'title' => $ext['title'] ); } if (isset($ext['acc_file'])) $new['acc_file'] = $ext['acc_file']; $new['name'] = $ext['name']; $new['package'] = $new['package'] = ''; $new['active'] = 1; $new_exts[$i] = $new; } } */ // Preserve non-standard themes $path = $path_to_root . '/themes/'; $themes = array(); $themedir = opendir($path); while (false !== ($fname = readdir($themedir))) { if ($fname != '.' && $fname != '..' && $fname != 'CVS' && is_dir($path . $fname) && !in_array($fname, array('aqua', 'cool', 'default'))) { foreach ($installed_extensions as $ext) { if ($ext['path'] == 'themes/' . $fname) { // skip if theme is already listed continue 2; } } $new_exts[$next_extension_id++] = array('name' => 'Theme ' . ucwords($fname), 'package' => $fname, 'type' => 'theme', 'active' => true, 'path' => 'themes/' . $fname); } } closedir($themedir); if (count($new_exts)) { return update_extensions($new_exts); } else { return true; } }