Skip to content

Commit 2b77959

Browse files
committed
fixed bug in creation if search.inc.php
1 parent 4f7cff3 commit 2b77959

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

class/Files/Includes/IncludeSearch.php

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,13 @@ public function getSearchFunction($moduleDirname)
120120
$fieldMain = '';
121121
$fieldDate = '';
122122
$countField = 0;
123+
$fieldUser = '';
123124
foreach (\array_keys($fields) as $f) {
124-
$fieldName = $fields[$f]->getVar('field_name');
125+
$fieldName = $fields[$f]->getVar('field_name');
126+
$fieldElement = $fields[$f]->getVar('field_element');
127+
if (Modulebuilder\Constants::FIELD_ELE_SELECTUSER == $fieldElement) {
128+
$fieldUser = $fieldName;
129+
}
125130
if (0 == $f) {
126131
$fieldId = $fieldName;
127132
}
@@ -143,22 +148,26 @@ public function getSearchFunction($moduleDirname)
143148
$for .= $this->pc->getPhpCodeUnset('crKeyword', $t . "\t\t");
144149
$contIf .= $this->pc->getPhpCodeFor('i', $for, 'elementCount', '0', ' < ', $t . "\t");
145150
$func .= $this->pc->getPhpCodeConditions('$elementCount', ' > ', '0', $contIf, false, $t);
146-
$func .= $this->pc->getPhpCodeCommentLine('search user(s)', '', $t);
147-
$contIf = $this->xc->getXcEqualsOperator('$userid', "array_map('\intval', \$userid)", '', $t . "\t");
148-
$contIf .= $this->xc->getXcCriteriaCompo('crUser', $t . "\t");
149-
$crit = $this->xc->getXcCriteria('', "'{$tableFieldname}_submitter'", "'(' . \implode(',', \$userid) . ')'", "'IN'", true, $t . "\t");
150-
$contIf .= $this->xc->getXcCriteriaAdd('crUser', $crit, $t . "\t", "\n", "'OR'");
151-
$contElse = $this->xc->getXcCriteriaCompo('crUser', $t . "\t");
152-
$crit = $this->xc->getXcCriteria('', "'{$tableFieldname}_submitter'", '$userid', '', true, $t . "\t");
153-
$contElse .= $this->xc->getXcCriteriaAdd('crUser', $crit, $t . "\t", "\n", "'OR'");
154-
$func .= $this->pc->getPhpCodeConditions('$userid && \is_array($userid)', '', '', $contIf, $contElse, $t, 'is_numeric($userid) && $userid > 0');
151+
if ('' !== $fieldUser) {
152+
$func .= $this->pc->getPhpCodeCommentLine('search user(s)', '', $t);
153+
$contIf = $this->xc->getXcEqualsOperator('$userid', "array_map('\intval', \$userid)", '', $t . "\t");
154+
$contIf .= $this->xc->getXcCriteriaCompo('crUser', $t . "\t");
155+
$crit = $this->xc->getXcCriteria('', "'{$fieldUser}'", "'(' . \implode(',', \$userid) . ')'", "'IN'", true, $t . "\t");
156+
$contIf .= $this->xc->getXcCriteriaAdd('crUser', $crit, $t . "\t", "\n", "'OR'");
157+
$contElse = $this->xc->getXcCriteriaCompo('crUser', $t . "\t");
158+
$crit = $this->xc->getXcCriteria('', "'{$fieldUser}'", '$userid', '', true, $t . "\t");
159+
$contElse .= $this->xc->getXcCriteriaAdd('crUser', $crit, $t . "\t", "\n", "'OR'");
160+
$func .= $this->pc->getPhpCodeConditions('$userid && \is_array($userid)', '', '', $contIf, $contElse, $t, 'is_numeric($userid) && $userid > 0');
161+
}
155162
$func .= $this->xc->getXcCriteriaCompo('crSearch', $t);
156163
$contIf = $this->xc->getXcCriteriaAdd('crSearch', '$crKeywords', $t . "\t", "\n", "'AND'");
157164
$cond = $this->pc->getPhpCodeIsset('crKeywords');
158165
$func .= $this->pc->getPhpCodeConditions($cond, '', '', $contIf, false, $t);
159-
$contIf = $this->xc->getXcCriteriaAdd('crSearch', '$crUser', $t . "\t", "\n", "'AND'");
160-
$cond = $this->pc->getPhpCodeIsset('crUser');
161-
$func .= $this->pc->getPhpCodeConditions($cond, '', '', $contIf, false, $t);
166+
if ('' !== $fieldUser) {
167+
$contIf = $this->xc->getXcCriteriaAdd('crSearch', '$crUser', $t . "\t", "\n", "'AND'");
168+
$cond = $this->pc->getPhpCodeIsset('crUser');
169+
$func .= $this->pc->getPhpCodeConditions($cond, '', '', $contIf, false, $t);
170+
}
162171
$func .= $this->xc->getXcCriteriaSetStart('crSearch', '$offset', $t);
163172
$func .= $this->xc->getXcCriteriaSetLimit('crSearch', '$limit', $t);
164173
if ('' !== $fieldDate) {

docs/changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<h5>3.7.0 Alpha [2023-07-06]</h5> Dev: XOOPS 2.5.11 RC2, PHP 8.0
22
- implemented smarty 3 (zivXP/goffy)
3+
- fixed bug in creation if search.inc.php (zivXP/goffy)
34

45
<h5>3.6.0 Stable [2023-02-28]</h5> Dev: XOOPS 2.5.11, PHP 7.4.25, PHP 8.0.12, PHP 8.1.0 Beta 4
56
- moved to last stable with smarty 2 (goffy)

0 commit comments

Comments
 (0)