diff --git a/php/libraries/User.class.inc b/php/libraries/User.class.inc index 46a5a3dba8b..a477d7d674d 100644 --- a/php/libraries/User.class.inc +++ b/php/libraries/User.class.inc @@ -351,6 +351,37 @@ class User extends UserPermissions implements return $site_list; } + /** + * Returns all user's sites + * + * @return array + */ + function getSites(): array + { + return array_map( + function ($centerID) { + return \Site::singleton($centerID); + }, + $this->getCenterIDs() + ); + } + + /** + * Returns all user's sites in associative + * array (CenterID => CenterName) + * + * @return array + */ + function getSiteNamesList(): array + { + $sites = []; + foreach ($this->getSites() as $site) { + $sites[$site->getCenterID()->__toString()] = $site->getCenterName(); + } + return $sites; + } + + /** * Returns all user's sites that are StudySites *