Valid user id by id field instead of user_id - refs BT#9413

1.10.x
Angel Fernando Quiroz Campos 11 years ago
parent 36153f58a0
commit a6f0c6b36f
  1. 22
      main/inc/lib/usermanager.lib.php

@ -1129,18 +1129,22 @@ class UserManager
* @param int User id
* @return bool True if user id was found, false otherwise
*/
public static function is_user_id_valid($user_id)
public static function is_user_id_valid($userId)
{
$user_id = (int) $user_id;
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
$sql = "SELECT user_id FROM $table_user WHERE user_id = '".$user_id."'";
$res = Database::query($sql);
$num_rows = Database::num_rows($res);
if ($num_rows == 0) {
$resultData = Database::select(
'COUNT(1) AS count',
Database::get_main_table(TABLE_MAIN_USER),
[
'where' => ['id = ?' => intval($userId)]
],
'first'
);
if ($resultData === false) {
return false;
} else {
return true;
}
return $resultData['count'] > 0;
}
/**

Loading…
Cancel
Save