Is this a bad thing to do?

Is this a bad thing to do?

by Michael Hughes -
Number of replies: 0
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
//extends_settings_navigation
function local_strathast_extends_settings_navigation(navigation_node $settingsnav, $context) {
	global $CFG, $PAGE, $COURSE;
	
	$courseadmin = $settingsnav->find('courseadmin', navigation_node::TYPE_COURSE);//->get(0);
	if (!is_null($courseadmin) and method_exists($courseadmin, 'add')) {
		if (
			has_capability('local/strathast:viewactivityschedule', $context) ||
			has_capability('local/strathast:viewactivityschedule', $context)
		) {
			local_strathast_add_navigation_node($courseadmin);
		}
	}
	
	 //This is all for AST-7
	$modadmin = $settingsnav->get(0);//,navigation_node::TYPE_ACTIVITY);
	if (!is_null($modadmin) and method_exists($modadmin,'add')) {
		$modadmin->add(
				'Stagger Deadlines',
				new moodle_url(
						'/local/strathast/staggeractivity.php', array(
								'courseid' => $COURSE->id,
								'cmid' => $PAGE->cm->id//$settingsnav->page->cm->id																
						)
					)
			);
	} else {
		debugging('couldnt find mod');
	}
	
}

I have a local plugin that I want to hook in to the activity settings part of the settings block to allow users to access the local plugin's functions whilst passing in the activity's details.

If anyone has a better way of doing this I'd be really grateful to hear of them (I would have used the $settingsnav->page->cm->id to get the coursemodule id but this is protected...)

Average of ratings: Useful (1)