| @@ 1160-1170 (lines=11) @@ | ||
| 1157 | * @assert ('') === false |
|
| 1158 | * @assert ('xyzxyzxyz') === true |
|
| 1159 | */ |
|
| 1160 | public static function is_username_available($username) |
|
| 1161 | { |
|
| 1162 | if (empty($username)) { |
|
| 1163 | return false; |
|
| 1164 | } |
|
| 1165 | $table_user = Database :: get_main_table(TABLE_MAIN_USER); |
|
| 1166 | $sql = "SELECT username FROM $table_user |
|
| 1167 | WHERE username = '".Database::escape_string($username)."'"; |
|
| 1168 | $res = Database::query($sql); |
|
| 1169 | ||
| 1170 | return Database::num_rows($res) == 0; |
|
| 1171 | } |
|
| 1172 | ||
| 1173 | /** |
|
| @@ 1612-1624 (lines=13) @@ | ||
| 1609 | * status of "6" (anonymous). |
|
| 1610 | * @return int User ID of the anonymous user, or O if no anonymous user found |
|
| 1611 | */ |
|
| 1612 | function api_get_anonymous_id() |
|
| 1613 | { |
|
| 1614 | $table = Database::get_main_table(TABLE_MAIN_USER); |
|
| 1615 | $sql = "SELECT user_id FROM $table WHERE status = ".ANONYMOUS; |
|
| 1616 | $res = Database::query($sql); |
|
| 1617 | if (Database::num_rows($res) > 0) { |
|
| 1618 | $row = Database::fetch_array($res); |
|
| 1619 | return $row['user_id']; |
|
| 1620 | } |
|
| 1621 | ||
| 1622 | // No anonymous user was found. |
|
| 1623 | return 0; |
|
| 1624 | } |
|
| 1625 | ||
| 1626 | /** |
|
| 1627 | * @param string $courseCode |
|