| @@ 1167-1177 (lines=11) @@ | ||
| 1164 | * @assert ('') === false |
|
| 1165 | * @assert ('xyzxyzxyz') === true |
|
| 1166 | */ |
|
| 1167 | public static function is_username_available($username) |
|
| 1168 | { |
|
| 1169 | if (empty($username)) { |
|
| 1170 | return false; |
|
| 1171 | } |
|
| 1172 | $table_user = Database :: get_main_table(TABLE_MAIN_USER); |
|
| 1173 | $sql = "SELECT username FROM $table_user |
|
| 1174 | WHERE username = '".Database::escape_string($username)."'"; |
|
| 1175 | $res = Database::query($sql); |
|
| 1176 | ||
| 1177 | return Database::num_rows($res) == 0; |
|
| 1178 | } |
|
| 1179 | ||
| 1180 | /** |
|
| @@ 1606-1618 (lines=13) @@ | ||
| 1603 | * status of "6" (anonymous). |
|
| 1604 | * @return int User ID of the anonymous user, or O if no anonymous user found |
|
| 1605 | */ |
|
| 1606 | function api_get_anonymous_id() |
|
| 1607 | { |
|
| 1608 | $table = Database::get_main_table(TABLE_MAIN_USER); |
|
| 1609 | $sql = "SELECT user_id FROM $table WHERE status = ".ANONYMOUS; |
|
| 1610 | $res = Database::query($sql); |
|
| 1611 | if (Database::num_rows($res) > 0) { |
|
| 1612 | $row = Database::fetch_array($res); |
|
| 1613 | return $row['user_id']; |
|
| 1614 | } |
|
| 1615 | ||
| 1616 | // No anonymous user was found. |
|
| 1617 | return 0; |
|
| 1618 | } |
|
| 1619 | ||
| 1620 | /** |
|
| 1621 | * @param string $courseCode |
|