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 * @param int User id
* @return bool True if user id was found, false otherwise * @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; $resultData = Database::select(
$table_user = Database :: get_main_table(TABLE_MAIN_USER); 'COUNT(1) AS count',
$sql = "SELECT user_id FROM $table_user WHERE user_id = '".$user_id."'"; Database::get_main_table(TABLE_MAIN_USER),
$res = Database::query($sql); [
$num_rows = Database::num_rows($res); 'where' => ['id = ?' => intval($userId)]
if ($num_rows == 0) { ],
'first'
);
if ($resultData === false) {
return false; return false;
} else {
return true;
} }
return $resultData['count'] > 0;
} }
/** /**

Loading…
Cancel
Save