From 87b92987b7a87117f696a71528ec43c1c1c4e3d0 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Wed, 11 May 2016 09:20:10 -0600 Subject: [PATCH] Run array unique and sort only on groups array if it exists. And use is_array instead of isset on the conditions that test if it is an array. --- app/operator_panel/index_inc.php | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/app/operator_panel/index_inc.php b/app/operator_panel/index_inc.php index 355fde0d10..724354b99a 100644 --- a/app/operator_panel/index_inc.php +++ b/app/operator_panel/index_inc.php @@ -41,10 +41,10 @@ else { $activity = get_call_activity(); -if (isset($activity)) foreach ($activity as $extension => $fields) { +if (is_array($activity)) foreach ($activity as $extension => $fields) { if (substr_count($fields['call_group'], ',')) { $tmp = explode(',', $fields['call_group']); - if (isset($tmp)) foreach ($tmp as $tmp_index => $tmp_value) { + if (is_array($tmp)) foreach ($tmp as $tmp_index => $tmp_value) { if (trim($tmp_value) == '') { unset($tmp[$tmp_index]); } else { $groups[] = $tmp_value; } } @@ -53,8 +53,10 @@ if (isset($activity)) foreach ($activity as $extension => $fields) { $groups[] = $fields['call_group']; } } -$groups = array_unique($groups); -sort($groups); +if (is_array($groups)) { + $groups = array_unique($groups); + sort($groups); +} $onhover_pause_refresh = " onmouseover='refresh_stop();' onmouseout='refresh_start();'"; @@ -84,7 +86,7 @@ if (sizeof($_SESSION['user']['extensions']) > 0) { $status_options[5]['label'] = $text['label-status_logged_out']; $status_options[5]['style'] = "op_btn_status_logged_out"; - if (isset($status_options)) foreach ($status_options as $status_option) { + if (is_array($status_options)) foreach ($status_options as $status_option) { echo " \n"; } } @@ -103,7 +105,7 @@ if (permission_exists('operator_panel_eavesdrop')) { echo " "; echo " "; echo " \n"; @@ -122,7 +124,7 @@ if (sizeof($groups) > 0) { echo " \n"; @@ -130,7 +132,7 @@ if (sizeof($groups) > 0) { else { //show buttons echo " "; - if (isset($groups)) foreach ($groups as $group) { + if (is_array($groups)) foreach ($groups as $group) { echo " "; } } @@ -145,7 +147,7 @@ echo " "; echo ""; echo "
"; -if (isset($activity)) foreach ($activity as $extension => $ext) { +if (is_array($activity)) foreach ($activity as $extension => $ext) { unset($block); //filter by group, if defined @@ -406,7 +408,7 @@ if (isset($activity)) foreach ($activity as $extension => $ext) { if (sizeof($user_extensions) > 0) { echo "
"; - if (isset($user_extensions)) foreach ($user_extensions as $ext_block) { + if (is_array($user_extensions)) foreach ($user_extensions as $ext_block) { echo $ext_block; } echo "
"; @@ -425,7 +427,7 @@ else if (sizeof($user_extensions) > 0) { if (sizeof($other_extensions) > 0) { echo "
"; - if (isset($other_extensions)) foreach ($other_extensions as $ext_block) { + if (is_array($other_extensions)) foreach ($other_extensions as $ext_block) { echo $ext_block; } echo "
";