Skip to content

Commit cc21565

Browse files
committed
Fixed: FS#843 - replacePrefix just returns last result (tools.inc.php)
1 parent 0e11b4b commit cc21565

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

interface/web/sites/tools.inc.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,27 @@
2727
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2828
*/
2929

30-
function replacePrefix($name, $dataRecord){
31-
$keywordlist=array('CLIENTNAME','CLIENTID');
30+
function replacePrefix($name, $dataRecord) {
31+
// No input -> no possible output -> go out!
32+
if ($name=="") return "";
3233

33-
if ($name != '') {
34-
foreach ($keywordlist as $keyword) {
35-
if (substr_count($name, '['.$keyword.']') > 0) {
36-
switch ($keyword) {
37-
case 'CLIENTNAME':
38-
$res=str_replace('['.$keyword.']', getClientName($dataRecord), $name);
39-
break;
40-
case 'CLIENTID':
41-
$res=str_replace('['.$keyword.']', getClientID($dataRecord), $name);
42-
break;
43-
}
44-
}
45-
}
46-
} else {
47-
$res='';
48-
}
49-
50-
return $res;
34+
// Array containing keys to search
35+
$keywordlist=array('CLIENTNAME','CLIENTID');
36+
37+
// Try to match the key within the string
38+
foreach ($keywordlist as $keyword) {
39+
if (substr_count($name, '['.$keyword.']') > 0) {
40+
switch ($keyword) {
41+
case 'CLIENTNAME':
42+
$name=str_replace('['.$keyword.']', getClientName($dataRecord),$name);
43+
break;
44+
case 'CLIENTID':
45+
$name=str_replace('['.$keyword.']', getClientID($dataRecord),$name);
46+
break;
47+
}
48+
}
49+
}
50+
return $name;
5151
}
5252

5353
function getClientName($dataRecord) {

0 commit comments

Comments
 (0)