Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Activity header URL fix for mymedia and user profile #17

Merged
merged 1 commit into from
Dec 20, 2023
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
45 changes: 35 additions & 10 deletions classes/output/core_renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public function full_header() {

// try to avoid problems with special characters in titles ( & )
$headertext = html_entity_decode($headertext);
//Little hack to add back missing header for dashboard
//The context header the comes through is not formated properly
if($this->page->pagelayout=="mydashboard"&&strpos($PAGE->url,'my/indexsys.php')===false){
Expand All @@ -212,8 +212,7 @@ public function full_header() {
$header->contextheader = '<h2><a href="'.$CFG->wwwroot.'/course/view.php?id='.$COURSE->id.'">'.$COURSE->fullname.'</a></h2>';
}
*/
//error_log('pg url:'.$PAGE->url);


$activityheader = false;

//error_log('$PAGE->url:'.$PAGE->url);
Expand All @@ -234,12 +233,38 @@ public function full_header() {
} else if (strpos($PAGE->url,'grade/')===false&&strpos($PAGE->url,'backup/')===false&&strpos($PAGE->url,'reset.php')===false&&strpos($PAGE->url,'coursecompetencies.php')===false&&strpos($PAGE->url,'unenrolself.php')===false&&strpos($PAGE->url,'newbadge.php')===false&&strpos($PAGE->url,'report/')===false&&$PAGE->url->get_param('bui_editid')===null&&strpos($PAGE->url,'my/courses.php')===false&&strpos($PAGE->url,'admin/')===false&&strpos($PAGE->url,'my/indexsys.php')===false) {
$activityheader = true;
}





if ($activityheader === true) {
$header->contextheader = '<a href="'.$CFG->wwwroot.'/mod/'.$this->page->activityname.'/view.php?id='.$this->page->context->instanceid.'" class="activity-header-link">'.$headertext.'</a>';


/**
* UOFR Hack
* Joel Dapiawen
* November 22, 2023
* Override activity-header URL to macth the current Page URL..
*/
$current_url = $PAGE->url;

if (strpos($current_url, 'mymedia/mymedia.php') !== false || strpos($current_url, 'user/profile.php') !== false) {

if (isset($header) && isset($headertext)) {
// Construct the header links based on URL conditions
if (strpos($current_url, 'mymedia/mymedia.php') !== false) {
$header->contextheader = '<a href="' . $PAGE->url .'" class="activity-header-link">' . $headertext . '</a>';
// $header->contextheader = '<a href="' . $CFG->wwwroot . '/local/mymedia/mymedia.php" class="activity-header-link">' . $headertext . '</a>';

}

if (strpos($current_url, 'user/profile.php') !== false) {
$header->contextheader = '<a href="' . $PAGE->url .'" class="activity-header-link">' . $headertext . '</a>';
// $header->contextheader = '<a href="' . $CFG->wwwroot . '/user/profile.php" class="activity-header-link">' . $headertext . '</a>';
}
}
} else {
// default URL's for activity header..
$header->contextheader = '<a href="'.$CFG->wwwroot.'/mod/'.$this->page->activityname.'/view.php?id='.$this->page->context->instanceid.'" class="activity-header-link">'.$headertext.'</a>';
}

} else {

$headertext = $COURSE->fullname;
Expand All @@ -258,8 +283,8 @@ public function full_header() {
$header->contextheader = '<!-- hello -->';//'<h2><a href="'.$CFG->wwwroot.'/course/view.php?id='.$COURSE->id.'">'.$COURSE->fullname.'</a></h2>';
$header->iscoursepage = true;
}
//error_log('Header actions:'.print_r($PAGE->get_header_actions(),1));

//error_log('Header actions:'.print_r($PAGE->get_header_actions(),1));

$header->headeractions = $PAGE->get_header_actions();

Expand Down