Skip to content

Commit

Permalink
Use preg_split instead of explode for creating arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
dasistwas committed May 13, 2024
1 parent 286ef2c commit 98c005c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public function __construct() {
// Allowed user ids sql
if (!empty($user->profile['alloweduserids'])) {
$alloweduserids = $user->profile['alloweduserids'];
$userids = explode('\r\n', $alloweduserids);
$userids = preg_split('/\s+/', $alloweduserids, -1, PREG_SPLIT_NO_EMPTY);
[$inuserids, $inuseridparams] = $DB->get_in_or_equal($userids, SQL_PARAMS_NAMED, 'userids');
if ($user->profile['tenant'] == "Esso" || $user->profile['tenant'] == "REG") {
$where .= " AND m.userid $inuserids";
Expand All @@ -186,7 +186,7 @@ public function __construct() {
profile_load_custom_fields($tmpuser);
$allowedpbls = $tmpuser->profile['allowedpbls'];
$allowedpbls = str_replace(' ', '', $allowedpbls);
$pbls = explode('\r\n', $allowedpbls);
$pbls = preg_split('/\s+/', $alloweduserids, -1, PREG_SPLIT_NO_EMPTY);
$allpbls = array_merge($allpbls, $pbls);
}
if (!empty($user->profile['partnerid'])) { // Shortname for PBL is partnerid.
Expand Down
2 changes: 1 addition & 1 deletion wbreport/egusers/classes/output/egusers.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public function __construct() {
if (!empty($user->profile['allowedpbls'])) {
$allowedpbls = $user->profile['allowedpbls'];
$allowedpbls = str_replace(' ', '', $allowedpbls);
$pbls = explode('\r\n', $allowedpbls);
$pbls = preg_split('/\s+/', $allowedpbls, -1, PREG_SPLIT_NO_EMPTY);
// By default, a user can see all users having the same PBL as himself, so add it if it exists.
if (!empty($user->profile['partnerid'])) { // Shortname for PBL is partnerid.
$pbls[] = $user->profile['partnerid'];
Expand Down

0 comments on commit 98c005c

Please sign in to comment.