// Get the base URL for this and related pages into a convenient variable. $baseurl = new moodle_url('/admin/roles/define.php', array('action' => $action, 'roleid' => $roleid)); $manageurl = new moodle_url('/admin/roles/manage.php'); if ($return === 'manage') { $returnurl = $manageurl; } else { $returnurl = new moodle_url('/admin/roles/define.php', array('action' => 'view', 'roleid' => $roleid)); } // Check access permissions. $systemcontext = context_system::instance(); require_login(); require_capability('moodle/role:manage', $systemcontext); admin_externalpage_setup('defineroles', '', array('action' => $action, 'roleid' => $roleid), new moodle_url('/admin/roles/define.php')); // Export role. if ($action === 'export') { core_role_preset::send_export_xml($roleid); die; } // Handle the toggle advanced mode button. $showadvanced = get_user_preferences('definerole_showadvanced', false); if (optional_param('toggleadvanced', false, PARAM_BOOL)) { $showadvanced = !$showadvanced; set_user_preference('definerole_showadvanced', $showadvanced); } // Get some basic data we are going to need. $roles = get_all_roles(); $rolenames = role_fix_names($roles, $systemcontext, ROLENAME_ORIGINAL); $rolescount = count($roles); if ($action === 'add') { $title = get_string('addinganewrole', 'core_role'); } else {