No-brainer: Add blanks around OR statement in $BE_USER->getPagePermsClause()
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_sqlparser.php
index 6a327aa..fd11c17 100755 (executable)
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 2004-2006 Kasper Skaarhoj (kasperYYYY@typo3.com)
+*  (c) 2004-2008 Kasper Skaarhoj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -712,7 +712,7 @@ class t3lib_sqlparser {
                        } else {        // Outside parenthesis, looking for next field:
 
                                        // Looking for a known function (only known functions supported)
-                               $func = $this->nextPart($parseString,'^(count|max|min|floor|sum|avg|concat|year|from_unixtime|lcase|left|unix_timestamp)[[:space:]]*\(');
+                               $func = $this->nextPart($parseString,'^(count|max|min|floor|sum|avg)[[:space:]]*\(');
                                if ($func)      {
                                        $parseString = trim(substr($parseString,1));    // Strip of "("
                                        $stack[$pnt]['type'] = 'function';
@@ -905,18 +905,9 @@ class t3lib_sqlparser {
                                        // Find "modifyer", eg. "NOT or !"
                                $stack[$level][$pnt[$level]]['modifier'] = trim($this->nextPart($parseString,'^(!|NOT[[:space:]]+)'));
 
-                               if($fieldName = $this->nextFunction($parseString)) {    // SQL functions
-                                       if($parseString{0}=='(') {
-                                               $parseString = ltrim(substr($parseString,1));
-                                               $arg = $this->getValue($parseString);
-                                               $fieldName .= '('.$arg[0].')';
-                                               $parseString = ltrim(substr($parseString,1));
-                                       }
-                                       $stack[$level][$pnt[$level]]['table'] = '';
-                                       $stack[$level][$pnt[$level]]['field'] = $fieldName;
-                               }
-                                               // Fieldname:
-                               elseif ($fieldName = $this->nextPart($parseString,'^([[:alnum:]._]+)([[:space:]]+|&|<=|>=|<|>|=|!=|IS)'))       {
+                                       // Fieldname:
+                               if ($fieldName = $this->nextPart($parseString,'^([[:alnum:]._]+)([[:space:]]+|&|<=|>=|<|>|=|!=|IS)'))   {
+
                                                // Parse field name into field and table:
                                        $tableField = explode('.',$fieldName,2);
                                        if (count($tableField)==2)      {
@@ -938,7 +929,7 @@ class t3lib_sqlparser {
                                }
 
                                        // Find "comparator":
-                               $stack[$level][$pnt[$level]]['comparator'] = $this->nextPart($parseString,'^(<=|>=|<|>|=|!=|NOT[[:space:]]+IN|IN|NOT[[:space:]]+LIKE|LIKE|IS NOT|IS)');
+                               $stack[$level][$pnt[$level]]['comparator'] = $this->nextPart($parseString,'^(<=|>=|<|>|=|!=|NOT[[:space:]]+IN|IN|NOT[[:space:]]+LIKE|LIKE|IS[[:space:]]+NOT|IS)');
                                if (strlen($stack[$level][$pnt[$level]]['comparator'])) {
                                                // Finding value for comparator:
                                        $stack[$level][$pnt[$level]]['value'] = $this->getValue($parseString,$stack[$level][$pnt[$level]]['comparator']);
@@ -1074,7 +1065,7 @@ class t3lib_sqlparser {
         * @param       string          The comparator used before. If "NOT IN" or "IN" then the value is expected to be a list of values. Otherwise just an integer (un-quoted) or string (quoted)
         * @return      mixed           The value (string/integer). Otherwise an array with error message in first key (0)
         */
-       function getValue(&$parseString,$comparator='',$extraRegexpChars='')    {
+       function getValue(&$parseString,$comparator='') {
                $value = '';
 
                if (t3lib_div::inList('NOTIN,IN,_LIST',strtoupper(str_replace(array(' ',"\n","\r","\t"),'',$comparator))))      {       // List of values:
@@ -1101,19 +1092,6 @@ class t3lib_sqlparser {
                                } else return array($this->parseError('No ) parenthesis in list',$parseString));
                        } else return array($this->parseError('No ( parenthesis starting the list',$parseString));
 
-               } elseif($function = $this->nextFunction($parseString)) {       // SQL functions
-                       if($parseString{0}=='(') {
-                               $parseString = ltrim(substr($parseString,1));
-                               $arg = $this->getValue($parseString,'',','); // extraRegexpChars for stuff like LEFT(tx_dam.title,1)
-                               if(count($arg)==2)
-                                       $function .= '('.$arg[1].$arg[0].$arg[1].')';
-                               else
-                                       $function .= '('.$arg[0].')';
-                               $parseString = ltrim(substr($parseString,1));
-                       } elseif($function=='BETWEEN') {
-
-                       }
-                       return array($function);
                } else {        // Just plain string value, in quotes or not:
 
                                // Quote?
@@ -1127,7 +1105,7 @@ class t3lib_sqlparser {
                                break;
                                default:
                                        $reg = array();
-                                       if (preg_match('/^([[:alnum:]'.$extraRegexpChars.'._-]+)/i',$parseString, $reg))        {
+                                       if (preg_match('/^([[:alnum:]._-]+)/i',$parseString, $reg))     {
                                                $parseString = ltrim(substr($parseString,strlen($reg[0])));
                                                $value = array($reg[1]);
                                        }
@@ -1137,10 +1115,6 @@ class t3lib_sqlparser {
                return $value;
        }
 
-       function nextFunction(&$parseString) {
-               return $this->nextPart($parseString,'^(count|max|min|floor|sum|avg|concat|year|from_unixtime|lcase|left|unix_timestamp)([[:space:]]*\()');
-       }
-
        /**
         * Get value in quotes from $parseString.
         * NOTICE: If a query being parsed was prepared for another database than MySQL this function should probably be changed
@@ -1766,4 +1740,5 @@ return $str;
 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_sqlparser.php'])        {
        include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_sqlparser.php']);
 }
-?>
+
+?>
\ No newline at end of file