phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] [18602] Merging in the useful bits of http://www.bygg


From: Dave Hall
Subject: [Phpgroupware-cvs] [18602] Merging in the useful bits of http://www.byggeplass.bergen.no/ download/phpgroupware.0.9.17.514_snap.tar.gz
Date: Sat, 07 Jun 2008 23:43:48 +0000

Revision: 18602
          
http://svn.sv.gnu.org/viewvc/?view=rev&root=phpgroupware&revision=18602
Author:   skwashd
Date:     2008-06-07 23:43:47 +0000 (Sat, 07 Jun 2008)

Log Message:
-----------
Merging in the useful bits of 
http://www.byggeplass.bergen.no/download/phpgroupware.0.9.17.514_snap.tar.gz
Posted by Sigurd Nes to the developers list on 
http://article.gmane.org/gmane.comp.web.phpgroupware.devel/6605
Offer to merge into tree "as soon as possible" was never carried out

I also did some cleaning up to better adhere to the coding standards

Modified Paths:
--------------
    trunk/phpgroupware/redirect.php
    trunk/phpgwapi/inc/accounts/class.accounts_.inc.php
    trunk/phpgwapi/inc/accounts/class.accounts_sql.inc.php
    trunk/phpgwapi/inc/class.custom_fields.inc.php
    trunk/phpgwapi/inc/class.db.inc.php
    trunk/phpgwapi/inc/class.schema_proc_mssql.inc.php
    trunk/phpgwapi/inc/class.schema_proc_mysql.inc.php
    trunk/phpgwapi/inc/class.schema_proc_pgsql.inc.php
    trunk/phpgwapi/inc/class.setup_process.inc.php
    trunk/phpgwapi/inc/class.setup_translation.inc.php
    trunk/setup/applications.php

Modified: trunk/phpgroupware/redirect.php
===================================================================
--- trunk/phpgroupware/redirect.php     2008-06-07 22:42:12 UTC (rev 18601)
+++ trunk/phpgroupware/redirect.php     2008-06-07 23:43:47 UTC (rev 18602)
@@ -6,15 +6,38 @@
        * @internal Idea by Jason Wies <address@hidden>
        * @author Lars Kneschke <address@hidden>
        * @author Dave Hall <address@hidden>
-       * @copyright Copyright (C) 2004-2005 Free Software Foundation, Inc. 
http://www.fsf.org/
-       * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
+       * @copyright Copyright (C) 2004 - 2008 Free Software Foundation, Inc. 
http://www.fsf.org/
+       * @license http://www.fsf.org/licenses/gpl.html GNU General Public 
License v3 or later
        * @package phpgroupware
        * @version $Id$
        */
+ 
+       /*
+          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 3 of the License, or
+          (at your option) any later version.
 
+          This program is distributed in the hope that it will be useful,
+          but WITHOUT ANY WARRANTY; without even the implied warranty of
+          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+          GNU Lesser General Public License for more details.
+
+          You should have received a copy of the GNU Lesser General Public 
License
+          along with this program.  If not, see <http://www.gnu.org/licenses/>.
+        */
+
        //Get the session variables set for non cookie based sessions
-       if (! (@isset($_COOKIES['PHPSESSID']) || @isset($_COOKIES['sessionid']) 
) )
+       if ( !isset($_COOKIES['PHPSESSID']) 
+               || isset($_COOKIES['sessionid']) ) 
        {
+               // nothing else we can do
+               if ( !isset($_SERVER['HTTP_REFERER']) 
+                               && isset($_GET['go']) )
+               {
+                       Header("Location: {$_GET['go']}");
+                       exit;
+               }
                $get = array();
                $url = parse_url($_SERVER['HTTP_REFERER']);
                parse_str($url['query'], $get);
@@ -25,21 +48,22 @@
 
        }
 
-       $GLOBALS['phpgw_info']['flags'] = array(
-                                       'currentapp'    => 'home',
-                                       'noheader'      => True,
-                                       'nonavbar'      => True,
-                                       'noappheader'   => True,
-                                       'noappfooter'   => True,
-                                       'nofooter'      => True
-                                       );
+       $GLOBALS['phpgw_info']['flags'] = array
+       (
+               'currentapp'    => 'home',
+               'noheader'              => True,
+               'nonavbar'              => True,
+               'noappheader'   => True,
+               'noappfooter'   => True,
+               'nofooter'              => True
+       );
 
        /**
        * Include phpgroupware header
        */
        include_once('header.inc.php');
 
-       if( @isset($_GET['go']) )
+       if( isset($_GET['go']) )
        {
                $_GET['go'] = html_entity_decode($_GET['go']);
                ?>

Modified: trunk/phpgwapi/inc/accounts/class.accounts_.inc.php
===================================================================
--- trunk/phpgwapi/inc/accounts/class.accounts_.inc.php 2008-06-07 22:42:12 UTC 
(rev 18601)
+++ trunk/phpgwapi/inc/accounts/class.accounts_.inc.php 2008-06-07 23:43:47 UTC 
(rev 18602)
@@ -434,7 +434,7 @@
                function get_members()
                {
                        $members = array();
-                       $sql = "SELECT acl_account FROM phpgw_acl WHERE 
acl_appname = 'phpgw_group' and acl_location =" . (int) $this->account_id;
+                       $sql = "SELECT acl_account FROM phpgw_acl WHERE 
acl_appname = 'phpgw_group' and acl_location ='" . (int) $this->account_id . 
"'";
                        $this->db->query($sql,__LINE__,__FILE__);
                        while ($this->db->next_record())
                        {

Modified: trunk/phpgwapi/inc/accounts/class.accounts_sql.inc.php
===================================================================
--- trunk/phpgwapi/inc/accounts/class.accounts_sql.inc.php      2008-06-07 
22:42:12 UTC (rev 18601)
+++ trunk/phpgwapi/inc/accounts/class.accounts_sql.inc.php      2008-06-07 
23:43:47 UTC (rev 18602)
@@ -1,22 +1,39 @@
 <?php
        /**
-       * View and manipulate account records using SQL
-       * @author Joseph Engo <address@hidden>
-       * @author Dan Kuykendall <address@hidden>
-       * @author Bettina Gille <address@hidden>
-       * @copyright Copyright (C) 2000-2004 Free Software Foundation, Inc. 
http://www.fsf.org/
-       * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General 
Public License
-       * @package phpgwapi
-       * @subpackage accounts
-       * @version $Id$
-       */
+        * phpGroupWare - View and manipulate account records using SQL
+        *
+        * @author Joseph Engo <address@hidden>
+        * @author Dan Kuykendall <address@hidden>
+        * @author Bettina Gille <address@hidden>
+        * @author Dave Hall <address@hidden>
+        * @copyright Copyright (C) 2000-2008 Free Software Foundation, Inc. 
http://www.fsf.org/
+        * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General 
Public License v3 or later
+        * @package phpgroupware
+        * @subpackage phpgwapi
+        * @version $Id$
+        */
 
+       /*
+          This program is free software: you can redistribute it and/or modify
+          it under the terms of the GNU Lesser General Public License as 
published by
+          the Free Software Foundation, either version 3 of the License, or
+          (at your option) any later version.
+
+          This program is distributed in the hope that it will be useful,
+          but WITHOUT ANY WARRANTY; without even the implied warranty of
+          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+          GNU Lesser General Public License for more details.
+
+          You should have received a copy of the GNU Lesser General Public 
License
+          along with this program.  If not, see <http://www.gnu.org/licenses/>.
+        */
+
        /**
-       * View and manipulate handling user and group account records using SQL
-       *
-       * @package phpgwapi
-       * @subpackage accounts
-       */
+        * View and manipulate handling user and group account records using SQL
+        *
+        * @package phpgroupware
+        * @subpackage phpgwapi
+        */
        class accounts_sql extends accounts_
        {
                function __construct($account_id = null, $account_type = null)
@@ -91,7 +108,7 @@
                                                        . "', 
account_lastname='" . $this->data['account_lastname'] . "', account_status='"
                                                        . $this->data['status'] 
. "', account_expires=" . $this->data['expires']
                                                        . 
($this->data['account_lid']?", account_lid='".$this->data['account_lid']."'":'')
-                                               //      . 
(isset($this->data['person_id'])?', person_id=' . $this->data['person_id']:'')
+                                                       . 
(isset($this->data['person_id']) && $this->data['person_id'] ?', person_id=' . 
$this->data['person_id']:'')
                                                        . ', account_quota=' . 
intval($this->data['quota'])
                                                        . ' WHERE account_id=' 
. intval($this->data['account_id']),__LINE__,__FILE__);
                }
@@ -163,7 +180,7 @@
                                }
 
                                $whereclause .= " account_firstname $this->like 
'%$query%' OR account_lastname $this->like "
-                                       . "'%$query%' OR account_lid 
$this->like '%$query%' OR person_id $this->like '%$query%')";
+                                       . "'%$query%' OR account_lid 
$this->like '%$query%' OR person_id =" . (int)$query . ')';
                        }
 
                        $sql = "SELECT * FROM phpgw_accounts $whereclause 
$orderclause";
@@ -540,7 +557,7 @@
                function get_account_without_contact()
                {
                        $sql = 'SELECT account_id FROM phpgw_accounts '
-                               . 'WHERE person_id IS NULL OR person_id = 0';
+                               . "WHERE account_type = 'u' AND (person_id IS 
NULL OR person_id = '0')";
                        $this->db->query($sql,__LINE__,__FILE__);
                        while ($this->db->next_record())
                        {

Modified: trunk/phpgwapi/inc/class.custom_fields.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.custom_fields.inc.php      2008-06-07 22:42:12 UTC 
(rev 18601)
+++ trunk/phpgwapi/inc/class.custom_fields.inc.php      2008-06-07 23:43:47 UTC 
(rev 18602)
@@ -123,9 +123,10 @@
                 * 
                 * @param array $attrib the field data
                 * @param string $attrib_table where to append the attrib
+                * @param bool $doubled sometimes the attribute fits into a 
history-table as a double
                 * @return int the the new custom field db pk
                 */
-               function add_attrib($attrib, $attrib_table = '')
+               function add_attrib($attrib, $attrib_table = '', $doubled = 
false)
                {
                        $receipt = array();
                        // Checkboxes are only present if ticked, so we declare 
them here to stop errors
@@ -141,7 +142,7 @@
 
                        $sql = "SELECT * FROM phpgw_cust_attribute where 
appname='{$attrib['appname']}' AND location='{$attrib['location']}' AND 
column_name = '{$attrib['column_name']}'";
                        $this->db->query($sql,__LINE__,__FILE__);
-                       if ( $this->db->next_record() )
+                       if ( $this->db->next_record() && !$doubled)
                        {
                                $receipt['id'] = 0;
                                $receipt['error'] = array();
@@ -196,8 +197,11 @@
 
                        $this->db->transaction_begin();
 
-                       $this->db->query("INSERT INTO phpgw_cust_attribute 
(appname,location,id,column_name, input_text, 
statustext,search,list,history,disabled,helpmsg,attrib_sort, 
datatype,precision_,scale,default_value,nullable) "
-                               . "VALUES ($values)",__LINE__,__FILE__);
+                       if(!$doubled)
+                       {
+                               $this->db->query("INSERT INTO 
phpgw_cust_attribute (appname,location,id,column_name, input_text, 
statustext,search,list,history,disabled,helpmsg,attrib_sort, 
datatype,precision_,scale,default_value,nullable) "
+                                       . "VALUES ($values)",__LINE__,__FILE__);
+                       }
 
                        $receipt['id']= $attrib['id'];
 
@@ -973,7 +977,15 @@
                        return 
isset($datatype_precision[$datatype])?$datatype_precision[$datatype]:'';
                }
 
-               function _delete_attrib($location,$appname,$attrib_id,$table = 
'')
+               /**
+                * Delete a custom field/attribute
+                * 
+                * @param string $location within an application
+                * @param string $appname where to delete the attrib
+                * @param integer $attrib_id id of attrib to delete
+                * @param bool $doubled sometimes the attribute fits into a 
history-table as a double
+                */
+               function _delete_attrib($location,$appname,$attrib_id,$table = 
'',$doubled = false )
                {
                        $this->_init_process();
                        $this->oProc->m_odb->transaction_begin();
@@ -1008,7 +1020,10 @@
                                $this->db->query($sql,__LINE__,__FILE__);
                        }
 
-                       $this->db->query("DELETE FROM phpgw_cust_attribute 
WHERE appname='$appname' AND location='$location' AND 
id=$attrib_id",__LINE__,__FILE__);
+                       if(!$doubled) // else: wait for it - another one is 
coming
+                       {
+                               $this->db->query("DELETE FROM 
phpgw_cust_attribute WHERE appname='$appname' AND location='$location' AND id = 
" . (int)$attrib_id,__LINE__,__FILE__);
+                       }
        //              $this->db->query("DELETE FROM history...
                        $this->db->transaction_commit();
                        $this->oProc->m_odb->transaction_commit();
@@ -1160,11 +1175,11 @@
                                {
                                        if($values['attributes'][$i]['value'])
                                        {
-                                               $vendor_data    = 
$vendor->read_single(array('values_id'=>$values['attributes'][$i]['value']));
+                                               $vendor_data    = 
$vendor->read_single($values['attributes'][$i]['value'],array('attributes' => 
array(0 => array('column_name' => 'org_name'))));
 
                                                for 
($n=0;$n<count($vendor_data['attributes']);$n++)
                                                {
-                                                       
if($vendor_data['attributes'][$n]['name'] == 'org_name')
+                                                       
if($vendor_data['attributes'][$n]['column_name'] == 'org_name')
                                                        {
                                                                
$values['attributes'][$i]['vendor_name']= 
$vendor_data['attributes'][$n]['value'];
                                                                $n 
=count($vendor_data['attributes']);
@@ -1232,7 +1247,7 @@
                                                }
                                        }
                                }
-                               else if 
($entity['attributes'][$i]['datatype']!='I' && 
$entity['attributes'][$i]['value'])
+                               else if (isset($entity['attributes'][$i]) && 
$entity['attributes'][$i]['datatype']!='I' && 
$entity['attributes'][$i]['value'])
                                {
                                        $entity['attributes'][$i]['value'] = 
stripslashes($entity['attributes'][$i]['value']);
                                }

Modified: trunk/phpgwapi/inc/class.db.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.db.inc.php 2008-06-07 22:42:12 UTC (rev 18601)
+++ trunk/phpgwapi/inc/class.db.inc.php 2008-06-07 23:43:47 UTC (rev 18602)
@@ -1,17 +1,41 @@
 <?php
        /**
-       * Database abstraction class
+       * phpGroupWare - Database abstraction class
+       *
        * @author NetUSE AG Boris Erdmann, Kristian Koehntopp
        * @author Dan Kuykendall, Dave Hall and others
        * @copyright Copyright (C) 1998-2000 NetUSE AG Boris Erdmann, Kristian 
Koehntopp
        * @copyright Portions Copyright (C) 2001-2006 Free Software Foundation, 
Inc. http://www.fsf.org/
-       * @license http://www.fsf.org/licenses/lgpl.html GNU Lesser General 
Public License
+       * @license http://www.fsf.org/licenses/lgpl.html GNU Lesser General 
Public License v3 or later
        * @link http://www.sanisoft.com/phplib/manual/DB_sql.php
-       * @package phpgwapi
-       * @subpackage database
+       * @package phpgroupware
+       * @subpackage phpgwapi
        * @version $Id$
        */
 
+       /*
+          This program is free software: you can redistribute it and/or modify
+          it under the terms of the GNU Lesser General Public License as 
published by
+          the Free Software Foundation, either version 3 of the License, or
+          (at your option) any later version.
+
+          This program is distributed in the hope that it will be useful,
+          but WITHOUT ANY WARRANTY; without even the implied warranty of
+          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+          GNU Lesser General Public License for more details.
+
+          You should have received a copy of the GNU Lesser General Public 
License
+          along with this program.  If not, see <http://www.gnu.org/licenses/>.
+        */
+
+       /**
+       * phpGroupWare - Database abstraction class
+       *
+       * @package phpgroupware
+       * @subpackage phpgwapi
+       * @version $Id$
+       */
+
        if (empty($GLOBALS['phpgw_info']['server']['db_type']))
        {
                $GLOBALS['phpgw_info']['server']['db_type'] = 'mysql';
@@ -510,7 +534,11 @@
                 * Prepare the VALUES component of an INSERT sql statement
                 * 
                 * @param array $value_set array of values to insert into the 
database
+                *
                 * @return string the prepared sql, empty string for invalid 
input
+                *
+                * @internal this method tries to guess target data types, 
+                * so the results may not match the db schema - use with caution
                 */
                public function validate_insert($values)
                {
@@ -518,24 +546,23 @@
                        {
                                return '';
                        }
-                       
+
                        $insert_value = array();
-                       foreach ( $values as $value )
                        {
+                               if($value || $value === 0)
+                               {
                                        if ( is_numeric($value) )
                                        {
-                                       if ( !$value )
-                                       {
-                                               $insert_value[] = 'NULL';
+                                               $insert_value[] = "$value";
                                        }
                                        else
                                        {
-                                               $insert_value[] = $value;
+                                               $insert_value[] = "'$value'";
                                        }
                                }
                                else
                                {
-                                       $insert_value[] = "'$value'";
+                                       $insert_value[] = 'NULL';
                                }
                        }
                        return implode(",", $insert_value);

Modified: trunk/phpgwapi/inc/class.schema_proc_mssql.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.schema_proc_mssql.inc.php  2008-06-07 22:42:12 UTC 
(rev 18601)
+++ trunk/phpgwapi/inc/class.schema_proc_mssql.inc.php  2008-06-07 23:43:47 UTC 
(rev 18602)
@@ -110,7 +110,7 @@
                        {
                                case 'current_date':
                                case 'current_timestamp':
-                               return "'GetDate()'";
+                               return "GetDate()";
                        }
 
                        return "'" . $sDefault . "'";
@@ -197,8 +197,33 @@
                        return "UNIQUE($sFields)";
                }
 
-               function GetIXSQL($sFields)
+
+               /* format:
+                       CREATE [ UNIQUE ] [ CLUSTERED | NONCLUSTERED ] INDEX 
index_name
+                           ON { table | view } ( column [ ASC | DESC ] [ ,...n 
] )
+                       [ WITH < index_option > [ ,...n] ]
+                       [ ON filegroup ]
+
+                       < index_option > :: =
+                           { PAD_INDEX |
+                               FILLFACTOR = fillfactor |
+                               IGNORE_DUP_KEY |
+                               DROP_EXISTING |
+                           STATISTICS_NORECOMPUTE |
+                           SORT_IN_TEMPDB 
+                       }
+               */
+
+               function GetIXSQL($sFields,$sTableName = '')
                {
+                       if($sTableName)
+                       {
+                               return "CREATE NONCLUSTERED INDEX ". 
str_replace(',','_',$sFields).'_'.$sTableName.'_idx' ."  ON $sTableName 
($sFields)";
+                       }
+                       else
+                       {
+                               
$this->indexes_sql[str_replace(',','_',$sFields)] = "CREATE NONCLUSTERED INDEX 
__index_name__ ON __table_name__ ($sFields)";
+                       }
                        return '';
                }
 
@@ -210,8 +235,7 @@
                        $this->ix = array();
                        $this->uc = array();
 
-                       // Field, Type, Null, Key, Default, Extra
-                       $oProc->m_odb->query("exec sp_columns '$sTableName'", 
__LINE__, __FILE__);
+                       $oProc->m_odb->query("EXEC sp_columns '$sTableName'", 
__LINE__, __FILE__);
                        while ($oProc->m_odb->next_record())
                        {
                                $type = $default = $null = $nullcomma = $prec = 
$scale = $ret = $colinfo = $scales = '';
@@ -219,20 +243,12 @@
                                {
                                        $sColumns .= ',';
                                }
-                               $sColumns .= $oProc->m_odb->f(0);
 
-                               // The rest of this is used only for SQL->array
-                               $colinfo = explode('(',$oProc->m_odb->f(1));
-                               $prec = ereg_replace(')','',$colinfo[1]);
-                               $scales = explode(',',$prec);
-                               if ($scales[1])
-                               {
-                                       $prec  = $scales[0];
-                                       $scale = $scales[1];
-                               }
-                               $type = $this->rTranslateType($colinfo[0], 
$prec, $scale);
+                               $sColumns .= $oProc->m_odb->f('COLUMN_NAME');
 
-                               if ($oProc->m_odb->f(2) == 'YES')
+                               $type = 
$this->rTranslateType($oProc->m_odb->f('TYPE_NAME'),$oProc->m_odb->f('PRECISION'),
 $oProc->m_odb->f('SCALE'));
+
+                               if ($oProc->m_odb->f('IS_NULLABLE') == 'YES')
                                {
                                        $null = "'nullable' => True";
                                }
@@ -240,9 +256,10 @@
                                {
                                        $null = "'nullable' => False";
                                }
-                               if ($oProc->m_odb->f(4))
+
+                               if ($oProc->m_odb->f('COLUMN_DEF'))
                                {
-                                       $default = "'default' => 
'".$oProc->m_odb->f(4)."'";
+                                       $default = "'default' => 
'".str_replace(array('((','))', "('", 
"')",'GetDate()'),array('','','','','current_timestamp'),$oProc->m_odb->f('COLUMN_DEF'))."'";
                                        $nullcomma = ',';
                                }
                                else
@@ -250,25 +267,42 @@
                                        $default = '';
                                        $nullcomma = '';
                                }
-                               if ($oProc->m_odb->f(5))
+                               if ($oProc->m_odb->f('TYPE_NAME') == 'int 
identity')
                                {
                                        $type = "'type' => 'auto'";
                                }
-                               $this->sCol[] = "\t\t\t\t'" . 
$oProc->m_odb->f(0)."' => array(" . $type . ',' . $null . $nullcomma . $default 
. '),' . "\n";
-                               if ($oProc->m_odb->f(3) == 'PRI')
+                               $this->sCol[] = "\t\t\t\t'" . 
$oProc->m_odb->f('COLUMN_NAME')."' => array(" . $type . ',' . $null . 
$nullcomma . $default . '),' . "\n";
+                       }
+
+                       $this->pk = 
$oProc->m_odb->adodb->MetaPrimaryKeys($sTableName);
+
+                       $ForeignKeys 
=$oProc->m_odb->MetaForeignKeys($sTableName);
+
+                       foreach($ForeignKeys as $table => $keys)
+                       {
+                               $keystr = array();
+                               foreach ($keys as $keypair)
                                {
-                                       $this->pk[] = $oProc->m_odb->f(0);
+                                       $keypair = explode('=',$keypair);
+                                       $keystr[] = "'" . $keypair[0] . "' => 
'" . $keypair[1] . "'";
                                }
-                               if ($oProc->m_odb->f(3) == 'UNI')
+                               $this->fk[] = $table . "' => array(" . 
implode(', ',$keystr)  . ')';
+                       }
+
+                       /*FIXME: not working as expected */
+                       $oProc->m_odb->query("EXEC sp_indexes  @table_server = 
'{$GLOBALS['phpgw_info']['server']['db_host']}', @table_name = '$sTableName'", 
__LINE__, __FILE__);
+                       while ($oProc->m_odb->next_record())
+                       {
+                               if($oProc->m_odb->f('NON_UNIQUE') == 1)
                                {
-                                       $this->uc[] = $oProc->m_odb->f(0);
+                                       $this->ix[] = 
$oProc->m_odb->f('COLUMN_NAME');
                                }
-                               /* Hmmm, MUL could also mean unique, or not... 
*/
-                               if ($oProc->m_odb->f(3) == 'MUL')
+                               else
                                {
-                                       $this->ix[] = $oProc->m_odb->f(0);
+                                       $this->uc[] = 
$oProc->m_odb->f('COLUMN_NAME');
                                }
                        }
+
                        /* ugly as heck, but is here to chop the trailing comma 
on the last element (for php3) */
                        $this->sCol[count($this->sCol) - 1] = 
substr($this->sCol[count($this->sCol) - 1],0,-2) . "\n";
 
@@ -337,6 +371,8 @@
 
                function CreateTable($oProc, &$aTables, $sTableName, $aTableDef)
                {
+                       global $DEBUG;
+                       unset($this->indexes_sql);
                        if ($oProc->_GetTableSQL($sTableName, $aTableDef, 
$sTableSQL, $sSequenceSQL, $sTriggerSQL))
                        {
                                // create sequence first since it will be 
needed for default
@@ -346,7 +382,28 @@
                                }
 
                                $query = "CREATE TABLE $sTableName 
($sTableSQL)";
-                               return !!($oProc->m_odb->query($query));
+
+                               $result = !!$oProc->m_odb->query($query, 
__LINE__, __FILE__);
+                               if($result==True)
+                               {
+                                       if (isset($this->indexes_sql) && $DEBUG)
+                                       {
+                                               echo  '<pre>';
+                                               print_r($this->indexes_sql);
+                                               echo '</pre>';
+                                       }
+
+                                       if(isset($this->indexes_sql) && 
is_array($this->indexes_sql) && count($this->indexes_sql)>0)
+                                       {
+                                               foreach($this->indexes_sql as 
$key => $sIndexSQL)
+                                               {
+                                                       $ix_name = 
str_replace(',','_',$key).'_'.$sTableName.'_idx';
+                                                       $IndexSQL = 
str_replace(array('__index_name__','__table_name__'), 
array($ix_name,$sTableName), $sIndexSQL);
+                                                       
$oProc->m_odb->query($IndexSQL, __LINE__, __FILE__);
+                                               }
+                                       }                       
+                               }
+                               return $result;
                        }
 
                        return false;

Modified: trunk/phpgwapi/inc/class.schema_proc_mysql.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.schema_proc_mysql.inc.php  2008-06-07 22:42:12 UTC 
(rev 18601)
+++ trunk/phpgwapi/inc/class.schema_proc_mysql.inc.php  2008-06-07 23:43:47 UTC 
(rev 18602)
@@ -295,7 +295,7 @@
                                                }
                                        }
                                }
-                               elseif ($scales[1])
+                               else if ( isset($scales[1]) )
                                {
                                        $prec  = $scales[0];
                                        $scale = $scales[1];

Modified: trunk/phpgwapi/inc/class.schema_proc_pgsql.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.schema_proc_pgsql.inc.php  2008-06-07 22:42:12 UTC 
(rev 18601)
+++ trunk/phpgwapi/inc/class.schema_proc_pgsql.inc.php  2008-06-07 23:43:47 UTC 
(rev 18602)
@@ -1,6 +1,7 @@
 <?php
        /**
        * Database schema abstraction class for PostgreSQL
+       *
        * @author Tobias Ratschiller <address@hidden>
        * @author Dan Wilson <address@hidden>
        * @author Michael Dean <address@hidden>
@@ -8,10 +9,10 @@
        * @copyright Copyright (C) 1998-1999 Tobias Ratschiller
        * @copyright Copyright (C) 1999-2000 Dan Wilson
        * @copyright Copyright (C) ? Michael Dean, Miles Lott
-       * @copyright Portions Copyright (C) 2003,2004 Free Software Foundation, 
Inc. http://www.fsf.org/
-       * @license http://www.fsf.org/licenses/gpl.html GNU General Public 
License
-       * @package phpgwapi
-       * @subpackage database
+       * @copyright Portions Copyright (C) 2003 - 2008 Free Software 
Foundation, Inc. http://www.fsf.org/
+       * @license http://www.fsf.org/licenses/gpl.html GNU General Public 
License v3 or later
+       * @package phpgroupware
+       * @subpackage phpgwapi
        * @version $Id$
        * @link http://www.greatbridge.org/project/phppgadmin
        * @internal SQL for table properties taken from phpPgAdmin Version 2.2.1
@@ -329,7 +330,7 @@
                                        }
                                        else
                                        {
-                                               $default = "'default' => '" . 
str_replace(array('::bpchar','::character 
varying','now()'),array('','','current_timestamp'),$sdc->f(0));
+                                               $default = "'default' => '" . 
str_replace(array('::bpchar','::character 
varying','now()',"('now'::text)::timestamp(6) without time 
zone"),array('','','current_timestamp','current_timestamp'),$sdc->f(0));
                                                // For db-functions - add an 
apos
                                                if(substr($default,-1)!= "'")
                                                {
@@ -378,7 +379,7 @@
                                {
                                        $this->pk[] = $sdc->f(2);
                                }
-                               if ($sdc->f(3) == 't')
+                               else if ($sdc->f(3) == 't')
                                {
                                        $this->uc[] = $sdc->f(2);
                                }
@@ -399,15 +400,16 @@
 
                        $MetaIndexes = $sdc->adodb->MetaIndexes($sTableName);
 
+                       //FIXME: looks like unique is reported as index
                        foreach($MetaIndexes as $key => $index)
                        {
                                if(count($index['columns']) > 1)
                                {
-                                       $this->ix[] = "array('" . implode("', 
'",$index['columns']) . "')";
+                                       $this->ix[] = $index['columns'];
                                }
                                else
                                {
-                                       $this->ix[] = "'" . 
$index['columns'][0] . "'"; 
+                                       $this->ix[] = $index['columns'][0];     
                                }
                        }
 

Modified: trunk/phpgwapi/inc/class.setup_process.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.setup_process.inc.php      2008-06-07 22:42:12 UTC 
(rev 18601)
+++ trunk/phpgwapi/inc/class.setup_process.inc.php      2008-06-07 23:43:47 UTC 
(rev 18602)
@@ -1,46 +1,71 @@
 <?php
        /**
-       * Setup process
-       * @author Miles Lott <address@hidden>
-       * @copyright Portions Copyright (C) 2004 Free Software Foundation, Inc. 
http://www.fsf.org/
-       * @license http://www.fsf.org/licenses/gpl.html GNU General Public 
License
-       * @package phpgwapi
-       * @subpackage application
-       * @version $Id$
-       */
+        * phpGroupWare - Setup process
+        *
+        * @author Miles Lott <address@hidden>
+        * @author Dave Hall <address@hidden>
+        * @copyright Portions Copyright (C) 2004 - 2008 Free Software 
Foundation, Inc. http://www.fsf.org/
+        * @license http://www.fsf.org/licenses/gpl.html GNU General Public 
License v3 or later
+        * @package phpgroupware
+        * @subpackage phpgwapi
+        * @version $Id$
+        */
 
+       /*
+          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 3 of the License, or
+          (at your option) any later version.
+
+          This program is distributed in the hope that it will be useful,
+          but WITHOUT ANY WARRANTY; without even the implied warranty of
+          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+          GNU Lesser General Public License for more details.
+
+          You should have received a copy of the GNU Lesser General Public 
License
+          along with this program.  If not, see <http://www.gnu.org/licenses/>.
+        */
+
+       /*
+        * app status values:
+        * U : Upgrade required/available
+        * R : upgrade in pRogress
+        * C : upgrade Completed successfully
+        * D : Dependency failure
+        * F : upgrade Failed
+        * V : Version mismatch at end of upgrade (Not used, proposed only)
+        * M : Missing files at start of upgrade (Not used, proposed only)
+        */
+
        /**
-       * Setup process
-       * 
-       * @package phpgwapi
-       * @subpackage application
-       * app status values:
-       * U : Upgrade required/available
-       * R : upgrade in pRogress
-       * C : upgrade Completed successfully
-       * D : Dependency failure
-       * F : upgrade Failed
-       * V : Version mismatch at end of upgrade (Not used, proposed only)
-       * M : Missing files at start of upgrade (Not used, proposed only)
-       */
-       class setup_process
+        * Setup process
+        * 
+        * @package phpgroupware
+        * @subpackage phpgwapi
+        */
+       class phpgwapi_setup_process
        {
                var $oProc;
                var $tables;
                var $updateincluded = array();
                var $translation;
 
-               function setup_process()
+               /**
+                * Constructor
+                *
+                * @return void
+                */
+               public function __construct()
                {
-                       $this->translation = 
createObject('phpgwapi.setup_translation');
+                       $this->translation = 
&$GLOBALS['phpgw']->setup_translation;
                }
 
                /**
                 * create schema_proc object
-               *
-                * @param none
+                *
+                * @return void
                 */
-               function init_process()
+               public function init_process()
                {
                        $ConfigDomain = phpgw::get_var('ConfigDomain');
                        $phpgw_domain = $GLOBALS['phpgw_domain'];
@@ -62,12 +87,14 @@
                 * @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
+                *
+                * @return array processed setup values
                 */
-               function pass($setup_info, $method = 'new', $DEBUG = false, 
$force_en = false)
+               public function pass($setup_info, $method = 'new', $DEBUG = 
false, $force_en = false)
                {
                        if(!$method)
                        {
-                               return False;
+                               return false;
                        }
                        $setup_info = 
$GLOBALS['phpgw_setup']->detection->get_versions($setup_info);
                        /* Check current versions and dependencies */
@@ -93,7 +120,6 @@
                                {
                                        echo '<br>process->pass(): #' . $i . ' 
for ' . $method . ' processing' . "\n"; 
                                }
-                               //if($i==2) { _debug_array($passed);exit; }
 
                                /* stuff the rest of the apps, but only those 
with available upgrades */
                                foreach($setup_info as $key => $value)
@@ -109,13 +135,6 @@
                                                        $pass[$value['name']] = 
$setup_info[$value['name']];
                                                }
                                        }
-                                       /*
-                                       Now if we are on the 2nd or more 
passes, add api in
-                                       if (!$pass['phpgwapi'])
-                                       {
-                                               $pass['phpgwapi'] = 
$setup_info['phpgwapi'];
-                                       }
-                                       */
                                }
 
                                switch ($method)
@@ -134,7 +153,7 @@
                                                break;
                                        default:
                                                /* What the heck are you doing? 
*/
-                                               return False;
+                                               return false;
                                                break;
                                }
 
@@ -194,15 +213,18 @@
                /**
                 * drop tables per application, check that they are in the db 
first
                *
-                * @param $setup_info   array of application info from 
setup.inc.php files, etc.
+                * @param array $setup_info application info from setup.inc.php 
files, etc.
+                * @param boolean $DEBUG enable debugging
+                *
+                * @return array processed setup_info values
                 */
-               function droptables($setup_info,$DEBUG=False)
+               public function droptables($setup_info, $DEBUG = false)
                {
                        if( !isset($GLOBALS['phpgw_setup']->oProc) || 
!$GLOBALS['phpgw_setup']->oProc )
                        {
                                $this->init_process();
                        }
-                       $GLOBALS['phpgw_setup']->oProc->m_bDeltaOnly = False;
+                       $GLOBALS['phpgw_setup']->oProc->m_bDeltaOnly = false;
 
                        /* The following is built so below we won't try to drop 
a table that isn't there. */
                        $tablenames = 
$GLOBALS['phpgw_setup']->db->table_names();
@@ -221,7 +243,8 @@
                                if ( isset($setup_info[$key]['tables'])
                                        && 
is_array($setup_info[$key]['tables']) )
                                {
-                                       foreach ( $setup_info[$key]['tables'] 
as $table )
+                                       // Tables has to be dropped in reversed 
order (mssql) if they are referenced by others
+                                       foreach ( 
array_reverse($setup_info[$key]['tables']) as $table )
                                        {
                                                //echo $table;
                                                if(in_array($table,$tables))
@@ -241,17 +264,19 @@
 
                /**
                 * 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 boolean $DEBUG enable debugging
+                *
+                * @return array processed setup_info values
                 */
-               function current($setup_info, $DEBUG=False)
+               public function current($setup_info, $DEBUG=false)
                {
                        if( !isset($GLOBALS['phpgw_setup']->oProc) || 
!$GLOBALS['phpgw_setup']->oProc )
                        {
                                $this->init_process();
                        }
-                       $GLOBALS['phpgw_setup']->oProc->m_bDeltaOnly = False;
+                       $GLOBALS['phpgw_setup']->oProc->m_bDeltaOnly = false;
 
                        if ( !is_array($setup_info) )
                        {
@@ -259,7 +284,7 @@
                        }
                        foreach ( array_keys($setup_info) as $key )
                        {
-                               $enabled = False;
+                               $enabled = false;
                                $appname  = isset($setup_info[$key]['name']) ? 
$setup_info[$key]['name'] : '';
                                $apptitle = isset($setup_info[$key]['title']) ? 
$setup_info[$key]['title'] : '';
 
@@ -307,7 +332,7 @@
                                        if ( 
isset($setup_info[$key]['tables'][0])
                                                && 
$setup_info[$key]['tables'][0] != '' )
                                        {
-                                               $enabled = False;
+                                               $enabled = false;
                                        }
                                        
if($GLOBALS['phpgw_setup']->app_registered($appname))
                                        {
@@ -330,16 +355,19 @@
 
                /**
                 * process default_records.inc.php in each application/setup dir
-               *
+                *
                 * @param $setup_info   array of application info from 
setup.inc.php files, etc.
+                * @param boolean $DEBUG enable debugging
+                *
+                * @return array processed setup_info values
                 */
-               function default_records($setup_info,$DEBUG=False)
+               public function default_records($setup_info,$DEBUG=false)
                {
                        if( !isset($GLOBALS['phpgw_setup']->oProc) || 
!$GLOBALS['phpgw_setup']->oProc)
                        {
                                $this->init_process();
                        }
-                       $GLOBALS['phpgw_setup']->oProc->m_bDeltaOnly = False;
+                       $GLOBALS['phpgw_setup']->oProc->m_bDeltaOnly = false;
 
                        if ( !is_array($setup_info) )
                        {
@@ -372,10 +400,14 @@
 
                /**
                 * process application lang files and uninstall
-               *
+                *
                 * @param $setup_info   array of application info from 
setup.inc.php files, etc.
+                * @param boolean $DEBUG enable debugging
+                * @param boolean $force_en force english to be loaded
+                *
+                * @return array processed setup_info values
                 */
-               function add_langs($setup_info, $DEBUG = false, $force_en = 
false)
+               public function add_langs($setup_info, $DEBUG = false, 
$force_en = false)
                {
                        foreach ( array_keys($setup_info) as $key )
                        {
@@ -392,10 +424,13 @@
 
                /**
                 * process application lang files and install
-               *
+                *
                 * @param $setup_info   array of application info from 
setup.inc.php files, etc.
+                * @param boolean $DEBUG enable debugging
+                *
+                * @return array processed setup_info values
                 */
-               function drop_langs($setup_info,$DEBUG=False)
+               public function drop_langs($setup_info,$DEBUG=false)
                {
                        @reset($setup_info);
                        while(list($key,$null) = @each($setup_info))
@@ -413,10 +448,13 @@
 
                /**
                 * process application lang files and reinstall
-               *
+                *
                 * @param $setup_info   array of application info from 
setup.inc.php files, etc.
+                * @param boolean $DEBUG enable debugging
+                *
+                * @return array processed setup_info values
                 */
-               function upgrade_langs($setup_info,$DEBUG=False)
+               public function upgrade_langs($setup_info,$DEBUG=false)
                {
                        @reset($setup_info);
                        while(list($key,$null) = @each($setup_info))
@@ -440,17 +478,20 @@
 
                /**
                 * process test_data.inc.php in each application/setup dir for 
developer tests
-               *
+                *
                 * This data should work with the baseline tables
                 * @param $setup_info   array of application info from 
setup.inc.php files, etc.
+                * @param boolean $DEBUG enable debugging
+                *
+                * @return array processed setup_info values
                 */
-               function test_data($setup_info,$DEBUG=False)
+               public function test_data($setup_info,$DEBUG=false)
                {
                        if( !isset($GLOBALS['phpgw_setup']->oProc) || 
!$GLOBALS['phpgw_setup']->oProc)
                        {
                                $this->init_process();
                        }
-                       $GLOBALS['phpgw_setup']->oProc->m_bDeltaOnly = False;
+                       $GLOBALS['phpgw_setup']->oProc->m_bDeltaOnly = false;
 
                        if ( !is_array($setup_info) )
                        {
@@ -479,10 +520,13 @@
 
                /**
                 * process baseline table setup in each application/setup dir
-               *
+                *
                 * @param $appinfo      array of application info from 
setup.inc.php files, etc.
+                * @param boolean $DEBUG enable debugging
+                *
+                * @return array processed setup_info values
                 */
-               function baseline($setup_info,$DEBUG=False)
+               public function baseline($setup_info,$DEBUG=false)
                {
                        if ( !isset($GLOBALS['phpgw_setup']->oProc) || 
!$GLOBALS['phpgw_setup'] )
                        {
@@ -527,17 +571,20 @@
 
                /**
                 * process available upgrades in each application/setup dir
-               *
+                *
                 * @param $appinfo      array of application info from 
setup.inc.php files, etc.
+                * @param boolean $DEBUG enable debugging
+                *
+                * @return array processed setup_info values
                 */
-               function upgrade($setup_info, $DEBUG = false)
+               public function upgrade($setup_info, $DEBUG = false)
                {
                        if( !isset($GLOBALS['phpgw_setup']->oProc) || 
!$GLOBALS['phpgw_setup']->oProc )
                        {
                                $this->init_process();
                        }
                        $GLOBALS['phpgw_setup']->oProc->m_odb->HaltOnError = 
'report';
-                       $GLOBALS['phpgw_setup']->oProc->m_bDeltaOnly = True;
+                       $GLOBALS['phpgw_setup']->oProc->m_bDeltaOnly = true;
 
                        if ( !is_array($setup_info) )
                        {
@@ -617,8 +664,8 @@
                                                        {
                                                                $currentver = 
isset($setup_info[$key]['currentver']) ? $setup_info[$key]['currentver'] : '';
 
-                                                               /* build 
upgrade function name */
-                                                               $function = 
$appname . '_upgrade' . ereg_replace("\.", '_', $value);
+                                                               /* build 
upgrade public function name */
+                                                               $public 
function = $appname . '_upgrade' . ereg_replace("\.", '_', $value);
 
                                                                if($DEBUG)
                                                                {
@@ -632,7 +679,7 @@
 
                                                                if($value == 
$targetver)
                                                                {
-                                                                       
$GLOBALS['phpgw_setup']->oProc->m_bDeltaOnly = False;
+                                                                       
$GLOBALS['phpgw_setup']->oProc->m_bDeltaOnly = false;
                                                                        /* Done 
upgrading */
                                                                        
if($DEBUG)
                                                                        {
@@ -656,9 +703,9 @@
                                                                elseif ( 
($value == $currentver) || !$currentver)
                                                                {
                                                                        /* 
start upgrading db in addition to bas eline */
-                                                                       
$GLOBALS['phpgw_setup']->oProc->m_bDeltaOnly = False;
+                                                                       
$GLOBALS['phpgw_setup']->oProc->m_bDeltaOnly = false;
                                                                        
if($DEBUG) { echo '<br>process->upgrade(): running ' . $function; }
-                                                                       /* run 
upgrade function */
+                                                                       /* run 
upgrade public function */
                                                                        
$success = $function();
                                                                        if ( 
$success )
                                                                        {
@@ -707,8 +754,8 @@
                                                                elseif ( 
$GLOBALS['phpgw_setup']->alessthanb($value, $currentver) )
                                                                {
                                                                /*
-                                                                       
if($DEBUG) { echo '<br>process->upgrade(): running baseline delta only: ' . 
$function . '...'; }
-                                                                       
$GLOBALS['phpgw_setup']->oProc->m_bDeltaOnly = True;
+                                                                       
if($DEBUG) { echo '<br>process->upgrade(): running baseline delta only: ' . 
$public function . '...'; }
+                                                                       
$GLOBALS['phpgw_setup']->oProc->m_bDeltaOnly = true;
                                                                        
$success = $function();
                                                                */
                                                                }
@@ -774,14 +821,18 @@
                }
 
                /**
-                * commit above processing to the db
-               *
+                * Create new tables in the database
+                *
+                * @param array   $tables the tables to create
+                * @param boolean $DEBUG enable debugging
+                *
+                * @return array processed setup_info values
                 */
-               function post_process($tables,$DEBUG=False)
+               public function post_process($tables,$DEBUG=false)
                {
                        if(!$tables)
                        {
-                               return False;
+                               return false;
                        }
 
                        $ret = 
$GLOBALS['phpgw_setup']->oProc->GenerateScripts($tables,$DEBUG);
@@ -790,29 +841,31 @@
                                $oret = 
$GLOBALS['phpgw_setup']->oProc->ExecuteScripts($tables,$DEBUG);
                                if($oret)
                                {
-                                       return True;
+                                       return true;
                                }
                                else
                                {
-                                       return False;
+                                       return false;
                                }
                        }
                        else
                        {
-                               return False;
+                               return false;
                        }
                }
 
                /**
                 * send this a table name, returns printable column spec and 
keys for the table from schema_proc
-               *
-                * @param       $tablename      table whose array you want to 
see
+                *
+                * @param string $tablename name of table to fetch structure for
+                *
+                * @return array the table structure as an array
                 */
-               function sql_to_array($tablename='')
+               public function sql_to_array($tablename='')
                {
                        if(!$tablename)
                        {
-                               return False;
+                               return false;
                        }
 
                        if(!$GLOBALS['phpgw_setup']->oProc)
@@ -840,4 +893,3 @@
                        return array($arr,$pk,$fk,$ix,$uc);
                }
        }
-?>

Modified: trunk/phpgwapi/inc/class.setup_translation.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.setup_translation.inc.php  2008-06-07 22:42:12 UTC 
(rev 18601)
+++ trunk/phpgwapi/inc/class.setup_translation.inc.php  2008-06-07 23:43:47 UTC 
(rev 18602)
@@ -1,12 +1,14 @@
 <?php
        /**
        * Setup translation - Handles multi-language support using flat files
+       *
+       * @author Dave Hall <address@hidden>
        * @author Miles Lott <address@hidden>
        * @author Dan Kuykendall <address@hidden>
        * @copyright Portions Copyright (C) 2001-2004 Free Software Foundation, 
Inc. http://www.fsf.org/
-       * @license http://www.fsf.org/licenses/lgpl.html GNU Lesser General 
Public License
-       * @package phpgwapi
-       * @subpackage application
+       * @license http://www.fsf.org/licenses/lgpl.html GNU Lesser General 
Public License v3 or later
+       * @package phpgroupware
+       * @subpackage phpgwapi
        * @version $Id$
        */
 
@@ -14,28 +16,30 @@
 
        /**
        * Setup translation - Handles multi-language support using flat files
-       * 
-       * @package phpgwapi
-       * @subpackage application
+       *
+       * @package phpgroupware
+       * @subpackage phpgwapi
        */
        class phpgwapi_setup_translation extends phpgwapi_translation
        {
                var $langarray;
 
                /**
-                * constructor for the class, loads all phrases into langarray
-               *
+                * Constructor
+                *
                 * @param $lang user lang variable (defaults to en)
+                *
+                * @return void
                 */
                public function __construct()
                {
                        $ConfigLang = phpgw::get_var('ConfigLang');
                        $this->set_userlang($ConfigLang);
 
-                       $fn = "./lang/phpgw_{$this->userlang}.lang";
+                       $fn = PHPGW_SERVER_ROOT . 
"/phpgwapi/setup/phpgw_{$this->userlang}.lang";
                        if (!file_exists($fn))
                        {
-                               $fn = './lang/phpgw_en.lang';
+                               $fn = PHPGW_SERVER_ROOT . 
'/phpgwapi/setup/phpgw_en.lang';
                        }
 
                        $strings = $this->parse_lang_file($fn, $this->userlang);
@@ -62,6 +66,8 @@
                 *
                 * @param $key  phrase to translate
                 * @param $vars vars sent to lang function, passed to us
+                *
+                * @return string the translated string
                 */
                public function translate($key, $vars = array(), $only_common = 
false ) 
                {
@@ -89,56 +95,58 @@
                        return $ret;
                }
 
-               /* Following functions are called for app (un)install */
-
                /**
-                * return array of installed languages, e.g. array('de','en')
-               *
+                * Get a list of installed languages
+                *
+                * @param bool $DEBUG enabled debugging?
+                *
+                * @return array list installed languages, e.g. array('de','en')
                 */
-               function get_langs($DEBUG=False)
+               public function get_langs($DEBUG=false)
                {
-                       if($DEBUG)
+                       $langs = array();
+
+                       if ( $DEBUG )
                        {
                                echo '<br>get_langs(): checking db...' . "\n";
                        }
+
                        $GLOBALS['phpgw_setup']->db->query("SELECT 
DISTINCT(lang) FROM phpgw_lang",__LINE__,__FILE__);
-                       $langs = array();
-
                        while($GLOBALS['phpgw_setup']->db->next_record())
                        {
-                               if($DEBUG)
+                               if ( $DEBUG )
                                {
                                        echo '<br>get_langs(): found ' . 
$GLOBALS['phpgw_setup']->db->f(0);
                                }
+
                                $langs[] = $GLOBALS['phpgw_setup']->db->f(0);
                        }
+
                        return $langs;
                }
 
                /**
-                * delete all lang entries for an application, return True if 
langs were found
+                * delete all lang entries for an application, return true if 
langs were found
                *
                 * @param $appname app_name whose translations you want to 
delete
+                *
+                * @return bool was the language deleted?
                 */
-               function drop_langs($appname,$DEBUG=False)
+               public function drop_langs($appname, $DEBUG = false)
                {
                        if($DEBUG)
                        {
                                echo '<br>drop_langs(): Working on: ' . 
$appname;
                        }
+
                        $GLOBALS['phpgw_setup']->db->query("SELECT 
COUNT(message_id) FROM phpgw_lang WHERE app_name='$appname'",__LINE__,__FILE__);
                        $GLOBALS['phpgw_setup']->db->next_record();
-                       if($GLOBALS['phpgw_setup']->db->f(0))
+                       if ( $GLOBALS['phpgw_setup']->db->f(0) )
                        {
-                               if(function_exists('sem_get'))
+                               if ( function_exists('sem_get') )
                                {
-                                       if ( !isset($GLOBALS['phpgw']->shm) || 
!is_object($GLOBALS['phpgw']->shm) )
-                                       {
-                                               $GLOBALS['phpgw']->shm = 
CreateObject('phpgwapi.shm');
-                                       }
-
                                        
$GLOBALS['phpgw_setup']->db->query("SELECT lang FROM phpgw_lang WHERE 
app_name='$appname'",__LINE__,__FILE__);
-                                       while 
($GLOBALS['phpgw_setup']->db->next_record())
+                                       while ( 
$GLOBALS['phpgw_setup']->db->next_record() )
                                        {
                                                
$GLOBALS['phpgw']->shm->delete_key('lang_' . 
$GLOBALS['phpgw_setup']->db->f('lang'));
                                        }
@@ -146,25 +154,27 @@
 
                                $GLOBALS['phpgw_setup']->db->query("DELETE FROM 
phpgw_lang WHERE app_name='$appname'",__LINE__,__FILE__);
 
-                               return True;
+                               return true;
                        }
-                       return False;
+                       return false;
                }
 
                /**
                 * process an application's lang files, calling get_langs() to 
see what langs the admin installed already
-               *
+                *
                 * @param $appname app_name of application to process
+                *
+                * @return void
                 */
-               function add_langs($appname,$DEBUG=False,$force_en=False)
+               public function add_langs($appname, $DEBUG = false, $force_en = 
false)
                {
                        $langs = $this->get_langs($DEBUG);
-                       if($force_en && address@hidden('en',$langs))
+                       if ( $force_en && !in_array('en', $langs) )
                        {
                                $langs[] = 'en';
                        }
 
-                       if($DEBUG)
+                       if ( $DEBUG )
                        {
                                echo '<br>add_langs(): chose these langs: ';
                                _debug_array($langs);
@@ -185,13 +195,15 @@
                                {
                                        echo '<br>add_langs(): Working on: ' . 
$lang . ' for ' . $appname;
                                }
+
                                $appfile = PHPGW_SERVER_ROOT . 
"/{$appname}/setup/phpgw_{$lang}.lang";
-                               if(file_exists($appfile))
+                               if ( file_exists($appfile) )
                                {
-                                       if($DEBUG)
+                                       if ( $DEBUG )
                                        {
                                                echo '<br>add_langs(): 
Including: ' . $appfile;
                                        }
+
                                        $raw_file = 
$this->parse_lang_file($appfile, $lang);
 
                                        foreach ( $raw_file as $line ) 
@@ -203,14 +215,15 @@
 
                                                
$GLOBALS['phpgw_setup']->db->query("SELECT COUNT(*) FROM phpgw_lang WHERE 
message_id='$message_id' and lang='{$lang}' ", __LINE__, __FILE__);
                                                
$GLOBALS['phpgw_setup']->db->next_record();
-                                               if 
($GLOBALS['phpgw_setup']->db->f(0) == 0)
+                                               if ( 
$GLOBALS['phpgw_setup']->db->f(0) == 0 )
                                                {
-                                                       if($message_id && 
$content)
+                                                       if ( $message_id && 
$content )
                                                        {
-                                                               if($DEBUG)
+                                                               if ( $DEBUG )
                                                                {
                                                                        echo 
"<br>add_langs(): adding - INSERT INTO phpgw_lang VALUES 
('{$message_id}','{$app_name}','{$lang}','{$content}')";
                                                                }
+
                                                                
$GLOBALS['phpgw_setup']->db->query("INSERT INTO phpgw_lang VALUES 
('{$message_id}','{$app_name}','{$lang}','{$content}')", __LINE__, __FILE__);
                                                        }
                                                }

Modified: trunk/setup/applications.php
===================================================================
--- trunk/setup/applications.php        2008-06-07 22:42:12 UTC (rev 18601)
+++ trunk/setup/applications.php        2008-06-07 23:43:47 UTC (rev 18602)
@@ -1,13 +1,32 @@
 <?php
        /**
-       * Setup
-       *
-       * @copyright Copyright (C) 2000-2005 Free Software Foundation, Inc. 
http://www.fsf.org/
-       * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
-       * @package setup
-       * @version $Id$
-       */
+        * Setup - Applications Manager
+        *
+        * @author Dave Hall <address@hidden>
+        * @author Others <unknown>
+        * @copyright Copyright (C) 2000 - 2008 Free Software Foundation, Inc. 
http://www.fsf.org/
+        * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License v3 or later
+        * @package phpgroupware
+        * @subpackage setup
+        * @version $Id$
+        */
 
+       /*
+          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 3 of the License, or
+          (at your option) any later version.
+
+          This program is distributed in the hope that it will be useful,
+          but WITHOUT ANY WARRANTY; without even the implied warranty of
+          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+          GNU Lesser General Public License for more details.
+
+          You should have received a copy of the GNU General Public License
+          along with this program.  If not, see <http://www.gnu.org/licenses/>.
+        */
+
+
        $DEBUG = (isset($_POST['debug']) && $_POST['debug']) || 
(isset($_GET['debug']) && $_GET['debug']);
        /*
         TODO: We allow a user to hose their setup here, need to make use
@@ -148,6 +167,8 @@
                                if ( isset($setup_info[$appname]['tables'])
                                        && $setup_info[$appname]['tables'] )
                                {
+                                       // Tables has to be dropped in reversed 
order (mssql) if they are referenced by others
+                                       $terror[0]['tables'] = 
array_reverse($setup_info[$appname]['tables']);
                                        
$GLOBALS['phpgw_setup']->process->droptables($terror, $DEBUG);
                                        echo '<li>' . lang('%1 tables dropped', 
lang($appname)) . ".</li>\n";
                                }






reply via email to

[Prev in Thread] Current Thread [Next in Thread]