| @@ 1600-1612 (lines=13) @@ | ||
| 1597 | * status of "6" (anonymous). |
|
| 1598 | * @return int User ID of the anonymous user, or O if no anonymous user found |
|
| 1599 | */ |
|
| 1600 | function api_get_anonymous_id() |
|
| 1601 | { |
|
| 1602 | $table = Database::get_main_table(TABLE_MAIN_USER); |
|
| 1603 | $sql = "SELECT user_id FROM $table WHERE status = ".ANONYMOUS; |
|
| 1604 | $res = Database::query($sql); |
|
| 1605 | if (Database::num_rows($res) > 0) { |
|
| 1606 | $row = Database::fetch_array($res); |
|
| 1607 | return $row['user_id']; |
|
| 1608 | } |
|
| 1609 | ||
| 1610 | // No anonymous user was found. |
|
| 1611 | return 0; |
|
| 1612 | } |
|
| 1613 | ||
| 1614 | /** |
|
| 1615 | * @param string $courseCode |
|
| @@ 1198-1208 (lines=11) @@ | ||
| 1195 | * @assert ('') === false |
|
| 1196 | * @assert ('xyzxyzxyz') === true |
|
| 1197 | */ |
|
| 1198 | public static function is_username_available($username) |
|
| 1199 | { |
|
| 1200 | if (empty($username)) { |
|
| 1201 | return false; |
|
| 1202 | } |
|
| 1203 | $table_user = Database :: get_main_table(TABLE_MAIN_USER); |
|
| 1204 | $sql = "SELECT username FROM $table_user |
|
| 1205 | WHERE username = '".Database::escape_string($username)."'"; |
|
| 1206 | $res = Database::query($sql); |
|
| 1207 | ||
| 1208 | return Database::num_rows($res) == 0; |
|
| 1209 | } |
|
| 1210 | ||
| 1211 | /** |
|