navigation MDL-21565 Update this xxx is now automatically added to the nav for all modules by default and is renamed to settings as that is what was being used in the tabs system presently anyway.
The following minor changes were also made: * Added roles links to the navigation automatically * Handling of block context for settings navigation * Tidied up init code for settings navigation
This commit is contained in:
+254
-80
@@ -1172,7 +1172,7 @@ class global_navigation extends navigation_node {
|
||||
*/
|
||||
protected function load_for_category($lookforid=true) {
|
||||
global $PAGE, $CFG;
|
||||
$id = optional_param('id', null);
|
||||
$id = optional_param('id', null, PARAM_INT);
|
||||
if ($lookforid && $id!==null) {
|
||||
if (!empty($CFG->navshowallcourses)) {
|
||||
$this->load_categories();
|
||||
@@ -2328,13 +2328,25 @@ class navbar extends navigation_node {
|
||||
// For screen readers
|
||||
$output = get_accesshide(get_string('youarehere','access'), 'h2').html_writer::start_tag('ul');
|
||||
|
||||
$navigationactive = $this->page->navigation->contains_active_node();
|
||||
$settingsactive = $this->page->settingsnav->contains_active_node();
|
||||
|
||||
// Check if navigation contains the active node
|
||||
if (!$this->ignoreactive && $this->page->navigation->contains_active_node()) {
|
||||
// Parse the navigation tree to get the active node
|
||||
$output .= $this->parse_branch_to_html($this->page->navigation->children, true);
|
||||
} else if (!$this->ignoreactive && $this->page->settingsnav->contains_active_node()) {
|
||||
// Parse the settings navigation to get the active node
|
||||
$output .= $this->parse_branch_to_html($this->page->settingsnav->children, true);
|
||||
if (!$this->ignoreactive) {
|
||||
if ($navigationactive && $settingsactive) {
|
||||
// Parse a combined navigation tree
|
||||
$output .= $this->parse_branch_to_html($this->page->navigation->children, true, true);
|
||||
$activenode = $this->page->settingsnav->find_active_node();
|
||||
if ($activenode) {
|
||||
$output .= $this->parse_branch_to_html(array($activenode), false);
|
||||
}
|
||||
} else if ($navigationactive) {
|
||||
// Parse the navigation tree to get the active node
|
||||
$output .= $this->parse_branch_to_html($this->page->navigation->children, true);
|
||||
} else if ($settingsactive) {
|
||||
// Parse the settings navigation to get the active node
|
||||
$output .= $this->parse_branch_to_html($this->page->settingsnav->children, true);
|
||||
}
|
||||
} else {
|
||||
$output .= $this->parse_branch_to_html($this, true);
|
||||
}
|
||||
@@ -2355,7 +2367,7 @@ class navbar extends navigation_node {
|
||||
* @param bool $firstnode
|
||||
* @return string HTML
|
||||
*/
|
||||
protected function parse_branch_to_html($navarray, $firstnode=true) {
|
||||
protected function parse_branch_to_html($navarray, $firstnode=true, $morecoming=false) {
|
||||
global $CFG;
|
||||
$separator = get_separator();
|
||||
$output = '';
|
||||
@@ -2396,7 +2408,7 @@ class navbar extends navigation_node {
|
||||
$navarray = $child->children;
|
||||
// If there are not more arrays being processed after this AND this is the last element
|
||||
// then we want to set the action to null so that it is not used
|
||||
if (empty($this->children) && (!$child->contains_active_node() || ($child->find_active_node()==false || $child->find_active_node()->mainnavonly))) {
|
||||
if (empty($this->children) && !$morecoming && (!$child->contains_active_node() || ($child->find_active_node()==false || $child->find_active_node()->mainnavonly))) {
|
||||
$oldaction = $child->action;
|
||||
$child->action = null;
|
||||
}
|
||||
@@ -2487,67 +2499,56 @@ class settings_navigation extends navigation_node {
|
||||
* by calling supporting functions to generate major parts of the tree.
|
||||
*/
|
||||
public function initialise() {
|
||||
global $DB;
|
||||
|
||||
if (during_initial_install()) {
|
||||
return false;
|
||||
}
|
||||
$this->id = 'settingsnav';
|
||||
$this->context = $this->page->context;
|
||||
switch ($this->context->contextlevel) {
|
||||
|
||||
$context = $this->context;
|
||||
if ($context->contextlevel == CONTEXT_BLOCK) {
|
||||
$this->load_block_settings();
|
||||
$context = $DB->get_record_sql('SELECT ctx.* FROM {block_instances} bi LEFT JOIN {context} ctx ON ctx.id=bi.parentcontextid WHERE bi.id=?', array($context->instanceid));
|
||||
}
|
||||
|
||||
switch ($context->contextlevel) {
|
||||
case CONTEXT_SYSTEM:
|
||||
$this->cache->volatile();
|
||||
$adminkey = $this->load_administration_settings();
|
||||
$settingskey = $this->load_user_settings(SITEID);
|
||||
if ($this->page->url->compare(new moodle_url('/admin/settings.php', array('section'=>'frontpagesettings')))) {
|
||||
$this->load_front_page_settings(($context->id == $this->context->id));
|
||||
}
|
||||
break;
|
||||
case CONTEXT_COURSECAT:
|
||||
$adminkey = $this->load_administration_settings();
|
||||
$adminnode = $this->get($adminkey);
|
||||
if ($adminnode!==false) {
|
||||
$adminnode->forceopen = true;
|
||||
}
|
||||
$settingskey = $this->load_user_settings(SITEID);
|
||||
$this->load_category_settings();
|
||||
break;
|
||||
case CONTEXT_COURSE:
|
||||
case CONTEXT_BLOCK:
|
||||
if ($this->page->course->id!==SITEID) {
|
||||
$coursekey = $this->load_course_settings();
|
||||
$coursenode = $this->get($coursekey);
|
||||
if ($coursenode!==false) {
|
||||
$coursenode->forceopen = true;
|
||||
}
|
||||
$settingskey = $this->load_user_settings($this->page->course->id);
|
||||
$adminkey = $this->load_administration_settings();
|
||||
if ($this->page->course->id != SITEID) {
|
||||
$this->load_course_settings(($context->id == $this->context->id));
|
||||
} else {
|
||||
$this->load_front_page_settings();
|
||||
$settingskey = $this->load_user_settings(SITEID);
|
||||
$adminkey = $this->load_administration_settings();
|
||||
$this->load_front_page_settings(($context->id == $this->context->id));
|
||||
}
|
||||
break;
|
||||
case CONTEXT_MODULE:
|
||||
$modulekey = $this->load_module_settings();
|
||||
$modulenode = $this->get($modulekey);
|
||||
if ($modulenode!==false) {
|
||||
$modulenode->forceopen = true;
|
||||
}
|
||||
$coursekey = $this->load_course_settings();
|
||||
$settingskey = $this->load_user_settings($this->page->course->id);
|
||||
$adminkey = $this->load_administration_settings();
|
||||
$this->load_module_settings();
|
||||
$this->load_course_settings();
|
||||
break;
|
||||
case CONTEXT_USER:
|
||||
$settingskey = $this->load_user_settings($this->page->course->id);
|
||||
$settingsnode = $this->get($settingskey);
|
||||
if ($settingsnode!==false) {
|
||||
$settingsnode->forceopen = true;
|
||||
if ($this->page->course->id != SITEID) {
|
||||
$this->load_course_settings();
|
||||
}
|
||||
if ($this->page->course->id!==SITEID) {
|
||||
$coursekey = $this->load_course_settings();
|
||||
}
|
||||
$adminkey = $this->load_administration_settings();
|
||||
break;
|
||||
default:
|
||||
debugging('An unknown context has passed into settings_navigation::initialise', DEBUG_DEVELOPER);
|
||||
break;
|
||||
}
|
||||
|
||||
$settingskey = $this->load_user_settings($this->page->course->id);
|
||||
$adminkey = $this->load_administration_settings();
|
||||
|
||||
if ($context->contextlevel == CONTEXT_SYSTEM) {
|
||||
$this->get($adminkey)->forceopen = true;
|
||||
} else if ($context->contextlevel == CONTEXT_USER) {
|
||||
$this->get($settingskey)->forceopen = true;
|
||||
}
|
||||
|
||||
// Check if the user is currently logged in as another user
|
||||
if (session_is_loggedinas()) {
|
||||
// Get the actual user, we need this so we can display an informative return link
|
||||
@@ -2757,9 +2758,10 @@ class settings_navigation extends navigation_node {
|
||||
/**
|
||||
* This function loads the course settings that are available for the user
|
||||
*
|
||||
* @param bool $forceopen If set to true the course node will be forced open
|
||||
* @return bool|mixed Either false of a key to access the course tree by
|
||||
*/
|
||||
protected function load_course_settings() {
|
||||
protected function load_course_settings($forceopen = false) {
|
||||
global $CFG, $USER, $SESSION;
|
||||
|
||||
$course = $this->page->course;
|
||||
@@ -2776,10 +2778,9 @@ class settings_navigation extends navigation_node {
|
||||
return false;
|
||||
}
|
||||
|
||||
$coursenode = $this->page->navigation->find_child($course->id, global_navigation::TYPE_COURSE);
|
||||
|
||||
$coursenodekey = $this->add(get_string('courseadministration'), null, $coursenode->type, null, 'courseadmin');
|
||||
$coursenodekey = $this->add(get_string('courseadministration'), null, self::TYPE_COURSE, null, 'courseadmin');
|
||||
$coursenode = $this->get($coursenodekey);
|
||||
$coursenode->forceopen = ($forceopen==true);
|
||||
|
||||
if (has_capability('moodle/course:update', $course->context)) {
|
||||
// Add the turn on/off settings
|
||||
@@ -2879,13 +2880,25 @@ class settings_navigation extends navigation_node {
|
||||
$coursenode->add(get_string('settings'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/settings', ''));
|
||||
}
|
||||
|
||||
// Add assign or override roles if allowed
|
||||
if (has_capability('moodle/role:assign', $course->context)) {
|
||||
$url = new moodle_url('/admin/roles/assign.php', array('contextid'=>$course->context->id));
|
||||
// Add assign or override roles if allowed
|
||||
$url = new moodle_url('/'.$CFG->admin.'/roles/assign.php', array('contextid'=>$course->context->id));
|
||||
$coursenode->add(get_string('assignroles', 'role'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/roles', ''));
|
||||
} else if (get_overridable_roles($course->context, ROLENAME_ORIGINAL)) {
|
||||
$url = new moodle_url('/admin/roles/override.php', array('contextid'=>$course->context->id));
|
||||
$coursenode->add(get_string('overridepermissions', 'role'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/roles', ''));
|
||||
// Override roles
|
||||
if (has_capability('moodle/role:review', $course->context) or count(get_overridable_roles($course->context))>0) {
|
||||
$url = new moodle_url('/'.$CFG->admin.'/roles/permissions.php', array('contextid'=>$course->context->id));
|
||||
$coursenode->add(get_string('permissions', 'role'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/roles', ''));
|
||||
}
|
||||
// Check role permissions
|
||||
if (has_any_capability(array('moodle/role:assign', 'moodle/role:safeoverride','moodle/role:override', 'moodle/role:assign'), $course->context)) {
|
||||
$url = new moodle_url('/'.$CFG->admin.'/roles/check.php', array('contextid'=>$course->context->id));
|
||||
$coursenode->add(get_string('checkpermissions', 'role'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/roles', ''));
|
||||
}
|
||||
// Manage filters
|
||||
if (has_capability('moodle/filter:manage', $course->context) && count(filter_get_available_in_context($course->context))>0) {
|
||||
$url = new moodle_url('/filter/manage.php', array('contextid'=>$course->context->id));
|
||||
$coursenode->add(get_string('filters', 'admin'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/filter', ''));
|
||||
}
|
||||
}
|
||||
|
||||
// Add view grade report is permitted
|
||||
@@ -3069,7 +3082,7 @@ class settings_navigation extends navigation_node {
|
||||
global $CFG;
|
||||
|
||||
if (!$this->page->cm && $this->context->contextlevel == CONTEXT_MODULE && $this->context->instanceid) {
|
||||
$cm = get_coursemodule_from_id('chat', $this->context->instanceid, 0, false, MUST_EXIST);
|
||||
$cm = get_coursemodule_from_id(false, $this->context->instanceid, 0, false, MUST_EXIST);
|
||||
$cm->context = $this->context;
|
||||
$this->page->set_cm($cm, $this->page->course);
|
||||
}
|
||||
@@ -3082,6 +3095,36 @@ class settings_navigation extends navigation_node {
|
||||
}
|
||||
}
|
||||
|
||||
$modulekey = $this->add(get_string($this->page->activityname.'administration', $this->page->activityname));
|
||||
$modulenode = $this->get($modulekey);
|
||||
$modulenode->forceopen = true;
|
||||
|
||||
// Settings for the module
|
||||
if (has_capability('moodle/course:manageactivities', $this->page->cm->context)) {
|
||||
$url = new moodle_url('/course/modedit.php', array('update' => $this->page->cm->id, 'return' => true, 'sesskey' => sesskey()));
|
||||
$modulenode->add(get_string('settings'), $url, navigation_node::TYPE_SETTING);
|
||||
}
|
||||
// Assign local roles
|
||||
if (count(get_assignable_roles($this->page->cm->context))>0) {
|
||||
$url = new moodle_url('/'.$CFG->admin.'/roles/assign.php', array('contextid'=>$this->page->cm->context->id));
|
||||
$modulenode->add(get_string('localroles', 'role'), $url, self::TYPE_SETTING);
|
||||
}
|
||||
// Override roles
|
||||
if (has_capability('moodle/role:review', $this->page->cm->context) or count(get_overridable_roles($this->page->cm->context))>0) {
|
||||
$url = new moodle_url('/'.$CFG->admin.'/roles/permissions.php', array('contextid'=>$this->page->cm->context->id));
|
||||
$modulenode->add(get_string('permissions', 'role'), $url, self::TYPE_SETTING);
|
||||
}
|
||||
// Check role permissions
|
||||
if (has_any_capability(array('moodle/role:assign', 'moodle/role:safeoverride','moodle/role:override', 'moodle/role:assign'), $this->page->cm->context)) {
|
||||
$url = new moodle_url('/'.$CFG->admin.'/roles/check.php', array('contextid'=>$this->page->cm->context->id));
|
||||
$modulenode->add(get_string('checkpermissions', 'role'), $url, self::TYPE_SETTING);
|
||||
}
|
||||
// Manage filters
|
||||
if (has_capability('moodle/filter:manage', $this->page->cm->context) && count(filter_get_available_in_context($this->page->cm->context))>0) {
|
||||
$url = new moodle_url('/filter/manage.php', array('contextid'=>$this->page->cm->context->id));
|
||||
$modulenode->add(get_string('filters', 'admin'), $url, self::TYPE_SETTING);
|
||||
}
|
||||
|
||||
$file = $CFG->dirroot.'/mod/'.$this->page->activityname.'/lib.php';
|
||||
$function = $this->page->activityname.'_extend_settings_navigation';
|
||||
|
||||
@@ -3089,9 +3132,17 @@ class settings_navigation extends navigation_node {
|
||||
require_once($file);
|
||||
}
|
||||
if (!function_exists($function)) {
|
||||
return;
|
||||
return $modulekey;
|
||||
}
|
||||
return $function($this,$this->page->activityrecord);
|
||||
|
||||
$function($this, $modulenode);
|
||||
|
||||
// Remove the module node if there are no children
|
||||
if (empty($modulenode->children)) {
|
||||
$this->remove_child($modulekey);
|
||||
}
|
||||
|
||||
return $modulekey;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3107,7 +3158,7 @@ class settings_navigation extends navigation_node {
|
||||
* @param int $courseid The course id of the current course
|
||||
*/
|
||||
protected function load_user_settings($courseid=SITEID) {
|
||||
global $USER, $FULLME;
|
||||
global $USER, $FULLME, $CFG;
|
||||
|
||||
if (isguestuser() || !isloggedin()) {
|
||||
return false;
|
||||
@@ -3118,22 +3169,24 @@ class settings_navigation extends navigation_node {
|
||||
// and the key depends on the current location
|
||||
// Default to look at id
|
||||
$userkey='id';
|
||||
if ($this->context->contextlevel >= CONTEXT_COURSECAT && strpos($FULLME, '/message/')===false && strpos($FULLME, '/mod/forum/user')===false) {
|
||||
|
||||
if (strpos($FULLME,'/blog/') || strpos($FULLME, $CFG->admin.'/roles/')) {
|
||||
// And blog and roles just do thier own thing using `userid`
|
||||
$userkey = 'userid';
|
||||
} else if ($this->context->contextlevel >= CONTEXT_COURSECAT && strpos($FULLME, '/message/')===false && strpos($FULLME, '/mod/forum/user')===false) {
|
||||
// If we have a course context and we are not in message or forum
|
||||
// Message and forum both pick the user up from `id`
|
||||
$userkey = 'user';
|
||||
} else if (strpos($FULLME,'/blog/') || strpos($FULLME, '/roles/')) {
|
||||
// And blog and roles just do thier own thing using `userid`
|
||||
$userkey = 'userid';
|
||||
}
|
||||
|
||||
$userid = optional_param($userkey, $USER->id, PARAM_INT);
|
||||
if ($userid!=$USER->id) {
|
||||
$this->generate_user_settings($courseid,$userid,'userviewingsettings');
|
||||
$this->generate_user_settings($courseid,$USER->id);
|
||||
$userkey = $this->generate_user_settings($courseid, $userid, 'userviewingsettings');
|
||||
$this->generate_user_settings($courseid, $USER->id);
|
||||
} else {
|
||||
$this->generate_user_settings($courseid,$USER->id);
|
||||
$userkey = $this->generate_user_settings($courseid, $USER->id);
|
||||
}
|
||||
return $userkey;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3252,16 +3305,15 @@ class settings_navigation extends navigation_node {
|
||||
$usersetting->get($roleskey)->add(get_string('thisusersroles', 'role'), $url, self::TYPE_SETTING);
|
||||
|
||||
$assignableroles = get_assignable_roles($usercontext, ROLENAME_BOTH);
|
||||
$overridableroles = get_overridable_roles($usercontext, ROLENAME_BOTH);
|
||||
|
||||
if (!empty($assignableroles)) {
|
||||
$url = new moodle_url('/admin/roles/assign.php', array('contextid'=>$usercontext->id,'userid'=>$user->id, 'courseid'=>$course->id));
|
||||
$usersetting->get($roleskey)->add(get_string('assignrolesrelativetothisuser', 'role'), $url, self::TYPE_SETTING);
|
||||
}
|
||||
|
||||
if (!empty($overridableroles)) {
|
||||
$url = new moodle_url('/admin/roles/override.php', array('contextid'=>$usercontext->id,'userid'=>$user->id, 'courseid'=>$course->id));
|
||||
$usersetting->get($roleskey)->add(get_string('overridepermissions', 'role'), $url, self::TYPE_SETTING);
|
||||
if (has_capability('moodle/role:review', $usercontext) || count(get_overridable_roles($usercontext, ROLENAME_BOTH))>0) {
|
||||
$url = new moodle_url('/admin/roles/permissions.php', array('contextid'=>$usercontext->id,'userid'=>$user->id, 'courseid'=>$course->id));
|
||||
$usersetting->get($roleskey)->add(get_string('permissions', 'role'), $url, self::TYPE_SETTING);
|
||||
}
|
||||
|
||||
$url = new moodle_url('/admin/roles/check.php', array('contextid'=>$usercontext->id,'userid'=>$user->id, 'courseid'=>$course->id));
|
||||
@@ -3303,6 +3355,71 @@ class settings_navigation extends navigation_node {
|
||||
return $usersettingskey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads block specific settings in the navigation
|
||||
*
|
||||
* @return string The key that can be used to retrieve the navigation node
|
||||
*/
|
||||
protected function load_block_settings() {
|
||||
global $CFG;
|
||||
|
||||
$blocksettingskey = $this->add(print_context_name($this->context));
|
||||
$blocknode = $this->get($blocksettingskey);
|
||||
$blocknode->forceopen = true;
|
||||
|
||||
// Assign local roles
|
||||
$assignurl = new moodle_url('/'.$CFG->admin.'/roles/assign.php', array('contextid'=>$this->context->id));
|
||||
$blocknode->add(get_string('assignroles', 'role'), $assignurl, self::TYPE_SETTING);
|
||||
|
||||
// Override roles
|
||||
if (has_capability('moodle/role:review', $this->context) or count(get_overridable_roles($this->context))>0) {
|
||||
$url = new moodle_url('/'.$CFG->admin.'/roles/permissions.php', array('contextid'=>$this->context->id));
|
||||
$blocknode->add(get_string('permissions', 'role'), $url, self::TYPE_SETTING);
|
||||
}
|
||||
// Check role permissions
|
||||
if (has_any_capability(array('moodle/role:assign', 'moodle/role:safeoverride','moodle/role:override', 'moodle/role:assign'), $this->context)) {
|
||||
$url = new moodle_url('/'.$CFG->admin.'/roles/check.php', array('contextid'=>$this->context->id));
|
||||
$blocknode->add(get_string('checkpermissions', 'role'), $url, self::TYPE_SETTING);
|
||||
}
|
||||
|
||||
return $blocksettingskey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads category specific settings in the navigation
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function load_category_settings() {
|
||||
global $CFG;
|
||||
|
||||
$blocksettingskey = $this->add(print_context_name($this->context));
|
||||
$blocknode = $this->get($blocksettingskey);
|
||||
$blocknode->forceopen = true;
|
||||
|
||||
if ($this->page->user_is_editing() && has_capability('moodle/category:manage', $this->context)) {
|
||||
$blocknode->add(get_string('editcategorythis'), new moodle_url('/course/editcategory.php', array('id' => $this->context->instanceid)));
|
||||
$blocknode->add(get_string('addsubcategory'), new moodle_url('/course/editcategory.php', array('parent' => $this->context->instanceid)));
|
||||
}
|
||||
|
||||
// Assign local roles
|
||||
$assignurl = new moodle_url('/'.$CFG->admin.'/roles/assign.php', array('contextid'=>$this->context->id));
|
||||
$blocknode->add(get_string('assignroles', 'role'), $assignurl, self::TYPE_SETTING);
|
||||
|
||||
// Override roles
|
||||
if (has_capability('moodle/role:review', $this->context) or count(get_overridable_roles($this->context))>0) {
|
||||
$url = new moodle_url('/'.$CFG->admin.'/roles/permissions.php', array('contextid'=>$this->context->id));
|
||||
$blocknode->add(get_string('permissions', 'role'), $url, self::TYPE_SETTING);
|
||||
}
|
||||
// Check role permissions
|
||||
if (has_any_capability(array('moodle/role:assign', 'moodle/role:safeoverride','moodle/role:override', 'moodle/role:assign'), $this->context)) {
|
||||
$url = new moodle_url('/'.$CFG->admin.'/roles/check.php', array('contextid'=>$this->context->id));
|
||||
$blocknode->add(get_string('checkpermissions', 'role'), $url, self::TYPE_SETTING);
|
||||
}
|
||||
|
||||
return $blocksettingskey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user is assuming another role
|
||||
*
|
||||
@@ -3332,20 +3449,20 @@ class settings_navigation extends navigation_node {
|
||||
* This function loads all of the front page settings into the settings navigation.
|
||||
* This function is called when the user is on the front page, or $COURSE==$SITE
|
||||
*/
|
||||
protected function load_front_page_settings() {
|
||||
global $SITE;
|
||||
protected function load_front_page_settings($forceopen = false) {
|
||||
global $SITE, $CFG;
|
||||
|
||||
$course = $SITE;
|
||||
$course = clone($SITE);
|
||||
if (empty($course->context)) {
|
||||
$course->context = get_context_instance(CONTEXT_COURSE, $course->id); // Course context
|
||||
}
|
||||
|
||||
$frontpagekey = $this->add(get_string('frontpagesettings'), null, self::TYPE_SETTING, null, 'frontpage');
|
||||
$frontpage = $this->get($frontpagekey);
|
||||
$frontpage->forceopen = $forceopen;
|
||||
$frontpage->id = 'frontpagesettings';
|
||||
|
||||
if (has_capability('moodle/course:update', $course->context)) {
|
||||
$frontpage->id = 'frontpagesettings';
|
||||
$frontpage->forceopen = true;
|
||||
|
||||
// Add the turn on/off settings
|
||||
$url = new moodle_url('/course/view.php', array('id'=>$course->id, 'sesskey'=>sesskey()));
|
||||
@@ -3368,8 +3485,65 @@ class settings_navigation extends navigation_node {
|
||||
$url = new moodle_url('/user/index.php', array('contextid'=>$course->context->id));
|
||||
$frontpage->add(get_string('participants'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/users', ''));
|
||||
}
|
||||
}
|
||||
|
||||
// Roles
|
||||
if (has_capability('moodle/role:assign', $course->context)) {
|
||||
// Add assign or override roles if allowed
|
||||
$url = new moodle_url('/'.$CFG->admin.'/roles/assign.php', array('contextid'=>$course->context->id));
|
||||
$frontpage->add(get_string('assignroles', 'role'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/roles', ''));
|
||||
// Override roles
|
||||
if (has_capability('moodle/role:review', $course->context) or count(get_overridable_roles($course->context))>0) {
|
||||
$url = new moodle_url('/'.$CFG->admin.'/roles/permissions.php', array('contextid'=>$course->context->id));
|
||||
$frontpage->add(get_string('permissions', 'role'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/roles', ''));
|
||||
}
|
||||
// Check role permissions
|
||||
if (has_any_capability(array('moodle/role:assign', 'moodle/role:safeoverride','moodle/role:override', 'moodle/role:assign'), $course->context)) {
|
||||
$url = new moodle_url('/'.$CFG->admin.'/roles/check.php', array('contextid'=>$course->context->id));
|
||||
$frontpage->add(get_string('checkpermissions', 'role'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/roles', ''));
|
||||
}
|
||||
// Manage filters
|
||||
if (has_capability('moodle/filter:manage', $course->context) && count(filter_get_available_in_context($course->context))>0) {
|
||||
$url = new moodle_url('/filter/manage.php', array('contextid'=>$course->context->id));
|
||||
$frontpage->add(get_string('filters', 'admin'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/filter', ''));
|
||||
}
|
||||
}
|
||||
|
||||
// Backup this course
|
||||
if (has_capability('moodle/backup:backupcourse', $course->context)) {
|
||||
$url = new moodle_url('/backup/backup.php', array('id'=>$course->id));
|
||||
$frontpage->add(get_string('backup'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/backup', ''));
|
||||
}
|
||||
|
||||
// Restore to this course
|
||||
if (has_capability('moodle/restore:restorecourse', $course->context)) {
|
||||
$url = new moodle_url('/files/index.php', array('id'=>$course->id, 'wdir'=>'/backupdata'));
|
||||
$frontpage->add(get_string('restore'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/restore', ''));
|
||||
}
|
||||
|
||||
// Manage questions
|
||||
$questioncaps = array('moodle/question:add',
|
||||
'moodle/question:editmine',
|
||||
'moodle/question:editall',
|
||||
'moodle/question:viewmine',
|
||||
'moodle/question:viewall',
|
||||
'moodle/question:movemine',
|
||||
'moodle/question:moveall');
|
||||
if (has_any_capability($questioncaps, $this->context)) {
|
||||
$questionlink = $CFG->wwwroot.'/question/edit.php';
|
||||
} else if (has_capability('moodle/question:managecategory', $this->context)) {
|
||||
$questionlink = $CFG->wwwroot.'/question/category.php';
|
||||
}
|
||||
if (isset($questionlink)) {
|
||||
$url = new moodle_url($questionlink, array('courseid'=>$course->id));
|
||||
$frontpage->add(get_string('questions','quiz'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/questions', ''));
|
||||
}
|
||||
|
||||
// Manage files
|
||||
if (has_capability('moodle/course:managefiles', $this->context)) {
|
||||
$url = new moodle_url('/files/index.php', array('id'=>$course->id));
|
||||
$frontpage->add(get_string('files'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/files', ''));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function removes all root branches that have no children
|
||||
|
||||
+8
-19
@@ -3346,20 +3346,21 @@ function assignment_supports($feature) {
|
||||
}
|
||||
}
|
||||
|
||||
function assignment_extend_settings_navigation($navnode, $module) {
|
||||
/**
|
||||
* Adds module specific settings to the settings block
|
||||
*
|
||||
* @param settings_navigation $settings The settings navigation object
|
||||
* @param navigation_node $assignmentnode The node to add module settings to
|
||||
*/
|
||||
function assignment_extend_settings_navigation(settings_navigation $settings, navigation_node $assignmentnode) {
|
||||
global $PAGE, $DB, $USER, $CFG;
|
||||
|
||||
$allgroups = false;
|
||||
|
||||
$assignmentrow = $DB->get_record("assignment", array("id" => $PAGE->cm->instance));
|
||||
require_once "$CFG->dirroot/mod/assignment/type/$assignmentrow->assignmenttype/assignment.class.php";
|
||||
|
||||
$assignmentclass = 'assignment_'.$assignmentrow->assignmenttype;
|
||||
$assignmentinstance = new $assignmentclass($PAGE->cm->id, $assignmentrow, $PAGE->cm, $PAGE->course);
|
||||
|
||||
$assignmentnodekey = $navnode->add(get_string('assignmentadministration', 'assignment'));
|
||||
$assignmentnode = $navnode->get($assignmentnodekey);
|
||||
$assignmentnode->forceopen = true;
|
||||
|
||||
if (!empty($USER->id) && !has_capability('moodle/legacy:guest', $PAGE->cm->context, NULL, false)) {
|
||||
|
||||
$allgroups = false;
|
||||
@@ -3383,17 +3384,5 @@ function assignment_extend_settings_navigation($navnode, $module) {
|
||||
if (is_object($assignmentinstance) && method_exists($assignmentinstance, 'extend_settings_navigation')) {
|
||||
$assignmentinstance->extend_settings_navigation($assignmentnode);
|
||||
}
|
||||
|
||||
// Add update this activity link
|
||||
if (has_capability('moodle/course:manageactivities', $PAGE->cm->context)) {
|
||||
$modulename = get_string('modulename', 'assignment');
|
||||
$string = get_string('updatethis', '', $modulename);
|
||||
$url = new moodle_url("$CFG->wwwroot/course/mod.php", array('update' => $PAGE->cm->id, 'return' => true, 'sesskey' => sesskey()));
|
||||
$assignmentnode->add($string, $url, navigation_node::TYPE_SETTING);
|
||||
}
|
||||
|
||||
if (count($assignmentnode->children)<1) {
|
||||
$navnode->remove_child($assignmentnodekey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+15
-13
@@ -1231,9 +1231,11 @@ function chat_supports($feature) {
|
||||
|
||||
function chat_extend_navigation($navigation, $course, $module, $cm) {
|
||||
global $CFG, $USER, $PAGE, $OUTPUT;
|
||||
|
||||
$currentgroup = groups_get_activity_group($cm, true);
|
||||
|
||||
if (has_capability('mod/chat:chat',$cm->context)) {
|
||||
$strenterchat = get_string('enterchat', 'chat');
|
||||
$currentgroup = groups_get_activity_group($cm, true);
|
||||
|
||||
$target = $CFG->wwwroot.'/mod/chat/';
|
||||
$params = array('id'=>$cm->instance);
|
||||
@@ -1281,15 +1283,19 @@ function chat_extend_navigation($navigation, $course, $module, $cm) {
|
||||
}
|
||||
}
|
||||
|
||||
function chat_extend_settings_navigation($settingsnav, $module) {
|
||||
global $DB, $PAGE, $USER, $CFG;
|
||||
/**
|
||||
* Adds module specific settings to the settings block
|
||||
*
|
||||
* @param settings_navigation $settings The settings navigation object
|
||||
* @param navigation_node $chatnode The node to add module settings to
|
||||
*/
|
||||
function chat_extend_settings_navigation(settings_navigation $settings, navigation_node $chatnode) {
|
||||
global $DB, $PAGE, $USER;
|
||||
$chat = $DB->get_record("chat", array("id" => $PAGE->cm->instance));
|
||||
$chatnavkey = $settingsnav->add(get_string('chatadministration', 'chat'));
|
||||
$chatnav = $settingsnav->get($chatnavkey);
|
||||
$chatnav->forceopen = true;
|
||||
|
||||
if ($chat->chattime && $chat->schedule) {
|
||||
$key = $chatnav->add(get_string('nextsession', 'chat').': '.userdate($chat->chattime).' ('.usertimezone($USER->timezone));
|
||||
$chatnav->get($key)->add_class('note');
|
||||
$key = $chatnode->add(get_string('nextsession', 'chat').': '.userdate($chat->chattime).' ('.usertimezone($USER->timezone));
|
||||
$chatnode->get($key)->add_class('note');
|
||||
}
|
||||
|
||||
$currentgroup = groups_get_activity_group($PAGE->cm, true);
|
||||
@@ -1301,11 +1307,7 @@ function chat_extend_settings_navigation($settingsnav, $module) {
|
||||
|
||||
if ($chat->studentlogs || has_capability('mod/chat:readlog',$PAGE->cm->context)) {
|
||||
if ($DB->get_records_select('chat_messages', "chatid = ? $groupselect", array($chat->id))) {
|
||||
$chatnav->add(get_string('viewreport', 'chat'), new moodle_url('/mod/chat/report.php', array('id'=>$PAGE->cm->id)));
|
||||
$chatnode->add(get_string('viewreport', 'chat'), new moodle_url('/mod/chat/report.php', array('id'=>$PAGE->cm->id)));
|
||||
}
|
||||
}
|
||||
|
||||
if (has_capability('moodle/course:manageactivities', $PAGE->cm->context)) {
|
||||
$chatnav->add(get_string('updatethis', '', get_string('modulename', 'chat')), new moodle_url('/course/mod.php', array('update' => $PAGE->cm->id, 'return' => true, 'sesskey' => sesskey())));
|
||||
}
|
||||
}
|
||||
|
||||
+10
-12
@@ -921,12 +921,14 @@ function choice_supports($feature) {
|
||||
}
|
||||
}
|
||||
|
||||
function choice_extend_settings_navigation($settings, $module) {
|
||||
global $PAGE, $OUTPUT, $CFG;
|
||||
|
||||
$choicenavkey = $settings->add(get_string('choiceadministration', 'choice'));
|
||||
$choicenav = $settings->get($choicenavkey);
|
||||
$choicenav->forceopen = true;
|
||||
/**
|
||||
* Adds module specific settings to the settings block
|
||||
*
|
||||
* @param settings_navigation $settings The settings navigation object
|
||||
* @param navigation_node $choicenode The node to add module settings to
|
||||
*/
|
||||
function choice_extend_settings_navigation(settings_navigation $settings, navigation_node $choicenode) {
|
||||
global $PAGE;
|
||||
|
||||
if (has_capability('mod/choice:readresponses', $PAGE->cm->context)) {
|
||||
|
||||
@@ -945,10 +947,6 @@ function choice_extend_settings_navigation($settings, $module) {
|
||||
$responsecount += count($userlist);
|
||||
}
|
||||
}
|
||||
$choicenav->add(get_string("viewallresponses", "choice", $responsecount), new moodle_url('/mod/choice/report.php', array('id'=>$PAGE->cm->id)));
|
||||
$choicenode->add(get_string("viewallresponses", "choice", $responsecount), new moodle_url('/mod/choice/report.php', array('id'=>$PAGE->cm->id)));
|
||||
}
|
||||
|
||||
if (has_capability('moodle/course:manageactivities', $PAGE->cm->context)) {
|
||||
$choicenav->add(get_string('updatethis', '', get_string('modulename', 'choice')), new moodle_url('/course/mod.php', array('update' => $PAGE->cm->id, 'return' => true, 'sesskey' => sesskey())));
|
||||
}
|
||||
}
|
||||
}
|
||||
+14
-16
@@ -2856,17 +2856,19 @@ function data_extend_navigation($navigation, $course, $module, $cm) {
|
||||
$navigation->add(get_string('search', 'data'), new moodle_url('/mod/data/view.php', array('d'=>$cm->instance, 'mode'=>'search')));
|
||||
}
|
||||
|
||||
function data_extend_settings_navigation($settings, $module) {
|
||||
global $PAGE, $OUTPUT, $CFG;
|
||||
/**
|
||||
* Adds module specific settings to the settings block
|
||||
*
|
||||
* @param settings_navigation $settings The settings navigation object
|
||||
* @param navigation_node $datanode The node to add module settings to
|
||||
*/
|
||||
function data_extend_settings_navigation(settings_navigation $settings, navigation_node $datanode) {
|
||||
global $PAGE;
|
||||
|
||||
// We only actually need the id here for functions
|
||||
$data = new stdClass;
|
||||
$data->id = $PAGE->cm->instance;
|
||||
|
||||
$datanavkey = $settings->add(get_string('dataadministration', 'data'));
|
||||
$datanav = $settings->get($datanavkey);
|
||||
$datanav->forceopen = true;
|
||||
|
||||
$currentgroup = groups_get_activity_group($PAGE->cm);
|
||||
$groupmode = groups_get_activity_groupmode($PAGE->cm);
|
||||
|
||||
@@ -2876,13 +2878,13 @@ function data_extend_settings_navigation($settings, $module) {
|
||||
} else {
|
||||
$addstring = get_string('editentry', 'data');
|
||||
}
|
||||
$datanav->add($addstring, new moodle_url('/mod/data/edit.php', array('d'=>$PAGE->cm->instance)));
|
||||
$datanode->add($addstring, new moodle_url('/mod/data/edit.php', array('d'=>$PAGE->cm->instance)));
|
||||
}
|
||||
|
||||
if (has_capability(DATA_CAP_EXPORT, $PAGE->cm->context)) {
|
||||
// The capability required to Export database records is centrally defined in 'lib.php'
|
||||
// and should be weaker than those required to edit Templates, Fields and Presets.
|
||||
$datanav->add(get_string('export', 'data'), new moodle_url('/mod/data/export.php', array('d'=>$data->id)));
|
||||
$datanode->add(get_string('export', 'data'), new moodle_url('/mod/data/export.php', array('d'=>$data->id)));
|
||||
}
|
||||
|
||||
if (has_capability('mod/data:managetemplates', $PAGE->cm->context)) {
|
||||
@@ -2897,19 +2899,15 @@ function data_extend_settings_navigation($settings, $module) {
|
||||
$defaultemplate = 'singletemplate';
|
||||
}
|
||||
|
||||
$templatekey = $datanav->add(get_string('templates', 'data'));
|
||||
$templates = $datanav->get($templatekey);
|
||||
$templatekey = $datanode->add(get_string('templates', 'data'));
|
||||
$templates = $datanode->get($templatekey);
|
||||
|
||||
$templatelist = array ('listtemplate', 'singletemplate', 'asearchtemplate', 'addtemplate', 'rsstemplate', 'csstemplate', 'jstemplate');
|
||||
foreach ($templatelist as $template) {
|
||||
$templates->add(get_string($template, 'data'), new moodle_url('/mod/data/templates.php', array('d'=>$data->id,'mode'=>$template)));
|
||||
}
|
||||
|
||||
$datanav->add(get_string('fields', 'data'), new moodle_url('/mod/data/field.php', array('d'=>$data->id)));
|
||||
$datanav->add(get_string('presets', 'data'), new moodle_url('/mod/data/preset.php', array('d'=>$data->id)));
|
||||
$datanode->add(get_string('fields', 'data'), new moodle_url('/mod/data/field.php', array('d'=>$data->id)));
|
||||
$datanode->add(get_string('presets', 'data'), new moodle_url('/mod/data/preset.php', array('d'=>$data->id)));
|
||||
}
|
||||
|
||||
if (has_capability('moodle/course:manageactivities', $PAGE->cm->context)) {
|
||||
$datanav->add(get_string('updatethis', '', get_string('modulename', 'choice')), new moodle_url('/course/mod.php', array('update' => $PAGE->cm->id, 'return' => true, 'sesskey' => sesskey())));
|
||||
}
|
||||
}
|
||||
|
||||
+17
-19
@@ -2333,40 +2333,38 @@ function feedback_encode_target_url($url) {
|
||||
}
|
||||
}
|
||||
|
||||
function feedback_extend_settings_navigation($settings, $module) {
|
||||
global $PAGE, $USER, $OUTPUT, $CFG, $DB;
|
||||
|
||||
$feedback = $DB->get_record('feedback', array('id'=>$PAGE->cm->instance));
|
||||
$feedbacknavkey = $settings->add(get_string('feedbackadministration', 'feedback'));
|
||||
$feedbacknav = $settings->get($feedbacknavkey);
|
||||
$feedbacknav->forceopen = true;
|
||||
/**
|
||||
* Adds module specific settings to the settings block
|
||||
*
|
||||
* @param settings_navigation $settings The settings navigation object
|
||||
* @param navigation_node $feedbacknode The node to add module settings to
|
||||
*/
|
||||
function feedback_extend_settings_navigation(settings_navigation $settings, navigation_node $feedbacknode) {
|
||||
global $PAGE, $DB;
|
||||
|
||||
$capabilities = feedback_load_capabilities($PAGE->cm->id);
|
||||
|
||||
if($capabilities->edititems) {
|
||||
$qkey = $feedbacknav->add(get_string('questions', 'feedback'));
|
||||
$feedbacknav->get($qkey)->add(get_string('edit_items', 'feedback'), new moodle_url('/mod/feedback/edit.php', array('id'=>$PAGE->cm->id, 'do_show'=>'edit')));
|
||||
$feedbacknav->get($qkey)->add(get_string('export_questions', 'feedback'), new moodle_url('/mod/feedback/export.php', array('id'=>$PAGE->cm->id, 'action'=>'exportfile')));
|
||||
$feedbacknav->get($qkey)->add(get_string('import_questions', 'feedback'), new moodle_url('/mod/feedback/import.php', array('id'=>$PAGE->cm->id)));
|
||||
$feedbacknav->get($qkey)->add(get_string('templates', 'feedback'), new moodle_url('/mod/feedback/edit.php', array('id'=>$PAGE->cm->id, 'do_show'=>'templates')));
|
||||
$qkey = $feedbacknode->add(get_string('questions', 'feedback'));
|
||||
$feedbacknode->get($qkey)->add(get_string('edit_items', 'feedback'), new moodle_url('/mod/feedback/edit.php', array('id'=>$PAGE->cm->id, 'do_show'=>'edit')));
|
||||
$feedbacknode->get($qkey)->add(get_string('export_questions', 'feedback'), new moodle_url('/mod/feedback/export.php', array('id'=>$PAGE->cm->id, 'action'=>'exportfile')));
|
||||
$feedbacknode->get($qkey)->add(get_string('import_questions', 'feedback'), new moodle_url('/mod/feedback/import.php', array('id'=>$PAGE->cm->id)));
|
||||
$feedbacknode->get($qkey)->add(get_string('templates', 'feedback'), new moodle_url('/mod/feedback/edit.php', array('id'=>$PAGE->cm->id, 'do_show'=>'templates')));
|
||||
}
|
||||
|
||||
if($capabilities->viewreports) {
|
||||
$feedback = $DB->get_record('feedback', array('id'=>$PAGE->cm->instance));
|
||||
if($feedback->course == SITEID){
|
||||
$feedbacknav->add(get_string('analysis', 'feedback'), new moodle_url('/mod/feedback/analysis_course.php', array('id'=>$PAGE->cm->id, 'course'=>$PAGE->course->id,'do_show'=>'analysis')));
|
||||
$feedbacknode->add(get_string('analysis', 'feedback'), new moodle_url('/mod/feedback/analysis_course.php', array('id'=>$PAGE->cm->id, 'course'=>$PAGE->course->id,'do_show'=>'analysis')));
|
||||
}else {
|
||||
$feedbacknav->add(get_string('analysis', 'feedback'), new moodle_url('/mod/feedback/analysis.php', array('id'=>$PAGE->cm->id, 'course'=>$PAGE->course->id,'do_show'=>'analysis')));
|
||||
$feedbacknode->add(get_string('analysis', 'feedback'), new moodle_url('/mod/feedback/analysis.php', array('id'=>$PAGE->cm->id, 'course'=>$PAGE->course->id,'do_show'=>'analysis')));
|
||||
}
|
||||
}
|
||||
|
||||
if($capabilities->viewreports) {
|
||||
$feedbacknav->add(get_string('show_entries', 'feedback'), new moodle_url('/mod/feedback/show_entries.php', array('id'=>$PAGE->cm->id, 'do_show'=>'showentries')));
|
||||
$feedbacknode->add(get_string('show_entries', 'feedback'), new moodle_url('/mod/feedback/show_entries.php', array('id'=>$PAGE->cm->id, 'do_show'=>'showentries')));
|
||||
}
|
||||
|
||||
if (has_capability('moodle/course:manageactivities', $PAGE->cm->context)) {
|
||||
$feedbacknav->add(get_string('updatethis', '', get_string('modulename', 'feedback')), new moodle_url('/course/mod.php', array('update' => $PAGE->cm->id, 'return' => true, 'sesskey' => sesskey())));
|
||||
}
|
||||
}
|
||||
|
||||
function feedback_init_feedback_session() {
|
||||
//initialize the feedback-Session - not nice at all!!
|
||||
|
||||
@@ -325,33 +325,4 @@ function folder_extend_navigation($navigation, $course, $module, $cm) {
|
||||
* you content.
|
||||
*/
|
||||
$navigation->nodetype = navigation_node::NODETYPE_LEAF;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function extends the settings navigation block for the site.
|
||||
*
|
||||
* It is safe to rely on PAGE here as we will only ever be within the module
|
||||
* context when this is called.
|
||||
*
|
||||
* @param settings_navigation $settings
|
||||
* @param stdClass $module
|
||||
*/
|
||||
function folder_extend_settings_navigation($settings, $module) {
|
||||
global $PAGE, $CFG;
|
||||
|
||||
// Add a folder node to the settings navigation.
|
||||
$foldernavkey = $settings->add(get_string('folderadministration', 'folder'));
|
||||
$foldernav = $settings->get($foldernavkey);
|
||||
$foldernav->forceopen = true;
|
||||
|
||||
// If the user has the capability add an update this module link for the folder instance
|
||||
if (has_capability('moodle/course:manageactivities', $PAGE->cm->context)) {
|
||||
$url = new moodle_url('/course/mod.php', array('update'=>$PAGE->cm->id, 'return'=>true, 'sesskey'=>sesskey()));
|
||||
$foldernav->add(get_string('updatethis', '', get_string('modulename', 'folder')), $url);
|
||||
}
|
||||
|
||||
// Check if any children have been added. If not remove the node to save on clutter.
|
||||
if (count($foldernav->children)<1) {
|
||||
$settings->remove_child($foldernavkey);
|
||||
}
|
||||
}
|
||||
+18
-31
@@ -8025,18 +8025,13 @@ function forum_extend_navigation($navref, $course, $module, $cm) {
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is used to extend the settings navigation with settings for the module
|
||||
* It is called when the context for the page is a forum module
|
||||
* Adds module specific settings to the settings block
|
||||
*
|
||||
* @param settings_navigation $settingsnav {@link settings_navigation}
|
||||
* @param stdClass $module
|
||||
* @return void|mixed The key to the modules branch
|
||||
* @param settings_navigation $settings The settings navigation object
|
||||
* @param navigation_node $forumnode The node to add module settings to
|
||||
*/
|
||||
function forum_extend_settings_navigation($settingsnav, $module=null) {
|
||||
global $USER, $PAGE, $FULLME, $CFG, $DB, $OUTPUT;
|
||||
$forumkey = $settingsnav->add(get_string('forumadministration', 'forum'));
|
||||
$forum = $settingsnav->get($forumkey);
|
||||
$forum->forceopen = true;
|
||||
function forum_extend_settings_navigation(settings_navigation $settingsnav, navigation_node $forumnode) {
|
||||
global $USER, $PAGE, $CFG, $DB, $OUTPUT;
|
||||
|
||||
$forumobject = $DB->get_record("forum", array("id" => $PAGE->cm->instance));
|
||||
if (empty($PAGE->cm->context)) {
|
||||
@@ -8046,33 +8041,33 @@ function forum_extend_settings_navigation($settingsnav, $module=null) {
|
||||
$notekey = false;
|
||||
$helpbutton = false;
|
||||
if (forum_is_forcesubscribed($forumobject)) {
|
||||
$notekey = $forum->add(get_string("forcessubscribe", 'forum'));
|
||||
$notekey = $forumnode->add(get_string("forcessubscribe", 'forum'));
|
||||
$string = get_string('allowchoice', 'forum');
|
||||
$helpbutton = $OUTPUT->help_icon("subscription", $string, "forum");
|
||||
if (has_capability('mod/forum:managesubscriptions', $PAGE->cm->context)) {
|
||||
$url = new moodle_url('/mod/forum/subscribe.php', array('id'=>$forumobject->id, 'force'=>'no'));
|
||||
$forum->add($string, $url, navigation_node::TYPE_SETTING);
|
||||
$forumnode->add($string, $url, navigation_node::TYPE_SETTING);
|
||||
} else {
|
||||
$forum->add(get_string('everyoneisnowsubscribed', 'forum'), null, navigation_node::TYPE_SETTING);
|
||||
$forumnode->add(get_string('everyoneisnowsubscribed', 'forum'), null, navigation_node::TYPE_SETTING);
|
||||
}
|
||||
} else if ($forumobject->forcesubscribe == FORUM_DISALLOWSUBSCRIBE) {
|
||||
$string = get_string('disallowsubscribe', 'forum');
|
||||
$notekey = $forum->add($string);
|
||||
$notekey = $forumnode->add($string);
|
||||
$helpbutton = $OUTPUT->help_icon("subscription", $string, "forum");
|
||||
} else {
|
||||
$string = get_string("forcesubscribe", "forum");
|
||||
$notekey = $forum->add(get_string("allowsallsubscribe", 'forum'));
|
||||
$notekey = $forumnode->add(get_string("allowsallsubscribe", 'forum'));
|
||||
$helpbutton = $OUTPUT->help_icon("subscription", $string, "forum");
|
||||
|
||||
if (has_capability('mod/forum:managesubscriptions', $PAGE->cm->context)) {
|
||||
$url = new moodle_url('/mod/forum/subscribe.php', array('id'=>$forumobject->id, 'force'=>'yes'));
|
||||
$forum->add($string, $url, navigation_node::TYPE_SETTING);
|
||||
$forumnode->add($string, $url, navigation_node::TYPE_SETTING);
|
||||
} else {
|
||||
$forum->add(get_string('everyonecannowchoose', 'forum'), null, navigation_node::TYPE_SETTING);
|
||||
$forumnode->add(get_string('everyonecannowchoose', 'forum'), null, navigation_node::TYPE_SETTING);
|
||||
}
|
||||
if(has_capability('mod/forum:viewsubscribers', $PAGE->cm->context)){
|
||||
$url = new moodle_url('/mod/forum/subscribers.php', array('id'=>$forumobject->id));
|
||||
$forum->add(get_string('showsubscribers', 'forum'), $url, navigation_node::TYPE_SETTING);
|
||||
$forumnode->add(get_string('showsubscribers', 'forum'), $url, navigation_node::TYPE_SETTING);
|
||||
}
|
||||
|
||||
if (forum_is_forcesubscribed($forumobject) || ($forumobject->forcesubscribe == FORUM_DISALLOWSUBSCRIBE && !has_capability('mod/forum:managesubscriptions', $PAGE->cm->context))) {
|
||||
@@ -8084,7 +8079,7 @@ function forum_extend_settings_navigation($settingsnav, $module=null) {
|
||||
$linktext = get_string('subscribe', 'forum');
|
||||
}
|
||||
$url = new moodle_url('/mod/forum/subscribe.php', array('id'=>$forumobject->id));
|
||||
$forum->add($linktext, $url, navigation_node::TYPE_SETTING);
|
||||
$forumnode->add($linktext, $url, navigation_node::TYPE_SETTING);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8095,21 +8090,15 @@ function forum_extend_settings_navigation($settingsnav, $module=null) {
|
||||
$linktext = get_string('trackforum', 'forum');
|
||||
}
|
||||
$url = new moodle_url('/mod/forum/settracking.php', array('id'=>$forumobject->id));
|
||||
$forum->add($linktext, $url, navigation_node::TYPE_SETTING);
|
||||
$forumnode->add($linktext, $url, navigation_node::TYPE_SETTING);
|
||||
}
|
||||
if ($notekey!==false) {
|
||||
$forum->get($notekey)->add_class('note');
|
||||
$forumnode->get($notekey)->add_class('note');
|
||||
if ($helpbutton!==false) {
|
||||
$forum->get($notekey)->helpbutton = $helpbutton;
|
||||
$forumnode->get($notekey)->helpbutton = $helpbutton;
|
||||
}
|
||||
}
|
||||
if (has_capability('moodle/course:manageactivities', $PAGE->cm->context)) {
|
||||
$modulename = get_string('modulename', 'forum');
|
||||
$string = get_string('updatethis', '', $modulename);
|
||||
$url = new moodle_url("$CFG->wwwroot/course/mod.php", array('update' => $PAGE->cm->id, 'return' => true, 'sesskey' => sesskey()));
|
||||
$forum->add($string, $url, navigation_node::TYPE_SETTING);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($CFG->enablerssfeeds) && !empty($CFG->forum_enablerssfeeds) && $forumobject->rsstype && $forumobject->rssarticles) {
|
||||
|
||||
@@ -8128,10 +8117,8 @@ function forum_extend_settings_navigation($settingsnav, $module=null) {
|
||||
$userid = $USER->id;
|
||||
}
|
||||
$url = new moodle_url(rss_get_url($PAGE->course->id, $userid, "forum", $forumobject->id));
|
||||
$forum->add($string, $url, settings_navigation::TYPE_SETTING, null, null, new pix_icon('i/rss', ''));
|
||||
$forumnode->add($string, $url, settings_navigation::TYPE_SETTING, null, null, new pix_icon('i/rss', ''));
|
||||
}
|
||||
|
||||
return $forumkey;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+11
-13
@@ -2681,33 +2681,31 @@ function glossary_extend_navigation($navigation, $course, $module, $cm) {
|
||||
$navigation->add(get_string('authorview', 'glossary'), new moodle_url('/mod/glossary/view.php', array('id'=>$cm->id, 'mode'=>'author')));
|
||||
}
|
||||
|
||||
function glossary_extend_settings_navigation($settings, $module) {
|
||||
/**
|
||||
* Adds module specific settings to the settings block
|
||||
*
|
||||
* @param settings_navigation $settings The settings navigation object
|
||||
* @param navigation_node $glossarynode The node to add module settings to
|
||||
*/
|
||||
function glossary_extend_settings_navigation(settings_navigation $settings, navigation_node $glossarynode) {
|
||||
global $PAGE, $DB, $CFG;
|
||||
|
||||
$mode = optional_param('mode', '', PARAM_ALPHA);
|
||||
$hook = optional_param('hook', 'ALL', PARAM_CLEAN);
|
||||
|
||||
$glossarynavkey = $settings->add(get_string('glossaryadministration', 'glossary'));
|
||||
$glossarynav = $settings->get($glossarynavkey);
|
||||
$glossarynav->forceopen = true;
|
||||
|
||||
if (has_capability('mod/glossary:import', $PAGE->cm->context)) {
|
||||
$glossarynav->add(get_string('importentries', 'glossary'), new moodle_url('/mod/glossary/import.php', array('id'=>$PAGE->cm->id)));
|
||||
$glossarynode->add(get_string('importentries', 'glossary'), new moodle_url('/mod/glossary/import.php', array('id'=>$PAGE->cm->id)));
|
||||
}
|
||||
|
||||
if (has_capability('mod/glossary:export', $PAGE->cm->context)) {
|
||||
$glossarynav->add(get_string('exportentries', 'glossary'), new moodle_url('/mod/glossary/export.php', array('id'=>$PAGE->cm->id, 'mode'=>$mode, 'hook'=>$hook)));
|
||||
$glossarynode->add(get_string('exportentries', 'glossary'), new moodle_url('/mod/glossary/export.php', array('id'=>$PAGE->cm->id, 'mode'=>$mode, 'hook'=>$hook)));
|
||||
}
|
||||
|
||||
if (has_capability('mod/glossary:approve', $PAGE->cm->context) && ($hiddenentries = $DB->count_records('glossary_entries', array('glossaryid'=>$PAGE->cm->instance, 'approved'=>0)))) {
|
||||
$glossarynav->add(get_string('waitingapproval', 'glossary'), new moodle_url('/mod/glossary/view.php', array('id'=>$PAGE->cm->id, 'mode'=>'approval')));
|
||||
$glossarynode->add(get_string('waitingapproval', 'glossary'), new moodle_url('/mod/glossary/view.php', array('id'=>$PAGE->cm->id, 'mode'=>'approval')));
|
||||
}
|
||||
|
||||
if (has_capability('mod/glossary:write', $PAGE->cm->context)) {
|
||||
$glossarynav->add(get_string('addentry', 'glossary'), new moodle_url('/mod/glossary/edit.php', array('cmid'=>$PAGE->cm->id)));
|
||||
$glossarynode->add(get_string('addentry', 'glossary'), new moodle_url('/mod/glossary/edit.php', array('cmid'=>$PAGE->cm->id)));
|
||||
}
|
||||
|
||||
if (has_capability('moodle/course:manageactivities', $PAGE->cm->context)) {
|
||||
$glossarynav->add(get_string('updatethis', '', get_string('modulename', 'glossary')), new moodle_url('/course/mod.php', array('update' => $PAGE->cm->id, 'return' => true, 'sesskey' => sesskey())));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2997,35 +2997,4 @@ function hotpot_extend_navigation($navigation, $course, $module, $cm) {
|
||||
* you content.
|
||||
*/
|
||||
$navigation->nodetype = navigation_node::NODETYPE_LEAF;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function extends the settings navigation block for the site.
|
||||
*
|
||||
* It is safe to rely on PAGE here as we will only ever be within the module
|
||||
* context when this is called.
|
||||
*
|
||||
* @param settings_navigation $settings
|
||||
* @param stdClass $module
|
||||
*/
|
||||
function hotpot_extend_settings_navigation($settings, $module) {
|
||||
global $PAGE, $CFG, $DB;
|
||||
|
||||
// Load the hotpot instance from the database
|
||||
$hotpot = $DB->get_record('hotpot', array('id'=>$PAGE->cm->instance));
|
||||
// Add a hotpot node to the settings navigation.
|
||||
$hotpotnavkey = $settings->add(get_string('hotpotadministration', 'hotpot'));
|
||||
$hotpotnav = $settings->get($hotpotnavkey);
|
||||
$hotpotnav->forceopen = true;
|
||||
|
||||
// If the user has the capability add an update this module link for the hotpot instance
|
||||
if (has_capability('moodle/course:manageactivities', $PAGE->cm->context)) {
|
||||
$url = new moodle_url('/course/mod.php', array('update'=>$PAGE->cm->id, 'return'=>true, 'sesskey'=>sesskey()));
|
||||
$hotpotnav->add(get_string('updatethis', '', get_string('modulename', 'hotpot')), $url);
|
||||
}
|
||||
|
||||
// Check if any children have been added. If not remove the node to save on clutter.
|
||||
if (count($hotpotnav->children)<1) {
|
||||
$settings->remove_child($hotpotnav);
|
||||
}
|
||||
}
|
||||
@@ -392,33 +392,4 @@ function imscp_extend_navigation($navigation, $course, $module, $cm) {
|
||||
* you content.
|
||||
*/
|
||||
$navigation->nodetype = navigation_node::NODETYPE_LEAF;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function extends the settings navigation block for the site.
|
||||
*
|
||||
* It is safe to rely on PAGE here as we will only ever be within the module
|
||||
* context when this is called.
|
||||
*
|
||||
* @param settings_navigation $settings
|
||||
* @param stdClass $module
|
||||
*/
|
||||
function imscp_extend_settings_navigation($settings, $module) {
|
||||
global $PAGE, $CFG;
|
||||
|
||||
// Add a imscp node to the settings navigation.
|
||||
$imscpnavkey = $settings->add(get_string('imscpadministration', 'imscp'));
|
||||
$imscpnav = $settings->get($imscpnavkey);
|
||||
$imscpnav->forceopen = true;
|
||||
|
||||
// If the user has the capability add an update this module link for the imscp instance
|
||||
if (has_capability('moodle/course:manageactivities', $PAGE->cm->context)) {
|
||||
$imscp = new moodle_url($CFG->wwwroot.'/course/mod.php', array('update'=>$PAGE->cm->id, 'return'=>true, 'sesskey'=>sesskey()));
|
||||
$imscpnav->add(get_string('updatethis', '', get_string('modulename', 'imscp')), $imscp);
|
||||
}
|
||||
|
||||
// Check if any children have been added. If not remove the node to save on clutter.
|
||||
if (count($imscpnav->children)<1) {
|
||||
$settings->remove_child($imscpnavkey);
|
||||
}
|
||||
}
|
||||
+12
-29
@@ -795,58 +795,41 @@ function lesson_extend_navigation($navigation, $course, $module, $cm) {
|
||||
* It is safe to rely on PAGE here as we will only ever be within the module
|
||||
* context when this is called
|
||||
*
|
||||
* @param navigation_node $settings
|
||||
* @param stdClass $module
|
||||
* @param settings_navigation $settings
|
||||
* @param navigation_node $lessonnode
|
||||
*/
|
||||
function lesson_extend_settings_navigation($settings, $module) {
|
||||
global $PAGE, $CFG, $USER, $OUTPUT;
|
||||
|
||||
$lessonnavkey = $settings->add(get_string('lessonadministration', 'lesson'));
|
||||
$lessonnav = $settings->get($lessonnavkey);
|
||||
$lessonnav->forceopen = true;
|
||||
|
||||
if (empty($PAGE->cm->context)) {
|
||||
$PAGE->cm->context = get_context_instance(CONTEXT_MODULE, $PAGE->cm->instance);
|
||||
}
|
||||
function lesson_extend_settings_navigation($settings, $lessonnode) {
|
||||
global $PAGE, $DB;
|
||||
|
||||
$canedit = has_capability('mod/lesson:edit', $PAGE->cm->context);
|
||||
|
||||
$url = new moodle_url('/mod/lesson/view.php', array('id'=>$PAGE->cm->id));
|
||||
$key = $lessonnav->add(get_string('preview', 'lesson'), $url);
|
||||
$key = $lessonnode->add(get_string('preview', 'lesson'), $url);
|
||||
|
||||
if ($canedit) {
|
||||
$url = new moodle_url('/mod/lesson/edit.php', array('id'=>$PAGE->cm->id));
|
||||
$key = $lessonnav->add(get_string('edit', 'lesson'), $url);
|
||||
$key = $lessonnode->add(get_string('edit', 'lesson'), $url);
|
||||
}
|
||||
|
||||
if (has_capability('mod/lesson:manage', $PAGE->cm->context)) {
|
||||
$key = $lessonnav->add(get_string('reports', 'lesson'));
|
||||
$key = $lessonnode->add(get_string('reports', 'lesson'));
|
||||
$url = new moodle_url('/mod/lesson/report.php', array('id'=>$PAGE->cm->id, 'action'=>'reportoverview'));
|
||||
$lessonnav->get($key)->add(get_string('overview', 'lesson'), $url);
|
||||
$lessonnode->get($key)->add(get_string('overview', 'lesson'), $url);
|
||||
$url = new moodle_url('/mod/lesson/report.php', array('id'=>$PAGE->cm->id, 'action'=>'reportdetail'));
|
||||
$lessonnav->get($key)->add(get_string('detailedstats', 'lesson'), $url);
|
||||
$lessonnode->get($key)->add(get_string('detailedstats', 'lesson'), $url);
|
||||
}
|
||||
|
||||
if ($canedit) {
|
||||
$url = new moodle_url('/mod/lesson/essay.php', array('id'=>$PAGE->cm->id));
|
||||
$lessonnav->add(get_string('manualgrading', 'lesson'), $url);
|
||||
$lessonnode->add(get_string('manualgrading', 'lesson'), $url);
|
||||
}
|
||||
|
||||
if ($PAGE->activityrecord->highscores) {
|
||||
$url = new moodle_url('/mod/lesson/highscores.php', array('id'=>$PAGE->cm->id));
|
||||
$lessonnav->add(get_string('highscores', 'lesson'), $url);
|
||||
$lessonnode->add(get_string('highscores', 'lesson'), $url);
|
||||
}
|
||||
|
||||
if (has_capability('moodle/course:manageactivities', $PAGE->cm->context)) {
|
||||
$url = new moodle_url('/course/mod.php', array('update' => $PAGE->cm->id, 'return' => true, 'sesskey' => sesskey()));
|
||||
$lessonnav->add(get_string('updatethis', '', get_string('modulename', 'lesson')), $url);
|
||||
}
|
||||
|
||||
if (count($lessonnav->children)<1) {
|
||||
$settings->remove_child($lessonnavkey);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of available import or export formats
|
||||
*
|
||||
@@ -3115,4 +3098,4 @@ abstract class lesson_add_page_form_base extends moodleform {
|
||||
public function construction_override() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -399,32 +399,3 @@ function page_extend_navigation($navigation, $course, $module, $cm) {
|
||||
*/
|
||||
$navigation->nodetype = navigation_node::NODETYPE_LEAF;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function extends the settings navigation block for the site.
|
||||
*
|
||||
* It is safe to rely on PAGE here as we will only ever be within the module
|
||||
* context when this is called.
|
||||
*
|
||||
* @param settings_navigation $settings
|
||||
* @param stdClass $module
|
||||
*/
|
||||
function page_extend_settings_navigation($settings, $module) {
|
||||
global $PAGE, $CFG;
|
||||
|
||||
// Add a page node to the settings navigation.
|
||||
$pagenavkey = $settings->add(get_string('pageadministration', 'page'));
|
||||
$pagenav = $settings->get($pagenavkey);
|
||||
$pagenav->forceopen = true;
|
||||
|
||||
// If the user has the capability add an update this module link for the page instance
|
||||
if (has_capability('moodle/course:manageactivities', $PAGE->cm->context)) {
|
||||
$url = new moodle_url('/course/mod.php', array('update'=>$PAGE->cm->id, 'return'=>true, 'sesskey'=>sesskey()));
|
||||
$pagenav->add(get_string('updatethis', '', get_string('modulename', 'page')), $url);
|
||||
}
|
||||
|
||||
// Check if any children have been added. If not remove the node to save on clutter.
|
||||
if (count($pagenav->children)<1) {
|
||||
$settings->remove_child($pagenavkey);
|
||||
}
|
||||
}
|
||||
+9
-22
@@ -1614,46 +1614,33 @@ function quiz_extend_navigation($navigation, $course, $module, $cm) {
|
||||
* It is safe to rely on PAGE here as we will only ever be within the module
|
||||
* context when this is called
|
||||
*
|
||||
* @param navigation_node $settings
|
||||
* @param stdClass $module
|
||||
* @param settings_navigation $settings
|
||||
* @param navigation_node $quiznode
|
||||
*/
|
||||
function quiz_extend_settings_navigation($settings, $module) {
|
||||
global $PAGE, $CFG, $OUTPUT;
|
||||
|
||||
$quiznavkey = $settings->add(get_string('quizadministration', 'quiz'));
|
||||
$quiznav = $settings->get($quiznavkey);
|
||||
$quiznav->forceopen = true;
|
||||
function quiz_extend_settings_navigation($settings, $quiznode) {
|
||||
global $PAGE, $CFG;
|
||||
|
||||
if (has_capability('mod/quiz:view', $PAGE->cm->context)) {
|
||||
$url = new moodle_url('/mod/quiz/view.php', array('id'=>$PAGE->cm->id));
|
||||
$quiznav->add(get_string('info', 'quiz'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/info', ''));
|
||||
$quiznode->add(get_string('info', 'quiz'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/info', ''));
|
||||
}
|
||||
if (has_capability('mod/quiz:viewreports', $PAGE->cm->context)) {
|
||||
$url = new moodle_url('/mod/quiz/report.php', array('q'=>$PAGE->cm->instance));
|
||||
$reportkey = $quiznav->add(get_string('results', 'quiz'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', ''));
|
||||
$reportkey = $quiznode->add(get_string('results', 'quiz'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', ''));
|
||||
|
||||
require_once($CFG->dirroot.'/mod/quiz/report/reportlib.php');
|
||||
$reportlist = quiz_report_list($PAGE->cm->context);
|
||||
foreach ($reportlist as $report) {
|
||||
$url = new moodle_url('/mod/quiz/report.php', array('q'=>$PAGE->cm->instance, 'mode'=>$report));
|
||||
$quiznav->get($reportkey)->add(get_string($report, 'quiz_'.$report), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/item', ''));
|
||||
$quiznode->get($reportkey)->add(get_string($report, 'quiz_'.$report), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/item', ''));
|
||||
}
|
||||
}
|
||||
if (has_capability('mod/quiz:preview', $PAGE->cm->context)) {
|
||||
$url = new moodle_url('/mod/quiz/startattempt.php', array('cmid'=>$PAGE->cm->id, 'sesskey'=>sesskey()));
|
||||
$quiznav->add(get_string('preview', 'quiz'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('t/preview', ''));
|
||||
$quiznode->add(get_string('preview', 'quiz'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('t/preview', ''));
|
||||
}
|
||||
if (has_capability('mod/quiz:manage', $PAGE->cm->context)) {
|
||||
$url = new moodle_url('/mod/quiz/edit.php', array('cmid'=>$PAGE->cm->id));
|
||||
$quiznav->add(get_string('edit'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('t/edit', ''));
|
||||
$quiznode->add(get_string('edit'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('t/edit', ''));
|
||||
}
|
||||
|
||||
if (has_capability('moodle/course:manageactivities', $PAGE->cm->context)) {
|
||||
$url = new moodle_url('/course/mod.php', array('update' => $PAGE->cm->id, 'return' => true, 'sesskey' => sesskey()));
|
||||
$quiznav->add(get_string('updatethis', '', get_string('modulename', 'quiz')), $url);
|
||||
}
|
||||
|
||||
if (count($quiznav->children)<1) {
|
||||
$settings->remove_child($quiznavkey);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -954,33 +954,4 @@ function scorm_extend_navigation($navigation, $course, $module, $cm) {
|
||||
* you content.
|
||||
*/
|
||||
$navigation->nodetype = navigation_node::NODETYPE_LEAF;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function extends the settings navigation block for the site.
|
||||
*
|
||||
* It is safe to rely on PAGE here as we will only ever be within the module
|
||||
* context when this is called.
|
||||
*
|
||||
* @param settings_navigation $settings
|
||||
* @param stdClass $module
|
||||
*/
|
||||
function scorm_extend_settings_navigation($settings, $module) {
|
||||
global $PAGE, $CFG;
|
||||
|
||||
// Add a scorm node to the settings navigation.
|
||||
$scormnavkey = $settings->add(get_string('scormadministration', 'scorm'));
|
||||
$scormnav = $settings->get($scormnavkey);
|
||||
$scormnav->forceopen = true;
|
||||
|
||||
// If the user has the capability add an update this module link for the scorm instance
|
||||
if (has_capability('moodle/course:manageactivities', $PAGE->cm->context)) {
|
||||
$url = new moodle_url('/course/mod.php', array('update'=>$PAGE->cm->id, 'return'=>true, 'sesskey'=>sesskey()));
|
||||
$scormnav->add(get_string('updatethis', '', get_string('modulename', 'scorm')), $url);
|
||||
}
|
||||
|
||||
// Check if any children have been added. If not remove the node to save on clutter.
|
||||
if (count($scormnav->children)<1) {
|
||||
$settings->remove_child($scormnavkey);
|
||||
}
|
||||
}
|
||||
+10
-37
@@ -819,56 +819,29 @@ function survey_extend_navigation($navigation, $course, $module, $cm) {
|
||||
* context when this is called
|
||||
*
|
||||
* @param navigation_node $settings
|
||||
* @param stdClass $module
|
||||
* @param navigation_node $surveynode
|
||||
*/
|
||||
function survey_extend_settings_navigation($settings, $module) {
|
||||
global $PAGE, $CFG, $OUTPUT;
|
||||
|
||||
$surveynavkey = $settings->add(get_string('surveyadministration', 'survey'));
|
||||
$surveynav = $settings->get($surveynavkey);
|
||||
$surveynav->forceopen = true;
|
||||
|
||||
$strreport = get_string("report", "survey");
|
||||
$strsurvey = get_string("modulename", "survey");
|
||||
$strsurveys = get_string("modulenameplural", "survey");
|
||||
$strsummary = get_string("summary", "survey");
|
||||
$strscales = get_string("scales", "survey");
|
||||
$strquestion = get_string("question", "survey");
|
||||
$strquestions = get_string("questions", "survey");
|
||||
$strdownload = get_string("download", "survey");
|
||||
$strallscales = get_string("allscales", "survey");
|
||||
$strallquestions = get_string("allquestions", "survey");
|
||||
$strselectedquestions = get_string("selectedquestions", "survey");
|
||||
$strseemoredetail = get_string("seemoredetail", "survey");
|
||||
$strnotes = get_string("notes", "survey");
|
||||
function survey_extend_settings_navigation($settings, $surveynode) {
|
||||
global $PAGE;
|
||||
|
||||
if (has_capability('mod/survey:readresponses', $PAGE->cm->context)) {
|
||||
$key = $surveynav->add(get_string("responsereports", "survey"));
|
||||
$key = $surveynode->add(get_string("responsereports", "survey"));
|
||||
|
||||
$url = new moodle_url('/mod/survey/report.php', array('id' => $PAGE->cm->id, 'action'=>'summary'));
|
||||
$surveynav->get($key)->add(get_string("summary", "survey"), $url);
|
||||
$surveynode->get($key)->add(get_string("summary", "survey"), $url);
|
||||
|
||||
$url = new moodle_url('/mod/survey/report.php', array('id' => $PAGE->cm->id, 'action'=>'scales'));
|
||||
$surveynav->get($key)->add(get_string("scales", "survey"), $url);
|
||||
$surveynode->get($key)->add(get_string("scales", "survey"), $url);
|
||||
|
||||
$url = new moodle_url('/mod/survey/report.php', array('id' => $PAGE->cm->id, 'action'=>'questions'));
|
||||
$surveynav->get($key)->add(get_string("question", "survey"), $url);
|
||||
$surveynode->get($key)->add(get_string("question", "survey"), $url);
|
||||
|
||||
$url = new moodle_url('/mod/survey/report.php', array('id' => $PAGE->cm->id, 'action'=>'students'));
|
||||
$surveynav->get($key)->add(get_string('participants'), $url);
|
||||
$surveynode->get($key)->add(get_string('participants'), $url);
|
||||
|
||||
if (has_capability('mod/survey:download', $PAGE->cm->context)) {
|
||||
$url = new moodle_url('/mod/survey/report.php', array('id' => $PAGE->cm->id, 'action'=>'download'));
|
||||
$surveynav->add(get_string('downloadresults', 'survey'), $url);
|
||||
$surveynode->add(get_string('downloadresults', 'survey'), $url);
|
||||
}
|
||||
}
|
||||
|
||||
if (has_capability('moodle/course:manageactivities', $PAGE->cm->context)) {
|
||||
$url = new moodle_url('/course/mod.php', array('update' => $PAGE->cm->id, 'return' => true, 'sesskey' => sesskey()));
|
||||
$surveynav->add(get_string('updatethis', '', get_string('modulename', 'quiz')), $url);
|
||||
}
|
||||
|
||||
if (count($surveynav->children)<1) {
|
||||
$settings->remove_child($surveynavkey);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -304,33 +304,4 @@ function url_extend_navigation($navigation, $course, $module, $cm) {
|
||||
* you content.
|
||||
*/
|
||||
$navigation->nodetype = navigation_node::NODETYPE_LEAF;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function extends the settings navigation block for the site.
|
||||
*
|
||||
* It is safe to rely on PAGE here as we will only ever be within the module
|
||||
* context when this is called.
|
||||
*
|
||||
* @param settings_navigation $settings
|
||||
* @param stdClass $module
|
||||
*/
|
||||
function url_extend_settings_navigation($settings, $module) {
|
||||
global $PAGE, $CFG;
|
||||
|
||||
// Add a url node to the settings navigation.
|
||||
$urlnavkey = $settings->add(get_string('urladministration', 'url'));
|
||||
$urlnav = $settings->get($urlnavkey);
|
||||
$urlnav->forceopen = true;
|
||||
|
||||
// If the user has the capability add an update this module link for the url instance
|
||||
if (has_capability('moodle/course:manageactivities', $PAGE->cm->context)) {
|
||||
$url = new moodle_url('/course/mod.php', array('update'=>$PAGE->cm->id, 'return'=>true, 'sesskey'=>sesskey()));
|
||||
$urlnav->add(get_string('updatethis', '', get_string('modulename', 'url')), $url);
|
||||
}
|
||||
|
||||
// Check if any children have been added. If not remove the node to save on clutter.
|
||||
if (count($urlnav->children)<1) {
|
||||
$settings->remove_child($urlnavkey);
|
||||
}
|
||||
}
|
||||
+3
-11
@@ -693,21 +693,13 @@ function workshop_extend_navigation(navigation_node $navref, stdclass $course, s
|
||||
* so it is safe to rely on the $PAGE.
|
||||
*
|
||||
* @param settings_navigation $settingsnav {@link settings_navigation}
|
||||
* @param stdclass $module
|
||||
* @return void|mixed The key to the modules branch
|
||||
* @param navigation_node $workshopnode {@link navigation_node}
|
||||
*/
|
||||
function workshop_extend_settings_navigation(settings_navigation $settingsnav, stdclass $module=null) {
|
||||
global $CFG, $PAGE;
|
||||
function workshop_extend_settings_navigation(settings_navigation $settingsnav, navigation_node $workshopnode=null) {
|
||||
global $PAGE;
|
||||
|
||||
$workshopkey = $settingsnav->add(get_string('workshopadministration', 'workshop'));
|
||||
$workshopnode = $settingsnav->get($workshopkey);
|
||||
$workshopnode->forceopen = true;
|
||||
//$workshopobject = $DB->get_record("workshop", array("id" => $PAGE->cm->instance));
|
||||
|
||||
if (has_capability('moodle/course:manageactivities', $PAGE->cm->context)) {
|
||||
$url = new moodle_url('/course/mod.php', array('update' => $PAGE->cm->id, 'return' => true, 'sesskey' => sesskey()));
|
||||
$workshopnode->add(get_string('updatethis', '', get_string('modulename', 'workshop')), $url, settings_navigation::TYPE_SETTING);
|
||||
}
|
||||
if (has_capability('mod/workshop:editdimensions', $PAGE->cm->context)) {
|
||||
$url = new moodle_url('/mod/workshop/editform.php', array('cmid' => $PAGE->cm->id));
|
||||
$workshopnode->add(get_string('editassessmentform', 'workshop'), $url, settings_navigation::TYPE_SETTING);
|
||||
|
||||
Reference in New Issue
Block a user