in repository/office365/lib.php [154:272]
public function get_listing($path = '', $page = '') {
global $OUTPUT, $SESSION, $USER;
if (utils::is_configured() !== true) {
throw new \moodle_exception('errorauthoidcnotconfig', 'repository_office365');
}
$clientid = optional_param('client_id', '', PARAM_TEXT);
if (!empty($clientid)) {
$SESSION->repository_office365['curpath'][$clientid] = $path;
}
// If we were launched from a course context (or child of course context), initialize the file picker in the correct course.
if (!empty($this->context)) {
$context = $this->context->get_course_context(false);
}
if (empty($context)) {
$context = \context_system::instance();
}
$list = [];
$breadcrumb = [['name' => $this->name, 'path' => '/']];
$unifiedactive = false;
$trendingactive = false;
$trendingdisabled = get_config('office365', 'trendinggroup');
if ($this->unifiedconfigured === true) {
$unifiedtoken = $this->get_unified_token();
if (!empty($unifiedtoken)) {
$unifiedactive = true;
$trendingactive = (empty($trendingdisabled)) ? true : false;
}
}
$onedriveactive = false;
$onedrivegroupdisabled = get_config('office365', 'onedrivegroup');
if ($this->onedriveconfigured === true && empty($onedrivegroupdisabled)) {
$onedrivetoken = $this->get_onedrive_token();
if (!empty($onedrivetoken)) {
$onedriveactive = true;
}
}
$courses = enrol_get_users_courses($USER->id, true);
$showgroups = false;
$coursegroupdisabled = get_config('office365', 'coursegroup');
if (\local_o365\rest\unified::is_configured() === true && empty($coursegroupdisabled)) {
foreach ($courses as $course) {
if (\local_o365\feature\usergroups\utils::course_is_group_enabled($course->id)) {
$showgroups = true;
break;
}
}
}
if (strpos($path, '/my/') === 0) {
if ($unifiedactive === true) {
// Path is in my files.
[$list, $breadcrumb] = $this->get_listing_my_unified(substr($path, 3));
} else if ($onedriveactive === true) {
// Path is in my files.
[$list, $breadcrumb] = $this->get_listing_my(substr($path, 3));
}
} else if (strpos($path, '/groups/') === 0) {
if ($showgroups === true) {
// Path is in group files.
[$list, $breadcrumb] = $this->get_listing_groups(substr($path, 7));
}
} else if (strpos($path, '/trending/') === 0) {
if ($trendingactive === true) {
// Path is in trending files.
[$list, $breadcrumb] = $this->get_listing_trending_unified(substr($path, 9));
}
} else {
if ($unifiedactive === true && $onedriveactive === true) {
$list[] = [
'title' => get_string('myfiles', 'repository_office365'),
'path' => '/my/',
'thumbnail' => $OUTPUT->pix_url('onedrive', 'repository_office365')->out(false),
'children' => [],
];
}
if ($showgroups === true) {
$list[] = [
'title' => get_string('groups', 'repository_office365'),
'path' => '/groups/',
'thumbnail' => $OUTPUT->pix_url('coursegroups', 'repository_office365')->out(false),
'children' => [],
];
}
if ($trendingactive === true) {
$list[] = [
'title' => get_string('trendingaround', 'repository_office365'),
'path' => '/trending/',
'thumbnail' => $OUTPUT->pix_url('delve', 'repository_office365')->out(false),
'children' => [],
];
}
}
if ($this->path_is_upload($path) === true) {
return [
'dynload' => true,
'nologin' => true,
'nosearch' => true,
'path' => $breadcrumb,
'upload' => [
'label' => get_string('file', 'repository_office365'),
],
];
}
return [
'dynload' => true,
'nologin' => true,
'nosearch' => true,
'list' => $list,
'path' => $breadcrumb,
];
}