@@ -5274,7 +5274,7 @@ function api_get_current_access_url_id(): int
52745274
52755275 //if the url in WEB_PATH was not found, it can only mean that there is
52765276 // either a configuration problem or the first URL has not been defined yet
5277- // (by default it is http://localhost/). Thus the more sensible thing we can
5277+ // (by default, it is http://localhost/). Thus, the more sensible thing we can
52785278 // do is return 1 (the main URL) as the user cannot hack this value anyway
52795279 return 1 ;
52805280}
@@ -5287,10 +5287,10 @@ function api_get_current_access_url_id(): int
52875287 * @param int $user_id
52885288 *
52895289 * @return array
5290+ * @throws Exception
52905291 */
5291- function api_get_access_url_from_user ($ user_id )
5292+ function api_get_access_url_from_user (int $ user_id ): array
52925293{
5293- $ user_id = (int ) $ user_id ;
52945294 $ table_url_rel_user = Database::get_main_table (TABLE_MAIN_ACCESS_URL_REL_USER );
52955295 $ table_url = Database::get_main_table (TABLE_MAIN_ACCESS_URL );
52965296 $ sql = "SELECT access_url_id
@@ -5308,11 +5308,12 @@ function api_get_access_url_from_user($user_id)
53085308}
53095309
53105310/**
5311- * Checks whether the current admin user in in all access urls.
5311+ * Checks whether the current admin user in all access urls.
53125312 *
53135313 * @return bool
5314+ * @throws Exception
53145315 */
5315- function api_is_admin_in_all_active_urls ()
5316+ function api_is_admin_in_all_active_urls (): bool
53165317{
53175318 if (api_is_platform_admin ()) {
53185319 $ urls = api_get_active_urls ();
@@ -5322,16 +5323,20 @@ function api_is_admin_in_all_active_urls()
53225323 return false ;
53235324 }
53245325 }
5326+
53255327 return true ;
53265328 }
5329+
5330+ return false ;
53275331}
53285332
53295333/**
53305334 * Gets all the access urls in the database.
53315335 *
53325336 * @return array
5337+ * @throws Exception
53335338 */
5334- function api_get_active_urls ()
5339+ function api_get_active_urls (): array
53355340{
53365341 $ table = Database::get_main_table (TABLE_MAIN_ACCESS_URL );
53375342 $ sql = "SELECT * FROM $ table WHERE active = 1 " ;
@@ -5345,16 +5350,16 @@ function api_get_active_urls()
53455350}
53465351
53475352/**
5348- * Checks whether the curent user is in a group or not.
5353+ * Checks whether the current user is in a group or not.
53495354 *
5350- * @param string The group id - optional (takes it from session if not given)
5351- * @param string The course code - optional (no additional check by course if course code is not given)
5355+ * @param ?int $groupIdParam The group id - optional (takes it from session if not given)
5356+ * @param ? string $courseCodeParam The course code - optional (no additional check by course if course code is not given)
53525357 *
53535358 * @return bool
53545359 *
53555360 * @author Ivan Tcholakov
53565361 */
5357- function api_is_in_group ($ groupIdParam = null , $ courseCodeParam = null )
5362+ function api_is_in_group (? int $ groupIdParam = null , ? string $ courseCodeParam = null ): bool
53585363{
53595364 if (!empty ($ courseCodeParam )) {
53605365 $ courseCode = api_get_course_id ();
@@ -5369,7 +5374,7 @@ function api_is_in_group($groupIdParam = null, $courseCodeParam = null)
53695374
53705375 $ groupId = api_get_group_id ();
53715376
5372- if (isset ( $ groupId ) && '' != $ groupId ) {
5377+ if ('' != $ groupId ) {
53735378 if (!empty ($ groupIdParam )) {
53745379 return $ groupIdParam == $ groupId ;
53755380 } else {
@@ -5386,7 +5391,7 @@ function api_is_in_group($groupIdParam = null, $courseCodeParam = null)
53865391 * @param string $original_key_secret - secret key from (webservice) client
53875392 * @param string $security_key - security key from Chamilo
53885393 *
5389- * @return bool - true if secret key is valid, false otherwise
5394+ * @return bool - true if the secret key is valid, false otherwise
53905395 */
53915396function api_is_valid_secret_key ($ original_key_secret , $ security_key )
53925397{
0 commit comments