From fbaea0cb0a6e6001f64058d8b2b11caf689513ed Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Fri, 3 Jun 2016 16:36:47 -0500 Subject: [PATCH] Fix code quality issues (suggested by Scrutinizer) --- main/admin/user_list.php | 19 ++++++++++++++----- main/auth/external_login/ldap.inc.php | 12 +++--------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/main/admin/user_list.php b/main/admin/user_list.php index a474ccf096..28d4ad77d5 100755 --- a/main/admin/user_list.php +++ b/main/admin/user_list.php @@ -216,11 +216,14 @@ function prepare_user_sql_query($is_count) $keywordListValues = array(); } + /* + // This block is never executed because $keyword_extra_data never exists if (isset($keyword_extra_data) && !empty($keyword_extra_data)) { $extra_info = UserManager::get_extra_field_information_by_name($keyword_extra_data); $field_id = $extra_info['id']; $sql.= " INNER JOIN user_field_values ufv ON u.id=ufv.user_id AND ufv.field_id=$field_id "; } + */ if (isset($_GET['keyword']) && !empty($_GET['keyword'])) { $keywordFiltered = Database::escape_string("%". $_GET['keyword'] ."%"); @@ -247,10 +250,14 @@ function prepare_user_sql_query($is_count) } $keyword_extra_value = ''; + + // This block is never executed because $keyword_extra_data never exists + /* if (isset($keyword_extra_data) && !empty($keyword_extra_data) && !empty($keyword_extra_data_text)) { $keyword_extra_value = " AND ufv.field_value LIKE '%".trim($keyword_extra_data_text)."%' "; } + */ $sql .= " $query_admin_table WHERE ( @@ -264,12 +271,14 @@ function prepare_user_sql_query($is_count) $keyword_extra_value "; - if (isset($keyword_active) && !isset($keyword_inactive)) { - $sql .= " AND u.active='1'"; - } elseif (isset($keyword_inactive) && !isset($keyword_active)) { - $sql .= " AND u.active='0'"; + if (isset($keywordListValues['keyword_active'])) { + if (!empty($keywordListValues['keyword_active'])) { + $sql .= " AND u.active = 1"; + } else { + $sql .= " AND u.active = 0"; + } } - $sql .= " ) "; + $sql .= ')'; } // adding the filter to see the user's only of the current access_url diff --git a/main/auth/external_login/ldap.inc.php b/main/auth/external_login/ldap.inc.php index 6bd48e4ea6..9b53245f9b 100755 --- a/main/auth/external_login/ldap.inc.php +++ b/main/auth/external_login/ldap.inc.php @@ -314,15 +314,9 @@ function extldap_add_user_by_array($data, $update_if_exists = true) // No expiration date for students (recover from LDAP's shadow expiry) $expiration_date = ''; $active = 1; - if (empty($status)) { - $status = 5; - } - if (empty($phone)) { - $phone = ''; - } - if (empty($picture_uri)) { - $picture_uri = ''; - } + $status = 5; + $phone = ''; + $picture_uri = ''; // Adding user $user_id = 0; if (UserManager::is_username_available($username)) {