@@ -120,8 +120,13 @@ public function getSearchFunction($moduleDirname)
120
120
$ fieldMain = '' ;
121
121
$ fieldDate = '' ;
122
122
$ countField = 0 ;
123
+ $ fieldUser = '' ;
123
124
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
+ }
125
130
if (0 == $ f ) {
126
131
$ fieldId = $ fieldName ;
127
132
}
@@ -143,22 +148,26 @@ public function getSearchFunction($moduleDirname)
143
148
$ for .= $ this ->pc ->getPhpCodeUnset ('crKeyword ' , $ t . "\t\t" );
144
149
$ contIf .= $ this ->pc ->getPhpCodeFor ('i ' , $ for , 'elementCount ' , '0 ' , ' < ' , $ t . "\t" );
145
150
$ 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
+ }
155
162
$ func .= $ this ->xc ->getXcCriteriaCompo ('crSearch ' , $ t );
156
163
$ contIf = $ this ->xc ->getXcCriteriaAdd ('crSearch ' , '$crKeywords ' , $ t . "\t" , "\n" , "'AND' " );
157
164
$ cond = $ this ->pc ->getPhpCodeIsset ('crKeywords ' );
158
165
$ 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
+ }
162
171
$ func .= $ this ->xc ->getXcCriteriaSetStart ('crSearch ' , '$offset ' , $ t );
163
172
$ func .= $ this ->xc ->getXcCriteriaSetLimit ('crSearch ' , '$limit ' , $ t );
164
173
if ('' !== $ fieldDate ) {
0 commit comments