Commit cc215651 authored by tbrehm's avatar tbrehm
Browse files

Fixed: FS#843 - replacePrefix just returns last result (tools.inc.php)

parent 0e11b4b7
...@@ -27,27 +27,27 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ...@@ -27,27 +27,27 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
function replacePrefix($name, $dataRecord){ function replacePrefix($name, $dataRecord) {
$keywordlist=array('CLIENTNAME','CLIENTID'); // No input -> no possible output -> go out!
if ($name=="") return "";
if ($name != '') { // Array containing keys to search
foreach ($keywordlist as $keyword) { $keywordlist=array('CLIENTNAME','CLIENTID');
if (substr_count($name, '['.$keyword.']') > 0) {
switch ($keyword) { // Try to match the key within the string
case 'CLIENTNAME': foreach ($keywordlist as $keyword) {
$res=str_replace('['.$keyword.']', getClientName($dataRecord), $name); if (substr_count($name, '['.$keyword.']') > 0) {
break; switch ($keyword) {
case 'CLIENTID': case 'CLIENTNAME':
$res=str_replace('['.$keyword.']', getClientID($dataRecord), $name); $name=str_replace('['.$keyword.']', getClientName($dataRecord),$name);
break; break;
} case 'CLIENTID':
} $name=str_replace('['.$keyword.']', getClientID($dataRecord),$name);
} break;
} else { }
$res=''; }
} }
return $name;
return $res;
} }
function getClientName($dataRecord) { function getClientName($dataRecord) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment