diff --git a/etemplate/inc/class.boetemplate.inc.php b/etemplate/inc/class.boetemplate.inc.php index ed3e8713fd..3411ec8a28 100644 --- a/etemplate/inc/class.boetemplate.inc.php +++ b/etemplate/inc/class.boetemplate.inc.php @@ -157,8 +157,8 @@ $cont = array(); } if (!is_numeric($c)) $c = boetemplate::chrs2num($c); - $col = $this->num2chrs($c-1); // $c-1 to get: 0:'@', 1:'A', ... - $col_ = $this->num2chrs($c_-1); + $col = boetemplate::num2chrs($c-1); // $c-1 to get: 0:'@', 1:'A', ... + $col_ = boetemplate::num2chrs($c_-1); $row_cont = $cont[$row]; $col_row_cont = $cont[$col.$row]; diff --git a/etemplate/inc/class.date_widget.inc.php b/etemplate/inc/class.date_widget.inc.php index eb20b5c978..7f97dede6f 100644 --- a/etemplate/inc/class.date_widget.inc.php +++ b/etemplate/inc/class.date_widget.inc.php @@ -164,7 +164,7 @@ } if ($value['m'] && strchr($this->dateformat,'M') !== false) { - static $month = array('','January','February','March','April','Mai','June','July','August','September','October','November','December'); + static $month = array('','January','February','March','April','May','June','July','August','September','October','November','December'); static $substr; if (is_null($substr)) $substr = function_exists('mb_substr') ? 'mb_substr' : 'substr'; static $chars_shortcut; diff --git a/etemplate/inc/class.editor.inc.php b/etemplate/inc/class.editor.inc.php index 059296df59..8433e78976 100644 --- a/etemplate/inc/class.editor.inc.php +++ b/etemplate/inc/class.editor.inc.php @@ -320,7 +320,7 @@ $msg = $ok ? lang('Template saved') : lang('Error: while saving !!!'); if ($ok) unset($preserv['import']); } - elseif (isset($_GET['name']) || isset($content['name'])) + elseif (!$content['import_xml'] && (isset($_GET['name']) || isset($content['name']))) { if ($_GET['name']) { diff --git a/etemplate/inc/class.link_widget.inc.php b/etemplate/inc/class.link_widget.inc.php index f63108204e..917c2af043 100644 --- a/etemplate/inc/class.link_widget.inc.php +++ b/etemplate/inc/class.link_widget.inc.php @@ -113,6 +113,7 @@ function pre_process($name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl) { $extension_data['type'] = $type = $cell['type']; + $extension_data['needed'] = $cell['needed']; $help = $cell['help'] ? ($value['help'] ? $value['help'] : $cell['help']) : lang('view this linked entry in its application'); if (($type == 'link-to' || $type == 'link-add') && ($cell['readonly'] || $readonlys)) @@ -458,10 +459,20 @@ switch($extension_data['type']) { case 'link-entry': + if (!$value_in['id'] && $extension_data['needed']) + { + $tmpl->set_validation_error($name,lang('Field must not be empty !!!'),''); + return true; + } $value = $extension_data['app'] ? $value_in['id'] : $value['app'].':'.$value_in['id']; return !!$value_in['id']; case 'link-apps': + if (!$value_in && $extension_data['needed']) + { + $tmpl->set_validation_error($name,lang('Field must not be empty !!!'),''); + return true; + } $value = $value_in; return !!$value; } diff --git a/etemplate/inc/class.nextmatch_widget.inc.php b/etemplate/inc/class.nextmatch_widget.inc.php index ed920f2591..bbcc9b99f6 100644 --- a/etemplate/inc/class.nextmatch_widget.inc.php +++ b/etemplate/inc/class.nextmatch_widget.inc.php @@ -346,10 +346,9 @@ $cell['name'] = $nextmatch->name; } // preset everything for the column selection - if (!$value['no_columnselection']) + if (!$value['no_columnselection'] && // fetching column-names & -labels from the template + $this->_cols_from_tpl($value['template'],$value['options-selectcols'],$name2col,$value['rows'])) { - // fetching column-names & -labels from the template - $this->_cols_from_tpl($value['template'],$value['options-selectcols'],$name2col,$value['rows']); //_debug_array($name2col); //_debug_array($value['options-selectcols']); // getting the selected colums from the prefs (or if not set a given default or all) @@ -421,6 +420,7 @@ * @param array &$cols here we add the column-name/-label * @param array &$name2col * @param array $content nextmatch content, to be able to resolve labels with @name + * @return int columns found, count($cols) */ function _cols_from_tpl(&$tmpl,&$cols,&$name2col,&$content) { @@ -429,7 +429,7 @@ $cols['__content__'] =& $content; $tmpl->widget_tree_walk(array($this,'_cols_from_tpl_walker'),$cols); unset($cols['__content__']); - $name2col = $cols['name2col'] ? $cols['name2col'] : array(); unset($cols['name2col']); + $name2col = is_array($cols['name2col']) ? $cols['name2col'] : array(); unset($cols['name2col']); //_debug_array($cols); foreach($cols as $name => $label) { @@ -457,7 +457,8 @@ } $cols[$name] = $label; } - //_debug_array($cols); + //_debug_array($cols); + return count($cols); } /** diff --git a/etemplate/inc/class.soetemplate.inc.php b/etemplate/inc/class.soetemplate.inc.php index fb45b7e90c..4d19902c72 100644 --- a/etemplate/inc/class.soetemplate.inc.php +++ b/etemplate/inc/class.soetemplate.inc.php @@ -1174,16 +1174,16 @@ * * @param string/array $func function to use or array($obj,'method') * @param mixed &$extra extra parameter passed to function + * @param string $path='/' start-path * @return mixed return-value of func or null if nothing returned at all */ - function &widget_tree_walk($func,&$extra) + function &widget_tree_walk($func,&$extra,$path='/') { if (!is_callable($func)) { echo "

boetemplate($this->name)::widget_tree_walk(".print_r($func,true).", ".print_r($extra,true).", ".print_r($opts,true).") func is not callable !!!
".function_backtrace()."

"; return false; } - $path = '/'; foreach($this->children as $c => $nul) { $child = &$this->children[$c]; @@ -1304,7 +1304,7 @@ } if (!is_object($widget['obj'])) break; // cant descent into template - $result =& $widget['obj']->widget_tree_walk($func,$extra); + $result =& $widget['obj']->widget_tree_walk($func,$extra,$path.'/'); break; } return $result; diff --git a/etemplate/inc/class.xul_io.inc.php b/etemplate/inc/class.xul_io.inc.php index 097e0ebf80..335a9ec819 100644 --- a/etemplate/inc/class.xul_io.inc.php +++ b/etemplate/inc/class.xul_io.inc.php @@ -428,7 +428,7 @@ * * @param object &$etempl eTemplate object to set * @param string $data the XML - * @param array/string array with names of imported templates or error-message + * @return array/string array with names of imported templates or error-message */ function import(&$etempl,$data) { @@ -498,9 +498,8 @@ switch ($type) { case 'close': - if (!count($parents) || $parent['.is_root']) // templ import complet => save it + if (!count($parents)) // templ import complet => save it { - unset($parent['.is_root']); unset($parent); $parents = array(); $etempl->fix_old_template_format(); // set the depricated compat vars // save tmpl to the cache, as the file may contain more then one tmpl @@ -525,7 +524,7 @@ { $etempl->init($attr); $etempl->children = array(); // init adds one grid by default - $parent = &$etempl->children; + $parent = &$etempl; // parent is the template-object itself! } if ($tag == 'grid') { @@ -541,7 +540,6 @@ 'rows' => 0, 'size' => $size, ); - if ($is_root) $grid['.is_root'] = true; // we need to remember we have no template as parent soetemplate::add_child($parent,$grid); $parents[count($parents)] = &$parent; $parent = &$grid; diff --git a/etemplate/js/etemplate.js b/etemplate/js/etemplate.js index 5e3f08c947..ec8dc2db45 100644 --- a/etemplate/js/etemplate.js +++ b/etemplate/js/etemplate.js @@ -72,16 +72,19 @@ function activate_tab(tab,all_tabs,name) // activate FCK in newly activated tab for Gecko browsers if (!document.all) { - var t = document.getElementById(tab); - var inputs = t.getElementsByTagName('input'); - for (i = 0; i < inputs.length;i++) { - editor = FCKeditorAPI.GetInstance(inputs[i].name); - if (editor && editor.EditorDocument && editor.EditMode == FCK_EDITMODE_WYSIWYG) { - editor.SwitchEditMode(); - editor.SwitchEditMode(); - break; - } + try { + var t = document.getElementById(tab); + var inputs = t.getElementsByTagName('input'); + for (i = 0; i < inputs.length;i++) { + editor = FCKeditorAPI.GetInstance(inputs[i].name); + if (editor && editor.EditorDocument && editor.EditMode == FCK_EDITMODE_WYSIWYG) { + editor.SwitchEditMode(); + editor.SwitchEditMode(); + break; + } + } } + catch(e) { } // ignore the error if FCKeditorAPI is not loaded } if (name) { set_element(document.eTemplate,name,tab); diff --git a/infolog/inc/class.uiinfolog.inc.php b/infolog/inc/class.uiinfolog.inc.php index 91ed9df2e7..62aa8e11e3 100644 --- a/infolog/inc/class.uiinfolog.inc.php +++ b/infolog/inc/class.uiinfolog.inc.php @@ -1264,7 +1264,7 @@ class uiinfolog $bodyAppend = $bofelamimail->wordwrap($value,75,"\n"); $message .= $bodyAppend; } - } + } if (is_array($attachments)) { @@ -1288,7 +1288,7 @@ class uiinfolog $subject, $message, $attachments, - strtotime($headers->date) + strtotime($headers['DATE']) )); } $GLOBALS['egw']->common->egw_header(); diff --git a/infolog/inc/hook_settings.inc.php b/infolog/inc/hook_settings.inc.php index a59a65d857..83217ac469 100644 --- a/infolog/inc/hook_settings.inc.php +++ b/infolog/inc/hook_settings.inc.php @@ -124,7 +124,7 @@ 'type' => 'check', 'label' => 'Should the calendar show custom types too', 'name' => 'cal_show_custom', - 'help' => 'Do you want to see custome InfoLog types in the calendar?', + 'help' => 'Do you want to see custom InfoLog types in the calendar?', 'xmlrpc' => True, 'admin' => False ); diff --git a/infolog/setup/phpgw_de.lang b/infolog/setup/phpgw_de.lang index 7d9dc4651f..94a08214b2 100644 --- a/infolog/setup/phpgw_de.lang +++ b/infolog/setup/phpgw_de.lang @@ -94,7 +94,7 @@ description infolog de Beschreibung determines the order the fields are displayed infolog de legt die Reihenfolge fest in der die Felder angezeigt werden disables a status without deleting it infolog de deaktiviert einen Status ohne ihn zu löschen do you want a confirmation of the responsible on: accepting, finishing the task or both infolog de wollen Sie eine Bestätigung des Verantwortlichen bei: Annahme, Beendigung der Aufgabe oder bei beidem -do you want to see custome infolog types in the calendar? infolog de Wollen Sie benutzerdefinierte Typen auch im Kalender sehen? +do you want to see custom infolog types in the calendar? infolog de Wollen Sie benutzerdefinierte Typen auch im Kalender sehen? don't show infolog infolog de InfoLog NICHT anzeigen done infolog de erledigt download infolog de Datei laden @@ -244,7 +244,7 @@ should infolog show subtasks, -calls or -notes in the normal view or not. you ca should infolog show the links to other applications and/or the file-attachments in the infolog list (normal view when you enter infolog). infolog de Soll InfoLog die Verknüpfungen zu anderen Anwendungen und/oder die Datei-Anhänge in der InfoLog Liste (normale Ansicht wenn InfoLog aufgerufen wird) anzeigen. should infolog show up on the main screen and with which filter. works only if you dont selected an application for the main screen (in your preferences). infolog de Soll InfoLog auf der Startseite angezeigt werden und mit welchem Filter. Funktioniert nur, wenn Sie keine (einzelne) Anwendung für die Startseite ausgewählt haben (in Ihren Einstellungen). should infolog use full names (surname and familyname) or just the loginnames. infolog de Soll InfoLog den vollen Namen (Vor- und Familienname) oder nur die Benutzerkennung verwenden. -should the calendar show custom types too infolog de Soll der Kalender auch benutzerdefinierte Typen anzeiten +should the calendar show custom types too infolog de Soll der Kalender auch benutzerdefinierte Typen anzeigen should the infolog list show a unique numerical id, which can be used eg. as ticket id. infolog de Soll die InfoLog Liste eine eindeutige Nummer anzeigen, die zB. als Ticketnummer verwendet werden kann. should the infolog list show the column "last modified". infolog de Soll die InfoLog Liste die Spalte "Zuletzt geändert" anzeigen. should the infolog list show the percent done only for status ongoing or two separate icons. infolog de Soll die InfoLog Liste Prozent erledigt nur für den Status "in Arbeit" anzeigen oder zwei separate Icons. diff --git a/infolog/setup/phpgw_en.lang b/infolog/setup/phpgw_en.lang index 8dce6813ca..edf355147a 100644 --- a/infolog/setup/phpgw_en.lang +++ b/infolog/setup/phpgw_en.lang @@ -94,7 +94,7 @@ description infolog en Description determines the order the fields are displayed infolog en determines the order the fields are displayed disables a status without deleting it infolog en disables a status without deleting it do you want a confirmation of the responsible on: accepting, finishing the task or both infolog en do you want a confirmation of the responsible on: accepting, finishing the task or both -do you want to see custome infolog types in the calendar? infolog en Do you want to see custome InfoLog types in the calendar? +do you want to see custom infolog types in the calendar? infolog en Do you want to see custom InfoLog types in the calendar? don't show infolog infolog en DON'T show InfoLog done infolog en done download infolog en Download diff --git a/infolog/setup/phpgw_es-es.lang b/infolog/setup/phpgw_es-es.lang index 4e2963f5bf..e2588f1657 100644 --- a/infolog/setup/phpgw_es-es.lang +++ b/infolog/setup/phpgw_es-es.lang @@ -94,7 +94,7 @@ description infolog es-es Descripci determines the order the fields are displayed infolog es-es determina el orden en el que se muestran los campos disables a status without deleting it infolog es-es deshabilita un estado sin eliminarlo do you want a confirmation of the responsible on: accepting, finishing the task or both infolog es-es ¿Desea una confirmación del responsable al aceptar, terminar la tarea, o ambos? -do you want to see custome infolog types in the calendar? infolog es-es ¿Desea ver los tipos de tareas personalizadas en el calendario? +do you want to see custom infolog types in the calendar? infolog es-es ¿Desea ver los tipos de tareas personalizadas en el calendario? don't show infolog infolog es-es NO mostrar el Registro de notas y tareas done infolog es-es hecho download infolog es-es Descargar diff --git a/infolog/setup/phpgw_fi.lang b/infolog/setup/phpgw_fi.lang index ae8cac498c..d9e4f4dcb8 100644 --- a/infolog/setup/phpgw_fi.lang +++ b/infolog/setup/phpgw_fi.lang @@ -88,7 +88,7 @@ deletes this field infolog fi poistaa t deletes this status infolog fi poista tämä tila description infolog fi Kuvaus disables a status without deleting it infolog fi estä tila poistamatta sitä -do you want to see custome infolog types in the calendar? infolog fi Haluatko nähdä muokatut InfoLog merkinnän muodot kalenterissa? +do you want to see custom infolog types in the calendar? infolog fi Haluatko nähdä muokatut InfoLog merkinnän muodot kalenterissa? don't show infolog infolog fi ÄLÄ näytä InfoLogissa done infolog fi valmis download infolog fi Lataa diff --git a/infolog/setup/phpgw_fr.lang b/infolog/setup/phpgw_fr.lang index f79ed2bb80..32494f3487 100644 --- a/infolog/setup/phpgw_fr.lang +++ b/infolog/setup/phpgw_fr.lang @@ -94,7 +94,7 @@ description infolog fr Description determines the order the fields are displayed infolog fr détermine l´ordre d´affichage des champs disables a status without deleting it infolog fr désactive un statut sans le supprimer do you want a confirmation of the responsible on: accepting, finishing the task or both infolog fr Voulez-vous une confirmation du responsable sur: accepter, finir la tâche, ou les deux -do you want to see custome infolog types in the calendar? infolog fr Voulez-vous voir les types d'InfoLog personnalisé dans le calendrier? +do you want to see custom infolog types in the calendar? infolog fr Voulez-vous voir les types d'InfoLog personnalisé dans le calendrier? don't show infolog infolog fr NE PAS afficher InfoLog done infolog fr Fait download infolog fr Télécharger diff --git a/infolog/setup/phpgw_it.lang b/infolog/setup/phpgw_it.lang index a566d73e23..c2a6a4dafe 100644 --- a/infolog/setup/phpgw_it.lang +++ b/infolog/setup/phpgw_it.lang @@ -94,7 +94,7 @@ description infolog it Descrizione determines the order the fields are displayed infolog it determina l'ordine di visualizzazone dei campi disables a status without deleting it infolog it disabilita lo stato senza cancellarlo do you want a confirmation of the responsible on: accepting, finishing the task or both infolog it vuoi una conferma dal responsabile su: accettazione, completamento dei ToDo o entrambe -do you want to see custome infolog types in the calendar? infolog it Vuoi vedere tipi Attività personalizzati in agenda? +do you want to see custom infolog types in the calendar? infolog it Vuoi vedere tipi Attività personalizzati in agenda? don't show infolog infolog it NON mostrare Attività done infolog it eseguita download infolog it Download diff --git a/infolog/setup/phpgw_nl.lang b/infolog/setup/phpgw_nl.lang index 9cd928b244..2fe84b61d4 100644 --- a/infolog/setup/phpgw_nl.lang +++ b/infolog/setup/phpgw_nl.lang @@ -94,7 +94,7 @@ description infolog nl Beschrijving determines the order the fields are displayed infolog nl bepaald hoe de volgorde van de velden wordt weergegeven disables a status without deleting it infolog nl deactiveerd een status zonder het te verwijderen do you want a confirmation of the responsible on: accepting, finishing the task or both infolog nl Wilt een een bevestiging van de verantwoordelijke voor accepteren, voor beëindigen, of voor beide -do you want to see custome infolog types in the calendar? infolog nl Wilt u aangepaste InfoLog types in de agenda weergeven? +do you want to see custom infolog types in the calendar? infolog nl Wilt u aangepaste InfoLog types in de agenda weergeven? don't show infolog infolog nl InfoLog NIET weergeven done infolog nl gereed download infolog nl Downloaden diff --git a/infolog/setup/phpgw_pt-br.lang b/infolog/setup/phpgw_pt-br.lang index 13a3ee14c0..8478eb3129 100644 --- a/infolog/setup/phpgw_pt-br.lang +++ b/infolog/setup/phpgw_pt-br.lang @@ -94,7 +94,7 @@ description infolog pt-br Descri determines the order the fields are displayed infolog pt-br determine a ordem em que os campos aparecerão disables a status without deleting it infolog pt-br desabilitar o status após a remoção do you want a confirmation of the responsible on: accepting, finishing the task or both infolog pt-br você quer uma confirmação do responsável quanto à: aceitação, encerramento ou ambos -do you want to see custome infolog types in the calendar? infolog pt-br Você deseja exibir tipos de tarefas personalizadas na Agenda de Eventos ? +do you want to see custom infolog types in the calendar? infolog pt-br Você deseja exibir tipos de tarefas personalizadas na Agenda de Eventos ? don't show infolog infolog pt-br Não exibir Tarefas done infolog pt-br Encerrado download infolog pt-br Baixar diff --git a/infolog/setup/phpgw_sk.lang b/infolog/setup/phpgw_sk.lang index 53238a8c1c..971983417d 100644 --- a/infolog/setup/phpgw_sk.lang +++ b/infolog/setup/phpgw_sk.lang @@ -94,7 +94,7 @@ description infolog sk Opis determines the order the fields are displayed infolog sk Urèuje poradie v akom sa polo¾ky zobrazujú disables a status without deleting it infolog sk Zablokuje stav bez toho, aby sa zmazal do you want a confirmation of the responsible on: accepting, finishing the task or both infolog sk vy¾adujete potvrdenie zodpovedného k: prijatiu, ukonèeniu úlohy alebo oboje -do you want to see custome infolog types in the calendar? infolog sk ®eláte si zobrazova» vlastné typy Záznamníka v Kalendári? +do you want to see custom infolog types in the calendar? infolog sk ®eláte si zobrazova» vlastné typy Záznamníka v Kalendári? don't show infolog infolog sk NEzobrazova» Záznamník done infolog sk Hotovo download infolog sk Stiahnu» diff --git a/infolog/setup/phpgw_sl.lang b/infolog/setup/phpgw_sl.lang index cd5625216a..184f02e19d 100644 --- a/infolog/setup/phpgw_sl.lang +++ b/infolog/setup/phpgw_sl.lang @@ -94,7 +94,7 @@ description infolog sl Opis determines the order the fields are displayed infolog sl ugotovi vrstni red polj, ki so prikazana disables a status without deleting it infolog sl OnemogoÄi status brez brisanja do you want a confirmation of the responsible on: accepting, finishing the task or both infolog sl Ali želite potrdilo odgovornosti za: sprejemanje, konÄanje naloge ali oboje? -do you want to see custome infolog types in the calendar? infolog sl Želite videti vrste po meri InfoDnevnika v koledarju? +do you want to see custom infolog types in the calendar? infolog sl Želite videti vrste po meri InfoDnevnika v koledarju? don't show infolog infolog sl Ne prikaži InfoDnevnika done infolog sl KonÄano download infolog sl Prenos diff --git a/infolog/setup/phpgw_sv.lang b/infolog/setup/phpgw_sv.lang index 0ecf206ee6..b4b0a5ab62 100644 --- a/infolog/setup/phpgw_sv.lang +++ b/infolog/setup/phpgw_sv.lang @@ -94,7 +94,7 @@ description infolog sv Beskrivning determines the order the fields are displayed infolog sv Bestämmer i vilken ordning fält ska visas disables a status without deleting it infolog sv Inaktivera status utan att radera do you want a confirmation of the responsible on: accepting, finishing the task or both infolog sv Vill du få bekräftelse från ansvarig angående acceptering, avslut eller båda? -do you want to see custome infolog types in the calendar? infolog sv Vill du se anpassade InfoLogg typer i kalendern? +do you want to see custom infolog types in the calendar? infolog sv Vill du se anpassade InfoLogg typer i kalendern? don't show infolog infolog sv Visa INTE InfoLogg done infolog sv Färdig download infolog sv Ladda ner diff --git a/infolog/setup/phpgw_zh-tw.lang b/infolog/setup/phpgw_zh-tw.lang index d3a342c8d1..87da7e67da 100644 --- a/infolog/setup/phpgw_zh-tw.lang +++ b/infolog/setup/phpgw_zh-tw.lang @@ -94,7 +94,7 @@ description infolog zh-tw æè¿° determines the order the fields are displayed infolog zh-tw 決定顯示的順åºèˆ‡æ¬„ä½ disables a status without deleting it infolog zh-tw åœç”¨ä¸€å€‹ç‹€æ…‹è€Œä¸æ˜¯åˆªé™¤ do you want a confirmation of the responsible on: accepting, finishing the task or both infolog zh-tw 您希望åšå†æ¬¡çš„確èªåœ¨ï¼šåŒæ„,工作完æˆæˆ–æ˜¯å…©è€…éƒ½è¦ -do you want to see custome infolog types in the calendar? infolog zh-tw 您是å¦å¸Œæœ›åœ¨è¡Œäº‹æ›†ä¸­æª¢è¦–記事本的類型? +do you want to see custom infolog types in the calendar? infolog zh-tw 您是å¦å¸Œæœ›åœ¨è¡Œäº‹æ›†ä¸­æª¢è¦–記事本的類型? don't show infolog infolog zh-tw ä¸è¦é¡¯ç¤ºè¨˜äº‹æœ¬ done infolog zh-tw å®Œæˆ download infolog zh-tw 下載 diff --git a/phpgwapi/inc/adodb/datadict/datadict-postgres.inc.php b/phpgwapi/inc/adodb/datadict/datadict-postgres.inc.php index 66c9c00e68..fd1aa46b06 100644 --- a/phpgwapi/inc/adodb/datadict/datadict-postgres.inc.php +++ b/phpgwapi/inc/adodb/datadict/datadict-postgres.inc.php @@ -210,18 +210,21 @@ class ADODB2_postgres extends ADODB_DataDict { { if ($dropflds && !is_array($dropflds)) $dropflds = explode(',',$dropflds); $copyflds = array(); - foreach($this->MetaColumns($tabname) as $fld) { + foreach(($meta=$this->MetaColumns($tabname)) as $fld) { if (!$dropflds || !in_array($fld->name,$dropflds)) { // we need to explicit convert varchar to a number to be able to do an AlterColumn of a char column to a nummeric one if (preg_match('/'.$fld->name.' (I|I2|I4|I8|N|F)/i',$tableflds,$matches) && in_array($fld->type,array('varchar','char','text','bytea'))) { $copyflds[] = "to_number($fld->name,'S9999999999999D99')"; + } elseif (preg_match('/'.$fld->name.' ([\w]+)/i',$tableflds,$matches) && + strtoupper($fld->type) != ($type = $this->ActualType($matches[1]))) { + $copyflds[] = "CAST($fld->name AS $type)"; } else { $copyflds[] = $fld->name; } // identify the sequence name and the fld its on if ($fld->primary_key && $fld->has_default && - preg_match("/nextval\('([^']+)'::text\)/",$fld->default_value,$matches)) { + preg_match("/nextval\('([^']+)'::(text|regclass)\)/",$fld->default_value,$matches)) { $seq_name = $matches[1]; $seq_fld = $fld->name; } diff --git a/phpgwapi/inc/adodb/drivers/adodb-postgres64.inc.php b/phpgwapi/inc/adodb/drivers/adodb-postgres64.inc.php index affc34ebb4..aeeda7fde9 100644 --- a/phpgwapi/inc/adodb/drivers/adodb-postgres64.inc.php +++ b/phpgwapi/inc/adodb/drivers/adodb-postgres64.inc.php @@ -165,7 +165,7 @@ a different OID if a database must be reloaded. */ $cols = $this->MetaColumns($table); $fld = $cols[strtoupper($column)]; if ($fld->primary_key && $fld->has_default && - preg_match("/nextval\('([^']+)'::text\)/",$fld->default_value,$matches)) { + preg_match("/nextval\('([^']+)'::(text|regclass)\)/",$fld->default_value,$matches)) { $ret = $this->GetOne($sql='SELECT currval('.$this->qstr($matches[1]).')'); } } diff --git a/phpgwapi/inc/class.schema_proc.inc.php b/phpgwapi/inc/class.schema_proc.inc.php index efcfde0cd7..944abbfa48 100644 --- a/phpgwapi/inc/class.schema_proc.inc.php +++ b/phpgwapi/inc/class.schema_proc.inc.php @@ -32,46 +32,66 @@ */ var $m_oTranslator; /** - * @var egw_db-object $m_odb db-object + * egw_db-object + * + * @var egw_db */ var $m_odb; /** - * @var adodb-object $adodb reference to the global ADOdb object + * reference to the global ADOdb object + * + * @var ADOConnection */ var $adodb; /** - * @var datadictionary-object $dict adodb's datadictionary object for the used db-type + * adodb's datadictionary object for the used db-type + * + * @var ADODB_DataDict */ var $dict; /** - * @var $debug=0 0=Off, 1=some, eg. primary function calls, 2=lots incl. the SQL used + * Debuglevel: 0=Off, 1=some, eg. primary function calls, 2=lots incl. the SQL used + * + * @var int */ var $debug = 0; /** - * @var array $max_index_length db => max. length of indexes pairs (if there is a considerable low limit for a db) + * Arry with db => max. length of indexes pairs (if there is a considerable low limit for a db) + * + * @var array */ var $max_index_length=array( 'sapdb' => 32, 'oracle' => 30, ); /** - * @var string $sType type of the database, set by the the constructor + * type of the database, set by the the constructor: 'mysql','pgsql','mssql','sapdb' + * + * @var string */ var $sType; /** - * @var int $max_varchar_length maximum length of a varchar column, everything above get converted to text + * maximum length of a varchar column, everything above get converted to text + * + * @var int */ var $max_varchar_length = 255; /** - * @var string $system_charset system-charset if set + * system-charset if set + * + * @var string */ var $system_charset; /** - * @var array $capabilities reference to the array of the db-class + * reference to the capabilities array of the db-class + * + * @var array */ var $capabilities; /** - * @var int $pgsql_old_seq preserve value of old sequences in PostgreSQL + * preserve value of old sequences in PostgreSQL + * + * @var int */ var $pgsql_old_seq; @@ -80,6 +100,7 @@ * * @param string $dbms type of the database: 'mysql','pgsql','mssql','sapdb' * @param object $db=null database class, if null we use $GLOBALS['egw']->db + * @return schema_proc */ function schema_proc($dbms=False,$db=null) { @@ -501,7 +522,7 @@ if (!is_array($options)) $options = $options ? array($options) : array(); if ($bUnique) $options[] = 'UNIQUE'; - $aSql = $this->dict->CreateIndexSQL($name,$sTableName,$aColumnNames,$options); + $aSql = $this->dict->CreateIndexSQL($sIdxName,$sTableName,$aColumnNames,$options); return $this->ExecuteSQLArray($aSql,2,'CreateIndexSQL(%1,%2,%3,%4) sql=%5',False,$name,$sTableName,$aColumnNames,$options,$aSql); } @@ -518,6 +539,7 @@ if (is_array($aColumnNames)) { $indexes = $this->dict->MetaIndexes($sTableName); + if ($indexes === False) { // if MetaIndexes is not availible for the DB, we try the name the index was created with @@ -605,12 +627,25 @@ elseif (isset($old_table_def['fd'][$name])) // existing column, use its value => column-name in query { $value = $name; - // this is eg. necessary to change a varchar into an int column under postgres - if ($this->sType == 'pgsql' && - in_array($old_table_def['fd'][$name]['type'],array('char','varchar','text','blob')) && - in_array($data['type'],array('int','decimal'))) + + if ($this->sType == 'pgsql') // some postgres specific code { - $value = "to_number($name,'S9999999999999D99')"; + // this is eg. necessary to change a varchar into an int column under postgres + if (in_array($old_table_def['fd'][$name]['type'],array('char','varchar','text','blob')) && + in_array($data['type'],array('int','decimal'))) + { + $value = "to_number($name,'S9999999999999D99')"; + } + // blobs cant be casted to text + elseif($old_table_def['fd'][$name]['type'] == 'blob' && $data['type'] == 'text') + { + $value = "ENCODE($value,'escape')"; + } + // cast everything which is a different type + elseif($old_table_def['fd'][$name]['type'] != $data['type'] && ($type_translated = $this->TranslateType($data['type']))) + { + $value = "CAST($value AS $type_translated)"; + } } } else // new column => use default value or NULL @@ -622,13 +657,13 @@ else { $value = $this->m_odb->quote(isset($data['default']) ? $data['default'] : '',$data['type']); - if ($this->sType == 'pgsql') + } + if ($this->sType == 'pgsql') + { + // fix for postgres error "no '<' operator for type 'unknown'" + if(($type_translated = $this->TranslateType($data['type']))) { - // fix for postgres error "no '<' operator for type 'unknown'" - if(($type_translated = $this->TranslateType($data['type']))) - { - $value = "CAST($value AS $type_translated)"; - } + $value = "CAST($value AS $type_translated)"; } } } @@ -1188,6 +1223,10 @@ } if ($column->has_default) { + if (preg_match("/^'(.*)'::.*$/",$column->default_value,$matches)) // postgres + { + $column->default_value = $matches[1]; + } $definition['fd'][$name]['default'] = $column->default_value; } if ($column->not_null) @@ -1234,7 +1273,7 @@ } if ($this->debug > 2) $this->debug_message("schema_proc::GetTableDefintion: MetaIndexes(%1) = %2",False,$sTableName,$indexes); if ($this->debug > 1) $this->debug_message("schema_proc::GetTableDefintion(%1) = %2",False,$sTableName,$definition); - + return $definition; }