Ejemplo n.º 1
0
function upgrade_database_conf()
{
    //
    // Create new keywords (if necessary)
    // This must be done at the end, in case keyword DB structure changed
    //
    include_lcm('inc_meta');
    include_lcm('inc_keywords_default');
    $all_default_kwgs = get_default_keywords();
    create_groups($all_default_kwgs);
    //
    // Create new meta (if necessary)
    // This must be done at the end, in case meta DB structure changed
    //
    include_lcm('inc_meta_defaults');
    init_default_config();
    // Rewrite metas in inc/data/inc_meta_cache.php, just to be sure
    write_metas();
    //
    // Update lcm_fields
    //
    include_lcm('inc_repfields_defaults');
    $fields = get_default_repfields();
    create_repfields($fields);
}
Ejemplo n.º 2
0
function _Tkw($grp, $val, $args = '')
{
    global $system_kwg;
    $kwg = array();
    // If a 'contact' keyword (starts with +), remove the +
    if (substr($val, 0, 1) == '+') {
        $val = substr($val, 1);
    }
    if ($system_kwg[$grp]) {
        $kwg = $system_kwg[$grp]['keywords'];
    } else {
        $kwg = get_keywords_in_group_name($grp, false);
    }
    if (count($kwg)) {
        if ($kwg[$val]) {
            return _T(remove_number_prefix($kwg[$val]['title']), $args);
        } else {
            // This is a weird case where the upgrade didn't refresh the
            // group correctly, so we will try to fix the situation.
            // First, we check in the database to see if the keyword exists,
            // and if it does, then we refresh the keywords.
            // Note: that get_keywords_in_group_id() consults only the DB
            // [ML] Note: this should not happen from 0.6.3, but i'm fed up of
            // thinking that this time we fixed it, so the code stays..
            $tmp_group = get_kwg_from_name($grp);
            $kws1 = get_keywords_in_group_id($tmp_group['id_group'], false);
            foreach ($kws1 as $kw) {
                if ($kw['name'] == $val) {
                    include_lcm('inc_keywords_default');
                    $system_keyword_groups = get_default_keywords();
                    create_groups($system_keyword_groups);
                    write_metas();
                    // regenerate inc/data/inc_meta_cache.php
                    return _T(remove_number_prefix($kw['title']), $args);
                }
            }
            lcm_panic("*** The keyword does not exist. It is possible that a\n\t\t\t\tminor error occured while the last upgrade of the software. Please\n\t\t\t\task your administrator to do the following: Go to the 'Keywords'\n\t\t\t\tmenu, then click on the 'Maintenance' tab, then click on the\n\t\t\t\t'Validate' button. This will refresh the available keywords.");
        }
    } else {
        lcm_panic("*** The keyword group does not exist. It is possible that a\n\t\t\tminor error occured while the last upgrade of the software. Please\n\t\t\task your administrator to do the following: Go to the 'Keywords'\n\t\t\tmenu, then click on the 'Maintenance' tab, then click on the\n\t\t\t'Validate' button. This will refresh the available keywords.");
    }
}
Ejemplo n.º 3
0
function install_step_3()
{
    $db_address = _request('db_address');
    $db_login = _request('db_login');
    $db_password = _request('db_password');
    global $lcm_db_version;
    $install_log = "";
    $upgrade_log = "";
    // Possible errors will get trapped in the output buffer and displayed later,
    // so that they don't mess up with headers/html.
    ob_start();
    if (_request('db_choice') == "__manual__") {
        $sel_db = _request('manual_db');
    } else {
        $sel_db = _request('db_choice');
    }
    $link = lcm_connect_db($db_address, 0, $db_login, $db_password, $sel_db);
    $io_output = ob_get_contents();
    ob_end_clean();
    if (!$link) {
        install_html_start('AUTO', '', 3);
        lcm_panic("connection denied: " . lcm_sql_error());
    }
    //
    // TEMPORARY (used by testing the installer)
    /*
    lcm_query("DROP TABLE lcm_case", true);
    lcm_query("DROP TABLE lcm_case_attachment", true);
    lcm_query("DROP TABLE lcm_stage", true);
    lcm_query("DROP TABLE lcm_followup", true);
    lcm_query("DROP TABLE lcm_author", true);
    lcm_query("DROP TABLE lcm_client", true);
    lcm_query("DROP TABLE lcm_client_attachment", true);
    lcm_query("DROP TABLE lcm_org", true);
    lcm_query("DROP TABLE lcm_org_attachment", true);
    lcm_query("DROP TABLE lcm_contact", true);
    lcm_query("DROP TABLE lcm_keyword", true);
    lcm_query("DROP TABLE lcm_keyword_case", true);
    lcm_query("DROP TABLE lcm_keyword_client", true);
    lcm_query("DROP TABLE lcm_keyword_org", true);
    lcm_query("DROP TABLE lcm_keyword_group", true);
    lcm_query("DROP TABLE lcm_report", true);
    lcm_query("DROP TABLE lcm_fields", true);
    lcm_query("DROP TABLE lcm_filter", true);
    lcm_query("DROP TABLE lcm_app", true);
    lcm_query("DROP TABLE lcm_app_client_org", true);
    lcm_query("DROP TABLE lcm_app_fu", true);
    lcm_query("DROP TABLE lcm_author_app", true);
    lcm_query("DROP TABLE lcm_case_client_org", true);
    lcm_query("DROP TABLE lcm_case_author", true);
    lcm_query("DROP TABLE lcm_client_org", true);
    lcm_query("DROP TABLE lcm_rep_col", true);
    lcm_query("DROP TABLE lcm_rep_line", true);
    lcm_query("DROP TABLE lcm_rep_filters", true);
    lcm_query("DROP TABLE lcm_filter_conds", true);
    lcm_query("DROP TABLE lcm_rep_filter", true);
    lcm_query("DROP TABLE lcm_meta", true);
    */
    // Test if the software was already installed
    $result = lcm_query("SELECT * FROM lcm_meta", true);
    $already_installed = !lcm_sql_errno() && lcm_num_rows($result);
    $old_lcm_version = 'NONE';
    if ($already_installed) {
        lcm_log("LCM already installed", 'install');
        // Find the current database version
        $old_lcm_db_version = 0;
        $query = "SELECT value FROM lcm_meta WHERE name = 'lcm_db_version'";
        $result = lcm_query_db($query);
        while ($row = lcm_fetch_array($result)) {
            $old_lcm_db_version = $row['value'];
        }
        lcm_log("LCM version installed is {$old_lcm_db_version}", 'install');
        // Check if upgrade is needed
        if ($old_lcm_db_version < $lcm_db_version) {
            lcm_log("Calling the upgrade procedure (since < {$lcm_db_version})", 'install');
            include_lcm('inc_db_upgrade');
            $upgrade_log = upgrade_database($old_lcm_db_version);
        } else {
            lcm_log("Upgrade _not_ called, looks OK (= {$lcm_db_version})", 'install');
        }
    } else {
        lcm_log("Creating the database from scratch", 'install');
        include_lcm('inc_db_create');
        $install_log .= create_database();
        lcm_log("DB creation complete", 'install');
    }
    // Create default meta + keywords
    include_lcm('inc_meta');
    include_lcm('inc_keywords_default');
    include_lcm('inc_meta_defaults');
    init_default_config();
    init_languages();
    $skwg = get_default_keywords();
    create_groups($skwg);
    write_metas();
    // regenerate inc/data/inc_meta_cache.php
    // Test DB: not used for now..
    include_lcm('inc_db_test');
    $structure_ok = lcm_structure_test();
    if (!empty($install_log)) {
        install_html_start('AUTO', '', 3);
        echo "<h3><small>" . _T('install_step_three') . "</small> " . _T('install_title_creating_database') . "</h3>\n";
        echo "<div class='box_error'>\n";
        echo "<p>";
        echo "<b>" . _T('warning_operation_failed') . "</b> " . _T('install_database_install_failed');
        echo " " . lcm_help("install_connection") . "</p>\n";
        echo "</div>\n";
        // Dump error listing
        echo put_text_in_textbox($install_log);
        install_html_end();
    } else {
        if (!empty($upgrade_log)) {
            install_html_start('AUTO', '', 3);
            echo "<h3><small>" . _T('install_step_three') . "</small> " . _T('install_title_creating_database') . "</h3>\n";
            echo "<div class='box_error'>\n";
            echo "<p>" . _T('install_warning_update_impossible', array('old_version' => $old_lcm_version, 'version' => $lcm_version)) . "</p>\n";
            echo "</div>\n";
            // Dump error listing
            echo put_text_in_textbox($upgrade_log);
            install_html_end();
        } else {
            if (!$structure_ok) {
                install_html_start('AUTO', '', 3);
                echo "<h3><small>" . _T('install_step_three') . "</small> " . _T('install_title_creating_database') . "</h3>\n";
                echo "<div class='box_error'>\n";
                echo "<p> STRUCTURE PROBLEM </p>\n";
                // TRAD
                echo "</div>\n";
                install_html_end();
            } else {
                // Everything OK
                $conn = '<' . '?php' . "\n";
                $conn .= "if (defined('_CONFIG_INC_CONNECT')) return;\n";
                $conn .= "define('_CONFIG_INC_CONNECT', '1');\n";
                $conn .= "\$GLOBALS['lcm_connect_version'] = 0.1;\n";
                $conn .= "include_lcm('inc_db');\n";
                $conn .= "@lcm_connect_db('{$db_address}','','{$db_login}','{$db_password}','{$sel_db}');\n";
                $conn .= "\$GLOBALS['db_ok'] = !!@lcm_num_rows(@lcm_query_db('SELECT COUNT(*) FROM lcm_meta'));\n";
                $conn .= '?' . '>';
                $lcm_config_prefix = isset($_SERVER['LcmConfigDir']) ? $_SERVER['LcmConfigDir'] : 'inc/config';
                $myFile = fopen($lcm_config_prefix . '/inc_connect_install.php', 'wb');
                fputs($myFile, $conn);
                fclose($myFile);
                install_step_4();
            }
        }
    }
}
Ejemplo n.º 4
0
    case 'edit_keyword':
        // Show form to edit a keyword and exit
        show_keyword_id(intval(_request('id_keyword', 0)));
        break;
    case 'update_group':
        // Update the information on a keyword group then goes to edit group
        update_keyword_group(intval(_request('id_group', 0)), intval(_request('id_parent', 0)));
        break;
    case 'update_keyword':
        // Update the information on a keyword group then goes to edit group
        update_keyword(intval(_request('id_keyword', 0)));
        break;
    case 'refresh':
        include_lcm('inc_meta');
        include_lcm('inc_keywords_default');
        $system_keyword_groups = get_default_keywords();
        create_groups($system_keyword_groups);
        write_metas();
        // regenerate inc/data/inc_meta_cache.php
        $_SESSION['info']['refresh'] = 'Keywords cache refreshed';
        // TRAD
        break;
    case '':
        // Do Nothing
        break;
    default:
        lcm_panic("No such action (" . _request('action') . ")");
}
lcm_page_start(_T('menu_admin_keywords'), '', '', 'keywords_intro');
lcm_bubble('keyword_list');
echo show_all_errors();