Skip to content

Commit

Permalink
MDL-49688 navigation: First review fixes and version bump.
Browse files Browse the repository at this point in the history
Part of MDL-45774.
  • Loading branch information
abgreeve committed Apr 10, 2015
1 parent 0ef6c85 commit 45367bd
Show file tree
Hide file tree
Showing 22 changed files with 111 additions and 70 deletions.
5 changes: 5 additions & 0 deletions admin/roles/assign.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@
}
}

if ($user->id != $USER->id) {
$PAGE->navigation->extend_for_user($user);
$PAGE->navbar->includesettingsbase = true;
}

$PAGE->set_pagelayout('admin');
$PAGE->set_title($title);

Expand Down
23 changes: 13 additions & 10 deletions blog/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,20 @@
$id = null;
}

$entry = new stdClass();
$entry->id = null;

if ($id) {
if (!$entry = new blog_entry($id)) {
print_error('wrongentryid', 'blog');
}
$userid = $entry->userid;
} else {
$userid = $USER->id;
}

$sitecontext = context_system::instance();
$usercontext = context_user::instance($USER->id);
$usercontext = context_user::instance($userid);
$PAGE->set_context($usercontext);
$blognode = $PAGE->settingsnav->find('blogadd', null);
$blognode->make_active();
Expand Down Expand Up @@ -85,24 +97,15 @@

// Make sure that the person trying to edit has access right.
if ($id) {
if (!$entry = new blog_entry($id)) {
print_error('wrongentryid', 'blog');
}

if (!blog_user_can_edit_entry($entry)) {
print_error('notallowedtoedit', 'blog');
}
$userid = $entry->userid;
$entry->subject = clean_text($entry->subject);
$entry->summary = clean_text($entry->summary, $entry->format);

} else {
if (!has_capability('moodle/blog:create', $sitecontext)) {
print_error('noentry', 'blog'); // The capability "manageentries" is not enough for adding.
}
$entry = new stdClass();
$entry->id = null;
$userid = $USER->id;
}
$returnurl->param('userid', $userid);

Expand Down
6 changes: 6 additions & 0 deletions blog/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@
}
}

// Set the userid to the entry author if we have the entry ID.
if ($entryid and !isset($userid)) {
$entry = new blog_entry($entryid);
$userid = $entry->userid;
}

if (isset($userid)) {
$context = context_user::instance($userid);
} else {
Expand Down
2 changes: 1 addition & 1 deletion course/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
// Add the user name.
$PAGE->navbar->add(fullname($user), $userurl, navigation_node::TYPE_SETTING);
}
$gradeurl = new moodle_url('/course/user.php', array('id'=>$id, 'user'=>$user->id, 'mode'=>$mode));
$gradeurl = new moodle_url('/course/user.php', array('id' => $id, 'user' => $user->id, 'mode' => $mode));
// Add the 'grades' node to the navbar.
$navbar = $PAGE->navbar->add(get_string('grades', 'grades'), $gradeurl, navigation_node::TYPE_SETTING);
}
Expand Down
5 changes: 3 additions & 2 deletions lib/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4270,6 +4270,7 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2015032000.00);
}

<<<<<<< HEAD
if ($oldversion < 2015040200.01) {
// Force uninstall of deleted tool.
if (!file_exists("$CFG->dirroot/$CFG->admin/tool/timezoneimport")) {
Expand Down Expand Up @@ -4315,7 +4316,7 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2015040800.01);
}

if ($oldversion < 2015030400.02) {
if ($oldversion < 2015040800.02) {
// Update the default user menu (add preferences, remove my files and my badges).
$oldconfig = get_config('core', 'customusermenuitems');

Expand All @@ -4334,7 +4335,7 @@ function xmldb_main_upgrade($oldversion) {
$newconfig = preg_replace('/(\r\n)+/', "\n", $newconfig);
set_config('customusermenuitems', $newconfig);

upgrade_main_savepoint(true, 2015030400.02);
upgrade_main_savepoint(true, 2015040800.02);
}

return true;
Expand Down
6 changes: 5 additions & 1 deletion lib/myprofilelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ function core_myprofile_navigation(core_user\output\myprofile\tree $tree, $user,
if ($userauthplugin && $userauthplugin->can_edit_profile()) {
$url = $userauthplugin->edit_profile_url();
if (empty($url)) {
$url = new moodle_url('/user/edit.php', array('userid' => $user->id, 'course' => $id));
if (empty($course)) {
$url = new moodle_url('/user/edit.php', array('userid' => $user->id));
} else {
$url = new moodle_url('/user/edit.php', array('userid' => $user->id, 'course' => $course->id));
}
}
$node = new core_user\output\myprofile\node('administration', 'editprofile',
get_string('editmyprofile'), null, $url);
Expand Down
67 changes: 35 additions & 32 deletions lib/navigationlib.php

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions lib/outputrenderers.php
Original file line number Diff line number Diff line change
Expand Up @@ -3960,6 +3960,7 @@ public function favicon() {
*/
public function render_preferences_groups(preferences_groups $renderable) {
$html = '';
$html .= html_writer::start_div('row-fluid');
$html .= html_writer::start_tag('div', array('class' => 'span12 preferences-groups'));
$i = 0;
$open = false;
Expand All @@ -3968,7 +3969,7 @@ public function render_preferences_groups(preferences_groups $renderable) {
if ($open) {
$html .= html_writer::end_tag('div');
}
$html .= html_writer::start_tag('div', array('class' => 'row'));
$html .= html_writer::start_tag('div', array('class' => 'row-fluid'));
$open = true;
}
$html .= $this->render($group);
Expand All @@ -3979,6 +3980,7 @@ public function render_preferences_groups(preferences_groups $renderable) {

$html .= html_writer::end_tag('ul');
$html .= html_writer::end_tag('div');
$html .= html_writer::end_div();
return $html;
}

Expand Down Expand Up @@ -4122,11 +4124,13 @@ protected function render_context_header(context_header $contextheader) {

/**
* Wrapper for header elements.
*
* @param string $heading Heading to be used for the main header.
* @return string HTML to display the main header.
*/
public function full_header($heading = null) {
$html = html_writer::start_tag('header', array('id' => 'page-header', 'class' => 'clearfix'));
// This is to ensure that the logo completely overwrites the header. MDL-49536 has been created to investigate
// whether the logo should work this way or not.
// This is to ensure that the logo completely overwrites the header if set.
if (isset($heading) && $heading == '<div class="logo"></div>') {
$html .= $heading;
} else {
Expand All @@ -4136,7 +4140,7 @@ public function full_header($heading = null) {
$html .= html_writer::tag('nav', $this->navbar(), array('class' => 'breadcrumb-nav'));
$html .= html_writer::div($this->page_heading_button(), 'breadcrumb-button');
$html .= html_writer::end_div();
$html .= html_writer::tag('div', $this->course_header(), array('class' => 'course-header'));
$html .= html_writer::tag('div', $this->course_header(), array('id' => 'course-header'));
$html .= html_writer::end_tag('header');
return $html;
}
Expand Down
2 changes: 1 addition & 1 deletion message/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
} else {
$PAGE->set_title("{$SITE->shortname}: $strmessages");
}
$PAGE->set_heading(fullname($USER));
$PAGE->set_heading(fullname($user1));

// Remove the user node from the main navigation for this page.
$usernode = $PAGE->navigation->find('users', null);
Expand Down
5 changes: 3 additions & 2 deletions message/output/email/message_output_email.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,9 @@ function config_form($preferences){
}

if (!empty($CFG->messagingallowemailoverride)) {
$inputattributes = array('size'=>'30', 'name'=>'email_email', 'value'=>$preferences->email_email, 'id'=>'email_email');
$string .= html_writer::label(get_string('email','message_email'), 'email_email');
$inputattributes = array('size' => '30', 'name' => 'email_email', 'value' => $preferences->email_email,
'id' => 'email_email');
$string .= html_writer::label(get_string('email', 'message_email'), 'email_email');
$string .= $OUTPUT->container(html_writer::empty_tag('input', $inputattributes));

if (empty($preferences->email_email) && !empty($preferences->userdefaultemail)) {
Expand Down
4 changes: 2 additions & 2 deletions mod/forum/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -7831,7 +7831,7 @@ function mod_forum_myprofile_navigation(core_user\output\myprofile\tree $tree, $
}
$postsurl = new moodle_url('/mod/forum/user.php', array('id' => $user->id));
if (!empty($course)) {
$postsurl->param('coursre', $course->id);
$postsurl->param('course', $course->id);
}
$string = $iscurrentuser ? get_string('myprofileownpost', 'mod_forum') :
get_string('myprofileotherpost', 'mod_forum', fullname($user));
Expand All @@ -7840,7 +7840,7 @@ function mod_forum_myprofile_navigation(core_user\output\myprofile\tree $tree, $

$discussionssurl = new moodle_url('/mod/forum/user.php', array('id' => $user->id, 'mode' => 'discussions'));
if (!empty($course)) {
$postsurl->param('coursre', $course->id);
$postsurl->param('course', $course->id);
}
$string = $iscurrentuser ? get_string('myprofileowndis', 'mod_forum') :
get_string('myprofileotherdis', 'mod_forum', fullname($user));
Expand Down
6 changes: 3 additions & 3 deletions mod/forum/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@
array('id' => $user->id, 'course' => $courseid)));
} else {
$navbar = $PAGE->navbar->add(get_string('discussions', 'forum'), new moodle_url('/mod/forum/user.php',
array('id' => $user->id, 'course' => $courseid, 'mode'=>'discussions')));
array('id' => $user->id, 'course' => $courseid, 'mode' => 'discussions')));
}
}
} else if ($canviewuser) {
Expand All @@ -211,7 +211,7 @@
array('id' => $user->id, 'course' => $courseid)));
} else {
$navbar = $PAGE->navbar->add(get_string('discussions', 'forum'), new moodle_url('/mod/forum/user.php',
array('id' => $user->id, 'course' => $courseid, 'mode'=>'discussions')));
array('id' => $user->id, 'course' => $courseid, 'mode' => 'discussions')));
}
}

Expand Down Expand Up @@ -384,7 +384,7 @@
array('id' => $user->id, 'course' => $courseid)));
} else {
$navbar = $PAGE->navbar->add(get_string('discussions', 'forum'), new moodle_url('/mod/forum/user.php',
array('id' => $user->id, 'course' => $courseid, 'mode'=>'discussions')));
array('id' => $user->id, 'course' => $courseid, 'mode' => 'discussions')));
}
}

Expand Down
3 changes: 0 additions & 3 deletions my/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@
}
}
}
$mycoursenode = $PAGE->navigation->get('mycourses');
$mycoursenode->collapse = true;
$mycoursenode->make_inactive();

// Toggle the editing state and switches
if ($PAGE->user_allowed_editing()) {
Expand Down
3 changes: 2 additions & 1 deletion user/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@
$a->oldemail = $usernew->email = $user->email;

$emailchangedhtml = $OUTPUT->box(get_string('auth_changingemailaddress', 'auth', $a), 'generalbox', 'notice');
$emailchangedhtml .= $OUTPUT->continue_button("$CFG->wwwroot/user/preferences.php?userid=$user->id&amp;course=$course->id");
$emailchangedhtml .=
$OUTPUT->continue_button("$CFG->wwwroot/user/preferences.php?userid=$user->id&amp;course=$course->id");
$emailchanged = true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion user/editadvanced.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@
$PAGE->set_heading($userfullname);

echo $OUTPUT->header();
echo $OUTPUT->heading($userfullname);
echo $OUTPUT->heading($streditmyprofile);
}

// Finally display THE form.
Expand Down
5 changes: 1 addition & 4 deletions user/editlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,7 @@ function useredit_setup_preference_page($userid, $courseid) {
} else {
// Teachers, parents, etc.
require_capability('moodle/user:editprofile', $personalcontext);
// No editing of guest user account.
if (isguestuser($user->id)) {
print_error('guestnoeditprofileother');
}

// No editing of primary admin!
if (is_siteadmin($user) and !is_siteadmin($USER)) { // Only admins may edit other admins.
print_error('useradmineditadmin');
Expand Down
2 changes: 2 additions & 0 deletions user/editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
$streditmyeditor = get_string('editorpreferences');
$userfullname = fullname($user, true);

$PAGE->navbar->includesettingsbase = true;

$PAGE->set_title("$course->shortname: $streditmyeditor");
$PAGE->set_heading($userfullname);

Expand Down
2 changes: 2 additions & 0 deletions user/forum.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
$streditmyforum = get_string('forumpreferences');
$userfullname = fullname($user, true);

$PAGE->navbar->includesettingsbase = true;

$PAGE->set_title("$course->shortname: $streditmyforum");
$PAGE->set_heading($userfullname);

Expand Down
4 changes: 3 additions & 1 deletion user/forum_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Form to edit a users forum preferences. These are stored as columns in the user table, which
* Form to edit a users forum preferences.
*
* These are stored as columns in the user table, which
* is why they are in /user and not /mod/forum.
*
* @copyright 1999 Martin Dougiamas http://dougiamas.com
Expand Down
4 changes: 3 additions & 1 deletion user/language.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,13 @@
$streditmylanguage = get_string('preferredlanguage');
$userfullname = fullname($user, true);

$PAGE->navbar->includesettingsbase = true;

$PAGE->set_title("$course->shortname: $streditmylanguage");
$PAGE->set_heading($userfullname);

echo $OUTPUT->header();
echo $OUTPUT->heading($userfullname);
echo $OUTPUT->heading($streditmylanguage);

// Finally display THE form.
$languageform->display();
Expand Down
11 changes: 11 additions & 0 deletions user/tests/fixtures/myprofile_fixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
class phpunit_fixture_myprofile_category extends \core_user\output\myprofile\category {
/**
* Make protected method public for testing.
*
* @param node $node
* @return node Nodes after the specified node.
*/
public function find_nodes_after($node) {
return parent::find_nodes_after($node);
Expand All @@ -51,10 +54,18 @@ public function validate_after_order() {

/**
* Class phpunit_fixture_myprofile_tree
*
* @package core_user
* @category test
* @copyright 2015 onwards Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class phpunit_fixture_myprofile_tree extends \core_user\output\myprofile\tree {
/**
* Make protected method public for testing.
*
* @param category $cat Category object
* @return array An array of category objects.
*/
public function find_categories_after($cat) {
return parent::find_categories_after($cat);
Expand Down
2 changes: 1 addition & 1 deletion user/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@
echo $OUTPUT->header();

echo '<div class="userprofile">';
$headerinfo = array('heading' => fullname($user) ,'user' => $user, 'usercontext' => $usercontext);
$headerinfo = array('heading' => fullname($user), 'user' => $user, 'usercontext' => $usercontext);
echo $OUTPUT->context_header($headerinfo, 2);

if ($user->deleted) {
Expand Down

0 comments on commit 45367bd

Please sign in to comment.