diff --git a/setup/lang.php b/setup/lang.php
index c37272062f..938a16f840 100644
--- a/setup/lang.php
+++ b/setup/lang.php
@@ -11,169 +11,120 @@
/* $Id$ */
- $phpgw_info["flags"] = array("noheader" => True, "nonavbar" => True,
- "currentapp" => "home", "noapi" => True);
- include("../header.inc.php");
+ if (! $included) {
+
+ $phpgw_info["flags"] = array("noheader" => True, "nonavbar" => True, "currentapp" => "home", "noapi" => True);
include("./inc/functions.inc.php");
-
+ include("../header.inc.php");
// Authorize the user to use setup app and load the database
- // include("./inc/setup_auth.inc.php");
// Does not return unless user is authorized
- $phpgw_info["server"]["api_inc"] = $phpgw_info["server"]["include_root"]."/phpgwapi/inc";
- include($phpgw_info["server"]["api_inc"] . "/phpgw_common.inc.php");
+ if (!auth()){
+ Header("Location: index.php");
+ exit;
+ }
+ loaddb();
- $common = new common;
- loaddb();
+ echo "
phpGroupWare Setup\n";
+ echo "\n";
- $db->query("select config_name,config_value from config where config_name like 'ldap%'",__LINE__,__FILE__);
- while ($db->next_record()) {
- $config[$db->f("config_name")] = $db->f("config_value");
+ include($phpgw_info["server"]["include_root"]."/phpgwapi/inc/phpgw_common.inc.php");
+ $common = new common;
+ $sep = $common->filesystem_separator();
+ } else {
+ $newinstall = True;
+ $lang_selected["en"] = "en";
+ $submit = True;
}
- // First, see if we can connect to the LDAP server, if not send `em back to config.php with an
- // error message.
-
- // connect to ldap server
- if (! $ldap = @ldap_connect($config["ldap_host"])) {
- $noldapconnection = True;
- }
-
- // bind as admin, we not to able to do everything
- if (! @ldap_bind($ldap,$config["ldap_root_dn"],$config["ldap_root_pw"])) {
- $noldapconnection = True;
- }
-
- if ($noldapconnection) {
- Header("Location: config.php?error=badldapconnection");
- exit;
- }
-
- $sr = ldap_search($ldap,$config["ldap_context"],"(|(uid=*))",array("sn","givenname","uid","uidnumber"));
- $info = ldap_get_entries($ldap, $sr);
-
- for ($i=0; $i<$info["count"]; $i++) {
- if (! $phpgw_info["server"]["global_denied_users"][$info[$i]["uid"][0]]) {
- $account_info[$i]["account_id"] = $info[$i]["uidnumber"][0];
- $account_info[$i]["account_lid"] = $info[$i]["uid"][0];
- $account_info[$i]["account_lastname"] = $info[$i]["givenname"][0];
- $account_info[$i]["account_firstname"] = $info[$i]["sn"][0];
- }
- }
-
- $db->query("select app_name,app_title from applications where app_enabled != '0' and "
- . "app_name != 'admin'",__LINE__,__FILE__);
- while ($db->next_record()) {
- $apps[$db->f("app_name")] = $db->f("app_title");
- }
-
if ($submit) {
- if (! count($admins)) {
- $error = "
You must select at least 1 admin";
- }
-
- if (! count($s_apps)) {
- $error .= "
You must select at least 1 application";
- }
-
- if (! $error) {
- include($phpgw_info["server"]["api_inc"] . "/phpgw_accounts_ldap.inc.php");
- include($phpgw_info["server"]["api_inc"] . "/phpgw_accounts_shared.inc.php");
- $accounts = new accounts;
-
- while ($app = each($s_apps)) {
- $permissions_string = $accounts->add_app($app[1]);
+ if (count($lang_selected)) {
+ if ($upgrademethod == "dumpold") {
+ $db->query("delete from lang");
+ //echo "
Test: dumpold";
}
- $permissions_string = $accounts->add_app("",True);
- $admin_permissions_string = $permissions_string . "admin:";
-
- while ($admin = each($admins)) {
- $s_admin[$admin[1]] = True;
- }
-
- while ($account = each($account_info)) {
- if ($s_admin[$account[1]["account_id"]]) {
- $np = $admin_permissions_string;
- } else {
- $np = $permissions_string;
+ while (list($null,$lang) = each($lang_selected)) {
+ $addlang = False;
+ if ($upgrademethod == "addonlynew") {
+ //echo "
Test: addonlynew - select count(*) from lang where lang='$lang'";
+ $db->query("select count(*) from lang where lang='$lang'");
+ $db->next_record();
+
+ if ($db->f(0) == 0) {
+ //echo "
Test: addonlynew - True";
+ $addlang = True;
+ }
}
- // do some checks before we try to import the data
- if (!empty($account[1]["account_id"]) && !empty($account[1]["account_lid"]))
- $db->query("insert into accounts (account_id,account_lid,account_pwd,account_permissions,"
- . "account_groups,account_status,account_lastpwd_change) values ('" . $account[1]["account_id"] . "','"
- . $account[1]["account_lid"] . "','x','$np',',1:0,','A','".time()."')",__LINE__,__FILE__);
- }
- $setup_complete = True;
- }
- }
-
- // Add a check to see if there is no users in LDAP, if not create a default user.
+ if (($addlang && $upgrademethod == "addonlynew") || ($upgrademethod != "addonlynew")) {
+ //echo '
Test: loop above file()';
+ $raw_file = file($phpgw_info["server"]["server_root"] . "/setup/phpgw_" . strtolower($lang) . ".lang");
+ while (list($null,$line) = each($raw_file)) {
+ $addit = False;
+ list($message_id,$app_name,$db_lang,$content) = explode("\t",$line);
+ $message_id = addslashes(chop($message_id));
+ $app_name = addslashes(chop($app_name));
+ $db_lang = addslashes(chop($db_lang));
+ $content = addslashes(chop($content));
+ if ($upgrademethod == "addmissing") {
+ //echo "
Test: addmissing";
+ $db->query("select count(*) from lang where message_id='$message_id' and lang='$db_lang'");
+ $db->next_record();
+
+ if ($db->f(0) == 0) {
+ //echo "
Test: addmissing - True - Total: " . $db->f(0);
+ $addit = True;
+ }
+ }
+
+ if ($addit || ($upgrademethod == "dumpold" || $newinstall || $upgrademethod == "addonlynew")) {
+ //echo "
adding - insert into lang values ('$message_id','$app_name','$db_lang','$content')";
+ $db->query("insert into lang values ('$message_id','$app_name','$db_lang','$content')");
+ }
+ }
+ }
+ }
+ }
- setup_header();
-
- if ($error) {
- echo "
Error: $error";
- }
+ if (! $included) {
+ echo "Language files have been installed";
+ exit;
+ }
- if ($setup_complete) {
- $db->query("select config_value from config where config_name='webserver_url'",__LINE__,__FILE__);
- $db->next_record();
- echo '
Setup has been completed! Click here to login';
- exit;
- }
+ } else {
+ if (! $included) {
+ setup_header();
?>
-
-