an other big update ;-)

1) phpgw_lang(uages) --> egw_lang(uages)
2) mysql 4.0+
 - charset gets now set for the connect
 - charset gets used for new tables
 - some columns shortend to deal with 1000byte (= 333 utf-8 chars) limit for indexes
 - update to 1.0.1.019 fixes the charset of existing tables
This commit is contained in:
Ralf Becker 2005-11-04 18:35:09 +00:00
parent 6717a20a69
commit 970a92297e
14 changed files with 700 additions and 307 deletions

View File

@ -13,10 +13,13 @@
/* $Id$ */
define('BACKSLASH_TOKEN','##!!**bAcKsLaSh**!!##'); // used in cvs_split
/**
* DB independent backup and restore of eGW's DB
*
* @class db_backup
* @package phpgwapi
* @subpackage db
* @author RalfBecker-AT-outdoor-training.de
* @license GPL
*/
@ -28,11 +31,10 @@
var $exclude_tables = array( /** exclude from backup */
'phpgw_sessions','phpgw_app_sessions', // eGW's session-tables
'phpgw_anglemail', // email's cache
'phpgw_felamimail_cache','phpgw_felamimail_folderstatus', // felamimail's cache
'egw_felamimail_cache','egw_felamimail_folderstatus','phpgw_felamimail_cache','phpgw_felamimail_folderstatus', // felamimail's cache
);
var $system_tables = false; /** regular expression to identify system-tables => ignored for schema+backup */
var $egw_tables = false; /** regurar expression to identify eGW tables => if set only they are used */
var $backslash_token = '##!!**bAcKsLaSh**!!##'; // used in cvs_split
/**
* Constructor
@ -52,7 +54,7 @@
$this->adodb = &$GLOBALS['egw']->ADOdb;
if (is_object($GLOBALS['egw_setup'])) // called from setup
{
if ($GLOBALS['egw_setup']->config_table)
if ($GLOBALS['egw_setup']->config_table && $GLOBALS['egw_setup']->table_exist(array($GLOBALS['egw_setup']->config_table)))
{
$this->db->query("SELECT config_value FROM {$GLOBALS['egw_setup']->config_table} WHERE config_app='phpgwapi' AND config_name='backup_dir'",__LINE__,__FILE__);
$this->db->next_record();
@ -71,17 +73,21 @@
$this->db->next_record();
$this->charset = $this->db->f(0);
}
$this->db->select($GLOBALS['egw_setup']->applications_table,'app_version',array('app_name'=>'phpgwapi'),__LINE__,__FILE__);
$this->api_version = $this->db->next_record() ? $this->db->f(0) : false;
}
if (!$this->charset) $this->charset = 'iso-8859-1';
}
else // called from eGW
{
$this->schema_proc = CreateObject('phpgwapi.schema_proc');
if (!($this->backup_dir = $GLOBALS['phpgw_info']['server']['backup_dir']))
if (!($this->backup_dir = $GLOBALS['egw_info']['server']['backup_dir']))
{
$this->backup_dir = $GLOBALS['phpgw_info']['server']['files_dir'].'/db_backup';
$this->backup_dir = $GLOBALS['egw_info']['server']['files_dir'].'/db_backup';
}
$this->charset = $GLOBALS['egw']->translation->charset();
$this->api_version = $GLOBALS['egw_info']['apps']['phpgwapi']['version'];
}
if (!is_dir($this->backup_dir) && is_writable(dirname($this->backup_dir)))
{
@ -162,13 +168,23 @@
if (empty($line)) continue;
if (substr($line,0,9) == 'version: ')
{
$api_version = trim(substr($line,9));
continue;
}
if (substr($line,0,9) == 'charset: ')
{
$charset = substr($line,9);
$charset = trim(substr($line,9));
// needed if mbstring.func_overload > 0, else eg. substr does not work with non ascii chars
@ini_set('mbstring.internal_encoding',$charset);
// set the DB's client encoding
$this->db->Link_ID->SetCharSet($charset);
// set the DB's client encoding (for mysql only if api_version >= 1.0.1.019)
if (substr($this->db->Type,0,5) != 'mysql' || !is_object($GLOBALS['egw_setup']) ||
$api_version && !$GLOBALS['egw_setup']->alessthanb($api_version,'1.0.1.019'))
{
$this->db->Link_ID->SetCharSet($charset);
$this->schema_proc->system_charset = $charset; // so schema_proc uses it for the creation of the tables
}
continue;
}
if (substr($line,0,8) == 'schema: ')
@ -181,7 +197,7 @@
$this->schema_proc->CreateTable($table_name,$schema);
}
// make the schemas availible for the db-class
$GLOBALS['phpgw_info']['apps']['all-apps']['table_defs'] = &$this->schemas;
$GLOBALS['egw_info']['apps']['all-apps']['table_defs'] = &$this->schemas;
continue;
}
if (substr($line,0,7) == 'table: ')
@ -244,21 +260,12 @@
if ($field[0] == '"')
{
if (substr($field,-1) !== '"' || $field === '"')
if (substr($field,-1) !== '"' || $field === '"' || !preg_match('/[^\\\\]+(\\\\\\\\)*"$/',$field))
{
$str_pending = $field;
continue;
}
// count the number of backslashes before the finishing double-quote
// it's not escaped if the number is even (incl. zero)
for($anz_bslash = 0, $i = strlen($field)-2; $i >= 0 && $field[$i] == '\\'; --$i,++$anz_bslash);
if ($anz_bslash & 1) // ending double quote is escaped and does not end the string
{
$str_pending = $field;
continue;
}
$arr[$key] = str_replace($this->backslash_token,'\\',str_replace(array('\\\\','\\n','\\r','\\"'),array($this->backslash_token,"\n","\r",'"'),substr($field,1,-1)));
$arr[$key] = str_replace(BACKSLASH_TOKEN,'\\',str_replace(array('\\\\','\\n','\\r','\\"'),array(BACKSLASH_TOKEN,"\n","\r",'"'),substr($field,1,-1)));
}
else
{
@ -304,9 +311,11 @@
{
@set_time_limit(0);
fwrite($f,"eGroupWare backup from ".date('Y-m-d H:i:s')."\n");
fwrite($f,"eGroupWare backup from ".date('Y-m-d H:i:s')."\n\n");
fwrite($f,"\ncharset: $this->charset\n\n");
fwrite($f,"version: $this->api_version\n\n");
fwrite($f,"charset: $this->charset\n\n");
$this->schema_backup($f); // add the schema in a human readable form too
@ -445,3 +454,9 @@
return $def;
}
}
/*
$line = '"de","ranking","use \\"yes\\", or \\"no, prefession\\"","benützen Sie \\"yes\\" oder \\"no, Beruf\\""';
echo "<p>line='$line'</p>\n";
echo "<pre>".print_r(db_backup::csv_split($line),true)."</pre>\n";
*/

View File

@ -164,6 +164,20 @@
register_shutdown_function(array($this->common, 'egw_final'));
$this->db->connect(); // we need to re-connect
// Set the DB's client charset if a system-charset is set
$this->db->select($this->config_table,'config_value',array(
'config_app' => 'phpgwapi',
'config_name' => 'system_charset',
),__LINE__,__FILE__);
if ($this->db->next_record() && $this->db->f(0))
{
$this->db->Link_ID->SetCharSet($this->db->f(0));
}
if ($GLOBALS['egw_info']['system']['system_charset'])
{
$this->db->Link_ID->SetCharSet($GLOBALS['egw_info']['system']['system_charset']);
}
foreach(array('translation','hooks','auth','accounts','acl','session','preferences','applications','contenthistory','contacts') as $class)
{
if (is_object($this->$class->db))

View File

@ -20,7 +20,8 @@
/**
* eGW's ADOdb based schema-processor
*
* @class schema_proc
* @package phpgwapi
* @subpackage db
* @author RalfBecker-AT-outdoor-training.de and others
* @license GPL
*/
@ -36,6 +37,8 @@
);
var $sType; // type of the database, set by the the constructor
var $max_varchar_length = 255; // maximum length of a varchar column, everything above get converted to text
var $system_charset;
/**
* Constructor of schema-processor
@ -65,6 +68,14 @@
$this->max_varchar_length = 8000;
break;
}
if (is_object($GLOBALS['egw_setup']))
{
$this->system_charset =& $GLOBALS['egw_setup']->system_charset;
}
elseif (isset($GLOBALS['egw_info']['server']['system_charset']))
{
$this->system_charset = $GLOBALS['egw_info']['server']['system_charset'];
}
}
/**
@ -80,8 +91,14 @@
{
$this->debug_message('schema_proc::CreateTable(%1,%2)',False,$sTableName, $aTableDef);
}
// for mysql 4.0+ we set the charset for the table
if ($this->system_charset && substr($this->sType,0,5) == 'mysql' &&
(float) $this->m_odb->ServerInfo['version'] >= 4.0 && $this->m_odb->Link_ID->charset2mysql[$this->system_charset])
{
$set_table_charset = array($this->sType => 'CHARACTER SET '.$this->m_odb->Link_ID->charset2mysql[$this->system_charset]);
}
// creating the table
$aSql = $this->dict->CreateTableSQL($sTableName,$ado_cols = $this->_egw2adodb_columndef($aTableDef));
$aSql = $this->dict->CreateTableSQL($sTableName,$ado_cols = $this->_egw2adodb_columndef($aTableDef),$set_table_charset);
if (!($retVal = $this->ExecuteSQLArray($aSql,2,'CreateTableSQL(%1,%2) sql=%3',False,$sTableName,$ado_cols,$aSql)))
{
return $retVal;
@ -570,7 +587,7 @@
* Creates all tables for one application
*
* @param array $aTables array of eGW table-definitions
* @param boolean $bOutputHTML should we give diagnostics, default False
* @param boolean $bOutputHTML=false should we give diagnostics, default False
* @return boolean True on success, False if an (fatal) error occured
*/
function ExecuteScripts($aTables, $bOutputHTML=False)
@ -661,12 +678,12 @@
* if the row exists db::update is called else a new row with $date merged with $where gets inserted (data has precedence)
* @param int $line line-number to pass to query
* @param string $file file-name to pass to query
* @param string $app string with name of app, this need to be set in setup anyway!!!
* @param string $app=false string with name of app, this need to be set in setup anyway!!!
* @return ADORecordSet or false, if the query fails
*/
function insert($table,$data,$where,$line,$file,$app)
function insert($table,$data,$where,$line,$file,$app=False,$use_prepared_statement=false)
{
return $this->m_odb->insert($table,$data,$where,$line,$file,$app);
return $this->m_odb->insert($table,$data,$where,$line,$file,$app,$use_prepared_statement);
}
/**

View File

@ -25,10 +25,10 @@
/* $Id$ */
// define the maximal length of a message_id, all message_ids have to be unique
// in this length, our column is varchar 255, but addslashes might add some length
// in this length, our column is varchar 128
if (!defined('MAX_MESSAGE_ID_LENGTH'))
{
define('MAX_MESSAGE_ID_LENGTH',230);
define('MAX_MESSAGE_ID_LENGTH',128);
}
// some constanst for pre php4.3
if (!defined('PHP_SHLIB_SUFFIX'))
@ -46,6 +46,9 @@
var $loaded_apps = array();
var $line_rejected = array();
var $lang_array = array();
var $lang_table = 'egw_lang';
var $languages_table = 'egw_languages';
var $config_table = 'egw_config';
/**
* Constructor, sets up a copy of the db-object, gets the system-charset and tries to load the mbstring extension
@ -58,9 +61,6 @@
}
$this->db = is_object($GLOBALS['egw']->db) ? $GLOBALS['egw']->db : $GLOBALS['egw_setup']->db;
$this->db->set_app('phpgwapi');
$this->lang_table = 'phpgw_lang';
$this->languages_table = 'phpgw_languages';
$this->config_table = 'egw_config';
if (!isset($GLOBALS['egw_setup']))
{
@ -272,7 +272,7 @@
{
if (!is_array($this->langs))
{
$this->db->query("SELECT DISTINCT l.lang,lx.lang_name FROM phpgw_lang l,phpgw_languages lx WHERE l.lang = lx.lang_id",__LINE__,__FILE__);
$this->db->query("SELECT DISTINCT l.lang,lx.lang_name FROM $this->lang_table l,$this->languages_table lx WHERE l.lang = lx.lang_id",__LINE__,__FILE__);
if (!$this->db->num_rows())
{
return False;
@ -300,7 +300,7 @@
{
$distinct = $this->db->capabilities['distinct_on_text'] ? 'DISTINCT' : '';
$this->db->query("SELECT $distinct l.lang,lx.lang_name,l.content AS charset FROM phpgw_lang l,phpgw_languages lx WHERE l.lang = lx.lang_id AND l.message_id='charset'",__LINE__,__FILE__);
$this->db->query("SELECT $distinct l.lang,lx.lang_name,l.content AS charset FROM $this->lang_table l,$this->languages_table lx WHERE l.lang = lx.lang_id AND l.message_id='charset'",__LINE__,__FILE__);
if (!$this->db->num_rows())
{
return False;
@ -451,7 +451,7 @@
$addlang = False;
if ($upgrademethod == 'addonlynew')
{
//echo "<br>Test: addonlynew - select count(*) from phpgw_lang where lang='".$lang."'";
//echo "<br>Test: addonlynew - select count(*) from egw_lang where lang='".$lang."'";
$this->db->select($this->lang_table,'COUNT(*)',array(
'lang' => $lang,
),__LINE__,__FILE__);
@ -475,7 +475,7 @@
$setup_info = $GLOBALS['egw_setup']->detection->get_db_versions($setup_info);
$raw = array();
$apps = $only_app ? array($only_app) : array_keys($setup_info);
// Visit each app/setup dir, look for a phpgw_lang file
// Visit each app/setup dir, look for a egw_lang file
foreach($apps as $app)
{
$appfile = EGW_SERVER_ROOT . SEP . $app . SEP . 'setup' . SEP . 'phpgw_' . strtolower($lang) . '.lang';
@ -562,7 +562,7 @@
{
if($message_id && $content)
{
// echo "<br>adding - insert into phpgw_lang values ('$message_id','$app_name','$lang','$content')";
// echo "<br>adding - insert into egw_lang values ('$message_id','$app_name','$lang','$content')";
$result = $this->db->insert($this->lang_table,array(
'message_id' => $message_id,
'app_name' => $app_name,
@ -572,7 +572,7 @@
if ((int)$result <= 0)
{
echo "<br>Error inserting record: phpgw_lang values ('$message_id','$app_name','$lang','$content')";
echo "<br>Error inserting record: egw_lang values ('$message_id','$app_name','$lang','$content')";
}
}
}

View File

@ -1,195 +1,195 @@
<?php
/**************************************************************************\
* eGroupWare - Setup *
* http://www.egroupware.org *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/**************************************************************************\
* eGroupWare - Setup *
* http://www.egroupware.org *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('aa','Afar')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('ab','Abkhazian')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('af','Afrikaans')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('am','Amharic')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('ar','Arabic')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('as','Assamese')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('ay','Aymara')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('az','Azerbaijani')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('ba','Bashkir')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('be','Byelorussian')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('bg','Bulgarian')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('bh','Bihari')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('bi','Bislama')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('bn','Bengali / Bangla')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('bo','Tibetan')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('br','Breton')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('ca','Catalan')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('co','Corsican')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('cs','Czech')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('cy','Welsh')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('da','Danish')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('de','German')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('dz','Bhutani')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('el','Greek')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('en','English / US')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('eo','Esperanto')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('es-es','Espa&ntilde;ol')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('et','Estonian')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('eu','Basque')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('fa','Persian')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('fi','Finnish')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('fj','Fiji')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('fo','Faeroese')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('fr','French')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('fy','Frisian')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('ga','Irish')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('gd','Gaelic / Scots Gaelic')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('gl','Galician')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('gn','Guarani')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('gu','Gujarati')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('ha','Hausa')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('hi','Hindi')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('hr','Croatian')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('hu','Hungarian')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('hy','Armenian')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('ia','Interlingua')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('ie','Interlingue')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('ik','Inupiak')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('in','Indonesian')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('is','Icelandic')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('it','Italian')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('iw','Hebrew')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('ja','Japanese')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('ji','Yiddish')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('jw','Javanese')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('ka','Georgian')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('kk','Kazakh')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('kl','Greenlandic')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('km','Cambodian')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('kn','Kannada')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('ko','Korean')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('ks','Kashmiri')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('ku','Kurdish')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('ky','Kirghiz')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('la','Latin')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('ln','Lingala')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('lo','Laothian')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('lt','Lithuanian')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('lv','Latvian / Lettish')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('mg','Malagasy')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('mi','Maori')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('mk','Macedonian')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('ml','Malayalam')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('mn','Mongolian')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('mo','Moldavian')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('mr','Marathi')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('ms','Malay')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('mt','Maltese')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('my','Burmese')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('na','Nauru')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('ne','Nepali')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('nl','Dutch')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('no','Norwegian')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('oc','Occitan')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('om','Oromo / Afan')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('or','Oriya')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('pa','Punjabi')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('pl','Polish')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('ps','Pashto / Pushto')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('pt','Portuguese')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('pt-br','Brazil')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('qu','Quechua')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('rm','Rhaeto-Romance')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('rn','Kirundi')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('ro','Romanian')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('ru','Russian')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('rw','Kinyarwanda')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('sa','Sanskrit')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('sd','Sindhi')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('sg','Sangro')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('sh','Serbo-Croatian')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('si','Singhalese')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('sk','Slovak')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('sl','Slovenian')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('sm','Samoan')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('sn','Shona')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('so','Somali')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('sq','Albanian')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('sr','Serbian')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('ss','Siswati')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('st','Sesotho')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('su','Sudanese')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('sv','Swedish')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('sw','Swahili')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('ta','Tamil')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('te','Tegulu')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('tg','Tajik')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('th','Thai')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('ti','Tigrinya')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('tk','Turkmen')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('tl','Tagalog')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('tn','Setswana')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('to','Tonga')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('tr','Turkish')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('ts','Tsonga')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('tt','Tatar')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('tw','Twi')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('uk','Ukrainian')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('ur','Urdu')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('uz','Uzbek')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('vi','Vietnamese')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('vo','Volapuk')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('wo','Wolof')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('xh','Xhosa')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('yo','Yoruba')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('zh','Chinese(simplified)')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('zt','Chinese(Taiwan)')");
$oProc->query("INSERT INTO phpgw_languages (lang_id, lang_name) VALUES ('zu','Zulu')");
/* $Id$ */
foreach(array(
'aa' => 'Afar',
'ab' => 'Abkhazian',
'af' => 'Afrikaans',
'am' => 'Amharic',
'ar' => 'Arabic',
'as' => 'Assamese',
'ay' => 'Aymara',
'az' => 'Azerbaijani',
'ba' => 'Bashkir',
'be' => 'Byelorussian',
'bg' => 'Bulgarian',
'bh' => 'Bihari',
'bi' => 'Bislama',
'bn' => 'Bengali / Bangla',
'bo' => 'Tibetan',
'br' => 'Breton',
'ca' => 'Catalan',
'co' => 'Corsican',
'cs' => 'Czech',
'cy' => 'Welsh',
'da' => 'Danish',
'de' => 'German',
'dz' => 'Bhutani',
'el' => 'Greek',
'en' => 'English / US',
'eo' => 'Esperanto',
'es-es' => 'Espa&ntilde;ol',
'et' => 'Estonian',
'eu' => 'Basque',
'fa' => 'Persian',
'fi' => 'Finnish',
'fj' => 'Fiji',
'fo' => 'Faeroese',
'fr' => 'French',
'fy' => 'Frisian',
'ga' => 'Irish',
'gd' => 'Gaelic / Scots Gaelic',
'gl' => 'Galician',
'gn' => 'Guarani',
'gu' => 'Gujarati',
'ha' => 'Hausa',
'hi' => 'Hindi',
'hr' => 'Croatian',
'hu' => 'Hungarian',
'hy' => 'Armenian',
'ia' => 'Interlingua',
'ie' => 'Interlingue',
'ik' => 'Inupiak',
'in' => 'Indonesian',
'is' => 'Icelandic',
'it' => 'Italian',
'iw' => 'Hebrew',
'ja' => 'Japanese',
'ji' => 'Yiddish',
'jw' => 'Javanese',
'ka' => 'Georgian',
'kk' => 'Kazakh',
'kl' => 'Greenlandic',
'km' => 'Cambodian',
'kn' => 'Kannada',
'ko' => 'Korean',
'ks' => 'Kashmiri',
'ku' => 'Kurdish',
'ky' => 'Kirghiz',
'la' => 'Latin',
'ln' => 'Lingala',
'lo' => 'Laothian',
'lt' => 'Lithuanian',
'lv' => 'Latvian / Lettish',
'mg' => 'Malagasy',
'mi' => 'Maori',
'mk' => 'Macedonian',
'ml' => 'Malayalam',
'mn' => 'Mongolian',
'mo' => 'Moldavian',
'mr' => 'Marathi',
'ms' => 'Malay',
'mt' => 'Maltese',
'my' => 'Burmese',
'na' => 'Nauru',
'ne' => 'Nepali',
'nl' => 'Dutch',
'no' => 'Norwegian',
'oc' => 'Occitan',
'om' => 'Oromo / Afan',
'or' => 'Oriya',
'pa' => 'Punjabi',
'pl' => 'Polish',
'ps' => 'Pashto / Pushto',
'pt' => 'Portuguese',
'pt-br' => 'Brazil',
'qu' => 'Quechua',
'rm' => 'Rhaeto-Romance',
'rn' => 'Kirundi',
'ro' => 'Romanian',
'ru' => 'Russian',
'rw' => 'Kinyarwanda',
'sa' => 'Sanskrit',
'sd' => 'Sindhi',
'sg' => 'Sangro',
'sh' => 'Serbo-Croatian',
'si' => 'Singhalese',
'sk' => 'Slovak',
'sl' => 'Slovenian',
'sm' => 'Samoan',
'sn' => 'Shona',
'so' => 'Somali',
'sq' => 'Albanian',
'sr' => 'Serbian',
'ss' => 'Siswati',
'st' => 'Sesotho',
'su' => 'Sudanese',
'sv' => 'Swedish',
'sw' => 'Swahili',
'ta' => 'Tamil',
'te' => 'Tegulu',
'tg' => 'Tajik',
'th' => 'Thai',
'ti' => 'Tigrinya',
'tk' => 'Turkmen',
'tl' => 'Tagalog',
'tn' => 'Setswana',
'to' => 'Tonga',
'tr' => 'Turkish',
'ts' => 'Tsonga',
'tt' => 'Tatar',
'tw' => 'Twi',
'uk' => 'Ukrainian',
'ur' => 'Urdu',
'uz' => 'Uzbek',
'vi' => 'Vietnamese',
'vo' => 'Volapuk',
'wo' => 'Wolof',
'xh' => 'Xhosa',
'yo' => 'Yoruba',
'zh' => 'Chinese(simplified)',
'zt' => 'Chinese(Taiwan)',
'zu' => 'Zulu',
) as $id => $name)
{
$oProc->insert($GLOBALS['egw_setup']->languages_table,array('lang_name' => $name),array('lang_id' => $id),__LINE__,__FILLE_);
}
foreach(array(
'sessions_checkip' => 'True',
'image_type' => '1',
'asyncservice' => 'fallback',
) as $name => $value)
{
$oProc->insert($GLOBALS['egw_setup']->config_table,array(
'config_value' => $value,
),array(
'config_app' => 'phpgwapi',
'config_name' => $name,
),__FILE__,__LINE__);
}
foreach(array(
'sessions_checkip' => 'True',
'image_type' => '1',
'asyncservice' => 'fallback',
) as $name => $value)
{
$oProc->insert($GLOBALS['egw_setup']->config_table,array(
'config_value' => $value,
),array(
'config_app' => 'phpgwapi',
'config_name' => $name,
),__LINE__,__FILE__);
}
$oProc->query("INSERT INTO phpgw_interserv(server_name,server_host,server_url,trust_level,trust_rel,server_mode) VALUES ('eGW demo',NULL,'http://www.egroupware.org/egroupware/xmlrpc.php',99,0,'xmlrpc')");
$oProc->query("INSERT INTO phpgw_interserv(server_name,server_host,server_url,trust_level,trust_rel,server_mode) VALUES ('eGW demo',NULL,'http://www.egroupware.org/egroupware/xmlrpc.php',99,0,'xmlrpc')");
// where is this empty directory for?
$oProc->query ("INSERT INTO phpgw_vfs (owner_id, createdby_id, modifiedby_id, created, modified, size, mime_type, deleteable, comment, app, directory, name, link_directory, link_name) VALUES (0,0,0,'1970-01-01',NULL,NULL,'Directory','Y',NULL,NULL,'/','', NULL, NULL)");
$oProc->query ("INSERT INTO phpgw_vfs (owner_id, createdby_id, modifiedby_id, created, modified, size, mime_type, deleteable, comment, app, directory, name, link_directory, link_name) VALUES (0,0,0,'1970-01-01',NULL,NULL,'Directory','Y',NULL,NULL,'/','home', NULL, NULL)");
// insert the VFS basedir /home
$oProc->query ("INSERT INTO egw_vfs (owner_id, createdby_id, modifiedby_id, created, modified, size, mime_type, deleteable, comment, app, directory, name, link_directory, link_name) VALUES (0,0,0,'1970-01-01',NULL,NULL,'Directory','Y',NULL,NULL,'/','', NULL, NULL)");
$oProc->query ("INSERT INTO egw_vfs (owner_id, createdby_id, modifiedby_id, created, modified, size, mime_type, deleteable, comment, app, directory, name, link_directory, link_name) VALUES (0,0,0,'1970-01-01',NULL,NULL,'Directory','Y',NULL,NULL,'/','home', NULL, NULL)");
/*************************************************************************\
* Default Records for VFS v2 *
\*************************************************************************/
if ($GLOBALS['DEBUG'])
{
echo "<br>\n<b>initiating to create the default records for VFS SQL2...";
}
include PHPGW_INCLUDE_ROOT.'/phpgwapi/setup/default_records_mime.inc.php';
/*************************************************************************\
* Default Records for VFS v2 *
\*************************************************************************/
if ($GLOBALS['DEBUG'])
{
echo "<br>\n<b>initiating to create the default records for VFS SQL2...";
}
$oProc->query("INSERT INTO phpgw_vfs2_files (mime_id,owner_id,createdby_id,size,directory,name)
SELECT mime_id,0,0,4096,'/','' FROM phpgw_vfs2_mimetypes WHERE mime='Directory'");
include EGW_INCLUDE_ROOT.'/phpgwapi/setup/default_records_mime.inc.php';
if ($GLOBALS['DEBUG'])
{
echo " DONE!</b>";
}
/*************************************************************************/
$oProc->query("INSERT INTO phpgw_vfs2_files (mime_id,owner_id,createdby_id,size,directory,name)
SELECT mime_id,0,0,4096,'/' => '' FROM phpgw_vfs2_mimetypes WHERE mime='Directory'");
?>
if ($GLOBALS['DEBUG'])
{
echo " DONE!</b>";
}
/*************************************************************************/

View File

@ -14,7 +14,7 @@
/* Basic information about this app */
$setup_info['phpgwapi']['name'] = 'phpgwapi';
$setup_info['phpgwapi']['title'] = 'API';
$setup_info['phpgwapi']['version'] = '1.0.1.014';
$setup_info['phpgwapi']['version'] = '1.0.1.019';
$setup_info['phpgwapi']['versions']['current_header'] = '1.28';
$setup_info['phpgwapi']['enable'] = 3;
$setup_info['phpgwapi']['app_order'] = 1;
@ -29,8 +29,8 @@
$setup_info['phpgwapi']['tables'][] = 'phpgw_app_sessions';
$setup_info['phpgwapi']['tables'][] = 'phpgw_access_log';
$setup_info['phpgwapi']['tables'][] = 'phpgw_hooks';
$setup_info['phpgwapi']['tables'][] = 'phpgw_languages';
$setup_info['phpgwapi']['tables'][] = 'phpgw_lang';
$setup_info['phpgwapi']['tables'][] = 'egw_languages';
$setup_info['phpgwapi']['tables'][] = 'egw_lang';
$setup_info['phpgwapi']['tables'][] = 'phpgw_nextid';
$setup_info['phpgwapi']['tables'][] = 'phpgw_categories';
$setup_info['phpgwapi']['tables'][] = 'phpgw_addressbook';
@ -76,3 +76,7 @@

View File

@ -138,7 +138,7 @@
'fk' => array(),
'uc' => array()
),
'phpgw_languages' => array(
'egw_languages' => array(
'fd' => array(
'lang_id' => array('type' => 'varchar','precision' => '5','nullable' => False),
'lang_name' => array('type' => 'varchar','precision' => '50','nullable' => False)
@ -148,11 +148,11 @@
'ix' => array(),
'uc' => array()
),
'phpgw_lang' => array(
'egw_lang' => array(
'fd' => array(
'lang' => array('type' => 'varchar','precision' => '5','nullable' => False,'default' => ''),
'app_name' => array('type' => 'varchar','precision' => '100','nullable' => False,'default' => 'common'),
'message_id' => array('type' => 'varchar','precision' => '255','nullable' => False,'default' => ''),
'app_name' => array('type' => 'varchar','precision' => '32','nullable' => False,'default' => 'common'),
'message_id' => array('type' => 'varchar','precision' => '128','nullable' => False,'default' => ''),
'content' => array('type' => 'text')
),
'pk' => array('lang','app_name','message_id'),
@ -328,7 +328,7 @@
'vfs_comment' => array('type' => 'varchar','precision' => '255'),
'vfs_app' => array('type' => 'varchar','precision' => '25'),
'vfs_directory' => array('type' => 'varchar','precision' => '255'),
'vfs_name' => array('type' => 'varchar','precision' => '128','nullable' => False),
'vfs_name' => array('type' => 'varchar','precision' => '64','nullable' => False),
'vfs_link_directory' => array('type' => 'varchar','precision' => '255'),
'vfs_link_name' => array('type' => 'varchar','precision' => '128'),
'vfs_version' => array('type' => 'varchar','precision' => '30','nullable' => False,'default' => '0.0.0.0'),
@ -336,7 +336,7 @@
),
'pk' => array('vfs_file_id'),
'fk' => array(),
'ix' => array(array('vfs_directory','vfs_name','vfs_mime_type')),
'ix' => array(array('vfs_directory','vfs_name')),
'uc' => array()
),
'phpgw_history_log' => array(
@ -407,14 +407,14 @@
'owner_id' => array('type' => 'int','precision' => '4','nullable' => False),
'createdby_id' => array('type' => 'int','precision' => '4'),
'modifiedby_id' => array('type' => 'int','precision' => '4'),
'created' => array('type' => 'timestamp','default' => '1970-01-01 00:00:00','nullable' => False),
'modified' => array('type' => 'timestamp','nullable' => True),
'created' => array('type' => 'timestamp','nullable' => False,'default' => '1970-01-01 00:00:00'),
'modified' => array('type' => 'timestamp'),
'size' => array('type' => 'int','precision' => '8'),
'deleteable' => array('type' => 'char','precision' => '1','default' => 'Y'),
'comment' => array('type' => 'varchar','precision' => '255'),
'app' => array('type' => 'varchar','precision' => '25'),
'directory' => array('type' => 'varchar','precision' => '255'),
'name' => array('type' => 'varchar','precision' => '128','nullable' => False),
'name' => array('type' => 'varchar','precision' => '64','nullable' => False),
'link_directory' => array('type' => 'varchar','precision' => '255'),
'link_name' => array('type' => 'varchar','precision' => '128'),
'version' => array('type' => 'varchar','precision' => '30','nullable' => False,'default' => '0.0.0.0'),
@ -424,7 +424,7 @@
'proper_id' => array('type' => 'varchar','precision' => '45')
),
'pk' => array('file_id'),
'fk' => array('mime_id' => array('phpgw_vfs2_mimetypes' => 'mime_id')),
'fk' => array(),
'ix' => array(array('directory','name')),
'uc' => array()
),
@ -508,15 +508,15 @@
),
'egw_contentmap' => array(
'fd' => array(
'map_id' => array('type' => 'varchar','precision' => '255','nullable' => False),
'map_guid' => array('type' => 'varchar','precision' => '200','nullable' => False),
'map_locuid' => array('type' => 'varchar','precision' => '200','nullable' => False),
'map_id' => array('type' => 'varchar','precision' => '128','nullable' => False),
'map_guid' => array('type' => 'varchar','precision' => '128','nullable' => False),
'map_locuid' => array('type' => 'int','precision' => '8','nullable' => False),
'map_timestamp' => array('type' => 'timestamp','nullable' => False),
'map_expired' => array('type' => 'bool','nullable' => False)
),
'pk' => array(array('map_id','map_guid','map_locuid')),
'pk' => array('map_id','map_guid','map_locuid'),
'fk' => array(),
'ix' => array(array('map_id','map_locuid'),'map_expired'),
'ix' => array('map_expired',array('map_id','map_locuid')),
'uc' => array()
),
'egw_syncmldevinfo' => array(
@ -565,5 +565,5 @@
'fk' => array(),
'ix' => array(array('link_app1','link_id1','link_lastmod'),array('link_app2','link_id2','link_lastmod')),
'uc' => array()
),
)
);

View File

@ -605,3 +605,171 @@
$GLOBALS['setup_info']['phpgwapi']['currentver'] = '1.0.1.014';
return $GLOBALS['setup_info']['phpgwapi']['currentver'];
}
$test[] = '1.0.1.014';
function phpgwapi_upgrade1_0_1_014()
{
// index was to big for mysql with charset utf8 (max 1000byte = 333 utf8 chars)
$GLOBALS['egw_setup']->oProc->AlterColumn('phpgw_lang','app_name',array(
'type' => 'varchar',
'precision' => '32',
'nullable' => False,
'default' => 'common'
));
$GLOBALS['egw_setup']->oProc->AlterColumn('phpgw_lang','message_id',array(
'type' => 'varchar',
'precision' => '128',
'nullable' => False,
'default' => ''
));
$GLOBALS['egw_setup']->oProc->RenameTable('phpgw_lang','egw_lang');
$GLOBALS['egw_setup']->lang_table = 'egw_lang';
$GLOBALS['egw_setup']->oProc->RenameTable('phpgw_languages','egw_languages');
$GLOBALS['egw_setup']->languages_table = 'egw_languages';
$GLOBALS['setup_info']['phpgwapi']['currentver'] = '1.0.1.015';
return $GLOBALS['setup_info']['phpgwapi']['currentver'];
}
$test[] = '1.0.1.015';
function phpgwapi_upgrade1_0_1_015()
{
// index was to big for mysql with charset utf8 (max 1000byte = 333 utf8 chars)
/* done by RefreshTable() anyway
$GLOBALS['egw_setup']->oProc->AlterColumn('egw_contentmap','map_id',array(
'type' => 'varchar',
'precision' => '128',
'nullable' => False
));*/
/* done by RefreshTable() anyway
$GLOBALS['egw_setup']->oProc->AlterColumn('egw_contentmap','map_guid',array(
'type' => 'varchar',
'precision' => '128',
'nullable' => False
));*/
/* done by RefreshTable() anyway
$GLOBALS['egw_setup']->oProc->AlterColumn('egw_contentmap','map_locuid',array(
'type' => 'int',
'precision' => '8',
'nullable' => False
));*/
$GLOBALS['egw_setup']->oProc->RefreshTable('egw_contentmap',array(
'fd' => array(
'map_id' => array('type' => 'varchar','precision' => '128','nullable' => False),
'map_guid' => array('type' => 'varchar','precision' => '128','nullable' => False),
'map_locuid' => array('type' => 'int','precision' => '8','nullable' => False),
'map_timestamp' => array('type' => 'timestamp','nullable' => False),
'map_expired' => array('type' => 'bool','nullable' => False)
),
'pk' => array('map_id','map_guid','map_locuid'),
'fk' => array(),
'ix' => array('map_expired',array('map_id','map_locuid')),
'uc' => array()
));
$GLOBALS['setup_info']['phpgwapi']['currentver'] = '1.0.1.016';
return $GLOBALS['setup_info']['phpgwapi']['currentver'];
}
$test[] = '1.0.1.016';
function phpgwapi_upgrade1_0_1_016()
{
// index was to big for mysql with charset utf8 (max 1000byte = 333 utf8 chars)
$GLOBALS['egw_setup']->oProc->AlterColumn('phpgw_vfs2_files','name',array(
'type' => 'varchar',
'precision' => '64',
'nullable' => False
));
$GLOBALS['setup_info']['phpgwapi']['currentver'] = '1.0.1.017';
return $GLOBALS['setup_info']['phpgwapi']['currentver'];
}
$test[] = '1.0.1.017';
function phpgwapi_upgrade1_0_1_017()
{
// index was to big for mysql with charset utf8 (max 1000byte = 333 utf8 chars)
/* done by RefreshTable() anyway
$GLOBALS['egw_setup']->oProc->AlterColumn('egw_vfs','vfs_name',array(
'type' => 'varchar',
'precision' => '64',
'nullable' => False
));*/
$GLOBALS['egw_setup']->oProc->RefreshTable('egw_vfs',array(
'fd' => array(
'vfs_file_id' => array('type' => 'auto','nullable' => False),
'vfs_owner_id' => array('type' => 'int','precision' => '4','nullable' => False),
'vfs_createdby_id' => array('type' => 'int','precision' => '4'),
'vfs_modifiedby_id' => array('type' => 'int','precision' => '4'),
'vfs_created' => array('type' => 'date','nullable' => False,'default' => '1970-01-01'),
'vfs_modified' => array('type' => 'date'),
'vfs_size' => array('type' => 'int','precision' => '4'),
'vfs_mime_type' => array('type' => 'varchar','precision' => '64'),
'vfs_deleteable' => array('type' => 'char','precision' => '1','default' => 'Y'),
'vfs_comment' => array('type' => 'varchar','precision' => '255'),
'vfs_app' => array('type' => 'varchar','precision' => '25'),
'vfs_directory' => array('type' => 'varchar','precision' => '255'),
'vfs_name' => array('type' => 'varchar','precision' => '64','nullable' => False),
'vfs_link_directory' => array('type' => 'varchar','precision' => '255'),
'vfs_link_name' => array('type' => 'varchar','precision' => '128'),
'vfs_version' => array('type' => 'varchar','precision' => '30','nullable' => False,'default' => '0.0.0.0'),
'vfs_content' => array('type' => 'text')
),
'pk' => array('vfs_file_id'),
'fk' => array(),
'ix' => array(array('vfs_directory','vfs_name')),
'uc' => array()
));
$GLOBALS['setup_info']['phpgwapi']['currentver'] = '1.0.1.018';
return $GLOBALS['setup_info']['phpgwapi']['currentver'];
}
$test[] = '1.0.1.018';
function phpgwapi_upgrade1_0_1_018()
{
// This update fixes charset in mysql4+ tables, if the default client charset does not match the eGW system-charset.
// It is necessary as update, as we now set the system_charset as client charset, which causes the existing input to be returned wrong.
// We have to shorten the felamimail columns first, as this update would fail, because it's run before the felamimail update
// (shortening them twice, does no harm) !!!
if ($GLOBALS['egw_setup']->table_exist(array('phpgw_felamimail_cache')))
{
$GLOBALS['egw_setup']->oProc->AlterColumn('phpgw_felamimail_cache','fmail_accountname',array(
'type' => 'varchar',
'precision' => '128',
'nullable' => False
));
$GLOBALS['egw_setup']->oProc->AlterColumn('phpgw_felamimail_cache','fmail_foldername',array(
'type' => 'varchar',
'precision' => '128',
'nullable' => False
));
$GLOBALS['egw_setup']->oProc->AlterColumn('phpgw_felamimail_folderstatus','fmail_accountname',array(
'type' => 'varchar',
'precision' => '128',
'nullable' => False
));
$GLOBALS['egw_setup']->oProc->AlterColumn('phpgw_felamimail_folderstatus','fmail_foldername',array(
'type' => 'varchar',
'precision' => '128',
'nullable' => False
));
}
if (substr($GLOBALS['egw_setup']->db->Type,0,5) == 'mysql' && $GLOBALS['egw_setup']->system_charset && $GLOBALS['egw_setup']->db_charset_was &&
$GLOBALS['egw_setup']->system_charset != $GLOBALS['egw_setup']->db_charset_was)
{
include(EGW_SERVER_ROOT.'/setup/fix_mysql_charset.php');
// now the DB is fixed we can set the charset
$GLOBALS['egw_setup']->db->Link_ID->SetCharSet($GLOBALS['egw_setup']->system_charset);
}
$GLOBALS['setup_info']['phpgwapi']['currentver'] = '1.0.1.019';
return $GLOBALS['setup_info']['phpgwapi']['currentver'];
}
?>

177
setup/fix_mysql_charset.php Normal file
View File

@ -0,0 +1,177 @@
<?php
/**************************************************************************\
* eGroupWare - Setup - fixes a mysql DB to match our system_charset *
* http://www.eGroupWare.org *
* Written by RalfBecker@outdoor-training.de *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
// if we are NOT called as part of an update script, behave like a regular setup script
if (!isset($GLOBALS['egw_setup']) || !is_object($GLOBALS['egw_setup']))
{
$diagnostics = 1; // can be set to 0=non, 1=some (default for now), 2=all
$GLOBALS['egw_info'] = array(
'flags' => array(
'noheader' => True,
'nonavbar' => True,
'currentapp' => 'home',
'noapi' => True
));
include('./inc/functions.inc.php');
// Authorize the user to use setup app and load the database
// Does not return unless user is authorized
if (!$GLOBALS['egw_setup']->auth('Config') || @$_POST['cancel'])
{
Header('Location: index.php');
exit;
}
$GLOBALS['egw_setup']->loaddb();
$tpl_root = $GLOBALS['egw_setup']->html->setup_tpl_dir('setup');
$setup_tpl = CreateObject('phpgwapi.Template',$tpl_root);
$setup_tpl->set_file(array(
'T_head' => 'head.tpl',
'T_footer' => 'footer.tpl',
));
$GLOBALS['egw_setup']->html->show_header('',False,'config',$GLOBALS['egw_setup']->ConfigDomain . '(' . $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]['db_type'] . ')');
echo '<h3>'.'Fix mysql DB to match the eGroupWare system_charset'."</h3>\n";
$running_standalone = true;
echo "<p>DB-Type='{$GLOBALS['egw_setup']->db->Type}', eGroupWare system_charset='{$GLOBALS['egw_setup']->system_charset}', DB charset was '{$GLOBALS['egw_setup']->db_charset_was}'</p>\n";
}
$db =& $GLOBALS['egw_setup']->db;
$charset2mysql =& $GLOBALS['egw_setup']->db->Link_ID->charset2mysql;
$mysql2charset = array_flip($charset2mysql);
$mysql_system_charset = isset($charset2mysql[$GLOBALS['egw_setup']->system_charset]) ?
$charset2mysql[$GLOBALS['egw_setup']->system_charset] : $GLOBALS['egw_setup']->system_charset;
if (substr($db->Type,0,5) == 'mysql' && $GLOBALS['egw_setup']->system_charset && $GLOBALS['egw_setup']->db_charset_was &&
$GLOBALS['egw_setup']->system_charset != $GLOBALS['egw_setup']->db_charset_was)
{
$tables = array();
$db->query("SHOW TABLE STATUS",__LINE__,__FILE__);
while (($row = $db->row(true)))
{
$tables[$row['Name']] = $row['Collation'];
}
$tables_modified = 0;
foreach($tables as $table => $collation)
{
$columns = array();
$db->query("SHOW FULL FIELDS FROM `$table`",__LINE__,__FILE__);
while(($row = $db->row(true)))
{
$columns[] = $row;
}
//echo $table; _debug_array($columns);
$fulltext = $fulltext_back = array();
$db->query("SHOW KEYS FROM `$table`",__LINE__,__FILE__);
while(($row = $db->row(true)))
{
if ($row['Index_type'] == 'FULLTEXT')
{
$fulltext[$row['Column_name']] = $row['Key_name'];
}
}
$alter_table = $alter_table_back = array();
foreach($columns as $column)
{
if ($column['Collation'] && preg_match('/^(char|varchar|.*text)\(?([0-9]*)\)?$/i',$column['Type'],$matches))
{
list(,$type,$size) = $matches;
list($charset) = explode('_',$column['Collation']);
if (isset($mysql2charset[$charset])) $charset = $mysql2charset[$charset];
if ($charset != $GLOBALS['egw_setup']->system_charset)
{
$col = $column['Field'];
if ($type == 'varchar' || $type == 'char') // old schema_proc (pre 1.0.1) used also char
{
$type = 'varchar('.$size.')';
$bintype = 'varbinary('.$size.')';
}
else
{
$bintype = str_replace('text','blob',$type);
}
//echo "<p>$table.$col $type CHARACTER SET $charset $default $null</p>\n";
$default = !is_null($column['Default']) ? "DEFAULT '".$column['Default']."'" : '';
$null = $column['Null'] ? 'NULL' : 'NOT NULL';
if (isset($fulltext[$col]))
{
$idx_name = $fulltext[$col];
$idx_cols = array();
foreach($fulltext as $c => $i)
{
if ($i == $idx_name)
{
$idx_cols[] = $c;
unset($fulltext[$c]);
}
}
$fulltext_back[$idx_name] = $idx_cols;
$alter_table[] = " DROP INDEX `$idx_name`";
}
$alter_table[] = " CHANGE `$col` `$col` $bintype $default $null";
$alter_table_back[] = " CHANGE `$col` `$col` $type CHARACTER SET $mysql_system_charset $default $null";
}
}
}
list($charset) = explode('_',$collation);
if (isset($mysql2charset[$charset])) $charset = $mysql2charset[$charset];
if ($charset != $GLOBALS['egw_setup']->system_charset)
{
$alter_table[] = " DEFAULT CHARACTER SET $mysql_system_charset";
}
if (count($alter_table))
{
$alter_table = "ALTER TABLE $table\n".implode(",\n",$alter_table);
/*if ($running_standalone)*/ echo '<p>'.nl2br($alter_table)."</p>\n";
if (!$db->query($alter_table,__LINE__,__FILE__))
{
echo "<p>SQL Error: ".nl2br($alter_table)."</p>\n";
echo "<b>{$this->db->Type} Error</b>: {$this->db->Errno} ({$this->db->Error})</p>\n";
echo "<p>continuing ...</p>\n";
continue;
}
foreach($fulltext_back as $idx_name => $idx_cols)
{
$alter_table_back[] = " ADD FULLTEXT `$idx_name` (`".implode('`,`',$idx_cols)."`)";
}
if (count($alter_table_back))
{
$alter_table_back = "ALTER TABLE $table\n".implode(",\n",$alter_table_back);
/*if ($running_standalone)*/ echo '<p>'.nl2br($alter_table_back)."</p>\n";
if (!$db->query($alter_table_back,__LINE__,__FILE__))
{
echo "<p><b>SQL Error</b>: ".nl2br($alter_table_back)."</p>\n";
echo "<b>{$this->db->Type} Error</b>: {$this->db->Errno} ({$this->db->Error})</p>\n";
echo "<p>continuing ...</p>\n";
continue;
}
}
++$tables_modified;
}
}
}
if ($running_standalone)
{
echo "<p>$tables_modified tables changed to our system_charset {$GLOBALS['egw_setup']->system_charset}($mysql_system_charset)</p>\n";
$GLOBALS['egw_setup']->html->show_footer();
}

View File

@ -32,8 +32,8 @@
var $acl_table = 'egw_acl';
var $accounts_table = 'egw_accounts';
var $prefs_table = 'phpgw_preferences';
var $lang_table = 'phpgw_lang';
var $languages_table = 'phpgw_languages';
var $lang_table = 'egw_lang';
var $languages_table = 'egw_languages';
var $hooks_table = 'phpgw_hooks';
var $cats_table = 'phpgw_categories';
var $oProc;
@ -97,7 +97,21 @@
),__LINE__,__FILE__);
if ($this->db->next_record() && $this->db->f(0))
{
$this->db->Link_ID->SetCharSet($this->db->f(0));
$this->system_charset = $this->db->f(0);
$this->db_charset_was = $this->db->Link_ID->GetCharSet(); // needed for the update
// we can NOT set the DB charset for mysql, if the api version < 1.0.1.019, as it would mess up the DB content!!!
if (substr($this->db->Type,0,5) == 'mysql') // we need to check the api version
{
$this->db->select($this->applications_table,'app_version',array(
'app_name' => 'phpgwapi',
),__LINE__,__FILE__);
$api_version = $this->db->next_record() ? $this->db->f(0) : false;
}
if (!$api_version || !$this->alessthanb($api_version,'1.0.1.019'))
{
$this->db->Link_ID->SetCharSet($this->system_charset);
}
}
$this->db->Halt_On_Error = 'yes'; // setting the default again
}
@ -395,9 +409,13 @@
/**
* Clear system/user level cache so as to have it rebuilt with the next access
*
* AFAIK this code is not used anymore -- RalfBecker 2005/11/04
*/
function clear_session_cache()
{
return; // AFAIK this code is not used anymore -- RalfBecker 2005/11/04
$tables = Array();
$tablenames = $this->db->table_names();
foreach($tablenames as $key => $val)
@ -485,11 +503,6 @@
return False;
}
if($this->alessthanb($setup_info['phpgwapi']['currentver'],'0.9.10pre8') && ($setup_info['phpgwapi']['currentver'] != ''))
{
$this->applications_table = 'applications';
}
if(@$GLOBALS['DEBUG'])
{
echo '<br>app_registered(): checking ' . $appname . ', table: ' . $this->applications_table;
@ -497,8 +510,7 @@
}
$this->db->select($this->applications_table,'COUNT(*)',array('app_name' => $appname),__LINE__,__FILE__);
$this->db->next_record();
if($this->db->f(0))
if($this->db->next_record() && $this->db->f(0))
{
if(@$GLOBALS['DEBUG'])
{
@ -528,11 +540,6 @@
return False;
}
if($this->alessthanb($setup_info['phpgwapi']['currentver'],'0.9.10pre8') && ($setup_info['phpgwapi']['currentver'] != ''))
{
$this->applications_table = 'applications';
}
if($GLOBALS['DEBUG'])
{
echo '<br>update_app(): ' . $appname . ', version: ' . $setup_info[$appname]['currentver'] . ', table: ' . $this->applications_table . '<br>';
@ -574,11 +581,6 @@
return False;
}
if($this->alessthanb($setup_info['phpgwapi']['currentver'],'0.9.10pre8') && ($setup_info['phpgwapi']['currentver'] != ''))
{
$this->applications_table = 'applications';
}
if($tableschanged == True)
{
$GLOBALS['egw_info']['setup']['tableschanged'] = True;
@ -605,11 +607,6 @@
}
$setup_info = $GLOBALS['setup_info'];
if($this->alessthanb($setup_info['phpgwapi']['currentver'],'0.9.10pre8') && ($setup_info['phpgwapi']['currentver'] != ''))
{
$this->applications_table = 'applications';
}
//echo 'DELETING application: ' . $appname;
$this->db->delete($this->applications_table,array('app_name'=>$appname),__LINE__,__FILE__);
$this->clear_session_cache();
@ -981,7 +978,6 @@
$this->setup_account_object();
$account = $GLOBALS['egw']->accounts->name2id($account);
}
$rights = (int)$rights;
if(!is_object($this->db))
{
$this->loaddb();
@ -993,10 +989,21 @@
}
foreach($apps as $app)
{
$this->db->query("DELETE FROM $this->acl_table WHERE acl_appname='$app' AND acl_location='$location' AND acl_account=$account");
if ($rights)
$this->db->delete($this->acl_table,array(
'acl_appname' => $app,
'acl_location' => $location,
'acl_account' => $account,
),__LINE__,__FILE__);
if ((int) $rights)
{
$this->db->query("INSERT INTO $this->acl_table (acl_appname,acl_location,acl_account,acl_rights) VALUES('$app','$location',$account,$rights)");
$this->db->insert($this->acl_table,array(
'acl_rights' => $rights
),array(
'acl_appname' => $app,
'acl_location' => $location,
'acl_account' => $account,
),__LINE__,__FILE__);
}
}
}
@ -1039,7 +1046,12 @@
'languages_table' => array('egw_languages','phpgw_languages','languages'),
) as $name => $tables)
{
$this->$name = $this->table_exist($tables);
$table = $this->table_exist($tables);
if ($table && $table != $this->$name) // only overwrite the default name, if we realy got one (important for new installs)
{
$this->$name = $table;
}
//echo "<p>setup::set_table_names: $name = '{$this->$name}'</p>\n";
}
}

View File

@ -45,7 +45,7 @@
$GLOBALS['egw_setup']->set_table_names();
if($GLOBALS['egw_setup']->applications_table)
if($GLOBALS['egw_setup']->table_exist(array($GLOBALS['egw_setup']->applications_table)))
{
/* one of these tables exists. checking for post/pre beta version */
if($GLOBALS['egw_setup']->applications_table != 'applications')

View File

@ -51,12 +51,13 @@
/**
* the mother of all multipass upgrade parental loop functions
*
* @param $setup_info array of application info from setup.inc.php files
* @param $type optional, defaults to new(install), could also be 'upgrade'
* @param $DEBUG optional, print debugging info
* @param $force_en optional, install english language files
* @param array $setup_info array of application info from setup.inc.php files
* @param string $type='new' defaults to new(install), could also be 'upgrade'
* @param boolean $DEBUG=false print debugging info
* @param boolean $force_en=false install english language files
* @param string $system_charset=null charset to use
*/
function pass($setup_info,$method='new',$DEBUG=False,$force_en=False,$system_charset=false)
function pass($setup_info,$method='new',$DEBUG=False,$force_en=False,$system_charset=null)
{
if(!$method)
{
@ -294,8 +295,8 @@
/**
* process current table setup in each application/setup dir
*
* @param $appinfo array of application info from setup.inc.php files, etc.
* This duplicates the old newtables behavior, using schema_proc
* @param array $setup_info array of application info from setup.inc.php files, etc.
* @param boolean $DEBUG=false
*/
function current($setup_info,$DEBUG=False)
{
@ -626,23 +627,7 @@
return False;
}
$ret = $GLOBALS['egw_setup']->oProc->GenerateScripts($tables,$DEBUG);
if($ret)
{
$oret = $GLOBALS['egw_setup']->oProc->ExecuteScripts($tables,$DEBUG);
if($oret)
{
return True;
}
else
{
return False;
}
}
else
{
return False;
}
return $GLOBALS['egw_setup']->oProc->ExecuteScripts($tables,$DEBUG);
}
/**

View File

@ -25,7 +25,7 @@
if (!defined('MAX_MESSAGE_ID_LENGTH'))
{
define('MAX_MESSAGE_ID_LENGTH',230);
define('MAX_MESSAGE_ID_LENGTH',128);
}
class setup_translation

View File

@ -324,6 +324,7 @@
// Set the DB's client charset if a system-charset is set
if ($_REQUEST['system_charset'])
{
$GLOBALS['egw_setup']->system_charset = $_REQUEST['system_charset'];
$GLOBALS['egw_setup']->db->Link_ID->SetCharSet($_REQUEST['system_charset']);
}
$setup_info = $GLOBALS['egw_setup']->process->pass($setup_info,'new',$_REQUEST['debug'],True,$_REQUEST['system_charset']);
@ -334,7 +335,7 @@
// create a backup, before upgrading the tables
if ($_POST['backup'])
{
$db_backup = CreateObject('phpgwapi.db_backup');
$db_backup =& CreateObject('phpgwapi.db_backup');
if (is_resource($f = $db_backup->fopen_backup()))
{
echo '<p align="center">'.lang('backup started, this might take a view minutes ...')."</p>\n".str_repeat(' ',4096);
@ -384,7 +385,7 @@
function check_dir($dir,&$msg,$check_in_docroot=false)
{
if (!@is_dir($dir))
if (!@is_dir($dir) && !(@is_writeable(dirname($dir)) && @mkdir($dir,0700,true)))
{
$msg = lang('does not exist');
return false;
@ -445,6 +446,11 @@ function check_dir($dir,&$msg,$check_in_docroot=false)
{
$config[$GLOBALS['egw_setup']->db->f(0)] = $GLOBALS['egw_setup']->db->f(1);
}
$config_msg = '';
if (!check_dir($config['temp_dir'],$error_msg))
{
$config_msg = lang("Your temporary directory '%1' %2",$config['temp_dir'],$error_msg);
}
// set and create the default backup_dir
if (@is_writeable($config['files_dir']) && !isset($config['backup_dir']) && $config['file_store_contents'] == 'filesystem')
{
@ -459,11 +465,6 @@ function check_dir($dir,&$msg,$check_in_docroot=false)
),__LINE__,__FILE__);
}
}
$config_msg = '';
if (!check_dir($config['temp_dir'],$error_msg))
{
$config_msg = lang("Your temporary directory '%1' %2",$config['temp_dir'],$error_msg);
}
if (!check_dir($config['files_dir'],$error_msg,true))
{
$config_msg .= ($config_msg?"<br />\n":'').lang("Your files directory '%1' %2",$config['files_dir'],$error_msg);