| @@ 1604-1616 (lines=13) @@ | ||
| 1601 | * status of "6" (anonymous). |
|
| 1602 | * @return int User ID of the anonymous user, or O if no anonymous user found |
|
| 1603 | */ |
|
| 1604 | function api_get_anonymous_id() |
|
| 1605 | { |
|
| 1606 | $table = Database::get_main_table(TABLE_MAIN_USER); |
|
| 1607 | $sql = "SELECT user_id FROM $table WHERE status = ".ANONYMOUS; |
|
| 1608 | $res = Database::query($sql); |
|
| 1609 | if (Database::num_rows($res) > 0) { |
|
| 1610 | $row = Database::fetch_array($res); |
|
| 1611 | return $row['user_id']; |
|
| 1612 | } |
|
| 1613 | ||
| 1614 | // No anonymous user was found. |
|
| 1615 | return 0; |
|
| 1616 | } |
|
| 1617 | ||
| 1618 | /** |
|
| 1619 | * @param string $courseCode |
|
| @@ 1241-1251 (lines=11) @@ | ||
| 1238 | * @assert ('') === false |
|
| 1239 | * @assert ('xyzxyzxyz') === true |
|
| 1240 | */ |
|
| 1241 | public static function is_username_available($username) |
|
| 1242 | { |
|
| 1243 | if (empty($username)) { |
|
| 1244 | return false; |
|
| 1245 | } |
|
| 1246 | $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
| 1247 | $sql = "SELECT username FROM $table_user |
|
| 1248 | WHERE username = '".Database::escape_string($username)."'"; |
|
| 1249 | $res = Database::query($sql); |
|
| 1250 | ||
| 1251 | return Database::num_rows($res) == 0; |
|
| 1252 | } |
|
| 1253 | ||
| 1254 | /** |
|