From 18b818bd57e5abdcbb1ae78b48736561fa1870ef Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Sun, 10 Apr 2011 15:05:47 +0000 Subject: [PATCH] reverting accidently commit r34595 --- .../adodb/drivers/adodb-postgres64.inc.php | 10 +- .../inc/adodb/drivers/adodb-postgres7.inc.php | 157 +++++------------- phpgwapi/inc/class.asyncservice.inc.php | 4 +- phpgwapi/inc/class.auth_ldap.inc.php | 2 +- phpgwapi/inc/class.dragdrop.inc.php | 44 ++--- phpgwapi/inc/class.egw_db.inc.php | 3 +- phpgwapi/inc/class.egw_json.inc.php | 7 +- phpgwapi/inc/class.groupdav_handler.inc.php | 2 +- phpgwapi/inc/class.pdf.inc.php | 48 +----- phpgwapi/inc/class.phpmailer.inc.php | 16 +- 10 files changed, 86 insertions(+), 207 deletions(-) diff --git a/phpgwapi/inc/adodb/drivers/adodb-postgres64.inc.php b/phpgwapi/inc/adodb/drivers/adodb-postgres64.inc.php index 51f5fa257b..12f8a31935 100644 --- a/phpgwapi/inc/adodb/drivers/adodb-postgres64.inc.php +++ b/phpgwapi/inc/adodb/drivers/adodb-postgres64.inc.php @@ -152,7 +152,7 @@ WHERE relkind in ('r','v') AND (c.relname='%s' or c.relname = lower('%s')) Using a OID as a unique identifier is not generally wise. Unless you are very careful, you might end up with a tuple having a different OID if a database must be reloaded. */ - function _insertid($table,$column,$try_oid=false) + function _insertid($table,$column,$try_oid=true) { if ($try_oid) { @@ -257,20 +257,20 @@ select viewname,'V' from pg_views where viewname like $mask"; function qstr($s,$magic_quotes=false) { if (is_bool($s)) return $s ? 'true' : 'false'; - + if (!$magic_quotes) { if (ADODB_PHPVER >= 0x5200) { return "'".pg_escape_string($this->_connectionID,$s)."'"; - } + } if (ADODB_PHPVER >= 0x4200) { return "'".pg_escape_string($s)."'"; } if ($this->replaceQuote[0] == '\\'){ $s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\\000"),$s); } - return "'".str_replace("'",$this->replaceQuote,$s)."'"; + return "'".str_replace("'",$this->replaceQuote,$s)."'"; } - + // undo magic quotes for " $s = str_replace('\\"','"',$s); return "'$s'"; diff --git a/phpgwapi/inc/adodb/drivers/adodb-postgres7.inc.php b/phpgwapi/inc/adodb/drivers/adodb-postgres7.inc.php index 1dfd0d5245..b0ac53b4fa 100644 --- a/phpgwapi/inc/adodb/drivers/adodb-postgres7.inc.php +++ b/phpgwapi/inc/adodb/drivers/adodb-postgres7.inc.php @@ -1,6 +1,6 @@ rsPrefix .= 'assoc_'; } - $this->_bindInputArray = PHP_VERSION >= 5.1; } // the following should be compat with postgresql 7.2, // which makes obsolete the LIMIT limit,offset syntax - function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0) + function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0) { - $offsetStr = ($offset >= 0) ? " OFFSET ".((integer)$offset) : ''; - $limitStr = ($nrows >= 0) ? " LIMIT ".((integer)$nrows) : ''; + $offsetStr = ($offset >= 0) ? ' OFFSET '.(int)$offset : ''; + $limitStr = ($nrows >= 0) ? ' LIMIT '.(int)$nrows : ''; if ($secs2cache) - $rs = $this->CacheExecute($secs2cache,$sql."$limitStr$offsetStr",$inputarr); + $rs =& $this->CacheExecute($secs2cache,$sql.$limitStr.$offsetStr,$inputarr); else - $rs = $this->Execute($sql."$limitStr$offsetStr",$inputarr); + $rs =& $this->Execute($sql.$limitStr.$offsetStr,$inputarr); return $rs; } @@ -56,123 +55,41 @@ class ADODB_postgres7 extends ADODB_postgres64 { } */ - /* - I discovered that the MetaForeignKeys method no longer worked for Postgres 8.3. - I went ahead and modified it to work for both 8.2 and 8.3. - Please feel free to include this change in your next release of adodb. - William Kolodny [William.Kolodny#gt-t.net] - */ - function MetaForeignKeys($table, $owner=false, $upper=false) - { - $sql=" - SELECT fum.ftblname AS lookup_table, split_part(fum.rf, ')'::text, 1) AS lookup_field, - fum.ltable AS dep_table, split_part(fum.lf, ')'::text, 1) AS dep_field - FROM ( - SELECT fee.ltable, fee.ftblname, fee.consrc, split_part(fee.consrc,'('::text, 2) AS lf, - split_part(fee.consrc, '('::text, 3) AS rf - FROM ( - SELECT foo.relname AS ltable, foo.ftblname, - pg_get_constraintdef(foo.oid) AS consrc - FROM ( - SELECT c.oid, c.conname AS name, t.relname, ft.relname AS ftblname - FROM pg_constraint c - JOIN pg_class t ON (t.oid = c.conrelid) - JOIN pg_class ft ON (ft.oid = c.confrelid) - JOIN pg_namespace nft ON (nft.oid = ft.relnamespace) - LEFT JOIN pg_description ds ON (ds.objoid = c.oid) - JOIN pg_namespace n ON (n.oid = t.relnamespace) - WHERE c.contype = 'f'::\"char\" - ORDER BY t.relname, n.nspname, c.conname, c.oid - ) foo - ) fee) fum - WHERE fum.ltable='".strtolower($table)."' - ORDER BY fum.ftblname, fum.ltable, split_part(fum.lf, ')'::text, 1) - "; - $rs = $this->Execute($sql); - - if (!$rs || $rs->EOF) return false; - - $a = array(); - while (!$rs->EOF) { - if ($upper) { - $a[strtoupper($rs->Fields('lookup_table'))][] = strtoupper(str_replace('"','',$rs->Fields('dep_field').'='.$rs->Fields('lookup_field'))); - } else { - $a[$rs->Fields('lookup_table')][] = str_replace('"','',$rs->Fields('dep_field').'='.$rs->Fields('lookup_field')); - } - $rs->MoveNext(); - } - - return $a; - - } - // from Edward Jaramilla, improved version - works on pg 7.4 - function _old_MetaForeignKeys($table, $owner=false, $upper=false) - { - $sql = 'SELECT t.tgargs as args - FROM - pg_trigger t,pg_class c,pg_proc p - WHERE - t.tgenabled AND - t.tgrelid = c.oid AND - t.tgfoid = p.oid AND - p.proname = \'RI_FKey_check_ins\' AND - c.relname = \''.strtolower($table).'\' - ORDER BY - t.tgrelid'; +function MetaForeignKeys($table, $owner=false, $upper=false) +{ + $sql = 'SELECT t.tgargs as args + FROM + pg_trigger t,pg_class c,pg_proc p + WHERE + t.tgenabled AND + t.tgrelid = c.oid AND + t.tgfoid = p.oid AND + p.proname = \'RI_FKey_check_ins\' AND + c.relname = \''.strtolower($table).'\' + ORDER BY + t.tgrelid'; - $rs = $this->Execute($sql); + $rs = $this->Execute($sql); - if (!$rs || $rs->EOF) return false; - - $arr = $rs->GetArray(); + if ($rs && !$rs->EOF) { + $arr =& $rs->GetArray(); $a = array(); - foreach($arr as $v) { + foreach($arr as $v) + { $data = explode(chr(0), $v['args']); - $size = count($data)-1; //-1 because the last node is empty - for($i = 4; $i < $size; $i++) { - if ($upper) - $a[strtoupper($data[2])][] = strtoupper($data[$i].'='.$data[++$i]); - else - $a[$data[2]][] = $data[$i].'='.$data[++$i]; + if ($upper) { + $a[strtoupper($data[2])][] = strtoupper($data[4].'='.$data[5]); + } else { + $a[$data[2]][] = $data[4].'='.$data[5]; } } return $a; } + return false; +} - function _query($sql,$inputarr=false) - { - if (! $this->_bindInputArray) { - // We don't have native support for parameterized queries, so let's emulate it at the parent - return ADODB_postgres64::_query($sql, $inputarr); - } - $this->_errorMsg = false; - // -- added Cristiano da Cunha Duarte - if ($inputarr) { - $sqlarr = explode('?',trim($sql)); - $sql = ''; - $i = 1; - $last = sizeof($sqlarr)-1; - foreach($sqlarr as $v) { - if ($last < $i) $sql .= $v; - else $sql .= $v.' $'.$i; - $i++; - } - $rez = pg_query_params($this->_connectionID,$sql, $inputarr); - } else { - $rez = pg_query($this->_connectionID,$sql); - } - // check if no data returned, then no need to create real recordset - if ($rez && pg_numfields($rez) <= 0) { - if (is_resource($this->_resultid) && get_resource_type($this->_resultid) === 'pgsql result') { - pg_freeresult($this->_resultid); - } - $this->_resultid = $rez; - return true; - } - return $rez; - } // this is a set of functions for managing client encoding - very important if the encodings // of your database and your output target (i.e. HTML) don't match @@ -203,6 +120,20 @@ class ADODB_postgres7 extends ADODB_postgres64 { } else return false; } else return true; } + + // use pg_escape_string if available + function qstr($s,$magic_quotes=false) + { + if (!$magic_quotes && function_exists('pg_escape_string')) { + return "'".pg_escape_string($s)."'"; + } + return parent::qstr($s,$magic_quotes); + } + + function _insertid($table,$column) + { + return parent::_insertid($table,$column,false); // dont try oid + } } /*-------------------------------------------------------------------------------------- diff --git a/phpgwapi/inc/class.asyncservice.inc.php b/phpgwapi/inc/class.asyncservice.inc.php index 90789d13ad..5d3c2a7f84 100644 --- a/phpgwapi/inc/class.asyncservice.inc.php +++ b/phpgwapi/inc/class.asyncservice.inc.php @@ -467,11 +467,11 @@ class asyncservice * != 0 reads all rows/jobs matching $id (sql-wildcards '%' and '_' can be used) * @param array|string $cols='*' string or array of column-names / select-expressions * @param int|bool $offset=False offset for a limited query or False (default) - * @param string $append='ORDER BY async_next' string to append to the end of the query + * @param string $append string to append to the end of the query, eg. ORDER BY ... * @param int $num_rows=0 number of rows to return if offset set, default 0 = use default in user prefs * @return array/boolean db-rows / jobs as array or False if no matches */ - function read($id=0,$cols='*',$offset=False,$append='ORDER BY async_next',$num_rows=0) + function read($id=0,$cols='*',$offset=False,$append='',$num_rows=0) { if (!is_array($id) && (strpos($id,'%') !== False || strpos($id,'_') !== False)) { diff --git a/phpgwapi/inc/class.auth_ldap.inc.php b/phpgwapi/inc/class.auth_ldap.inc.php index ca807e3478..90303ea553 100644 --- a/phpgwapi/inc/class.auth_ldap.inc.php +++ b/phpgwapi/inc/class.auth_ldap.inc.php @@ -121,7 +121,7 @@ class auth_ldap implements auth_backend * fetch the last pwd change for the user * * @param string $username username of account to authenticate - * @return mixed false or shadowlastchange*24*3600 + * @return mixed false or shadowlastchange*24*3600 */ function getLastPwdChange($username) { diff --git a/phpgwapi/inc/class.dragdrop.inc.php b/phpgwapi/inc/class.dragdrop.inc.php index c3da1ff6fd..3c8cc6c57a 100644 --- a/phpgwapi/inc/class.dragdrop.inc.php +++ b/phpgwapi/inc/class.dragdrop.inc.php @@ -1,13 +1,13 @@ * @copyright (c) 2006 by Christian Binder * @package phpgwapi * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License - * @version $Id$ + * @version $Id$ */ require_once(EGW_INCLUDE_ROOT. '/phpgwapi/inc/class.browser.inc.php'); @@ -24,46 +24,46 @@ class dragdrop { /** * draggable Objects - * + * * @var array */ var $draggables; /** * droppable Objects - * + * * @var array */ var $droppables; /** * custom DHTML Objects - * + * * @var array */ var $customs; - + /** * ensures that function setJSCode is only run once - * + * * @var boolean */ var $setCodeDone = false; /** * JavaScript(s) to include which contains the actions while dragging or dropping - * + * * @var array */ var $actionScripts; /** * enables class for all browsers - use this for testing still not validated browsers - * + * * @var boolean */ var $browserTestMode = false; - + function dragdrop() { } @@ -121,7 +121,7 @@ class dragdrop /** * generates the appropriate JSCode for all defined objects * - * @return boolean true if all actions succeed or false if the function was called more than once + * @return boolean true if all actions succeed or false if the function was called more than once */ function setJSCode() { @@ -139,7 +139,7 @@ class dragdrop error_log('phpgwapi.dragdrop::setJSCode called more than once - aborting'); return false; } - + $GLOBALS['egw_info']['flags']['need_footer'] .= "\n"; // include wz_dragdrop once @@ -148,7 +148,7 @@ class dragdrop $GLOBALS['egw_info']['flags']['need_footer'] .= ''."\n"; $GLOBALS['egw_info']['flags']['wz_dragdrop_included'] = true; } - + // include actionScripts if(is_array($this->actionScripts)) { @@ -157,7 +157,7 @@ class dragdrop $GLOBALS['egw_info']['flags']['need_footer'] .= ''."\n"; } } - + // register all elements to wz_dragdrop if(is_array($this->draggables)) { @@ -187,7 +187,7 @@ class dragdrop $GLOBALS['egw_info']['flags']['need_footer'] .= $this->DHTMLcommand().'('.$element_names.')'."\n"; $GLOBALS['egw_info']['flags']['need_footer'] .= ''."\n"; } - + // set special params for draggable elements if(is_array($this->draggables)) { @@ -255,10 +255,10 @@ class dragdrop } $GLOBALS['egw_info']['flags']['need_footer'] .= "\n"; - return $this->setCodeDone = true; + return $this->setCodeDone = true; } - + /** * checks if the given name of an object is unique in all draggable,droppable and custom objects * @@ -318,7 +318,7 @@ class dragdrop { error_log('dragdrop::validateBrowser, agent: ' . $clientBrowser->get_agent()); } - + foreach(array('MOZILLA') as $id=>$validatedBrowser) { if($this->browserTestMode || $clientBrowser->get_agent() == $validatedBrowser) @@ -326,10 +326,10 @@ class dragdrop egw_framework::validate_file('wz_dragdrop', 'wz_dragdrop'); return true; } - + return false; } - + } /** @@ -345,7 +345,7 @@ class dragdrop $script = $appname.'.'.$scriptname; $serverFile = EGW_INCLUDE_ROOT.'/'.$appname.'/js/'.$scriptname.'.js'; $browserFile = $GLOBALS['egw_info']['server']['webserver_url'].'/'.$appname.'/js/'.$scriptname.'.js'; - + // check if file exists otherwise exit if(!file_exists($serverFile)) { @@ -359,7 +359,7 @@ class dragdrop if($actionScript['script'] == $script) { return $functionname; } } } - + $this->actionScripts[] = array('script' => $script,'file' => $browserFile); return $functionname; } diff --git a/phpgwapi/inc/class.egw_db.inc.php b/phpgwapi/inc/class.egw_db.inc.php index 234b463d5b..285c1a1c6a 100644 --- a/phpgwapi/inc/class.egw_db.inc.php +++ b/phpgwapi/inc/class.egw_db.inc.php @@ -274,7 +274,6 @@ class egw_db $this->$var = $db_data[$key]; } } -//if ($GLOBALS['egw_info']['server']['default_domain'] == 'ralfsmacbook.local') $this->query_log = '/tmp/query.log'; } /** @@ -847,7 +846,7 @@ class egw_db if ($id === False) // function not supported { echo "

db::get_last_insert_id(table='$table',field='$field') not yet implemented for db-type '$this->Type' OR no insert operation before

\n"; - echo '

'.function_backtrace()."

\n"; + function_backtrace(); return -1; } return $id; diff --git a/phpgwapi/inc/class.egw_json.inc.php b/phpgwapi/inc/class.egw_json.inc.php index 6912dc774d..0a6ba7bf76 100644 --- a/phpgwapi/inc/class.egw_json.inc.php +++ b/phpgwapi/inc/class.egw_json.inc.php @@ -122,7 +122,7 @@ class egw_json_request $ajaxClass = CreateObject($appName.'.'.$className); } - // for Ajax: no need to load the "standard" javascript files, + // for Ajax: no need to load the "standard" javascript files, // they are already loaded, in fact jquery has a problem if loaded twice egw_framework::js_files(array()); @@ -185,11 +185,6 @@ class egw_json_response private function sendHeader() { //Send the character encoding header - if (headers_sent($file,$line)) - { - //error_log(__METHOD__."() header already send in $file on line $line!"); - } - else header('content-type: application/json; charset='.translation::charset()); } diff --git a/phpgwapi/inc/class.groupdav_handler.inc.php b/phpgwapi/inc/class.groupdav_handler.inc.php index 93e066eba9..5342f1f39f 100644 --- a/phpgwapi/inc/class.groupdav_handler.inc.php +++ b/phpgwapi/inc/class.groupdav_handler.inc.php @@ -23,7 +23,7 @@ abstract class groupdav_handler * * @var integer */ - var $debug = 1; + var $debug = 0; /** * eGW's charset diff --git a/phpgwapi/inc/class.pdf.inc.php b/phpgwapi/inc/class.pdf.inc.php index 9a62fe5237..f997824bcb 100644 --- a/phpgwapi/inc/class.pdf.inc.php +++ b/phpgwapi/inc/class.pdf.inc.php @@ -54,11 +54,8 @@ function pdf() { parent::FPDF(); - $this->AliasNbPages(); $this->SetCreator('eGroupWare '.$GLOBALS['egw_info']['server']['versions']['phpgwapi']); - $this->SetAuthor($GLOBALS['phpgw']->common->display_fullname()); - - $this->egw_charset = $GLOBALS['phpgw']->translation->charset(); + $this->SetAuthor($GLOBALS['egw']->common->display_fullname()); } //Page footer @@ -71,48 +68,5 @@ //Page number $this->Cell(0,10,lang('Page').' '.$this->PageNo().'/{nb}',0,0,'C'); } - - /** - * Reimplement FPDF::Cell to do charset conversation - * - * stock FPDF only understands iso-8859-1, so we convert everything to that for now - */ - function Cell($w,$h=0,$txt='',$border=0,$ln=0,$align='',$fill=0,$link='') - { - $txt = $GLOBALS['phpgw']->translation->convert($txt,$this->egw_charset,'iso-8859-1'); - - return FPDF::Cell($w,$h,$txt,$border,$ln,$align,$fill,$link); - } - - /** - * Reimplement FPDF::Text to do charset conversation - * - * stock FPDF only understands iso-8859-1, so we convert everything to that for now - */ - function Text($x,$y,$txt) - { - $txt = $GLOBALS['phpgw']->translation->convert($txt,$this->egw_charset,'iso-8859-1'); - - return FPDF::Text($x,$y,$txt); - } - - /** - * Sets dashed line mode, to reset to continues call withour params - * - * @param float $black drawn part (in user-units) - * @param float $white empty part - */ - function SetDash($black=false, $white=false) - { - if($black && $white) - { - $s=sprintf('[%.3f %.3f] 0 d', $black*$this->k, $white*$this->k); - } - else - { - $s='[] 0 d'; - } - $this->_out($s); - } } ?> diff --git a/phpgwapi/inc/class.phpmailer.inc.php b/phpgwapi/inc/class.phpmailer.inc.php index dd83ec992b..cf6558377f 100644 --- a/phpgwapi/inc/class.phpmailer.inc.php +++ b/phpgwapi/inc/class.phpmailer.inc.php @@ -1280,7 +1280,7 @@ class PHPMailer { $body .= $this->EncodeString($this->Body, $this->Encoding); $body .= $this->LE.$this->LE; // Create the extended body for an attached text/calendar - $body .= $this->GetBoundary($this->boundary[2], '', $this->attachment[0][4], '') . $this->LE; + $body .= $this->GetBoundary($this->boundary[2], '', $this->attachment[0][4], '') . $this->LE; $body .= $this->EncodeString($this->attachment[0][0], $this->attachment[0][3]); $body .= $this->LE.$this->LE; $body .= $this->EndBoundary($this->boundary[2]); @@ -1537,16 +1537,16 @@ class PHPMailer { * @access private * @return string */ - private function &EncodeFile($path, $encoding = 'base64') + private function &EncodeFile($path, $encoding = 'base64') { - if (function_exists('get_magic_quotes')) + if (function_exists('get_magic_quotes')) { - function get_magic_quotes() + function get_magic_quotes() { return false; } } - if (PHP_VERSION < 6) + if (PHP_VERSION < 6) { if (function_exists('get_magic_quotes_runtime') && ($magic_quotes = get_magic_quotes_runtime())) set_magic_quotes_runtime(0); } @@ -1556,13 +1556,13 @@ class PHPMailer { throw new phpmailerException($this->Lang('file_open') . $path, self::STOP_CONTINUE); } $file_buffer = $this->EncodeString($file_buffer, $encoding); - if (PHP_VERSION < 6) + if (PHP_VERSION < 6) { if ($magic_quotes) set_magic_quotes_runtime($magic_quotes); - } + } return $file_buffer; } catch (Exception $e) { - if (PHP_VERSION < 6) + if (PHP_VERSION < 6) { if ($magic_quotes) set_magic_quotes_runtime($magic_quotes); }