Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions php/libraries/User.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down