@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * \brief PHPUnit test for the BlockedLog and LNE class. |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | -global $conf,$user,$langs,$db; |
|
| 27 | +global $conf, $user, $langs, $db; |
|
| 28 | 28 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
| 29 | 29 | //require_once 'PHPUnit/Autoload.php'; |
| 30 | 30 | require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | */ |
| 59 | 59 | public function testBlockedLogAndLNETest() |
| 60 | 60 | { |
| 61 | - global $conf,$user,$langs,$db; |
|
| 61 | + global $conf, $user, $langs, $db; |
|
| 62 | 62 | $conf = $this->savconf; |
| 63 | 63 | $user = $this->savuser; |
| 64 | 64 | $langs = $this->savlangs; |
@@ -25,33 +25,33 @@ discard block |
||
| 25 | 25 | * \remarks To run this script as CLI: phpunit filename.php |
| 26 | 26 | */ |
| 27 | 27 | |
| 28 | -global $conf,$user,$langs,$db; |
|
| 28 | +global $conf, $user, $langs, $db; |
|
| 29 | 29 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
| 30 | 30 | //require_once 'PHPUnit/Autoload.php'; |
| 31 | 31 | |
| 32 | -if (! defined('NOCSRFCHECK')) { |
|
| 32 | +if (!defined('NOCSRFCHECK')) { |
|
| 33 | 33 | define('NOCSRFCHECK', '1'); |
| 34 | 34 | } |
| 35 | -if (! defined('NOTOKENRENEWAL')) { |
|
| 35 | +if (!defined('NOTOKENRENEWAL')) { |
|
| 36 | 36 | define('NOTOKENRENEWAL', '1'); |
| 37 | 37 | } |
| 38 | -if (! defined('NOREQUIREMENU')) { |
|
| 38 | +if (!defined('NOREQUIREMENU')) { |
|
| 39 | 39 | define('NOREQUIREMENU', '1'); // If there is no menu to show |
| 40 | 40 | } |
| 41 | -if (! defined('NOREQUIREHTML')) { |
|
| 41 | +if (!defined('NOREQUIREHTML')) { |
|
| 42 | 42 | define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php |
| 43 | 43 | } |
| 44 | -if (! defined('NOREQUIREAJAX')) { |
|
| 44 | +if (!defined('NOREQUIREAJAX')) { |
|
| 45 | 45 | define('NOREQUIREAJAX', '1'); |
| 46 | 46 | } |
| 47 | -if (! defined("NOLOGIN")) { |
|
| 48 | - define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) |
|
| 47 | +if (!defined("NOLOGIN")) { |
|
| 48 | + define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) |
|
| 49 | 49 | } |
| 50 | -if (! defined("NOSESSION")) { |
|
| 50 | +if (!defined("NOSESSION")) { |
|
| 51 | 51 | define("NOSESSION", '1'); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | -require_once dirname(__FILE__).'/../../htdocs/main.inc.php'; // We force include of main.inc.php instead of master.inc.php even if we are in CLI mode because it contains a lot of security components we want to test. |
|
| 54 | +require_once dirname(__FILE__).'/../../htdocs/main.inc.php'; // We force include of main.inc.php instead of master.inc.php even if we are in CLI mode because it contains a lot of security components we want to test. |
|
| 55 | 55 | require_once dirname(__FILE__).'/../../htdocs/core/lib/security.lib.php'; |
| 56 | 56 | require_once dirname(__FILE__).'/../../htdocs/core/lib/security2.lib.php'; |
| 57 | 57 | require_once dirname(__FILE__).'/CommonClassTest.class.php'; |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | public function testGETPOST() |
| 82 | 82 | { |
| 83 | - global $conf,$user,$langs,$db,$mysoc; |
|
| 83 | + global $conf, $user, $langs, $db, $mysoc; |
|
| 84 | 84 | $conf = $this->savconf; |
| 85 | 85 | $user = $this->savuser; |
| 86 | 86 | $langs = $this->savlangs; |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | $_GET["param1"] = "222"; |
| 98 | 98 | $_POST["param1"] = "333"; |
| 99 | 99 | $_GET["param2"] = 'a/b#e(pr)qq-rr\cc'; |
| 100 | - $_GET["param3"] = '"na/b#e(pr)qq-rr\cc'; // Same than param2 + " and n |
|
| 100 | + $_GET["param3"] = '"na/b#e(pr)qq-rr\cc'; // Same than param2 + " and n |
|
| 101 | 101 | $_GET["param4a"] = '../../dir'; |
| 102 | 102 | $_GET["param4b"] = '..\..\dirwindows'; |
| 103 | 103 | $_GET["param4c"] = '\a123 \123 \u123 \x123'; |
@@ -105,11 +105,11 @@ discard block |
||
| 105 | 105 | $_POST["param6"] = ""><svg onload='console.log("123")'>"; |
| 106 | 106 | $_POST["param6b"] = '<<<../>../>../svg><<<../>../>../animate =alert(1)>abc'; |
| 107 | 107 | $_GET["param7"] = '"c:\this is a path~1\aaan &#x110;" abc<bad>def</bad>'; |
| 108 | - $_POST["param8a"] = "Hacker<svg onload='console.log("123")'"; // html tag is not closed so it is not detected as html tag but is still harmfull |
|
| 109 | - $_POST['param8b'] = '<img src=x onerror=alert(document.location) t='; // this is html obfuscated by non closing tag |
|
| 108 | + $_POST["param8a"] = "Hacker<svg onload='console.log("123")'"; // html tag is not closed so it is not detected as html tag but is still harmfull |
|
| 109 | + $_POST['param8b'] = '<img src=x onerror=alert(document.location) t='; // this is html obfuscated by non closing tag |
|
| 110 | 110 | $_POST['param8c'] = '< with space after is ok'; |
| 111 | 111 | $_POST['param8d'] = '<abc123 is html to clean'; |
| 112 | - $_POST['param8e'] = '<123abc is not html to clean'; // other similar case: '<2021-12-12' |
|
| 112 | + $_POST['param8e'] = '<123abc is not html to clean'; // other similar case: '<2021-12-12' |
|
| 113 | 113 | $_POST['param8f'] = 'abc<<svg <><<animate onbegin=alert(document.domain) a'; |
| 114 | 114 | $_POST["param9"] = 'is_object($object) ? ($object->id < 10 ? round($object->id / 2, 2) : (2 * $user->id) * (int) substr($mysoc->zip, 1, 2)) : \'objnotdefined\''; |
| 115 | 115 | $_POST["param10"] = 'is_object($object) ? ($object->id < 10 ? round($object->id / 2, 2) : (2 * $user->id) * (int) substr($mysoc->zip, 1, 2)) : \'<abc>objnotdefined\''; |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | $_GET["param20"] = '<link rel="dns-prefetch" href="//cdnjs.cloudflare.com" />'; |
| 130 | 130 | |
| 131 | 131 | |
| 132 | - $result = GETPOST('id', 'int'); // Must return nothing |
|
| 132 | + $result = GETPOST('id', 'int'); // Must return nothing |
|
| 133 | 133 | print __METHOD__." result=".$result."\n"; |
| 134 | 134 | $this->assertEquals('', $result); |
| 135 | 135 | |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | |
| 144 | 144 | // Test with alpha |
| 145 | 145 | |
| 146 | - $result = GETPOST("param0", 'alpha'); // a simple format, so " completely removed |
|
| 146 | + $result = GETPOST("param0", 'alpha'); // a simple format, so " completely removed |
|
| 147 | 147 | $resultexpected = 'A real string with aaa and and \' and & inside content'; |
| 148 | 148 | print __METHOD__." result=".$result."\n"; |
| 149 | 149 | $this->assertEquals($resultexpected, $result, 'Test on param0'); |
@@ -152,19 +152,19 @@ discard block |
||
| 152 | 152 | print __METHOD__." result=".$result."\n"; |
| 153 | 153 | $this->assertEquals('a/b#e(pr)qq-rr\cc', $result, 'Test on param2'); |
| 154 | 154 | |
| 155 | - $result = GETPOST("param3", 'alpha'); // Must return string sanitized from char " |
|
| 155 | + $result = GETPOST("param3", 'alpha'); // Must return string sanitized from char " |
|
| 156 | 156 | print __METHOD__." result=".$result."\n"; |
| 157 | 157 | $this->assertEquals('na/b#e(pr)qq-rr\cc', $result, 'Test on param3'); |
| 158 | 158 | |
| 159 | - $result = GETPOST("param4a", 'alpha'); // Must return string sanitized from ../ |
|
| 159 | + $result = GETPOST("param4a", 'alpha'); // Must return string sanitized from ../ |
|
| 160 | 160 | print __METHOD__." result=".$result."\n"; |
| 161 | 161 | $this->assertEquals('dir', $result); |
| 162 | 162 | |
| 163 | - $result = GETPOST("param4b", 'alpha'); // Must return string sanitized from ../ |
|
| 163 | + $result = GETPOST("param4b", 'alpha'); // Must return string sanitized from ../ |
|
| 164 | 164 | print __METHOD__." result=".$result."\n"; |
| 165 | 165 | $this->assertEquals('dirwindows', $result); |
| 166 | 166 | |
| 167 | - $result = GETPOST("param4c", 'alpha'); // Must return string sanitized from ../ |
|
| 167 | + $result = GETPOST("param4c", 'alpha'); // Must return string sanitized from ../ |
|
| 168 | 168 | print __METHOD__." result=".$result."\n"; |
| 169 | 169 | $this->assertEquals('\a123 /123 /u123 /x123', $result); |
| 170 | 170 | |
@@ -174,19 +174,19 @@ discard block |
||
| 174 | 174 | print __METHOD__." result=".$result."\n"; |
| 175 | 175 | $this->assertEquals($result, $_GET["param1"]); |
| 176 | 176 | |
| 177 | - $result = GETPOST("param2", 'aZ09'); // Must return '' as string contains car not in aZ09 definition |
|
| 177 | + $result = GETPOST("param2", 'aZ09'); // Must return '' as string contains car not in aZ09 definition |
|
| 178 | 178 | print __METHOD__." result=".$result."\n"; |
| 179 | 179 | $this->assertEquals($result, ''); |
| 180 | 180 | |
| 181 | - $result = GETPOST("param3", 'aZ09'); // Must return '' as string contains car not in aZ09 definition |
|
| 181 | + $result = GETPOST("param3", 'aZ09'); // Must return '' as string contains car not in aZ09 definition |
|
| 182 | 182 | print __METHOD__." result=".$result."\n"; |
| 183 | 183 | $this->assertEquals($result, ''); |
| 184 | 184 | |
| 185 | - $result = GETPOST("param4a", 'aZ09'); // Must return '' as string contains car not in aZ09 definition |
|
| 185 | + $result = GETPOST("param4a", 'aZ09'); // Must return '' as string contains car not in aZ09 definition |
|
| 186 | 186 | print __METHOD__." result=".$result."\n"; |
| 187 | 187 | $this->assertEquals('', $result); |
| 188 | 188 | |
| 189 | - $result = GETPOST("param4b", 'aZ09'); // Must return '' as string contains car not in aZ09 definition |
|
| 189 | + $result = GETPOST("param4b", 'aZ09'); // Must return '' as string contains car not in aZ09 definition |
|
| 190 | 190 | print __METHOD__." result=".$result."\n"; |
| 191 | 191 | $this->assertEquals('', $result); |
| 192 | 192 | |
@@ -297,13 +297,13 @@ discard block |
||
| 297 | 297 | print __METHOD__." result=".$result."\n"; |
| 298 | 298 | $this->assertEquals("Text with ' encoded with the numeric html entity converted into text entity ' (like when submitted by CKEditor)", $result, 'Test 14'); |
| 299 | 299 | |
| 300 | - $result = GETPOST("param15", 'restricthtml'); // param15 = <img onxxxx<=alert(document.domain)> src=>0xbeefed that is a dangerous string |
|
| 300 | + $result = GETPOST("param15", 'restricthtml'); // param15 = <img onxxxx<=alert(document.domain)> src=>0xbeefed that is a dangerous string |
|
| 301 | 301 | print __METHOD__." result=".$result."\n"; |
| 302 | - $this->assertEquals("<img onxxxx=alert(document.domain) src=>0xbeefed", $result, 'Test 15'); // The GETPOST return a harmull string |
|
| 302 | + $this->assertEquals("<img onxxxx=alert(document.domain) src=>0xbeefed", $result, 'Test 15'); // The GETPOST return a harmull string |
|
| 303 | 303 | |
| 304 | - $result = GETPOST("param15b", 'restricthtml'); // param15b = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string |
|
| 304 | + $result = GETPOST("param15b", 'restricthtml'); // param15b = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string |
|
| 305 | 305 | print __METHOD__." result=".$result."\n"; |
| 306 | - $this->assertEquals("<img alert(document.domain) src=>0xbeefed", $result, 'Test 15b'); // The GETPOST return a harmull string |
|
| 306 | + $this->assertEquals("<img alert(document.domain) src=>0xbeefed", $result, 'Test 15b'); // The GETPOST return a harmull string |
|
| 307 | 307 | |
| 308 | 308 | $result = GETPOST("param19", 'restricthtml'); |
| 309 | 309 | print __METHOD__." result=".$result."\n"; |
@@ -322,17 +322,17 @@ discard block |
||
| 322 | 322 | print __METHOD__." result for param0=".$result."\n"; |
| 323 | 323 | $this->assertEquals($resultexpected, $result, 'Test on param0'); |
| 324 | 324 | |
| 325 | - $result = GETPOST("param15b", 'restricthtml'); // param15b = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string |
|
| 325 | + $result = GETPOST("param15b", 'restricthtml'); // param15b = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string |
|
| 326 | 326 | print __METHOD__." result for param15b=".$result."\n"; |
| 327 | 327 | //$this->assertEquals('InvalidHTMLStringCantBeCleaned', $result, 'Test 15b'); // With some PHP and libxml version, we got this result when parsing invalid HTML, but ... |
| 328 | 328 | //$this->assertEquals('<img onerror> src=>0xbeefed', $result, 'Test 15b'); // ... on other PHP and libxml versions, we got a HTML that has been cleaned |
| 329 | 329 | |
| 330 | - $result = GETPOST("param6", 'restricthtml'); // param6 = ""><svg onload='console.log("123")'>" |
|
| 330 | + $result = GETPOST("param6", 'restricthtml'); // param6 = ""><svg onload='console.log("123")'>" |
|
| 331 | 331 | print __METHOD__." result for param6=".$result." - before=".$_POST["param6"]."\n"; |
| 332 | 332 | //$this->assertEquals('InvalidHTMLStringCantBeCleaned', $result, 'Test 15b'); // With some PHP and libxml version, we got this result when parsing invalid HTML, but ... |
| 333 | 333 | //$this->assertEquals('">', $result); // ... on other PHP and libxml versions, we got a HTML that has been cleaned |
| 334 | 334 | |
| 335 | - $result = GETPOST("param7", 'restricthtml'); // param7 = "c:\this is a path~1\aaan &#x110;" abc<bad>def</bad> |
|
| 335 | + $result = GETPOST("param7", 'restricthtml'); // param7 = "c:\this is a path~1\aaan &#x110;" abc<bad>def</bad> |
|
| 336 | 336 | print __METHOD__." result param7 = ".$result."\n"; |
| 337 | 337 | //$this->assertEquals('InvalidHTMLStringCantBeCleaned', $result, 'Test 15b'); // With some PHP and libxml version, we got this result when parsing invalid HTML, but ... |
| 338 | 338 | //$this->assertEquals('"c:\this is a path~1\aaan 110;" abcdef', $result); // ... on other PHP and libxml versions, we got a HTML that has been cleaned |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | print __METHOD__." result for param0=".$result."\n"; |
| 355 | 355 | $this->assertEquals($resultexpected, $result, 'Test on param0'); |
| 356 | 356 | |
| 357 | - $result = GETPOST("param15b", 'restricthtml'); // param15b = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string |
|
| 357 | + $result = GETPOST("param15b", 'restricthtml'); // param15b = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string |
|
| 358 | 358 | print __METHOD__." result for param15b=".$result."\n"; |
| 359 | 359 | //$this->assertEquals('InvalidHTMLStringCantBeCleaned', $result, 'Test 15b'); // With some PHP and libxml version, we got this result when parsing invalid HTML, but ... |
| 360 | 360 | //$this->assertEquals('<img onerror> src=>0xbeefed', $result, 'Test 15b'); // ... on other PHP and libxml versions, we got a HTML that has been cleaned |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | print __METHOD__." result for param0=".$result."\n"; |
| 383 | 383 | $this->assertEquals($resultexpected, $result, 'Test on param0'); |
| 384 | 384 | |
| 385 | - $result = GETPOST("param15b", 'restricthtml'); // param15b = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string |
|
| 385 | + $result = GETPOST("param15b", 'restricthtml'); // param15b = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string |
|
| 386 | 386 | print __METHOD__." result=".$result."\n"; |
| 387 | 387 | //$this->assertEquals('InvalidHTMLStringCantBeCleaned', $result, 'Test 15b'); // With some PHP and libxml version, we got this result when parsing invalid HTML, but ... |
| 388 | 388 | //$this->assertEquals('<img onerror> src=>0xbeefed', $result, 'Test 15b'); // ... on other PHP and libxml versions, we got a HTML that has been cleaned |
@@ -1203,7 +1203,7 @@ discard block |
||
| 1203 | 1203 | } |
| 1204 | 1204 | print '<td colspan="'.($colspan - 1).'" class="" style="padding-left: 20px; padding-right: 20px;">'; |
| 1205 | 1205 | |
| 1206 | - $fieldsforcontent = array('topic', 'email_from','joinfiles', 'content'); |
|
| 1206 | + $fieldsforcontent = array('topic', 'email_from', 'joinfiles', 'content'); |
|
| 1207 | 1207 | if (getDolGlobalString('MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES')) { |
| 1208 | 1208 | $fieldsforcontent[] = 'content_lines'; |
| 1209 | 1209 | } |
@@ -1293,7 +1293,7 @@ discard block |
||
| 1293 | 1293 | continue; // It means this is a type of template not into elementList (may be because enabled condition of this type is false because module is not enabled) |
| 1294 | 1294 | } |
| 1295 | 1295 | // Test on 'enabled' |
| 1296 | - if (! (int) dol_eval((string) $obj->enabled, 1, 1, '1')) { |
|
| 1296 | + if (!(int) dol_eval((string) $obj->enabled, 1, 1, '1')) { |
|
| 1297 | 1297 | $i++; |
| 1298 | 1298 | continue; // Email template not qualified |
| 1299 | 1299 | } |
@@ -1603,7 +1603,7 @@ discard block |
||
| 1603 | 1603 | print $form->selectyesno($value, (isset($obj->$value) ? $obj->$value : ''), 1, false, 0, 1); |
| 1604 | 1604 | } |
| 1605 | 1605 | } else { |
| 1606 | - print '<input type="text" '.$size.'class="flat'.($class ? ' '.$class : '').'" value="'.(isset($obj->$value) ? $obj->$value : '').'" name="'. $value .'"'.($context == 'preview' ? ' disabled' : '').' spellcheck="false">'; |
|
| 1606 | + print '<input type="text" '.$size.'class="flat'.($class ? ' '.$class : '').'" value="'.(isset($obj->$value) ? $obj->$value : '').'" name="'.$value.'"'.($context == 'preview' ? ' disabled' : '').' spellcheck="false">'; |
|
| 1607 | 1607 | } |
| 1608 | 1608 | print '</td>'; |
| 1609 | 1609 | $nboffieldsprinted++; |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | if ((!is_string($objecttype) || empty($objecttype)) && isModEnabled('societe')) { |
| 135 | 135 | $objecttype = 'thirdparty'; |
| 136 | 136 | } |
| 137 | -'@phan-var-force string $objecttype'; // Help phan that suggests $objecttype can be null |
|
| 137 | +'@phan-var-force string $objecttype'; // Help phan that suggests $objecttype can be null |
|
| 138 | 138 | |
| 139 | 139 | require_once DOL_DOCUMENT_ROOT."/core/class/extrafields.class.php"; |
| 140 | 140 | require_once DOL_DOCUMENT_ROOT."/core/class/html.form.class.php"; |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | // Fetch optionals attributes and labels |
| 244 | -$extrafields->fetch_name_optionals_label('all'); // We load all extrafields definitions for all objects |
|
| 244 | +$extrafields->fetch_name_optionals_label('all'); // We load all extrafields definitions for all objects |
|
| 245 | 245 | //$extrafields->fetch_name_optionals_label($object->table_element_line); |
| 246 | 246 | |
| 247 | 247 | if (!empty($object->table_element)) { |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | |
| 259 | 259 | // If string is not an universal filter string, we try to convert it into universal filter syntax string |
| 260 | 260 | $errorstr = ''; |
| 261 | -forgeSQLFromUniversalSearchCriteria($search_component_params_input, $errorstr); // Try conversion UFS->SQL |
|
| 261 | +forgeSQLFromUniversalSearchCriteria($search_component_params_input, $errorstr); // Try conversion UFS->SQL |
|
| 262 | 262 | //var_dump($errorstr); |
| 263 | 263 | if ($errorstr) { |
| 264 | 264 | $value = $search_component_params_input; |
@@ -270,14 +270,14 @@ discard block |
||
| 270 | 270 | $crits = explode(' ', trim($value)); // the string after the name of the field. Explode on each AND |
| 271 | 271 | $res = ''; |
| 272 | 272 | |
| 273 | - $i1 = 0; // count the nb of and criteria added (all fields / criteria) |
|
| 273 | + $i1 = 0; // count the nb of and criteria added (all fields / criteria) |
|
| 274 | 274 | foreach ($crits as $crit) { // Loop on each AND criteria |
| 275 | 275 | $crit = trim($crit); |
| 276 | 276 | |
| 277 | - $i2 = 0; // count the nb of valid criteria added for this first criteria |
|
| 277 | + $i2 = 0; // count the nb of valid criteria added for this first criteria |
|
| 278 | 278 | $newres = ''; |
| 279 | 279 | $tmpcrits = explode('|', $crit); |
| 280 | - $i3 = 0; // count the nb of valid criteria added for this current field |
|
| 280 | + $i3 = 0; // count the nb of valid criteria added for this current field |
|
| 281 | 281 | foreach ($tmpcrits as $tmpcrit) { |
| 282 | 282 | if ($tmpcrit !== '0' && empty($tmpcrit)) { |
| 283 | 283 | continue; |
@@ -295,8 +295,8 @@ discard block |
||
| 295 | 295 | } |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | - $field = preg_replace('/(:[!<>=\s]+:|:in:|:notin:|:like:|:notlike:).*$/', '', $tmpcrit); // the name of the field |
|
| 299 | - $tmpcrit = preg_replace('/^.*(:[!<>=\s]+:|:in:|:notin:|:like:|:notlike:)/', '\1', $tmpcrit); // the condition after the name of the field |
|
| 298 | + $field = preg_replace('/(:[!<>=\s]+:|:in:|:notin:|:like:|:notlike:).*$/', '', $tmpcrit); // the name of the field |
|
| 299 | + $tmpcrit = preg_replace('/^.*(:[!<>=\s]+:|:in:|:notin:|:like:|:notlike:)/', '\1', $tmpcrit); // the condition after the name of the field |
|
| 300 | 300 | //var_dump($field); var_dump($tmpcrit); var_dump($i3); |
| 301 | 301 | |
| 302 | 302 | $newres .= (($i2 > 0 || $i3 > 0) ? ' OR ' : ''); |
@@ -686,7 +686,7 @@ discard block |
||
| 686 | 686 | foreach ($arrayofmesures as $key => $val) { |
| 687 | 687 | $simplearrayofmesures[$key] = $arrayofmesures[$key]['label']; |
| 688 | 688 | } |
| 689 | - print $form->multiselectarray('search_measures', $simplearrayofmesures, $search_measures, 0, 0, 'minwidth300 widthcentpercentminusx', 1, 0, '', '', $langs->transnoentitiesnoconv("Measures")); // Fill the array $arrayofmeasures with possible fields |
|
| 689 | + print $form->multiselectarray('search_measures', $simplearrayofmesures, $search_measures, 0, 0, 'minwidth300 widthcentpercentminusx', 1, 0, '', '', $langs->transnoentitiesnoconv("Measures")); // Fill the array $arrayofmeasures with possible fields |
|
| 690 | 690 | print '</div>'; |
| 691 | 691 | |
| 692 | 692 | // XAxis |
@@ -694,14 +694,14 @@ discard block |
||
| 694 | 694 | print '<div class="divadvancedsearchfield">'; |
| 695 | 695 | print '<div class="inline-block"><span class="fas fa-ruler-combined paddingright pictofixedwidth" title="'.dol_escape_htmltag($langs->trans("XAxis")).'"></span><span class="fas fa-caret-down caretdownaxis" title="'.dol_escape_htmltag($langs->trans("XAxis")).'"></span></div>'; |
| 696 | 696 | //var_dump($arrayofxaxis); |
| 697 | - print $formother->selectXAxisField($object, $search_xaxis, $arrayofxaxis, $langs->trans("XAxis"), 'minwidth300 maxwidth400 widthcentpercentminusx'); // Fill the array $arrayofxaxis with possible fields |
|
| 697 | + print $formother->selectXAxisField($object, $search_xaxis, $arrayofxaxis, $langs->trans("XAxis"), 'minwidth300 maxwidth400 widthcentpercentminusx'); // Fill the array $arrayofxaxis with possible fields |
|
| 698 | 698 | print '</div>'; |
| 699 | 699 | |
| 700 | 700 | // Group by |
| 701 | 701 | $count = 0; |
| 702 | 702 | print '<div class="divadvancedsearchfield">'; |
| 703 | 703 | print '<div class="inline-block opacitymedium"><span class="fas fa-ruler-horizontal paddingright pictofixedwidth" title="'.dol_escape_htmltag($langs->trans("GroupBy")).'"></span></div>'; |
| 704 | - print $formother->selectGroupByField($object, $search_groupby, $arrayofgroupby, 'minwidth250 maxwidth300 widthcentpercentminusx', $langs->trans("GroupBy")); // Fill the array $arrayofgroupby with possible fields |
|
| 704 | + print $formother->selectGroupByField($object, $search_groupby, $arrayofgroupby, 'minwidth250 maxwidth300 widthcentpercentminusx', $langs->trans("GroupBy")); // Fill the array $arrayofgroupby with possible fields |
|
| 705 | 705 | print '</div>'; |
| 706 | 706 | } |
| 707 | 707 | |
@@ -862,7 +862,7 @@ discard block |
||
| 862 | 862 | //var_dump($arrayofgroupby); |
| 863 | 863 | $tmpforloop = dolExplodeIntoArray($arrayofxaxis[$val]['tablefromt'], ','); |
| 864 | 864 | foreach ($tmpforloop as $tmptable => $tmptablealias) { |
| 865 | - if (! in_array($tmptable, $listoftablesalreadyadded)) { // We do not add join for main table and tables already added |
|
| 865 | + if (!in_array($tmptable, $listoftablesalreadyadded)) { // We do not add join for main table and tables already added |
|
| 866 | 866 | $tmpforexplode = explode('__', $tmptablealias); |
| 867 | 867 | $endpart = end($tmpforexplode); |
| 868 | 868 | $parenttableandfield = preg_replace('/__'.$endpart.'$/', '', $tmptablealias).'.'.$endpart; |
@@ -889,7 +889,7 @@ discard block |
||
| 889 | 889 | //var_dump($arrayofgroupby[$val]); var_dump($tmpval); |
| 890 | 890 | $tmpforloop = dolExplodeIntoArray($arrayofgroupby[$val]['tablefromt'], ','); |
| 891 | 891 | foreach ($tmpforloop as $tmptable => $tmptablealias) { |
| 892 | - if (! in_array($tmptable, $listoftablesalreadyadded)) { // We do not add join for main table and tables already added |
|
| 892 | + if (!in_array($tmptable, $listoftablesalreadyadded)) { // We do not add join for main table and tables already added |
|
| 893 | 893 | $tmpforexplode = explode('__', $tmptablealias); |
| 894 | 894 | $endpart = end($tmpforexplode); |
| 895 | 895 | $parenttableandfield = preg_replace('/__'.$endpart.'$/', '', $tmptablealias).'.'.$endpart; |
@@ -916,7 +916,7 @@ discard block |
||
| 916 | 916 | //var_dump($arrayofgroupby); |
| 917 | 917 | $tmpforloop = dolExplodeIntoArray($arrayofmesures[$val]['tablefromt'], ','); |
| 918 | 918 | foreach ($tmpforloop as $tmptable => $tmptablealias) { |
| 919 | - if (! in_array($tmptable, $listoftablesalreadyadded)) { // We do not add join for main table and tables already added |
|
| 919 | + if (!in_array($tmptable, $listoftablesalreadyadded)) { // We do not add join for main table and tables already added |
|
| 920 | 920 | $tmpforexplode = explode('__', $tmptablealias); |
| 921 | 921 | $endpart = end($tmpforexplode); |
| 922 | 922 | $parenttableandfield = preg_replace('/__'.$endpart.'$/', '', $tmptablealias).'.'.$endpart; |
@@ -951,7 +951,7 @@ discard block |
||
| 951 | 951 | $tmpval = explode('.', $val); |
| 952 | 952 | $tmpforloop = dolExplodeIntoArray($arrayoffilterfields[$val]['tablefromt'], ','); |
| 953 | 953 | foreach ($tmpforloop as $tmptable => $tmptablealias) { |
| 954 | - if (! in_array($tmptable, $listoftablesalreadyadded)) { // We do not add join for main table and tables already added |
|
| 954 | + if (!in_array($tmptable, $listoftablesalreadyadded)) { // We do not add join for main table and tables already added |
|
| 955 | 955 | $tmpforexplode = explode('__', $tmptablealias); |
| 956 | 956 | $endpart = end($tmpforexplode); |
| 957 | 957 | $parenttableandfield = preg_replace('/__'.$endpart.'$/', '', $tmptablealias).'.'.$endpart; |
@@ -987,9 +987,9 @@ discard block |
||
| 987 | 987 | * @param array<int, string> $matches |
| 988 | 988 | * @return string SQL filter condition |
| 989 | 989 | */ |
| 990 | - function (array $matches): string { |
|
| 990 | + function(array $matches): string { |
|
| 991 | 991 | global $db; |
| 992 | - $column = $matches[1] . '.' . $matches[2]; |
|
| 992 | + $column = $matches[1].'.'.$matches[2]; |
|
| 993 | 993 | $operator = $matches[3]; |
| 994 | 994 | $year = (int) $matches[4]; |
| 995 | 995 | $month = (int) $matches[5]; |