| @@ 1589-1601 (lines=13) @@ | ||
| 1586 | * status of "6" (anonymous). |
|
| 1587 | * @return int User ID of the anonymous user, or O if no anonymous user found |
|
| 1588 | */ |
|
| 1589 | function api_get_anonymous_id() |
|
| 1590 | { |
|
| 1591 | $table = Database::get_main_table(TABLE_MAIN_USER); |
|
| 1592 | $sql = "SELECT user_id FROM $table WHERE status = ".ANONYMOUS; |
|
| 1593 | $res = Database::query($sql); |
|
| 1594 | if (Database::num_rows($res) > 0) { |
|
| 1595 | $row = Database::fetch_array($res); |
|
| 1596 | return $row['user_id']; |
|
| 1597 | } |
|
| 1598 | ||
| 1599 | // No anonymous user was found. |
|
| 1600 | return 0; |
|
| 1601 | } |
|
| 1602 | ||
| 1603 | /** |
|
| 1604 | * @param string $courseCode |
|
| @@ 1165-1175 (lines=11) @@ | ||
| 1162 | * @assert ('') === false |
|
| 1163 | * @assert ('xyzxyzxyz') === true |
|
| 1164 | */ |
|
| 1165 | public static function is_username_available($username) |
|
| 1166 | { |
|
| 1167 | if (empty($username)) { |
|
| 1168 | return false; |
|
| 1169 | } |
|
| 1170 | $table_user = Database :: get_main_table(TABLE_MAIN_USER); |
|
| 1171 | $sql = "SELECT username FROM $table_user |
|
| 1172 | WHERE username = '".Database::escape_string($username)."'"; |
|
| 1173 | $res = Database::query($sql); |
|
| 1174 | ||
| 1175 | return Database::num_rows($res) == 0; |
|
| 1176 | } |
|
| 1177 | ||
| 1178 | /** |
|