fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [15475] Syncromind: merge 15422:15474 from trunk


From: sigurdne
Subject: [Fmsystem-commits] [15475] Syncromind: merge 15422:15474 from trunk
Date: Tue, 16 Aug 2016 18:50:47 +0000 (UTC)

Revision: 15475
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=15475
Author:   sigurdne
Date:     2016-08-16 18:50:46 +0000 (Tue, 16 Aug 2016)
Log Message:
-----------
Syncromind: merge 15422:15474 from trunk

Modified Paths:
--------------
    branches/dev-syncromind-2/bim/inc/class.sobimitem.inc.php
    branches/dev-syncromind-2/bim/setup/setup.inc.php
    branches/dev-syncromind-2/bim/setup/tables_current.inc.php
    branches/dev-syncromind-2/bim/setup/tables_update.inc.php
    branches/dev-syncromind-2/controller/inc/class.uicomponent.inc.php
    branches/dev-syncromind-2/controller/templates/base/component.xsl
    branches/dev-syncromind-2/frontend/inc/class.bofellesdata.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/README.md
    branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-active-record.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-active-recordx.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-csvlib.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-datadict.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-error.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-errorhandler.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-errorpear.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-exceptions.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-iterator.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-lib.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-memcache.lib.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-pager.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-pear.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-perf.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-php4.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-time.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-xmlschema.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-xmlschema03.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/composer.json
    
branches/dev-syncromind-2/phpgwapi/inc/adodb/datadict/datadict-access.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/datadict/datadict-db2.inc.php
    
branches/dev-syncromind-2/phpgwapi/inc/adodb/datadict/datadict-firebird.inc.php
    
branches/dev-syncromind-2/phpgwapi/inc/adodb/datadict/datadict-generic.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/datadict/datadict-ibase.inc.php
    
branches/dev-syncromind-2/phpgwapi/inc/adodb/datadict/datadict-informix.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/datadict/datadict-mssql.inc.php
    
branches/dev-syncromind-2/phpgwapi/inc/adodb/datadict/datadict-mssqlnative.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/datadict/datadict-mysql.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/datadict/datadict-oci8.inc.php
    
branches/dev-syncromind-2/phpgwapi/inc/adodb/datadict/datadict-postgres.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/datadict/datadict-sapdb.inc.php
    
branches/dev-syncromind-2/phpgwapi/inc/adodb/datadict/datadict-sqlite.inc.php
    
branches/dev-syncromind-2/phpgwapi/inc/adodb/datadict/datadict-sybase.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-access.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-ado.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-ado5.inc.php
    
branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-ado_access.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-ado_mssql.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-ads.inc.php
    
branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-borland_ibase.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-csv.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-db2.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-db2oci.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-db2ora.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-fbsql.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-firebird.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-ibase.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-informix.inc.php
    
branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-informix72.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-ldap.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-mssql.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-mssql_n.inc.php
    
branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-mssqlnative.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-mssqlpo.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-mysql.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-mysqli.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-mysqlpo.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-mysqlt.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-netezza.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-oci8.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-oci805.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-oci8po.inc.php
    
branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-oci8quercus.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-odbc.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-odbc_db2.inc.php
    
branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-odbc_mssql.inc.php
    
branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-odbc_oracle.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-odbtp.inc.php
    
branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-odbtp_unicode.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-oracle.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-pdo.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-pdo_mssql.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-pdo_mysql.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-pdo_oci.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-pdo_pgsql.inc.php
    
branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-pdo_sqlite.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-postgres.inc.php
    
branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-postgres64.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-postgres7.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-postgres8.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-postgres9.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-proxy.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-sapdb.inc.php
    
branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-sqlanywhere.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-sqlite.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-sqlite3.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-sqlitepo.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-sybase.inc.php
    
branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-sybase_ase.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-vfp.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/lang/adodb-ar.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/lang/adodb-bg.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/lang/adodb-ca.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/lang/adodb-cn.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/lang/adodb-cz.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/lang/adodb-da.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/lang/adodb-de.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/lang/adodb-fr.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/lang/adodb-hu.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/lang/adodb-it.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/lang/adodb-pl.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/lang/adodb-pt-br.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/lang/adodb-sv.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/pear/Auth/Container/ADOdb.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/perf/perf-db2.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/perf/perf-informix.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/perf/perf-mssql.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/perf/perf-mssqlnative.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/perf/perf-mysql.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/perf/perf-oci8.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/perf/perf-postgres.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/pivottable.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/rsfilter.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/server.php
    
branches/dev-syncromind-2/phpgwapi/inc/adodb/session/adodb-compress-bzip2.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/session/adodb-compress-gzip.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/session/adodb-cryptsession.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/session/adodb-cryptsession2.php
    
branches/dev-syncromind-2/phpgwapi/inc/adodb/session/adodb-encrypt-mcrypt.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/session/adodb-encrypt-md5.php
    
branches/dev-syncromind-2/phpgwapi/inc/adodb/session/adodb-encrypt-secret.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/session/adodb-session-clob.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/session/adodb-session-clob2.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/session/adodb-session.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/session/adodb-session2.php
    
branches/dev-syncromind-2/phpgwapi/inc/adodb/session/old/adodb-cryptsession.php
    
branches/dev-syncromind-2/phpgwapi/inc/adodb/session/old/adodb-session-clob.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/session/old/adodb-session.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/tests/benchmark.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/tests/client.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/tests/test-datadict.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/tests/test-php5.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/tests/test.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/tests/test3.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/tests/test4.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/tests/test5.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/tests/testcache.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/tests/testdatabases.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/tests/testmssql.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/tests/testoci8.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/tests/testoci8cursor.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/tests/testpaging.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/tests/testpear.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/tests/testsessions.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/toexport.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/tohtml.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/auth/class.auth_customsso.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/class.db.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/class.db_adodb.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/class.db_pdo.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/class.ofphpgwapi.inc.php
    
branches/dev-syncromind-2/phpgwapi/inc/phpexcel/PHPExcel/Calculation/Functions.php
    branches/dev-syncromind-2/property/inc/class.boentity.inc.php
    branches/dev-syncromind-2/property/inc/class.bogeneric.inc.php
    branches/dev-syncromind-2/property/inc/class.bowo_hour.inc.php
    branches/dev-syncromind-2/property/inc/class.db_oci8.inc.php
    branches/dev-syncromind-2/property/inc/class.soadmin_entity.inc.php
    branches/dev-syncromind-2/property/inc/class.soadmin_location.inc.php
    branches/dev-syncromind-2/property/inc/class.soagreement.inc.php
    branches/dev-syncromind-2/property/inc/class.socustom.inc.php
    branches/dev-syncromind-2/property/inc/class.sodocument.inc.php
    branches/dev-syncromind-2/property/inc/class.soentity.inc.php
    branches/dev-syncromind-2/property/inc/class.soevent.inc.php
    branches/dev-syncromind-2/property/inc/class.sogab.inc.php
    branches/dev-syncromind-2/property/inc/class.sogeneric.inc.php
    branches/dev-syncromind-2/property/inc/class.soinvestment.inc.php
    branches/dev-syncromind-2/property/inc/class.solookup.inc.php
    branches/dev-syncromind-2/property/inc/class.sopending_action.inc.php
    branches/dev-syncromind-2/property/inc/class.sopricebook.inc.php
    branches/dev-syncromind-2/property/inc/class.soproject.inc.php
    branches/dev-syncromind-2/property/inc/class.sorequest.inc.php
    branches/dev-syncromind-2/property/inc/class.soresponsible.inc.php
    branches/dev-syncromind-2/property/inc/class.sos_agreement.inc.php
    branches/dev-syncromind-2/property/inc/class.sotemplate.inc.php
    branches/dev-syncromind-2/property/inc/class.uigeneric.inc.php
    branches/dev-syncromind-2/property/inc/class.uiimport.inc.php
    branches/dev-syncromind-2/property/inc/class.uitts.inc.php
    branches/dev-syncromind-2/property/inc/class.uiwo_hour.inc.php
    
branches/dev-syncromind-2/property/inc/cron/default/synkroniser_avdelinger_med_fellesdata.php
    branches/dev-syncromind-2/property/inc/cron/default/synkroniser_med_boei.php
    branches/dev-syncromind-2/property/inc/hook_config.inc.php
    branches/dev-syncromind-2/property/inc/import/import_update_generic.php
    branches/dev-syncromind-2/property/js/portico/wo_hour.index.js
    branches/dev-syncromind-2/property/setup/default_records.inc.php
    branches/dev-syncromind-2/property/setup/setup.inc.php
    branches/dev-syncromind-2/property/setup/tables_current.inc.php
    branches/dev-syncromind-2/property/setup/tables_update.inc.php
    branches/dev-syncromind-2/property/templates/base/attributes_form.xsl
    branches/dev-syncromind-2/property/templates/base/config.tpl
    branches/dev-syncromind-2/property/templates/base/tts.xsl
    branches/dev-syncromind-2/property/templates/base/wo_hour.index.xsl
    branches/dev-syncromind-2/rental/inc/class.bofellesdata.inc.php

Added Paths:
-----------
    branches/dev-syncromind-2/phpgwapi/inc/adodb/LICENSE.md
    branches/dev-syncromind-2/phpgwapi/inc/adodb/docs/README.md
    branches/dev-syncromind-2/phpgwapi/inc/adodb/docs/changelog.md
    branches/dev-syncromind-2/phpgwapi/inc/adodb/docs/changelog_v2.x.md
    branches/dev-syncromind-2/phpgwapi/inc/adodb/docs/changelog_v3.x.md
    branches/dev-syncromind-2/phpgwapi/inc/adodb/docs/changelog_v4+5.md
    branches/dev-syncromind-2/phpgwapi/inc/adodb/docs/changelog_v4.x.md
    
branches/dev-syncromind-2/phpgwapi/inc/adodb/drivers/adodb-pdo_sqlsrv.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/lang/adodb-eo.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/lang/adodb-ru.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/lang/adodb-th.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/lang/adodb-uk.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/nbproject/
    branches/dev-syncromind-2/phpgwapi/inc/adodb/x.php

Removed Paths:
-------------
    branches/dev-syncromind-2/phpgwapi/inc/adodb/docs/adodb-faq.html
    branches/dev-syncromind-2/phpgwapi/inc/adodb/docs/docs-active-record.htm
    branches/dev-syncromind-2/phpgwapi/inc/adodb/docs/docs-adodb.htm
    branches/dev-syncromind-2/phpgwapi/inc/adodb/docs/docs-datadict.htm
    branches/dev-syncromind-2/phpgwapi/inc/adodb/docs/docs-oracle.htm
    branches/dev-syncromind-2/phpgwapi/inc/adodb/docs/docs-perf.htm
    branches/dev-syncromind-2/phpgwapi/inc/adodb/docs/docs-session.htm
    branches/dev-syncromind-2/phpgwapi/inc/adodb/docs/docs-session.old.htm
    branches/dev-syncromind-2/phpgwapi/inc/adodb/docs/index.html
    branches/dev-syncromind-2/phpgwapi/inc/adodb/docs/old-changelog.htm
    branches/dev-syncromind-2/phpgwapi/inc/adodb/docs/tips_portable_sql.htm
    branches/dev-syncromind-2/phpgwapi/inc/adodb/docs/tute.htm
    branches/dev-syncromind-2/phpgwapi/inc/adodb/lang/adodb-bgutf8.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/lang/adodb-esperanto.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/lang/adodb-ru1251.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/lang/adodb-uk1251.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/lang/adodb_th.inc.php
    branches/dev-syncromind-2/phpgwapi/inc/adodb/license.txt

Property Changed:
----------------
    branches/dev-syncromind-2/


Property changes on: branches/dev-syncromind-2
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/dev-syncromind:13653
/branches/stavangerkommune:12743-12875,12986
/trunk:14934-14935,15165-15215,15218-15220,15222-15304,15306-15337,15339,15341-15398,15400-15421
   + /branches/dev-syncromind:13653
/branches/stavangerkommune:12743-12875,12986
/trunk:14934-14935,15165-15215,15218-15220,15222-15304,15306-15337,15339,15341-15398,15400-15421,15423-15474

Modified: branches/dev-syncromind-2/bim/inc/class.sobimitem.inc.php
===================================================================
--- branches/dev-syncromind-2/bim/inc/class.sobimitem.inc.php   2016-08-16 
18:43:57 UTC (rev 15474)
+++ branches/dev-syncromind-2/bim/inc/class.sobimitem.inc.php   2016-08-16 
18:50:46 UTC (rev 15475)
@@ -53,14 +53,14 @@
                {
                $itemTable = self::bimItemTable;
                $typeTable = self::bimTypeTable;
-                       $sql = "SELECT $itemTable.id, fm_bim_type.name AS type, 
 $itemTable.guid,  $itemTable.xml_representation " .
+                       $sql = "SELECT $itemTable.id, fm_bim_type.name AS type, 
 $itemTable.guid,  $itemTable.json_representation " .
                        "FROM public. $itemTable,  public.$typeTable " .
                                        "WHERE   $itemTable.type = 
$typeTable.id";
                $bimItemArray = array();
                $this->db->query($sql);
                while($this->db->next_record())
                {
-                               $bimItem = new BimItem($this->db->f('id'), 
$this->db->f('guid'), $this->db->f('type'), $this->db->f('xml_representation', 
true));
+                               $bimItem = new BimItem($this->db->f('id'), 
$this->db->f('guid'), $this->db->f('type'), 
$this->db->f('json_representation'));
                        array_push($bimItemArray, $bimItem);
                }
 
@@ -71,7 +71,7 @@
                {
                $itemTable = self::bimItemTable;
                $typeTable = self::bimTypeTable;
-                       $sql = "SELECT $itemTable.id, fm_bim_type.name AS type, 
$itemTable.guid, $itemTable.xml_representation, $itemTable.model " .
+                       $sql = "SELECT $itemTable.id, fm_bim_type.name AS type, 
$itemTable.guid, $itemTable.json_representation, $itemTable.model " .
                        "FROM public.$itemTable,  public.$typeTable " .
                                        "WHERE  $itemTable.type = $typeTable.id 
" .
                                "AND $itemTable.guid ='$bimObjectGuid'";
@@ -83,7 +83,7 @@
                        else
                        {
                        $this->db->next_record();
-                               return new BimItem($this->db->f('id'), 
$this->db->f('guid'), $this->db->f('type'), $this->db->f('xml_representation', 
true), $this->db->f('model'));
+                               return new BimItem($this->db->f('id'), 
$this->db->f('guid'), $this->db->f('type'), 
$this->db->f('json_representation'), $this->db->f('model'));
                }
        }
        
@@ -100,7 +100,7 @@
                $type = $this->db->f('type');
                        $id = $this->db->next_id('fm_bim_item', array('type' => 
$type));
 
-                       $sql = "INSERT INTO " . self::bimItemTable . " (type, 
id, guid, xml_representation, model) values ($type, $id,";
+                       $sql = "INSERT INTO " . self::bimItemTable . " (type, 
id, guid, json_representation, model) values ($type, $id,";
        //      $sql = $sql."(select id from ".self::bimTypeTable." where name 
= '".$bimItem->getType()."'),";
                        $sql = $sql . "'" . $bimItem->getGuid() . "', '" . 
$this->db->db_addslashes($bimItem->getXml()) . "', " . $bimItem->getModelId() . 
")";
                        try
@@ -164,7 +164,7 @@
                        {
                        throw new Exception("Item does not exist!");
                }
-                       $sql = "Update " . self::bimItemTable . " set 
xml_representation='" . $this->db->db_addslashes($bimItem->getXml()) . "' where 
guid='" . $bimItem->getGuid() . "'";
+                       $sql = "Update " . self::bimItemTable . " set 
json_representation='" . $bimItem->getXml() . "' where guid='" . 
$bimItem->getGuid() . "'";
                
                        if(is_null($this->db->query($sql, __LINE__, __FILE__)))
                        {
@@ -191,8 +191,8 @@
                {
                $columnAlias = "attribute_values";
                $itemTable = self::bimItemTable;
-               //$sql = "select 
xpath('descendant-or-self::*[$attribute]/$attribute/text()', (select 
xml_representation from fm_bim_data where guid='$bimItemGuid'))";
-               $sql = "select 
array_to_string(xpath('descendant-or-self::*[$attribute]/$attribute/text()', 
(select xml_representation from $itemTable where guid='$bimItemGuid')), ',') as 
$columnAlias";
+               //$sql = "select 
xpath('descendant-or-self::*[$attribute]/$attribute/text()', (select 
json_representation from fm_bim_data where guid='$bimItemGuid'))";
+               $sql = "select 
array_to_string(xpath('descendant-or-self::*[$attribute]/$attribute/text()', 
(select json_representation from $itemTable where guid='$bimItemGuid')), ',') 
as $columnAlias";
                        $this->db->query($sql, __LINE__, __FILE__);
                        if($this->db->num_rows() == 0)
                        {

Modified: branches/dev-syncromind-2/bim/setup/setup.inc.php
===================================================================
--- branches/dev-syncromind-2/bim/setup/setup.inc.php   2016-08-16 18:43:57 UTC 
(rev 15474)
+++ branches/dev-syncromind-2/bim/setup/setup.inc.php   2016-08-16 18:50:46 UTC 
(rev 15475)
@@ -11,7 +11,7 @@
        * @version $Id: setup.inc.php 6982 2011-02-14 20:01:17Z sigurdne $
        */
        $setup_info['bim']['name']                      = 'bim';
-       $setup_info['bim']['version']           = '0.9.17.510';
+       $setup_info['bim']['version']           = '0.9.17.511';
        $setup_info['bim']['app_order']         = 8;
        $setup_info['bim']['enable']            = 1;
        $setup_info['bim']['app_group']         = 'office';

Modified: branches/dev-syncromind-2/bim/setup/tables_current.inc.php
===================================================================
--- branches/dev-syncromind-2/bim/setup/tables_current.inc.php  2016-08-16 
18:43:57 UTC (rev 15474)
+++ branches/dev-syncromind-2/bim/setup/tables_current.inc.php  2016-08-16 
18:50:46 UTC (rev 15475)
@@ -50,7 +50,7 @@
                                'id' => array('type' => 'int', 'precision' => 
4, 'nullable' => False),
                                'type' => array('type' => 'int', 'precision' => 
4, 'nullable' => False),
                                'guid' => array('type' => 'varchar', 
'precision' => 50, 'nullable' => False),
-                               'xml_representation' => array('type' => 'xml', 
'nullable' => False),
+                               'json_representation' => array('type' => 
'jsonb', 'nullable' => False),
                                'model' => array('type' => 'int', 'precision' 
=> 4, 'nullable' => False),
                                'p_location_id' => array('type' => 'int', 
'precision' => '4', 'nullable' => True),
                                'p_id' => array('type' => 'int', 'precision' => 
'4', 'nullable' => True),

Modified: branches/dev-syncromind-2/bim/setup/tables_update.inc.php
===================================================================
--- branches/dev-syncromind-2/bim/setup/tables_update.inc.php   2016-08-16 
18:43:57 UTC (rev 15474)
+++ branches/dev-syncromind-2/bim/setup/tables_update.inc.php   2016-08-16 
18:50:46 UTC (rev 15475)
@@ -253,4 +253,54 @@
                        $GLOBALS['setup_info']['bim']['currentver'] = 
'0.9.17.510';
                        return $GLOBALS['setup_info']['bim']['currentver'];
                }
-       }
\ No newline at end of file
+       }
+       /**
+       * Update bim version from 0.9.17.510 to 0.9.17.511
+       */
+       $test[] = '0.9.17.510';
+
+       function bim_upgrade0_9_17_510()
+       {
+               $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+
+               $GLOBALS['phpgw_setup']->oProc->AddColumn('fm_bim_item', 
'json_representation', array(
+                       'type' => 'jsonb', 'nullable' => true));
+
+               $GLOBALS['phpgw_setup']->oProc->query("SELECT 
id,location_id,xml_representation FROM fm_bim_item", __LINE__, __FILE__);
+
+               $items = array();
+               while($GLOBALS['phpgw_setup']->oProc->next_record())
+               {
+                       $items[] = array
+                       (
+                               'id'                    => 
(int)$GLOBALS['phpgw_setup']->oProc->f('id'),
+                               'location_id'   => 
(int)$GLOBALS['phpgw_setup']->oProc->f('location_id'),
+                               'xml_representation' => 
$GLOBALS['phpgw_setup']->oProc->f('xml_representation', true),
+                       );
+               }
+
+               $xmlparse = CreateObject('property.XmlToArray');
+               $xmlparse->setEncoding('UTF-8');
+               $xmlparse->setDecodesUTF8Automaticly(false);
+
+               foreach ($items as $item)
+               {
+                       $xmldata = $item['xml_representation'];
+                       $var_result = $xmlparse->parse($xmldata);
+
+                       $jsondata = json_encode($var_result, JSON_HEX_APOS);
+                       $GLOBALS['phpgw_setup']->oProc->query("UPDATE 
fm_bim_item SET json_representation = '{$jsondata}'"
+                       . " WHERE id = {$item['id']} AND location_id = 
{$item['location_id']}", __LINE__, __FILE__);
+               }
+
+               $GLOBALS['phpgw_setup']->oProc->AlterColumn('fm_bim_item', 
'json_representation', array(
+                       'type' => 'jsonb', 'nullable' => False));
+
+               $GLOBALS['phpgw_setup']->oProc->DropColumn('fm_bim_item', 
array(), 'xml_representation');
+
+               if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+               {
+                       $GLOBALS['setup_info']['bim']['currentver'] = 
'0.9.17.511';
+                       return $GLOBALS['setup_info']['bim']['currentver'];
+               }
+       }

Modified: branches/dev-syncromind-2/controller/inc/class.uicomponent.inc.php
===================================================================
--- branches/dev-syncromind-2/controller/inc/class.uicomponent.inc.php  
2016-08-16 18:43:57 UTC (rev 15474)
+++ branches/dev-syncromind-2/controller/inc/class.uicomponent.inc.php  
2016-08-16 18:50:46 UTC (rev 15475)
@@ -302,12 +302,18 @@
                                                                'text' => 
lang('User'),
                                                                'list' => 
$user_list,
                                                                'onchange' => 
'update_table();'
-                                                       ),
+                                                       ),/*
                                                        array('type' => 
'checkbox',
                                                                'name' => 
'user_only',
                                                                'text' => 
'Filtrer bruker',
                                                                'value' => 1,
                                                                'onclick' => 
'update_table();'
+                                                       ),*/
+                                                       array('type' => 
'checkbox',
+                                                               'name' => 
'all_users',
+                                                               'text' => 'Vis 
totale timer',
+                                                               'value' => 1,
+                                                               'onclick' => 
'update_table();'
                                                        ),
                                                        array('type' => 
'filter',
                                                                'name' => 
'district_id',
@@ -469,7 +475,9 @@
                        $query = phpgw::get_var('query', 'string');
                        $year = phpgw::get_var('year', 'int');
                        $all_items = phpgw::get_var('all_items', 'bool');
-                       $user_only = phpgw::get_var('user_only', 'bool');
+                       $all_users = phpgw::get_var('all_users', 'bool');
+//                     $user_only = phpgw::get_var('user_only', 'bool');
+                       $user_only = $all_users ? false : true;
                        $filter_status = phpgw::get_var('status', 'string');
                        $report_type = phpgw::get_var('report_type', 'string');
                        if ($filter_component_str = 
phpgw::get_var('filter_component', 'string'))
@@ -837,6 +845,11 @@
 
                        if ($report_type == 'summary')
                        {
+                               if($all_users)
+                               {
+                                       $user_id = 0;
+                               }
+
                                return array(
                                        'components' => null,
                                        'summary' => 
$this->get_summary($values, $user_id),
@@ -906,10 +919,10 @@
                                for ($_month = 1; $_month < 13; $_month++)
                                {
                                        $row[$_month] = 
$this->translate_calendar_info($entry[$_month], $year, $_month, $filter_status, 
$found_at_least_one, $keep_only_assigned_to);
-                                       if ($row[$_month] && (!$user_id || 
$entry[$_month]['info']['assigned_to'] == $user_id))
+                                       if(true)// ($row[$_month] && (!$user_id 
|| $entry[$_month]['info']['assigned_to'] == $user_id))
                                        {
-                                               $row_sum[$_month] = 
$entry[$_month]['info']['service_time'] + 
$entry[$_month]['info']['controle_time'];
-                                               $row_sum_actual[$_month] = + 
$entry[$_month]['info']['billable_hours'];
+                                               $row_sum[$_month] = 
(float)$entry[$_month]['info']['service_time'] + 
(float)$entry[$_month]['info']['controle_time'];
+                                               $row_sum_actual[$_month] = + 
(float)$entry[$_month]['info']['billable_hours'];
                                        }
                                        else
                                        {

Modified: branches/dev-syncromind-2/controller/templates/base/component.xsl
===================================================================
--- branches/dev-syncromind-2/controller/templates/base/component.xsl   
2016-08-16 18:43:57 UTC (rev 15474)
+++ branches/dev-syncromind-2/controller/templates/base/component.xsl   
2016-08-16 18:50:46 UTC (rev 15475)
@@ -313,13 +313,14 @@
                        var report_type = $("#report_type").val();
                        var user_id = $("#user_id").val();
                        var custom_frontend = 
$("[name='custom_frontend']").val();
+                       var hide_all_users = false;
 
                        if(custom_frontend ==1)
                        {
                                $( "#user_id" ).hide();
                                $("[for='user_id']").hide();
                        }
-
+//console.log(user_id);
                        if(user_id < 0 || custom_frontend ==1)
                        {
                                $( "#entity_group_id" ).hide();
@@ -330,8 +331,9 @@
                                $("[for='all_items']").hide();
                                $( "#org_unit_id" ).hide();
                                $("[for='org_unit_id']").hide();
-                               $("[name='user_only']").hide();
-                               $("[for='user_only']").hide();
+                               $("[name='all_users']").hide();
+                               $("[for='all_users']").hide();
+                               hide_all_users = true;
                        }
                        else
                        {
@@ -343,21 +345,30 @@
                                $("[for='all_items']").show();
                                $( "#org_unit_id" ).show();
                                $("[for='org_unit_id']").show();
-                               $("[name='user_only']").show();
-                               $("[for='user_only']").show();
+                               $("[name='all_users']").show();
+                               $("[for='all_users']").show();
                        }
 
-                       if(report_type == 'summary')
+                       if(report_type != 'summary' && hide_all_users == false)
                        {
-                               $("[name='user_only']").hide();
-                               $("[for='user_only']").hide();
+                               $("[name='all_users']").show();
+                               $("[for='all_users']").show();
                        }
-                       else
+
+                       if(user_id == '')
                        {
-                               $("[name='user_only']").show();
-                               $("[for='user_only']").show();
+                               $("[name='all_users']").hide();
+                               $("[for='all_users']").hide();
                        }
 
+                       if(report_type == 'summary')
+                       {
+                               $("[name='all_items']").hide();
+                               $("[for='all_items']").hide();
+                               $("[name='status']").hide();
+                               $("[for='status']").hide();
+                       }
+
                        var requestUrl = $("#queryForm").attr("action");
                        requestUrl += '&phpgw_return_as=json' + "&" + 
$("#queryForm").serialize();
 

Modified: branches/dev-syncromind-2/frontend/inc/class.bofellesdata.inc.php
===================================================================
--- branches/dev-syncromind-2/frontend/inc/class.bofellesdata.inc.php   
2016-08-16 18:43:57 UTC (rev 15474)
+++ branches/dev-syncromind-2/frontend/inc/class.bofellesdata.inc.php   
2016-08-16 18:50:46 UTC (rev 15475)
@@ -67,7 +67,11 @@
                                return false;
                        }
 
-                       $db = createObject('phpgwapi.db', null, null, true);
+//                     $db = createObject('phpgwapi.db', null, null, true);
+                       /*
+                        * pdo for oracle is deprecated for php7 - switch to 
oci8/adodb
+                        */
+                       $db = createObject('phpgwapi.db_adodb', null, null, 
true);
 
                        $db->debug = 
!!$config->config_data['external_db_debug'];
                        $db->Host = $config->config_data['external_db_host'];

Copied: branches/dev-syncromind-2/phpgwapi/inc/adodb/LICENSE.md (from rev 
15474, trunk/phpgwapi/inc/adodb/LICENSE.md)
===================================================================
--- branches/dev-syncromind-2/phpgwapi/inc/adodb/LICENSE.md                     
        (rev 0)
+++ branches/dev-syncromind-2/phpgwapi/inc/adodb/LICENSE.md     2016-08-16 
18:50:46 UTC (rev 15475)
@@ -0,0 +1,496 @@
+ADOdb License
+=============
+
+ADOdb is dual licensed under BSD and LGPL.
+
+In plain English, you do not need to distribute your application in source 
code form,
+nor do you need to distribute ADOdb source code, provided you follow the rest 
of
+terms of the BSD license.
+
+For more info about ADOdb, visit http://adodb.sourceforge.net/
+
+BSD 3-Clause License
+--------------------
+
+(c) 2000-2013 John Lim (address@hidden)
+(c) 2014      Damien Regad, Mark Newnham and the ADOdb community
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without 
modification,
+are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+   list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice,
+   this list of conditions and the following disclaimer in the documentation
+   and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holder nor the names of its contributors
+   may be used to endorse or promote products derived from this software 
without
+   specific prior written permission.
+
+### DISCLAIMER
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 
FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+GNU LESSER GENERAL PUBLIC LICENSE
+---------------------------------
+
+_Version 2.1, February 1999_
+_Copyright © 1991, 1999 Free Software Foundation, Inc._
+_51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA_
+
+Everyone is permitted to copy and distribute verbatim copies
+of this license document, but changing it is not allowed.
+
+_This is the first released version of the Lesser GPL.  It also counts
+as the successor of the GNU Library Public License, version 2, hence
+the version number 2.1._
+
+### Preamble
+
+The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it.  You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+When we speak of free software, we are referring to freedom of use,
+not price.  Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights.  These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+We protect your rights with a two-step method: **(1)** we copyright the
+library, and **(2)** we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+To protect each distributor, we want to make it very clear that
+there is no warranty for the free library.  Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+Finally, software patents pose a constant threat to the existence of
+any free program.  We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder.  Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License.  This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License.  We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library.  The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom.  The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+We call this license the “Lesser” General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License.  It also provides other free software developers Less
+of an advantage over competing non-free programs.  These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries.  However, the Lesser license provides advantages in certain
+special circumstances.
+
+For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard.  To achieve this, non-free programs must be
+allowed to use the library.  A more frequent case is that a free
+library does the same job as widely used non-free libraries.  In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software.  For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+“work based on the library” and a “work that uses the library”.  The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+### TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+**0.** This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called “this License”).
+Each licensee is addressed as “you”.
+
+A “library” means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+The “Library”, below, refers to any such software library or work
+which has been distributed under these terms.  A “work based on the
+Library” means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term “modification”.)
+
+“Source code” for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+**1.** You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+**2.** You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+* **a)** The modified work must itself be a software library.
+* **b)** You must cause the files modified to carry prominent notices
+stating that you changed the files and the date of any change.
+* **c)** You must cause the whole of the work to be licensed at no
+charge to all third parties under the terms of this License.
+* **d)** If a facility in the modified Library refers to a function or a
+table of data to be supplied by an application program that uses
+the facility, other than as an argument passed when the facility
+is invoked, then you must make a good faith effort to ensure that,
+in the event an application does not supply such function or
+table, the facility still operates, and performs whatever part of
+its purpose remains meaningful.
+(For example, a function in a library to compute square roots has
+a purpose that is entirely well-defined independent of the
+application.  Therefore, Subsection 2d requires that any
+application-supplied function or table used by this function must
+be optional: if the application does not supply it, the square
+root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+**3.** You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+
+Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+**4.** You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+**5.** A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a “work that uses the Library”.  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+However, linking a “work that uses the Library” with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a “work that uses the
+library”.  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+When a “work that uses the Library” uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+**6.** As an exception to the Sections above, you may also combine or
+link a “work that uses the Library” with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+* **a)** Accompany the work with the complete corresponding
+machine-readable source code for the Library including whatever
+changes were used in the work (which must be distributed under
+Sections 1 and 2 above); and, if the work is an executable linked
+with the Library, with the complete machine-readable “work that
+uses the Library”, as object code and/or source code, so that the
+user can modify the Library and then relink to produce a modified
+executable containing the modified Library.  (It is understood
+that the user who changes the contents of definitions files in the
+Library will not necessarily be able to recompile the application
+to use the modified definitions.)
+* **b)** Use a suitable shared library mechanism for linking with the
+Library.  A suitable mechanism is one that (1) uses at run time a
+copy of the library already present on the user's computer system,
+rather than copying library functions into the executable, and (2)
+will operate properly with a modified version of the library, if
+the user installs one, as long as the modified version is
+interface-compatible with the version that the work was made with.
+* **c)** Accompany the work with a written offer, valid for at
+least three years, to give the same user the materials
+specified in Subsection 6a, above, for a charge no more
+than the cost of performing this distribution.
+* **d)** If distribution of the work is made by offering access to copy
+from a designated place, offer equivalent access to copy the above
+specified materials from the same place.
+* **e)** Verify that the user has already received a copy of these
+materials or that you have already sent this user a copy.
+
+For an executable, the required form of the “work that uses the
+Library” must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+**7.** You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+* **a)** Accompany the combined library with a copy of the same work
+based on the Library, uncombined with any other library
+facilities.  This must be distributed under the terms of the
+Sections above.
+* **b)** Give prominent notice with the combined library of the fact
+that part of it is a work based on the Library, and explaining
+where to find the accompanying uncombined form of the same work.
+
+**8.** You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+**9.** You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+**10.** Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+**11.** If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+**12.** If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded.  In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+**13.** The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Library
+specifies a version number of this License which applies to it and
+“any later version”, you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+**14.** If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+### NO WARRANTY
+
+**15.** BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY “AS IS” WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+**16.** IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+_END OF TERMS AND CONDITIONS_

Modified: branches/dev-syncromind-2/phpgwapi/inc/adodb/README.md
===================================================================
--- branches/dev-syncromind-2/phpgwapi/inc/adodb/README.md      2016-08-16 
18:43:57 UTC (rev 15474)
+++ branches/dev-syncromind-2/phpgwapi/inc/adodb/README.md      2016-08-16 
18:50:46 UTC (rev 15475)
@@ -1,14 +1,30 @@
-ADODB Library for PHP5
+ADOdb Library for PHP5
 ======================
 
-(c) 2000-2014 John Lim (address@hidden)
+[![Join chat on 
Gitter](https://img.shields.io/gitter/room/form-data/form-data.svg)](https://gitter.im/adodb/adodb?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
+[![Download 
ADOdb](https://img.shields.io/sourceforge/dm/adodb.svg)](https://sourceforge.net/projects/adodb/files/latest/download)
 
-Released under both BSD and GNU Lesser GPL library license.
-This means you can use it in proprietary products.
+(c) 2000-2013 John Lim (address@hidden)  
+(c) 2014      Damien Regad, Mark Newnham and the ADOdb community
 
-Home page: http://adodb.sourceforge.net/
+Released under both [BSD 
3-Clause](https://github.com/ADOdb/ADOdb/blob/master/LICENSE.md#bsd-3-clause-license)
 
+and [GNU Lesser GPL library 
2.1](https://github.com/ADOdb/ADOdb/blob/master/LICENSE.md#gnu-lesser-general-public-license)
 
+licenses.  
+This means you can use it in proprietary products; 
+see [License](https://github.com/ADOdb/ADOdb/blob/master/LICENSE.md) for 
details.
 
+Home page: http://adodb.org/
 
+> **WARNING: known issue with Associative Fetch Mode in ADOdb v5.19
+-- PLEASE UPGRADE TO v5.20 !**  
+> When fetching data in Associative mode (i.e. when `$ADODB_FETCH_MODE` is
+> set to *ADODB_FETCH_ASSOC*), recordsets do not return any data (empty 
strings)
+> when using some database drivers. The problem has been reported on MSSQL,
+> Interbase and Foxpro, but possibly affects other drivers as well; all drivers
+> derived from the above are also impacted.
+> For further details, please refer to [Issue 
#20](https://github.com/ADOdb/ADOdb/issues/20).
+
+
 Introduction
 ============
 
@@ -51,18 +67,14 @@
 Documentation and Examples
 ==========================
 
-Refer to the `docs` directory for library documentation and examples.
+Refer to the [ADOdb website](http://adodb.org/) for library documentation and 
examples. The documentation can also be [downloaded for offline 
viewing](https://sourceforge.net/projects/adodb/files/Documentation/).
 
-- Main documentation: `docs-adodb.htm`.
-  Query, update and insert records using a portable API.
-- Data dictionary docs: `docs-datadict.htm`.
-  Describes how to create database tables and indexes in a portable manner.
-- Database performance monitoring docs: `docs-perf.htm`.
-  Allows you to perform health checks, tune and monitor your database.
-- Database-backed session docs: `docs-session.htm`.
+- [Main 
documentation](http://adodb.org/dokuwiki/doku.php?id=v5:userguide:userguide_index):
 Query, update and insert records using a portable API.
+- [Data 
dictionary](http://adodb.org/dokuwiki/doku.php?id=v5:dictionary:dictionary_index)
 describes how to create database tables and indexes in a portable manner.
+- [Database performance 
monitoring](http://adodb.org/dokuwiki/doku.php?id=v5:performance:performance_index)
 allows you to perform health checks, tune and monitor your database.
+- [Database-backed 
sessions](http://adodb.org/dokuwiki/doku.php?id=v5:session:session_index).
 
-There is also a tutorial `tute.htm` that contrasts ADOdb code with
-mysql code.
+There is also a 
[tutorial](http://adodb.org/dokuwiki/doku.php?id=v5:userguide:mysql_tutorial) 
that contrasts ADOdb code with PHP native MySQL code.
 
 
 Files
@@ -78,9 +90,12 @@
 tables are created in test.php.
 
 
-Feature Requests and Bug Reports
-================================
+Support
+=======
 
+To discuss with the ADOdb development team and users, connect to our
+[Gitter chatroom](https://gitter.im/adodb/adodb) using your Github credentials.
+
 Please report bugs, issues and feature requests on Github:
 
 https://github.com/ADOdb/ADOdb/issues

Modified: 
branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-active-record.inc.php
===================================================================
--- branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-active-record.inc.php    
2016-08-16 18:43:57 UTC (rev 15474)
+++ branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-active-record.inc.php    
2016-08-16 18:50:46 UTC (rev 15475)
@@ -1,7 +1,9 @@
 <?php
 /*
 
address@hidden V5.19  23-Apr-2014  (c) 2000-2014 John Lim (jlim#natsoft.com). 
All rights reserved.
address@hidden   v5.20.4  30-Mar-2016
address@hidden (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
address@hidden (c) 2014      Damien Regad, Mark Newnham and the ADOdb community
   Latest version is available at http://adodb.sourceforge.net
  
   Released under both BSD license and Lesser GPL library license. 
@@ -52,19 +54,23 @@
        
                foreach($_ADODB_ACTIVE_DBS as $k => $d) {
                        if (PHP_VERSION >= 5) {
-                               if ($d->db === $db) return $k;
+                               if ($d->db === $db) {
+                                       return $k;
+                               }
                        } else {
-                               if ($d->db->_connectionID === 
$db->_connectionID && $db->database == $d->db->database) 
+                               if ($d->db->_connectionID === 
$db->_connectionID && $db->database == $d->db->database) {
                                        return $k;
                        }
                }
+               }
                
                $obj = new ADODB_Active_DB();
                $obj->db = $db;
                $obj->tables = array();
                
-               if ($index == false) $index = sizeof($_ADODB_ACTIVE_DBS);
-
+               if ($index == false) {
+                       $index = sizeof($_ADODB_ACTIVE_DBS);
+               }
                
                $_ADODB_ACTIVE_DBS[$index] = $obj;
                
@@ -92,7 +98,9 @@
        static function UseDefaultValues($bool=null)
        {
        global $ADODB_ACTIVE_DEFVALS;
-               if (isset($bool)) $ADODB_ACTIVE_DEFVALS = $bool;
+               if (isset($bool)) {
+                       $ADODB_ACTIVE_DEFVALS = $bool;
+               }
                return $ADODB_ACTIVE_DEFVALS;
        }
 
@@ -120,14 +128,21 @@
                }
                
                if (!$table) { 
-                       if (!empty($this->_table)) $table = $this->_table;
+                       if (!empty($this->_table)) {
+                               $table = $this->_table;
+                       }
                        else $table = $this->_pluralize(get_class($this));
                }
                $this->foreignName = strtolower(get_class($this)); // CFR: 
default foreign name
                if ($db) {
                        $this->_dbat = 
ADODB_Active_Record::SetDatabaseAdapter($db);
                } else if (!isset($this->_dbat)) {
-                       if (sizeof($_ADODB_ACTIVE_DBS) == 0) $this->Error("No 
database connection set; use 
ADOdb_Active_Record::SetDatabaseAdapter(\$db)",'ADODB_Active_Record::__constructor');
+                       if (sizeof($_ADODB_ACTIVE_DBS) == 0) {
+                               $this->Error(
+                                       "No database connection set; use 
ADOdb_Active_Record::SetDatabaseAdapter(\$db)",
+                                       'ADODB_Active_Record::__constructor'
+                               );
+                       }
                        end($_ADODB_ACTIVE_DBS);
                        $this->_dbat = key($_ADODB_ACTIVE_DBS);
                }
@@ -146,7 +161,9 @@
        
        function _pluralize($table)
        {
-               if (!ADODB_Active_Record::$_changeNames) return $table;
+               if (!ADODB_Active_Record::$_changeNames) {
+                       return $table;
+               }
 
                $ut = strtoupper($table);
                $len = strlen($table);
@@ -160,8 +177,9 @@
                case 'X':       
                        return $table.'es';
                case 'H': 
-                       if ($lastc2 == 'CH' || $lastc2 == 'SH')
+                       if ($lastc2 == 'CH' || $lastc2 == 'SH') {
                                return $table.'es';
+                       }
                default:
                        return $table.'s';
                }
@@ -172,24 +190,28 @@
        function _singularize($tables)
        {
        
-               if (!ADODB_Active_Record::$_changeNames) return $table;
+               if (!ADODB_Active_Record::$_changeNames) {
+                       return $table;
+               }
        
                $ut = strtoupper($tables);
                $len = strlen($tables);
-               if($ut[$len-1] != 'S')
+               if($ut[$len-1] != 'S') {
                        return $tables; // I know...forget oxen
-               if($ut[$len-2] != 'E')
+               }
+               if($ut[$len-2] != 'E') {
                        return substr($tables, 0, $len-1);
-               switch($ut[$len-3])
-               {
+               }
+               switch($ut[$len-3]) {
                        case 'S':
                        case 'X':
                                return substr($tables, 0, $len-2);
                        case 'I':
                                return substr($tables, 0, $len-3) . 'y';
                        case 'H';
-                               if($ut[$len-4] == 'C' || $ut[$len-4] == 'S')
+                               if($ut[$len-4] == 'C' || $ut[$len-4] == 'S') {
                                        return substr($tables, 0, $len-2);
+                               }
                        default:
                                return substr($tables, 0, $len-1); // ?
                }
@@ -216,7 +238,9 @@
        // use when you don't want ADOdb to auto-pluralize tablename
        static function TableKeyHasMany($table, $tablePKey, $foreignRef, 
$foreignKey = false, $foreignClass = 'ADODB_Active_Record')
        {
-               if (!is_array($tablePKey)) $tablePKey = array($tablePKey);
+               if (!is_array($tablePKey)) {
+                       $tablePKey = array($tablePKey);
+               }
                $ar = new ADODB_Active_Record($table,$tablePKey);
                $ar->hasMany($foreignRef, $foreignKey, $foreignClass);
        }
@@ -260,7 +284,9 @@
        
        static function TableKeyBelongsTo($table, $tablePKey, $foreignRef, 
$foreignKey=false, $parentKey='', $parentClass = 'ADODB_Active_Record')
        {
-               if (!is_array($tablePKey)) $tablePKey = array($tablePKey);
+               if (!is_array($tablePKey)) {
+                       $tablePKey = array($tablePKey);
+               }
                $ar = new ADOdb_Active_Record($table, $tablePKey);
                $ar->belongsTo($foreignRef, $foreignKey, $parentKey, 
$parentClass);
        }
@@ -289,24 +315,34 @@
        {
                $extras = array();
                $table = $this->TableInfo();
-               if ($limit >= 0) $extras['limit'] = $limit;
-               if ($offset >= 0) $extras['offset'] = $offset;
+               if ($limit >= 0) {
+                       $extras['limit'] = $limit;
+               }
+               if ($offset >= 0) {
+                       $extras['offset'] = $offset;
+               }
                
-               if (strlen($whereOrderBy)) 
-                       if (!preg_match('/^[ \n\r]*AND/i',$whereOrderBy))
-                               if (!preg_match('/^[ \n\r]*ORDER[ 
\n\r]/i',$whereOrderBy))
-                                       $whereOrderBy = 'AND '.$whereOrderBy;
+               if (strlen($whereOrderBy)) {
+                       if (!preg_match('/^[ \n\r]*AND/i', $whereOrderBy)) {
+                               if (!preg_match('/^[ \n\r]*ORDER[ \n\r]/i', 
$whereOrderBy)) {
+                                       $whereOrderBy = 'AND ' . $whereOrderBy;
+                               }
+                       }
+               }
                                
-               if(!empty($table->_belongsTo[$name]))
-               {
+               if(!empty($table->_belongsTo[$name])) {
                        $obj = $table->_belongsTo[$name];
                        $columnName = $obj->foreignKey;
-                       if(empty($this->$columnName))
+                       if(empty($this->$columnName)) {
                                $this->$name = null;
-                       else
-                       {
-                               if ($obj->parentKey) $key = $obj->parentKey;
-                               else $key = reset($table->keys);
+                       }
+                       else {
+                               if ($obj->parentKey) {
+                                       $key = $obj->parentKey;
+                               }
+                               else {
+                                       $key = reset($table->keys);
+                               }
                                
                                $arrayOfOne = 
$obj->Find($key.'='.$this->$columnName.' '.$whereOrderBy,false,false,$extras);
                                if ($arrayOfOne) {
@@ -315,8 +351,7 @@
                                }
                        }
                }
-               if(!empty($table->_hasMany[$name]))
-               {       
+               if(!empty($table->_hasMany[$name])) {
                        $obj = $table->_hasMany[$name];
                        $key = reset($table->keys);
                        $id = @$this->$key;
@@ -325,7 +360,9 @@
                                $id = $db->qstr($id);
                        }
                        $objs = $obj->Find($obj->foreignKey.'='.$id. ' 
'.$whereOrderBy,false,false,$extras);
-                       if (!$objs) $objs = array();
+                       if (!$objs) {
+                               $objs = array();
+                       }
                        $this->$name = $objs;
                        return $objs;
                }
@@ -349,11 +386,13 @@
 
                        $acttab = $tables[$tableat];
                        foreach($acttab->flds as $name => $fld) {
-                       if ($ADODB_ACTIVE_DEFVALS && 
isset($fld->default_value)) 
+                               if ($ADODB_ACTIVE_DEFVALS && 
isset($fld->default_value)) {
                                $this->$name = $fld->default_value;
-                       else
+                               }
+                               else {
                                $this->$name = null;
                        }
+                       }
                        return;
                }
                $db = $activedb->db;
@@ -368,11 +407,13 @@
                                // ideally, you should cache at least 32 secs
                                
                                foreach($acttab->flds as $name => $fld) {
-                                       if ($ADODB_ACTIVE_DEFVALS && 
isset($fld->default_value)) 
+                                       if ($ADODB_ACTIVE_DEFVALS && 
isset($fld->default_value)) {
                                                $this->$name = 
$fld->default_value;
-                                       else
+                                       }
+                                       else {
                                                $this->$name = null;
                                }
+                               }
        
                                $activedb->tables[$table] = $acttab;
                                
@@ -387,11 +428,15 @@
                
                $save = $ADODB_FETCH_MODE;
                $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
-               if ($db->fetchMode !== false) $savem = $db->SetFetchMode(false);
+               if ($db->fetchMode !== false) {
+                       $savem = $db->SetFetchMode(false);
+               }
                
                $cols = $db->MetaColumns($table);
                
-               if (isset($savem)) $db->SetFetchMode($savem);
+               if (isset($savem)) {
+                       $db->SetFetchMode($savem);
+               }
                $ADODB_FETCH_MODE = $save;
                
                if (!$cols) {
@@ -403,7 +448,9 @@
                        if (isset($fld->primary_key)) {
                                $pkeys = array();
                                foreach($cols as $name => $fld) {
-                                       if (!empty($fld->primary_key)) $pkeys[] 
= $name;
+                                       if (!empty($fld->primary_key)) {
+                                               $pkeys[] = $name;
+                                       }
                                }
                        } else  
                                $pkeys = $this->GetPrimaryKeys($db, $table);
@@ -420,10 +467,12 @@
                case 0:
                        foreach($cols as $name => $fldobj) {
                                $name = strtolower($name);
-                if ($ADODB_ACTIVE_DEFVALS && isset($fldobj->default_value))
+                               if ($ADODB_ACTIVE_DEFVALS && 
isset($fldobj->default_value)) {
                     $this->$name = $fldobj->default_value;
-                else
+                               }
+                               else {
                                        $this->$name = null;
+                               }
                                $attr[$name] = $fldobj;
                        }
                        foreach($pkeys as $k => $name) {
@@ -435,10 +484,12 @@
                        foreach($cols as $name => $fldobj) {
                                $name = strtoupper($name);
                
-                if ($ADODB_ACTIVE_DEFVALS && isset($fldobj->default_value))
+                               if ($ADODB_ACTIVE_DEFVALS && 
isset($fldobj->default_value)) {
                     $this->$name = $fldobj->default_value;
-                else
+                               }
+                               else {
                                        $this->$name = null;
+                               }
                                $attr[$name] = $fldobj;
                        }
                        
@@ -450,10 +501,12 @@
                        foreach($cols as $name => $fldobj) {
                                $name = ($fldobj->name);
                 
-                if ($ADODB_ACTIVE_DEFVALS && isset($fldobj->default_value))
+                               if ($ADODB_ACTIVE_DEFVALS && 
isset($fldobj->default_value)) {
                     $this->$name = $fldobj->default_value;
-                else
+                               }
+                               else {
                                        $this->$name = null;
+                               }
                                $attr[$name] = $fldobj;
                        }
                        foreach($pkeys as $k => $name) {
@@ -468,14 +521,18 @@
                if ($ADODB_ACTIVE_CACHESECS && $ADODB_CACHE_DIR) {
                        $activetab->_created = time();
                        $s = serialize($activetab);
-                       if (!function_exists('adodb_write_file')) 
include(ADODB_DIR.'/adodb-csvlib.inc.php');
+                       if (!function_exists('adodb_write_file')) {
+                               include(ADODB_DIR.'/adodb-csvlib.inc.php');
+                       }
                        adodb_write_file($fname,$s);
                }
                if (isset($activedb->tables[$table])) {
                        $oldtab = $activedb->tables[$table];
                
-                       if ($oldtab) $activetab->_belongsTo = 
$oldtab->_belongsTo;
-                       if ($oldtab) $activetab->_hasMany = $oldtab->_hasMany;
+                       if ($oldtab) {
+                               $activetab->_belongsTo = $oldtab->_belongsTo;
+                               $activetab->_hasMany = $oldtab->_hasMany;
+                       }
                }
                $activedb->tables[$table] = $activetab;
        }
@@ -493,17 +550,26 @@
                $fn = get_class($this).'::'.$fn;
                $this->_lasterr = $fn.': '.$err;
                
-               if ($this->_dbat < 0) $db = false;
+               if ($this->_dbat < 0) {
+                       $db = false;
+               }
                else {
                        $activedb = $_ADODB_ACTIVE_DBS[$this->_dbat];
                        $db = $activedb->db;
                }
                
                if (function_exists('adodb_throw')) {   
-                       if (!$db) adodb_throw('ADOdb_Active_Record', $fn, -1, 
$err, 0, 0, false);
-                       else adodb_throw($db->databaseType, $fn, -1, $err, 0, 
0, $db);
-               } else
-                       if (!$db || $db->debug) 
ADOConnection::outp($this->_lasterr);
+                       if (!$db) {
+                               adodb_throw('ADOdb_Active_Record', $fn, -1, 
$err, 0, 0, false);
+                       }
+                       else {
+                               adodb_throw($db->databaseType, $fn, -1, $err, 
0, 0, $db);
+                       }
+               } else {
+                       if (!$db || $db->debug) {
+                               ADOConnection::outp($this->_lasterr);
+                       }
+               }
                
        }
        
@@ -511,18 +577,26 @@
        function ErrorMsg()
        {
                if (!function_exists('adodb_throw')) {
-                       if ($this->_dbat < 0) $db = false;
-                       else $db = $this->DB();
+                       if ($this->_dbat < 0) {
+                               $db = false;
+                       }
+                       else {
+                               $db = $this->DB();
+                       }
                
                        // last error could be database error too
-                       if ($db && $db->ErrorMsg()) return $db->ErrorMsg();
+                       if ($db && $db->ErrorMsg()) {
+                               return $db->ErrorMsg();
+                       }
                }
                return $this->_lasterr;
        }
        
        function ErrorNo() 
        {
-               if ($this->_dbat < 0) return -9999; // no database connection...
+               if ($this->_dbat < 0) {
+                       return -9999; // no database connection...
+               }
                $db = $this->DB();
                
                return (int) $db->ErrorNo();
@@ -558,8 +632,11 @@
        // So, I find that for myTable, I want to reload an active record after 
saving it. -- Malcolm Cook
        function Reload()
        {
-               $db =& $this->DB(); if (!$db) return false;
-               $table =& $this->TableInfo();
+               $db = $this->DB();
+               if (!$db) {
+                       return false;
+               }
+               $table = $this->TableInfo();
                $where = $this->GenWhere($db, $table);
                return($this->Load($where));
        }
@@ -586,9 +663,10 @@
             if (sizeof($row) == 2 * sizeof($table->flds)) {
                 // Only keep string keys
                 $keys = array_filter(array_keys($row), 'is_string');
-                if (sizeof($keys) == sizeof($table->flds))
+                               if (sizeof($keys) == sizeof($table->flds)) {
                     $bad_size = FALSE;
             }
+                       }
             if ($bad_size) {
                        $this->Error("Table structure of $this->_table has 
changed","Load");
                        return false;
@@ -615,10 +693,12 @@
        // get last inserted id for INSERT
        function LastInsertID(&$db,$fieldname)
        {
-               if ($db->hasInsertID)
+               if ($db->hasInsertID) {
                        $val = $db->Insert_ID($this->_table,$fieldname);
-               else
+               }
+               else {
                        $val = false;
+               }
                        
                if (is_null($val) || $val === false) {
                        // this might not work reliably in multi-user 
environment
@@ -632,19 +712,25 @@
        {
                switch($t) {
                case 'L':
-                       if (strpos($db->databaseType,'postgres') !== false) 
return $db->qstr($val);
+                       if (strpos($db->databaseType,'postgres') !== false) {
+                               return $db->qstr($val);
+                       }
                case 'D':       
                case 'T':
-                       if (empty($val)) return 'null';
-               
+                       if (empty($val)) {
+                               return 'null';
+                       }
                case 'B':       
                case 'N':
                case 'C':
                case 'X':
-                       if (is_null($val)) return 'null';
+                       if (is_null($val)) {
+                               return 'null';
+                       }
                        
                        if (strlen($val)>0 && 
-                               (strncmp($val,"'",1) != 0 || 
substr($val,strlen($val)-1,1) != "'")) { 
+                               (strncmp($val,"'",1) != 0 || 
substr($val,strlen($val)-1,1) != "'")
+                       ) {
                                return $db->qstr($val);
                                break;
                        }
@@ -672,8 +758,15 @@
        
        function _QName($n,$db=false)
        {
-               if (!ADODB_Active_Record::$_quoteNames) return $n;
-               if (!$db) $db = $this->DB(); if (!$db) return false;
+               if (!ADODB_Active_Record::$_quoteNames) {
+                       return $n;
+               }
+               if (!$db) {
+                       $db = $this->DB();
+                       if (!$db) {
+                               return false;
+                       }
+               }
                return $db->nameQuote.$n.$db->nameQuote;
        }
        
@@ -683,23 +776,32 @@
        {
        global $ADODB_FETCH_MODE;
        
-               $db = $this->DB(); if (!$db) return false;
+               $db = $this->DB();
+               if (!$db) {
+                       return false;
+               }
                $this->_where = $where;
                
                $save = $ADODB_FETCH_MODE;
                $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
-               if ($db->fetchMode !== false) $savem = $db->SetFetchMode(false);
+               if ($db->fetchMode !== false) {
+                       $savem = $db->SetFetchMode(false);
+               }
                
                $qry = "select * from ".$this->_table;
                
                if($where) {
                        $qry .= ' WHERE '.$where;
                }
-               if ($lock) $qry .= $this->lockMode;
+               if ($lock) {
+                       $qry .= $this->lockMode;
+               }
                
                $row = $db->GetRow($qry,$bindarr);
                
-               if (isset($savem)) $db->SetFetchMode($savem);
+               if (isset($savem)) {
+                       $db->SetFetchMode($savem);
+               }
                $ADODB_FETCH_MODE = $save;
                
                return $this->Set($row);
@@ -731,8 +833,12 @@
        // false on error
        function Save()
        {
-               if ($this->_saved) $ok = $this->Update();
-               else $ok = $this->Insert();
+               if ($this->_saved) {
+                       $ok = $this->Update();
+               }
+               else {
+                       $ok = $this->Insert();
+               }
                
                return $ok;
        }
@@ -741,7 +847,10 @@
        // false on error
        function Insert()
        {
-               $db = $this->DB(); if (!$db) return false;
+               $db = $this->DB();
+               if (!$db) {
+                       return false;
+               }
                $cnt = 0;
                $table = $this->TableInfo();
                
@@ -791,7 +900,10 @@
        
        function Delete()
        {
-               $db = $this->DB(); if (!$db) return false;
+               $db = $this->DB();
+               if (!$db) {
+                       return false;
+               }
                $table = $this->TableInfo();
                
                $where = $this->GenWhere($db,$table);
@@ -804,7 +916,10 @@
        // returns an array of active record objects
        function 
Find($whereOrderBy,$bindarr=false,$pkeysArr=false,$extra=array())
        {
-               $db = $this->DB(); if (!$db || empty($this->_table)) return 
false;
+               $db = $this->DB();
+               if (!$db || empty($this->_table)) {
+                       return false;
+               }
                $arr = 
$db->GetActiveRecordsClass(get_class($this),$this->_table, 
$whereOrderBy,$bindarr,$pkeysArr,$extra);
                return $arr;
        }
@@ -814,7 +929,10 @@
        {
        global $ADODB_ASSOC_CASE;
                
-               $db = $this->DB(); if (!$db) return false;
+               $db = $this->DB();
+               if (!$db) {
+                       return false;
+               }
                $table = $this->TableInfo();
                
                $pkey = $table->keys;
@@ -824,7 +942,9 @@
                        /*
                        if (is_null($val)) {
                                if (isset($fld->not_null) && $fld->not_null) {
-                                       if (isset($fld->default_value) && 
strlen($fld->default_value)) continue;
+                                       if (isset($fld->default_value) && 
strlen($fld->default_value)) {
+                                               continue;
+                                       }
                                        else {
                                                $this->Error("Cannot update 
null into $name","Replace");
                                                return false;
@@ -835,22 +955,28 @@
                continue;
             }
                        
-                       if (is_array($val)) continue;
+                       if (is_array($val)) {
+                               continue;
+                       }
                        
                        $t = $db->MetaType($fld->type);
                        $arr[$name] = $this->doquote($db,$val,$t);
                        $valarr[] = $val;
                }
                
-               if (!is_array($pkey)) $pkey = array($pkey);
+               if (!is_array($pkey)) {
+                       $pkey = array($pkey);
+               }
                
-               
-               if ($ADODB_ASSOC_CASE == 0) 
+               if ($ADODB_ASSOC_CASE == 0) {
                        foreach($pkey as $k => $v)
                                $pkey[$k] = strtolower($v);
-               elseif ($ADODB_ASSOC_CASE == 1) 
-                       foreach($pkey as $k => $v)
+               }
+               elseif ($ADODB_ASSOC_CASE == 1) {
+                       foreach($pkey as $k => $v) {
                                $pkey[$k] = strtoupper($v);
+                       }
+               }
                                
                $ok = $db->Replace($this->_table,$arr,$pkey);
                if ($ok) {
@@ -877,7 +1003,10 @@
        // returns 0 on error, 1 on update, -1 if no change in data (no update)
        function Update()
        {
-               $db = $this->DB(); if (!$db) return false;
+               $db = $this->DB();
+               if (!$db) {
+                       return false;
+               }
                $table = $this->TableInfo();
                
                $where = $this->GenWhere($db, $table);
@@ -896,12 +1025,15 @@
                        $val = $this->$name;
                        $neworig[] = $val;
                        
-                       if (isset($table->keys[$name]) || is_array($val)) 
+                       if (isset($table->keys[$name]) || is_array($val)) {
                                continue;
+                       }
                        
                        if (is_null($val)) {
                                if (isset($fld->not_null) && $fld->not_null) {
-                                       if (isset($fld->default_value) && 
strlen($fld->default_value)) continue;
+                                       if (isset($fld->default_value) && 
strlen($fld->default_value)) {
+                                               continue;
+                                       }
                                        else {
                                                $this->Error("Cannot set field 
$name to NULL","Update");
                                                return false;
@@ -909,9 +1041,13 @@
                                }
                        }
 
-                       if (isset($this->_original[$i]) && 
strcmp($val,$this->_original[$i]) == 0) continue;
+                       if (isset($this->_original[$i]) && 
strcmp($val,$this->_original[$i]) == 0) {
+                               continue;
+                       }
                        
-                       if (is_null($this->_original[$i]) && is_null($val)) 
continue;
+                       if (is_null($this->_original[$i]) && is_null($val)) {
+                               continue;
+                       }
                        
                        $valarr[] = $val;
                        $pairs[] = 
$this->_QName($name,$db).'='.$db->Param($cnt);
@@ -919,7 +1055,10 @@
                }
                
                
-               if (!$cnt) return -1;
+               if (!$cnt) {
+                       return -1;
+               }
+
                $sql = 'UPDATE '.$this->_table." SET ".implode(",",$pairs)." 
WHERE ".$where;
                $ok = $db->Execute($sql,$valarr);
                if ($ok) {
@@ -932,7 +1071,9 @@
        function GetAttributeNames()
        {
                $table = $this->TableInfo();
-               if (!$table) return false;
+               if (!$table) {
+                       return false;
+               }
                return array_keys($table->flds);
        }
        
@@ -947,10 +1088,10 @@
        $save = $db->SetFetchMode(ADODB_FETCH_NUM);
        $qry = "select * from ".$table;
        
-       if (!empty($whereOrderBy))
+       if (!empty($whereOrderBy)) {
                $qry .= ' WHERE '.$whereOrderBy;
-       if(isset($extra['limit']))
-       {
+       }
+       if(isset($extra['limit'])) {
                $rows = false;
                if(isset($extra['offset'])) {
                        $rs = $db->SelectLimit($qry, $extra['limit'], 
$extra['offset'],$bindarr);

Modified: 
branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-active-recordx.inc.php
===================================================================
--- branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-active-recordx.inc.php   
2016-08-16 18:43:57 UTC (rev 15474)
+++ branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-active-recordx.inc.php   
2016-08-16 18:50:46 UTC (rev 15475)
@@ -1,7 +1,9 @@
 <?php
 /*
 
address@hidden V5.19  23-Apr-2014  (c) 2000-2014 John Lim (jlim#natsoft.com). 
All rights reserved.
address@hidden   v5.20.4  30-Mar-2016
address@hidden (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
address@hidden (c) 2014      Damien Regad, Mark Newnham and the ADOdb community
   Latest version is available at http://adodb.sourceforge.net
  
   Released under both BSD license and Lesser GPL library license. 
@@ -66,12 +68,15 @@
        
                foreach($_ADODB_ACTIVE_DBS as $k => $d) {
                        if (PHP_VERSION >= 5) {
-                               if ($d->db === $db) return $k;
+                               if ($d->db === $db) {
+                                       return $k;
+                               }
                        } else {
-                               if ($d->db->_connectionID === 
$db->_connectionID && $db->database == $d->db->database) 
+                               if ($d->db->_connectionID === 
$db->_connectionID && $db->database == $d->db->database) {
                                        return $k;
                        }
                }
+               }
                
                $obj = new ADODB_Active_DB();
                $obj->db = $db;
@@ -101,7 +106,9 @@
        static function UseDefaultValues($bool=null)
        {
        global $ADODB_ACTIVE_DEFVALS;
-               if (isset($bool)) $ADODB_ACTIVE_DEFVALS = $bool;
+               if (isset($bool)) {
+                       $ADODB_ACTIVE_DEFVALS = $bool;
+               }
                return $ADODB_ACTIVE_DEFVALS;
        }
 
@@ -137,15 +144,13 @@
                        $pkeyarr = false;
                }
                
-               if($table)
-               {
+               if($table) {
                        // table argument exists. It is expected to be
                        // already plural form.
                        $this->_pTable = $table;
                        $this->_sTable = $this->_singularize($this->_pTable);
                }
-               else
-               {
+               else {
                        // We will use current classname as table name.
                        // We need to pluralize it for the real table name.
                        $this->_sTable = strtolower(get_class($this));
@@ -161,7 +166,12 @@
                        $this->_dbat = sizeof($_ADODB_ACTIVE_DBS)-1;
                
                
-               if ($this->_dbat < 0) $this->Error("No database connection set; 
use 
ADOdb_Active_Record::SetDatabaseAdapter(\$db)",'ADODB_Active_Record::__constructor');
+               if ($this->_dbat < 0) {
+                       $this->Error(
+                               "No database connection set; use 
ADOdb_Active_Record::SetDatabaseAdapter(\$db)",
+                               'ADODB_Active_Record::__constructor'
+                       );
+               }
                
                $this->_tableat = $this->_table; # reserved for setting the 
assoc value to a non-table name, eg. the sql string in future
 
@@ -169,8 +179,7 @@
                // but there was no way to ask it to do that.
                $forceUpdate = (isset($options['refresh']) && true === 
$options['refresh']);
                $this->UpdateActiveTable($pkeyarr, $forceUpdate);
-               if(isset($options['new']) && true === $options['new'])
-               {
+               if(isset($options['new']) && true === $options['new']) {
                        $table =& $this->TableInfo();
                        unset($table->_hasMany);
                        unset($table->_belongsTo);
@@ -215,15 +224,14 @@
 
        function _pluralize($table)
        {
-               if (!ADODB_Active_Record::$_changeNames) return $table;
-
+               if (!ADODB_Active_Record::$_changeNames) {
+                       return $table;
+               }
                $ut = strtoupper($table);
-               if(isset(self::$WeIsI[$ut]))
-               {
+               if(isset(self::$WeIsI[$ut])) {
                        return $table;
                }
-               if(isset(self::$IrregularP[$ut]))
-               {
+               if(isset(self::$IrregularP[$ut])) {
                        return self::$IrregularP[$ut];
                }
                $len = strlen($table);
@@ -237,8 +245,9 @@
                case 'X':       
                        return $table.'es';
                case 'H': 
-                       if ($lastc2 == 'CH' || $lastc2 == 'SH')
+                               if ($lastc2 == 'CH' || $lastc2 == 'SH') {
                                return $table.'es';
+                               }
                default:
                        return $table.'s';
                }
@@ -249,32 +258,33 @@
        function _singularize($table)
        {
        
-               if (!ADODB_Active_Record::$_changeNames) return $table;
-       
+               if (!ADODB_Active_Record::$_changeNames) {
+               return $table;
+       }
                $ut = strtoupper($table);
-               if(isset(self::$WeIsI[$ut]))
-               {
+               if(isset(self::$WeIsI[$ut])) {
                        return $table;
                }
-               if(isset(self::$IrregularS[$ut]))
-               {
+               if(isset(self::$IrregularS[$ut])) {
                        return self::$IrregularS[$ut];
                }
                $len = strlen($table);
-               if($ut[$len-1] != 'S')
+               if($ut[$len-1] != 'S') {
                        return $table; // I know...forget oxen
-               if($ut[$len-2] != 'E')
+               }
+               if($ut[$len-2] != 'E') {
                        return substr($table, 0, $len-1);
-               switch($ut[$len-3])
-               {
+               }
+               switch($ut[$len-3]) {
                        case 'S':
                        case 'X':
                                return substr($table, 0, $len-2);
                        case 'I':
                                return substr($table, 0, $len-3) . 'y';
                        case 'H';
-                               if($ut[$len-4] == 'C' || $ut[$len-4] == 'S')
+                               if($ut[$len-4] == 'C' || $ut[$len-4] == 'S') {
                                        return substr($table, 0, $len-2);
+                               }
                        default:
                                return substr($table, 0, $len-1); // ?
                }
@@ -296,8 +306,7 @@
                $ar->foreignKey = ($foreignKey) ? $foreignKey : 
strtolower(get_class($this)) . self::$_foreignSuffix;
 
                $table =& $this->TableInfo();
-               if(!isset($table->_hasMany[$foreignRef]))
-               {
+               if(!isset($table->_hasMany[$foreignRef])) {
                        $table->_hasMany[$foreignRef] = $ar;
                        $table->updateColsCount();
                }
@@ -322,8 +331,7 @@
                $ar->foreignKey = ($foreignKey) ? $foreignKey : 
$ar->foreignName . self::$_foreignSuffix;
                
                $table =& $this->TableInfo();
-               if(!isset($table->_belongsTo[$foreignRef]))
-               {
+               if(!isset($table->_belongsTo[$foreignRef])) {
                        $table->_belongsTo[$foreignRef] = $ar;
                        $table->updateColsCount();
                }
@@ -345,27 +353,35 @@
        function LoadRelations($name, $whereOrderBy, $offset=-1, $limit=-1)
        {
                $extras = array();
-               if($offset >= 0) $extras['offset'] = $offset;
-               if($limit >= 0) $extras['limit'] = $limit;
+               if($offset >= 0) {
+                       $extras['offset'] = $offset;
+               }
+               if($limit >= 0) {
+                       $extras['limit'] = $limit;
+               }
                $table =& $this->TableInfo();
                
-               if (strlen($whereOrderBy)) 
-                       if (!preg_match('/^[ \n\r]*AND/i',$whereOrderBy))
-                               if (!preg_match('/^[ \n\r]*ORDER[ 
\n\r]/i',$whereOrderBy))
+               if (strlen($whereOrderBy)) {
+                       if (!preg_match('/^[ \n\r]*AND/i',$whereOrderBy)) {
+                               if (!preg_match('/^[ \n\r]*ORDER[ 
\n\r]/i',$whereOrderBy)) {
                                        $whereOrderBy = 'AND '.$whereOrderBy;
+                               }
+                       }
+               }
                                        
-               if(!empty($table->_belongsTo[$name]))
-               {
+               if(!empty($table->_belongsTo[$name])) {
                        $obj = $table->_belongsTo[$name];
                        $columnName = $obj->foreignKey;
-                       if(empty($this->$columnName))
+                       if(empty($this->$columnName)) {
                                $this->$name = null;
-                       else
-                       {
-                               if(($k = reset($obj->TableInfo()->keys)))
+                       }
+                       else {
+                               if(($k = reset($obj->TableInfo()->keys))) {
                                        $belongsToId = $k;
-                               else
+                               }
+                               else {
                                        $belongsToId = 'id';
+                               }
                                
                                $arrayOfOne =
                                        $obj->Find(
@@ -374,13 +390,14 @@
                        }
                        return $this->$name;
                }
-               if(!empty($table->_hasMany[$name]))
-               {
+               if(!empty($table->_hasMany[$name])) {
                        $obj = $table->_hasMany[$name];
-                       if(($k = reset($table->keys)))
+                       if(($k = reset($table->keys))) {
                                $hasManyId   = $k;
-                       else
+                       }
+                       else {
                                $hasManyId   = 'id';                    
+                       }
 
                        $this->$name =
                                $obj->Find(
@@ -405,11 +422,13 @@
 
                        $tobj = $tables[$tableat];
                        foreach($tobj->flds as $name => $fld) {
-                       if ($ADODB_ACTIVE_DEFVALS && 
isset($fld->default_value)) 
+                               if ($ADODB_ACTIVE_DEFVALS && 
isset($fld->default_value)) {
                                $this->$name = $fld->default_value;
-                       else
+                               }
+                               else {
                                $this->$name = null;
                        }
+                       }
                        return;
                }
                
@@ -436,11 +455,15 @@
                
                $save = $ADODB_FETCH_MODE;
                $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
-               if ($db->fetchMode !== false) $savem = $db->SetFetchMode(false);
+               if ($db->fetchMode !== false) {
+                       $savem = $db->SetFetchMode(false);
+               }
                
                $cols = $db->MetaColumns($table);
                
-               if (isset($savem)) $db->SetFetchMode($savem);
+               if (isset($savem)) {
+                       $db->SetFetchMode($savem);
+               }
                $ADODB_FETCH_MODE = $save;
                
                if (!$cols) {
@@ -452,11 +475,14 @@
                        if (isset($fld->primary_key)) {
                                $pkeys = array();
                                foreach($cols as $name => $fld) {
-                                       if (!empty($fld->primary_key)) $pkeys[] 
= $name;
+                                       if (!empty($fld->primary_key)) {
+                                               $pkeys[] = $name;
                                }
-                       } else  
+                               }
+                       } else {
                                $pkeys = $this->GetPrimaryKeys($db, $table);
                }
+               }
                if (empty($pkeys)) {
                        $this->Error("No primary key found for table 
$table",'UpdateActiveTable');
                        return false;
@@ -469,10 +495,12 @@
                case 0:
                        foreach($cols as $name => $fldobj) {
                                $name = strtolower($name);
-                if ($ADODB_ACTIVE_DEFVALS && isset($fldobj->default_value))
+                               if ($ADODB_ACTIVE_DEFVALS && 
isset($fldobj->default_value)) {
                     $this->$name = $fldobj->default_value;
-                else
+                               }
+                               else {
                                        $this->$name = null;
+                               }
                                $attr[$name] = $fldobj;
                        }
                        foreach($pkeys as $k => $name) {
@@ -484,10 +512,12 @@
                        foreach($cols as $name => $fldobj) {
                                $name = strtoupper($name);
                
-                if ($ADODB_ACTIVE_DEFVALS && isset($fldobj->default_value))
+                               if ($ADODB_ACTIVE_DEFVALS && 
isset($fldobj->default_value)) {
                     $this->$name = $fldobj->default_value;
-                else
+                               }
+                               else {
                                        $this->$name = null;
+                               }
                                $attr[$name] = $fldobj;
                        }
                        
@@ -499,10 +529,12 @@
                        foreach($cols as $name => $fldobj) {
                                $name = ($fldobj->name);
                 
-                if ($ADODB_ACTIVE_DEFVALS && isset($fldobj->default_value))
+                               if ($ADODB_ACTIVE_DEFVALS && 
isset($fldobj->default_value)) {
                     $this->$name = $fldobj->default_value;
-                else
+                               }
+                               else {
                                        $this->$name = null;
+                               }
                                $attr[$name] = $fldobj;
                        }
                        foreach($pkeys as $k => $name) {
@@ -518,14 +550,18 @@
                if ($ADODB_ACTIVE_CACHESECS && $ADODB_CACHE_DIR) {
                        $activetab->_created = time();
                        $s = serialize($activetab);
-                       if (!function_exists('adodb_write_file')) 
include(ADODB_DIR.'/adodb-csvlib.inc.php');
+                       if (!function_exists('adodb_write_file')) {
+                               include(ADODB_DIR.'/adodb-csvlib.inc.php');
+                       }
                        adodb_write_file($fname,$s);
                }
                if (isset($activedb->tables[$table])) {
                        $oldtab = $activedb->tables[$table];
                
-                       if ($oldtab) $activetab->_belongsTo = 
$oldtab->_belongsTo;
-                       if ($oldtab) $activetab->_hasMany = $oldtab->_hasMany;
+                       if ($oldtab) {
+                               $activetab->_belongsTo = $oldtab->_belongsTo;
+                               $activetab->_hasMany = $oldtab->_hasMany;
+                       }
                }
                $activedb->tables[$table] = $activetab;
        }
@@ -543,17 +579,26 @@
                $fn = get_class($this).'::'.$fn;
                $this->_lasterr = $fn.': '.$err;
                
-               if ($this->_dbat < 0) $db = false;
+               if ($this->_dbat < 0) {
+                       $db = false;
+               }
                else {
                        $activedb = $_ADODB_ACTIVE_DBS[$this->_dbat];
                        $db = $activedb->db;
                }
                
                if (function_exists('adodb_throw')) {   
-                       if (!$db) adodb_throw('ADOdb_Active_Record', $fn, -1, 
$err, 0, 0, false);
-                       else adodb_throw($db->databaseType, $fn, -1, $err, 0, 
0, $db);
-               } else
-                       if (!$db || $db->debug) 
ADOConnection::outp($this->_lasterr);
+                       if (!$db) {
+                               adodb_throw('ADOdb_Active_Record', $fn, -1, 
$err, 0, 0, false);
+                       }
+                       else {
+                               adodb_throw($db->databaseType, $fn, -1, $err, 
0, 0, $db);
+                       }
+               } else {
+                       if (!$db || $db->debug) {
+                               ADOConnection::outp($this->_lasterr);
+                       }
+               }
                
        }
        
@@ -561,18 +606,26 @@
        function ErrorMsg()
        {
                if (!function_exists('adodb_throw')) {
-                       if ($this->_dbat < 0) $db = false;
-                       else $db = $this->DB();
+                       if ($this->_dbat < 0) {
+                               $db = false;
+                       }
+                       else {
+                               $db = $this->DB();
+                       }
                
                        // last error could be database error too
-                       if ($db && $db->ErrorMsg()) return $db->ErrorMsg();
+                       if ($db && $db->ErrorMsg()) {
+                               return $db->ErrorMsg();
+                       }
                }
                return $this->_lasterr;
        }
        
        function ErrorNo() 
        {
-               if ($this->_dbat < 0) return -9999; // no database connection...
+               if ($this->_dbat < 0) {
+                       return -9999; // no database connection...
+               }
                $db = $this->DB();
                
                return (int) $db->ErrorNo();
@@ -609,7 +662,10 @@
        // So, I find that for myTable, I want to reload an active record after 
saving it. -- Malcolm Cook
        function Reload()
        {
-               $db =& $this->DB(); if (!$db) return false;
+               $db =& $this->DB();
+               if (!$db) {
+                       return false;
+               }
                $table =& $this->TableInfo();
                $where = $this->GenWhere($db, $table);
                return($this->Load($where));
@@ -639,62 +695,69 @@
        if($sizeofRow == 2 * $table->_colsCount || $sizeofRow == 2 * 
$sizeofFlds) {
                 // Only keep string keys
                 $keys = array_filter(array_keys($row), 'is_string');
-                if (sizeof($keys) == sizeof($table->flds))
+                               if (sizeof($keys) == sizeof($table->flds)) {
                     $bad_size = FALSE;
             }
+                       }
             if ($bad_size) {
                        $this->Error("Table structure of $this->_table has 
changed","Load");
                        return false;
                }
             # </AP>
                }
-        else
+               else {
                $keys = array_keys($row);
+               }
+
         # <AP>
         reset($keys);
         $this->_original = array();
-               foreach($table->flds as $name=>$fld)
-               {
+               foreach($table->flds as $name=>$fld) {
             $value = $row[current($keys)];
                        $this->$name = $value;
             $this->_original[] = $value;
-            if(!next($keys)) break;
+                       if(!next($keys)) {
+                               break;
+                       }
                }
                $table =& $this->TableInfo();
-               foreach($table->_belongsTo as $foreignTable)
-               {
+               foreach($table->_belongsTo as $foreignTable) {
                        $ft = $foreignTable->TableInfo();
                        $propertyName = $ft->name;
-                       foreach($ft->flds as $name=>$fld)
-                       {
+                       foreach($ft->flds as $name=>$fld) {
                                $value = $row[current($keys)];
                                $foreignTable->$name = $value;
                                $foreignTable->_original[] = $value;
-                               if(!next($keys)) break;
+                               if(!next($keys)) {
+                                       break;
                        }
                }
-               foreach($table->_hasMany as $foreignTable)
-               {
+               }
+               foreach($table->_hasMany as $foreignTable) {
                        $ft = $foreignTable->TableInfo();
-                       foreach($ft->flds as $name=>$fld)
-                       {
+                       foreach($ft->flds as $name=>$fld) {
                                $value = $row[current($keys)];
                                $foreignTable->$name = $value;
                                $foreignTable->_original[] = $value;
-                               if(!next($keys)) break;
+                               if(!next($keys)) {
+                                       break;
+                               }
                        }
                }
         # </AP>
+
                return true;
        }
        
        // get last inserted id for INSERT
        function LastInsertID(&$db,$fieldname)
        {
-               if ($db->hasInsertID)
+               if ($db->hasInsertID) {
                        $val = $db->Insert_ID($this->_table,$fieldname);
-               else
+               }
+               else {
                        $val = false;
+               }
                        
                if (is_null($val) || $val === false) {
                        // this might not work reliably in multi-user 
environment
@@ -709,14 +772,17 @@
                switch($t) {
                case 'D':
                case 'T':
-                       if (empty($val)) return 'null';
-                       
+                       if (empty($val)) {
+                               return 'null';
+                       }
                case 'C':
                case 'X':
-                       if (is_null($val)) return 'null';
-                       
+                       if (is_null($val)) {
+                               return 'null';
+                       }
                        if (strlen($val)>0 && 
-                               (strncmp($val,"'",1) != 0 || 
substr($val,strlen($val)-1,1) != "'")) { 
+                               (strncmp($val,"'",1) != 0 || 
substr($val,strlen($val)-1,1) != "'")
+                       ) {
                                return $db->qstr($val);
                                break;
                        }
@@ -746,26 +812,28 @@
        
        function Load($where=null,$bindarr=false)
        {
-               $db = $this->DB(); if (!$db) return false;
+               $db = $this->DB();
+               if (!$db) {
+                       return false;
+               }
                $this->_where = $where;
                
                $save = $db->SetFetchMode(ADODB_FETCH_NUM);
                $qry = "select * from ".$this->_table;
                $table =& $this->TableInfo();
 
-               if(($k = reset($table->keys)))
+               if(($k = reset($table->keys))) {
                        $hasManyId   = $k;
-               else
+               }
+               else {
                        $hasManyId   = 'id';
+               }
                
-               foreach($table->_belongsTo as $foreignTable)
-               {
-                       if(($k = reset($foreignTable->TableInfo()->keys)))
-                       {
+               foreach($table->_belongsTo as $foreignTable) {
+                       if(($k = reset($foreignTable->TableInfo()->keys))) {
                                $belongsToId = $k;
                        }
-                       else
-                       {
+                       else {
                                $belongsToId = 'id';
                        }
                        $qry .= ' LEFT JOIN '.$foreignTable->_table.' ON '.
@@ -778,96 +846,88 @@
                                $this->_table.'.'.$hasManyId.'='.
                                
$foreignTable->_table.'.'.$foreignTable->foreignKey;
                }
-               if($where)
+               if($where) {
                        $qry .= ' WHERE '.$where;
+               }
                
                // Simple case: no relations. Load row and return.
-               if((count($table->_hasMany) + count($table->_belongsTo)) < 1)
-               {
+               if((count($table->_hasMany) + count($table->_belongsTo)) < 1) {
                        $row = $db->GetRow($qry,$bindarr);
-                       if(!$row)
+                       if(!$row) {
                                return false;
+                       }
                        $db->SetFetchMode($save);
                        return $this->Set($row);
                }
                
                // More complex case when relations have to be collated
                $rows = $db->GetAll($qry,$bindarr);
-               if(!$rows)
+               if(!$rows) {
                        return false;
+               }
                $db->SetFetchMode($save);
-               if(count($rows) < 1)
+               if(count($rows) < 1) {
                        return false;
+               }
                $class = get_class($this);
                $isFirstRow = true;
                
-               if(($k = reset($this->TableInfo()->keys)))
+               if(($k = reset($this->TableInfo()->keys))) {
                        $myId   = $k;
-               else
+               }
+               else {
                        $myId   = 'id';
+               }
                $index = 0; $found = false;
                /** @todo Improve by storing once and for all in table metadata 
*/
                /** @todo Also re-use info for hasManyId */
-               foreach($this->TableInfo()->flds as $fld)
-               {
-                       if($fld->name == $myId)
-                       {
+               foreach($this->TableInfo()->flds as $fld) {
+                       if($fld->name == $myId) {
                                $found = true;
                                break;
                        }
                        $index++;
                }
-               if(!$found)
+               if(!$found) {
                        $this->outp_throw("Unable to locate key $myId for 
$class in Load()",'Load');
+               }
                
-               foreach($rows as $row)
-               {
+               foreach($rows as $row) {
                        $rowId = intval($row[$index]);
-                       if($rowId > 0)
-                       {
-                               if($isFirstRow)
-                               {
+                       if($rowId > 0) {
+                               if($isFirstRow) {
                                        $isFirstRow = false;
-                                       if(!$this->Set($row))
+                                       if(!$this->Set($row)) {
                                                return false;
                                }
+                               }
                                $obj = new $class($table,false,$db);
                                $obj->Set($row);
                                // TODO Copy/paste code below: bad!
-                               if(count($table->_hasMany) > 0)
-                               {
-                                       foreach($table->_hasMany as 
$foreignTable)
-                                       {
+                               if(count($table->_hasMany) > 0) {
+                                       foreach($table->_hasMany as 
$foreignTable) {
                                                $foreignName = 
$foreignTable->foreignName;
-                                               if(!empty($obj->$foreignName))
-                                               {
-                                                       
if(!is_array($this->$foreignName))
-                                                       {
+                                               if(!empty($obj->$foreignName)) {
+                                                       
if(!is_array($this->$foreignName)) {
                                                                $foreignObj = 
$this->$foreignName;
                                                                
$this->$foreignName = array(clone($foreignObj));
                                                        }
-                                                       else
-                                                       {
+                                                       else {
                                                                $foreignObj = 
$obj->$foreignName;
                                                                
array_push($this->$foreignName, clone($foreignObj));
                                                        }
                                                }
                                        }
                                }
-                               if(count($table->_belongsTo) > 0)
-                               {
-                                       foreach($table->_belongsTo as 
$foreignTable)
-                                       {
+                               if(count($table->_belongsTo) > 0) {
+                                       foreach($table->_belongsTo as 
$foreignTable) {
                                                $foreignName = 
$foreignTable->foreignName;
-                                               if(!empty($obj->$foreignName))
-                                               {
-                                                       
if(!is_array($this->$foreignName))
-                                                       {
+                                               if(!empty($obj->$foreignName)) {
+                                                       
if(!is_array($this->$foreignName)) {
                                                                $foreignObj = 
$this->$foreignName;
                                                                
$this->$foreignName = array(clone($foreignObj));
                                                        }
-                                                       else
-                                                       {
+                                                       else {
                                                                $foreignObj = 
$obj->$foreignName;
                                                                
array_push($this->$foreignName, clone($foreignObj));
                                                        }
@@ -882,8 +942,12 @@
        // false on error
        function Save()
        {
-               if ($this->_saved) $ok = $this->Update();
-               else $ok = $this->Insert();
+               if ($this->_saved) {
+                       $ok = $this->Update();
+               }
+               else {
+                       $ok = $this->Insert();
+               }
                
                return $ok;
        }
@@ -898,7 +962,10 @@
        // false on error
        function Insert()
        {
-               $db = $this->DB(); if (!$db) return false;
+               $db = $this->DB();
+               if (!$db) {
+                       return false;
+               }
                $cnt = 0;
                $table = $this->TableInfo();
                
@@ -948,7 +1015,10 @@
        
        function Delete()
        {
-               $db = $this->DB(); if (!$db) return false;
+               $db = $this->DB();
+               if (!$db) {
+                       return false;
+               }
                $table = $this->TableInfo();
                
                $where = $this->GenWhere($db,$table);
@@ -961,7 +1031,10 @@
        // returns an array of active record objects
        function 
Find($whereOrderBy,$bindarr=false,$pkeysArr=false,$extra=array())
        {
-               $db = $this->DB(); if (!$db || empty($this->_table)) return 
false;
+               $db = $this->DB();
+               if (!$db || empty($this->_table)) {
+                       return false;
+               }
                $table =& $this->TableInfo();
                $arr = $db->GetActiveRecordsClass(get_class($this),$this, 
$whereOrderBy,$bindarr,$pkeysArr,$extra,
                        array('foreignName'=>$this->foreignName, 
'belongsTo'=>$table->_belongsTo, 'hasMany'=>$table->_hasMany));
@@ -974,7 +1047,10 @@
        // Shockingly because I want to preserve PHP4 compatibility.
        function 
packageFind($whereOrderBy,$bindarr=false,$pkeysArr=false,$extra=array())
        {
-               $db = $this->DB(); if (!$db || empty($this->_table)) return 
false;
+               $db = $this->DB();
+               if (!$db || empty($this->_table)) {
+                       return false;
+               }
                $table =& $this->TableInfo();
                $arr = $db->GetActiveRecordsClass(get_class($this),$this, 
$whereOrderBy,$bindarr,$pkeysArr,$extra,
                        array('foreignName'=>$this->foreignName, 
'belongsTo'=>$table->_belongsTo, 'hasMany'=>$table->_hasMany));
@@ -986,7 +1062,10 @@
        {
        global $ADODB_ASSOC_CASE;
                
-               $db = $this->DB(); if (!$db) return false;
+               $db = $this->DB();
+               if (!$db) {
+                       return false;
+               }
                $table = $this->TableInfo();
                
                $pkey = $table->keys;
@@ -996,7 +1075,9 @@
                        /*
                        if (is_null($val)) {
                                if (isset($fld->not_null) && $fld->not_null) {
-                                       if (isset($fld->default_value) && 
strlen($fld->default_value)) continue;
+                                       if (isset($fld->default_value) && 
strlen($fld->default_value)) {
+                                               continue;
+                                       }
                                        else {
                                                $this->Error("Cannot update 
null into $name","Replace");
                                                return false;
@@ -1011,15 +1092,23 @@
                        $valarr[] = $val;
                }
                
-               if (!is_array($pkey)) $pkey = array($pkey);
+               if (!is_array($pkey)) {
+                       $pkey = array($pkey);
+               }
                
                
-               if ($ADODB_ASSOC_CASE == 0) 
-                       foreach($pkey as $k => $v)
+               switch ($ADODB_ASSOC_CASE == 0) {
+                       case ADODB_ASSOC_CASE_LOWER:
+                               foreach($pkey as $k => $v) {
                                $pkey[$k] = strtolower($v);
-               elseif ($ADODB_ASSOC_CASE == 1) 
-                       foreach($pkey as $k => $v)
+                               }
+                               break;
+                       case ADODB_ASSOC_CASE_UPPER:
+                               foreach($pkey as $k => $v) {
                                $pkey[$k] = strtoupper($v);
+                               }
+                               break;
+               }
                                
                $ok = $db->Replace($this->_table,$arr,$pkey);
                if ($ok) {
@@ -1046,7 +1135,10 @@
        // returns 0 on error, 1 on update, -1 if no change in data (no update)
        function Update()
        {
-               $db = $this->DB(); if (!$db) return false;
+               $db = $this->DB();
+               if (!$db) {
+                       return false;
+               }
                $table = $this->TableInfo();
                
                $where = $this->GenWhere($db, $table);
@@ -1071,7 +1163,9 @@
                        
                        if (is_null($val)) {
                                if (isset($fld->not_null) && $fld->not_null) {
-                                       if (isset($fld->default_value) && 
strlen($fld->default_value)) continue;
+                                       if (isset($fld->default_value) && 
strlen($fld->default_value)) {
+                                               continue;
+                                       }
                                        else {
                                                $this->Error("Cannot set field 
$name to NULL","Update");
                                                return false;
@@ -1079,7 +1173,7 @@
                                }
                        }
                        
-                       if (isset($this->_original[$i]) && $val == 
$this->_original[$i]) {
+                       if (isset($this->_original[$i]) && $val === 
$this->_original[$i]) {
                                continue;
                        }                       
                        $valarr[] = $val;
@@ -1088,7 +1182,9 @@
                }
                
                
-               if (!$cnt) return -1;
+               if (!$cnt) {
+                       return -1;
+               }
                $sql = 'UPDATE '.$this->_table." SET ".implode(",",$pairs)." 
WHERE ".$where;
                $ok = $db->Execute($sql,$valarr);
                if ($ok) {
@@ -1101,7 +1197,9 @@
        function GetAttributeNames()
        {
                $table = $this->TableInfo();
-               if (!$table) return false;
+               if (!$table) {
+                       return false;
+               }
                return array_keys($table->flds);
        }
        
@@ -1112,43 +1210,41 @@
 {
        global $_ADODB_ACTIVE_DBS;
        
-               if (empty($extra['loading'])) $extra['loading'] = ADODB_LAZY_AR;
-               
+               if (empty($extra['loading'])) {
+                       $extra['loading'] = ADODB_LAZY_AR;
+               }
                $save = $db->SetFetchMode(ADODB_FETCH_NUM);
                $table = &$tableObj->_table;
                $tableInfo =& $tableObj->TableInfo();
-               if(($k = reset($tableInfo->keys)))
+               if(($k = reset($tableInfo->keys))) {
                        $myId   = $k;
-               else
+               }
+               else {
                        $myId   = 'id';
+               }
                $index = 0; $found = false;
                /** @todo Improve by storing once and for all in table metadata 
*/
                /** @todo Also re-use info for hasManyId */
                foreach($tableInfo->flds as $fld)
                {
-                       if($fld->name == $myId)
-                       {
+                       if($fld->name == $myId) {
                                $found = true;
                                break;
                        }
                        $index++;
                }
-               if(!$found)
+               if(!$found) {
                        $db->outp_throw("Unable to locate key $myId for $class 
in GetActiveRecordsClass()",'GetActiveRecordsClass');
+               }
                
                $qry = "select * from ".$table;
-               if(ADODB_JOIN_AR == $extra['loading'])
-               {
-                       if(!empty($relations['belongsTo']))
-                       {
-                               foreach($relations['belongsTo'] as 
$foreignTable)
-                               {
-                                       if(($k = 
reset($foreignTable->TableInfo()->keys)))
-                                       {
+               if(ADODB_JOIN_AR == $extra['loading']) {
+                       if(!empty($relations['belongsTo'])) {
+                               foreach($relations['belongsTo'] as 
$foreignTable) {
+                                       if(($k = 
reset($foreignTable->TableInfo()->keys))) {
                                                $belongsToId = $k;
                                        }
-                                       else
-                                       {
+                                       else {
                                                $belongsToId = 'id';
                                        }
 
@@ -1157,27 +1253,28 @@
                                                
$foreignTable->_table.'.'.$belongsToId;
                                }
                        }
-                       if(!empty($relations['hasMany']))
-                       {
-                               if(empty($relations['foreignName']))
+                       if(!empty($relations['hasMany'])) {
+                               if(empty($relations['foreignName'])) {
                                        $db->outp_throw("Missing foreignName is 
relation specification in GetActiveRecordsClass()",'GetActiveRecordsClass');
-                               if(($k = reset($tableInfo->keys)))
+                               }
+                               if(($k = reset($tableInfo->keys))) {
                                        $hasManyId   = $k;
-                               else
+                               }
+                               else {
                                        $hasManyId   = 'id';
+                               }
 
-                               foreach($relations['hasMany'] as $foreignTable)
-                               {
+                               foreach($relations['hasMany'] as $foreignTable) 
{
                                        $qry .= ' LEFT JOIN 
'.$foreignTable->_table.' ON '.
                                                $table.'.'.$hasManyId.'='.
                                                
$foreignTable->_table.'.'.$foreignTable->foreignKey;
                                }
                        }
                }
-               if (!empty($whereOrderBy))
+               if (!empty($whereOrderBy)) {
                        $qry .= ' WHERE '.$whereOrderBy;
-               if(isset($extra['limit']))
-               {
+               }
+               if(isset($extra['limit'])) {
                        $rows = false;
                        if(isset($extra['offset'])) {
                                $rs = $db->SelectLimit($qry, $extra['limit'], 
$extra['offset']);
@@ -1237,59 +1334,55 @@
                        // Note: to-many relationships mess around with the 
'limit' parameter
                        $rowId = intval($row[$index]);
 
-                       if(ADODB_WORK_AR == $extra['loading'])
-                       {
+                       if(ADODB_WORK_AR == $extra['loading']) {
                                $arrRef[$rowId] = $obj;
                                $arr[] = &$arrRef[$rowId];
-                               if(!isset($indices))
+                               if(!isset($indices)) {
                                        $indices = $rowId;
-                               else
+                               }
+                               else {
                                        $indices .= ','.$rowId;
-                               if(!empty($relations['belongsTo']))
-                               {
-                                       foreach($relations['belongsTo'] as 
$foreignTable)
-                                       {
+                               }
+                               if(!empty($relations['belongsTo'])) {
+                                       foreach($relations['belongsTo'] as 
$foreignTable) {
                                                $foreignTableRef = 
$foreignTable->foreignKey;
                                                // First array: list of foreign 
ids we are looking for
-                                               
if(empty($bTos[$foreignTableRef]))
+                                               
if(empty($bTos[$foreignTableRef])) {
                                                        $bTos[$foreignTableRef] 
= array();
+                                               }
                                                // Second array: list of ids 
found
-                                               
if(empty($obj->$foreignTableRef))
+                                               
if(empty($obj->$foreignTableRef)) {
                                                        continue;
-                                               
if(empty($bTos[$foreignTableRef][$obj->$foreignTableRef]))
+                                               }
+                                               
if(empty($bTos[$foreignTableRef][$obj->$foreignTableRef])) {
                                                        
$bTos[$foreignTableRef][$obj->$foreignTableRef] = array();
+                                               }
                                                
$bTos[$foreignTableRef][$obj->$foreignTableRef][] = $obj;
                                        }
                                }
                                continue;
                        }
 
-                       if($rowId>0)
-                       {
-                               if(ADODB_JOIN_AR == $extra['loading'])
-                               {
+                       if($rowId>0) {
+                               if(ADODB_JOIN_AR == $extra['loading']) {
                                        $isNewObj = 
!isset($uniqArr['_'.$row[0]]); 
-                                       if($isNewObj)
+                                       if($isNewObj) {
                                                $uniqArr['_'.$row[0]] = $obj;
+                                       }
 
                                        // TODO Copy/paste code below: bad!
-                                       if(!empty($relations['hasMany']))
-                                       {
-                                               foreach($relations['hasMany'] 
as $foreignTable)
-                                               {
+                                       if(!empty($relations['hasMany'])) {
+                                               foreach($relations['hasMany'] 
as $foreignTable) {
                                                        $foreignName = 
$foreignTable->foreignName;
-                                                       
if(!empty($obj->$foreignName))
-                                                       {
+                                                       
if(!empty($obj->$foreignName)) {
                                                                $masterObj = 
&$uniqArr['_'.$row[0]];
                                                                // Assumption: 
this property exists in every object since they are instances of the same class
-                                                               
if(!is_array($masterObj->$foreignName))
-                                                               {
+                                                               
if(!is_array($masterObj->$foreignName)) {
                                                                        // 
Pluck!
                                                                        
$foreignObj = $masterObj->$foreignName;
                                                                        
$masterObj->$foreignName = array(clone($foreignObj));
                                                                }
-                                                               else
-                                                               {
+                                                               else {
                                                                        // 
Pluck pluck!
                                                                        
$foreignObj = $obj->$foreignName;
                                                                        
array_push($masterObj->$foreignName, clone($foreignObj));
@@ -1297,23 +1390,18 @@
                                                        }
                                                }
                                        }
-                                       if(!empty($relations['belongsTo']))
-                                       {
-                                               foreach($relations['belongsTo'] 
as $foreignTable)
-                                               {
+                                       if(!empty($relations['belongsTo'])) {
+                                               foreach($relations['belongsTo'] 
as $foreignTable) {
                                                        $foreignName = 
$foreignTable->foreignName;
-                                                       
if(!empty($obj->$foreignName))
-                                                       {
+                                                       
if(!empty($obj->$foreignName)) {
                                                                $masterObj = 
&$uniqArr['_'.$row[0]];
                                                                // Assumption: 
this property exists in every object since they are instances of the same class
-                                                               
if(!is_array($masterObj->$foreignName))
-                                                               {
+                                                               
if(!is_array($masterObj->$foreignName)) {
                                                                        // 
Pluck!
                                                                        
$foreignObj = $masterObj->$foreignName;
                                                                        
$masterObj->$foreignName = array(clone($foreignObj));
                                                                }
-                                                               else
-                                                               {
+                                                               else {
                                                                        // 
Pluck pluck!
                                                                        
$foreignObj = $obj->$foreignName;
                                                                        
array_push($masterObj->$foreignName, clone($foreignObj));
@@ -1321,34 +1409,28 @@
                                                        }
                                                }
                                        }
-                                       if(!$isNewObj)
+                                       if(!$isNewObj) {
                                                unset($obj); // We do not need 
this object itself anymore and do not want it re-added to the main array        
                         
                                }
-                               else if(ADODB_LAZY_AR == $extra['loading'])
-                               {
+                               }
+                               else if(ADODB_LAZY_AR == $extra['loading']) {
                                        // Lazy loading: we need to give AdoDb 
a hint that we have not really loaded
                                        // anything, all the while keeping 
enough information on what we wish to load.
                                        // Let's do this by keeping the 
relevant info in our relationship arrays
                                        // but get rid of the actual properties.
                                        // We will then use PHP's __get to load 
these properties on-demand.
-                                       if(!empty($relations['hasMany']))
-                                       {
-                                               foreach($relations['hasMany'] 
as $foreignTable)
-                                               {
+                                       if(!empty($relations['hasMany'])) {
+                                               foreach($relations['hasMany'] 
as $foreignTable) {
                                                        $foreignName = 
$foreignTable->foreignName;
-                                                       
if(!empty($obj->$foreignName))
-                                                       {
+                                                       
if(!empty($obj->$foreignName)) {
                                                                
unset($obj->$foreignName);
                                                        }
                                                }
                                        }
-                                       if(!empty($relations['belongsTo']))
-                                       {
-                                               foreach($relations['belongsTo'] 
as $foreignTable)
-                                               {
+                                       if(!empty($relations['belongsTo'])) {
+                                               foreach($relations['belongsTo'] 
as $foreignTable) {
                                                        $foreignName = 
$foreignTable->foreignName;
-                                                       
if(!empty($obj->$foreignName))
-                                                       {
+                                                       
if(!empty($obj->$foreignName)) {
                                                                
unset($obj->$foreignName);
                                                        }
                                                }
@@ -1356,47 +1438,42 @@
                                }
                        }
 
-                       if(isset($obj))
+                       if(isset($obj)) {
                                $arr[] = $obj;
                }
+               }
 
-               if(ADODB_WORK_AR == $extra['loading'])
-               {
+               if(ADODB_WORK_AR == $extra['loading']) {
                        // The best of both worlds?
                        // Here, the number of queries is constant: 1 + 
n*relationship.
                        // The second query will allow us to perform a good join
                        // while preserving LIMIT etc.
-                       if(!empty($relations['hasMany']))
-                       {
-                               foreach($relations['hasMany'] as $foreignTable)
-                               {
+                       if(!empty($relations['hasMany'])) {
+                               foreach($relations['hasMany'] as $foreignTable) 
{
                                        $foreignName = 
$foreignTable->foreignName;
                                        $className = 
ucfirst($foreignTable->_singularize($foreignName));
                                        $obj = new $className();
                                        $dbClassRef = $foreignTable->foreignKey;
                                        $objs = $obj->packageFind($dbClassRef.' 
IN ('.$indices.')');
-                                       foreach($objs as $obj)
-                                       {
-                                               
if(!is_array($arrRef[$obj->$dbClassRef]->$foreignName))
+                                       foreach($objs as $obj) {
+                                               
if(!is_array($arrRef[$obj->$dbClassRef]->$foreignName)) {
                                                        
$arrRef[$obj->$dbClassRef]->$foreignName = array();
+                                               }
                                                
array_push($arrRef[$obj->$dbClassRef]->$foreignName, $obj);
                                        }
                                }
                                
                        }
-                       if(!empty($relations['belongsTo']))
-                       {
-                               foreach($relations['belongsTo'] as 
$foreignTable)
-                               {
+                       if(!empty($relations['belongsTo'])) {
+                               foreach($relations['belongsTo'] as 
$foreignTable) {
                                        $foreignTableRef = 
$foreignTable->foreignKey;
-                                       if(empty($bTos[$foreignTableRef]))
+                                       if(empty($bTos[$foreignTableRef])) {
                                                continue;
-                                       if(($k = 
reset($foreignTable->TableInfo()->keys)))
-                                       {
+                                       }
+                                       if(($k = 
reset($foreignTable->TableInfo()->keys))) {
                                                $belongsToId = $k;
                                        }
-                                       else
-                                       {
+                                       else {
                                                $belongsToId = 'id';
                                        }                                       
        
                                        $origObjsArr = $bTos[$foreignTableRef];

Modified: branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-csvlib.inc.php
===================================================================
--- branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-csvlib.inc.php   
2016-08-16 18:43:57 UTC (rev 15474)
+++ branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-csvlib.inc.php   
2016-08-16 18:50:46 UTC (rev 15475)
@@ -8,7 +8,9 @@
 
 /* 
 
-  V5.19  23-Apr-2014  (c) 2000-2014 John Lim (jlim#natsoft.com). All rights 
reserved.
+  @version   v5.20.4  30-Mar-2016
+  @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
+  @copyright (c) 2014      Damien Regad, Mark Newnham and the ADOdb community
   Released under both BSD license and Lesser GPL library license. 
   Whenever there is any discrepancy between the two licenses, 
   the BSD license will take precedence. See License.txt. 
@@ -292,7 +294,7 @@
                                // the tricky moment
                                @unlink($filename);
                                if (address@hidden($tmpname,$filename)) {
-                                       unlink($tmpname);
+                                       @unlink($tmpname);
                                        $ok = 0;
                                }
                                if (!$ok) {

Modified: branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-datadict.inc.php
===================================================================
--- branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-datadict.inc.php 
2016-08-16 18:43:57 UTC (rev 15474)
+++ branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-datadict.inc.php 
2016-08-16 18:50:46 UTC (rev 15475)
@@ -1,7 +1,9 @@
 <?php
 
 /**
-  V5.19  23-Apr-2014  (c) 2000-2014 John Lim (jlim#natsoft.com). All rights 
reserved.
+  @version   v5.20.4  30-Mar-2016
+  @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
+  @copyright (c) 2014      Damien Regad, Mark Newnham and the ADOdb community
   Released under both BSD license and Lesser GPL library license. 
   Whenever there is any discrepancy between the two licenses, 
   the BSD license will take precedence.

Modified: branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-error.inc.php
===================================================================
--- branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-error.inc.php    
2016-08-16 18:43:57 UTC (rev 15474)
+++ branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-error.inc.php    
2016-08-16 18:50:46 UTC (rev 15475)
@@ -1,6 +1,8 @@
 <?php
 /** 
- * @version V5.19  23-Apr-2014  (c) 2000-2014 John Lim (jlim#natsoft.com). All 
rights reserved.
+ * @version   v5.20.4  30-Mar-2016
+ * @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
+ * @copyright (c) 2014      Damien Regad, Mark Newnham and the ADOdb community
  * Released under both BSD license and Lesser GPL library license. 
  * Whenever there is any discrepancy between the two licenses, 
  * the BSD license will take precedence. 

Modified: 
branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-errorhandler.inc.php
===================================================================
--- branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-errorhandler.inc.php     
2016-08-16 18:43:57 UTC (rev 15474)
+++ branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-errorhandler.inc.php     
2016-08-16 18:50:46 UTC (rev 15475)
@@ -1,6 +1,8 @@
 <?php
 /**
- * @version V5.19  23-Apr-2014  (c) 2000-2014 John Lim (jlim#natsoft.com). All 
rights reserved.
+ * @version   v5.20.4  30-Mar-2016
+ * @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
+ * @copyright (c) 2014      Damien Regad, Mark Newnham and the ADOdb community
  * Released under both BSD license and Lesser GPL library license.
  * Whenever there is any discrepancy between the two licenses,
  * the BSD license will take precedence.

Modified: branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-errorpear.inc.php
===================================================================
--- branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-errorpear.inc.php        
2016-08-16 18:43:57 UTC (rev 15474)
+++ branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-errorpear.inc.php        
2016-08-16 18:50:46 UTC (rev 15475)
@@ -1,6 +1,8 @@
 <?php
 /** 
- * @version V5.19  23-Apr-2014  (c) 2000-2014 John Lim (jlim#natsoft.com). All 
rights reserved.
+ * @version   v5.20.4  30-Mar-2016
+ * @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
+ * @copyright (c) 2014      Damien Regad, Mark Newnham and the ADOdb community
  * Released under both BSD license and Lesser GPL library license. 
   Whenever there is any discrepancy between the two licenses, 
   the BSD license will take precedence. 

Modified: branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-exceptions.inc.php
===================================================================
--- branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-exceptions.inc.php       
2016-08-16 18:43:57 UTC (rev 15474)
+++ branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-exceptions.inc.php       
2016-08-16 18:50:46 UTC (rev 15475)
@@ -1,7 +1,9 @@
 <?php
 
 /**
- * @version V5.19  23-Apr-2014  (c) 2000-2014 John Lim (jlim#natsoft.com). All 
rights reserved.
+ * @version   v5.20.4  30-Mar-2016
+ * @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
+ * @copyright (c) 2014      Damien Regad, Mark Newnham and the ADOdb community
  * Released under both BSD license and Lesser GPL library license.
  * Whenever there is any discrepancy between the two licenses,
  * the BSD license will take precedence.
@@ -29,9 +31,9 @@
        {
                switch($fn) {
                case 'EXECUTE':
-                       $this->sql = $p1;
+                       $this->sql = is_array($p1) ? $p1[0] : $p1;
                        $this->params = $p2;
-                       $s = "$dbms error: [$errno: $errmsg] in $fn(\"$p1\")\n";
+                       $s = "$dbms error: [$errno: $errmsg] in 
$fn(\"$this->sql\")\n";
                        break;
        
                case 'PCONNECT':

Modified: branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-iterator.inc.php
===================================================================
--- branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-iterator.inc.php 
2016-08-16 18:43:57 UTC (rev 15474)
+++ branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-iterator.inc.php 
2016-08-16 18:50:46 UTC (rev 15475)
@@ -1,7 +1,9 @@
 <?php
 
 /*
-  V5.19  23-Apr-2014  (c) 2000-2014 John Lim (jlim#natsoft.com). All rights 
reserved.
+  @version   v5.20.4  30-Mar-2016
+  @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
+  @copyright (c) 2014      Damien Regad, Mark Newnham and the ADOdb community
   Released under both BSD license and Lesser GPL library license. 
   Whenever there is any discrepancy between the two licenses, 
   the BSD license will take precedence.

Modified: branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-lib.inc.php
===================================================================
--- branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-lib.inc.php      
2016-08-16 18:43:57 UTC (rev 15474)
+++ branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-lib.inc.php      
2016-08-16 18:50:46 UTC (rev 15475)
@@ -6,7 +6,9 @@
 $ADODB_INCLUDED_LIB = 1;
 
 /* 
-  @version V5.19  23-Apr-2014  (c) 2000-2014 John Lim (jlim#natsoft.com). All 
rights reserved.
+  @version   v5.20.4  30-Mar-2016
+  @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
+  @copyright (c) 2014      Damien Regad, Mark Newnham and the ADOdb community
   Released under both BSD license and Lesser GPL library license. 
   Whenever there is any discrepancy between the two licenses, 
   the BSD license will take precedence. See License.txt. 
@@ -17,7 +19,7 @@
 
 function adodb_strip_order_by($sql)
 {
-       $rez = 
preg_match('/(\sORDER\s+BY\s(?:[^)](?!limit))*)(?:\sLIMIT\s+[0-9]+)?/is', $sql, 
$arr);
+       $rez = preg_match('/(\sORDER\s+BY\s(?:[^)](?!LIMIT))*)/is', $sql, $arr);
        if ($arr)
                if (strpos($arr[1], '(') !== false) {
                        $at = strpos($sql, $arr[1]);
@@ -38,7 +40,7 @@
                        $sql = str_replace($arr[1], '', $sql);
                }
        return $sql;
- }
+}
 
 if (false) {
        $sql = 'select * from (select a from b order by a(b),b(c) desc)';
@@ -421,8 +423,11 @@
                }
        } else {
                // now replace SELECT ... FROM with SELECT COUNT(*) FROM
-               $rewritesql = preg_replace(
-                                       '/^\s*SELECT\s.*\s+FROM\s/Uis','SELECT 
COUNT(*) FROM ',$sql);
+               if ( strpos($sql, '_ADODB_COUNT') !== FALSE ) {
+                       $rewritesql = 
preg_replace('/^\s*?SELECT\s+_ADODB_COUNT(.*)_ADODB_COUNT\s/is','SELECT 
COUNT(*) ',$sql);
+               } else {
+                       $rewritesql = 
preg_replace('/^\s*?SELECT\s.*?\s+(.*?)\s+FROM\s/is','SELECT COUNT(*) FROM 
',$sql);
+               }
                // fix by alexander zhukov, alex#unipack.ru, because count(*) 
and 'order by' fails 
                // with mssql, access and postgresql. Also a good speedup 
optimization - skips sorting!
                // also see http://phplens.com/lens/lensforum/msgs.php?id=12752
@@ -543,46 +548,86 @@
        return $rsreturn;
 }
 
-// Iv\xE1n Oliva version
+// Iván Oliva version
 function _adodb_pageexecute_no_last_page(&$zthis, $sql, $nrows, $page, 
$inputarr=false, $secs2cache=0) 
 {
 
        $atfirstpage = false;
        $atlastpage = false;
        
-       if (!isset($page) || $page <= 1) {      // If page number <= 1, then we 
are at the first page
+       if (!isset($page) || $page <= 1) {
+               // If page number <= 1, then we are at the first page
                $page = 1;
                $atfirstpage = true;
        }
-       if ($nrows <= 0) $nrows = 10;   // If an invalid nrows is supplied, we 
assume a default value of 10 rows per page
-       
-       // ***** Here we check whether $page is the last page or whether we are 
trying to retrieve a page number greater than 
-       // the last page number.
+       if ($nrows <= 0) {
+               // If an invalid nrows is supplied, we assume a default value 
of 10 rows per page
+               $nrows = 10;
+       }
+
+       $pagecounteroffset = ($page * $nrows) - $nrows;
+
+       // To find out if there are more pages of rows, simply increase the 
limit or
+       // nrows by 1 and see if that number of records was returned. If it was,
+       // then we know there is at least one more page left, otherwise we are 
on
+       // the last page. Therefore allow non-Count() paging with single queries
+       // rather than three queries as was done before.
+       $test_nrows = $nrows + 1;
+       if ($secs2cache > 0) {
+               $rsreturn = $zthis->CacheSelectLimit($secs2cache, $sql, $nrows, 
$pagecounteroffset, $inputarr);
+       } else {
+               $rsreturn = $zthis->SelectLimit($sql, $test_nrows, 
$pagecounteroffset, $inputarr, $secs2cache);
+       }
+
+       // Now check to see if the number of rows returned was the higher value 
we asked for or not.
+       if ( $rsreturn->_numOfRows == $test_nrows ) {
+               // Still at least 1 more row, so we are not on last page yet...
+               // Remove the last row from the RS.
+               $rsreturn->_numOfRows = ( $rsreturn->_numOfRows - 1 );
+       } elseif ( $rsreturn->_numOfRows == 0 && $page > 1 ) {
+               // Likely requested a page that doesn't exist, so need to find 
the last
+               // page and return it. Revert to original method and loop 
through pages
+               // until we find some data...
        $pagecounter = $page + 1;
        $pagecounteroffset = ($pagecounter * $nrows) - $nrows;
-       if ($secs2cache>0) $rstest = $zthis->CacheSelectLimit($secs2cache, 
$sql, $nrows, $pagecounteroffset, $inputarr);
-       else $rstest = $zthis->SelectLimit($sql, $nrows, $pagecounteroffset, 
$inputarr, $secs2cache);
+
+               $rstest = $rsreturn;
        if ($rstest) {
-               while ($rstest && $rstest->EOF && $pagecounter>0) {
+                       while ($rstest && $rstest->EOF && $pagecounter > 0) {
                        $atlastpage = true;
                        $pagecounter--;
                        $pagecounteroffset = $nrows * ($pagecounter - 1);
                        $rstest->Close();
-                       if ($secs2cache>0) $rstest = 
$zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $pagecounteroffset, 
$inputarr);
-                       else $rstest = $zthis->SelectLimit($sql, $nrows, 
$pagecounteroffset, $inputarr, $secs2cache);
+                               if ($secs2cache>0) {
+                                       $rstest = 
$zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $pagecounteroffset, 
$inputarr);
+                               }
+                               else {
+                                       $rstest = $zthis->SelectLimit($sql, 
$nrows, $pagecounteroffset, $inputarr, $secs2cache);
+                               }
                }
                if ($rstest) $rstest->Close();
        }
-       if ($atlastpage) {      // If we are at the last page or beyond it, we 
are going to retrieve it
+               if ($atlastpage) {
+                       // If we are at the last page or beyond it, we are 
going to retrieve it
                $page = $pagecounter;
-               if ($page == 1) $atfirstpage = true;    // We have to do this 
again in case the last page is the same as the first
-                       //... page, that is, the recordset has only 1 page.
+                       if ($page == 1) {
+                               // We have to do this again in case the last 
page is the same as
+                               // the first page, that is, the recordset has 
only 1 page.
+                               $atfirstpage = true;
+                       }
        }
-       
        // We get the data we want
        $offset = $nrows * ($page-1);
-       if ($secs2cache > 0) $rsreturn = $zthis->CacheSelectLimit($secs2cache, 
$sql, $nrows, $offset, $inputarr);
-       else $rsreturn = $zthis->SelectLimit($sql, $nrows, $offset, $inputarr, 
$secs2cache);
+               if ($secs2cache > 0) {
+                       $rsreturn = $zthis->CacheSelectLimit($secs2cache, $sql, 
$nrows, $offset, $inputarr);
+               }
+               else {
+                       $rsreturn = $zthis->SelectLimit($sql, $nrows, $offset, 
$inputarr, $secs2cache);
+               }
+       } elseif ( $rsreturn->_numOfRows < $test_nrows ) {
+               // Rows is less than what we asked for, so must be at the last 
page.
+               $atlastpage = true;
+       }
        
        // Before returning the RecordSet, we set the pagination properties we 
need
        if ($rsreturn) {

Modified: 
branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-memcache.lib.inc.php
===================================================================
--- branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-memcache.lib.inc.php     
2016-08-16 18:43:57 UTC (rev 15474)
+++ branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-memcache.lib.inc.php     
2016-08-16 18:50:46 UTC (rev 15475)
@@ -7,11 +7,13 @@
 $ADODB_INCLUDED_MEMCACHE = 1;
 
 global $ADODB_INCLUDED_CSV;
-if (empty($ADODB_INCLUDED_CSV)) include(ADODB_DIR.'/adodb-csvlib.inc.php');
+if (empty($ADODB_INCLUDED_CSV)) 
include_once(ADODB_DIR.'/adodb-csvlib.inc.php');
 
 /* 
 
-  V5.19  23-Apr-2014  (c) 2000-2014 John Lim (jlim#natsoft.com). All rights 
reserved.
+  @version   v5.20.4  30-Mar-2016
+  @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
+  @copyright (c) 2014      Damien Regad, Mark Newnham and the ADOdb community
   Released under both BSD license and Lesser GPL library license. 
   Whenever there is any discrepancy between the two licenses, 
   the BSD license will take precedence. See License.txt. 
@@ -48,7 +50,7 @@
                var $_connected = false;
                var $_memcache = false;
                
-               function ADODB_Cache_MemCache(&$obj)
+               function __construct(&$obj)
                {
                        $this->hosts = $obj->memCacheHost;
                        $this->port = $obj->memCachePort;

Modified: branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-pager.inc.php
===================================================================
--- branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-pager.inc.php    
2016-08-16 18:43:57 UTC (rev 15474)
+++ branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-pager.inc.php    
2016-08-16 18:50:46 UTC (rev 15475)
@@ -1,7 +1,9 @@
 <?php
 
 /*
-       V5.19  23-Apr-2014  (c) 2000-2014 John Lim (jlim#natsoft.com). All 
rights reserved.
+       @version   v5.20.4  30-Mar-2016
+       @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights 
reserved.
+       @copyright (c) 2014      Damien Regad, Mark Newnham and the ADOdb 
community
          Released under both BSD license and Lesser GPL library license. 
          Whenever there is any discrepancy between the two licenses, 
          the BSD license will take precedence. 
@@ -55,7 +57,7 @@
        //              if you have multiple on 1 page. 
        //              $id should be only be [a-z0-9]*
        //
-       function ADODB_Pager(&$db,$sql,$id = 'adodb', $showPageLinks = false)
+       function __construct(&$db,$sql,$id = 'adodb', $showPageLinks = false)
        {
        global $PHP_SELF;
        

Modified: branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-pear.inc.php
===================================================================
--- branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-pear.inc.php     
2016-08-16 18:43:57 UTC (rev 15474)
+++ branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-pear.inc.php     
2016-08-16 18:50:46 UTC (rev 15475)
@@ -1,6 +1,8 @@
 <?php
 /** 
- * @version V5.19  23-Apr-2014  (c) 2000-2014 John Lim (jlim#natsoft.com). All 
rights reserved.
+ * @version   v5.20.4  30-Mar-2016
+ * @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
+ * @copyright (c) 2014      Damien Regad, Mark Newnham and the ADOdb community
  * Released under both BSD license and Lesser GPL library license. 
  * Whenever there is any discrepancy between the two licenses, 
  * the BSD license will take precedence. 
@@ -52,10 +54,6 @@
 define("DB_OK",        1);
 define("DB_ERROR",-1);
 
-// autoExecute constants
-define('DB_AUTOQUERY_INSERT', 1);
-define('DB_AUTOQUERY_UPDATE', 2);
-
 /**
  * This is a special constant that tells DB the user hasn't specified
  * any particular get mode, so the default should be used.

Modified: branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-perf.inc.php
===================================================================
--- branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-perf.inc.php     
2016-08-16 18:43:57 UTC (rev 15474)
+++ branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-perf.inc.php     
2016-08-16 18:50:46 UTC (rev 15475)
@@ -1,6 +1,8 @@
 <?php
 /* 
-V5.19  23-Apr-2014  (c) 2000-2014 John Lim (jlim#natsoft.com). All rights 
reserved.
address@hidden   v5.20.4  30-Mar-2016
address@hidden (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
address@hidden (c) 2014      Damien Regad, Mark Newnham and the ADOdb community
   Released under both BSD license and Lesser GPL library license. 
   Whenever there is any discrepancy between the two licenses, 
   the BSD license will take precedence. See License.txt. 
@@ -224,7 +226,7 @@
        var $cliFormat = "%32s => %s \r\n";
        var $sql1 = 'sql1';  // used for casting sql1 to text for mssql
        var $explain = true;
-       var $helpurl = "<a 
href=http://phplens.com/adodb/reference.functions.fnexecute.and.fncacheexecute.properties.html#logsql>LogSQL
 help</a>";
+       var $helpurl = '<a 
href="http://adodb.sourceforge.net/docs-adodb.htm#logsql";>LogSQL help</a>';
        var $createTableSQL = false;
        var $maxLength = 2000;
        

Modified: branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-php4.inc.php
===================================================================
--- branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-php4.inc.php     
2016-08-16 18:43:57 UTC (rev 15474)
+++ branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-php4.inc.php     
2016-08-16 18:50:46 UTC (rev 15475)
@@ -1,7 +1,9 @@
 <?php
 
 /*
-  V5.19  23-Apr-2014  (c) 2000-2014 John Lim (jlim#natsoft.com). All rights 
reserved.
+  @version   v5.20.4  30-Mar-2016
+  @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
+  @copyright (c) 2014      Damien Regad, Mark Newnham and the ADOdb community
   Released under both BSD license and Lesser GPL library license. 
   Whenever there is any discrepancy between the two licenses, 
   the BSD license will take precedence.

Modified: branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-time.inc.php
===================================================================
--- branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-time.inc.php     
2016-08-16 18:43:57 UTC (rev 15474)
+++ branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-time.inc.php     
2016-08-16 18:50:46 UTC (rev 15475)
@@ -1,8 +1,12 @@
 <?php
-/**
+/*
 ADOdb Date Library, part of the ADOdb abstraction library
-Download: http://phplens.com/phpeverywhere/
+Download: http://adodb.sourceforge.net/#download
 
address@hidden   v5.20.4  30-Mar-2016
address@hidden (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
address@hidden (c) 2014      Damien Regad, Mark Newnham and the ADOdb community
+
 PHP native date functions use integer timestamps for computations.
 Because of this, dates are restricted to the years 1901-2038 on Unix 
 and 1970-2038 on Windows due to integer overflow for dates beyond 

Modified: branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-xmlschema.inc.php
===================================================================
--- branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-xmlschema.inc.php        
2016-08-16 18:43:57 UTC (rev 15474)
+++ branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-xmlschema.inc.php        
2016-08-16 18:50:46 UTC (rev 15475)
@@ -118,7 +118,7 @@
        /**
        * NOP
        */
-       function dbObject( &$parent, $attributes = NULL ) {
+       function __construct( &$parent, $attributes = NULL ) {
                $this->parent = $parent;
        }
        
@@ -248,7 +248,7 @@
        * @param string $prefix DB Object prefix
        * @param array $attributes Array of table attributes.
        */
-       function dbTable( &$parent, $attributes = NULL ) {
+       function __construct( &$parent, $attributes = NULL ) {
                $this->parent = $parent;
                $this->name = $this->prefix($attributes['NAME']);
        }
@@ -642,7 +642,7 @@
        *
        * @internal
        */
-       function dbIndex( &$parent, $attributes = NULL ) {
+       function __construct( &$parent, $attributes = NULL ) {
                $this->parent = $parent;
                
                $this->name = $this->prefix ($attributes['NAME']);
@@ -786,7 +786,7 @@
        *
        * @internal
        */
-       function dbData( &$parent, $attributes = NULL ) {
+       function __construct( &$parent, $attributes = NULL ) {
                $this->parent = $parent;
        }
        
@@ -985,7 +985,7 @@
        * @param object $parent Parent object
        * @param array $attributes Attributes
        */
-       function dbQuerySet( &$parent, $attributes = NULL ) {
+       function __construct( &$parent, $attributes = NULL ) {
                $this->parent = $parent;
                        
                // Overrides the manual prefix key
@@ -1301,7 +1301,7 @@
        *
        * @param object $db ADOdb database connection object.
        */
-       function adoSchema( $db ) {
+       function __construct( $db ) {
                // Initialize the environment
                $this->mgq = get_magic_quotes_runtime();
                ini_set("magic_quotes_runtime", 0);

Modified: branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-xmlschema03.inc.php
===================================================================
--- branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-xmlschema03.inc.php      
2016-08-16 18:43:57 UTC (rev 15474)
+++ branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb-xmlschema03.inc.php      
2016-08-16 18:50:46 UTC (rev 15475)
@@ -136,7 +136,7 @@
        /**
        * NOP
        */
-       function dbObject( &$parent, $attributes = NULL ) {
+       function __construct( &$parent, $attributes = NULL ) {
                $this->parent = $parent;
        }
        
@@ -273,7 +273,7 @@
        * @param string $prefix DB Object prefix
        * @param array $attributes Array of table attributes.
        */
-       function dbTable( &$parent, $attributes = NULL ) {
+       function __construct( &$parent, $attributes = NULL ) {
                $this->parent = $parent;
                $this->name = $this->prefix($attributes['NAME']);
        }
@@ -683,7 +683,7 @@
        *
        * @internal
        */
-       function dbIndex( &$parent, $attributes = NULL ) {
+       function __construct( &$parent, $attributes = NULL ) {
                $this->parent = $parent;
                
                $this->name = $this->prefix ($attributes['NAME']);
@@ -828,7 +828,7 @@
        *
        * @internal
        */
-       function dbData( &$parent, $attributes = NULL ) {
+       function __construct( &$parent, $attributes = NULL ) {
                $this->parent = $parent;
        }
        
@@ -1084,7 +1084,7 @@
        * @param object $parent Parent object
        * @param array $attributes Attributes
        */
-       function dbQuerySet( &$parent, $attributes = NULL ) {
+       function __construct( &$parent, $attributes = NULL ) {
                $this->parent = $parent;
                        
                // Overrides the manual prefix key
@@ -1405,7 +1405,7 @@
        *
        * @param object $db ADOdb database connection object.
        */
-       function adoSchema( $db ) {
+       function __construct( $db ) {
                // Initialize the environment
                $this->mgq = get_magic_quotes_runtime();
                #set_magic_quotes_runtime(0);
@@ -2104,11 +2104,12 @@
                
                $schema = '<?xml version="1.0"?>' . "\n"
                                . '<schema version="' . $this->schemaVersion . 
'">' . "\n";
-               
-               if( is_array( $tables = $this->db->MetaTables( 'TABLES' , 
($prefix) ? $prefix.'%' : '') ) ) {
+               if( is_array( $tables = $this->db->MetaTables( 'TABLES' ,false 
,($prefix) ? str_replace('_','\_',$prefix).'%' : '') ) ) {
                        foreach( $tables as $table ) {
-                               if ($stripprefix) $table = 
str_replace(str_replace('\\_', '_', $pfx ), '', $table);
-                               $schema .= $indent . '<table name="' . 
htmlentities( $table ) . '">' . "\n";
+                               $schema .= $indent
+                                       . '<table name="'
+                                       . htmlentities( $stripprefix ? 
str_replace($prefix, '', $table) : $table )
+                                       . '">' . "\n";
                                
                                // grab details from database
                                $rs = $this->db->Execute( 'SELECT * FROM ' . 
$table . ' WHERE -1' );

Modified: branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb.inc.php
===================================================================
--- branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb.inc.php  2016-08-16 
18:43:57 UTC (rev 15474)
+++ branches/dev-syncromind-2/phpgwapi/inc/adodb/adodb.inc.php  2016-08-16 
18:50:46 UTC (rev 15475)
@@ -14,7 +14,9 @@
 /**
        \mainpage
        
-        @version V5.19  23-Apr-2014  (c) 2000-2014 John Lim 
(jlim#natsoft.com). All rights reserved.
+       @version   v5.20.4  30-Mar-2016
+       @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights 
reserved.
+       @copyright (c) 2014      Damien Regad, Mark Newnham and the ADOdb 
community
 
        Released under both BSD license and Lesser GPL library license. You can 
choose which license
        you prefer.
@@ -44,7 +46,9 @@
         * Set ADODB_DIR to the directory where this file resides...
         * This constant was formerly called $ADODB_RootPath
         */
-       if (!defined('ADODB_DIR')) define('ADODB_DIR',dirname(__FILE__));
+       if (!defined('ADODB_DIR')) {
+               define('ADODB_DIR',dirname(__FILE__));
+       }
        
        
//==============================================================================================
        
        // GLOBAL VARIABLES
@@ -92,27 +96,59 @@
                define('ADODB_TABLE_REGEX','([]0-9a-z_\:\"address@hidden)');
        
        // prefetching used by oracle
-               if (!defined('ADODB_PREFETCH_ROWS')) 
define('ADODB_PREFETCH_ROWS',10);
+               if (!defined('ADODB_PREFETCH_ROWS')) {
+                       define('ADODB_PREFETCH_ROWS',10);
+               }
        
        
-       /*
-       Controls ADODB_FETCH_ASSOC field-name case. Default is 2, use native 
case-names.
-       This currently works only with mssql, odbc, oci8po and ibase derived 
drivers.
+       /**
+        * Fetch mode
+        *
+        * Set global variable $ADODB_FETCH_MODE to one of these constants or 
use
+        * the SetFetchMode() method to control how recordset fields are 
returned
+        * when fetching data.
+        *
+        *   - NUM:     array()
+        *   - ASSOC:   array('id' => 456, 'name' => 'john')
+        *   - BOTH:    array(0 => 456, 'id' => 456, 1 => 'john', 'name' => 
'john')
+        *   - DEFAULT: driver-dependent
+        */
+               define('ADODB_FETCH_DEFAULT', 0);
+               define('ADODB_FETCH_NUM', 1);
+               define('ADODB_FETCH_ASSOC', 2);
+               define('ADODB_FETCH_BOTH', 3);
        
-               0 = assoc lowercase field names. $rs->fields['orderid']
-               1 = assoc uppercase field names. $rs->fields['ORDERID']
-               2 = use native-case field names. $rs->fields['OrderID']
+       /**
+        * Associative array case constants
+        *
+        * By defining the ADODB_ASSOC_CASE constant to one of these values, it 
is
+        * possible to control the case of field names (associative array's 
keys)
+        * when operating in ADODB_FETCH_ASSOC fetch mode.
+        *   - LOWER:  $rs->fields['orderid']
+        *   - UPPER:  $rs->fields['ORDERID']
+        *   - NATIVE: $rs->fields['OrderID'] (or whatever the RDBMS will 
return)
+        *
+        * The default is to use native case-names.
+        *
+        * NOTE: This functionality is not implemented everywhere, it currently
+        * works only with: mssql, odbc, oci8 and ibase derived drivers
        */
                define('ADODB_ASSOC_CASE_LOWER', 0);
                define('ADODB_ASSOC_CASE_UPPER', 1);
                define('ADODB_ASSOC_CASE_NATIVE', 2);
        
-               define('ADODB_FETCH_DEFAULT',0);
-               define('ADODB_FETCH_NUM',1);
-               define('ADODB_FETCH_ASSOC',2);
-               define('ADODB_FETCH_BOTH',3);
                
-               if (!defined('TIMESTAMP_FIRST_YEAR')) 
define('TIMESTAMP_FIRST_YEAR',100);
+               if (!defined('TIMESTAMP_FIRST_YEAR')) {
+                       define('TIMESTAMP_FIRST_YEAR',100);
+               }
+
+               /**
+                * AutoExecute constants
+                * (moved from adodb-pear.inc.php since they are only used in 
here)
+                */
+               define('DB_AUTOQUERY_INSERT', 1);
+               define('DB_AUTOQUERY_UPDATE', 2);
+
        
                // PHP's version scheme makes converting to numbers difficult - 
workaround
                $_adodb_ver = (float) PHP_VERSION;
@@ -120,20 +156,20 @@
                        define('ADODB_PHPVER',0x5200);
                } else if ($_adodb_ver >= 5.0) {
                        define('ADODB_PHPVER',0x5000);
-               } else 
+               } else {
                        die("PHP5 or later required. You are running 
".PHP_VERSION);
        }
-       
-       
-       //if (!defined('ADODB_ASSOC_CASE')) define('ADODB_ASSOC_CASE',2);
+               unset($_adodb_ver);
+       }
 
        
        /**
                Accepts $src and $dest arrays, replacing string $data
        */
-       function ADODB_str_replace($src, $dest, $data)
-       {
-               if (ADODB_PHPVER >= 0x4050) return 
str_replace($src,$dest,$data);
+       function ADODB_str_replace($src, $dest, $data) {
+               if (ADODB_PHPVER >= 0x4050) {
+                       return str_replace($src,$dest,$data);
+               }
                
                $s = reset($src);
                $d = reset($dest);
@@ -145,8 +181,7 @@
                return $data;
        }
        
-       function ADODB_Setup()
-       {
+       function ADODB_Setup() {
        GLOBAL 
                $ADODB_vers,            // database version
                $ADODB_COUNTRECS,       // count number of records returned - 
slows down query
@@ -158,7 +193,9 @@
                $ADODB_GETONE_EOF,
                $ADODB_QUOTE_FIELDNAMES;
                
-               if (empty($ADODB_CACHE_CLASS)) $ADODB_CACHE_CLASS =  
'ADODB_Cache_File' ;
+               if (empty($ADODB_CACHE_CLASS)) {
+                       $ADODB_CACHE_CLASS =  'ADODB_Cache_File' ;
+               }
                $ADODB_FETCH_MODE = ADODB_FETCH_DEFAULT;
                $ADODB_FORCE_TYPE = ADODB_FORCE_VALUE;
                $ADODB_GETONE_EOF = null;
@@ -167,9 +204,10 @@
                        $ADODB_CACHE_DIR = '/tmp'; //(isset($_ENV['TMP'])) ? 
$_ENV['TMP'] : '/tmp';
                } else {
                        // do not accept url based paths, eg. http:/ or ftp:/
-                       if (strpos($ADODB_CACHE_DIR,'://') !== false) 
+                       if (strpos($ADODB_CACHE_DIR,'://') !== false) {
                                die("Illegal path http:// or ftp://";);
                }
+               }
                
                        
                // Initialize random number generator for randomizing cache 
flushes
@@ -179,14 +217,16 @@
                /**
                 * ADODB version as a string.
                 */
-               $ADODB_vers = 'V5.19  23-Apr-2014  (c) 2000-2014 John Lim 
(jlim#natsoft.com). All rights reserved. Released BSD & LGPL.';
+               $ADODB_vers = 'v5.20.4  30-Mar-2016';
        
                /**
                 * Determines whether recordset->RecordCount() is used. 
                 * Set to false for highest performance -- RecordCount() will 
always return -1 then
                 * for databases that provide "virtual" recordcounts...
                 */
-               if (!isset($ADODB_COUNTRECS)) $ADODB_COUNTRECS = true; 
+               if (!isset($ADODB_COUNTRECS)) {
+                       $ADODB_COUNTRECS = true;
+               }
        }
        
        
@@ -219,18 +259,19 @@
        }
        
        
-       function _adodb_safedate($s)
-       {
+       function _adodb_safedate($s) {
                return str_replace(array("'", '\\'), '', $s);
        }
 
        // parse date string to prevent injection attack
        // date string will have one quote at beginning e.g. '3434343'
-       function _adodb_safedateq($s)
-       {
+       function _adodb_safedateq($s) {
                $len = strlen($s);
-               if ($s[0] !== "'") $s2 = "'".$s[0];
-               else $s2 = "'";
+               if ($s[0] !== "'") {
+                       $s2 = "'".$s[0];
+               } else {
+                       $s2 = "'";
+               }
                for($i=1; $i<$len; $i++) {
                        $ch = $s[$i];
                        if ($ch === '\\') {
@@ -250,8 +291,7 @@
        
        // for transaction handling
        
-       function ADODB_TransMonitor($dbms, $fn, $errno, $errmsg, $p1, $p2, 
&$thisConnection)
-       {
+       function ADODB_TransMonitor($dbms, $fn, $errno, $errmsg, $p1, $p2, 
&$thisConnection) {
                //print "Errorno ($fn errno=$errno m=$errmsg) ";
                $thisConnection->_transOK = false;
                if ($thisConnection->_oldRaiseFn) {
@@ -266,63 +306,68 @@
        
                var $createdir = true; // requires creation of temp dirs
                
-               function ADODB_Cache_File()
-               {
+               function __construct() {
                global $ADODB_INCLUDED_CSV;
-                       if (empty($ADODB_INCLUDED_CSV)) 
include_once(ADODB_DIR.'/adodb-csvlib.inc.php');
+                       if (empty($ADODB_INCLUDED_CSV)) {
+                               include_once(ADODB_DIR.'/adodb-csvlib.inc.php');
+                       }
                }
                
                // write serialised recordset to cache item/file
-               function writecache($filename, $contents,  $debug, $secs2cache)
-               {
+               function writecache($filename, $contents,  $debug, $secs2cache) 
{
                        return adodb_write_file($filename, $contents,$debug);
                }
                
                // load serialised recordset and unserialise it
-               function &readcache($filename, &$err, $secs2cache, $rsClass)
-               {
+               function &readcache($filename, &$err, $secs2cache, $rsClass) {
                        $rs = csv2rs($filename,$err,$secs2cache,$rsClass);
                        return $rs;
                }
                
                // flush all items in cache
-               function flushall($debug=false)
-               {
+               function flushall($debug=false) {
                global $ADODB_CACHE_DIR;
 
                $rez = false;
                
                        if (strlen($ADODB_CACHE_DIR) > 1) {
                                $rez = $this->_dirFlush($ADODB_CACHE_DIR);
-                       if ($debug) ADOConnection::outp( "flushall: 
$dir<br><pre>\n". $rez."</pre>");
+                               if ($debug) {
+                                       ADOConnection::outp( "flushall: 
$ADODB_CACHE_DIR<br><pre>\n". $rez."</pre>");
+                               }
                        }
                        return $rez;
                }
                
                // flush one file in cache
-               function flushcache($f, $debug=false)
-               {
+               function flushcache($f, $debug=false) {
                        if (address@hidden($f)) {
-                               if ($debug) ADOConnection::outp( "flushcache: 
failed for $f");
+                               if ($debug) {
+                                       ADOConnection::outp( "flushcache: 
failed for $f");
+                               }
                        }
                }
                
-               function getdirname($hash)
-               {
+               function getdirname($hash) {
                global $ADODB_CACHE_DIR;
-                       if (!isset($this->notSafeMode)) $this->notSafeMode = 
!ini_get('safe_mode');
+                       if (!isset($this->notSafeMode)) {
+                               $this->notSafeMode = !ini_get('safe_mode');
+                       }
                        return ($this->notSafeMode) ? 
$ADODB_CACHE_DIR.'/'.substr($hash,0,2) : $ADODB_CACHE_DIR;
                }
                
                // create temp directories
-               function createdir($hash, $debug)
-               {
+               function createdir($hash, $debug) {
                global $ADODB_CACHE_PERMS;
                
                        $dir = $this->getdirname($hash);
                        if ($this->notSafeMode && !file_exists($dir)) {
                                $oldu = umask(0);
-                               if (address@hidden($dir, 
empty($ADODB_CACHE_PERMS) ? 0771 : $ADODB_CACHE_PERMS)) if(!is_dir($dir) && 
$debug) ADOConnection::outp("Cannot create $dir");
+                               if (address@hidden($dir, 
empty($ADODB_CACHE_PERMS) ? 0771 : $ADODB_CACHE_PERMS)) {
+                                       if(!is_dir($dir) && $debug) {
+                                               ADOConnection::outp("Cannot 
create $dir");
+                                       }
+                               }
                                umask($oldu);
                        }
                
@@ -335,18 +380,23 @@
                * Just specify the directory, and tell it if you want to delete 
the directory or just clear it out.
                * Note: $kill_top_level is used internally in the function to 
flush subdirectories.
                */
-               function _dirFlush($dir, $kill_top_level = false) 
-               {
+               function _dirFlush($dir, $kill_top_level = false) {
                   if(!$dh = @opendir($dir)) return;
                   
                   while (($obj = readdir($dh))) {
                                if($obj=='.' || $obj=='..') continue;
                                $f = $dir.'/'.$obj;
                
-                               if (strpos($obj,'.cache')) @unlink($f);
-                               if (is_dir($f)) $this->_dirFlush($f, true);
+                               if (strpos($obj,'.cache')) {
+                                       @unlink($f);
+                               }
+                               if (is_dir($f)) {
+                                       $this->_dirFlush($f, true);
+                               }
+                       }
+                       if ($kill_top_level === true) {
+                               @rmdir($dir);
                   }
-                  if ($kill_top_level === true) @rmdir($dir);
                   return true;
                }
        }
@@ -456,14 +506,50 @@
        var $_logsql = false;
        var $_transmode = ''; // transaction mode
        
+       /*
+        * Additional parameters that may be passed to drivers in the connect 
string
+        * Driver must be coded to accept the parameters
+        */
+       protected $connectionParameters = array();
 
-       static function Version()
+       /**
+       * Adds a parameter to the connection string.
+       *
+       * These parameters are added to the connection string when connecting,
+       * if the driver is coded to use it.
+       *
+       * @param        string  $parameter      The name of the parameter to set
+       * @param        string  $value          The value of the parameter
+       *
+       * @return null
+       *
+       * @example, for mssqlnative driver ('CharacterSet','UTF-8')
+       */
+       final public function setConnectionParameter($parameter,$value)
        {
+
+               $this->connectionParameters[$parameter] = $value;
+
+       }
+
+       static function Version() {
        global $ADODB_vers;
        
-               $ok = preg_match( '/^[Vv]?([0-9]\.[0-9]+(dev|[a-z]))?/', 
$ADODB_vers, $matches );
-               if (!$ok) return (float) substr($ADODB_vers,1);
-               else return $matches[1];
+               // Semantic Version number matching regex
+               $regex = '^[vV]?(\d+\.\d+\.\d+'         // Version number 
(X.Y.Z) with optional 'V'
+                       . '(?:-(?:'                         // Optional preprod 
version: a '-'
+                       . 'dev|'                            // followed by 'dev'
+                       . '(?:(?:alpha|beta|rc)(?:\.\d+))'  // or a preprod 
suffix and version number
+                       . '))?)(?:\s|$)';                   // Whitespace or 
end of string
+
+               if (!preg_match("/$regex/", $ADODB_vers, $matches)) {
+                       // This should normally not happen... Return whatever 
is between the start
+                       // of the string and the first whitespace (or the end 
of the string).
+                       self::outp("Invalid version number: '$ADODB_vers'", 
'Version');
+                       $regex = '^[vV]?(.*?)(?:\s|$)';
+                       preg_match("/$regex/", $ADODB_vers, $matches);
+               }
+               return $matches[1];
        }
        
        /**
@@ -472,28 +558,27 @@
                @returns An array with 2 elements: $arr['string'] is the 
description string, 
                        and $arr[version] is the version (also a string).
        */
-       function ServerInfo()
-       {
+       function ServerInfo() {
                return array('description' => '', 'version' => '');
        }
        
-       function IsConnected()
-       {
+       function IsConnected() {
        return !empty($this->_connectionID);
        }
        
-       function _findvers($str)
-       {
-               if (preg_match('/([0-9]+\.([0-9\.])+)/',$str, $arr)) return 
$arr[1];
-               else return '';
+       function _findvers($str) {
+               if (preg_match('/([0-9]+\.([0-9\.])+)/',$str, $arr)) {
+                       return $arr[1];
+               } else {
+                       return '';
+               }
        }
        
        /**
        * All error messages go through this bottleneck function.
        * You can define your own handler by defining the function name in 
ADODB_OUTP.
        */
-       static function outp($msg,$newline=true)
-       {
+       static function outp($msg,$newline=true) {
        global $ADODB_FLUSH,$ADODB_OUTP;
        
                if (defined('ADODB_OUTP')) {
@@ -506,20 +591,28 @@
                        return;
                }
                
-               if ($newline) $msg .= "<br>\n";
+               if ($newline) {
+                       $msg .= "<br>\n";
+               }
                
-               if (isset($_SERVER['HTTP_USER_AGENT']) || !$newline) echo $msg;
-               else echo strip_tags($msg);
+               if (isset($_SERVER['HTTP_USER_AGENT']) || !$newline) {
+                       echo $msg;
+               } else {
+                       echo strip_tags($msg);
+               }
        
                
-               if (!empty($ADODB_FLUSH) && ob_get_length() !== false) flush(); 
//  do not flush if output buffering enabled - useless - thx to Jesse Mullan 
+               if (!empty($ADODB_FLUSH) && ob_get_length() !== false) {
+                       flush(); //  do not flush if output buffering enabled - 
useless - thx to Jesse Mullan
+               }
                
        }
        
-       function Time()
-       {
+       function Time() {
                $rs = $this->_Execute("select $this->sysTimeStamp");
-               if ($rs && !$rs->EOF) return 
$this->UnixTimeStamp(reset($rs->fields));
+               if ($rs && !$rs->EOF) {
+                       return $this->UnixTimeStamp(reset($rs->fields));
+               }
                
                return false;
        }
@@ -535,39 +628,56 @@
         *
         * @return true or false
         */       
-       function Connect($argHostname = "", $argUsername = "", $argPassword = 
"", $argDatabaseName = "", $forceNew = false) 
-       {
-               if ($argHostname != "") $this->host = $argHostname;
-               if ($argUsername != "") $this->user = $argUsername;
-               if ($argPassword != "") $this->password = 'not stored'; // not 
stored for security reasons
-               if ($argDatabaseName != "") $this->database = $argDatabaseName; 
        
+       function Connect($argHostname = "", $argUsername = "", $argPassword = 
"", $argDatabaseName = "", $forceNew = false) {
+               if ($argHostname != "") {
+                       $this->host = $argHostname;
+               }
+               if ( strpos($this->host, ':') > 0 && isset($this->port) ) {
+                       list($this->host, $this->port) = explode(":", 
$this->host, 2);
+               }
+               if ($argUsername != "") {
+                       $this->user = $argUsername;
+               }
+               if ($argPassword != "") {
+                       $this->password = 'not stored'; // not stored for 
security reasons
+               }
+               if ($argDatabaseName != "") {
+                       $this->database = $argDatabaseName;
+               }
                
                $this->_isPersistentConnection = false; 
                        
                if ($forceNew) {
-                       if ($rez=$this->_nconnect($this->host, $this->user, 
$argPassword, $this->database)) return true;
+                       if ($rez=$this->_nconnect($this->host, $this->user, 
$argPassword, $this->database)) {
+                               return true;
+                       }
                } else {
-                        if ($rez=$this->_connect($this->host, $this->user, 
$argPassword, $this->database)) return true;
+                       if ($rez=$this->_connect($this->host, $this->user, 
$argPassword, $this->database)) {
+                               return true;
+                       }
                }
                if (isset($rez)) {
                        $err = $this->ErrorMsg();
-                       if (empty($err)) $err = "Connection error to server 
'$argHostname' with user '$argUsername'";
+                       if (empty($err)) {
+                               $err = "Connection error to server 
'$argHostname' with user '$argUsername'";
+                       }
                        $ret = false;
                } else {
                        $err = "Missing extension for ".$this->dataProvider;
                        $ret = 0;
                }
-               if ($fn = $this->raiseErrorFn) 
+               if ($fn = $this->raiseErrorFn) {
                        
$fn($this->databaseType,'CONNECT',$this->ErrorNo(),$err,$this->host,$this->database,$this);
+               }
                
-               
                $this->_connectionID = false;
-               if ($this->debug) ADOConnection::outp( $this->host.': '.$err);
+               if ($this->debug) {
+                       ADOConnection::outp( $this->host.': '.$err);
+               }
                return $ret;
        }       
        
-       function _nconnect($argHostname, $argUsername, $argPassword, 
$argDatabaseName)
-       {
+       function _nconnect($argHostname, $argUsername, $argPassword, 
$argDatabaseName) {
                return $this->_connect($argHostname, $argUsername, 
$argPassword, $argDatabaseName);
        }
        
@@ -582,8 +692,7 @@
         *
         * @return true or false
         */       
-       function NConnect($argHostname = "", $argUsername = "", $argPassword = 
"", $argDatabaseName = "") 
-       {
+       function NConnect($argHostname = "", $argUsername = "", $argPassword = 
"", $argDatabaseName = "") {
                return $this->Connect($argHostname, $argUsername, $argPassword, 
$argDatabaseName, true);
        }
        
@@ -597,23 +706,38 @@
         *
         * @return return true or false
         */     
-       function PConnect($argHostname = "", $argUsername = "", $argPassword = 
"", $argDatabaseName = "")
-       {
+       function PConnect($argHostname = "", $argUsername = "", $argPassword = 
"", $argDatabaseName = "") {
                
-               if (defined('ADODB_NEVER_PERSIST')) 
+               if (defined('ADODB_NEVER_PERSIST')) {
                        return 
$this->Connect($argHostname,$argUsername,$argPassword,$argDatabaseName);
+               }
                
-               if ($argHostname != "") $this->host = $argHostname;
-               if ($argUsername != "") $this->user = $argUsername;
-               if ($argPassword != "") $this->password = 'not stored';
-               if ($argDatabaseName != "") $this->database = $argDatabaseName; 
        
+               if ($argHostname != "") {
+                       $this->host = $argHostname;
+               }
+               if ( strpos($this->host, ':') > 0 && isset($this->port) ) {
+                       list($this->host, $this->port) = explode(":", 
$this->host, 2);
+               }
+               if ($argUsername != "") {
+                       $this->user = $argUsername;
+               }
+               if ($argPassword != "") {
+                       $this->password = 'not stored';
+               }
+               if ($argDatabaseName != "") {
+                       $this->database = $argDatabaseName;
+               }
                        
                $this->_isPersistentConnection = true;  
                
-               if ($rez = $this->_pconnect($this->host, $this->user, 
$argPassword, $this->database)) return true;
+               if ($rez = $this->_pconnect($this->host, $this->user, 
$argPassword, $this->database)) {
+                       return true;
+               }
                if (isset($rez)) {
                        $err = $this->ErrorMsg();
-                       if (empty($err)) $err = "Connection error to server 
'$argHostname' with user '$argUsername'";
+                       if (empty($err)) {
+                               $err = "Connection error to server 
'$argHostname' with user '$argUsername'";
+                       }
                        $ret = false;
                } else {
                        $err = "Missing extension for ".$this->dataProvider;
@@ -624,12 +748,13 @@
                }
                
                $this->_connectionID = false;
-               if ($this->debug) ADOConnection::outp( $this->host.': '.$err);
+               if ($this->debug) {
+                       ADOConnection::outp( $this->host.': '.$err);
+               }
                return $ret;
        }
 
-       function outp_throw($msg,$src='WARN',$sql='')
-       {
+       function outp_throw($msg,$src='WARN',$sql='') {
                if (defined('ADODB_ERROR_HANDLER') &&  ADODB_ERROR_HANDLER == 
'adodb_throw') {
                        
adodb_throw($this->databaseType,$src,-9999,$msg,$sql,false,$this);
                        return;
@@ -638,24 +763,26 @@
        }
        
        // create cache class. Code is backward compat with old memcache 
implementation
-       function _CreateCache()
-       {
+       function _CreateCache() {
        global $ADODB_CACHE, $ADODB_CACHE_CLASS;
        
                if ($this->memCache) {
                global $ADODB_INCLUDED_MEMCACHE;
                
-                       if (empty($ADODB_INCLUDED_MEMCACHE)) 
include(ADODB_DIR.'/adodb-memcache.lib.inc.php');
+                       if (empty($ADODB_INCLUDED_MEMCACHE)) {
+                               
include_once(ADODB_DIR.'/adodb-memcache.lib.inc.php');
+                       }
                                $ADODB_CACHE = new ADODB_Cache_MemCache($this);
-               } else
+               } else {
                                $ADODB_CACHE = new $ADODB_CACHE_CLASS($this);
-               
+               }
        }
        
        // Format date column in sql string given an input format that 
understands Y M D
-       function SQLDate($fmt, $col=false)
-       {       
-               if (!$col) $col = $this->sysDate;
+       function SQLDate($fmt, $col=false) {
+               if (!$col) {
+                       $col = $this->sysDate;
+               }
                return $col; // child class implement
        }
        
@@ -674,8 +801,7 @@
         *                      if the database does not support prepare.
         *
         */     
-       function Prepare($sql)
-       {
+       function Prepare($sql) {
                return $sql;
        }
 
@@ -693,38 +819,35 @@
         *                      if the database does not support prepare.
         *
         */     
-       function PrepareSP($sql,$param=true)
-       {
+       function PrepareSP($sql,$param=true) {
                return $this->Prepare($sql,$param);
        }
 
        /**
        * PEAR DB Compat
        */
-       function Quote($s)
-       {
+       function Quote($s) {
                return $this->qstr($s,false);
        }
        
        /**
-        Requested by "Karsten Dambekalns" <address@hidden>
+        * Requested by "Karsten Dambekalns" <address@hidden>
        */
-       function QMagic($s)
-       {
+       function QMagic($s) {
                return $this->qstr($s,get_magic_quotes_gpc());
        }
 
-       function q(&$s)
-       {
-               #if (!empty($this->qNull)) if ($s == 'null') return $s;
+       function q(&$s) {
+               //if (!empty($this->qNull && $s == 'null') {
+               //      return $s;
+               //}
                $s = $this->qstr($s,false);
        }
        
        /**
        * PEAR DB Compat - do not use internally. 
        */
-       function ErrorNative()
-       {
+       function ErrorNative() {
                return $this->ErrorNo();
        }
 
@@ -732,8 +855,7 @@
    /**
        * PEAR DB Compat - do not use internally. 
        */
-       function nextId($seq_name)
-       {
+       function nextId($seq_name) {
                return $this->GenID($seq_name);
        }
 
@@ -744,18 +866,15 @@
        *  @param $table        name of table to lock
        *  @param $where        where clause to use, eg: "WHERE row=12". If 
left empty, will escalate to table lock
        */
-       function RowLock($table,$where,$col='1 as adodbignore')
-       {
+       function RowLock($table,$where,$col='1 as adodbignore') {
                return false;
        }
        
-       function CommitLock($table)
-       {
+       function CommitLock($table) {
                return $this->CommitTrans();
        }
        
-       function RollbackLock($table)
-       {
+       function RollbackLock($table) {
                return $this->RollbackTrans();
        }
        
@@ -768,8 +887,7 @@
        * @param mode   The fetchmode ADODB_FETCH_ASSOC or ADODB_FETCH_NUM
        * @returns              The previous fetch mode
        */
-       function SetFetchMode($mode)
-       {       
+       function SetFetchMode($mode) {
                $old = $this->fetchMode;
                $this->fetchMode = $mode;
                
@@ -784,10 +902,11 @@
        /**
        * PEAR DB Compat - do not use internally. 
        */
-       function Query($sql, $inputarr=false)
-       {
+       function Query($sql, $inputarr=false) {
                $rs = $this->Execute($sql, $inputarr);
-               if (!$rs && defined('ADODB_PEAR')) return ADODB_PEAR_Error();
+               if (!$rs && defined('ADODB_PEAR')) {
+                       return ADODB_PEAR_Error();
+               }
                return $rs;
        }
 
@@ -795,10 +914,11 @@
        /**
        * PEAR DB Compat - do not use internally
        */
-       function LimitQuery($sql, $offset, $count, $params=false)
-       {
+       function LimitQuery($sql, $offset, $count, $params=false) {
                $rs = $this->SelectLimit($sql, $count, $offset, $params); 
-               if (!$rs && defined('ADODB_PEAR')) return ADODB_PEAR_Error();
+               if (!$rs && defined('ADODB_PEAR')) {
+                       return ADODB_PEAR_Error();
+               }
                return $rs;
        }
 
@@ -806,8 +926,7 @@
        /**
        * PEAR DB Compat - do not use internally
        */
-       function Disconnect()
-       {
+       function Disconnect() {
                return $this->Close();
        }
        
@@ -824,23 +943,20 @@
         * @param string $type (unused)
         * @return string query parameter placeholder
        */
-       function Param($name,$type='C')
-       {
+       function Param($name,$type='C') {
                return '?';
        }
        
        /*
                InParameter and OutParameter are self-documenting versions of 
Parameter().
        */
-       function InParameter(&$stmt,&$var,$name,$maxLen=4000,$type=false)
-       {
+       function InParameter(&$stmt,&$var,$name,$maxLen=4000,$type=false) {
                return $this->Parameter($stmt,$var,$name,false,$maxLen,$type);
        }
        
        /*
        */
-       function OutParameter(&$stmt,&$var,$name,$maxLen=4000,$type=false)
-       {
+       function OutParameter(&$stmt,&$var,$name,$maxLen=4000,$type=false) {
                return $this->Parameter($stmt,$var,$name,true,$maxLen,$type);
        
        }
@@ -861,14 +977,12 @@
                @param [$type] The data type of $var. Legal values depend on 
driver.
 
        */
-       function 
Parameter(&$stmt,&$var,$name,$isOutput=false,$maxLen=4000,$type=false)
-       {
+       function 
Parameter(&$stmt,&$var,$name,$isOutput=false,$maxLen=4000,$type=false) {
                return false;
        }
        
        
-       function IgnoreErrors($saveErrs=false)
-       {
+       function IgnoreErrors($saveErrs=false) {
                if (!$saveErrs) {
                        $saveErrs = array($this->raiseErrorFn,$this->_transOK);
                        $this->raiseErrorFn = false;
@@ -880,17 +994,16 @@
        }
        
        /**
-               Improved method of initiating a transaction. Used together with 
CompleteTrans().
-               Advantages include:
-               
-               a. StartTrans/CompleteTrans is nestable, unlike 
BeginTrans/CommitTrans/RollbackTrans.
-                  Only the outermost block is treated as a transaction.<br>
-               b. CompleteTrans auto-detects SQL errors, and will rollback on 
errors, commit otherwise.<br>
-               c. All BeginTrans/CommitTrans/RollbackTrans inside a 
StartTrans/CompleteTrans block
-                  are disabled, making it backward compatible.
+        * Improved method of initiating a transaction. Used together with 
CompleteTrans().
+        * Advantages include:
+     *
+        * a. StartTrans/CompleteTrans is nestable, unlike 
BeginTrans/CommitTrans/RollbackTrans.
+        *    Only the outermost block is treated as a transaction.<br>
+        * b. CompleteTrans auto-detects SQL errors, and will rollback on 
errors, commit otherwise.<br>
+        * c. All BeginTrans/CommitTrans/RollbackTrans inside a 
StartTrans/CompleteTrans block
+        *    are disabled, making it backward compatible.
        */
-       function StartTrans($errfn = 'ADODB_TransMonitor')
-       {
+       function StartTrans($errfn = 'ADODB_TransMonitor') {
                if ($this->transOff > 0) {
                        $this->transOff += 1;
                        return true;
@@ -900,7 +1013,9 @@
                $this->raiseErrorFn = $errfn;
                $this->_transOK = true;
                
-               if ($this->debug && $this->transCnt > 0) 
ADOConnection::outp("Bad Transaction: StartTrans called within BeginTrans");
+               if ($this->debug && $this->transCnt > 0) {
+                       ADOConnection::outp("Bad Transaction: StartTrans called 
within BeginTrans");
+               }
                $ok = $this->BeginTrans();
                $this->transOff = 1;
                return $ok;
@@ -915,8 +1030,7 @@
                and if set to false force rollback even if no SQL error 
detected.
                @returns true on commit, false on rollback.
        */
-       function CompleteTrans($autoComplete = true)
-       {
+       function CompleteTrans($autoComplete = true) {
                if ($this->transOff > 1) {
                        $this->transOff -= 1;
                        return true;
@@ -927,13 +1041,20 @@
                if ($this->_transOK && $autoComplete) {
                        if (!$this->CommitTrans()) {
                                $this->_transOK = false;
-                               if ($this->debug) ADOConnection::outp("Smart 
Commit failed");
-                       } else
-                               if ($this->debug) ADOConnection::outp("Smart 
Commit occurred");
+                               if ($this->debug) {
+                                       ADOConnection::outp("Smart Commit 
failed");
+                               }
+                       } else {
+                               if ($this->debug) {
+                                       ADOConnection::outp("Smart Commit 
occurred");
+                               }
+                       }
                } else {
                        $this->_transOK = false;
                        $this->RollbackTrans();
-                       if ($this->debug) ADOCOnnection::outp("Smart Rollback 
occurred");
+                       if ($this->debug) {
+                               ADOCOnnection::outp("Smart Rollback occurred");
+                       }
                }
                
                return $this->_transOK;
@@ -942,8 +1063,7 @@
        /*
                At the end of a StartTrans/CompleteTrans block, perform a 
rollback.
        */
-       function FailTrans()
-       {
+       function FailTrans() {
                if ($this->debug) 
                        if ($this->transOff == 0) {
                                ADOConnection::outp("FailTrans outside 
StartTrans/CompleteTrans");
@@ -957,9 +1077,10 @@
        /**
                Check if transaction has failed, only for Smart Transactions.
        */
-       function HasFailedTrans()
-       {
-               if ($this->transOff > 0) return $this->_transOK == false;
+       function HasFailedTrans() {
+               if ($this->transOff > 0) {
+                       return $this->_transOK == false;
+               }
                return false;
        }
        
@@ -970,15 +1091,18 @@
         * @param [inputarr]    holds the input data to bind to. Null elements 
will be set to null.
         * @return              RecordSet or false
         */
-       function Execute($sql,$inputarr=false) 
-       {
+       function Execute($sql,$inputarr=false) {
                if ($this->fnExecute) {
                        $fn = $this->fnExecute;
                        $ret = $fn($this,$sql,$inputarr);
-                       if (isset($ret)) return $ret;
+                       if (isset($ret)) {
+                               return $ret;
+                       }
                }
                if ($inputarr !== false) {
-                       if (!is_array($inputarr)) $inputarr = array($inputarr);
+                       if (!is_array($inputarr)) {
+                               $inputarr = array($inputarr);
+                       }
                        
                        $element0 = reset($inputarr);
                        # is_object check because oci8 descriptors can be 
passed in
@@ -988,9 +1112,39 @@
                        unset($element0);
                        
                        if (!is_array($sql) && !$this->_bindInputArray) {
+                               // @TODO this would consider a '?' within a 
string as a parameter...
                                $sqlarr = explode('?',$sql);
                                $nparams = sizeof($sqlarr)-1;
-                               if (!$array_2d) $inputarr = array($inputarr);
+
+                               if (!$array_2d) {
+                                       // When not Bind Bulk - convert to 
array of arguments list
+                                       $inputarr = array($inputarr);
+                               } else {
+                                       // Bulk bind - Make sure all list of 
params have the same number of elements
+                                       $countElements = array_map('count', 
$inputarr);
+                                       if (1 != 
count(array_unique($countElements))) {
+                                               $this->outp_throw(
+                                                       "[bulk execute] Input 
array has different number of params  [" . print_r($countElements, true) .  
"].",
+                                                       'Execute'
+                                               );
+                                               return false;
+                                       }
+                                       unset($countElements);
+                               }
+                               // Make sure the number of parameters provided 
in the input
+                               // array matches what the query expects
+                               $element0 = reset($inputarr);
+                               if ($nparams != count($element0)) {
+                                       $this->outp_throw(
+                                               "Input array has " . 
count($element0) .
+                                               " params, does not match query: 
'" . htmlspecialchars($sql) . "'",
+                                               'Execute'
+                                       );
+                                       return false;
+                               }
+                               
+                               // clean memory
+                               unset($element0);
        
                                foreach($inputarr as $arr) {
                                        $sql = ''; $i = 0;
@@ -1000,43 +1154,57 @@
                                                // from Ron Baldwin 
<ron.baldwin#sourceprose.com>
                                                // Only quote string types      
                                                $typ = gettype($v);
-                                               if ($typ == 'string')
+                                               if ($typ == 'string') {
                                                        //New memory copy of 
input created here -mikefedyk
                                                        $sql .= $this->qstr($v);
-                                               else if ($typ == 'double')
+                                               } else if ($typ == 'double') {
                                                        $sql .= 
str_replace(',','.',$v); // locales fix so 1.1 does not get converted to 1,1
-                                               else if ($typ == 'boolean')
+                                               } else if ($typ == 'boolean') {
                                                        $sql .= $v ? 
$this->true : $this->false;
-                                               else if ($typ == 'object') {
-                                                       if (method_exists($v, 
'__toString')) $sql .= $this->qstr($v->__toString());
-                                                       else $sql .= 
$this->qstr((string) $v);
-                                               } else if ($v === null)
+                                               } else if ($typ == 'object') {
+                                                       if (method_exists($v, 
'__toString')) {
+                                                               $sql .= 
$this->qstr($v->__toString());
+                                                       } else {
+                                                               $sql .= 
$this->qstr((string) $v);
+                                                       }
+                                               } else if ($v === null) {
                                                        $sql .= 'NULL';
-                                               else
+                                               } else {
                                                        $sql .= $v;
+                                               }
                                                $i += 1;
                                                
-                                               if ($i == $nparams) break;
+                                               if ($i == $nparams) {
+                                                       break;
+                                               }
                                        } // while
                                        if (isset($sqlarr[$i])) {
                                                $sql .= $sqlarr[$i];
-                                               if ($i+1 != sizeof($sqlarr)) 
$this->outp_throw( "Input Array does not match ?: 
".htmlspecialchars($sql),'Execute');
-                                       } else if ($i != sizeof($sqlarr))       
+                                               if ($i+1 != sizeof($sqlarr)) {
+                                                       $this->outp_throw( 
"Input Array does not match ?: ".htmlspecialchars($sql),'Execute');
+                                               }
+                                       } else if ($i != sizeof($sqlarr)) {
                                                $this->outp_throw( "Input array 
does not match ?: ".htmlspecialchars($sql),'Execute');
+                                       }
                
                                        $ret = $this->_Execute($sql);
-                                       if (!$ret) return $ret;
+                                       if (!$ret) {
+                                               return $ret;
+                                       }
                                }       
                        } else {
                                if ($array_2d) {
-                                       if (is_string($sql))
+                                       if (is_string($sql)) {
                                                $stmt = $this->Prepare($sql);
-                                       else
+                                       } else {
                                                $stmt = $sql;
+                                       }
                                        
                                        foreach($inputarr as $arr) {
                                                $ret = 
$this->_Execute($stmt,$arr);
-                                               if (!$ret) return $ret;
+                                               if (!$ret) {
+                                                       return $ret;
+                                               }
                                        }
                                } else {
                                        $ret = $this->_Execute($sql,$inputarr);
@@ -1049,12 +1217,20 @@
                return $ret;
        }
        
+       function _Execute($sql,$inputarr=false) {
+               // ExecuteCursor() may send non-string queries (such as arrays),
+               // so we need to ignore those.
+               if( is_string($sql) ) {
+                       // Strips keyword used to help generate SELECT COUNT(*) 
queries
+                       // from SQL if it exists.
+                       $sql = ADODB_str_replace( '_ADODB_COUNT', '', $sql );
+               }
        
-       function _Execute($sql,$inputarr=false)
-       {
                if ($this->debug) {
                        global $ADODB_INCLUDED_LIB;
-                       if (empty($ADODB_INCLUDED_LIB)) 
include(ADODB_DIR.'/adodb-lib.inc.php');
+                       if (empty($ADODB_INCLUDED_LIB)) {
+                               include(ADODB_DIR.'/adodb-lib.inc.php');
+                       }
                        $this->_queryID = _adodb_debug_execute($this, 
$sql,$inputarr);
                } else {
                        $this->_queryID = @$this->_query($sql,$inputarr);
@@ -1064,17 +1240,20 @@
                // OK, query executed
                // ************************
 
-               if ($this->_queryID === false) { // error handling if query 
fails
-                       if ($this->debug == 99) adodb_backtrace(true,5);        
+               // error handling if query fails
+               if ($this->_queryID === false) {
+                       if ($this->debug == 99) {
+                               adodb_backtrace(true,5);
+                       }
                        $fn = $this->raiseErrorFn;
                        if ($fn) {
                                
$fn($this->databaseType,'EXECUTE',$this->ErrorNo(),$this->ErrorMsg(),$sql,$inputarr,$this);
                        } 
-                       $false = false;
-                       return $false;
+                       return false;
                } 
                
-               if ($this->_queryID === true) { // return simplified recordset 
for inserts/updates/deletes with lower overhead
+               // return simplified recordset for inserts/updates/deletes with 
lower overhead
+               if ($this->_queryID === true) {
                        $rsclass = $this->rsPrefix.'empty';
                        $rs = (class_exists($rsclass)) ? new $rsclass():  new 
ADORecordSet_empty();
                        
@@ -1086,8 +1265,11 @@
                $rs = new $rsclass($this->_queryID,$this->fetchMode);
                $rs->connection = $this; // Pablo suggestion
                $rs->Init();
-               if (is_array($sql)) $rs->sql = $sql[0];
-               else $rs->sql = $sql;
+               if (is_array($sql)) {
+                       $rs->sql = $sql[0];
+               } else {
+                       $rs->sql = $sql;
+               }
                if ($rs->_numOfRows <= 0) {
                global $ADODB_COUNTRECS;
                        if ($ADODB_COUNTRECS) {
@@ -1101,15 +1283,17 @@
                return $rs;
        }
 
-       function CreateSequence($seqname='adodbseq',$startID=1)
-       {
-               if (empty($this->_genSeqSQL)) return false;
+       function CreateSequence($seqname='adodbseq',$startID=1) {
+               if (empty($this->_genSeqSQL)) {
+                       return false;
+               }
                return 
$this->Execute(sprintf($this->_genSeqSQL,$seqname,$startID));
        }
 
-       function DropSequence($seqname='adodbseq')
-       {
-               if (empty($this->_dropSeqSQL)) return false;
+       function DropSequence($seqname='adodbseq') {
+               if (empty($this->_dropSeqSQL)) {
+                       return false;
+               }
                return $this->Execute(sprintf($this->_dropSeqSQL,$seqname));
        }
 
@@ -1121,8 +1305,7 @@
         * @param startID               if sequence does not exist, start at 
this ID
         * @return              0 if not supported, otherwise a sequence id
         */
-       function GenID($seqname='adodbseq',$startID=1)
-       {
+       function GenID($seqname='adodbseq',$startID=1) {
                if (!$this->hasGenID) {
                        return 0; // formerly returns false pre 1.60
                }
@@ -1141,10 +1324,15 @@
                        $createseq = 
$this->Execute(sprintf($this->_genSeqSQL,$seqname,$startID));
                        $rs = $this->Execute($getnext);
                }
-               if ($rs && !$rs->EOF) $this->genID = reset($rs->fields);
-               else $this->genID = 0; // false
+               if ($rs && !$rs->EOF) {
+                       $this->genID = reset($rs->fields);
+               } else {
+                       $this->genID = 0; // false
+               }
        
-               if ($rs) $rs->Close();
+               if ($rs) {
+                       $rs->Close();
+               }
 
                return $this->genID;
        }       
@@ -1154,10 +1342,13 @@
         * @param $column string name of the column, not needed by all 
databases (eg. mysql), default ''
         * @return  the last inserted ID. Not all databases support this.
         */ 

@@ Diff output truncated at 153600 characters. @@



reply via email to

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